aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CREDITS11
-rw-r--r--Documentation/DocBook/Makefile8
-rw-r--r--Documentation/DocBook/deviceiobook.tmpl19
-rw-r--r--Documentation/RCU/whatisRCU.txt4
-rw-r--r--Documentation/arm/Booting2
-rw-r--r--Documentation/arm/README2
-rw-r--r--Documentation/arm/Samsung-S3C24XX/Overview.txt42
-rw-r--r--Documentation/arm/Setup2
-rw-r--r--Documentation/cpusets.txt76
-rw-r--r--Documentation/feature-removal-schedule.txt41
-rw-r--r--Documentation/filesystems/9p.txt (renamed from Documentation/filesystems/v9fs.txt)21
-rw-r--r--Documentation/filesystems/ntfs.txt5
-rw-r--r--Documentation/filesystems/proc.txt6
-rw-r--r--Documentation/filesystems/udf.txt14
-rw-r--r--Documentation/filesystems/vfs.txt217
-rw-r--r--Documentation/firmware_class/firmware_sample_driver.c3
-rw-r--r--Documentation/firmware_class/firmware_sample_firmware_class.c1
-rw-r--r--Documentation/hwmon/w83627hf4
-rw-r--r--Documentation/hwmon/w83781d24
-rw-r--r--Documentation/i2c/busses/i2c-piix42
-rw-r--r--Documentation/i2c/busses/scx200_acb5
-rw-r--r--Documentation/kbuild/makefiles.txt172
-rw-r--r--Documentation/kbuild/modules.txt98
-rw-r--r--Documentation/kernel-parameters.txt28
-rw-r--r--Documentation/networking/packet_mmap.txt10
-rw-r--r--Documentation/networking/pktgen.txt20
-rw-r--r--Documentation/networking/ray_cs.txt2
-rw-r--r--Documentation/nfsroot.txt17
-rw-r--r--Documentation/power/swsusp.txt51
-rw-r--r--Documentation/power/userland-swsusp.txt149
-rw-r--r--Documentation/power/video.txt74
-rw-r--r--Documentation/powerpc/booting-without-of.txt72
-rw-r--r--Documentation/powerpc/eeh-pci-error-recovery.txt15
-rw-r--r--Documentation/powerpc/hvcs.txt4
-rw-r--r--Documentation/s390/driver-model.txt15
-rw-r--r--Documentation/serial-console.txt11
-rw-r--r--Documentation/smart-config.txt4
-rw-r--r--Documentation/sound/oss/Introduction2
-rw-r--r--Documentation/sound/oss/cs46xx16
-rw-r--r--Documentation/video4linux/CQcam.txt182
-rw-r--r--Documentation/video4linux/README.cpia4
-rw-r--r--Documentation/video4linux/Zoran108
-rw-r--r--Documentation/video4linux/bttv/ICs4
-rw-r--r--Documentation/video4linux/bttv/PROBLEMS16
-rw-r--r--Documentation/video4linux/bttv/README.quirks4
-rw-r--r--Documentation/video4linux/bttv/THANKS4
-rw-r--r--Documentation/video4linux/radiotrack.txt16
-rw-r--r--Documentation/video4linux/w9966.txt2
-rw-r--r--Documentation/video4linux/zr36120.txt4
-rw-r--r--Documentation/w1/masters/ds248231
-rw-r--r--MAINTAINERS57
-rw-r--r--Makefile201
-rw-r--r--arch/arm/Kconfig16
-rw-r--r--arch/arm/Makefile6
-rw-r--r--arch/arm/boot/Makefile5
-rw-r--r--arch/arm/boot/bootp/Makefile5
-rw-r--r--arch/arm/common/Makefile1
-rw-r--r--arch/arm/common/dmabounce.c2
-rw-r--r--arch/arm/common/locomo.c49
-rw-r--r--arch/arm/common/sa1111.c46
-rw-r--r--arch/arm/common/scoop.c6
-rw-r--r--arch/arm/common/uengine.c (renamed from arch/arm/mach-ixp2000/uengine.c)2
-rw-r--r--arch/arm/common/vic.c49
-rw-r--r--arch/arm/configs/enp2611_defconfig974
-rw-r--r--arch/arm/configs/ep93xx_defconfig (renamed from arch/arm/configs/ixdp2800_defconfig)554
-rw-r--r--arch/arm/configs/ixdp2401_defconfig976
-rw-r--r--arch/arm/configs/ixdp2801_defconfig976
-rw-r--r--arch/arm/configs/ixp2000_defconfig (renamed from arch/arm/configs/ixdp2400_defconfig)61
-rw-r--r--arch/arm/configs/s3c2410_defconfig147
-rw-r--r--arch/arm/kernel/apm.c4
-rw-r--r--arch/arm/kernel/bios32.c4
-rw-r--r--arch/arm/kernel/debug.S1
-rw-r--r--arch/arm/kernel/ecard.c4
-rw-r--r--arch/arm/kernel/entry-armv.S2
-rw-r--r--arch/arm/kernel/head.S7
-rw-r--r--arch/arm/kernel/irq.c11
-rw-r--r--arch/arm/lib/delay.S20
-rw-r--r--arch/arm/lib/io-acorn.S1
-rw-r--r--arch/arm/mach-at91rm9200/clock.c85
-rw-r--r--arch/arm/mach-at91rm9200/gpio.c4
-rw-r--r--arch/arm/mach-at91rm9200/time.c4
-rw-r--r--arch/arm/mach-ep93xx/Kconfig21
-rw-r--r--arch/arm/mach-ep93xx/Makefile10
-rw-r--r--arch/arm/mach-ep93xx/Makefile.boot2
-rw-r--r--arch/arm/mach-ep93xx/core.c374
-rw-r--r--arch/arm/mach-ep93xx/gesbc9312.c40
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c118
-rw-r--r--arch/arm/mach-footbridge/dc21285.c4
-rw-r--r--arch/arm/mach-integrator/impd1.c7
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c4
-rw-r--r--arch/arm/mach-iop3xx/iq31244-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80321-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80331-pci.c4
-rw-r--r--arch/arm/mach-iop3xx/iq80332-pci.c4
-rw-r--r--arch/arm/mach-ixp2000/Kconfig9
-rw-r--r--arch/arm/mach-ixp2000/Makefile2
-rw-r--r--arch/arm/mach-ixp2000/core.c13
-rw-r--r--arch/arm/mach-ixp2000/ixdp2x01.c20
-rw-r--r--arch/arm/mach-ixp4xx/common-pci.c3
-rw-r--r--arch/arm/mach-ixp4xx/common.c5
-rw-r--r--arch/arm/mach-lh7a40x/common.h1
-rw-r--r--arch/arm/mach-lh7a40x/irq-kev7a400.c1
-rw-r--r--arch/arm/mach-lh7a40x/irq-lh7a400.c2
-rw-r--r--arch/arm/mach-lh7a40x/irq-lh7a404.c3
-rw-r--r--arch/arm/mach-lh7a40x/irq-lpd7a40x.c1
-rw-r--r--arch/arm/mach-pxa/Makefile2
-rw-r--r--arch/arm/mach-pxa/clock.c124
-rw-r--r--arch/arm/mach-pxa/corgi.c1
-rw-r--r--arch/arm/mach-pxa/leds-mainstone.c6
-rw-r--r--arch/arm/mach-pxa/poodle.c1
-rw-r--r--arch/arm/mach-pxa/spitz.c1
-rw-r--r--arch/arm/mach-pxa/tosa.c1
-rw-r--r--arch/arm/mach-s3c2410/Kconfig7
-rw-r--r--arch/arm/mach-s3c2410/Makefile1
-rw-r--r--arch/arm/mach-s3c2410/clock.c178
-rw-r--r--arch/arm/mach-s3c2410/clock.h8
-rw-r--r--arch/arm/mach-s3c2410/cpu.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-osiris.c294
-rw-r--r--arch/arm/mach-s3c2410/s3c2440-clock.c89
-rw-r--r--arch/arm/mach-s3c2410/time.c8
-rw-r--r--arch/arm/mach-sa1100/Makefile2
-rw-r--r--arch/arm/mach-sa1100/clock.c132
-rw-r--r--arch/arm/mach-sa1100/collie.c30
-rw-r--r--arch/arm/mach-versatile/core.c2
-rw-r--r--arch/arm/mm/Kconfig2
-rw-r--r--arch/arm/mm/init.c1
-rw-r--r--arch/arm/mm/ioremap.c1
-rw-r--r--arch/arm/mm/proc-arm1020.S1
-rw-r--r--arch/arm/mm/proc-arm1020e.S1
-rw-r--r--arch/arm/mm/proc-arm720.S1
-rw-r--r--arch/arm/mm/proc-arm920.S1
-rw-r--r--arch/arm/mm/proc-arm922.S1
-rw-r--r--arch/arm/mm/proc-arm925.S1
-rw-r--r--arch/arm/mm/proc-arm926.S1
-rw-r--r--arch/arm/mm/proc-xscale.S1
-rw-r--r--arch/arm/oprofile/common.c34
-rw-r--r--arch/arm/oprofile/op_counter.h2
-rw-r--r--arch/arm/vfp/entry.S1
-rw-r--r--arch/arm26/Makefile7
-rw-r--r--arch/arm26/boot/Makefile5
-rw-r--r--arch/cris/arch-v32/drivers/cryptocop.c2
-rw-r--r--arch/cris/kernel/irq.c10
-rw-r--r--arch/cris/kernel/process.c3
-rw-r--r--arch/frv/kernel/gdb-stub.c2
-rw-r--r--arch/frv/kernel/irq.c10
-rw-r--r--arch/h8300/kernel/process.c4
-rw-r--r--arch/i386/Kconfig26
-rw-r--r--arch/i386/Kconfig.debug13
-rw-r--r--arch/i386/Makefile4
-rw-r--r--arch/i386/boot/edd.S2
-rw-r--r--arch/i386/kernel/Makefile2
-rw-r--r--arch/i386/kernel/alternative.c321
-rw-r--r--arch/i386/kernel/apic.c1
-rw-r--r--arch/i386/kernel/apm.c2
-rw-r--r--arch/i386/kernel/cpu/centaur.c1
-rw-r--r--arch/i386/kernel/cpu/common.c47
-rw-r--r--arch/i386/kernel/cpu/cpufreq/powernow-k8.c8
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-smi.c4
-rw-r--r--arch/i386/kernel/cpu/intel.c12
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c4
-rw-r--r--arch/i386/kernel/cpu/proc.c2
-rw-r--r--arch/i386/kernel/crash.c2
-rw-r--r--arch/i386/kernel/dmi_scan.c2
-rw-r--r--arch/i386/kernel/efi.c2
-rw-r--r--arch/i386/kernel/entry.S4
-rw-r--r--arch/i386/kernel/head.S5
-rw-r--r--arch/i386/kernel/io_apic.c25
-rw-r--r--arch/i386/kernel/kprobes.c4
-rw-r--r--arch/i386/kernel/module.c32
-rw-r--r--arch/i386/kernel/mpparse.c7
-rw-r--r--arch/i386/kernel/nmi.c6
-rw-r--r--arch/i386/kernel/process.c2
-rw-r--r--arch/i386/kernel/ptrace.c4
-rw-r--r--arch/i386/kernel/semaphore.c8
-rw-r--r--arch/i386/kernel/setup.c140
-rw-r--r--arch/i386/kernel/signal.c7
-rw-r--r--arch/i386/kernel/smpboot.c36
-rw-r--r--arch/i386/kernel/topology.c9
-rw-r--r--arch/i386/kernel/traps.c57
-rw-r--r--arch/i386/kernel/vmlinux.lds.S23
-rw-r--r--arch/i386/kernel/vsyscall-sysenter.S3
-rw-r--r--arch/i386/mach-es7000/es7000.h5
-rw-r--r--arch/i386/mach-es7000/es7000plat.c6
-rw-r--r--arch/i386/mach-visws/reboot.c1
-rw-r--r--arch/i386/mm/fault.c210
-rw-r--r--arch/i386/mm/init.c45
-rw-r--r--arch/i386/oprofile/nmi_int.c7
-rw-r--r--arch/i386/pci/Makefile2
-rw-r--r--arch/i386/pci/common.c32
-rw-r--r--arch/i386/pci/direct.c15
-rw-r--r--arch/i386/pci/init.c25
-rw-r--r--arch/i386/pci/mmconfig.c11
-rw-r--r--arch/i386/pci/pcbios.c4
-rw-r--r--arch/i386/pci/pci.h3
-rw-r--r--arch/ia64/Makefile5
-rw-r--r--arch/ia64/hp/sim/simserial.c7
-rw-r--r--arch/ia64/ia32/sys_ia32.c14
-rw-r--r--arch/ia64/kernel/setup.c1
-rw-r--r--arch/ia64/sn/kernel/bte.c2
-rw-r--r--arch/ia64/sn/pci/tioca_provider.c2
-rw-r--r--arch/m32r/Kconfig.debug2
-rw-r--r--arch/m32r/Makefile5
-rw-r--r--arch/m32r/kernel/irq.c10
-rw-r--r--arch/m68k/bvme6000/rtc.c4
-rw-r--r--arch/m68k/kernel/process.c2
-rw-r--r--arch/m68knommu/kernel/process.c2
-rw-r--r--arch/mips/kernel/irq.c10
-rw-r--r--arch/mips/kernel/smp.c4
-rw-r--r--arch/mips/kernel/sysirix.c22
-rw-r--r--arch/mips/mm/dma-ip32.c6
-rw-r--r--arch/mips/sgi-ip27/ip27-irq.c5
-rw-r--r--arch/parisc/kernel/process.c5
-rw-r--r--arch/parisc/kernel/smp.c25
-rw-r--r--arch/powerpc/Kconfig38
-rw-r--r--arch/powerpc/Makefile4
-rw-r--r--arch/powerpc/boot/install.sh2
-rw-r--r--arch/powerpc/boot/main.c4
-rw-r--r--arch/powerpc/configs/mpc8540_ads_defconfig721
-rw-r--r--arch/powerpc/kernel/asm-offsets.c3
-rw-r--r--arch/powerpc/kernel/cputable.c12
-rw-r--r--arch/powerpc/kernel/entry_64.S11
-rw-r--r--arch/powerpc/kernel/firmware.c25
-rw-r--r--arch/powerpc/kernel/head_44x.S2
-rw-r--r--arch/powerpc/kernel/head_64.S11
-rw-r--r--arch/powerpc/kernel/head_8xx.S2
-rw-r--r--arch/powerpc/kernel/head_booke.h363
-rw-r--r--arch/powerpc/kernel/head_fsl_booke.S6
-rw-r--r--arch/powerpc/kernel/iomap.c2
-rw-r--r--arch/powerpc/kernel/iommu.c1
-rw-r--r--arch/powerpc/kernel/irq.c37
-rw-r--r--arch/powerpc/kernel/kprobes.c5
-rw-r--r--arch/powerpc/kernel/of_device.c5
-rw-r--r--arch/powerpc/kernel/pci_iommu.c1
-rw-r--r--arch/powerpc/kernel/ppc_ksyms.c1
-rw-r--r--arch/powerpc/kernel/process.c9
-rw-r--r--arch/powerpc/kernel/prom.c4
-rw-r--r--arch/powerpc/kernel/ptrace-common.h2
-rw-r--r--arch/powerpc/kernel/rtas-proc.c1
-rw-r--r--arch/powerpc/kernel/rtas_pci.c2
-rw-r--r--arch/powerpc/kernel/setup-common.c5
-rw-r--r--arch/powerpc/kernel/setup_32.c5
-rw-r--r--arch/powerpc/kernel/setup_64.c2
-rw-r--r--arch/powerpc/kernel/signal_64.c2
-rw-r--r--arch/powerpc/kernel/smp.c4
-rw-r--r--arch/powerpc/kernel/time.c241
-rw-r--r--arch/powerpc/kernel/vdso.c2
-rw-r--r--arch/powerpc/lib/copypage_64.S2
-rw-r--r--arch/powerpc/lib/copyuser_64.S2
-rw-r--r--arch/powerpc/lib/e2a.c14
-rw-r--r--arch/powerpc/lib/memcpy_64.S2
-rw-r--r--arch/powerpc/lib/rheap.c2
-rw-r--r--arch/powerpc/mm/fault.c2
-rw-r--r--arch/powerpc/mm/hash_low_32.S2
-rw-r--r--arch/powerpc/mm/hash_utils_64.c32
-rw-r--r--arch/powerpc/mm/init_64.c48
-rw-r--r--arch/powerpc/mm/lmb.c16
-rw-r--r--arch/powerpc/mm/mem.c3
-rw-r--r--arch/powerpc/mm/mmap.c2
-rw-r--r--arch/powerpc/mm/numa.c160
-rw-r--r--arch/powerpc/mm/slb_low.S2
-rw-r--r--arch/powerpc/mm/stab.c4
-rw-r--r--arch/powerpc/mm/tlb_64.c2
-rw-r--r--arch/powerpc/oprofile/op_model_power4.c3
-rw-r--r--arch/powerpc/platforms/83xx/Makefile4
-rw-r--r--arch/powerpc/platforms/83xx/misc.c55
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.c89
-rw-r--r--arch/powerpc/platforms/83xx/mpc834x_sys.h2
-rw-r--r--arch/powerpc/platforms/83xx/mpc83xx.h5
-rw-r--r--arch/powerpc/platforms/83xx/pci.c21
-rw-r--r--arch/powerpc/platforms/85xx/Kconfig74
-rw-r--r--arch/powerpc/platforms/85xx/Makefile6
-rw-r--r--arch/powerpc/platforms/85xx/misc.c31
-rw-r--r--arch/powerpc/platforms/85xx/mpc8540_ads.h36
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx.h18
-rw-r--r--arch/powerpc/platforms/85xx/mpc85xx_ads.c244
-rw-r--r--arch/powerpc/platforms/85xx/pci.c96
-rw-r--r--arch/powerpc/platforms/Makefile2
-rw-r--r--arch/powerpc/platforms/chrp/pegasos_eth.c2
-rw-r--r--arch/powerpc/platforms/chrp/setup.c2
-rw-r--r--arch/powerpc/platforms/chrp/time.c2
-rw-r--r--arch/powerpc/platforms/iseries/mf.c112
-rw-r--r--arch/powerpc/platforms/iseries/setup.c72
-rw-r--r--arch/powerpc/platforms/maple/time.c2
-rw-r--r--arch/powerpc/platforms/powermac/cpufreq_32.c2
-rw-r--r--arch/powerpc/platforms/powermac/feature.c2
-rw-r--r--arch/powerpc/platforms/powermac/nvram.c2
-rw-r--r--arch/powerpc/platforms/powermac/setup.c8
-rw-r--r--arch/powerpc/platforms/powermac/smp.c4
-rw-r--r--arch/powerpc/platforms/pseries/Makefile3
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c103
-rw-r--r--arch/powerpc/platforms/pseries/firmware.h17
-rw-r--r--arch/powerpc/platforms/pseries/hvCall.S2
-rw-r--r--arch/powerpc/platforms/pseries/iommu.c4
-rw-r--r--arch/powerpc/platforms/pseries/pci.c2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c67
-rw-r--r--arch/powerpc/platforms/pseries/smp.c2
-rw-r--r--arch/powerpc/platforms/pseries/xics.c3
-rw-r--r--arch/powerpc/sysdev/dart_iommu.c2
-rw-r--r--arch/powerpc/sysdev/dcr.S2
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c292
-rw-r--r--arch/powerpc/sysdev/ipic.h2
-rw-r--r--arch/powerpc/xmon/xmon.c30
-rw-r--r--arch/ppc/4xx_io/serial_sicc.c5
-rw-r--r--arch/ppc/8xx_io/commproc.c6
-rw-r--r--arch/ppc/8xx_io/cs4218_tdm.c10
-rw-r--r--arch/ppc/Kconfig47
-rw-r--r--arch/ppc/Kconfig.debug2
-rw-r--r--arch/ppc/Makefile2
-rw-r--r--arch/ppc/amiga/amiints.c2
-rw-r--r--arch/ppc/amiga/bootinfo.c2
-rw-r--r--arch/ppc/amiga/cia.c2
-rw-r--r--arch/ppc/amiga/config.c2
-rw-r--r--arch/ppc/amiga/ints.c2
-rw-r--r--arch/ppc/boot/Makefile5
-rw-r--r--arch/ppc/boot/common/Makefile3
-rw-r--r--arch/ppc/boot/common/bootinfo.c2
-rw-r--r--arch/ppc/boot/common/misc-common.c2
-rw-r--r--arch/ppc/boot/common/ns16550.c3
-rw-r--r--arch/ppc/boot/common/serial_stub.c2
-rw-r--r--arch/ppc/boot/common/util.S2
-rw-r--r--arch/ppc/boot/include/mpc10x.h2
-rw-r--r--arch/ppc/boot/openfirmware/Makefile7
-rw-r--r--arch/ppc/boot/simple/Makefile1
-rw-r--r--arch/ppc/boot/simple/cpc700_memory.c2
-rw-r--r--arch/ppc/boot/simple/embed_config.c7
-rw-r--r--arch/ppc/boot/simple/head.S9
-rw-r--r--arch/ppc/boot/simple/misc-chestnut.c2
-rw-r--r--arch/ppc/boot/simple/misc-cpci690.c2
-rw-r--r--arch/ppc/boot/simple/misc-ev64260.c2
-rw-r--r--arch/ppc/boot/simple/misc-ev64360.c1
-rw-r--r--arch/ppc/boot/simple/misc-katana.c2
-rw-r--r--arch/ppc/boot/simple/misc-mv64x60.c2
-rw-r--r--arch/ppc/boot/simple/misc-prep.c2
-rw-r--r--arch/ppc/boot/simple/misc-radstone_ppc7d.c2
-rw-r--r--arch/ppc/boot/simple/misc-spruce.c2
-rw-r--r--arch/ppc/boot/simple/misc.c2
-rw-r--r--arch/ppc/boot/simple/mpc10x_memory.c2
-rw-r--r--arch/ppc/boot/simple/mpc52xx_tty.c2
-rw-r--r--arch/ppc/boot/simple/mv64x60_tty.c2
-rw-r--r--arch/ppc/boot/simple/openbios.c2
-rw-r--r--arch/ppc/boot/simple/relocate.S2
-rw-r--r--arch/ppc/boot/utils/mkbugboot.c2
-rw-r--r--arch/ppc/configs/ml300_defconfig739
-rw-r--r--arch/ppc/configs/ml403_defconfig740
-rw-r--r--arch/ppc/kernel/head_44x.S2
-rw-r--r--arch/ppc/kernel/head_8xx.S2
-rw-r--r--arch/ppc/kernel/head_fsl_booke.S6
-rw-r--r--arch/ppc/kernel/setup.c10
-rw-r--r--arch/ppc/kernel/smp-tbsync.c3
-rw-r--r--arch/ppc/kernel/traps.c2
-rw-r--r--arch/ppc/lib/rheap.c2
-rw-r--r--arch/ppc/math-emu/math.c2
-rw-r--r--arch/ppc/mm/44x_mmu.c4
-rw-r--r--arch/ppc/mm/fault.c2
-rw-r--r--arch/ppc/mm/hashtable.S2
-rw-r--r--arch/ppc/platforms/4xx/Kconfig23
-rw-r--r--arch/ppc/platforms/4xx/Makefile4
-rw-r--r--arch/ppc/platforms/4xx/bamboo.c2
-rw-r--r--arch/ppc/platforms/4xx/bamboo.h2
-rw-r--r--arch/ppc/platforms/4xx/bubinga.h2
-rw-r--r--arch/ppc/platforms/4xx/cpci405.c2
-rw-r--r--arch/ppc/platforms/4xx/ebony.c2
-rw-r--r--arch/ppc/platforms/4xx/ebony.h2
-rw-r--r--arch/ppc/platforms/4xx/ep405.c2
-rw-r--r--arch/ppc/platforms/4xx/ep405.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405ep.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm405ep.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gpr.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm405gpr.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440ep.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gp.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gx.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440gx.h2
-rw-r--r--arch/ppc/platforms/4xx/ibm440sp.c2
-rw-r--r--arch/ppc/platforms/4xx/ibm440sp.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmnp405h.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmnp405h.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmstb4.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmstb4.h2
-rw-r--r--arch/ppc/platforms/4xx/ibmstbx25.c2
-rw-r--r--arch/ppc/platforms/4xx/ibmstbx25.h2
-rw-r--r--arch/ppc/platforms/4xx/luan.c2
-rw-r--r--arch/ppc/platforms/4xx/luan.h2
-rw-r--r--arch/ppc/platforms/4xx/ocotea.c2
-rw-r--r--arch/ppc/platforms/4xx/ocotea.h2
-rw-r--r--arch/ppc/platforms/4xx/ppc440spe.c2
-rw-r--r--arch/ppc/platforms/4xx/ppc440spe.h2
-rw-r--r--arch/ppc/platforms/4xx/redwood5.c2
-rw-r--r--arch/ppc/platforms/4xx/redwood5.h2
-rw-r--r--arch/ppc/platforms/4xx/redwood6.c2
-rw-r--r--arch/ppc/platforms/4xx/redwood6.h2
-rw-r--r--arch/ppc/platforms/4xx/sycamore.c2
-rw-r--r--arch/ppc/platforms/4xx/sycamore.h2
-rw-r--r--arch/ppc/platforms/4xx/virtex-ii_pro.c60
-rw-r--r--arch/ppc/platforms/4xx/virtex-ii_pro.h99
-rw-r--r--arch/ppc/platforms/4xx/virtex.c56
-rw-r--r--arch/ppc/platforms/4xx/virtex.h35
-rw-r--r--arch/ppc/platforms/4xx/walnut.c2
-rw-r--r--arch/ppc/platforms/4xx/walnut.h2
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.c76
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml300.h6
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.c177
-rw-r--r--arch/ppc/platforms/4xx/xilinx_ml403.h49
-rw-r--r--arch/ppc/platforms/4xx/xparameters/xparameters.h37
-rw-r--r--arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h243
-rw-r--r--arch/ppc/platforms/4xx/yucca.c2
-rw-r--r--arch/ppc/platforms/4xx/yucca.h2
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.c2
-rw-r--r--arch/ppc/platforms/83xx/mpc834x_sys.h4
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc8540_ads.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc8555_cds.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc8560_ads.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_ads_common.h2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.c2
-rw-r--r--arch/ppc/platforms/85xx/mpc85xx_cds_common.h2
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.c2
-rw-r--r--arch/ppc/platforms/85xx/sbc8560.h2
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.c2
-rw-r--r--arch/ppc/platforms/85xx/sbc85xx.h2
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.c2
-rw-r--r--arch/ppc/platforms/85xx/stx_gp3.h2
-rw-r--r--arch/ppc/platforms/85xx/tqm85xx.c2
-rw-r--r--arch/ppc/platforms/85xx/tqm85xx.h2
-rw-r--r--arch/ppc/platforms/Makefile3
-rw-r--r--arch/ppc/platforms/apus_setup.c2
-rw-r--r--arch/ppc/platforms/chestnut.c2
-rw-r--r--arch/ppc/platforms/chestnut.h2
-rw-r--r--arch/ppc/platforms/chrp_pegasos_eth.c2
-rw-r--r--arch/ppc/platforms/chrp_setup.c2
-rw-r--r--arch/ppc/platforms/chrp_time.c2
-rw-r--r--arch/ppc/platforms/cpci690.c4
-rw-r--r--arch/ppc/platforms/cpci690.h2
-rw-r--r--arch/ppc/platforms/ev64260.c4
-rw-r--r--arch/ppc/platforms/ev64260.h2
-rw-r--r--arch/ppc/platforms/ev64360.c4
-rw-r--r--arch/ppc/platforms/ev64360.h2
-rw-r--r--arch/ppc/platforms/fads.h2
-rw-r--r--arch/ppc/platforms/gemini.h3
-rw-r--r--arch/ppc/platforms/gemini_prom.S2
-rw-r--r--arch/ppc/platforms/gemini_setup.c2
-rw-r--r--arch/ppc/platforms/hdpu.c5
-rw-r--r--arch/ppc/platforms/hdpu.h2
-rw-r--r--arch/ppc/platforms/katana.c7
-rw-r--r--arch/ppc/platforms/katana.h2
-rw-r--r--arch/ppc/platforms/lite5200.c2
-rw-r--r--arch/ppc/platforms/lite5200.h2
-rw-r--r--arch/ppc/platforms/lopec.c2
-rw-r--r--arch/ppc/platforms/mpc8272ads_setup.c236
-rw-r--r--arch/ppc/platforms/mpc866ads_setup.c273
-rw-r--r--arch/ppc/platforms/mpc885ads_setup.c389
-rw-r--r--arch/ppc/platforms/mvme5100.c2
-rw-r--r--arch/ppc/platforms/pal4.h2
-rw-r--r--arch/ppc/platforms/pal4_pci.c2
-rw-r--r--arch/ppc/platforms/pal4_serial.h2
-rw-r--r--arch/ppc/platforms/pal4_setup.c2
-rw-r--r--arch/ppc/platforms/powerpmc250.c2
-rw-r--r--arch/ppc/platforms/pplus.c2
-rw-r--r--arch/ppc/platforms/pplus.h2
-rw-r--r--arch/ppc/platforms/pq2ads.c2
-rw-r--r--arch/ppc/platforms/pq2ads.h4
-rw-r--r--arch/ppc/platforms/pq2ads_pd.h114
-rw-r--r--arch/ppc/platforms/prep_setup.c2
-rw-r--r--arch/ppc/platforms/prpmc750.c2
-rw-r--r--arch/ppc/platforms/prpmc800.c2
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.c7
-rw-r--r--arch/ppc/platforms/radstone_ppc7d.h2
-rw-r--r--arch/ppc/platforms/sandpoint.c2
-rw-r--r--arch/ppc/platforms/sandpoint.h2
-rw-r--r--arch/ppc/platforms/sbc82xx.c2
-rw-r--r--arch/ppc/platforms/spruce.c2
-rw-r--r--arch/ppc/platforms/tqm8260_setup.c2
-rw-r--r--arch/ppc/syslib/Makefile4
-rw-r--r--arch/ppc/syslib/cpc700.h2
-rw-r--r--arch/ppc/syslib/cpc700_pic.c2
-rw-r--r--arch/ppc/syslib/cpc710.h2
-rw-r--r--arch/ppc/syslib/gen550.h2
-rw-r--r--arch/ppc/syslib/gen550_dbg.c2
-rw-r--r--arch/ppc/syslib/gen550_kgdb.c2
-rw-r--r--arch/ppc/syslib/gt64260_pic.c2
-rw-r--r--arch/ppc/syslib/harrier.c2
-rw-r--r--arch/ppc/syslib/hawk_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gp_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gp_common.h2
-rw-r--r--arch/ppc/syslib/ibm440gx_common.c2
-rw-r--r--arch/ppc/syslib/ibm440gx_common.h2
-rw-r--r--arch/ppc/syslib/ibm440sp_common.c2
-rw-r--r--arch/ppc/syslib/ibm440sp_common.h2
-rw-r--r--arch/ppc/syslib/ibm44x_common.c2
-rw-r--r--arch/ppc/syslib/ibm44x_common.h2
-rw-r--r--arch/ppc/syslib/m8260_pci_erratum9.c2
-rw-r--r--arch/ppc/syslib/m8260_setup.c2
-rw-r--r--arch/ppc/syslib/m8xx_setup.c65
-rw-r--r--arch/ppc/syslib/m8xx_wdt.c3
-rw-r--r--arch/ppc/syslib/mpc10x_common.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_pci.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_pci.h2
-rw-r--r--arch/ppc/syslib/mpc52xx_pic.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_setup.c2
-rw-r--r--arch/ppc/syslib/mpc52xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc83xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc83xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc85xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc85xx_sys.c2
-rw-r--r--arch/ppc/syslib/mpc8xx_devices.c2
-rw-r--r--arch/ppc/syslib/mpc8xx_sys.c2
-rw-r--r--arch/ppc/syslib/mv64360_pic.c2
-rw-r--r--arch/ppc/syslib/mv64x60.c2
-rw-r--r--arch/ppc/syslib/mv64x60_dbg.c2
-rw-r--r--arch/ppc/syslib/mv64x60_win.c2
-rw-r--r--arch/ppc/syslib/ocp.c3
-rw-r--r--arch/ppc/syslib/open_pic.c2
-rw-r--r--arch/ppc/syslib/open_pic2.c2
-rw-r--r--arch/ppc/syslib/open_pic_defs.h2
-rw-r--r--arch/ppc/syslib/pci_auto.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_dma.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_pic.c2
-rw-r--r--arch/ppc/syslib/ppc4xx_pm.c47
-rw-r--r--arch/ppc/syslib/ppc4xx_sgdma.c2
-rw-r--r--arch/ppc/syslib/ppc83xx_setup.c2
-rw-r--r--arch/ppc/syslib/ppc83xx_setup.h2
-rw-r--r--arch/ppc/syslib/ppc85xx_common.c2
-rw-r--r--arch/ppc/syslib/ppc85xx_common.h2
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.c4
-rw-r--r--arch/ppc/syslib/ppc85xx_setup.h2
-rw-r--r--arch/ppc/syslib/ppc_sys.c179
-rw-r--r--arch/ppc/syslib/pq2_devices.c2
-rw-r--r--arch/ppc/syslib/pq2_sys.c2
-rw-r--r--arch/ppc/syslib/prep_nvram.c2
-rw-r--r--arch/ppc/syslib/todc_time.c2
-rw-r--r--arch/ppc/syslib/xilinx_pic.c4
-rw-r--r--arch/s390/Kconfig2
-rw-r--r--arch/s390/appldata/appldata_base.c3
-rw-r--r--arch/s390/kernel/debug.c11
-rw-r--r--arch/s390/kernel/process.c2
-rw-r--r--arch/s390/kernel/setup.c108
-rw-r--r--arch/s390/kernel/smp.c8
-rw-r--r--arch/s390/mm/cmm.c6
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/sh/kernel/irq.c5
-rw-r--r--arch/sh/kernel/process.c1
-rw-r--r--arch/sh/kernel/setup.c5
-rw-r--r--arch/sh64/kernel/irq.c5
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/sparc/kernel/irq.c71
-rw-r--r--arch/sparc/kernel/smp.c108
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c4
-rw-r--r--arch/sparc/kernel/sun4d_irq.c10
-rw-r--r--arch/sparc/kernel/sun4d_smp.c16
-rw-r--r--arch/sparc/kernel/sun4m_smp.c183
-rw-r--r--arch/sparc/mm/srmmu.c6
-rw-r--r--arch/sparc64/Kconfig.debug2
-rw-r--r--arch/sparc64/kernel/irq.c6
-rw-r--r--arch/sparc64/kernel/smp.c30
-rw-r--r--arch/sparc64/mm/init.c4
-rw-r--r--arch/um/Makefile7
-rw-r--r--arch/um/kernel/um_arch.c12
-rw-r--r--arch/v850/kernel/process.c2
-rw-r--r--arch/x86_64/Makefile4
-rw-r--r--arch/x86_64/ia32/sys_ia32.c16
-rw-r--r--arch/x86_64/kernel/early_printk.c116
-rw-r--r--arch/x86_64/kernel/irq.c21
-rw-r--r--arch/x86_64/kernel/kprobes.c4
-rw-r--r--arch/x86_64/kernel/mce.c3
-rw-r--r--arch/x86_64/kernel/nmi.c4
-rw-r--r--arch/x86_64/kernel/process.c2
-rw-r--r--arch/x86_64/kernel/setup.c3
-rw-r--r--arch/x86_64/kernel/signal.c4
-rw-r--r--arch/x86_64/pci/Makefile3
-rw-r--r--arch/x86_64/pci/mmconfig.c18
-rw-r--r--arch/xtensa/kernel/irq.c15
-rw-r--r--arch/xtensa/platform-iss/console.c4
-rw-r--r--block/Kconfig12
-rw-r--r--block/Makefile2
-rw-r--r--block/blktrace.c538
-rw-r--r--block/elevator.c7
-rw-r--r--block/ioctl.c28
-rw-r--r--block/ll_rw_blk.c44
-rw-r--r--drivers/acpi/Kconfig15
-rw-r--r--drivers/acpi/ibm_acpi.c13
-rw-r--r--drivers/acpi/scan.c5
-rw-r--r--drivers/atm/.gitignore5
-rw-r--r--drivers/base/cpu.c9
-rw-r--r--drivers/base/power/suspend.c5
-rw-r--r--drivers/block/DAC960.c3
-rw-r--r--drivers/block/Kconfig1
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/ataflop.c4
-rw-r--r--drivers/block/cciss.c7
-rw-r--r--drivers/block/cciss_scsi.c2
-rw-r--r--drivers/block/cpqarray.c3
-rw-r--r--drivers/block/floppy.c19
-rw-r--r--drivers/block/loop.c18
-rw-r--r--drivers/block/nbd.c21
-rw-r--r--drivers/block/paride/comm.c16
-rw-r--r--drivers/block/paride/on26.c2
-rw-r--r--drivers/block/pktcdvd.c27
-rw-r--r--drivers/block/rd.c7
-rw-r--r--drivers/cdrom/cdrom.c874
-rw-r--r--drivers/cdrom/cdu31a.c8
-rw-r--r--drivers/cdrom/cm206.c52
-rw-r--r--drivers/cdrom/sbpcd.c720
-rw-r--r--drivers/cdrom/viocd.c2
-rw-r--r--drivers/char/Kconfig4
-rw-r--r--drivers/char/Makefile87
-rw-r--r--drivers/char/amiserial.c18
-rw-r--r--drivers/char/generic_serial.c14
-rw-r--r--drivers/char/hvcs.c9
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c12
-rw-r--r--drivers/char/ipmi/ipmi_poweroff.c4
-rw-r--r--drivers/char/istallion.c9
-rw-r--r--drivers/char/mem.c28
-rw-r--r--drivers/char/mxser.c8
-rw-r--r--drivers/char/n_tty.c10
-rw-r--r--drivers/char/nwflash.c11
-rw-r--r--drivers/char/pcmcia/synclink_cs.c2
-rw-r--r--drivers/char/ppdev.c3
-rw-r--r--drivers/char/raw.c23
-rw-r--r--drivers/char/rio/Makefile2
-rw-r--r--drivers/char/rio/board.h58
-rw-r--r--drivers/char/rio/bootpkt.h61
-rw-r--r--drivers/char/rio/cirrus.h110
-rw-r--r--drivers/char/rio/cmdblk.h4
-rw-r--r--drivers/char/rio/cmdpkt.h94
-rw-r--r--drivers/char/rio/control.h61
-rw-r--r--drivers/char/rio/daemon.h67
-rw-r--r--drivers/char/rio/defaults.h51
-rw-r--r--drivers/char/rio/error.h82
-rw-r--r--drivers/char/rio/func.h52
-rw-r--r--drivers/char/rio/host.h56
-rw-r--r--drivers/char/rio/link.h124
-rw-r--r--drivers/char/rio/linux_compat.h45
-rw-r--r--drivers/char/rio/list.h56
-rw-r--r--drivers/char/rio/map.h12
-rw-r--r--drivers/char/rio/param.h24
-rw-r--r--drivers/char/rio/parmmap.h68
-rw-r--r--drivers/char/rio/phb.h39
-rw-r--r--drivers/char/rio/pkt.h24
-rw-r--r--drivers/char/rio/port.h250
-rw-r--r--drivers/char/rio/qbuf.h62
-rw-r--r--drivers/char/rio/rio.h173
-rw-r--r--drivers/char/rio/rio_linux.c139
-rw-r--r--drivers/char/rio/rioboot.c1688
-rw-r--r--drivers/char/rio/riocmd.c176
-rw-r--r--drivers/char/rio/rioctrl.c401
-rw-r--r--drivers/char/rio/riodrvr.h48
-rw-r--r--drivers/char/rio/rioinit.c199
-rw-r--r--drivers/char/rio/riointr.c320
-rw-r--r--drivers/char/rio/rioparam.c129
-rw-r--r--drivers/char/rio/riopcicopy.c8
-rw-r--r--drivers/char/rio/rioroute.c166
-rw-r--r--drivers/char/rio/riotable.c123
-rw-r--r--drivers/char/rio/riotty.c198
-rw-r--r--drivers/char/rio/riotypes.h68
-rw-r--r--drivers/char/rio/rom.h62
-rw-r--r--drivers/char/rio/rup.h25
-rw-r--r--drivers/char/rio/sam.h67
-rw-r--r--drivers/char/rio/space.h45
-rw-r--r--drivers/char/rio/top.h48
-rw-r--r--drivers/char/rio/typdef.h82
-rw-r--r--drivers/char/rio/unixrup.h6
-rw-r--r--drivers/char/riscom8.c8
-rw-r--r--drivers/char/ser_a2232.c4
-rw-r--r--drivers/char/snsc.c8
-rw-r--r--drivers/char/snsc_event.c5
-rw-r--r--drivers/char/stallion.c1
-rw-r--r--drivers/char/sx.c2
-rw-r--r--drivers/char/synclink.c2
-rw-r--r--drivers/char/synclink_gt.c2
-rw-r--r--drivers/char/synclinkmp.c2
-rw-r--r--drivers/char/sysrq.c250
-rw-r--r--drivers/char/toshiba.c38
-rw-r--r--drivers/char/tpm/tpm.h1
-rw-r--r--drivers/char/tty_io.c54
-rw-r--r--drivers/char/vme_scc.c2
-rw-r--r--drivers/char/vt.c22
-rw-r--r--drivers/char/watchdog/Kconfig10
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/ep93xx_wdt.c257
-rw-r--r--drivers/char/watchdog/pcwd_usb.c7
-rw-r--r--drivers/connector/connector.c15
-rw-r--r--drivers/dio/dio-driver.c9
-rw-r--r--drivers/eisa/.gitignore1
-rw-r--r--drivers/eisa/eisa-bus.c7
-rw-r--r--drivers/firmware/dcdbas.c23
-rw-r--r--drivers/hwmon/Kconfig7
-rw-r--r--drivers/hwmon/adm1021.c13
-rw-r--r--drivers/hwmon/adm1025.c25
-rw-r--r--drivers/hwmon/adm1026.c92
-rw-r--r--drivers/hwmon/adm1031.c49
-rw-r--r--drivers/hwmon/adm9240.c29
-rw-r--r--drivers/hwmon/asb100.c45
-rw-r--r--drivers/hwmon/atxp1.c9
-rw-r--r--drivers/hwmon/ds1621.c13
-rw-r--r--drivers/hwmon/f71805f.c275
-rw-r--r--drivers/hwmon/fscher.c41
-rw-r--r--drivers/hwmon/fscpos.c33
-rw-r--r--drivers/hwmon/gl518sm.c25
-rw-r--r--drivers/hwmon/gl520sm.c47
-rw-r--r--drivers/hwmon/hdaps.c37
-rw-r--r--drivers/hwmon/hwmon-vid.c9
-rw-r--r--drivers/hwmon/hwmon.c26
-rw-r--r--drivers/hwmon/it87.c66
-rw-r--r--drivers/hwmon/lm63.c29
-rw-r--r--drivers/hwmon/lm75.c13
-rw-r--r--drivers/hwmon/lm77.c21
-rw-r--r--drivers/hwmon/lm78.c51
-rw-r--r--drivers/hwmon/lm80.c27
-rw-r--r--drivers/hwmon/lm83.c13
-rw-r--r--drivers/hwmon/lm85.c71
-rw-r--r--drivers/hwmon/lm87.c39
-rw-r--r--drivers/hwmon/lm90.c21
-rw-r--r--drivers/hwmon/lm92.c17
-rw-r--r--drivers/hwmon/max1619.c13
-rw-r--r--drivers/hwmon/pc87360.c469
-rw-r--r--drivers/hwmon/sis5595.c51
-rw-r--r--drivers/hwmon/smsc47b397.c17
-rw-r--r--drivers/hwmon/smsc47m1.c41
-rw-r--r--drivers/hwmon/via686a.c33
-rw-r--r--drivers/hwmon/vt8231.c51
-rw-r--r--drivers/hwmon/w83627ehf.c239
-rw-r--r--drivers/hwmon/w83627hf.c134
-rw-r--r--drivers/hwmon/w83781d.c82
-rw-r--r--drivers/hwmon/w83792d.c538
-rw-r--r--drivers/hwmon/w83l785ts.c9
-rw-r--r--drivers/i2c/busses/Kconfig11
-rw-r--r--drivers/i2c/busses/i2c-ali1535.c4
-rw-r--r--drivers/i2c/busses/i2c-amd756-s4882.c13
-rw-r--r--drivers/i2c/busses/i2c-frodo.c85
-rw-r--r--drivers/i2c/busses/i2c-isa.c2
-rw-r--r--drivers/i2c/busses/i2c-ite.c4
-rw-r--r--drivers/i2c/busses/i2c-ixp4xx.c1
-rw-r--r--drivers/i2c/busses/i2c-piix4.c4
-rw-r--r--drivers/i2c/busses/i2c-pxa.c2
-rw-r--r--drivers/i2c/busses/scx200_acb.c283
-rw-r--r--drivers/i2c/chips/ds1374.c11
-rw-r--r--drivers/i2c/chips/eeprom.c9
-rw-r--r--drivers/i2c/chips/isp1301_omap.c2
-rw-r--r--drivers/i2c/chips/m41t00.c11
-rw-r--r--drivers/i2c/chips/max6875.c10
-rw-r--r--drivers/i2c/chips/pcf8591.c13
-rw-r--r--drivers/i2c/chips/rtc8564.c2
-rw-r--r--drivers/i2c/chips/tps65010.c45
-rw-r--r--drivers/i2c/i2c-core.c81
-rw-r--r--drivers/ide/ide-cd.c110
-rw-r--r--drivers/ide/ide-disk.c13
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-floppy.c11
-rw-r--r--drivers/ide/ide-probe.c9
-rw-r--r--drivers/ide/ide-tape.c19
-rw-r--r--drivers/ide/ide.c2
-rw-r--r--drivers/input/serio/hil_mlc.c2
-rw-r--r--drivers/input/touchscreen/ads7846.c1
-rw-r--r--drivers/isdn/capi/kcapi.c17
-rw-r--r--drivers/isdn/hardware/avm/b1dma.c2
-rw-r--r--drivers/isdn/hardware/avm/b1isa.c4
-rw-r--r--drivers/isdn/hardware/avm/c4.c2
-rw-r--r--drivers/isdn/hardware/avm/t1isa.c6
-rw-r--r--drivers/isdn/hisax/config.c1
-rw-r--r--drivers/isdn/hisax/elsa.c1
-rw-r--r--drivers/isdn/hysdn/boardergo.c31
-rw-r--r--drivers/isdn/hysdn/boardergo.h46
-rw-r--r--drivers/isdn/hysdn/hycapi.c4
-rw-r--r--drivers/isdn/hysdn/hysdn_boot.c28
-rw-r--r--drivers/isdn/hysdn/hysdn_defs.h71
-rw-r--r--drivers/isdn/hysdn/hysdn_init.c4
-rw-r--r--drivers/isdn/hysdn/hysdn_net.c8
-rw-r--r--drivers/isdn/hysdn/hysdn_pof.h12
-rw-r--r--drivers/isdn/hysdn/hysdn_procconf.c14
-rw-r--r--drivers/isdn/hysdn/hysdn_proclog.c10
-rw-r--r--drivers/isdn/hysdn/hysdn_sched.c11
-rw-r--r--drivers/isdn/hysdn/ince1pc.h18
-rw-r--r--drivers/isdn/i4l/isdn_ppp.c3
-rw-r--r--drivers/isdn/i4l/isdn_tty.c5
-rw-r--r--drivers/isdn/i4l/isdn_x25iface.c2
-rw-r--r--drivers/isdn/isdnloop/isdnloop.c2
-rw-r--r--drivers/macintosh/macio_asic.c5
-rw-r--r--drivers/macintosh/smu.c4
-rw-r--r--drivers/macintosh/therm_pm72.c2
-rw-r--r--drivers/macintosh/via-pmu.c5
-rw-r--r--drivers/macintosh/windfarm_lm75_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_max6690_sensor.c1
-rw-r--r--drivers/macintosh/windfarm_smu_sat.c1
-rw-r--r--drivers/md/bitmap.c4
-rw-r--r--drivers/md/dm-hw-handler.c3
-rw-r--r--drivers/md/dm.c13
-rw-r--r--drivers/media/Kconfig14
-rw-r--r--drivers/media/common/saa7146_fops.c5
-rw-r--r--drivers/media/common/saa7146_vbi.c8
-rw-r--r--drivers/media/common/saa7146_video.c8
-rw-r--r--drivers/media/dvb/b2c2/flexcop-usb.c1
-rw-r--r--drivers/media/dvb/bt8xx/Makefile2
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.c24
-rw-r--r--drivers/media/dvb/dvb-usb/cxusb.h2
-rw-r--r--drivers/media/dvb/ttpci/av7110_v4l.c5
-rw-r--r--drivers/media/video/Kconfig258
-rw-r--r--drivers/media/video/Makefile26
-rw-r--r--drivers/media/video/adv7170.c28
-rw-r--r--drivers/media/video/adv7175.c58
-rw-r--r--drivers/media/video/arv.c54
-rw-r--r--drivers/media/video/bt819.c28
-rw-r--r--drivers/media/video/bt856.c18
-rw-r--r--drivers/media/video/bt8xx/Kconfig25
-rw-r--r--drivers/media/video/bt8xx/Makefile12
-rw-r--r--drivers/media/video/bt8xx/bt832.c (renamed from drivers/media/video/bt832.c)3
-rw-r--r--drivers/media/video/bt8xx/bt832.h (renamed from drivers/media/video/bt832.h)0
-rw-r--r--drivers/media/video/bt8xx/bt848.h (renamed from drivers/media/video/bt848.h)0
-rw-r--r--drivers/media/video/bt8xx/bttv-cards.c (renamed from drivers/media/video/bttv-cards.c)315
-rw-r--r--drivers/media/video/bt8xx/bttv-driver.c (renamed from drivers/media/video/bttv-driver.c)149
-rw-r--r--drivers/media/video/bt8xx/bttv-gpio.c (renamed from drivers/media/video/bttv-gpio.c)0
-rw-r--r--drivers/media/video/bt8xx/bttv-i2c.c (renamed from drivers/media/video/bttv-i2c.c)4
-rw-r--r--drivers/media/video/bt8xx/bttv-if.c (renamed from drivers/media/video/bttv-if.c)0
-rw-r--r--drivers/media/video/bt8xx/bttv-input.c (renamed from drivers/media/video/bttv-input.c)0
-rw-r--r--drivers/media/video/bt8xx/bttv-risc.c (renamed from drivers/media/video/bttv-risc.c)4
-rw-r--r--drivers/media/video/bt8xx/bttv-vbi.c (renamed from drivers/media/video/bttv-vbi.c)6
-rw-r--r--drivers/media/video/bt8xx/bttv.h (renamed from drivers/media/video/bttv.h)23
-rw-r--r--drivers/media/video/bt8xx/bttvp.h (renamed from drivers/media/video/bttvp.h)7
-rw-r--r--drivers/media/video/bw-qcam.c106
-rw-r--r--drivers/media/video/c-qcam.c66
-rw-r--r--drivers/media/video/cpia.c658
-rw-r--r--drivers/media/video/cpia.h52
-rw-r--r--drivers/media/video/cpia2/cpia2.h2
-rw-r--r--drivers/media/video/cpia2/cpia2_core.c40
-rw-r--r--drivers/media/video/cpia2/cpia2_v4l.c43
-rw-r--r--drivers/media/video/cpia_pp.c106
-rw-r--r--drivers/media/video/cpia_usb.c40
-rw-r--r--drivers/media/video/cs53l32a.c20
-rw-r--r--drivers/media/video/cs8420.h2
-rw-r--r--drivers/media/video/cx25840/cx25840-audio.c1
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c51
-rw-r--r--drivers/media/video/cx88/Kconfig5
-rw-r--r--drivers/media/video/cx88/cx88-alsa.c4
-rw-r--r--drivers/media/video/cx88/cx88-blackbird.c5
-rw-r--r--drivers/media/video/cx88/cx88-core.c6
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c5
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c28
-rw-r--r--drivers/media/video/cx88/cx88-tvaudio.c3
-rw-r--r--drivers/media/video/cx88/cx88-vbi.c7
-rw-r--r--drivers/media/video/cx88/cx88-video.c35
-rw-r--r--drivers/media/video/cx88/cx88.h7
-rw-r--r--drivers/media/video/dabfirmware.h (renamed from drivers/usb/media/dabfirmware.h)0
-rw-r--r--drivers/media/video/dabusb.c (renamed from drivers/usb/media/dabusb.c)18
-rw-r--r--drivers/media/video/dabusb.h (renamed from drivers/usb/media/dabusb.h)4
-rw-r--r--drivers/media/video/dsbr100.c (renamed from drivers/usb/media/dsbr100.c)44
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c9
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c8
-rw-r--r--drivers/media/video/et61x251/Makefile4
-rw-r--r--drivers/media/video/et61x251/et61x251.h (renamed from drivers/usb/media/et61x251.h)8
-rw-r--r--drivers/media/video/et61x251/et61x251_core.c (renamed from drivers/usb/media/et61x251_core.c)210
-rw-r--r--drivers/media/video/et61x251/et61x251_sensor.h (renamed from drivers/usb/media/et61x251_sensor.h)20
-rw-r--r--drivers/media/video/et61x251/et61x251_tas5130d1b.c (renamed from drivers/usb/media/et61x251_tas5130d1b.c)10
-rw-r--r--drivers/media/video/font.h407
-rw-r--r--drivers/media/video/msp3400-driver.c249
-rw-r--r--drivers/media/video/msp3400-driver.h (renamed from drivers/media/video/msp3400.h)30
-rw-r--r--drivers/media/video/msp3400-kthreads.c331
-rw-r--r--drivers/media/video/mxb.c12
-rw-r--r--drivers/media/video/ov511.c (renamed from drivers/usb/media/ov511.c)92
-rw-r--r--drivers/media/video/ov511.h (renamed from drivers/usb/media/ov511.h)8
-rw-r--r--drivers/media/video/ovcamchip/Makefile2
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_core.c6
-rw-r--r--drivers/media/video/ovcamchip/ovcamchip_priv.h2
-rw-r--r--drivers/media/video/planb.c128
-rw-r--r--drivers/media/video/planb.h6
-rw-r--r--drivers/media/video/pms.c136
-rw-r--r--drivers/media/video/pwc/Makefile (renamed from drivers/usb/media/pwc/Makefile)2
-rw-r--r--drivers/media/video/pwc/philips.txt (renamed from drivers/usb/media/pwc/philips.txt)66
-rw-r--r--drivers/media/video/pwc/pwc-ctrl.c (renamed from drivers/usb/media/pwc/pwc-ctrl.c)374
-rw-r--r--drivers/media/video/pwc/pwc-if.c (renamed from drivers/usb/media/pwc/pwc-if.c)302
-rw-r--r--drivers/media/video/pwc/pwc-ioctl.h (renamed from drivers/usb/media/pwc/pwc-ioctl.h)40
-rw-r--r--drivers/media/video/pwc/pwc-kiara.c318
-rw-r--r--drivers/media/video/pwc/pwc-kiara.h (renamed from drivers/usb/media/pwc/pwc-kiara.h)0
-rw-r--r--drivers/media/video/pwc/pwc-misc.c (renamed from drivers/usb/media/pwc/pwc-misc.c)26
-rw-r--r--drivers/media/video/pwc/pwc-nala.h (renamed from drivers/usb/media/pwc/pwc-nala.h)2
-rw-r--r--drivers/media/video/pwc/pwc-timon.c316
-rw-r--r--drivers/media/video/pwc/pwc-timon.h (renamed from drivers/usb/media/pwc/pwc-timon.h)0
-rw-r--r--drivers/media/video/pwc/pwc-uncompress.c (renamed from drivers/usb/media/pwc/pwc-uncompress.c)6
-rw-r--r--drivers/media/video/pwc/pwc-uncompress.h (renamed from drivers/usb/media/pwc/pwc-uncompress.h)2
-rw-r--r--drivers/media/video/pwc/pwc.h (renamed from drivers/usb/media/pwc/pwc.h)4
-rw-r--r--drivers/media/video/saa5249.c112
-rw-r--r--drivers/media/video/saa6588.c2
-rw-r--r--drivers/media/video/saa7110.c24
-rw-r--r--drivers/media/video/saa7111.c31
-rw-r--r--drivers/media/video/saa7114.c36
-rw-r--r--drivers/media/video/saa7115.c1
-rw-r--r--drivers/media/video/saa711x.c1
-rw-r--r--drivers/media/video/saa7121.h6
-rw-r--r--drivers/media/video/saa7134/saa7134-alsa.c10
-rw-r--r--drivers/media/video/saa7134/saa7134-core.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c6
-rw-r--r--drivers/media/video/saa7134/saa7134-ts.c9
-rw-r--r--drivers/media/video/saa7134/saa7134-tvaudio.c2
-rw-r--r--drivers/media/video/saa7134/saa7134-vbi.c10
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c9
-rw-r--r--drivers/media/video/saa7134/saa7134.h3
-rw-r--r--drivers/media/video/saa7146.h10
-rw-r--r--drivers/media/video/saa7146reg.h4
-rw-r--r--drivers/media/video/saa7185.c22
-rw-r--r--drivers/media/video/saa7196.h4
-rw-r--r--drivers/media/video/se401.c (renamed from drivers/usb/media/se401.c)216
-rw-r--r--drivers/media/video/se401.h (renamed from drivers/usb/media/se401.h)6
-rw-r--r--drivers/media/video/sn9c102/Makefile7
-rw-r--r--drivers/media/video/sn9c102/sn9c102.h (renamed from drivers/usb/media/sn9c102.h)8
-rw-r--r--drivers/media/video/sn9c102/sn9c102_core.c (renamed from drivers/usb/media/sn9c102_core.c)264
-rw-r--r--drivers/media/video/sn9c102/sn9c102_hv7131d.c (renamed from drivers/usb/media/sn9c102_hv7131d.c)16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_mi0343.c (renamed from drivers/usb/media/sn9c102_mi0343.c)106
-rw-r--r--drivers/media/video/sn9c102/sn9c102_ov7630.c (renamed from drivers/usb/media/sn9c102_ov7630.c)14
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas106b.c (renamed from drivers/usb/media/sn9c102_pas106b.c)16
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bca.c (renamed from drivers/usb/media/sn9c102_pas202bca.c)6
-rw-r--r--drivers/media/video/sn9c102/sn9c102_pas202bcb.c (renamed from drivers/usb/media/sn9c102_pas202bcb.c)18
-rw-r--r--drivers/media/video/sn9c102/sn9c102_sensor.h (renamed from drivers/usb/media/sn9c102_sensor.h)70
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5110c1b.c (renamed from drivers/usb/media/sn9c102_tas5110c1b.c)12
-rw-r--r--drivers/media/video/sn9c102/sn9c102_tas5130d1b.c (renamed from drivers/usb/media/sn9c102_tas5130d1b.c)12
-rw-r--r--drivers/media/video/stradis.c10
-rw-r--r--drivers/media/video/stv680.c (renamed from drivers/usb/media/stv680.c)48
-rw-r--r--drivers/media/video/stv680.h (renamed from drivers/usb/media/stv680.h)142
-rw-r--r--drivers/media/video/tda7432.c5
-rw-r--r--drivers/media/video/tda9840.c4
-rw-r--r--drivers/media/video/tda9840.h2
-rw-r--r--drivers/media/video/tda9875.c9
-rw-r--r--drivers/media/video/tea6415c.c2
-rw-r--r--drivers/media/video/tea6420.c4
-rw-r--r--drivers/media/video/tea6420.h4
-rw-r--r--drivers/media/video/tuner-3036.c50
-rw-r--r--drivers/media/video/tuner-core.c1
-rw-r--r--drivers/media/video/tvaudio.c154
-rw-r--r--drivers/media/video/tvaudio.h14
-rw-r--r--drivers/media/video/tveeprom.c30
-rw-r--r--drivers/media/video/usbvideo/Makefile4
-rw-r--r--drivers/media/video/usbvideo/ibmcam.c (renamed from drivers/usb/media/ibmcam.c)10
-rw-r--r--drivers/media/video/usbvideo/konicawc.c (renamed from drivers/usb/media/konicawc.c)48
-rw-r--r--drivers/media/video/usbvideo/ultracam.c (renamed from drivers/usb/media/ultracam.c)2
-rw-r--r--drivers/media/video/usbvideo/usbvideo.c (renamed from drivers/usb/media/usbvideo.c)42
-rw-r--r--drivers/media/video/usbvideo/usbvideo.h (renamed from drivers/usb/media/usbvideo.h)10
-rw-r--r--drivers/media/video/usbvideo/vicam.c (renamed from drivers/usb/media/vicam.c)28
-rw-r--r--drivers/media/video/v4l2-common.c38
-rw-r--r--drivers/media/video/video-buf.c250
-rw-r--r--drivers/media/video/videocodec.h52
-rw-r--r--drivers/media/video/vino.c4
-rw-r--r--drivers/media/video/vivi.c1454
-rw-r--r--drivers/media/video/vpx3220.c21
-rw-r--r--drivers/media/video/w9966.c102
-rw-r--r--drivers/media/video/w9968cf.c (renamed from drivers/usb/media/w9968cf.c)930
-rw-r--r--drivers/media/video/w9968cf.h (renamed from drivers/usb/media/w9968cf.h)12
-rw-r--r--drivers/media/video/w9968cf_decoder.h (renamed from drivers/usb/media/w9968cf_decoder.h)8
-rw-r--r--drivers/media/video/w9968cf_vpp.h (renamed from drivers/usb/media/w9968cf_vpp.h)2
-rw-r--r--drivers/media/video/wm8775.c20
-rw-r--r--drivers/media/video/zc0301/Makefile3
-rw-r--r--drivers/media/video/zc0301/zc0301.h (renamed from drivers/usb/media/zc0301.h)6
-rw-r--r--drivers/media/video/zc0301/zc0301_core.c (renamed from drivers/usb/media/zc0301_core.c)148
-rw-r--r--drivers/media/video/zc0301/zc0301_pas202bcb.c (renamed from drivers/usb/media/zc0301_pas202bcb.c)12
-rw-r--r--drivers/media/video/zc0301/zc0301_sensor.h (renamed from drivers/usb/media/zc0301_sensor.h)4
-rw-r--r--drivers/media/video/zoran.h4
-rw-r--r--drivers/media/video/zoran_card.c51
-rw-r--r--drivers/media/video/zoran_card.h2
-rw-r--r--drivers/media/video/zoran_device.c16
-rw-r--r--drivers/media/video/zoran_device.h2
-rw-r--r--drivers/media/video/zoran_driver.c243
-rw-r--r--drivers/media/video/zoran_procfs.c2
-rw-r--r--drivers/media/video/zoran_procfs.h2
-rw-r--r--drivers/media/video/zr36016.c22
-rw-r--r--drivers/media/video/zr36050.c16
-rw-r--r--drivers/media/video/zr36057.h10
-rw-r--r--drivers/media/video/zr36060.c20
-rw-r--r--drivers/media/video/zr36120.c54
-rw-r--r--drivers/media/video/zr36120.h6
-rw-r--r--drivers/message/i2o/debug.c31
-rw-r--r--drivers/mfd/Kconfig1
-rw-r--r--drivers/mmc/Kconfig11
-rw-r--r--drivers/mmc/Makefile1
-rw-r--r--drivers/mmc/au1xmmc.c2
-rw-r--r--drivers/mmc/sdhci.c1265
-rw-r--r--drivers/mmc/sdhci.h185
-rw-r--r--drivers/mtd/maps/pcmciamtd.c14
-rw-r--r--drivers/net/3c59x.c20
-rw-r--r--drivers/net/8139too.c2
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/Makefile4
-rw-r--r--drivers/net/a2065.c2
-rw-r--r--drivers/net/ariadne.c2
-rw-r--r--drivers/net/arm/Kconfig8
-rw-r--r--drivers/net/arm/Makefile1
-rw-r--r--drivers/net/arm/at91_ether.c1110
-rw-r--r--drivers/net/arm/at91_ether.h101
-rw-r--r--drivers/net/atari_bionet.c2
-rw-r--r--drivers/net/atari_pamsnet.c2
-rw-r--r--drivers/net/atarilance.c2
-rw-r--r--drivers/net/au1000_eth.c18
-rw-r--r--drivers/net/bnx2.c108
-rw-r--r--drivers/net/bnx2.h62
-rw-r--r--drivers/net/cassini.c11
-rw-r--r--drivers/net/chelsio/cxgb2.c2
-rw-r--r--drivers/net/depca.c2
-rw-r--r--drivers/net/dgrs.c14
-rw-r--r--drivers/net/fec_8xx/fec_main.c4
-rw-r--r--drivers/net/fs_enet/fs_enet-main.c4
-rw-r--r--drivers/net/gt96100eth.c4
-rw-r--r--drivers/net/hamradio/dmascc.c2
-rw-r--r--drivers/net/hamradio/mkiss.c2
-rw-r--r--drivers/net/hp-plus.c17
-rw-r--r--drivers/net/hplance.c2
-rw-r--r--drivers/net/hydra.c2
-rw-r--r--drivers/net/irda/irport.c4
-rw-r--r--drivers/net/ixp2000/enp2611.c2
-rw-r--r--drivers/net/ixp2000/ixpdev.c2
-rw-r--r--drivers/net/lance.c9
-rw-r--r--drivers/net/lasi_82596.c6
-rw-r--r--drivers/net/loopback.c4
-rw-r--r--drivers/net/mac89x0.c2
-rw-r--r--drivers/net/mace.c2
-rw-r--r--drivers/net/meth.c2
-rw-r--r--drivers/net/ne-h8300.c6
-rw-r--r--drivers/net/ne2k-pci.c2
-rw-r--r--drivers/net/ni5010.c4
-rw-r--r--drivers/net/ppp_generic.c25
-rw-r--r--drivers/net/sis900.c1
-rw-r--r--drivers/net/sk98lin/skge.c2
-rw-r--r--drivers/net/skge.c105
-rw-r--r--drivers/net/skge.h1
-rw-r--r--drivers/net/sky2.c33
-rw-r--r--drivers/net/sky2.h73
-rw-r--r--drivers/net/sun3lance.c2
-rw-r--r--drivers/net/tg3.c84
-rw-r--r--drivers/net/tg3.h9
-rw-r--r--drivers/net/tulip/de2104x.c2
-rw-r--r--drivers/net/wireless/Kconfig10
-rw-r--r--drivers/net/wireless/airo.c455
-rw-r--r--drivers/net/wireless/hostap/hostap_ap.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_hw.c8
-rw-r--r--drivers/net/wireless/hostap/hostap_ioctl.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c4
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c13
-rw-r--r--drivers/net/wireless/prism54/oid_mgt.c4
-rw-r--r--drivers/net/wireless/spectrum_cs.c2
-rw-r--r--drivers/net/zorro8390.c2
-rw-r--r--drivers/oprofile/cpu_buffer.c3
-rw-r--r--drivers/parisc/sba_iommu.c10
-rw-r--r--drivers/parisc/superio.c7
-rw-r--r--drivers/parport/parport_serial.c75
-rw-r--r--drivers/pci/Kconfig21
-rw-r--r--drivers/pci/hotplug/Makefile20
-rw-r--r--drivers/pci/hotplug/acpi_pcihp.c (renamed from drivers/pci/hotplug/shpchprm_acpi.c)145
-rw-r--r--drivers/pci/hotplug/acpiphp.h62
-rw-r--r--drivers/pci/hotplug/acpiphp_core.c134
-rw-r--r--drivers/pci/hotplug/acpiphp_dock.c438
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c356
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c9
-rw-r--r--drivers/pci/hotplug/cpqphp.h3
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c27
-rw-r--r--drivers/pci/hotplug/cpqphp_ctrl.c124
-rw-r--r--drivers/pci/hotplug/fakephp.c9
-rw-r--r--drivers/pci/hotplug/ibmphp.h2
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c10
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c59
-rw-r--r--drivers/pci/hotplug/ibmphp_hpc.c64
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c121
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c81
-rw-r--r--drivers/pci/hotplug/pci_hotplug.h16
-rw-r--r--drivers/pci/hotplug/pciehp.h27
-rw-r--r--drivers/pci/hotplug/pciehp_core.c19
-rw-r--r--drivers/pci/hotplug/pciehp_ctrl.c68
-rw-r--r--drivers/pci/hotplug/pciehp_hpc.c77
-rw-r--r--drivers/pci/hotplug/pciehprm_acpi.c257
-rw-r--r--drivers/pci/hotplug/pciehprm_nonacpi.c47
-rw-r--r--drivers/pci/hotplug/pcihp_skeleton.c33
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c9
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c16
-rw-r--r--drivers/pci/hotplug/shpchp.h108
-rw-r--r--drivers/pci/hotplug/shpchp_core.c331
-rw-r--r--drivers/pci/hotplug/shpchp_ctrl.c808
-rw-r--r--drivers/pci/hotplug/shpchp_hpc.c518
-rw-r--r--drivers/pci/hotplug/shpchp_pci.c10
-rw-r--r--drivers/pci/hotplug/shpchprm_legacy.c54
-rw-r--r--drivers/pci/hotplug/shpchprm_nonacpi.c57
-rw-r--r--drivers/pci/msi.c105
-rw-r--r--drivers/pci/pci-driver.c12
-rw-r--r--drivers/pci/pci-sysfs.c3
-rw-r--r--drivers/pci/pci.c22
-rw-r--r--drivers/pci/pci.h2
-rw-r--r--drivers/pci/pcie/portdrv.h1
-rw-r--r--drivers/pci/pcie/portdrv_core.c3
-rw-r--r--drivers/pci/pcie/portdrv_pci.c66
-rw-r--r--drivers/pci/probe.c34
-rw-r--r--drivers/pci/proc.c126
-rw-r--r--drivers/pci/quirks.c71
-rw-r--r--drivers/pci/search.c4
-rw-r--r--drivers/pnp/isapnp/core.c4
-rw-r--r--drivers/pnp/pnpbios/rsparser.c6
-rw-r--r--drivers/s390/Kconfig8
-rw-r--r--drivers/s390/block/Kconfig14
-rw-r--r--drivers/s390/block/Makefile4
-rw-r--r--drivers/s390/block/dasd.c52
-rw-r--r--drivers/s390/block/dasd_3990_erp.c3
-rw-r--r--drivers/s390/block/dasd_cmb.c128
-rw-r--r--drivers/s390/block/dasd_devmap.c44
-rw-r--r--drivers/s390/block/dasd_eckd.c142
-rw-r--r--drivers/s390/block/dasd_eckd.h1
-rw-r--r--drivers/s390/block/dasd_eer.c682
-rw-r--r--drivers/s390/block/dasd_int.h60
-rw-r--r--drivers/s390/block/dasd_ioctl.c322
-rw-r--r--drivers/s390/block/dcssblk.c3
-rw-r--r--drivers/s390/char/Makefile1
-rw-r--r--drivers/s390/char/fs3270.c3
-rw-r--r--drivers/s390/char/keyboard.c12
-rw-r--r--drivers/s390/char/monreader.c6
-rw-r--r--drivers/s390/char/raw3270.c3
-rw-r--r--drivers/s390/char/tape.h1
-rw-r--r--drivers/s390/char/tape_34xx.c8
-rw-r--r--drivers/s390/char/tape_3590.c1301
-rw-r--r--drivers/s390/char/tape_3590.h124
-rw-r--r--drivers/s390/char/tape_class.c3
-rw-r--r--drivers/s390/char/tape_core.c57
-rw-r--r--drivers/s390/char/tape_std.c15
-rw-r--r--drivers/s390/char/tape_std.h12
-rw-r--r--drivers/s390/char/tty3270.c9
-rw-r--r--drivers/s390/char/vmlogrdr.c3
-rw-r--r--drivers/s390/cio/ccwgroup.c3
-rw-r--r--drivers/s390/cio/chsc.c457
-rw-r--r--drivers/s390/cio/chsc.h22
-rw-r--r--drivers/s390/cio/css.c44
-rw-r--r--drivers/s390/cio/css.h6
-rw-r--r--drivers/s390/cio/device.c6
-rw-r--r--drivers/s390/cio/device_fsm.c12
-rw-r--r--drivers/s390/cio/device_ops.c9
-rw-r--r--drivers/s390/cio/qdio.c20
-rw-r--r--drivers/s390/crypto/z90hardware.c10
-rw-r--r--drivers/s390/crypto/z90main.c15
-rw-r--r--drivers/s390/net/claw.c3
-rw-r--r--drivers/s390/net/fsm.c10
-rw-r--r--drivers/s390/net/iucv.c11
-rw-r--r--drivers/s390/net/lcs.c11
-rw-r--r--drivers/s390/net/netiucv.c7
-rw-r--r--drivers/s390/net/qeth_eddp.c13
-rw-r--r--drivers/s390/net/qeth_main.c77
-rw-r--r--drivers/s390/net/qeth_proc.c56
-rw-r--r--drivers/s390/net/qeth_sys.c5
-rw-r--r--drivers/s390/s390_rdev.c3
-rw-r--r--drivers/scsi/Kconfig4
-rw-r--r--drivers/scsi/Makefile4
-rw-r--r--drivers/scsi/ahci.c135
-rw-r--r--drivers/scsi/arm/cumana_2.c2
-rw-r--r--drivers/scsi/arm/eesox.c2
-rw-r--r--drivers/scsi/arm/powertec.c2
-rw-r--r--drivers/scsi/ata_piix.c6
-rw-r--r--drivers/scsi/atari_scsi.c10
-rw-r--r--drivers/scsi/g_NCR5380.c28
-rw-r--r--drivers/scsi/g_NCR5380.h23
-rw-r--r--drivers/scsi/ide-scsi.c11
-rw-r--r--drivers/scsi/in2000.c24
-rw-r--r--drivers/scsi/libata-bmdma.c273
-rw-r--r--drivers/scsi/libata-core.c565
-rw-r--r--drivers/scsi/libata-scsi.c213
-rw-r--r--drivers/scsi/megaraid/megaraid_mbox.c2
-rw-r--r--drivers/scsi/pdc_adma.c2
-rw-r--r--drivers/scsi/sata_mv.c5
-rw-r--r--drivers/scsi/sata_nv.c181
-rw-r--r--drivers/scsi/sata_sil.c2
-rw-r--r--drivers/scsi/sata_sil24.c25
-rw-r--r--drivers/scsi/sata_svw.c56
-rw-r--r--drivers/scsi/sata_uli.c37
-rw-r--r--drivers/scsi/sata_vsc.c124
-rw-r--r--drivers/scsi/scsi_sysfs.c2
-rw-r--r--drivers/scsi/sd.c2
-rw-r--r--drivers/scsi/sr.c37
-rw-r--r--drivers/scsi/sr.h1
-rw-r--r--drivers/scsi/sr_ioctl.c19
-rw-r--r--drivers/serial/21285.c19
-rw-r--r--drivers/serial/68328serial.c9
-rw-r--r--drivers/serial/8250.c26
-rw-r--r--drivers/serial/8250_early.c9
-rw-r--r--drivers/serial/8250_hp300.c10
-rw-r--r--drivers/serial/amba-pl010.c24
-rw-r--r--drivers/serial/amba-pl011.c20
-rw-r--r--drivers/serial/at91_serial.c24
-rw-r--r--drivers/serial/au1x00_uart.c37
-rw-r--r--drivers/serial/clps711x.c24
-rw-r--r--drivers/serial/crisv10.c68
-rw-r--r--drivers/serial/dz.c12
-rw-r--r--drivers/serial/imx.c26
-rw-r--r--drivers/serial/ioc4_serial.c387
-rw-r--r--drivers/serial/ip22zilog.c11
-rw-r--r--drivers/serial/m32r_sio.c41
-rw-r--r--drivers/serial/mpc52xx_uart.c13
-rw-r--r--drivers/serial/mpsc.c260
-rw-r--r--drivers/serial/mpsc.h289
-rw-r--r--drivers/serial/pmac_zilog.c23
-rw-r--r--drivers/serial/pxa.c26
-rw-r--r--drivers/serial/s3c2410.c26
-rw-r--r--drivers/serial/sa1100.c26
-rw-r--r--drivers/serial/serial_core.c21
-rw-r--r--drivers/serial/serial_lh7a40x.c17
-rw-r--r--drivers/serial/serial_txx9.c26
-rw-r--r--drivers/serial/sunsab.c10
-rw-r--r--drivers/serial/sunsu.c39
-rw-r--r--drivers/serial/sunzilog.c13
-rw-r--r--drivers/serial/vr41xx_siu.c16
-rw-r--r--drivers/tc/zs.c9
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/Makefile14
-rw-r--r--drivers/usb/image/microtek.c2
-rw-r--r--drivers/usb/input/hid-core.c2
-rw-r--r--drivers/usb/media/Kconfig241
-rw-r--r--drivers/usb/media/Makefile24
-rw-r--r--drivers/usb/media/pwc/pwc-kiara.c318
-rw-r--r--drivers/usb/media/pwc/pwc-timon.c316
-rw-r--r--drivers/usb/serial/option.c2
-rw-r--r--drivers/video/aty/radeon_pm.c2
-rw-r--r--drivers/video/backlight/locomolcd.c23
-rw-r--r--drivers/video/bw2.c3
-rw-r--r--drivers/video/cirrusfb.c2
-rw-r--r--drivers/video/ffb.c3
-rw-r--r--drivers/video/hpfb.c4
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c1
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.h1
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.c1
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.h1
-rw-r--r--drivers/video/matrox/matroxfb_base.c1
-rw-r--r--drivers/video/matrox/matroxfb_misc.c1
-rw-r--r--drivers/video/pm3fb.c18
-rw-r--r--drivers/video/sstfb.c2
-rw-r--r--drivers/w1/Kconfig60
-rw-r--r--drivers/w1/Makefile10
-rw-r--r--drivers/w1/masters/Kconfig48
-rw-r--r--drivers/w1/masters/Makefile13
-rw-r--r--drivers/w1/masters/ds2482.c564
-rw-r--r--drivers/w1/masters/ds_w1_bridge.c (renamed from drivers/w1/ds_w1_bridge.c)38
-rw-r--r--drivers/w1/masters/dscore.c (renamed from drivers/w1/dscore.c)4
-rw-r--r--drivers/w1/masters/dscore.h (renamed from drivers/w1/dscore.h)0
-rw-r--r--drivers/w1/masters/matrox_w1.c (renamed from drivers/w1/matrox_w1.c)24
-rw-r--r--drivers/w1/slaves/Kconfig38
-rw-r--r--drivers/w1/slaves/Makefile12
-rw-r--r--drivers/w1/slaves/w1_ds2433.c (renamed from drivers/w1/w1_ds2433.c)8
-rw-r--r--drivers/w1/slaves/w1_smem.c (renamed from drivers/w1/w1_smem.c)10
-rw-r--r--drivers/w1/slaves/w1_therm.c (renamed from drivers/w1/w1_therm.c)14
-rw-r--r--drivers/w1/w1.c77
-rw-r--r--drivers/w1/w1.h37
-rw-r--r--drivers/w1/w1_family.c2
-rw-r--r--drivers/w1/w1_int.c49
-rw-r--r--drivers/w1/w1_io.c2
-rw-r--r--drivers/zorro/zorro-driver.c9
-rw-r--r--fs/9p/9p.h11
-rw-r--r--fs/9p/Makefile10
-rw-r--r--fs/9p/conv.c15
-rw-r--r--fs/9p/conv.h9
-rw-r--r--fs/9p/debug.h6
-rw-r--r--fs/9p/error.c5
-rw-r--r--fs/9p/error.h5
-rw-r--r--fs/9p/fcall.c (renamed from fs/9p/9p.c)20
-rw-r--r--fs/9p/fcprint.c346
-rw-r--r--fs/9p/fid.c5
-rw-r--r--fs/9p/fid.h5
-rw-r--r--fs/9p/mux.c54
-rw-r--r--fs/9p/mux.h7
-rw-r--r--fs/9p/trans_fd.c301
-rw-r--r--fs/9p/trans_sock.c334
-rw-r--r--fs/9p/transport.h5
-rw-r--r--fs/9p/v9fs.c15
-rw-r--r--fs/9p/v9fs.h8
-rw-r--r--fs/9p/v9fs_vfs.h5
-rw-r--r--fs/9p/vfs_addr.c5
-rw-r--r--fs/9p/vfs_dentry.c7
-rw-r--r--fs/9p/vfs_dir.c5
-rw-r--r--fs/9p/vfs_file.c37
-rw-r--r--fs/9p/vfs_inode.c56
-rw-r--r--fs/9p/vfs_super.c7
-rw-r--r--fs/Kconfig12
-rw-r--r--fs/Makefile1
-rw-r--r--fs/adfs/file.c4
-rw-r--r--fs/adfs/super.c3
-rw-r--r--fs/affs/super.c3
-rw-r--r--fs/afs/cmservice.c2
-rw-r--r--fs/afs/super.c2
-rw-r--r--fs/aio.c3
-rw-r--r--fs/autofs4/autofs_i.h3
-rw-r--r--fs/autofs4/inode.c2
-rw-r--r--fs/autofs4/waitq.c16
-rw-r--r--fs/befs/datastream.c2
-rw-r--r--fs/befs/linuxvfs.c3
-rw-r--r--fs/bfs/inode.c3
-rw-r--r--fs/binfmt_elf.c5
-rw-r--r--fs/binfmt_elf_fdpic.c3
-rw-r--r--fs/binfmt_flat.c73
-rw-r--r--fs/bio.c19
-rw-r--r--fs/block_dev.c37
-rw-r--r--fs/buffer.c93
-rw-r--r--fs/char_dev.c7
-rw-r--r--fs/cifs/cifsfs.c5
-rw-r--r--fs/cifs/cifssmb.c2
-rw-r--r--fs/cifs/dir.c8
-rw-r--r--fs/cifs/fcntl.c4
-rw-r--r--fs/cifs/file.c4
-rw-r--r--fs/cifs/inode.c16
-rw-r--r--fs/cifs/link.c16
-rw-r--r--fs/cifs/readdir.c4
-rw-r--r--fs/cifs/xattr.c16
-rw-r--r--fs/coda/cache.c2
-rw-r--r--fs/coda/cnode.c3
-rw-r--r--fs/coda/coda_int.h13
-rw-r--r--fs/coda/dir.c3
-rw-r--r--fs/coda/file.c2
-rw-r--r--fs/coda/inode.c4
-rw-r--r--fs/coda/psdev.c9
-rw-r--r--fs/compat.c10
-rw-r--r--fs/compat_ioctl.c6
-rw-r--r--fs/dcache.c23
-rw-r--r--fs/devpts/inode.c76
-rw-r--r--fs/direct-io.c8
-rw-r--r--fs/dquot.c170
-rw-r--r--fs/efs/super.c2
-rw-r--r--fs/eventpoll.c36
-rw-r--r--fs/exec.c7
-rw-r--r--fs/ext2/ext2.h3
-rw-r--r--fs/ext2/namei.c54
-rw-r--r--fs/ext2/super.c6
-rw-r--r--fs/ext3/balloc.c40
-rw-r--r--fs/ext3/bitmap.c6
-rw-r--r--fs/ext3/dir.c52
-rw-r--r--fs/ext3/file.c4
-rw-r--r--fs/ext3/inode.c16
-rw-r--r--fs/ext3/ioctl.c4
-rw-r--r--fs/ext3/super.c16
-rw-r--r--fs/fat/cache.c2
-rw-r--r--fs/fat/fatent.c6
-rw-r--r--fs/fat/inode.c3
-rw-r--r--fs/fcntl.c9
-rw-r--r--fs/file.c34
-rw-r--r--fs/file_table.c10
-rw-r--r--fs/freevxfs/vxfs_super.c2
-rw-r--r--fs/fs-writeback.c2
-rw-r--r--fs/hpfs/hpfs_fn.h5
-rw-r--r--fs/hpfs/inode.c10
-rw-r--r--fs/hpfs/namei.c60
-rw-r--r--fs/hpfs/super.c7
-rw-r--r--fs/inode.c27
-rw-r--r--fs/inotify.c203
-rw-r--r--fs/isofs/inode.c3
-rw-r--r--fs/isofs/isofs.h12
-rw-r--r--fs/jbd/checkpoint.c4
-rw-r--r--fs/jbd/journal.c31
-rw-r--r--fs/jbd/transaction.c8
-rw-r--r--fs/jffs/inode-v23.c96
-rw-r--r--fs/jffs/intrep.c6
-rw-r--r--fs/jffs/jffs_fm.c2
-rw-r--r--fs/jffs/jffs_fm.h5
-rw-r--r--fs/jffs2/super.c7
-rw-r--r--fs/jfs/jfs_debug.c2
-rw-r--r--fs/jfs/super.c3
-rw-r--r--fs/libfs.c14
-rw-r--r--fs/lockd/mon.c6
-rw-r--r--fs/lockd/svc.c2
-rw-r--r--fs/lockd/xdr.c2
-rw-r--r--fs/mbcache.c2
-rw-r--r--fs/minix/bitmap.c10
-rw-r--r--fs/minix/inode.c29
-rw-r--r--fs/minix/itree_v1.c4
-rw-r--r--fs/minix/itree_v2.c4
-rw-r--r--fs/minix/namei.c48
-rw-r--r--fs/namei.c34
-rw-r--r--fs/ncpfs/file.c4
-rw-r--r--fs/ncpfs/inode.c9
-rw-r--r--fs/ncpfs/ncplib_kernel.c4
-rw-r--r--fs/ncpfs/sock.c34
-rw-r--r--fs/nfs/direct.c3
-rw-r--r--fs/nfs/inode.c11
-rw-r--r--fs/nfs/mount_clnt.c2
-rw-r--r--fs/nfs/nfs2xdr.c2
-rw-r--r--fs/nfs/nfs3xdr.c2
-rw-r--r--fs/nfs/nfs4xdr.c2
-rw-r--r--fs/nfsctl.c2
-rw-r--r--fs/nfsd/nfs4acl.c4
-rw-r--r--fs/nfsd/nfs4callback.c4
-rw-r--r--fs/nfsd/nfs4xdr.c2
-rw-r--r--fs/nfsd/nfsctl.c2
-rw-r--r--fs/nfsd/nfssvc.c4
-rw-r--r--fs/nls/nls_euc-jp.c6
-rw-r--r--fs/ntfs/ChangeLog30
-rw-r--r--fs/ntfs/Makefile2
-rw-r--r--fs/ntfs/aops.c14
-rw-r--r--fs/ntfs/attrib.c35
-rw-r--r--fs/ntfs/compress.c4
-rw-r--r--fs/ntfs/dir.c2
-rw-r--r--fs/ntfs/file.c16
-rw-r--r--fs/ntfs/inode.c111
-rw-r--r--fs/ntfs/inode.h13
-rw-r--r--fs/ntfs/layout.h44
-rw-r--r--fs/ntfs/mft.c68
-rw-r--r--fs/ntfs/mft.h5
-rw-r--r--fs/ntfs/namei.c9
-rw-r--r--fs/ntfs/ntfs.h2
-rw-r--r--fs/ntfs/runlist.c12
-rw-r--r--fs/ntfs/super.c88
-rw-r--r--fs/ntfs/unistr.c51
-rw-r--r--fs/ocfs2/dlm/dlmfs.c3
-rw-r--r--fs/ocfs2/super.c8
-rw-r--r--fs/open.c12
-rw-r--r--fs/partitions/ibm.c29
-rw-r--r--fs/pipe.c3
-rw-r--r--fs/pnode.c2
-rw-r--r--fs/proc/inode.c3
-rw-r--r--fs/proc/proc_misc.c39
-rw-r--r--fs/qnx4/file.c3
-rw-r--r--fs/qnx4/inode.c3
-rw-r--r--fs/quota.c6
-rw-r--r--fs/quota_v2.c2
-rw-r--r--fs/ramfs/file-mmu.c11
-rw-r--r--fs/read_write.c2
-rw-r--r--fs/reiserfs/file.c10
-rw-r--r--fs/reiserfs/fix_node.c4
-rw-r--r--fs/reiserfs/item_ops.c2
-rw-r--r--fs/reiserfs/journal.c21
-rw-r--r--fs/reiserfs/prints.c9
-rw-r--r--fs/reiserfs/stree.c210
-rw-r--r--fs/reiserfs/super.c11
-rw-r--r--fs/reiserfs/xattr_acl.c4
-rw-r--r--fs/relayfs/Makefile4
-rw-r--r--fs/relayfs/buffers.c190
-rw-r--r--fs/relayfs/buffers.h12
-rw-r--r--fs/relayfs/inode.c581
-rw-r--r--fs/relayfs/relay.c482
-rw-r--r--fs/relayfs/relay.h8
-rw-r--r--fs/romfs/inode.c3
-rw-r--r--fs/seq_file.c10
-rw-r--r--fs/smbfs/inode.c5
-rw-r--r--fs/super.c19
-rw-r--r--fs/sysv/inode.c2
-rw-r--r--fs/sysv/namei.c48
-rw-r--r--fs/sysv/super.c4
-rw-r--r--fs/udf/balloc.c36
-rw-r--r--fs/udf/ialloc.c8
-rw-r--r--fs/udf/inode.c6
-rw-r--r--fs/udf/super.c24
-rw-r--r--fs/ufs/file.c10
-rw-r--r--fs/ufs/namei.c48
-rw-r--r--fs/ufs/super.c5
-rw-r--r--fs/xfs/Makefile-linux-2.640
-rw-r--r--fs/xfs/linux-2.6/kmem.h91
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.c484
-rw-r--r--fs/xfs/linux-2.6/xfs_aops.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c7
-rw-r--r--fs/xfs/linux-2.6/xfs_export.c37
-rw-r--r--fs/xfs/linux-2.6/xfs_file.c187
-rw-r--r--fs/xfs/linux-2.6/xfs_fs_subr.c6
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl.c138
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.c12
-rw-r--r--fs/xfs/linux-2.6/xfs_ioctl32.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c317
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h12
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h10
-rw-r--r--fs/xfs/linux-2.6/xfs_lrw.c51
-rw-r--r--fs/xfs/linux-2.6/xfs_stats.c9
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c213
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h7
-rw-r--r--fs/xfs/linux-2.6/xfs_sysctl.c3
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.c19
-rw-r--r--fs/xfs/linux-2.6/xfs_vfs.h3
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.c35
-rw-r--r--fs/xfs/linux-2.6/xfs_vnode.h33
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c2
-rw-r--r--fs/xfs/quota/xfs_qm.c13
-rw-r--r--fs/xfs/quota/xfs_qm_bhv.c4
-rw-r--r--fs/xfs/support/ktrace.c4
-rw-r--r--fs/xfs/support/uuid.c15
-rw-r--r--fs/xfs/xfs_acl.h4
-rw-r--r--fs/xfs/xfs_attr.c59
-rw-r--r--fs/xfs/xfs_attr_leaf.c729
-rw-r--r--fs/xfs/xfs_attr_leaf.h47
-rw-r--r--fs/xfs/xfs_attr_sf.h8
-rw-r--r--fs/xfs/xfs_bmap.c1305
-rw-r--r--fs/xfs/xfs_bmap.h22
-rw-r--r--fs/xfs/xfs_bmap_btree.c10
-rw-r--r--fs/xfs/xfs_bmap_btree.h8
-rw-r--r--fs/xfs/xfs_clnt.h2
-rw-r--r--fs/xfs/xfs_da_btree.c409
-rw-r--r--fs/xfs/xfs_da_btree.h16
-rw-r--r--fs/xfs/xfs_dfrag.c4
-rw-r--r--fs/xfs/xfs_dir.c32
-rw-r--r--fs/xfs/xfs_dir2.h27
-rw-r--r--fs/xfs/xfs_dir2_block.c193
-rw-r--r--fs/xfs/xfs_dir2_block.h7
-rw-r--r--fs/xfs/xfs_dir2_data.c240
-rw-r--r--fs/xfs/xfs_dir2_data.h26
-rw-r--r--fs/xfs/xfs_dir2_leaf.c285
-rw-r--r--fs/xfs/xfs_dir2_leaf.h15
-rw-r--r--fs/xfs/xfs_dir2_node.c303
-rw-r--r--fs/xfs/xfs_dir2_node.h10
-rw-r--r--fs/xfs/xfs_dir2_sf.c8
-rw-r--r--fs/xfs/xfs_dir_leaf.c82
-rw-r--r--fs/xfs/xfs_dir_sf.h24
-rw-r--r--fs/xfs/xfs_dmapi.h10
-rw-r--r--fs/xfs/xfs_fsops.c1
-rw-r--r--fs/xfs/xfs_ialloc.c13
-rw-r--r--fs/xfs/xfs_iget.c6
-rw-r--r--fs/xfs/xfs_inode.c1303
-rw-r--r--fs/xfs/xfs_inode.h78
-rw-r--r--fs/xfs/xfs_iomap.c2
-rw-r--r--fs/xfs/xfs_itable.c5
-rw-r--r--fs/xfs/xfs_log_recover.c2
-rw-r--r--fs/xfs/xfs_mount.c646
-rw-r--r--fs/xfs/xfs_mount.h44
-rw-r--r--fs/xfs/xfs_rw.h1
-rw-r--r--fs/xfs/xfs_trans.c187
-rw-r--r--fs/xfs/xfs_trans.h2
-rw-r--r--fs/xfs/xfs_vfsops.c82
-rw-r--r--fs/xfs/xfs_vnodeops.c17
-rw-r--r--include/acpi/acpi_bus.h3
-rw-r--r--include/asm-alpha/io.h84
-rw-r--r--include/asm-alpha/mmu_context.h5
-rw-r--r--include/asm-alpha/poll.h2
-rw-r--r--include/asm-alpha/topology.h4
-rw-r--r--include/asm-arm/arch-aaec2000/param.h15
-rw-r--r--include/asm-arm/arch-at91rm9200/at91rm9200_emac.h138
-rw-r--r--include/asm-arm/arch-at91rm9200/param.h28
-rw-r--r--include/asm-arm/arch-cl7500/debug-macro.S14
-rw-r--r--include/asm-arm/arch-cl7500/param.h5
-rw-r--r--include/asm-arm/arch-clps711x/param.h19
-rw-r--r--include/asm-arm/arch-ebsa110/debug-macro.S19
-rw-r--r--include/asm-arm/arch-ebsa110/param.h4
-rw-r--r--include/asm-arm/arch-ebsa285/debug-macro.S18
-rw-r--r--include/asm-arm/arch-ebsa285/param.h3
-rw-r--r--include/asm-arm/arch-ep93xx/debug-macro.S22
-rw-r--r--include/asm-arm/arch-ep93xx/dma.h3
-rw-r--r--include/asm-arm/arch-ep93xx/entry-macro.S53
-rw-r--r--include/asm-arm/arch-ep93xx/ep93xx-regs.h125
-rw-r--r--include/asm-arm/arch-ep93xx/gesbc9312.h3
-rw-r--r--include/asm-arm/arch-ep93xx/gpio.h107
-rw-r--r--include/asm-arm/arch-ep93xx/hardware.h12
-rw-r--r--include/asm-arm/arch-ep93xx/io.h8
-rw-r--r--include/asm-arm/arch-ep93xx/irqs.h80
-rw-r--r--include/asm-arm/arch-ep93xx/memory.h14
-rw-r--r--include/asm-arm/arch-ep93xx/platform.h14
-rw-r--r--include/asm-arm/arch-ep93xx/system.h26
-rw-r--r--include/asm-arm/arch-ep93xx/timex.h5
-rw-r--r--include/asm-arm/arch-ep93xx/ts72xx.h90
-rw-r--r--include/asm-arm/arch-ep93xx/uncompress.h53
-rw-r--r--include/asm-arm/arch-ep93xx/vmalloc.h5
-rw-r--r--include/asm-arm/arch-h720x/irq.h14
-rw-r--r--include/asm-arm/arch-h720x/param.h10
-rw-r--r--include/asm-arm/arch-imx/irq.h20
-rw-r--r--include/asm-arm/arch-imx/param.h19
-rw-r--r--include/asm-arm/arch-integrator/debug-macro.S18
-rw-r--r--include/asm-arm/arch-integrator/param.h19
-rw-r--r--include/asm-arm/arch-iop3xx/debug-macro.S19
-rw-r--r--include/asm-arm/arch-iop3xx/param.h3
-rw-r--r--include/asm-arm/arch-ixp2000/debug-macro.S17
-rw-r--r--include/asm-arm/arch-ixp2000/irq.h13
-rw-r--r--include/asm-arm/arch-ixp2000/ixdp2x00.h5
-rw-r--r--include/asm-arm/arch-ixp2000/ixp2000-regs.h4
-rw-r--r--include/asm-arm/arch-ixp2000/param.h3
-rw-r--r--include/asm-arm/arch-ixp2000/system.h2
-rw-r--r--include/asm-arm/arch-ixp4xx/debug-macro.S15
-rw-r--r--include/asm-arm/arch-ixp4xx/irq.h13
-rw-r--r--include/asm-arm/arch-ixp4xx/param.h3
-rw-r--r--include/asm-arm/arch-ixp4xx/platform.h27
-rw-r--r--include/asm-arm/arch-l7200/param.h19
-rw-r--r--include/asm-arm/arch-lh7a40x/irq.h11
-rw-r--r--include/asm-arm/arch-lh7a40x/param.h9
-rw-r--r--include/asm-arm/arch-omap/param.h8
-rw-r--r--include/asm-arm/arch-pxa/debug-macro.S17
-rw-r--r--include/asm-arm/arch-pxa/irq.h14
-rw-r--r--include/asm-arm/arch-pxa/param.h3
-rw-r--r--include/asm-arm/arch-realview/debug-macro.S18
-rw-r--r--include/asm-arm/arch-realview/param.h19
-rw-r--r--include/asm-arm/arch-rpc/debug-macro.S19
-rw-r--r--include/asm-arm/arch-rpc/param.h3
-rw-r--r--include/asm-arm/arch-s3c2410/osiris-cpld.h25
-rw-r--r--include/asm-arm/arch-s3c2410/osiris-map.h41
-rw-r--r--include/asm-arm/arch-s3c2410/param.h27
-rw-r--r--include/asm-arm/arch-s3c2410/regs-gpio.h2
-rw-r--r--include/asm-arm/arch-sa1100/debug-macro.S1
-rw-r--r--include/asm-arm/arch-sa1100/param.h3
-rw-r--r--include/asm-arm/arch-shark/param.h5
-rw-r--r--include/asm-arm/arch-versatile/debug-macro.S18
-rw-r--r--include/asm-arm/arch-versatile/param.h19
-rw-r--r--include/asm-arm/delay.h12
-rw-r--r--include/asm-arm/hardware/debug-8250.S29
-rw-r--r--include/asm-arm/hardware/debug-pl01x.S29
-rw-r--r--include/asm-arm/hardware/uengine.h (renamed from include/asm-arm/arch-ixp2000/uengine.h)0
-rw-r--r--include/asm-arm/hardware/vic.h2
-rw-r--r--include/asm-arm/io.h36
-rw-r--r--include/asm-arm/mach/arch.h5
-rw-r--r--include/asm-arm/mach/irq.h7
-rw-r--r--include/asm-arm/param.h7
-rw-r--r--include/asm-arm/poll.h1
-rw-r--r--include/asm-arm26/poll.h1
-rw-r--r--include/asm-cris/poll.h1
-rw-r--r--include/asm-cris/system.h2
-rw-r--r--include/asm-frv/poll.h1
-rw-r--r--include/asm-generic/bug.h4
-rw-r--r--include/asm-generic/percpu.h7
-rw-r--r--include/asm-h8300/poll.h1
-rw-r--r--include/asm-i386/alternative.h129
-rw-r--r--include/asm-i386/arch_hooks.h3
-rw-r--r--include/asm-i386/atomic.h36
-rw-r--r--include/asm-i386/bitops.h7
-rw-r--r--include/asm-i386/cache.h2
-rw-r--r--include/asm-i386/cpufeature.h1
-rw-r--r--include/asm-i386/io.h12
-rw-r--r--include/asm-i386/mach-default/do_timer.h2
-rw-r--r--include/asm-i386/mach-es7000/mach_mpparse.h10
-rw-r--r--include/asm-i386/mach-visws/do_timer.h2
-rw-r--r--include/asm-i386/mach-voyager/do_timer.h2
-rw-r--r--include/asm-i386/mpspec.h1
-rw-r--r--include/asm-i386/mtrr.h1
-rw-r--r--include/asm-i386/mutex.h6
-rw-r--r--include/asm-i386/pgtable-2level.h2
-rw-r--r--include/asm-i386/pgtable-3level.h2
-rw-r--r--include/asm-i386/poll.h1
-rw-r--r--include/asm-i386/rwlock.h56
-rw-r--r--include/asm-i386/semaphore.h8
-rw-r--r--include/asm-i386/spinlock.h34
-rw-r--r--include/asm-i386/system.h64
-rw-r--r--include/asm-i386/uaccess.h12
-rw-r--r--include/asm-i386/unistd.h36
-rw-r--r--include/asm-ia64/atomic.h8
-rw-r--r--include/asm-ia64/cache.h2
-rw-r--r--include/asm-ia64/linkage.h8
-rw-r--r--include/asm-ia64/poll.h1
-rw-r--r--include/asm-ia64/sn/sn_sal.h2
-rw-r--r--include/asm-ia64/system.h2
-rw-r--r--include/asm-m32r/poll.h1
-rw-r--r--include/asm-m68k/atomic.h8
-rw-r--r--include/asm-m68k/poll.h1
-rw-r--r--include/asm-mips/io.h13
-rw-r--r--include/asm-mips/linkage.h4
-rw-r--r--include/asm-mips/poll.h1
-rw-r--r--include/asm-parisc/cache.h2
-rw-r--r--include/asm-parisc/io.h18
-rw-r--r--include/asm-parisc/poll.h1
-rw-r--r--include/asm-powerpc/atomic.h38
-rw-r--r--include/asm-powerpc/cputable.h38
-rw-r--r--include/asm-powerpc/cputime.h202
-rw-r--r--include/asm-powerpc/firmware.h16
-rw-r--r--include/asm-powerpc/irq.h6
-rw-r--r--include/asm-powerpc/iseries/mf.h7
-rw-r--r--include/asm-powerpc/lmb.h19
-rw-r--r--include/asm-powerpc/mmu.h1
-rw-r--r--include/asm-powerpc/paca.h7
-rw-r--r--include/asm-powerpc/percpu.h7
-rw-r--r--include/asm-powerpc/pgtable-4k.h11
-rw-r--r--include/asm-powerpc/pgtable.h9
-rw-r--r--include/asm-powerpc/poll.h1
-rw-r--r--include/asm-powerpc/ppc_asm.h42
-rw-r--r--include/asm-powerpc/processor.h1
-rw-r--r--include/asm-powerpc/prom.h6
-rw-r--r--include/asm-powerpc/rwsem.h2
-rw-r--r--include/asm-powerpc/synch.h2
-rw-r--r--include/asm-powerpc/system.h6
-rw-r--r--include/asm-powerpc/time.h15
-rw-r--r--include/asm-ppc/harrier.h2
-rw-r--r--include/asm-ppc/ibm44x.h2
-rw-r--r--include/asm-ppc/ibm4xx.h4
-rw-r--r--include/asm-ppc/io.h7
-rw-r--r--include/asm-ppc/mpc10x.h3
-rw-r--r--include/asm-ppc/mpc52xx.h1
-rw-r--r--include/asm-ppc/mpc8260.h1
-rw-r--r--include/asm-ppc/mpc83xx.h1
-rw-r--r--include/asm-ppc/mpc85xx.h1
-rw-r--r--include/asm-ppc/mpc8xx.h3
-rw-r--r--include/asm-ppc/pgtable.h6
-rw-r--r--include/asm-ppc/ppc_sys.h34
-rw-r--r--include/asm-ppc/time.h5
-rw-r--r--include/asm-ppc/todc.h2
-rw-r--r--include/asm-ppc/xparameters.h18
-rw-r--r--include/asm-s390/atomic.h18
-rw-r--r--include/asm-s390/bug.h5
-rw-r--r--include/asm-s390/percpu.h7
-rw-r--r--include/asm-s390/poll.h1
-rw-r--r--include/asm-sh/io.h14
-rw-r--r--include/asm-sh/poll.h1
-rw-r--r--include/asm-sh64/poll.h1
-rw-r--r--include/asm-sparc/cpudata.h1
-rw-r--r--include/asm-sparc/poll.h1
-rw-r--r--include/asm-sparc/smp.h9
-rw-r--r--include/asm-sparc/spinlock.h25
-rw-r--r--include/asm-sparc64/atomic.h10
-rw-r--r--include/asm-sparc64/cache.h2
-rw-r--r--include/asm-sparc64/percpu.h7
-rw-r--r--include/asm-sparc64/poll.h1
-rw-r--r--include/asm-um/alternative.h6
-rw-r--r--include/asm-v850/linkage.h4
-rw-r--r--include/asm-v850/poll.h1
-rw-r--r--include/asm-x86_64/atomic.h8
-rw-r--r--include/asm-x86_64/cache.h2
-rw-r--r--include/asm-x86_64/io.h12
-rw-r--r--include/asm-x86_64/mmu_context.h6
-rw-r--r--include/asm-x86_64/percpu.h7
-rw-r--r--include/asm-x86_64/pgtable.h6
-rw-r--r--include/asm-x86_64/poll.h1
-rw-r--r--include/asm-xtensa/poll.h1
-rw-r--r--include/linux/ata.h7
-rw-r--r--include/linux/bitmap.h3
-rw-r--r--include/linux/bitops.h7
-rw-r--r--include/linux/blkdev.h3
-rw-r--r--include/linux/blktrace_api.h277
-rw-r--r--include/linux/cache.h4
-rw-r--r--include/linux/capability.h3
-rw-r--r--include/linux/cdrom.h5
-rw-r--r--include/linux/compat_ioctl.h4
-rw-r--r--include/linux/cpu.h1
-rw-r--r--include/linux/cpumask.h46
-rw-r--r--include/linux/cpuset.h29
-rw-r--r--include/linux/dcache.h2
-rw-r--r--include/linux/dio.h32
-rw-r--r--include/linux/eventpoll.h8
-rw-r--r--include/linux/ext3_fs.h9
-rw-r--r--include/linux/ext3_fs_i.h7
-rw-r--r--include/linux/fadvise.h6
-rw-r--r--include/linux/file.h28
-rw-r--r--include/linux/fs.h42
-rw-r--r--include/linux/fsnotify.h19
-rw-r--r--include/linux/generic_serial.h4
-rw-r--r--include/linux/genhd.h14
-rw-r--r--include/linux/hwmon-sysfs.h24
-rw-r--r--include/linux/i2c-id.h2
-rw-r--r--include/linux/i2c.h6
-rw-r--r--include/linux/ide.h1
-rw-r--r--include/linux/init.h4
-rw-r--r--include/linux/init_task.h10
-rw-r--r--include/linux/inotify.h11
-rw-r--r--include/linux/irq.h49
-rw-r--r--include/linux/jbd.h11
-rw-r--r--include/linux/kernel.h8
-rw-r--r--include/linux/kprobes.h3
-rw-r--r--include/linux/libata.h16
-rw-r--r--include/linux/linkage.h16
-rw-r--r--include/linux/loop.h3
-rw-r--r--include/linux/major.h1
-rw-r--r--include/linux/mempolicy.h5
-rw-r--r--include/linux/module.h20
-rw-r--r--include/linux/moduleparam.h7
-rw-r--r--include/linux/msdos_fs.h3
-rw-r--r--include/linux/nbd.h3
-rw-r--r--include/linux/ncp_fs_i.h2
-rw-r--r--include/linux/ncp_fs_sb.h5
-rw-r--r--include/linux/netfilter/x_tables.h64
-rw-r--r--include/linux/netfilter_arp/arp_tables.h37
-rw-r--r--include/linux/netfilter_ipv4/ip_tables.h70
-rw-r--r--include/linux/netfilter_ipv6/ip6_tables.h69
-rw-r--r--include/linux/pagemap.h5
-rw-r--r--include/linux/pci.h12
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/platform.h43
-rw-r--r--include/linux/pm.h3
-rw-r--r--include/linux/ppdev.h2
-rw-r--r--include/linux/profile.h2
-rw-r--r--include/linux/quota.h8
-rw-r--r--include/linux/radix-tree.h13
-rw-r--r--include/linux/raid/raid1.h2
-rw-r--r--include/linux/rcupdate.h2
-rw-r--r--include/linux/reiserfs_fs.h5
-rw-r--r--include/linux/reiserfs_xattr.h6
-rw-r--r--include/linux/relay.h281
-rw-r--r--include/linux/rtnetlink.h4
-rw-r--r--include/linux/sched.h9
-rw-r--r--include/linux/security.h22
-rw-r--r--include/linux/seq_file.h4
-rw-r--r--include/linux/serial_core.h3
-rw-r--r--include/linux/slab.h39
-rw-r--r--include/linux/string.h2
-rw-r--r--include/linux/swap.h5
-rw-r--r--include/linux/syscalls.h1
-rw-r--r--include/linux/time.h1
-rw-r--r--include/linux/timer.h6
-rw-r--r--include/linux/timex.h41
-rw-r--r--include/linux/tty.h8
-rw-r--r--include/linux/tty_flip.h16
-rw-r--r--include/linux/udf_fs_i.h21
-rw-r--r--include/linux/udf_fs_sb.h4
-rw-r--r--include/linux/videodev2.h1
-rw-r--r--include/linux/vt_kern.h5
-rw-r--r--include/linux/wireless.h10
-rw-r--r--include/linux/writeback.h14
-rw-r--r--include/linux/zorro.h33
-rw-r--r--include/media/audiochip.h14
-rw-r--r--include/media/cs53l32a.h34
-rw-r--r--include/media/i2c-addr.h44
-rw-r--r--include/media/msp3400.h226
-rw-r--r--include/media/rds.h (renamed from drivers/media/video/rds.h)4
-rw-r--r--include/media/saa7146_vv.h3
-rw-r--r--include/media/tvaudio.h30
-rw-r--r--include/media/v4l2-common.h19
-rw-r--r--include/media/video-buf.h56
-rw-r--r--include/media/wm8775.h35
-rw-r--r--include/net/ieee80211softmac.h292
-rw-r--r--include/net/ieee80211softmac_wx.h94
-rw-r--r--include/net/iw_handler.h12
-rw-r--r--include/net/netfilter/nf_conntrack.h4
-rw-r--r--include/net/route.h2
-rw-r--r--include/net/sock.h2
-rw-r--r--include/net/tc_act/tc_ipt.h4
-rw-r--r--include/scsi/scsi_host.h2
-rw-r--r--include/sound/opl3.h1
-rw-r--r--include/video/pm3fb.h3
-rw-r--r--init/Kconfig57
-rw-r--r--init/do_mounts.c2
-rw-r--r--init/do_mounts_initrd.c1
-rw-r--r--init/initramfs.c10
-rw-r--r--init/main.c50
-rw-r--r--ipc/msg.c3
-rw-r--r--ipc/shm.c3
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/auditsc.c2
-rw-r--r--kernel/capability.c16
-rw-r--r--kernel/cpu.c3
-rw-r--r--kernel/cpuset.c364
-rw-r--r--kernel/exec_domain.c1
-rw-r--r--kernel/exit.c4
-rw-r--r--kernel/fork.c10
-rw-r--r--kernel/irq/Makefile3
-rw-r--r--kernel/irq/manage.c23
-rw-r--r--kernel/irq/migration.c65
-rw-r--r--kernel/itimer.c103
-rw-r--r--kernel/kprobes.c14
-rw-r--r--kernel/ksysfs.c4
-rw-r--r--kernel/kthread.c9
-rw-r--r--kernel/module.c255
-rw-r--r--kernel/panic.c97
-rw-r--r--kernel/params.c12
-rw-r--r--kernel/posix-timers.c1
-rw-r--r--kernel/power/Makefile2
-rw-r--r--kernel/power/disk.c20
-rw-r--r--kernel/power/main.c2
-rw-r--r--kernel/power/pm.c21
-rw-r--r--kernel/power/power.h75
-rw-r--r--kernel/power/process.c61
-rw-r--r--kernel/power/smp.c4
-rw-r--r--kernel/power/snapshot.c335
-rw-r--r--kernel/power/swap.c544
-rw-r--r--kernel/power/swsusp.c887
-rw-r--r--kernel/power/user.c333
-rw-r--r--kernel/printk.c76
-rw-r--r--kernel/profile.c11
-rw-r--r--kernel/rcupdate.c19
-rw-r--r--kernel/rcutorture.c33
-rw-r--r--kernel/relay.c1012
-rw-r--r--kernel/sched.c13
-rw-r--r--kernel/signal.c11
-rw-r--r--kernel/softlockup.c55
-rw-r--r--kernel/spinlock.c9
-rw-r--r--kernel/sys.c114
-rw-r--r--kernel/sysctl.c19
-rw-r--r--kernel/time.c59
-rw-r--r--kernel/timer.c74
-rw-r--r--kernel/user.c10
-rw-r--r--lib/Kconfig.debug17
-rw-r--r--lib/Makefile2
-rw-r--r--lib/bitmap.c163
-rw-r--r--lib/cpumask.c45
-rw-r--r--lib/extable.c1
-rw-r--r--lib/radix-tree.c49
-rw-r--r--lib/reed_solomon/reed_solomon.c11
-rw-r--r--lib/swiotlb.c32
-rw-r--r--mm/Kconfig4
-rw-r--r--mm/fadvise.c46
-rw-r--r--mm/filemap.c41
-rw-r--r--mm/highmem.c3
-rw-r--r--mm/memory.c8
-rw-r--r--mm/mempolicy.c32
-rw-r--r--mm/mmap.c6
-rw-r--r--mm/msync.c139
-rw-r--r--mm/page-writeback.c64
-rw-r--r--mm/page_alloc.c11
-rw-r--r--mm/readahead.c1
-rw-r--r--mm/slab.c351
-rw-r--r--mm/slob.c10
-rw-r--r--mm/swapfile.c57
-rw-r--r--mm/util.c47
-rw-r--r--mm/vmscan.c2
-rw-r--r--net/bluetooth/af_bluetooth.c3
-rw-r--r--net/bridge/br_stp_bpdu.c5
-rw-r--r--net/core/datagram.c2
-rw-r--r--net/core/dev.c7
-rw-r--r--net/core/pktgen.c158
-rw-r--r--net/core/rtnetlink.c98
-rw-r--r--net/core/skbuff.c2
-rw-r--r--net/core/sock.c5
-rw-r--r--net/core/wireless.c911
-rw-r--r--net/dccp/proto.c2
-rw-r--r--net/ieee80211/Kconfig1
-rw-r--r--net/ieee80211/Makefile1
-rw-r--r--net/ieee80211/ieee80211_rx.c74
-rw-r--r--net/ieee80211/softmac/Kconfig10
-rw-r--r--net/ieee80211/softmac/Makefile9
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_assoc.c396
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_auth.c364
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_event.c159
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_io.c474
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_module.c457
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_priv.h230
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_scan.c244
-rw-r--r--net/ieee80211/softmac/ieee80211softmac_wx.c412
-rw-r--r--net/ipv4/fib_rules.c27
-rw-r--r--net/ipv4/icmp.c2
-rw-r--r--net/ipv4/inet_hashtables.c2
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/netfilter/arp_tables.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c72
-rw-r--r--net/ipv4/netfilter/ip_nat_standalone.c2
-rw-r--r--net/ipv4/netfilter/ip_tables.c15
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c1
-rw-r--r--net/ipv4/route.c45
-rw-r--r--net/ipv4/tcp.c28
-rw-r--r--net/ipv6/ip6_output.c2
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c15
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c1
-rw-r--r--net/netfilter/Kconfig6
-rw-r--r--net/netfilter/nf_conntrack_core.c35
-rw-r--r--net/netfilter/nf_conntrack_netlink.c84
-rw-r--r--net/netfilter/nf_conntrack_standalone.c2
-rw-r--r--net/netfilter/nfnetlink_queue.c19
-rw-r--r--net/netfilter/x_tables.c72
-rw-r--r--net/netfilter/xt_CLASSIFY.c12
-rw-r--r--net/netfilter/xt_CONNMARK.c12
-rw-r--r--net/netfilter/xt_MARK.c21
-rw-r--r--net/netfilter/xt_NFQUEUE.c19
-rw-r--r--net/netfilter/xt_NOTRACK.c12
-rw-r--r--net/netfilter/xt_comment.c12
-rw-r--r--net/netfilter/xt_connbytes.c12
-rw-r--r--net/netfilter/xt_connmark.c29
-rw-r--r--net/netfilter/xt_conntrack.c33
-rw-r--r--net/netfilter/xt_dccp.c12
-rw-r--r--net/netfilter/xt_helper.c29
-rw-r--r--net/netfilter/xt_length.c12
-rw-r--r--net/netfilter/xt_limit.c12
-rw-r--r--net/netfilter/xt_mac.c12
-rw-r--r--net/netfilter/xt_mark.c12
-rw-r--r--net/netfilter/xt_physdev.c12
-rw-r--r--net/netfilter/xt_pkttype.c12
-rw-r--r--net/netfilter/xt_policy.c18
-rw-r--r--net/netfilter/xt_realm.c5
-rw-r--r--net/netfilter/xt_sctp.c12
-rw-r--r--net/netfilter/xt_state.c41
-rw-r--r--net/netfilter/xt_string.c12
-rw-r--r--net/netfilter/xt_tcpmss.c12
-rw-r--r--net/netfilter/xt_tcpudp.c26
-rw-r--r--net/rxrpc/main.c2
-rw-r--r--net/sched/cls_u32.c6
-rw-r--r--net/sctp/input.c12
-rw-r--r--net/sctp/socket.c2
-rw-r--r--net/socket.c3
-rw-r--r--net/sunrpc/rpc_pipe.c7
-rw-r--r--net/tipc/link.c2
-rw-r--r--net/unix/af_unix.c2
-rw-r--r--scripts/Kbuild.include65
-rw-r--r--scripts/Makefile.build27
-rw-r--r--scripts/Makefile.clean10
-rw-r--r--scripts/Makefile.modinst10
-rw-r--r--scripts/Makefile.modpost21
-rw-r--r--scripts/basic/fixdep.c14
-rwxr-xr-xscripts/checkconfig.pl65
-rwxr-xr-xscripts/extract-ikconfig5
-rw-r--r--scripts/genksyms/genksyms.c843
-rw-r--r--scripts/genksyms/genksyms.h57
-rw-r--r--scripts/kallsyms.c12
-rw-r--r--scripts/kconfig/Makefile6
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/lxdialog/Makefile6
-rw-r--r--scripts/mkmakefile8
-rw-r--r--scripts/mod/file2alias.c17
-rw-r--r--scripts/mod/mk_elfconfig.c4
-rw-r--r--scripts/mod/modpost.c698
-rw-r--r--scripts/mod/modpost.h25
-rw-r--r--scripts/mod/sumversion.c32
-rw-r--r--scripts/namespace.pl4
-rw-r--r--scripts/package/Makefile20
-rw-r--r--scripts/reference_discarded.pl112
-rw-r--r--scripts/reference_init.pl108
-rw-r--r--security/commoncap.c4
-rw-r--r--security/keys/key.c18
-rw-r--r--security/keys/keyctl.c155
-rw-r--r--security/seclvl.c210
-rw-r--r--security/security.c23
-rw-r--r--sound/oss/.gitignore4
-rw-r--r--sound/oss/ac97_codec.c24
-rw-r--r--sound/oss/aci.c11
-rw-r--r--sound/oss/ad1889.c7
-rw-r--r--sound/oss/ad1889.h2
-rw-r--r--sound/oss/ali5455.c8
-rw-r--r--sound/oss/au1000.c46
-rw-r--r--sound/oss/au1550_ac97.c46
-rw-r--r--sound/oss/awe_wave.c6
-rw-r--r--sound/oss/btaudio.c36
-rw-r--r--sound/oss/cmpci.c20
-rw-r--r--sound/oss/cs4281/cs4281m.c54
-rw-r--r--sound/oss/cs46xx.c75
-rw-r--r--sound/oss/dmasound/dmasound_awacs.c12
-rw-r--r--sound/oss/dmasound/dmasound_core.c10
-rw-r--r--sound/oss/emu10k1/hwaccess.h2
-rw-r--r--sound/oss/emu10k1/main.c2
-rw-r--r--sound/oss/emu10k1/midi.c14
-rw-r--r--sound/oss/es1370.c71
-rw-r--r--sound/oss/es1371.c71
-rw-r--r--sound/oss/esssolo1.c50
-rw-r--r--sound/oss/forte.c11
-rw-r--r--sound/oss/hal2.c22
-rw-r--r--sound/oss/i810_audio.c8
-rw-r--r--sound/oss/ite8172.c24
-rw-r--r--sound/oss/maestro.c26
-rw-r--r--sound/oss/maestro3.c20
-rw-r--r--sound/oss/nec_vrc5477.c20
-rw-r--r--sound/oss/rme96xx.c17
-rw-r--r--sound/oss/sb_mixer.c6
-rw-r--r--sound/oss/sequencer.c4
-rw-r--r--sound/oss/sonicvibes.c48
-rw-r--r--sound/oss/swarm_cs4297a.c43
-rw-r--r--sound/oss/trident.c62
-rw-r--r--sound/oss/via82cxxx_audio.c49
-rw-r--r--sound/oss/vwsnd.c61
-rw-r--r--sound/oss/waveartist.c8
-rw-r--r--sound/oss/ymfpci.c14
-rw-r--r--sound/oss/ymfpci.h3
-rw-r--r--sound/ppc/daca.c1
-rw-r--r--sound/ppc/keywest.c1
-rw-r--r--sound/ppc/toonie.c5
-rw-r--r--sound/ppc/tumbler.c1
-rw-r--r--sound/sparc/cs4231.c6
2025 files changed, 56361 insertions, 35752 deletions
diff --git a/CREDITS b/CREDITS
index af70678a0af..c6d69bf10e1 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2007,13 +2007,14 @@ S: University of Stuttgart, Germany and
S: Ecole Nationale Superieure des Telecommunications, Paris
N: Jamie Lokier
-E: jamie@imbolc.ucc.ie
+E: jamie@shareable.org
+W: http://www.shareable.org/
D: Reboot-through-BIOS for broken 486 motherboards
-D: Some parport fixes
-S: 11 Goodson Walk
-S: Marston
+D: Parport fixes, futex improvements
+D: First instruction of x86 sysenter path :)
+S: 51 Sunningwell Road
S: Oxford
-S: OX3 0HX
+S: OX1 4SZ
S: United Kingdom
N: Mark Lord
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 2975291e296..7d87dd73cbe 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -28,7 +28,7 @@ PS_METHOD = $(prefer-db2x)
###
# The targets that may be used.
-.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
+PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
xmldocs: $(BOOKS)
@@ -211,3 +211,9 @@ clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS))
#man put files in man subdir - traverse down
subdir- := man/
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/Documentation/DocBook/deviceiobook.tmpl b/Documentation/DocBook/deviceiobook.tmpl
index 6f41f2f5c6f..90ed23df1f6 100644
--- a/Documentation/DocBook/deviceiobook.tmpl
+++ b/Documentation/DocBook/deviceiobook.tmpl
@@ -270,25 +270,6 @@ CPU B: spin_unlock_irqrestore(&dev_lock, flags)
</para>
</sect1>
- <sect1>
- <title>ISA legacy functions</title>
- <para>
- On older kernels (2.2 and earlier) the ISA bus could be read or
- written with these functions and without ioremap being used. This is
- no longer true in Linux 2.4. A set of equivalent functions exist for
- easy legacy driver porting. The functions available are prefixed
- with 'isa_' and are <function>isa_readb</function>,
- <function>isa_writeb</function>, <function>isa_readw</function>,
- <function>isa_writew</function>, <function>isa_readl</function>,
- <function>isa_writel</function>, <function>isa_memcpy_fromio</function>
- and <function>isa_memcpy_toio</function>
- </para>
- <para>
- These functions should not be used in new drivers, and will
- eventually be going away.
- </para>
- </sect1>
-
</chapter>
<chapter>
diff --git a/Documentation/RCU/whatisRCU.txt b/Documentation/RCU/whatisRCU.txt
index 5ed85af8878..b4ea51ad361 100644
--- a/Documentation/RCU/whatisRCU.txt
+++ b/Documentation/RCU/whatisRCU.txt
@@ -360,7 +360,7 @@ uses of RCU may be found in listRCU.txt, arrayRCU.txt, and NMI-RCU.txt.
struct foo *new_fp;
struct foo *old_fp;
- new_fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+ new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
spin_lock(&foo_mutex);
old_fp = gbl_foo;
*new_fp = *old_fp;
@@ -461,7 +461,7 @@ The foo_update_a() function might then be written as follows:
struct foo *new_fp;
struct foo *old_fp;
- new_fp = kmalloc(sizeof(*fp), GFP_KERNEL);
+ new_fp = kmalloc(sizeof(*new_fp), GFP_KERNEL);
spin_lock(&foo_mutex);
old_fp = gbl_foo;
*new_fp = *old_fp;
diff --git a/Documentation/arm/Booting b/Documentation/arm/Booting
index fad566bb02f..76850295af8 100644
--- a/Documentation/arm/Booting
+++ b/Documentation/arm/Booting
@@ -118,7 +118,7 @@ to store page tables. The recommended placement is 32KiB into RAM.
In either case, the following conditions must be met:
-- Quiesce all DMA capable devicess so that memory does not get
+- Quiesce all DMA capable devices so that memory does not get
corrupted by bogus network packets or disk data. This will save
you many hours of debug.
diff --git a/Documentation/arm/README b/Documentation/arm/README
index 5ed6f3530b8..9b9c8226fdc 100644
--- a/Documentation/arm/README
+++ b/Documentation/arm/README
@@ -89,7 +89,7 @@ Modules
Although modularisation is supported (and required for the FP emulator),
each module on an ARM2/ARM250/ARM3 machine when is loaded will take
memory up to the next 32k boundary due to the size of the pages.
- Therefore, modularisation on these machines really worth it?
+ Therefore, is modularisation on these machines really worth it?
However, ARM6 and up machines allow modules to take multiples of 4k, and
as such Acorn RiscPCs and other architectures using these processors can
diff --git a/Documentation/arm/Samsung-S3C24XX/Overview.txt b/Documentation/arm/Samsung-S3C24XX/Overview.txt
index 89aa89d526a..8c6ee684174 100644
--- a/Documentation/arm/Samsung-S3C24XX/Overview.txt
+++ b/Documentation/arm/Samsung-S3C24XX/Overview.txt
@@ -10,6 +10,8 @@ Introduction
by the 's3c2410' architecture of ARM Linux. Currently the S3C2410 and
the S3C2440 are supported CPUs.
+ Support for the S3C2400 series is in progress.
+
Configuration
-------------
@@ -32,6 +34,11 @@ Machines
A general purpose development board, see EB2410ITX.txt for further
details
+ Simtec Electronics IM2440D20 (Osiris)
+
+ CPU Module from Simtec Electronics, with a S3C2440A CPU, nand flash
+ and a PCMCIA controller.
+
Samsung SMDK2410
Samsung's own development board, geared for PDA work.
@@ -85,6 +92,26 @@ Adding New Machines
mailing list information.
+I2C
+---
+
+ The hardware I2C core in the CPU is supported in single master
+ mode, and can be configured via platform data.
+
+
+RTC
+---
+
+ Support for the onboard RTC unit, including alarm function.
+
+
+Watchdog
+--------
+
+ The onchip watchdog is available via the standard watchdog
+ interface.
+
+
NAND
----
@@ -121,6 +148,15 @@ Clock Management
various clock units
+Suspend to RAM
+--------------
+
+ For boards that provide support for suspend to RAM, the
+ system can be placed into low power suspend.
+
+ See Suspend.txt for more information.
+
+
Platform Data
-------------
@@ -158,6 +194,7 @@ Platform Data
exported outside arch/arm/mach-s3c2410/, or exported to
modules via EXPORT_SYMBOL() and related functions.
+
Port Contributors
-----------------
@@ -188,8 +225,11 @@ Document Changes
08 Mar 2005 - BJD - Added LCVR to list of people, updated introduction
08 Mar 2005 - BJD - Added section on adding machines
09 Sep 2005 - BJD - Added section on platform data
+ 11 Feb 2006 - BJD - Added I2C, RTC and Watchdog sections
+ 11 Feb 2006 - BJD - Added Osiris machine, and S3C2400 information
+
Document Author
---------------
-Ben Dooks, (c) 2004-2005 Simtec Electronics
+Ben Dooks, (c) 2004-2005,2006 Simtec Electronics
diff --git a/Documentation/arm/Setup b/Documentation/arm/Setup
index 0abd0720d7e..0cb1e64bde8 100644
--- a/Documentation/arm/Setup
+++ b/Documentation/arm/Setup
@@ -58,7 +58,7 @@ below:
video_y
This describes the character position of cursor on VGA console, and
- is otherwise unused. (should not used for other console types, and
+ is otherwise unused. (should not be used for other console types, and
should not be used for other purposes).
memc_control_reg
diff --git a/Documentation/cpusets.txt b/Documentation/cpusets.txt
index 30c41459953..159e2a0c3e8 100644
--- a/Documentation/cpusets.txt
+++ b/Documentation/cpusets.txt
@@ -18,7 +18,8 @@ CONTENTS:
1.4 What are exclusive cpusets ?
1.5 What does notify_on_release do ?
1.6 What is memory_pressure ?
- 1.7 How do I use cpusets ?
+ 1.7 What is memory spread ?
+ 1.8 How do I use cpusets ?
2. Usage Examples and Syntax
2.1 Basic Usage
2.2 Adding/removing cpus
@@ -317,7 +318,78 @@ the tasks in the cpuset, in units of reclaims attempted per second,
times 1000.
-1.7 How do I use cpusets ?
+1.7 What is memory spread ?
+---------------------------
+There are two boolean flag files per cpuset that control where the
+kernel allocates pages for the file system buffers and related in
+kernel data structures. They are called 'memory_spread_page' and
+'memory_spread_slab'.
+
+If the per-cpuset boolean flag file 'memory_spread_page' is set, then
+the kernel will spread the file system buffers (page cache) evenly
+over all the nodes that the faulting task is allowed to use, instead
+of preferring to put those pages on the node where the task is running.
+
+If the per-cpuset boolean flag file 'memory_spread_slab' is set,
+then the kernel will spread some file system related slab caches,
+such as for inodes and dentries evenly over all the nodes that the
+faulting task is allowed to use, instead of preferring to put those
+pages on the node where the task is running.
+
+The setting of these flags does not affect anonymous data segment or
+stack segment pages of a task.
+
+By default, both kinds of memory spreading are off, and memory
+pages are allocated on the node local to where the task is running,
+except perhaps as modified by the tasks NUMA mempolicy or cpuset
+configuration, so long as sufficient free memory pages are available.
+
+When new cpusets are created, they inherit the memory spread settings
+of their parent.
+
+Setting memory spreading causes allocations for the affected page
+or slab caches to ignore the tasks NUMA mempolicy and be spread
+instead. Tasks using mbind() or set_mempolicy() calls to set NUMA
+mempolicies will not notice any change in these calls as a result of
+their containing tasks memory spread settings. If memory spreading
+is turned off, then the currently specified NUMA mempolicy once again
+applies to memory page allocations.
+
+Both 'memory_spread_page' and 'memory_spread_slab' are boolean flag
+files. By default they contain "0", meaning that the feature is off
+for that cpuset. If a "1" is written to that file, then that turns
+the named feature on.
+
+The implementation is simple.
+
+Setting the flag 'memory_spread_page' turns on a per-process flag
+PF_SPREAD_PAGE for each task that is in that cpuset or subsequently
+joins that cpuset. The page allocation calls for the page cache
+is modified to perform an inline check for this PF_SPREAD_PAGE task
+flag, and if set, a call to a new routine cpuset_mem_spread_node()
+returns the node to prefer for the allocation.
+
+Similarly, setting 'memory_spread_cache' turns on the flag
+PF_SPREAD_SLAB, and appropriately marked slab caches will allocate
+pages from the node returned by cpuset_mem_spread_node().
+
+The cpuset_mem_spread_node() routine is also simple. It uses the
+value of a per-task rotor cpuset_mem_spread_rotor to select the next
+node in the current tasks mems_allowed to prefer for the allocation.
+
+This memory placement policy is also known (in other contexts) as
+round-robin or interleave.
+
+This policy can provide substantial improvements for jobs that need
+to place thread local data on the corresponding node, but that need
+to access large file system data sets that need to be spread across
+the several nodes in the jobs cpuset in order to fit. Without this
+policy, especially for jobs that might have one thread reading in the
+data set, the memory allocation across the nodes in the jobs cpuset
+can become very uneven.
+
+
+1.8 How do I use cpusets ?
--------------------------
In order to minimize the impact of cpusets on critical kernel
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index afeaf6218ea..495858b236b 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -116,6 +116,17 @@ Who: Harald Welte <laforge@netfilter.org>
---------------------------
+What: remove EXPORT_SYMBOL(kernel_thread)
+When: August 2006
+Files: arch/*/kernel/*_ksyms.c
+Why: kernel_thread is a low-level implementation detail. Drivers should
+ use the <linux/kthread.h> API instead which shields them from
+ implementation details and provides a higherlevel interface that
+ prevents bugs and code duplication
+Who: Christoph Hellwig <hch@lst.de>
+
+---------------------------
+
What: EXPORT_SYMBOL(lookup_hash)
When: January 2006
Why: Too low-level interface. Use lookup_one_len or lookup_create instead.
@@ -158,13 +169,6 @@ Who: Adrian Bunk <bunk@stusta.de>
---------------------------
-What: Legacy /proc/pci interface (PCI_LEGACY_PROC)
-When: March 2006
-Why: deprecated since 2.5.53 in favor of lspci(8)
-Who: Adrian Bunk <bunk@stusta.de>
-
----------------------------
-
What: pci_module_init(driver)
When: January 2007
Why: Is replaced by pci_register_driver(pci_driver).
@@ -172,6 +176,18 @@ Who: Richard Knutsson <ricknu-0@student.ltu.se> and Greg Kroah-Hartman <gregkh@s
---------------------------
+What: Usage of invalid timevals in setitimer
+When: March 2007
+Why: POSIX requires to validate timevals in the setitimer call. This
+ was never done by Linux. The invalid (e.g. negative timevals) were
+ silently converted to more or less random timeouts and intervals.
+ Until the removal a per boot limited number of warnings is printed
+ and the timevals are sanitized.
+
+Who: Thomas Gleixner <tglx@linutronix.de>
+
+---------------------------
+
What: I2C interface of the it87 driver
When: January 2007
Why: The ISA interface is faster and should be always available. The I2C
@@ -181,6 +197,17 @@ Who: Jean Delvare <khali@linux-fr.org>
---------------------------
+What: remove EXPORT_SYMBOL(tasklist_lock)
+When: August 2006
+Files: kernel/fork.c
+Why: tasklist_lock protects the kernel internal task list. Modules have
+ no business looking at it, and all instances in drivers have been due
+ to use of too-lowlevel APIs. Having this symbol exported prevents
+ moving to more scalable locking schemes for the task list.
+Who: Christoph Hellwig <hch@lst.de>
+
+---------------------------
+
What: mount/umount uevents
When: February 2007
Why: These events are not correct, and do not properly let userspace know
diff --git a/Documentation/filesystems/v9fs.txt b/Documentation/filesystems/9p.txt
index 24c7a9c41f0..43b89c214d2 100644
--- a/Documentation/filesystems/v9fs.txt
+++ b/Documentation/filesystems/9p.txt
@@ -1,5 +1,5 @@
- V9FS: 9P2000 for Linux
- ======================
+ v9fs: Plan 9 Resource Sharing for Linux
+ =======================================
ABOUT
=====
@@ -9,18 +9,19 @@ v9fs is a Unix implementation of the Plan 9 9p remote filesystem protocol.
This software was originally developed by Ron Minnich <rminnich@lanl.gov>
and Maya Gokhale <maya@lanl.gov>. Additional development by Greg Watson
<gwatson@lanl.gov> and most recently Eric Van Hensbergen
-<ericvh@gmail.com> and Latchesar Ionkov <lucho@ionkov.net>.
+<ericvh@gmail.com>, Latchesar Ionkov <lucho@ionkov.net> and Russ Cox
+<rsc@swtch.com>.
USAGE
=====
For remote file server:
- mount -t 9P 10.10.1.2 /mnt/9
+ mount -t 9p 10.10.1.2 /mnt/9
For Plan 9 From User Space applications (http://swtch.com/plan9)
- mount -t 9P `namespace`/acme /mnt/9 -o proto=unix,name=$USER
+ mount -t 9p `namespace`/acme /mnt/9 -o proto=unix,uname=$USER
OPTIONS
=======
@@ -32,7 +33,7 @@ OPTIONS
fd - used passed file descriptors for connection
(see rfdno and wfdno)
- name=name user name to attempt mount as on the remote server. The
+ uname=name user name to attempt mount as on the remote server. The
server may override or ignore this value. Certain user
names may require authentication.
@@ -42,7 +43,7 @@ OPTIONS
debug=n specifies debug level. The debug level is a bitmask.
0x01 = display verbose error messages
0x02 = developer debug (DEBUG_CURRENT)
- 0x04 = display 9P trace
+ 0x04 = display 9p trace
0x08 = display VFS trace
0x10 = display Marshalling debug
0x20 = display RPC debug
@@ -53,11 +54,11 @@ OPTIONS
wfdno=n the file descriptor for writing with proto=fd
- maxdata=n the number of bytes to use for 9P packet payload (msize)
+ maxdata=n the number of bytes to use for 9p packet payload (msize)
port=n port to connect to on the remote server
- noextend force legacy mode (no 9P2000.u semantics)
+ noextend force legacy mode (no 9p2000.u semantics)
uid attempt to mount as a particular uid
@@ -72,7 +73,7 @@ OPTIONS
RESOURCES
=========
-The Linux version of the 9P server is now maintained under the npfs project
+The Linux version of the 9p server is now maintained under the npfs project
on sourceforge (http://sourceforge.net/projects/npfs).
There are user and developer mailing lists available through the v9fs project
diff --git a/Documentation/filesystems/ntfs.txt b/Documentation/filesystems/ntfs.txt
index 25116858789..638cbd3d2b0 100644
--- a/Documentation/filesystems/ntfs.txt
+++ b/Documentation/filesystems/ntfs.txt
@@ -457,6 +457,11 @@ ChangeLog
Note, a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
+2.1.27:
+ - Implement page migration support so the kernel can move memory used
+ by NTFS files and directories around for management purposes.
+ - Add support for writing to sparse files created with Windows XP SP2.
+ - Many minor improvements and bug fixes.
2.1.26:
- Implement support for sector sizes above 512 bytes (up to the maximum
supported by NTFS which is 4096 bytes).
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index 944cf109a6f..99902ae6804 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -121,7 +121,7 @@ Table 1-1: Process specific entries in /proc
..............................................................................
File Content
cmdline Command line arguments
- cpu Current and last cpu in wich it was executed (2.4)(smp)
+ cpu Current and last cpu in which it was executed (2.4)(smp)
cwd Link to the current working directory
environ Values of environment variables
exe Link to the executable of this process
@@ -309,13 +309,13 @@ is the same by default:
> cat /proc/irq/0/smp_affinity
ffffffff
-It's a bitmask, in wich you can specify wich CPUs can handle the IRQ, you can
+It's a bitmask, in which you can specify which CPUs can handle the IRQ, you can
set it by doing:
> echo 1 > /proc/irq/prof_cpu_mask
This means that only the first CPU will handle the IRQ, but you can also echo 5
-wich means that only the first and fourth CPU can handle the IRQ.
+which means that only the first and fourth CPU can handle the IRQ.
The way IRQs are routed is handled by the IO-APIC, and it's Round Robin
between all the CPUs which are allowed to handle it. As usual the kernel has
diff --git a/Documentation/filesystems/udf.txt b/Documentation/filesystems/udf.txt
index e5213bc301f..511b4230c05 100644
--- a/Documentation/filesystems/udf.txt
+++ b/Documentation/filesystems/udf.txt
@@ -26,6 +26,20 @@ The following mount options are supported:
nostrict Unset strict conformance
iocharset= Set the NLS character set
+The uid= and gid= options need a bit more explaining. They will accept a
+decimal numeric value which will be used as the default ID for that mount.
+They will also accept the string "ignore" and "forget". For files on the disk
+that are owned by nobody ( -1 ), they will instead look as if they are owned
+by the default ID. The ignore option causes the default ID to override all
+IDs on the disk, not just -1. The forget option causes all IDs to be written
+to disk as -1, so when the media is later remounted, they will appear to be
+owned by whatever default ID it is mounted with at that time.
+
+For typical desktop use of removable media, you should set the ID to that
+of the interactively logged on user, and also specify both the forget and
+ignore options. This way the interactive user will always see the files
+on the disk as belonging to him.
+
The remaining are for debugging and disaster recovery:
novrs Skip volume sequence recognition
diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt
index e56e842847d..adaa899e5c9 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -230,10 +230,15 @@ only called from a process context (i.e. not from an interrupt handler
or bottom half).
alloc_inode: this method is called by inode_alloc() to allocate memory
- for struct inode and initialize it.
+ for struct inode and initialize it. If this function is not
+ defined, a simple 'struct inode' is allocated. Normally
+ alloc_inode will be used to allocate a larger structure which
+ contains a 'struct inode' embedded within it.
destroy_inode: this method is called by destroy_inode() to release
- resources allocated for struct inode.
+ resources allocated for struct inode. It is only required if
+ ->alloc_inode was defined and simply undoes anything done by
+ ->alloc_inode.
read_inode: this method is called to read a specific inode from the
mounted filesystem. The i_ino member in the struct inode is
@@ -443,14 +448,81 @@ otherwise noted.
The Address Space Object
========================
-The address space object is used to identify pages in the page cache.
-
+The address space object is used to group and manage pages in the page
+cache. It can be used to keep track of the pages in a file (or
+anything else) and also track the mapping of sections of the file into
+process address spaces.
+
+There are a number of distinct yet related services that an
+address-space can provide. These include communicating memory
+pressure, page lookup by address, and keeping track of pages tagged as
+Dirty or Writeback.
+
+The first can be used independently to the others. The VM can try to
+either write dirty pages in order to clean them, or release clean
+pages in order to reuse them. To do this it can call the ->writepage
+method on dirty pages, and ->releasepage on clean pages with
+PagePrivate set. Clean pages without PagePrivate and with no external
+references will be released without notice being given to the
+address_space.
+
+To achieve this functionality, pages need to be placed on an LRU with
+lru_cache_add and mark_page_active needs to be called whenever the
+page is used.
+
+Pages are normally kept in a radix tree index by ->index. This tree
+maintains information about the PG_Dirty and PG_Writeback status of
+each page, so that pages with either of these flags can be found
+quickly.
+
+The Dirty tag is primarily used by mpage_writepages - the default
+->writepages method. It uses the tag to find dirty pages to call
+->writepage on. If mpage_writepages is not used (i.e. the address
+provides its own ->writepages) , the PAGECACHE_TAG_DIRTY tag is
+almost unused. write_inode_now and sync_inode do use it (through
+__sync_single_inode) to check if ->writepages has been successful in
+writing out the whole address_space.
+
+The Writeback tag is used by filemap*wait* and sync_page* functions,
+via wait_on_page_writeback_range, to wait for all writeback to
+complete. While waiting ->sync_page (if defined) will be called on
+each page that is found to require writeback.
+
+An address_space handler may attach extra information to a page,
+typically using the 'private' field in the 'struct page'. If such
+information is attached, the PG_Private flag should be set. This will
+cause various VM routines to make extra calls into the address_space
+handler to deal with that data.
+
+An address space acts as an intermediate between storage and
+application. Data is read into the address space a whole page at a
+time, and provided to the application either by copying of the page,
+or by memory-mapping the page.
+Data is written into the address space by the application, and then
+written-back to storage typically in whole pages, however the
+address_space has finer control of write sizes.
+
+The read process essentially only requires 'readpage'. The write
+process is more complicated and uses prepare_write/commit_write or
+set_page_dirty to write data into the address_space, and writepage,
+sync_page, and writepages to writeback data to storage.
+
+Adding and removing pages to/from an address_space is protected by the
+inode's i_mutex.
+
+When data is written to a page, the PG_Dirty flag should be set. It
+typically remains set until writepage asks for it to be written. This
+should clear PG_Dirty and set PG_Writeback. It can be actually
+written at any point after PG_Dirty is clear. Once it is known to be
+safe, PG_Writeback is cleared.
+
+Writeback makes use of a writeback_control structure...
struct address_space_operations
-------------------------------
This describes how the VFS can manipulate mapping of a file to page cache in
-your filesystem. As of kernel 2.6.13, the following members are defined:
+your filesystem. As of kernel 2.6.16, the following members are defined:
struct address_space_operations {
int (*writepage)(struct page *page, struct writeback_control *wbc);
@@ -469,47 +541,148 @@ struct address_space_operations {
loff_t offset, unsigned long nr_segs);
struct page* (*get_xip_page)(struct address_space *, sector_t,
int);
+ /* migrate the contents of a page to the specified target */
+ int (*migratepage) (struct page *, struct page *);
};
- writepage: called by the VM write a dirty page to backing store.
+ writepage: called by the VM to write a dirty page to backing store.
+ This may happen for data integrity reasons (i.e. 'sync'), or
+ to free up memory (flush). The difference can be seen in
+ wbc->sync_mode.
+ The PG_Dirty flag has been cleared and PageLocked is true.
+ writepage should start writeout, should set PG_Writeback,
+ and should make sure the page is unlocked, either synchronously
+ or asynchronously when the write operation completes.
+
+ If wbc->sync_mode is WB_SYNC_NONE, ->writepage doesn't have to
+ try too hard if there are problems, and may choose to write out
+ other pages from the mapping if that is easier (e.g. due to
+ internal dependencies). If it chooses not to start writeout, it
+ should return AOP_WRITEPAGE_ACTIVATE so that the VM will not keep
+ calling ->writepage on that page.
+
+ See the file "Locking" for more details.
readpage: called by the VM to read a page from backing store.
+ The page will be Locked when readpage is called, and should be
+ unlocked and marked uptodate once the read completes.
+ If ->readpage discovers that it needs to unlock the page for
+ some reason, it can do so, and then return AOP_TRUNCATED_PAGE.
+ In this case, the page will be relocated, relocked and if
+ that all succeeds, ->readpage will be called again.
sync_page: called by the VM to notify the backing store to perform all
queued I/O operations for a page. I/O operations for other pages
associated with this address_space object may also be performed.
+ This function is optional and is called only for pages with
+ PG_Writeback set while waiting for the writeback to complete.
+
writepages: called by the VM to write out pages associated with the
- address_space object.
+ address_space object. If wbc->sync_mode is WBC_SYNC_ALL, then
+ the writeback_control will specify a range of pages that must be
+ written out. If it is WBC_SYNC_NONE, then a nr_to_write is given
+ and that many pages should be written if possible.
+ If no ->writepages is given, then mpage_writepages is used
+ instead. This will choose pages from the address space that are
+ tagged as DIRTY and will pass them to ->writepage.
set_page_dirty: called by the VM to set a page dirty.
+ This is particularly needed if an address space attaches
+ private data to a page, and that data needs to be updated when
+ a page is dirtied. This is called, for example, when a memory
+ mapped page gets modified.
+ If defined, it should set the PageDirty flag, and the
+ PAGECACHE_TAG_DIRTY tag in the radix tree.
readpages: called by the VM to read pages associated with the address_space
- object.
+ object. This is essentially just a vector version of
+ readpage. Instead of just one page, several pages are
+ requested.
+ readpages is only used for read-ahead, so read errors are
+ ignored. If anything goes wrong, feel free to give up.
prepare_write: called by the generic write path in VM to set up a write
- request for a page.
-
- commit_write: called by the generic write path in VM to write page to
- its backing store.
+ request for a page. This indicates to the address space that
+ the given range of bytes is about to be written. The
+ address_space should check that the write will be able to
+ complete, by allocating space if necessary and doing any other
+ internal housekeeping. If the write will update parts of
+ any basic-blocks on storage, then those blocks should be
+ pre-read (if they haven't been read already) so that the
+ updated blocks can be written out properly.
+ The page will be locked. If prepare_write wants to unlock the
+ page it, like readpage, may do so and return
+ AOP_TRUNCATED_PAGE.
+ In this case the prepare_write will be retried one the lock is
+ regained.
+
+ commit_write: If prepare_write succeeds, new data will be copied
+ into the page and then commit_write will be called. It will
+ typically update the size of the file (if appropriate) and
+ mark the inode as dirty, and do any other related housekeeping
+ operations. It should avoid returning an error if possible -
+ errors should have been handled by prepare_write.
bmap: called by the VFS to map a logical block offset within object to
- physical block number. This method is use by for the legacy FIBMAP
- ioctl. Other uses are discouraged.
-
- invalidatepage: called by the VM on truncate to disassociate a page from its
- address_space mapping.
-
- releasepage: called by the VFS to release filesystem specific metadata from
- a page.
-
- direct_IO: called by the VM for direct I/O writes and reads.
+ physical block number. This method is used by the FIBMAP
+ ioctl and for working with swap-files. To be able to swap to
+ a file, the file must have a stable mapping to a block
+ device. The swap system does not go through the filesystem
+ but instead uses bmap to find out where the blocks in the file
+ are and uses those addresses directly.
+
+
+ invalidatepage: If a page has PagePrivate set, then invalidatepage
+ will be called when part or all of the page is to be removed
+ from the address space. This generally corresponds to either a
+ truncation or a complete invalidation of the address space
+ (in the latter case 'offset' will always be 0).
+ Any private data associated with the page should be updated
+ to reflect this truncation. If offset is 0, then
+ the private data should be released, because the page
+ must be able to be completely discarded. This may be done by
+ calling the ->releasepage function, but in this case the
+ release MUST succeed.
+
+ releasepage: releasepage is called on PagePrivate pages to indicate
+ that the page should be freed if possible. ->releasepage
+ should remove any private data from the page and clear the
+ PagePrivate flag. It may also remove the page from the
+ address_space. If this fails for some reason, it may indicate
+ failure with a 0 return value.
+ This is used in two distinct though related cases. The first
+ is when the VM finds a clean page with no active users and
+ wants to make it a free page. If ->releasepage succeeds, the
+ page will be removed from the address_space and become free.
+
+ The second case if when a request has been made to invalidate
+ some or all pages in an address_space. This can happen
+ through the fadvice(POSIX_FADV_DONTNEED) system call or by the
+ filesystem explicitly requesting it as nfs and 9fs do (when
+ they believe the cache may be out of date with storage) by
+ calling invalidate_inode_pages2().
+ If the filesystem makes such a call, and needs to be certain
+ that all pages are invalidated, then its releasepage will
+ need to ensure this. Possibly it can clear the PageUptodate
+ bit if it cannot free private data yet.
+
+ direct_IO: called by the generic read/write routines to perform
+ direct_IO - that is IO requests which bypass the page cache
+ and transfer data directly between the storage and the
+ application's address space.
get_xip_page: called by the VM to translate a block number to a page.
The page is valid until the corresponding filesystem is unmounted.
Filesystems that want to use execute-in-place (XIP) need to implement
it. An example implementation can be found in fs/ext2/xip.c.
+ migrate_page: This is used to compact the physical memory usage.
+ If the VM wants to relocate a page (maybe off a memory card
+ that is signalling imminent failure) it will pass a new page
+ and an old page to this function. migrate_page should
+ transfer any private data across and update any references
+ that it has to the page.
The File Object
===============
diff --git a/Documentation/firmware_class/firmware_sample_driver.c b/Documentation/firmware_class/firmware_sample_driver.c
index d3ad2c24490..ad3edaba453 100644
--- a/Documentation/firmware_class/firmware_sample_driver.c
+++ b/Documentation/firmware_class/firmware_sample_driver.c
@@ -23,7 +23,6 @@ char __init inkernel_firmware[] = "let's say that this is firmware\n";
#endif
static struct device ghost_device = {
- .name = "Ghost Device",
.bus_id = "ghost0",
};
@@ -92,7 +91,7 @@ static void sample_probe_async(void)
{
/* Let's say that I can't sleep */
int error;
- error = request_firmware_nowait (THIS_MODULE,
+ error = request_firmware_nowait (THIS_MODULE, FW_ACTION_NOHOTPLUG,
"sample_driver_fw", &ghost_device,
"my device pointer",
sample_probe_async_cont);
diff --git a/Documentation/firmware_class/firmware_sample_firmware_class.c b/Documentation/firmware_class/firmware_sample_firmware_class.c
index 57b956aecbc..9e1b0e4051c 100644
--- a/Documentation/firmware_class/firmware_sample_firmware_class.c
+++ b/Documentation/firmware_class/firmware_sample_firmware_class.c
@@ -172,7 +172,6 @@ static void fw_remove_class_device(struct class_device *class_dev)
static struct class_device *class_dev;
static struct device my_device = {
- .name = "Sample Device",
.bus_id = "my_dev0",
};
diff --git a/Documentation/hwmon/w83627hf b/Documentation/hwmon/w83627hf
index bbeaba68044..79223192124 100644
--- a/Documentation/hwmon/w83627hf
+++ b/Documentation/hwmon/w83627hf
@@ -18,6 +18,10 @@ Supported chips:
Prefix: 'w83637hf'
Addresses scanned: ISA address retrieved from Super I/O registers
Datasheet: http://www.winbond.com/PDF/sheet/w83637hf.pdf
+ * Winbond W83687THF
+ Prefix: 'w83687thf'
+ Addresses scanned: ISA address retrieved from Super I/O registers
+ Datasheet: Provided by Winbond on request
Authors:
Frodo Looijaard <frodol@dds.nl>,
diff --git a/Documentation/hwmon/w83781d b/Documentation/hwmon/w83781d
index e5459333ba6..b1e9f80098e 100644
--- a/Documentation/hwmon/w83781d
+++ b/Documentation/hwmon/w83781d
@@ -36,6 +36,11 @@ Module parameters
Use 'init=0' to bypass initializing the chip.
Try this if your computer crashes when you load the module.
+* reset int
+ (default 0)
+ The driver used to reset the chip on load, but does no more. Use
+ 'reset=1' to restore the old behavior. Report if you need to do this.
+
force_subclients=bus,caddr,saddr,saddr
This is used to force the i2c addresses for subclients of
a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'
@@ -123,6 +128,25 @@ When an alarm goes off, you can be warned by a beeping signal through
your computer speaker. It is possible to enable all beeping globally,
or only the beeping for some alarms.
+Individual alarm and beep bits:
+
+0x000001: in0
+0x000002: in1
+0x000004: in2
+0x000008: in3
+0x000010: temp1
+0x000020: temp2 (+temp3 on W83781D)
+0x000040: fan1
+0x000080: fan2
+0x000100: in4
+0x000200: in5
+0x000400: in6
+0x000800: fan3
+0x001000: chassis
+0x002000: temp3 (W83782D and W83627HF only)
+0x010000: in7 (W83782D and W83627HF only)
+0x020000: in8 (W83782D and W83627HF only)
+
If an alarm triggers, it will remain triggered until the hardware register
is read at least once. This means that the cause for the alarm may
already have disappeared! Note that in the current implementation, all
diff --git a/Documentation/i2c/busses/i2c-piix4 b/Documentation/i2c/busses/i2c-piix4
index 856b4b8b962..a1c8f581afe 100644
--- a/Documentation/i2c/busses/i2c-piix4
+++ b/Documentation/i2c/busses/i2c-piix4
@@ -4,7 +4,7 @@ Supported adapters:
* Intel 82371AB PIIX4 and PIIX4E
* Intel 82443MX (440MX)
Datasheet: Publicly available at the Intel website
- * ServerWorks OSB4, CSB5 and CSB6 southbridges
+ * ServerWorks OSB4, CSB5, CSB6 and HT-1000 southbridges
Datasheet: Only available via NDA from ServerWorks
* Standard Microsystems (SMSC) SLC90E66 (Victory66) southbridge
Datasheet: Publicly available at the SMSC website http://www.smsc.com
diff --git a/Documentation/i2c/busses/scx200_acb b/Documentation/i2c/busses/scx200_acb
index 08c8cd1df60..f50e69981ec 100644
--- a/Documentation/i2c/busses/scx200_acb
+++ b/Documentation/i2c/busses/scx200_acb
@@ -6,9 +6,10 @@ Module Parameters
-----------------
* base: int
- Base addresses for the ACCESS.bus controllers
+ Base addresses for the ACCESS.bus controllers on SCx200 and SC1100 devices
Description
-----------
-Enable the use of the ACCESS.bus controllers of a SCx200 processor.
+Enable the use of the ACCESS.bus controller on the Geode SCx200 and
+SC1100 processors and the CS5535 and CS5536 Geode companion devices.
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 443230b43e0..a9c00facdf4 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -17,6 +17,7 @@ This document describes the Linux kernel Makefiles.
--- 3.8 Command line dependency
--- 3.9 Dependency tracking
--- 3.10 Special Rules
+ --- 3.11 $(CC) support functions
=== 4 Host Program support
--- 4.1 Simple Host Program
@@ -38,7 +39,6 @@ This document describes the Linux kernel Makefiles.
--- 6.6 Commands useful for building a boot image
--- 6.7 Custom kbuild commands
--- 6.8 Preprocessing linker scripts
- --- 6.9 $(CC) support functions
=== 7 Kbuild Variables
=== 8 Makefile language
@@ -106,9 +106,9 @@ This document is aimed towards normal developers and arch developers.
Most Makefiles within the kernel are kbuild Makefiles that use the
kbuild infrastructure. This chapter introduce the syntax used in the
kbuild makefiles.
-The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will
-continue to be supported. All new developmen is expected to use the
-Kbuild filename.
+The preferred name for the kbuild files are 'Makefile' but 'Kbuild' can
+be used and if both a 'Makefile' and a 'Kbuild' file exists then the 'Kbuild'
+file will be used.
Section 3.1 "Goal definitions" is a quick intro, further chapters provide
more details, with real examples.
@@ -385,6 +385,102 @@ more details, with real examples.
to prerequisites are referenced with $(src) (because they are not
generated files).
+--- 3.11 $(CC) support functions
+
+ The kernel may be build with several different versions of
+ $(CC), each supporting a unique set of features and options.
+ kbuild provide basic support to check for valid options for $(CC).
+ $(CC) is useally the gcc compiler, but other alternatives are
+ available.
+
+ as-option
+ as-option is used to check if $(CC) when used to compile
+ assembler (*.S) files supports the given option. An optional
+ second option may be specified if first option are not supported.
+
+ Example:
+ #arch/sh/Makefile
+ cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
+
+ In the above example cflags-y will be assinged the the option
+ -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
+ The second argument is optional, and if supplied will be used
+ if first argument is not supported.
+
+ cc-option
+ cc-option is used to check if $(CC) support a given option, and not
+ supported to use an optional second option.
+
+ Example:
+ #arch/i386/Makefile
+ cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
+
+ In the above example cflags-y will be assigned the option
+ -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
+ The second argument to cc-option is optional, and if omitted
+ cflags-y will be assigned no value if first option is not supported.
+
+ cc-option-yn
+ cc-option-yn is used to check if gcc supports a given option
+ and return 'y' if supported, otherwise 'n'.
+
+ Example:
+ #arch/ppc/Makefile
+ biarch := $(call cc-option-yn, -m32)
+ aflags-$(biarch) += -a32
+ cflags-$(biarch) += -m32
+
+ In the above example $(biarch) is set to y if $(CC) supports the -m32
+ option. When $(biarch) equals to y the expanded variables $(aflags-y)
+ and $(cflags-y) will be assigned the values -a32 and -m32.
+
+ cc-option-align
+ gcc version >= 3.0 shifted type of options used to speify
+ alignment of functions, loops etc. $(cc-option-align) whrn used
+ as prefix to the align options will select the right prefix:
+ gcc < 3.00
+ cc-option-align = -malign
+ gcc >= 3.00
+ cc-option-align = -falign
+
+ Example:
+ CFLAGS += $(cc-option-align)-functions=4
+
+ In the above example the option -falign-functions=4 is used for
+ gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
+
+ cc-version
+ cc-version return a numerical version of the $(CC) compiler version.
+ The format is <major><minor> where both are two digits. So for example
+ gcc 3.41 would return 0341.
+ cc-version is useful when a specific $(CC) version is faulty in one
+ area, for example the -mregparm=3 were broken in some gcc version
+ even though the option was accepted by gcc.
+
+ Example:
+ #arch/i386/Makefile
+ cflags-y += $(shell \
+ if [ $(call cc-version) -ge 0300 ] ; then \
+ echo "-mregparm=3"; fi ;)
+
+ In the above example -mregparm=3 is only used for gcc version greater
+ than or equal to gcc 3.0.
+
+ cc-ifversion
+ cc-ifversion test the version of $(CC) and equals last argument if
+ version expression is true.
+
+ Example:
+ #fs/reiserfs/Makefile
+ EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
+
+ In this example EXTRA_CFLAGS will be assigned the value -O1 if the
+ $(CC) version is less than 4.2.
+ cc-ifversion takes all the shell operators:
+ -eq, -ne, -lt, -le, -gt, and -ge
+ The third parameter may be a text as in this example, but it may also
+ be an expanded variable or a macro.
+
=== 4 Host Program support
@@ -973,74 +1069,6 @@ When kbuild executes the following steps are followed (roughly):
architecture specific files.
---- 6.9 $(CC) support functions
-
- The kernel may be build with several different versions of
- $(CC), each supporting a unique set of features and options.
- kbuild provide basic support to check for valid options for $(CC).
- $(CC) is useally the gcc compiler, but other alternatives are
- available.
-
- cc-option
- cc-option is used to check if $(CC) support a given option, and not
- supported to use an optional second option.
-
- Example:
- #arch/i386/Makefile
- cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
-
- In the above example cflags-y will be assigned the option
- -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
- The second argument to cc-option is optional, and if omitted
- cflags-y will be assigned no value if first option is not supported.
-
- cc-option-yn
- cc-option-yn is used to check if gcc supports a given option
- and return 'y' if supported, otherwise 'n'.
-
- Example:
- #arch/ppc/Makefile
- biarch := $(call cc-option-yn, -m32)
- aflags-$(biarch) += -a32
- cflags-$(biarch) += -m32
-
- In the above example $(biarch) is set to y if $(CC) supports the -m32
- option. When $(biarch) equals to y the expanded variables $(aflags-y)
- and $(cflags-y) will be assigned the values -a32 and -m32.
-
- cc-option-align
- gcc version >= 3.0 shifted type of options used to speify
- alignment of functions, loops etc. $(cc-option-align) whrn used
- as prefix to the align options will select the right prefix:
- gcc < 3.00
- cc-option-align = -malign
- gcc >= 3.00
- cc-option-align = -falign
-
- Example:
- CFLAGS += $(cc-option-align)-functions=4
-
- In the above example the option -falign-functions=4 is used for
- gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
-
- cc-version
- cc-version return a numerical version of the $(CC) compiler version.
- The format is <major><minor> where both are two digits. So for example
- gcc 3.41 would return 0341.
- cc-version is useful when a specific $(CC) version is faulty in one
- area, for example the -mregparm=3 were broken in some gcc version
- even though the option was accepted by gcc.
-
- Example:
- #arch/i386/Makefile
- cflags-y += $(shell \
- if [ $(call cc-version) -ge 0300 ] ; then \
- echo "-mregparm=3"; fi ;)
-
- In the above example -mregparm=3 is only used for gcc version greater
- than or equal to gcc 3.0.
-
-
=== 7 Kbuild Variables
The top Makefile exports the following variables:
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 7e77f93634e..fcccf2432f9 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -13,6 +13,7 @@ In this document you will find information about:
--- 2.2 Available targets
--- 2.3 Available options
--- 2.4 Preparing the kernel tree for module build
+ --- 2.5 Building separate files for a module
=== 3. Example commands
=== 4. Creating a kbuild file for an external module
=== 5. Include files
@@ -22,7 +23,10 @@ In this document you will find information about:
=== 6. Module installation
--- 6.1 INSTALL_MOD_PATH
--- 6.2 INSTALL_MOD_DIR
- === 7. Module versioning
+ === 7. Module versioning & Module.symvers
+ --- 7.1 Symbols fron the kernel (vmlinux + modules)
+ --- 7.2 Symbols and external modules
+ --- 7.3 Symbols from another external module
=== 8. Tips & Tricks
--- 8.1 Testing for CONFIG_FOO_BAR
@@ -88,7 +92,8 @@ when building an external module.
make -C $KDIR M=$PWD modules_install
Install the external module(s).
Installation default is in /lib/modules/<kernel-version>/extra,
- but may be prefixed with INSTALL_MOD_PATH - see separate chapter.
+ but may be prefixed with INSTALL_MOD_PATH - see separate
+ chapter.
make -C $KDIR M=$PWD clean
Remove all generated files for the module - the kernel
@@ -131,6 +136,16 @@ when building an external module.
Therefore a full kernel build needs to be executed to make
module versioning work.
+--- 2.5 Building separate files for a module
+ It is possible to build single files which is part of a module.
+ This works equal for the kernel, a module and even for external
+ modules.
+ Examples (module foo.ko, consist of bar.o, baz.o):
+ make -C $KDIR M=`pwd` bar.lst
+ make -C $KDIR M=`pwd` bar.o
+ make -C $KDIR M=`pwd` foo.ko
+ make -C $KDIR M=`pwd` /
+
=== 3. Example commands
@@ -422,7 +437,7 @@ External modules are installed in the directory:
=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
-=== 7. Module versioning
+=== 7. Module versioning & Module.symvers
Module versioning is enabled by the CONFIG_MODVERSIONS tag.
@@ -432,11 +447,80 @@ when a module is loaded/used then the CRC values contained in the kernel are
compared with similar values in the module. If they are not equal then the
kernel refuses to load the module.
-During a kernel build a file named Module.symvers will be generated. This
-file includes the symbol version of all symbols within the kernel. If the
-Module.symvers file is saved from the last full kernel compile one does not
-have to do a full kernel compile to build a module version's compatible module.
+Module.symvers contains a list of all exported symbols from a kernel build.
+
+--- 7.1 Symbols fron the kernel (vmlinux + modules)
+
+ During a kernel build a file named Module.symvers will be generated.
+ Module.symvers contains all exported symbols from the kernel and
+ compiled modules. For each symbols the corresponding CRC value
+ is stored too.
+
+ The syntax of the Module.symvers file is:
+ <CRC> <Symbol> <module>
+ Sample:
+ 0x2d036834 scsi_remove_host drivers/scsi/scsi_mod
+ For a kernel build without CONFIG_MODVERSIONING enabled the crc
+ would read: 0x00000000
+
+ Module.symvers serve two purposes.
+ 1) It list all exported symbols both from vmlinux and all modules
+ 2) It list CRC if CONFIG_MODVERSION is enabled
+
+--- 7.2 Symbols and external modules
+
+ When building an external module the build system needs access to
+ the symbols from the kernel to check if all external symbols are
+ defined. This is done in the MODPOST step and to obtain all
+ symbols modpost reads Module.symvers from the kernel.
+ If a Module.symvers file is present in the directory where
+ the external module is being build this file will be read too.
+ During the MODPOST step a new Module.symvers file will be written
+ containing all exported symbols that was not defined in the kernel.
+
+--- 7.3 Symbols from another external module
+
+ Sometimes one external module uses exported symbols from another
+ external module. Kbuild needs to have full knowledge on all symbols
+ to avoid spitting out warnings about undefined symbols.
+ Two solutions exist to let kbuild know all symbols of more than
+ one external module.
+ The method with a top-level kbuild file is recommended but may be
+ impractical in certain situations.
+
+ Use a top-level Kbuild file
+ If you have two modules: 'foo', 'bar' and 'foo' needs symbols
+ from 'bar' then one can use a common top-level kbuild file so
+ both modules are compiled in same build.
+
+ Consider following directory layout:
+ ./foo/ <= contains the foo module
+ ./bar/ <= contains the bar module
+ The top-level Kbuild file would then look like:
+
+ #./Kbuild: (this file may also be named Makefile)
+ obj-y := foo/ bar/
+
+ Executing:
+ make -C $KDIR M=`pwd`
+
+ will then do the expected and compile both modules with full
+ knowledge on symbols from both modules.
+
+ Use an extra Module.symvers file
+ When an external module is build a Module.symvers file is
+ generated containing all exported symbols which are not
+ defined in the kernel.
+ To get access to symbols from module 'bar' one can copy the
+ Module.symvers file from the compilation of the 'bar' module
+ to the directory where the 'foo' module is build.
+ During the module build kbuild will read the Module.symvers
+ file in the directory of the external module and when the
+ build is finished a new Module.symvers file is created
+ containing the sum of all symbols defined and not part of the
+ kernel.
+
=== 8. Tips & Tricks
--- 8.1 Testing for CONFIG_FOO_BAR
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index fc99075e0af..f8cb55c30b0 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -49,6 +49,7 @@ restrictions referred to are that the relevant option is valid if:
MCA MCA bus support is enabled.
MDA MDA console support is enabled.
MOUSE Appropriate mouse support is enabled.
+ MSI Message Signaled Interrupts (PCI).
MTD MTD support is enabled.
NET Appropriate network support is enabled.
NUMA NUMA support is enabled.
@@ -366,12 +367,17 @@ running once the system is up.
tty<n> Use the virtual console device <n>.
ttyS<n>[,options]
+ ttyUSB0[,options]
Use the specified serial port. The options are of
- the form "bbbbpn", where "bbbb" is the baud rate,
- "p" is parity ("n", "o", or "e"), and "n" is bits.
- Default is "9600n8".
+ the form "bbbbpnf", where "bbbb" is the baud rate,
+ "p" is parity ("n", "o", or "e"), "n" is number of
+ bits, and "f" is flow control ("r" for RTS or
+ omit it). Default is "9600n8".
- See also Documentation/serial-console.txt.
+ See Documentation/serial-console.txt for more
+ information. See
+ Documentation/networking/netconsole.txt for an
+ alternative.
uart,io,<addr>[,options]
uart,mmio,<addr>[,options]
@@ -1008,7 +1014,9 @@ running once the system is up.
noexec=on: enable non-executable mappings (default)
noexec=off: disable nn-executable mappings
- nofxsr [BUGS=IA-32]
+ nofxsr [BUGS=IA-32] Disables x86 floating point extended
+ register save and restore. The kernel will only save
+ legacy floating-point registers on task switch.
nohlt [BUGS=ARM]
@@ -1053,6 +1061,8 @@ running once the system is up.
nosbagart [IA-64]
+ nosep [BUGS=IA-32] Disables x86 SYSENTER/SYSEXIT support.
+
nosmp [SMP] Tells an SMP kernel to act as a UP kernel.
nosync [HW,M68K] Disables sync negotiation for all devices.
@@ -1122,6 +1132,11 @@ running once the system is up.
pas16= [HW,SCSI]
See header of drivers/scsi/pas16.c.
+ pause_on_oops=
+ Halt all CPUs after the first oops has been printed for
+ the specified number of seconds. This is to be used if
+ your oopses keep scrolling off the screen.
+
pcbit= [HW,ISDN]
pcd. [PARIDE]
@@ -1143,6 +1158,9 @@ running once the system is up.
Mechanism 2.
nommconf [IA-32,X86_64] Disable use of MMCONFIG for PCI
Configuration
+ nomsi [MSI] If the PCI_MSI kernel config parameter is
+ enabled, this kernel boot option can be used to
+ disable the use of MSI interrupts system-wide.
nosort [IA-32] Don't sort PCI devices according to
order given by the PCI BIOS. This sorting is
done to get a device order compatible with
diff --git a/Documentation/networking/packet_mmap.txt b/Documentation/networking/packet_mmap.txt
index 8d4cf78258e..4fc8e987432 100644
--- a/Documentation/networking/packet_mmap.txt
+++ b/Documentation/networking/packet_mmap.txt
@@ -40,7 +40,7 @@ network interface card supports some sort of interrupt load mitigation or
+ How to use CONFIG_PACKET_MMAP
--------------------------------------------------------------------------------
-From the user standpoint, you should use the higher level libpcap library, wich
+From the user standpoint, you should use the higher level libpcap library, which
is a de facto standard, portable across nearly all operating systems
including Win32.
@@ -217,8 +217,8 @@ called pg_vec, its size limits the number of blocks that can be allocated.
kmalloc allocates any number of bytes of phisically contiguous memory from
a pool of pre-determined sizes. This pool of memory is mantained by the slab
-allocator wich is at the end the responsible for doing the allocation and
-hence wich imposes the maximum memory that kmalloc can allocate.
+allocator which is at the end the responsible for doing the allocation and
+hence which imposes the maximum memory that kmalloc can allocate.
In a 2.4/2.6 kernel and the i386 architecture, the limit is 131072 bytes. The
predetermined sizes that kmalloc uses can be checked in the "size-<bytes>"
@@ -254,7 +254,7 @@ and, the number of frames be
<block number> * <block size> / <frame size>
-Suposse the following parameters, wich apply for 2.6 kernel and an
+Suposse the following parameters, which apply for 2.6 kernel and an
i386 architecture:
<size-max> = 131072 bytes
@@ -360,7 +360,7 @@ TP_STATUS_LOSING : indicates there were packet drops from last time
statistics where checked with getsockopt() and
the PACKET_STATISTICS option.
-TP_STATUS_CSUMNOTREADY: currently it's used for outgoing IP packets wich
+TP_STATUS_CSUMNOTREADY: currently it's used for outgoing IP packets which
it's checksum will be done in hardware. So while
reading the packet we should not try to check the
checksum.
diff --git a/Documentation/networking/pktgen.txt b/Documentation/networking/pktgen.txt
index cc4b4d04129..278771c9ad9 100644
--- a/Documentation/networking/pktgen.txt
+++ b/Documentation/networking/pktgen.txt
@@ -109,6 +109,22 @@ Examples:
cycle through the port range.
pgset "udp_dst_max 9" set UDP destination port max.
+ pgset "mpls 0001000a,0002000a,0000000a" set MPLS labels (in this example
+ outer label=16,middle label=32,
+ inner label=0 (IPv4 NULL)) Note that
+ there must be no spaces between the
+ arguments. Leading zeros are required.
+ Do not set the bottom of stack bit,
+ thats done automatically. If you do
+ set the bottom of stack bit, that
+ indicates that you want to randomly
+ generate that address and the flag
+ MPLS_RND will be turned on. You
+ can have any mix of random and fixed
+ labels in the label stack.
+
+ pgset "mpls 0" turn off mpls (or any invalid argument works too!)
+
pgset stop aborts injection. Also, ^C aborts generator.
@@ -167,6 +183,8 @@ pkt_size
min_pkt_size
max_pkt_size
+mpls
+
udp_src_min
udp_src_max
@@ -211,4 +229,4 @@ Grant Grundler for testing on IA-64 and parisc, Harald Welte, Lennert Buytenhek
Stephen Hemminger, Andi Kleen, Dave Miller and many others.
-Good luck with the linux net-development. \ No newline at end of file
+Good luck with the linux net-development.
diff --git a/Documentation/networking/ray_cs.txt b/Documentation/networking/ray_cs.txt
index 5427f8c7df9..145d27a5239 100644
--- a/Documentation/networking/ray_cs.txt
+++ b/Documentation/networking/ray_cs.txt
@@ -25,7 +25,7 @@ the essid= string parameter is available via the kernel command line.
This will change after the method of sorting out parameters for all
the PCMCIA drivers is agreed upon. If you must have a built in driver
with nondefault parameters, they can be edited in
-/usr/src/linux/drivers/net/pcmcia/ray_cs.c. Searching for MODULE_PARM
+/usr/src/linux/drivers/net/pcmcia/ray_cs.c. Searching for module_param
will find them all.
Information on card services is available at:
diff --git a/Documentation/nfsroot.txt b/Documentation/nfsroot.txt
index a87d4af216c..d56dc71d943 100644
--- a/Documentation/nfsroot.txt
+++ b/Documentation/nfsroot.txt
@@ -3,6 +3,7 @@ Mounting the root filesystem via NFS (nfsroot)
Written 1996 by Gero Kuhlmann <gero@gkminix.han.de>
Updated 1997 by Martin Mares <mj@atrey.karlin.mff.cuni.cz>
+Updated 2006 by Nico Schottelius <nico-kernel-nfsroot@schottelius.org>
@@ -168,7 +169,6 @@ depend on what facilities are available:
root. If it got a BOOTP answer the directory name in that answer
is used.
-
3.2) Using LILO
When using LILO you can specify all necessary command line
parameters with the 'append=' command in the LILO configuration
@@ -177,7 +177,11 @@ depend on what facilities are available:
LILO and its 'append=' command please refer to the LILO
documentation.
-3.3) Using loadlin
+3.3) Using GRUB
+ When you use GRUB, you simply append the parameters after the kernel
+ specification: "kernel <kernel> <parameters>" (without the quotes).
+
+3.4) Using loadlin
When you want to boot Linux from a DOS command prompt without
having a local hard disk to mount as root, you can use loadlin.
I was told that it works, but haven't used it myself yet. In
@@ -185,7 +189,7 @@ depend on what facilities are available:
lar to how LILO is doing it. Please refer to the loadlin docu-
mentation for further information.
-3.4) Using a boot ROM
+3.5) Using a boot ROM
This is probably the most elegant way of booting a diskless
client. With a boot ROM the kernel gets loaded using the TFTP
protocol. As far as I know, no commercial boot ROMs yet
@@ -194,6 +198,13 @@ depend on what facilities are available:
and its mirrors. They are called 'netboot-nfs' and 'etherboot'.
Both contain everything you need to boot a diskless Linux client.
+3.6) Using pxelinux
+ Using pxelinux you specify the kernel you built with
+ "kernel <relative-path-below /tftpboot>". The nfsroot parameters
+ are passed to the kernel by adding them to the "append" line.
+ You may perhaps also want to fine tune the console output,
+ see Documentation/serial-console.txt for serial console help.
+
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index b28b7f04abb..d7814a113ee 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -17,6 +17,11 @@ Some warnings, first.
* but it will probably only crash.
*
* (*) suspend/resume support is needed to make it safe.
+ *
+ * If you have any filesystems on USB devices mounted before suspend,
+ * they won't be accessible after resume and you may lose data, as though
+ * you have unplugged the USB devices with mounted filesystems on them
+ * (see the FAQ below for details).
You need to append resume=/dev/your_swap_partition to kernel command
line. Then you suspend by
@@ -27,19 +32,18 @@ echo shutdown > /sys/power/disk; echo disk > /sys/power/state
echo platform > /sys/power/disk; echo disk > /sys/power/state
+. If you have SATA disks, you'll need recent kernels with SATA suspend
+support. For suspend and resume to work, make sure your disk drivers
+are built into kernel -- not modules. [There's way to make
+suspend/resume with modular disk drivers, see FAQ, but you probably
+should not do that.]
+
If you want to limit the suspend image size to N bytes, do
echo N > /sys/power/image_size
before suspend (it is limited to 500 MB by default).
-Encrypted suspend image:
-------------------------
-If you want to store your suspend image encrypted with a temporary
-key to prevent data gathering after resume you must compile
-crypto and the aes algorithm into the kernel - modules won't work
-as they cannot be loaded at resume time.
-
Article about goals and implementation of Software Suspend for Linux
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -333,4 +337,37 @@ init=/bin/bash, then swapon and starting suspend sequence manually
usually does the trick. Then it is good idea to try with latest
vanilla kernel.
+Q: How can distributions ship a swsusp-supporting kernel with modular
+disk drivers (especially SATA)?
+
+A: Well, it can be done, load the drivers, then do echo into
+/sys/power/disk/resume file from initrd. Be sure not to mount
+anything, not even read-only mount, or you are going to lose your
+data.
+
+Q: How do I make suspend more verbose?
+
+A: If you want to see any non-error kernel messages on the virtual
+terminal the kernel switches to during suspend, you have to set the
+kernel console loglevel to at least 5, for example by doing
+
+ echo 5 > /proc/sys/kernel/printk
+
+Q: Is this true that if I have a mounted filesystem on a USB device and
+I suspend to disk, I can lose data unless the filesystem has been mounted
+with "sync"?
+
+A: That's right. It depends on your hardware, and it could be true even for
+suspend-to-RAM. In fact, even with "-o sync" you can lose data if your
+programs have information in buffers they haven't written out to disk.
+
+If you're lucky, your hardware will support low-power modes for USB
+controllers while the system is asleep. Lots of hardware doesn't,
+however. Shutting off the power to a USB controller is equivalent to
+unplugging all the attached devices.
+
+Remember that it's always a bad idea to unplug a disk drive containing a
+mounted filesystem. With USB that's true even when your system is asleep!
+The safest thing is to unmount all USB-based filesystems before suspending
+and remount them after resuming.
diff --git a/Documentation/power/userland-swsusp.txt b/Documentation/power/userland-swsusp.txt
new file mode 100644
index 00000000000..94058220aaf
--- /dev/null
+++ b/Documentation/power/userland-swsusp.txt
@@ -0,0 +1,149 @@
+Documentation for userland software suspend interface
+ (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
+
+First, the warnings at the beginning of swsusp.txt still apply.
+
+Second, you should read the FAQ in swsusp.txt _now_ if you have not
+done it already.
+
+Now, to use the userland interface for software suspend you need special
+utilities that will read/write the system memory snapshot from/to the
+kernel. Such utilities are available, for example, from
+<http://www.sisk.pl/kernel/utilities/suspend>. You may want to have
+a look at them if you are going to develop your own suspend/resume
+utilities.
+
+The interface consists of a character device providing the open(),
+release(), read(), and write() operations as well as several ioctl()
+commands defined in kernel/power/power.h. The major and minor
+numbers of the device are, respectively, 10 and 231, and they can
+be read from /sys/class/misc/snapshot/dev.
+
+The device can be open either for reading or for writing. If open for
+reading, it is considered to be in the suspend mode. Otherwise it is
+assumed to be in the resume mode. The device cannot be open for reading
+and writing. It is also impossible to have the device open more than once
+at a time.
+
+The ioctl() commands recognized by the device are:
+
+SNAPSHOT_FREEZE - freeze user space processes (the current process is
+ not frozen); this is required for SNAPSHOT_ATOMIC_SNAPSHOT
+ and SNAPSHOT_ATOMIC_RESTORE to succeed
+
+SNAPSHOT_UNFREEZE - thaw user space processes frozen by SNAPSHOT_FREEZE
+
+SNAPSHOT_ATOMIC_SNAPSHOT - create a snapshot of the system memory; the
+ last argument of ioctl() should be a pointer to an int variable,
+ the value of which will indicate whether the call returned after
+ creating the snapshot (1) or after restoring the system memory state
+ from it (0) (after resume the system finds itself finishing the
+ SNAPSHOT_ATOMIC_SNAPSHOT ioctl() again); after the snapshot
+ has been created the read() operation can be used to transfer
+ it out of the kernel
+
+SNAPSHOT_ATOMIC_RESTORE - restore the system memory state from the
+ uploaded snapshot image; before calling it you should transfer
+ the system memory snapshot back to the kernel using the write()
+ operation; this call will not succeed if the snapshot
+ image is not available to the kernel
+
+SNAPSHOT_FREE - free memory allocated for the snapshot image
+
+SNAPSHOT_SET_IMAGE_SIZE - set the preferred maximum size of the image
+ (the kernel will do its best to ensure the image size will not exceed
+ this number, but if it turns out to be impossible, the kernel will
+ create the smallest image possible)
+
+SNAPSHOT_AVAIL_SWAP - return the amount of available swap in bytes (the last
+ argument should be a pointer to an unsigned int variable that will
+ contain the result if the call is successful).
+
+SNAPSHOT_GET_SWAP_PAGE - allocate a swap page from the resume partition
+ (the last argument should be a pointer to a loff_t variable that
+ will contain the swap page offset if the call is successful)
+
+SNAPSHOT_FREE_SWAP_PAGES - free all swap pages allocated with
+ SNAPSHOT_GET_SWAP_PAGE
+
+SNAPSHOT_SET_SWAP_FILE - set the resume partition (the last ioctl() argument
+ should specify the device's major and minor numbers in the old
+ two-byte format, as returned by the stat() function in the .st_rdev
+ member of the stat structure); it is recommended to always use this
+ call, because the code to set the resume partition could be removed from
+ future kernels
+
+The device's read() operation can be used to transfer the snapshot image from
+the kernel. It has the following limitations:
+- you cannot read() more than one virtual memory page at a time
+- read()s accross page boundaries are impossible (ie. if ypu read() 1/2 of
+ a page in the previous call, you will only be able to read()
+ _at_ _most_ 1/2 of the page in the next call)
+
+The device's write() operation is used for uploading the system memory snapshot
+into the kernel. It has the same limitations as the read() operation.
+
+The release() operation frees all memory allocated for the snapshot image
+and all swap pages allocated with SNAPSHOT_GET_SWAP_PAGE (if any).
+Thus it is not necessary to use either SNAPSHOT_FREE or
+SNAPSHOT_FREE_SWAP_PAGES before closing the device (in fact it will also
+unfreeze user space processes frozen by SNAPSHOT_UNFREEZE if they are
+still frozen when the device is being closed).
+
+Currently it is assumed that the userland utilities reading/writing the
+snapshot image from/to the kernel will use a swap parition, called the resume
+partition, as storage space. However, this is not really required, as they
+can use, for example, a special (blank) suspend partition or a file on a partition
+that is unmounted before SNAPSHOT_ATOMIC_SNAPSHOT and mounted afterwards.
+
+These utilities SHOULD NOT make any assumptions regarding the ordering of
+data within the snapshot image, except for the image header that MAY be
+assumed to start with an swsusp_info structure, as specified in
+kernel/power/power.h. This structure MAY be used by the userland utilities
+to obtain some information about the snapshot image, such as the size
+of the snapshot image, including the metadata and the header itself,
+contained in the .size member of swsusp_info.
+
+The snapshot image MUST be written to the kernel unaltered (ie. all of the image
+data, metadata and header MUST be written in _exactly_ the same amount, form
+and order in which they have been read). Otherwise, the behavior of the
+resumed system may be totally unpredictable.
+
+While executing SNAPSHOT_ATOMIC_RESTORE the kernel checks if the
+structure of the snapshot image is consistent with the information stored
+in the image header. If any inconsistencies are detected,
+SNAPSHOT_ATOMIC_RESTORE will not succeed. Still, this is not a fool-proof
+mechanism and the userland utilities using the interface SHOULD use additional
+means, such as checksums, to ensure the integrity of the snapshot image.
+
+The suspending and resuming utilities MUST lock themselves in memory,
+preferrably using mlockall(), before calling SNAPSHOT_FREEZE.
+
+The suspending utility MUST check the value stored by SNAPSHOT_ATOMIC_SNAPSHOT
+in the memory location pointed to by the last argument of ioctl() and proceed
+in accordance with it:
+1. If the value is 1 (ie. the system memory snapshot has just been
+ created and the system is ready for saving it):
+ (a) The suspending utility MUST NOT close the snapshot device
+ _unless_ the whole suspend procedure is to be cancelled, in
+ which case, if the snapshot image has already been saved, the
+ suspending utility SHOULD destroy it, preferrably by zapping
+ its header. If the suspend is not to be cancelled, the
+ system MUST be powered off or rebooted after the snapshot
+ image has been saved.
+ (b) The suspending utility SHOULD NOT attempt to perform any
+ file system operations (including reads) on the file systems
+ that were mounted before SNAPSHOT_ATOMIC_SNAPSHOT has been
+ called. However, it MAY mount a file system that was not
+ mounted at that time and perform some operations on it (eg.
+ use it for saving the image).
+2. If the value is 0 (ie. the system state has just been restored from
+ the snapshot image), the suspending utility MUST close the snapshot
+ device. Afterwards it will be treated as a regular userland process,
+ so it need not exit.
+
+The resuming utility SHOULD NOT attempt to mount any file systems that could
+be mounted before suspend and SHOULD NOT attempt to perform any operations
+involving such file systems.
+
+For details, please refer to the source code.
diff --git a/Documentation/power/video.txt b/Documentation/power/video.txt
index 912bed87c75..d18a57d1a53 100644
--- a/Documentation/power/video.txt
+++ b/Documentation/power/video.txt
@@ -1,7 +1,7 @@
Video issues with S3 resume
~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 2003-2005, Pavel Machek
+ 2003-2006, Pavel Machek
During S3 resume, hardware needs to be reinitialized. For most
devices, this is easy, and kernel driver knows how to do
@@ -15,6 +15,27 @@ run normally so video card is normally initialized. It should not be
problem for S1 standby, because hardware should retain its state over
that.
+We either have to run video BIOS during early resume, or interpret it
+using vbetool later, or maybe nothing is neccessary on particular
+system because video state is preserved. Unfortunately different
+methods work on different systems, and no known method suits all of
+them.
+
+Userland application called s2ram has been developed; it contains long
+whitelist of systems, and automatically selects working method for a
+given system. It can be downloaded from CVS at
+www.sf.net/projects/suspend . If you get a system that is not in the
+whitelist, please try to find a working solution, and submit whitelist
+entry so that work does not need to be repeated.
+
+Currently, VBE_SAVE method (6 below) works on most
+systems. Unfortunately, vbetool only runs after userland is resumed,
+so it makes debugging of early resume problems
+hard/impossible. Methods that do not rely on userland are preferable.
+
+Details
+~~~~~~~
+
There are a few types of systems where video works after S3 resume:
(1) systems where video state is preserved over S3.
@@ -104,6 +125,7 @@ HP NX7000 ??? (*)
HP Pavilion ZD7000 vbetool post needed, need open-source nv driver for X
HP Omnibook XE3 athlon version none (1)
HP Omnibook XE3GC none (1), video is S3 Savage/IX-MV
+HP Omnibook 5150 none (1), (S1 also works OK)
IBM TP T20, model 2647-44G none (1), video is S3 Inc. 86C270-294 Savage/IX-MV, vesafb gets "interesting" but X work.
IBM TP A31 / Type 2652-M5G s3_mode (3) [works ok with BIOS 1.04 2002-08-23, but not at all with BIOS 1.11 2004-11-05 :-(]
IBM TP R32 / Type 2658-MMG none (1)
@@ -120,18 +142,24 @@ IBM ThinkPad T42p (2373-GTG) s3_bios (2)
IBM TP X20 ??? (*)
IBM TP X30 s3_bios (2)
IBM TP X31 / Type 2672-XXH none (1), use radeontool (http://fdd.com/software/radeon/) to turn off backlight.
-IBM TP X32 none (1), but backlight is on and video is trashed after long suspend
+IBM TP X32 none (1), but backlight is on and video is trashed after long suspend. s3_bios,s3_mode (4) works too. Perhaps that gets better results?
IBM Thinkpad X40 Type 2371-7JG s3_bios,s3_mode (4)
+IBM TP 600e none(1), but a switch to console and back to X is needed
Medion MD4220 ??? (*)
Samsung P35 vbetool needed (6)
-Sharp PC-AR10 (ATI rage) none (1)
+Sharp PC-AR10 (ATI rage) none (1), backlight does not switch off
Sony Vaio PCG-C1VRX/K s3_bios (2)
Sony Vaio PCG-F403 ??? (*)
+Sony Vaio PCG-GRT995MP none (1), works with 'nv' X driver
+Sony Vaio PCG-GR7/K none (1), but needs radeonfb, use radeontool (http://fdd.com/software/radeon/) to turn off backlight.
Sony Vaio PCG-N505SN ??? (*)
Sony Vaio vgn-s260 X or boot-radeon can init it (5)
+Sony Vaio vgn-S580BH vga=normal, but suspend from X. Console will be blank unless you return to X.
+Sony Vaio vgn-FS115B s3_bios (2),s3_mode (4)
Toshiba Libretto L5 none (1)
-Toshiba Satellite 4030CDT s3_mode (3)
-Toshiba Satellite 4080XCDT s3_mode (3)
+Toshiba Portege 3020CT s3_mode (3)
+Toshiba Satellite 4030CDT s3_mode (3) (S1 also works OK)
+Toshiba Satellite 4080XCDT s3_mode (3) (S1 also works OK)
Toshiba Satellite 4090XCDT ??? (*)
Toshiba Satellite P10-554 s3_bios,s3_mode (4)(****)
Toshiba M30 (2) xor X with nvidia driver using internal AGP
@@ -151,39 +179,3 @@ Asus A7V8X nVidia RIVA TNT2 model 64 s3_bios,s3_mode (4)
(***) To be tested with a newer kernel.
(****) Not with SMP kernel, UP only.
-
-VBEtool details
-~~~~~~~~~~~~~~~
-(with thanks to Carl-Daniel Hailfinger)
-
-First, boot into X and run the following script ONCE:
-#!/bin/bash
-statedir=/root/s3/state
-mkdir -p $statedir
-chvt 2
-sleep 1
-vbetool vbestate save >$statedir/vbe
-
-
-To suspend and resume properly, call the following script as root:
-#!/bin/bash
-statedir=/root/s3/state
-curcons=`fgconsole`
-fuser /dev/tty$curcons 2>/dev/null|xargs ps -o comm= -p|grep -q X && chvt 2
-cat /dev/vcsa >$statedir/vcsa
-sync
-echo 3 >/proc/acpi/sleep
-sync
-vbetool post
-vbetool vbestate restore <$statedir/vbe
-cat $statedir/vcsa >/dev/vcsa
-rckbd restart
-chvt $[curcons%6+1]
-chvt $curcons
-
-
-Unless you change your graphics card or other hardware configuration,
-the state once saved will be OK for every resume afterwards.
-NOTE: The "rckbd restart" command may be different for your
-distribution. Simply replace it with the command you would use to
-set the fonts on screen.
diff --git a/Documentation/powerpc/booting-without-of.txt b/Documentation/powerpc/booting-without-of.txt
index d02c64953dc..ee551c6ea23 100644
--- a/Documentation/powerpc/booting-without-of.txt
+++ b/Documentation/powerpc/booting-without-of.txt
@@ -1365,6 +1365,78 @@ platforms are moved over to use the flattened-device-tree model.
};
+ g) Freescale SOC SEC Security Engines
+
+ Required properties:
+
+ - device_type : Should be "crypto"
+ - model : Model of the device. Should be "SEC1" or "SEC2"
+ - compatible : Should be "talitos"
+ - reg : Offset and length of the register set for the device
+ - interrupts : <a b> where a is the interrupt number and b is a
+ field that represents an encoding of the sense and level
+ information for the interrupt. This should be encoded based on
+ the information in section 2) depending on the type of interrupt
+ controller you have.
+ - interrupt-parent : the phandle for the interrupt controller that
+ services interrupts for this device.
+ - num-channels : An integer representing the number of channels
+ available.
+ - channel-fifo-len : An integer representing the number of
+ descriptor pointers each channel fetch fifo can hold.
+ - exec-units-mask : The bitmask representing what execution units
+ (EUs) are available. It's a single 32 bit cell. EU information
+ should be encoded following the SEC's Descriptor Header Dword
+ EU_SEL0 field documentation, i.e. as follows:
+
+ bit 0 = reserved - should be 0
+ bit 1 = set if SEC has the ARC4 EU (AFEU)
+ bit 2 = set if SEC has the DES/3DES EU (DEU)
+ bit 3 = set if SEC has the message digest EU (MDEU)
+ bit 4 = set if SEC has the random number generator EU (RNG)
+ bit 5 = set if SEC has the public key EU (PKEU)
+ bit 6 = set if SEC has the AES EU (AESU)
+ bit 7 = set if SEC has the Kasumi EU (KEU)
+
+ bits 8 through 31 are reserved for future SEC EUs.
+
+ - descriptor-types-mask : The bitmask representing what descriptors
+ are available. It's a single 32 bit cell. Descriptor type
+ information should be encoded following the SEC's Descriptor
+ Header Dword DESC_TYPE field documentation, i.e. as follows:
+
+ bit 0 = set if SEC supports the aesu_ctr_nonsnoop desc. type
+ bit 1 = set if SEC supports the ipsec_esp descriptor type
+ bit 2 = set if SEC supports the common_nonsnoop desc. type
+ bit 3 = set if SEC supports the 802.11i AES ccmp desc. type
+ bit 4 = set if SEC supports the hmac_snoop_no_afeu desc. type
+ bit 5 = set if SEC supports the srtp descriptor type
+ bit 6 = set if SEC supports the non_hmac_snoop_no_afeu desc.type
+ bit 7 = set if SEC supports the pkeu_assemble descriptor type
+ bit 8 = set if SEC supports the aesu_key_expand_output desc.type
+ bit 9 = set if SEC supports the pkeu_ptmul descriptor type
+ bit 10 = set if SEC supports the common_nonsnoop_afeu desc. type
+ bit 11 = set if SEC supports the pkeu_ptadd_dbl descriptor type
+
+ ..and so on and so forth.
+
+ Example:
+
+ /* MPC8548E */
+ crypto@30000 {
+ device_type = "crypto";
+ model = "SEC2";
+ compatible = "talitos";
+ reg = <30000 10000>;
+ interrupts = <1d 3>;
+ interrupt-parent = <40000>;
+ num-channels = <4>;
+ channel-fifo-len = <24>;
+ exec-units-mask = <000000fe>;
+ descriptor-types-mask = <073f1127>;
+ };
+
+
More devices will be defined as this spec matures.
diff --git a/Documentation/powerpc/eeh-pci-error-recovery.txt b/Documentation/powerpc/eeh-pci-error-recovery.txt
index 67a11a36270..3764dd4b12c 100644
--- a/Documentation/powerpc/eeh-pci-error-recovery.txt
+++ b/Documentation/powerpc/eeh-pci-error-recovery.txt
@@ -121,7 +121,7 @@ accomplished.
EEH must be enabled in the PHB's very early during the boot process,
and if a PCI slot is hot-plugged. The former is performed by
-eeh_init() in arch/ppc64/kernel/eeh.c, and the later by
+eeh_init() in arch/powerpc/platforms/pseries/eeh.c, and the later by
drivers/pci/hotplug/pSeries_pci.c calling in to the eeh.c code.
EEH must be enabled before a PCI scan of the device can proceed.
Current Power5 hardware will not work unless EEH is enabled;
@@ -133,7 +133,7 @@ error. Given an arbitrary address, the routine
pci_get_device_by_addr() will find the pci device associated
with that address (if any).
-The default include/asm-ppc64/io.h macros readb(), inb(), insb(),
+The default include/asm-powerpc/io.h macros readb(), inb(), insb(),
etc. include a check to see if the i/o read returned all-0xff's.
If so, these make a call to eeh_dn_check_failure(), which in turn
asks the firmware if the all-ff's value is the sign of a true EEH
@@ -143,11 +143,12 @@ seen in /proc/ppc64/eeh (subject to change). Normally, almost
all of these occur during boot, when the PCI bus is scanned, where
a large number of 0xff reads are part of the bus scan procedure.
-If a frozen slot is detected, code in arch/ppc64/kernel/eeh.c will
-print a stack trace to syslog (/var/log/messages). This stack trace
-has proven to be very useful to device-driver authors for finding
-out at what point the EEH error was detected, as the error itself
-usually occurs slightly beforehand.
+If a frozen slot is detected, code in
+arch/powerpc/platforms/pseries/eeh.c will print a stack trace to
+syslog (/var/log/messages). This stack trace has proven to be very
+useful to device-driver authors for finding out at what point the EEH
+error was detected, as the error itself usually occurs slightly
+beforehand.
Next, it uses the Linux kernel notifier chain/work queue mechanism to
allow any interested parties to find out about the failure. Device
diff --git a/Documentation/powerpc/hvcs.txt b/Documentation/powerpc/hvcs.txt
index dca75cbda6f..1e38166f4e5 100644
--- a/Documentation/powerpc/hvcs.txt
+++ b/Documentation/powerpc/hvcs.txt
@@ -558,9 +558,9 @@ partitions.
The proper channel for reporting bugs is either through the Linux OS
distribution company that provided your OS or by posting issues to the
-ppc64 development mailing list at:
+PowerPC development mailing list at:
-linuxppc64-dev@lists.linuxppc.org
+linuxppc-dev@ozlabs.org
This request is to provide a documented and searchable public exchange
of the problems and solutions surrounding this driver for the benefit of
diff --git a/Documentation/s390/driver-model.txt b/Documentation/s390/driver-model.txt
index df09758bf3f..efb674eda4d 100644
--- a/Documentation/s390/driver-model.txt
+++ b/Documentation/s390/driver-model.txt
@@ -16,10 +16,12 @@ devices/
- 0.0.0000/0.0.0815/
- 0.0.0001/0.0.4711/
- 0.0.0002/
+ - 0.1.0000/0.1.1234/
...
-In this example, device 0815 is accessed via subchannel 0, device 4711 via
-subchannel 1, and subchannel 2 is a non-I/O subchannel.
+In this example, device 0815 is accessed via subchannel 0 in subchannel set 0,
+device 4711 via subchannel 1 in subchannel set 0, and subchannel 2 is a non-I/O
+subchannel. Device 1234 is accessed via subchannel 0 in subchannel set 1.
You should address a ccw device via its bus id (e.g. 0.0.4711); the device can
be found under bus/ccw/devices/.
@@ -97,7 +99,7 @@ is not available to the device driver.
Each driver should declare in a MODULE_DEVICE_TABLE into which CU types/models
and/or device types/models it is interested. This information can later be found
-found in the struct ccw_device_id fields:
+in the struct ccw_device_id fields:
struct ccw_device_id {
__u16 match_flags;
@@ -208,6 +210,11 @@ Each ccwgroup device also provides an 'ungroup' attribute to destroy the device
again (only when offline). This is a generic ccwgroup mechanism (the driver does
not need to implement anything beyond normal removal routines).
+A ccw device which is a member of a ccwgroup device carries a pointer to the
+ccwgroup device in the driver_data of its device struct. This field must not be
+touched by the driver - it should use the ccwgroup device's driver_data for its
+private data.
+
To implement a ccwgroup driver, please refer to include/asm/ccwgroup.h. Keep in
mind that most drivers will need to implement both a ccwgroup and a ccw driver
(unless you have a meta ccw driver, like cu3088 for lcs and ctc).
@@ -230,6 +237,8 @@ status - Can be 'online' or 'offline'.
a channel path the user knows to be online, but the machine hasn't
created a machine check for.
+type - The physical type of the channel path.
+
3. System devices
-----------------
diff --git a/Documentation/serial-console.txt b/Documentation/serial-console.txt
index 6c689b0df2b..9a7bc8b3f47 100644
--- a/Documentation/serial-console.txt
+++ b/Documentation/serial-console.txt
@@ -17,11 +17,13 @@ The format of this option is:
ttyX for any other virtual console
ttySx for a serial port
lp0 for the first parallel port
+ ttyUSB0 for the first USB serial device
options: depend on the driver. For the serial port this
- defines the baudrate/parity/bits of the port,
- in the format BBBBPN, where BBBB is the speed,
- P is parity (n/o/e), and N is bits. Default is
+ defines the baudrate/parity/bits/flow control of
+ the port, in the format BBBBPNF, where BBBB is the
+ speed, P is parity (n/o/e), N is number of bits,
+ and F is flow control ('r' for RTS). Default is
9600n8. The maximum baudrate is 115200.
You can specify multiple console= options on the kernel command line.
@@ -45,6 +47,9 @@ become the console.
You will need to create a new device to use /dev/console. The official
/dev/console is now character device 5,1.
+(You can also use a network device as a console. See
+Documentation/networking/netconsole.txt for information on that.)
+
Here's an example that will use /dev/ttyS1 (COM2) as the console.
Replace the sample values as needed.
diff --git a/Documentation/smart-config.txt b/Documentation/smart-config.txt
index c9bed4cf877..8467447b5a8 100644
--- a/Documentation/smart-config.txt
+++ b/Documentation/smart-config.txt
@@ -56,10 +56,6 @@ Here is the solution:
writing one file per option. It updates only the files for options
that have changed.
- mkdep.c no longer generates warning messages for missing or unneeded
- <linux/config.h> lines. The new top-level target 'make checkconfig'
- checks for these problems.
-
Flag Dependencies
Martin Von Loewis contributed another feature to this patch:
diff --git a/Documentation/sound/oss/Introduction b/Documentation/sound/oss/Introduction
index 15d4fb975ac..f04ba6bb739 100644
--- a/Documentation/sound/oss/Introduction
+++ b/Documentation/sound/oss/Introduction
@@ -69,7 +69,7 @@ are available, for example IRQ, address, DMA.
Warning, the options for different cards sometime use different names
for the same or a similar feature (dma1= versus dma16=). As a last
-resort, inspect the code (search for MODULE_PARM).
+resort, inspect the code (search for module_param).
Notes:
diff --git a/Documentation/sound/oss/cs46xx b/Documentation/sound/oss/cs46xx
index 88d6cf8b39f..b5443270986 100644
--- a/Documentation/sound/oss/cs46xx
+++ b/Documentation/sound/oss/cs46xx
@@ -88,7 +88,7 @@ parameters. for a copy email: twoller@crystal.cirrus.com
MODULE_PARMS definitions
------------------------
-MODULE_PARM(defaultorder, "i");
+module_param(defaultorder, ulong, 0);
defaultorder=N
where N is a value from 1 to 12
The buffer order determines the size of the dma buffer for the driver.
@@ -98,18 +98,18 @@ to not underrun the dma buffer as easily. As default, use 32k (order=3)
rather than 64k as some of the games work more responsively.
(2^N) * PAGE_SIZE = allocated buffer size
-MODULE_PARM(cs_debuglevel, "i");
-MODULE_PARM(cs_debugmask, "i");
+module_param(cs_debuglevel, ulong, 0644);
+module_param(cs_debugmask, ulong, 0644);
cs_debuglevel=N
cs_debugmask=0xMMMMMMMM
where N is a value from 0 (no debug printfs), to 9 (maximum)
0xMMMMMMMM is a debug mask corresponding to the CS_xxx bits (see driver source).
-MODULE_PARM(hercules_egpio_disable, "i");
+module_param(hercules_egpio_disable, ulong, 0);
hercules_egpio_disable=N
where N is a 0 (enable egpio), or a 1 (disable egpio support)
-MODULE_PARM(initdelay, "i");
+module_param(initdelay, ulong, 0);
initdelay=N
This value is used to determine the millescond delay during the initialization
code prior to powering up the PLL. On laptops this value can be used to
@@ -118,19 +118,19 @@ system is booted under battery power then the mdelay()/udelay() functions fail t
properly delay the required time. Also, if the system is booted under AC power
and then the power removed, the mdelay()/udelay() functions will not delay properly.
-MODULE_PARM(powerdown, "i");
+module_param(powerdown, ulong, 0);
powerdown=N
where N is 0 (disable any powerdown of the internal blocks) or 1 (enable powerdown)
-MODULE_PARM(external_amp, "i");
+module_param(external_amp, bool, 0);
external_amp=1
if N is set to 1, then force enabling the EAPD support in the primary AC97 codec.
override the detection logic and force the external amp bit in the AC97 0x26 register
to be reset (0). EAPD should be 0 for powerup, and 1 for powerdown. The VTB Santa Cruz
card has inverted logic, so there is a special function for these cards.
-MODULE_PARM(thinkpad, "i");
+module_param(thinkpad, bool, 0);
thinkpad=1
if N is set to 1, then force enabling the clkrun functionality.
Currently, when the part is being used, then clkrun is disabled for the entire system,
diff --git a/Documentation/video4linux/CQcam.txt b/Documentation/video4linux/CQcam.txt
index e415e360453..464e4cec94c 100644
--- a/Documentation/video4linux/CQcam.txt
+++ b/Documentation/video4linux/CQcam.txt
@@ -1,7 +1,7 @@
c-qcam - Connectix Color QuickCam video4linux kernel driver
Copyright (C) 1999 Dave Forrest <drf5n@virginia.edu>
- released under GNU GPL.
+ released under GNU GPL.
1999-12-08 Dave Forrest, written with kernel version 2.2.12 in mind
@@ -45,21 +45,21 @@ configuration. The appropriate flags are:
CONFIG_PNP_PARPORT M for autoprobe.o IEEE1284 readback module
CONFIG_PRINTER_READBACK M for parport_probe.o IEEE1284 readback module
CONFIG_VIDEO_DEV M for videodev.o video4linux module
- CONFIG_VIDEO_CQCAM M for c-qcam.o Color Quickcam module
+ CONFIG_VIDEO_CQCAM M for c-qcam.o Color Quickcam module
With these flags, the kernel should compile and install the modules.
To record and monitor the compilation, I use:
(make zlilo ; \
make modules; \
- make modules_install ;
+ make modules_install ;
depmod -a ) &>log &
less log # then a capital 'F' to watch the progress
-
+
But that is my personal preference.
2.2 Configuration
-
+
The configuration requires module configuration and device
configuration. I like kmod or kerneld process with the
/etc/modprobe.conf file so the modules can automatically load/unload as
@@ -68,7 +68,7 @@ using MAKEDEV, or need to be created. The following sections detail
these procedures.
-2.1 Module Configuration
+2.1 Module Configuration
Using modules requires a bit of work to install and pass the
parameters. Understand that entries in /etc/modprobe.conf of:
@@ -128,9 +128,9 @@ system (CONFIG_PROC_FS), the parallel printer support
(CONFIG_PRINTER), the IEEE 1284 system,(CONFIG_PRINTER_READBACK), you
should be able to read some identification from your quickcam with
- modprobe -v parport
- modprobe -v parport_probe
- cat /proc/parport/PORTNUMBER/autoprobe
+ modprobe -v parport
+ modprobe -v parport_probe
+ cat /proc/parport/PORTNUMBER/autoprobe
Returns:
CLASS:MEDIA;
MODEL:Color QuickCam 2.0;
@@ -140,7 +140,7 @@ Returns:
and well. A common problem is that the current driver does not
reliably detect a c-qcam, even though one is attached. In this case,
- modprobe -v c-qcam
+ modprobe -v c-qcam
or
insmod -v c-qcam
@@ -152,16 +152,16 @@ video4linux mailing list and archive for more current information.
3.1 Checklist:
Can you get an image?
- v4lgrab >qcam.ppm ; wc qcam.ppm ; xv qcam.ppm
+ v4lgrab >qcam.ppm ; wc qcam.ppm ; xv qcam.ppm
- Is a working c-qcam connected to the port?
- grep ^ /proc/parport/?/autoprobe
+ Is a working c-qcam connected to the port?
+ grep ^ /proc/parport/?/autoprobe
- Do the /dev/video* files exist?
- ls -lad /dev/video
+ Do the /dev/video* files exist?
+ ls -lad /dev/video
- Is the c-qcam module loaded?
- modprobe -v c-qcam ; lsmod
+ Is the c-qcam module loaded?
+ modprobe -v c-qcam ; lsmod
Does the camera work with alternate programs? cqcam, etc?
@@ -174,7 +174,7 @@ video4linux mailing list and archive for more current information.
isn't, you might try patching the c-qcam module to add a parport=xxx
option as in the bw-qcam module so you can specify the parallel port:
- insmod -v c-qcam parport=0
+ insmod -v c-qcam parport=0
And bypass the detection code, see ../../drivers/char/c-qcam.c and
look for the 'qc_detect' code and call.
@@ -183,12 +183,12 @@ look for the 'qc_detect' code and call.
this work is documented at the video4linux2 site listed below.
-9.0 --- A sample program using v4lgrabber,
+9.0 --- A sample program using v4lgrabber,
This program is a simple image grabber that will copy a frame from the
first video device, /dev/video0 to standard output in portable pixmap
format (.ppm) Using this like: 'v4lgrab | convert - c-qcam.jpg'
-produced this picture of me at
+produced this picture of me at
http://mug.sys.virginia.edu/~drf5n/extras/c-qcam.jpg
-------------------- 8< ---------------- 8< -----------------------------
@@ -202,8 +202,8 @@ produced this picture of me at
* Use as:
* v4lgrab >image.ppm
*
- * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org>
- * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c
+ * Copyright (C) 1998-05-03, Phil Blundell <philb@gnu.org>
+ * Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c
* with minor modifications (Dave Forrest, drf5n@virginia.edu).
*
*/
@@ -225,55 +225,55 @@ produced this picture of me at
#define READ_VIDEO_PIXEL(buf, format, depth, r, g, b) \
{ \
- switch (format) \
- { \
- case VIDEO_PALETTE_GREY: \
- switch (depth) \
- { \
- case 4: \
- case 6: \
- case 8: \
- (r) = (g) = (b) = (*buf++ << 8);\
- break; \
- \
- case 16: \
- (r) = (g) = (b) = \
- *((unsigned short *) buf); \
- buf += 2; \
- break; \
- } \
- break; \
- \
- \
- case VIDEO_PALETTE_RGB565: \
- { \
- unsigned short tmp = *(unsigned short *)buf; \
- (r) = tmp&0xF800; \
- (g) = (tmp<<5)&0xFC00; \
- (b) = (tmp<<11)&0xF800; \
- buf += 2; \
- } \
- break; \
- \
- case VIDEO_PALETTE_RGB555: \
- (r) = (buf[0]&0xF8)<<8; \
- (g) = ((buf[0] << 5 | buf[1] >> 3)&0xF8)<<8; \
- (b) = ((buf[1] << 2 ) & 0xF8)<<8; \
- buf += 2; \
- break; \
- \
- case VIDEO_PALETTE_RGB24: \
- (r) = buf[0] << 8; (g) = buf[1] << 8; \
- (b) = buf[2] << 8; \
- buf += 3; \
- break; \
- \
- default: \
- fprintf(stderr, \
- "Format %d not yet supported\n", \
- format); \
- } \
-}
+ switch (format) \
+ { \
+ case VIDEO_PALETTE_GREY: \
+ switch (depth) \
+ { \
+ case 4: \
+ case 6: \
+ case 8: \
+ (r) = (g) = (b) = (*buf++ << 8);\
+ break; \
+ \
+ case 16: \
+ (r) = (g) = (b) = \
+ *((unsigned short *) buf); \
+ buf += 2; \
+ break; \
+ } \
+ break; \
+ \
+ \
+ case VIDEO_PALETTE_RGB565: \
+ { \
+ unsigned short tmp = *(unsigned short *)buf; \
+ (r) = tmp&0xF800; \
+ (g) = (tmp<<5)&0xFC00; \
+ (b) = (tmp<<11)&0xF800; \
+ buf += 2; \
+ } \
+ break; \
+ \
+ case VIDEO_PALETTE_RGB555: \
+ (r) = (buf[0]&0xF8)<<8; \
+ (g) = ((buf[0] << 5 | buf[1] >> 3)&0xF8)<<8; \
+ (b) = ((buf[1] << 2 ) & 0xF8)<<8; \
+ buf += 2; \
+ break; \
+ \
+ case VIDEO_PALETTE_RGB24: \
+ (r) = buf[0] << 8; (g) = buf[1] << 8; \
+ (b) = buf[2] << 8; \
+ buf += 3; \
+ break; \
+ \
+ default: \
+ fprintf(stderr, \
+ "Format %d not yet supported\n", \
+ format); \
+ } \
+}
int get_brightness_adj(unsigned char *image, long size, int *brightness) {
long i, tot = 0;
@@ -324,40 +324,40 @@ int main(int argc, char ** argv)
if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
vpic.depth=6;
if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
- vpic.depth=4;
- if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
- fprintf(stderr, "Unable to find a supported capture format.\n");
- close(fd);
- exit(1);
- }
+ vpic.depth=4;
+ if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
+ fprintf(stderr, "Unable to find a supported capture format.\n");
+ close(fd);
+ exit(1);
+ }
}
}
} else {
vpic.depth=24;
vpic.palette=VIDEO_PALETTE_RGB24;
-
+
if(ioctl(fd, VIDIOCSPICT, &vpic) < 0) {
vpic.palette=VIDEO_PALETTE_RGB565;
vpic.depth=16;
-
+
if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
- vpic.palette=VIDEO_PALETTE_RGB555;
- vpic.depth=15;
-
- if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
- fprintf(stderr, "Unable to find a supported capture format.\n");
- return -1;
- }
+ vpic.palette=VIDEO_PALETTE_RGB555;
+ vpic.depth=15;
+
+ if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
+ fprintf(stderr, "Unable to find a supported capture format.\n");
+ return -1;
+ }
}
}
}
-
+
buffer = malloc(win.width * win.height * bpp);
if (!buffer) {
fprintf(stderr, "Out of memory.\n");
exit(1);
}
-
+
do {
int newbright;
read(fd, buffer, win.width * win.height * bpp);
@@ -365,8 +365,8 @@ int main(int argc, char ** argv)
if (f) {
vpic.brightness += (newbright << 8);
if(ioctl(fd, VIDIOCSPICT, &vpic)==-1) {
- perror("VIDIOSPICT");
- break;
+ perror("VIDIOSPICT");
+ break;
}
}
} while (f);
@@ -381,7 +381,7 @@ int main(int argc, char ** argv)
fputc(g>>8, stdout);
fputc(b>>8, stdout);
}
-
+
close(fd);
return 0;
}
diff --git a/Documentation/video4linux/README.cpia b/Documentation/video4linux/README.cpia
index c95e7bbc0fd..19cd3bf2498 100644
--- a/Documentation/video4linux/README.cpia
+++ b/Documentation/video4linux/README.cpia
@@ -87,7 +87,7 @@ hardware configuration of the parport. You can give the boot-parameter
at the LILO-prompt or specify it in lilo.conf. I use the following
append-line in lilo.conf:
- append="parport=0x378,7,3"
+ append="parport=0x378,7,3"
See Documentation/parport.txt for more information about the
configuration of the parport and the values given above. Do not simply
@@ -175,7 +175,7 @@ THANKS (in no particular order):
- Manuel J. Petit de Gabriel <mpetit@dit.upm.es> for providing help
with Isabel (http://isabel.dit.upm.es/)
- Bas Huisman <bhuism@cs.utwente.nl> for writing the initial parport code
-- Jarl Totland <Jarl.Totland@bdc.no> for setting up the mailing list
+- Jarl Totland <Jarl.Totland@bdc.no> for setting up the mailing list
and maintaining the web-server[3]
- Chris Whiteford <Chris@informinteractive.com> for fixes related to the
1.02 firmware
diff --git a/Documentation/video4linux/Zoran b/Documentation/video4linux/Zoran
index 52c94bd7dca..be9f21b8455 100644
--- a/Documentation/video4linux/Zoran
+++ b/Documentation/video4linux/Zoran
@@ -28,7 +28,7 @@ Iomega Buz:
* Philips saa7111 TV decoder
* Philips saa7185 TV encoder
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, saa7111, saa7185, zr36060, zr36067
+ videocodec, saa7111, saa7185, zr36060, zr36067
Inputs/outputs: Composite and S-video
Norms: PAL, SECAM (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
Card number: 7
@@ -39,7 +39,7 @@ Linux Media Labs LML33:
* Brooktree bt819 TV decoder
* Brooktree bt856 TV encoder
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, bt819, bt856, zr36060, zr36067
+ videocodec, bt819, bt856, zr36060, zr36067
Inputs/outputs: Composite and S-video
Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
Card number: 5
@@ -50,7 +50,7 @@ Linux Media Labs LML33R10:
* Philips saa7114 TV decoder
* Analog Devices adv7170 TV encoder
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, saa7114, adv7170, zr36060, zr36067
+ videocodec, saa7114, adv7170, zr36060, zr36067
Inputs/outputs: Composite and S-video
Norms: PAL (720x576 @ 25 fps), NTSC (720x480 @ 29.97 fps)
Card number: 6
@@ -61,7 +61,7 @@ Pinnacle/Miro DC10(new):
* Philips saa7110a TV decoder
* Analog Devices adv7176 TV encoder
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, saa7110, adv7175, zr36060, zr36067
+ videocodec, saa7110, adv7175, zr36060, zr36067
Inputs/outputs: Composite, S-video and Internal
Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
Card number: 1
@@ -84,7 +84,7 @@ Pinnacle/Miro DC10(old): *
* Micronas vpx3220a TV decoder
* mse3000 TV encoder or Analog Devices adv7176 TV encoder *
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, vpx3220, mse3000/adv7175, zr36050, zr36016, zr36067
+ videocodec, vpx3220, mse3000/adv7175, zr36050, zr36016, zr36067
Inputs/outputs: Composite, S-video and Internal
Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
Card number: 0
@@ -96,7 +96,7 @@ Pinnacle/Miro DC30: *
* Micronas vpx3225d/vpx3220a/vpx3216b TV decoder
* Analog Devices adv7176 TV encoder
Drivers to use: videodev, i2c-core, i2c-algo-bit,
- videocodec, vpx3220/vpx3224, adv7175, zr36050, zr36016, zr36067
+ videocodec, vpx3220/vpx3224, adv7175, zr36050, zr36016, zr36067
Inputs/outputs: Composite, S-video and Internal
Norms: PAL, SECAM (768x576 @ 25 fps), NTSC (640x480 @ 29.97 fps)
Card number: 3
@@ -123,11 +123,11 @@ Note: use encoder=X or decoder=X for non-default i2c chips (see i2c-id.h)
The best know TV standards are NTSC/PAL/SECAM. but for decoding a frame that
information is not enough. There are several formats of the TV standards.
-And not every TV decoder is able to handle every format. Also the every
-combination is supported by the driver. There are currently 11 different
-tv broadcast formats all aver the world.
+And not every TV decoder is able to handle every format. Also the every
+combination is supported by the driver. There are currently 11 different
+tv broadcast formats all aver the world.
-The CCIR defines parameters needed for broadcasting the signal.
+The CCIR defines parameters needed for broadcasting the signal.
The CCIR has defined different standards: A,B,D,E,F,G,D,H,I,K,K1,L,M,N,...
The CCIR says not much about about the colorsystem used !!!
And talking about a colorsystem says not to much about how it is broadcast.
@@ -136,18 +136,18 @@ The CCIR standards A,E,F are not used any more.
When you speak about NTSC, you usually mean the standard: CCIR - M using
the NTSC colorsystem which is used in the USA, Japan, Mexico, Canada
-and a few others.
+and a few others.
When you talk about PAL, you usually mean: CCIR - B/G using the PAL
-colorsystem which is used in many Countries.
+colorsystem which is used in many Countries.
-When you talk about SECAM, you mean: CCIR - L using the SECAM Colorsystem
+When you talk about SECAM, you mean: CCIR - L using the SECAM Colorsystem
which is used in France, and a few others.
There the other version of SECAM, CCIR - D/K is used in Bulgaria, China,
-Slovakai, Hungary, Korea (Rep.), Poland, Rumania and a others.
+Slovakai, Hungary, Korea (Rep.), Poland, Rumania and a others.
-The CCIR - H uses the PAL colorsystem (sometimes SECAM) and is used in
+The CCIR - H uses the PAL colorsystem (sometimes SECAM) and is used in
Egypt, Libya, Sri Lanka, Syrain Arab. Rep.
The CCIR - I uses the PAL colorsystem, and is used in Great Britain, Hong Kong,
@@ -158,30 +158,30 @@ and is used in Argentinia, Uruguay, an a few others
We do not talk about how the audio is broadcast !
-A rather good sites about the TV standards are:
+A rather good sites about the TV standards are:
http://www.sony.jp/ServiceArea/Voltage_map/
http://info.electronicwerkstatt.de/bereiche/fernsehtechnik/frequenzen_und_normen/Fernsehnormen/
and http://www.cabl.com/restaurant/channel.html
Other weird things around: NTSC 4.43 is a modificated NTSC, which is mainly
used in PAL VCR's that are able to play back NTSC. PAL 60 seems to be the same
-as NTSC 4.43 . The Datasheets also talk about NTSC 44, It seems as if it would
-be the same as NTSC 4.43.
+as NTSC 4.43 . The Datasheets also talk about NTSC 44, It seems as if it would
+be the same as NTSC 4.43.
NTSC Combs seems to be a decoder mode where the decoder uses a comb filter
to split coma and luma instead of a Delay line.
But I did not defiantly find out what NTSC Comb is.
Philips saa7111 TV decoder
-was introduced in 1997, is used in the BUZ and
-can handle: PAL B/G/H/I, PAL N, PAL M, NTSC M, NTSC N, NTSC 4.43 and SECAM
+was introduced in 1997, is used in the BUZ and
+can handle: PAL B/G/H/I, PAL N, PAL M, NTSC M, NTSC N, NTSC 4.43 and SECAM
Philips saa7110a TV decoder
was introduced in 1995, is used in the Pinnacle/Miro DC10(new), DC10+ and
-can handle: PAL B/G, NTSC M and SECAM
+can handle: PAL B/G, NTSC M and SECAM
Philips saa7114 TV decoder
-was introduced in 2000, is used in the LML33R10 and
+was introduced in 2000, is used in the LML33R10 and
can handle: PAL B/G/D/H/I/N, PAL N, PAL M, NTSC M, NTSC 4.43 and SECAM
Brooktree bt819 TV decoder
@@ -206,7 +206,7 @@ was introduced in 1996, is used in the BUZ
can generate: PAL B/G, NTSC M
Brooktree bt856 TV Encoder
-was introduced in 1994, is used in the LML33
+was introduced in 1994, is used in the LML33
can generate: PAL B/D/G/H/I/N, PAL M, NTSC M, PAL-N (Argentina)
Analog Devices adv7170 TV Encoder
@@ -221,9 +221,9 @@ ITT mse3000 TV encoder
was introduced in 1991, is used in the DC10 old
can generate: PAL , NTSC , SECAM
-The adv717x, should be able to produce PAL N. But you find nothing PAL N
+The adv717x, should be able to produce PAL N. But you find nothing PAL N
specific in the registers. Seem that you have to reuse a other standard
-to generate PAL N, maybe it would work if you use the PAL M settings.
+to generate PAL N, maybe it would work if you use the PAL M settings.
==========================
@@ -261,7 +261,7 @@ Here's my experience of using LML33 and Buz on various motherboards:
VIA MVP3
Forget it. Pointless. Doesn't work.
-Intel 430FX (Pentium 200)
+Intel 430FX (Pentium 200)
LML33 perfect, Buz tolerable (3 or 4 frames dropped per movie)
Intel 440BX (early stepping)
LML33 tolerable. Buz starting to get annoying (6-10 frames/hour)
@@ -438,52 +438,52 @@ importance of buffer sizes:
> -q 25 -b 128 : 24.655.992
> -q 25 -b 256 : 25.859.820
-I woke up, and can't go to sleep again. I'll kill some time explaining why
+I woke up, and can't go to sleep again. I'll kill some time explaining why
this doesn't look strange to me.
-Let's do some math using a width of 704 pixels. I'm not sure whether the Buz
+Let's do some math using a width of 704 pixels. I'm not sure whether the Buz
actually use that number or not, but that's not too important right now.
-704x288 pixels, one field, is 202752 pixels. Divided by 64 pixels per block;
-3168 blocks per field. Each pixel consist of two bytes; 128 bytes per block;
-1024 bits per block. 100% in the new driver mean 1:2 compression; the maximum
-output becomes 512 bits per block. Actually 510, but 512 is simpler to use
+704x288 pixels, one field, is 202752 pixels. Divided by 64 pixels per block;
+3168 blocks per field. Each pixel consist of two bytes; 128 bytes per block;
+1024 bits per block. 100% in the new driver mean 1:2 compression; the maximum
+output becomes 512 bits per block. Actually 510, but 512 is simpler to use
for calculations.
-Let's say that we specify d1q50. We thus want 256 bits per block; times 3168
-becomes 811008 bits; 101376 bytes per field. We're talking raw bits and bytes
-here, so we don't need to do any fancy corrections for bits-per-pixel or such
+Let's say that we specify d1q50. We thus want 256 bits per block; times 3168
+becomes 811008 bits; 101376 bytes per field. We're talking raw bits and bytes
+here, so we don't need to do any fancy corrections for bits-per-pixel or such
things. 101376 bytes per field.
-d1 video contains two fields per frame. Those sum up to 202752 bytes per
+d1 video contains two fields per frame. Those sum up to 202752 bytes per
frame, and one of those frames goes into each buffer.
-But wait a second! -b128 gives 128kB buffers! It's not possible to cram
+But wait a second! -b128 gives 128kB buffers! It's not possible to cram
202752 bytes of JPEG data into 128kB!
-This is what the driver notice and automatically compensate for in your
+This is what the driver notice and automatically compensate for in your
examples. Let's do some math using this information:
-128kB is 131072 bytes. In this buffer, we want to store two fields, which
-leaves 65536 bytes for each field. Using 3168 blocks per field, we get
-20.68686868... available bytes per block; 165 bits. We can't allow the
-request for 256 bits per block when there's only 165 bits available! The -q50
-option is silently overridden, and the -b128 option takes precedence, leaving
+128kB is 131072 bytes. In this buffer, we want to store two fields, which
+leaves 65536 bytes for each field. Using 3168 blocks per field, we get
+20.68686868... available bytes per block; 165 bits. We can't allow the
+request for 256 bits per block when there's only 165 bits available! The -q50
+option is silently overridden, and the -b128 option takes precedence, leaving
us with the equivalence of -q32.
-This gives us a data rate of 165 bits per block, which, times 3168, sums up
-to 65340 bytes per field, out of the allowed 65536. The current driver has
-another level of rate limiting; it won't accept -q values that fill more than
-6/8 of the specified buffers. (I'm not sure why. "Playing it safe" seem to be
-a safe bet. Personally, I think I would have lowered requested-bits-per-block
-by one, or something like that.) We can't use 165 bits per block, but have to
-lower it again, to 6/8 of the available buffer space: We end up with 124 bits
-per block, the equivalence of -q24. With 128kB buffers, you can't use greater
+This gives us a data rate of 165 bits per block, which, times 3168, sums up
+to 65340 bytes per field, out of the allowed 65536. The current driver has
+another level of rate limiting; it won't accept -q values that fill more than
+6/8 of the specified buffers. (I'm not sure why. "Playing it safe" seem to be
+a safe bet. Personally, I think I would have lowered requested-bits-per-block
+by one, or something like that.) We can't use 165 bits per block, but have to
+lower it again, to 6/8 of the available buffer space: We end up with 124 bits
+per block, the equivalence of -q24. With 128kB buffers, you can't use greater
than -q24 at -d1. (And PAL, and 704 pixels width...)
-The third example is limited to -q24 through the same process. The second
-example, using very similar calculations, is limited to -q48. The only
-example that actually grab at the specified -q value is the last one, which
+The third example is limited to -q24 through the same process. The second
+example, using very similar calculations, is limited to -q48. The only
+example that actually grab at the specified -q value is the last one, which
is clearly visible, looking at the file size.
--
diff --git a/Documentation/video4linux/bttv/ICs b/Documentation/video4linux/bttv/ICs
index 6b749133696..611315f87c3 100644
--- a/Documentation/video4linux/bttv/ICs
+++ b/Documentation/video4linux/bttv/ICs
@@ -14,13 +14,13 @@ Hauppauge Win/TV pci (version 405):
Microchip 24LC02B or
Philips 8582E2Y: 256 Byte EEPROM with configuration information
- I2C 0xa0-0xa1, (24LC02B also responds to 0xa2-0xaf)
+ I2C 0xa0-0xa1, (24LC02B also responds to 0xa2-0xaf)
Philips SAA5246AGP/E: Videotext decoder chip, I2C 0x22-0x23
TDA9800: sound decoder
Winbond W24257AS-35: 32Kx8 CMOS static RAM (Videotext buffer mem)
14052B: analog switch for selection of sound source
-PAL:
+PAL:
TDA5737: VHF, hyperband and UHF mixer/oscillator for TV and VCR 3-band tuners
TSA5522: 1.4 GHz I2C-bus controlled synthesizer, I2C 0xc2-0xc3
diff --git a/Documentation/video4linux/bttv/PROBLEMS b/Documentation/video4linux/bttv/PROBLEMS
index 8e31e9e36bf..2b8b0079f7c 100644
--- a/Documentation/video4linux/bttv/PROBLEMS
+++ b/Documentation/video4linux/bttv/PROBLEMS
@@ -3,7 +3,7 @@
- Start capturing by pressing "c" or by selecting it via a menu!!!
- The memory of some S3 cards is not recognized right:
-
+
First of all, if you are not using XFree-3.2 or newer, upgrade AT LEAST to
XFree-3.2A! This solved the problem for most people.
@@ -31,23 +31,23 @@
(mostly with Trio 64 but also with some others)
Get the free demo version of Accelerated X from www.xinside.com and try
bttv with it. bttv seems to work with most S3 cards with Accelerated X.
-
+
Since I do not know much (better make that almost nothing) about VGA card
programming I do not know the reason for this.
Looks like XFree does something different when setting up the video memory?
- Maybe somebody can enlighten me?
- Would be nice if somebody could get this to work with XFree since
- Accelerated X costs more than some of the grabber cards ...
-
+ Maybe somebody can enlighten me?
+ Would be nice if somebody could get this to work with XFree since
+ Accelerated X costs more than some of the grabber cards ...
+
Better linear frame buffer support for S3 cards will probably be in
XFree 4.0.
-
+
- Grabbing is not switched off when changing consoles with XFree.
That's because XFree and some AcceleratedX versions do not send unmap
events.
- Some popup windows (e.g. of the window manager) are not refreshed.
-
+
Disable backing store by starting X with the option "-bs"
- When using 32 bpp in XFree or 24+8bpp mode in AccelX 3.1 the system
diff --git a/Documentation/video4linux/bttv/README.quirks b/Documentation/video4linux/bttv/README.quirks
index e8edb87df71..92e03929a6b 100644
--- a/Documentation/video4linux/bttv/README.quirks
+++ b/Documentation/video4linux/bttv/README.quirks
@@ -38,9 +38,9 @@ tolerate.
------------------------
When using the 430FX PCI, the following rules will ensure
-compatibility:
+compatibility:
- (1) Deassert REQ at the same time as asserting FRAME.
+ (1) Deassert REQ at the same time as asserting FRAME.
(2) Do not reassert REQ to request another bus transaction until after
finish-ing the previous transaction.
diff --git a/Documentation/video4linux/bttv/THANKS b/Documentation/video4linux/bttv/THANKS
index 2085399da7d..950aa781c2e 100644
--- a/Documentation/video4linux/bttv/THANKS
+++ b/Documentation/video4linux/bttv/THANKS
@@ -1,6 +1,6 @@
Many thanks to:
-- Markus Schroeder <schroedm@uni-duesseldorf.de> for information on the Bt848
+- Markus Schroeder <schroedm@uni-duesseldorf.de> for information on the Bt848
and tuner programming and his control program xtvc.
- Martin Buck <martin-2.buck@student.uni-ulm.de> for his great Videotext
@@ -16,7 +16,7 @@ Many thanks to:
- MIRO for providing a free PCTV card and detailed information about the
components on their cards. (E.g. how the tuner type is detected)
Without their card I could not have debugged the NTSC mode.
-
+
- Hauppauge for telling how the sound input is selected and what components
they do and will use on their radio cards.
Also many thanks for faxing me the FM1216 data sheet.
diff --git a/Documentation/video4linux/radiotrack.txt b/Documentation/video4linux/radiotrack.txt
index 2b75345f13e..d1f3ed19918 100644
--- a/Documentation/video4linux/radiotrack.txt
+++ b/Documentation/video4linux/radiotrack.txt
@@ -131,17 +131,17 @@ Check Stereo: BASE <-- 0xd8 (current volume, stereo detect,
x=0xff ==> "not stereo", x=0xfd ==> "stereo detected"
Set Frequency: code = (freq*40) + 10486188
- foreach of the 24 bits in code,
- (from Least to Most Significant):
- to write a "zero" bit,
- BASE <-- 0x01 (audio mute, no stereo detect, radio
+ foreach of the 24 bits in code,
+ (from Least to Most Significant):
+ to write a "zero" bit,
+ BASE <-- 0x01 (audio mute, no stereo detect, radio
disable, "zero" bit phase 1, tuner adjust)
- BASE <-- 0x03 (audio mute, no stereo detect, radio
+ BASE <-- 0x03 (audio mute, no stereo detect, radio
disable, "zero" bit phase 2, tuner adjust)
- to write a "one" bit,
- BASE <-- 0x05 (audio mute, no stereo detect, radio
+ to write a "one" bit,
+ BASE <-- 0x05 (audio mute, no stereo detect, radio
disable, "one" bit phase 1, tuner adjust)
- BASE <-- 0x07 (audio mute, no stereo detect, radio
+ BASE <-- 0x07 (audio mute, no stereo detect, radio
disable, "one" bit phase 2, tuner adjust)
----------------------------------------------------------------------------
diff --git a/Documentation/video4linux/w9966.txt b/Documentation/video4linux/w9966.txt
index e7ac33a7eb0..78a651254b8 100644
--- a/Documentation/video4linux/w9966.txt
+++ b/Documentation/video4linux/w9966.txt
@@ -26,7 +26,7 @@ is called VIDEO_PALETTE_YUV422 (16 bpp).
A minimal test application (with source) is available from:
http://hem.fyristorg.com/mogul/w9966.html
-The slow framerate is due to missing DMA ECP read support in the
+The slow framerate is due to missing DMA ECP read support in the
parport drivers. I might add working EPP support later.
Good luck!
diff --git a/Documentation/video4linux/zr36120.txt b/Documentation/video4linux/zr36120.txt
index 5d6357eefde..ac6d92d0194 100644
--- a/Documentation/video4linux/zr36120.txt
+++ b/Documentation/video4linux/zr36120.txt
@@ -2,7 +2,7 @@ Driver for Trust Computer Products Framegrabber, version 0.6.1
------ --- ----- -------- -------- ------------ ------- - - -
- ZORAN ------------------------------------------------------
- Author: Pauline Middelink <middelin@polyware.nl>
+ Author: Pauline Middelink <middelin@polyware.nl>
Date: 18 September 1999
Version: 0.6.1
@@ -115,7 +115,7 @@ After making/checking the devices do:
<n> is the cardtype of the card you have. The cardnumber can
be found in the source of zr36120. Look for tvcards. If your
card is not there, please try if any other card gives some
-response, and mail me if you got a working tvcard addition.
+response, and mail me if you got a working tvcard addition.
PS. <TVCard editors behold!)
Dont forget to set video_input to the number of inputs
diff --git a/Documentation/w1/masters/ds2482 b/Documentation/w1/masters/ds2482
new file mode 100644
index 00000000000..c5d5478d90b
--- /dev/null
+++ b/Documentation/w1/masters/ds2482
@@ -0,0 +1,31 @@
+Kernel driver ds2482
+====================
+
+Supported chips:
+ * Maxim DS2482-100, Maxim DS2482-800
+ Prefix: 'ds2482'
+ Addresses scanned: None
+ Datasheets:
+ http://pdfserv.maxim-ic.com/en/ds/DS2482-100-DS2482S-100.pdf
+ http://pdfserv.maxim-ic.com/en/ds/DS2482-800-DS2482S-800.pdf
+
+Author: Ben Gardner <bgardner@wabtec.com>
+
+
+Description
+-----------
+
+The Maixm/Dallas Semiconductor DS2482 is a I2C device that provides
+one (DS2482-100) or eight (DS2482-800) 1-wire busses.
+
+
+General Remarks
+---------------
+
+Valid addresses are 0x18, 0x19, 0x1a, and 0x1b.
+However, the device cannot be detected without writing to the i2c bus, so no
+detection is done.
+You should force the device address.
+
+$ modprobe ds2482 force=0,0x18
+
diff --git a/MAINTAINERS b/MAINTAINERS
index dd1351dc32b..4e8fbbc5566 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -147,6 +147,18 @@ M: p_gortmaker@yahoo.com
L: netdev@vger.kernel.org
S: Maintained
+9P FILE SYSTEM
+P: Eric Van Hensbergen
+M: ericvh@gmail.com
+P: Ron Minnich
+M: rminnich@lanl.gov
+P: Latchesar Ionkov
+M: lucho@ionkov.net
+L: v9fs-developer@lists.sourceforge.net
+W: http://v9fs.sf.net
+T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs.git
+S: Maintained
+
A2232 SERIAL BOARD DRIVER
P: Enver Haase
M: ehaase@inf.fu-berlin.de
@@ -534,7 +546,7 @@ S: Supported
BROADBAND PROCESSOR ARCHITECTURE
P: Arnd Bergmann
M: arnd@arndb.de
-L: linuxppc64-dev@ozlabs.org
+L: linuxppc-dev@ozlabs.org
W: http://linuxppc64.org
S: Supported
@@ -1624,7 +1636,7 @@ P: Anton Blanchard
M: anton@samba.org
M: anton@au.ibm.com
W: http://linuxppc64.org
-L: linuxppc64-dev@ozlabs.org
+L: linuxppc-dev@ozlabs.org
S: Supported
LINUX SECURITY MODULE (LSM) FRAMEWORK
@@ -2013,12 +2025,6 @@ L: parisc-linux@parisc-linux.org
W: http://www.parisc-linux.org/
S: Maintained
-PERSONALITY HANDLING
-P: Christoph Hellwig
-M: hch@infradead.org
-L: linux-abi-devel@lists.sourceforge.net
-S: Maintained
-
PCI ERROR RECOVERY
P: Linas Vepstas
M: linas@austin.ibm.com
@@ -2069,6 +2075,12 @@ M: tsbogend@alpha.franken.de
L: netdev@vger.kernel.org
S: Maintained
+PERSONALITY HANDLING
+P: Christoph Hellwig
+M: hch@infradead.org
+L: linux-abi-devel@lists.sourceforge.net
+S: Maintained
+
PHRAM MTD DRIVER
P: Jörn Engel
M: joern@wh.fh-wedel.de
@@ -2212,13 +2224,6 @@ S: Maintained
RISCOM8 DRIVER
S: Orphan
-RTLINUX REALTIME LINUX
-P: Victor Yodaiken
-M: yodaiken@fsmlabs.com
-L: rtl@rtlinux.org
-W: www.rtlinux.org
-S: Maintained
-
S3 SAVAGE FRAMEBUFFER DRIVER
P: Antonino Daplas
M: adaplas@pol.net
@@ -2488,6 +2493,13 @@ M: kristen.c.accardi@intel.com
L: pcihpd-discuss@lists.sourceforge.net
S: Maintained
+SECURE DIGITAL HOST CONTROLLER INTERFACE DRIVER
+P: Pierre Ossman
+M: drzeus-sdhci@drzeus.cx
+L: sdhci-devel@list.drzeus.cx
+W: http://mmc.drzeus.cx/wiki/Linux/Drivers/sdhci
+S: Maintained
+
SKGE, SKY2 10/100/1000 GIGABIT ETHERNET DRIVERS
P: Stephen Hemminger
M: shemminger@osdl.org
@@ -2524,7 +2536,6 @@ S: Unsupported ?
STRADIS MPEG-2 DECODER DRIVER
P: Nathan Laredo
M: laredo@gnu.org
-W: http://mpeg.openprojects.net/
W: http://www.stradis.com/
S: Maintained
@@ -2643,7 +2654,7 @@ S: Maintained
TUN/TAP driver
P: Maxim Krasnyansky
-M: maxk@qualcomm.com, max_mk@yahoo.com
+M: maxk@qualcomm.com
L: vtun@office.satix.net
W: http://vtun.sourceforge.net/tun
S: Maintained
@@ -2972,18 +2983,6 @@ L: rio500-users@lists.sourceforge.net
W: http://rio500.sourceforge.net
S: Maintained
-V9FS FILE SYSTEM
-P: Eric Van Hensbergen
-M: ericvh@gmail.com
-P: Ron Minnich
-M: rminnich@lanl.gov
-P: Latchesar Ionkov
-M: lucho@ionkov.net
-L: v9fs-developer@lists.sourceforge.net
-W: http://v9fs.sf.net
-T: git kernel.org:/pub/scm/linux/kernel/ericvh/v9fs-devel.git
-S: Maintained
-
VIDEO FOR LINUX
P: Mauro Carvalho Chehab
M: mchehab@infradead.org
diff --git a/Makefile b/Makefile
index cb5790580fc..7bc2f4ad809 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ ifdef O
endif
# That's our default target when none is given on the command line
-.PHONY: _all
+PHONY := _all
_all:
ifneq ($(KBUILD_OUTPUT),)
@@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
$(if $(KBUILD_OUTPUT),, \
$(error output directory "$(saved-output)" does not exist))
-.PHONY: $(MAKECMDGOALS)
+PHONY += $(MAKECMDGOALS)
$(filter-out _all,$(MAKECMDGOALS)) _all:
$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@@ -123,7 +123,7 @@ ifeq ($(skip-makefile),)
# If building an external module we do not care about the all: rule
# but instead _all depend on modules
-.PHONY: all
+PHONY += all
ifeq ($(KBUILD_EXTMOD),)
_all: all
else
@@ -137,7 +137,7 @@ objtree := $(CURDIR)
src := $(srctree)
obj := $(objtree)
-VPATH := $(srctree)
+VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH TOPDIR
@@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
- -e s/ppc.*/powerpc/ )
+ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
@@ -258,38 +258,6 @@ endif
export quiet Q KBUILD_VERBOSE
-######
-# cc support functions to be used (only) in arch/$(ARCH)/Makefile
-# See documentation in Documentation/kbuild/makefiles.txt
-
-# as-option
-# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
-
-as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
- -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
- else echo "$(2)"; fi ;)
-
-# cc-option
-# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
-
-cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
- > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
-
-# cc-option-yn
-# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
-cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
- > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
-
-# cc-option-align
-# Prefix align with either -falign or -malign
-cc-option-align = $(subst -functions=0,,\
- $(call cc-option,-falign-functions=0,-malign-functions=0))
-
-# cc-version
-# Usage gcc-ver := $(call cc-version $(CC))
-cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
- $(if $(1), $(1), $(CC)))
-
# Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
@@ -369,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
# Rules shared between *config targets and build targets
# Basic helpers built in scripts/
-.PHONY: scripts_basic
+PHONY += scripts_basic
scripts_basic:
$(Q)$(MAKE) $(build)=scripts/basic
# To avoid any implicit rule to kick in, define an empty command.
scripts/basic/%: scripts_basic ;
-.PHONY: outputmakefile
+PHONY += outputmakefile
# outputmakefile generate a Makefile to be placed in output directory, if
# using a seperate output directory. This allows convinient use
# of make in output directory
@@ -452,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),)
# Additional helpers built in scripts/
# Carefully list dependencies so we do not try to build scripts twice
# in parrallel
-.PHONY: scripts
+PHONY += scripts
scripts: scripts_basic include/config/MARKER
$(Q)$(MAKE) $(build)=$(@)
@@ -504,19 +472,16 @@ else
CFLAGS += -O2
endif
-#Add align options if CONFIG_CC_* is not equal to 0
-add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1)))
-CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions)
-CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels)
-CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
-CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
-
ifdef CONFIG_FRAME_POINTER
CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
else
CFLAGS += -fomit-frame-pointer
endif
+ifdef CONFIG_UNWIND_INFO
+CFLAGS += -fasynchronous-unwind-tables
+endif
+
ifdef CONFIG_DEBUG_INFO
CFLAGS += -g
endif
@@ -752,7 +717,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
# make menuconfig etc.
# Error messages still appears in the original language
-.PHONY: $(vmlinux-dirs)
+PHONY += $(vmlinux-dirs)
$(vmlinux-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@
@@ -805,10 +770,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full)
# version.h and scripts_basic is processed / created.
# Listed in dependency order
-.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3
+PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
# prepare-all is deprecated, use prepare as valid replacement
-.PHONY: prepare-all
+PHONY += prepare-all
# prepare3 is used to check if we are building in a separate output directory,
# and if so do:
@@ -849,27 +814,6 @@ prepare prepare-all: prepare0
export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
-# Single targets
-# ---------------------------------------------------------------------------
-
-%.s: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.i: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.o: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.ko: scripts FORCE
- $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o)
- $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
-%/: scripts prepare FORCE
- $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
-%.lst: %.c scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.s: %.S scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-%.o: %.S scripts FORCE
- $(Q)$(MAKE) $(build)=$(@D) $@
-
# FIXME: The asm symlink changes when $(ARCH) changes. That's
# hard to detect, but I suppose "make mrproper" is a good idea
# before switching between archs anyway.
@@ -910,7 +854,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE
# ---------------------------------------------------------------------------
-.PHONY: depend dep
+PHONY += depend dep
depend dep:
@echo '*** Warning: make $@ is unnecessary now.'
@@ -925,21 +869,21 @@ all: modules
# Build modules
-.PHONY: modules
+PHONY += modules
modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
@echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
# Target to prepare building external modules
-.PHONY: modules_prepare
+PHONY += modules_prepare
modules_prepare: prepare scripts
# Target to install modules
-.PHONY: modules_install
+PHONY += modules_install
modules_install: _modinst_ _modinst_post
-.PHONY: _modinst_
+PHONY += _modinst_
_modinst_:
@if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
echo "Warning: you may need to install module-init-tools"; \
@@ -966,7 +910,7 @@ depmod_opts :=
else
depmod_opts := -b $(INSTALL_MOD_PATH) -r
endif
-.PHONY: _modinst_post
+PHONY += _modinst_post
_modinst_post: _modinst_
if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
@@ -1009,7 +953,7 @@ clean: rm-dirs := $(CLEAN_DIRS)
clean: rm-files := $(CLEAN_FILES)
clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
-.PHONY: $(clean-dirs) clean archclean
+PHONY += $(clean-dirs) clean archclean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
@@ -1027,7 +971,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
-.PHONY: $(mrproper-dirs) mrproper archmrproper
+PHONY += $(mrproper-dirs) mrproper archmrproper
$(mrproper-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
@@ -1037,7 +981,7 @@ mrproper: clean archmrproper $(mrproper-dirs)
# distclean
#
-.PHONY: distclean
+PHONY += distclean
distclean: mrproper
@find $(srctree) $(RCS_FIND_IGNORE) \
@@ -1053,12 +997,10 @@ distclean: mrproper
# rpm target kept for backward compatibility
package-dir := $(srctree)/scripts/package
-.PHONY: %-pkg rpm
-
%pkg: FORCE
- $(Q)$(MAKE) -f $(package-dir)/Makefile $@
+ $(Q)$(MAKE) $(build)=$(package-dir) $@
rpm: FORCE
- $(Q)$(MAKE) -f $(package-dir)/Makefile $@
+ $(Q)$(MAKE) $(build)=$(package-dir) $@
# Brief documentation of the typical targets used
@@ -1090,13 +1032,11 @@ help:
@echo ' kernelversion - Output the version stored in Makefile'
@echo ''
@echo 'Static analysers'
- @echo ' buildcheck - List dangling references to vmlinux discarded sections'
- @echo ' and init sections from non-init sections'
@echo ' checkstack - Generate a list of stack hogs'
@echo ' namespacecheck - Name space analysis on compiled kernel'
@echo ''
@echo 'Kernel packaging:'
- @$(MAKE) -f $(package-dir)/Makefile help
+ @$(MAKE) $(build)=$(package-dir) help
@echo ''
@echo 'Documentation targets:'
@$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
@@ -1145,11 +1085,12 @@ else # KBUILD_EXTMOD
# We are always building modules
KBUILD_MODULES := 1
-.PHONY: crmodverdir
+PHONY += crmodverdir
crmodverdir:
+ $(Q)rm -rf $(MODVERDIR)
$(Q)mkdir -p $(MODVERDIR)
-.PHONY: $(objtree)/Module.symvers
+PHONY += $(objtree)/Module.symvers
$(objtree)/Module.symvers:
@test -e $(objtree)/Module.symvers || ( \
echo; \
@@ -1158,7 +1099,7 @@ $(objtree)/Module.symvers:
echo )
module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
-.PHONY: $(module-dirs) modules
+PHONY += $(module-dirs) modules
$(module-dirs): crmodverdir $(objtree)/Module.symvers
$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
@@ -1166,13 +1107,32 @@ modules: $(module-dirs)
@echo ' Building modules, stage 2.';
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
-.PHONY: modules_install
-modules_install:
+PHONY += modules_install
+modules_install: _emodinst_ _emodinst_post
+
+install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
+PHONY += _emodinst_
+_emodinst_:
+ $(Q)rm -rf $(MODLIB)/$(install-dir)
+ $(Q)mkdir -p $(MODLIB)/$(install-dir)
$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
+# Run depmod only is we have System.map and depmod is executable
+quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
+ cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
+ $(DEPMOD) -ae -F System.map \
+ $(if $(strip $(INSTALL_MOD_PATH)), \
+ -b $(INSTALL_MOD_PATH) -r) \
+ $(KERNELRELEASE); \
+ fi
+
+PHONY += _emodinst_post
+_emodinst_post: _emodinst_
+ $(call cmd,depmod)
+
clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
-.PHONY: $(clean-dirs) clean
+PHONY += $(clean-dirs) clean
$(clean-dirs):
$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
@@ -1192,6 +1152,11 @@ help:
@echo ' modules_install - install the module'
@echo ' clean - remove generated files in module directory only'
@echo ''
+
+# Dummies...
+PHONY += prepare scripts
+prepare: ;
+scripts: ;
endif # KBUILD_EXTMOD
# Generate tags for editors
@@ -1292,17 +1257,13 @@ versioncheck:
-name '*.[hcS]' -type f -print | sort \
| xargs $(PERL) -w scripts/checkversion.pl
-buildcheck:
- $(PERL) $(srctree)/scripts/reference_discarded.pl
- $(PERL) $(srctree)/scripts/reference_init.pl
-
namespacecheck:
$(PERL) $(srctree)/scripts/namespace.pl
endif #ifeq ($(config-targets),1)
endif #ifeq ($(mixed-targets),1)
-.PHONY: checkstack
+PHONY += checkstack
checkstack:
$(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
$(PERL) $(src)/scripts/checkstack.pl $(ARCH)
@@ -1313,6 +1274,44 @@ kernelrelease:
kernelversion:
@echo $(KERNELVERSION)
+# Single targets
+# ---------------------------------------------------------------------------
+# The directory part is taken from first prerequisite, so this
+# works even with external modules
+%.s: %.c prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+%.i: %.c prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+%.o: %.c prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+%.lst: %.c prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+%.s: %.S prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+%.o: %.S prepare scripts FORCE
+ $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
+
+# For external modules we shall include any directory of the target,
+# but usual case there is no directory part.
+# make M=`pwd` module.o => $(dir $@)=./
+# make M=`pwd` foo/module.o => $(dir $@)=foo/
+# make M=`pwd` / => $(dir $@)=/
+
+ifeq ($(KBUILD_EXTMOD),)
+ target-dir = $(@D)
+else
+ zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
+ target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
+endif
+
+/ %/: scripts prepare FORCE
+ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ $(build)=$(target-dir)
+%.ko: scripts FORCE
+ $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+ $(build)=$(target-dir) $(@:.ko=.o)
+ $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
+
# FIXME Should go into a make.lib or something
# ===========================================================================
@@ -1347,4 +1346,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
endif # skip-makefile
+PHONY += FORCE
FORCE:
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+.PHONY: $(PHONY)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 32ba00bd0a2..0dd24ebdf6a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -108,6 +108,13 @@ config ARCH_EBSA110
Ethernet interface, two PCMCIA sockets, two serial ports and a
parallel port.
+config ARCH_EP93XX
+ bool "EP93xx-based"
+ select ARM_AMBA
+ select ARM_VIC
+ help
+ This enables support for the Cirrus EP93xx series of CPUs.
+
config ARCH_FOOTBRIDGE
bool "FootBridge"
select FOOTBRIDGE
@@ -250,6 +257,8 @@ endchoice
source "arch/arm/mach-clps711x/Kconfig"
+source "arch/arm/mach-ep93xx/Kconfig"
+
source "arch/arm/mach-footbridge/Kconfig"
source "arch/arm/mach-integrator/Kconfig"
@@ -434,6 +443,13 @@ config NO_IDLE_HZ
Currently at least OMAP, PXA2xx and SA11x0 platforms are known
to have accurate timekeeping with dynamic tick.
+config HZ
+ int
+ default 128 if ARCH_L7200
+ default 200 if ARCH_EBSA110 || ARCH_S3C2410
+ default OMAP_32K_TIMER_HZ if ARCH_OMAP && OMAP_32K_TIMER
+ default 100
+
config AEABI
bool "Use the ARM EABI to compile the kernel"
help
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index fbfc14a56b9..99c0d323719 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -1,6 +1,9 @@
#
# arch/arm/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -105,6 +108,7 @@ endif
machine-$(CONFIG_ARCH_AAEC2000) := aaec2000
machine-$(CONFIG_ARCH_REALVIEW) := realview
machine-$(CONFIG_ARCH_AT91RM9200) := at91rm9200
+ machine-$(CONFIG_ARCH_EP93XX) := ep93xx
ifeq ($(CONFIG_ARCH_EBSA110),y)
# This is what happens if you forget the IOCS16 line.
@@ -176,7 +180,7 @@ endif
archprepare: maketools
-.PHONY: maketools FORCE
+PHONY += maketools FORCE
maketools: include/linux/version.h include/asm-arm/.arch FORCE
$(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index a174d63395e..ec9c400c7f8 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -1,6 +1,9 @@
#
# arch/arm/boot/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -73,7 +76,7 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
-.PHONY: initrd FORCE
+PHONY += initrd FORCE
initrd:
@test "$(INITRD_PHYS)" != "" || \
(echo This machine does not support INITRD; exit -1)
diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile
index 8e8879b6b3d..c394e305447 100644
--- a/arch/arm/boot/bootp/Makefile
+++ b/arch/arm/boot/bootp/Makefile
@@ -1,6 +1,9 @@
#
# linux/arch/arm/boot/bootp/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
LDFLAGS_bootp :=-p --no-undefined -X \
--defsym initrd_phys=$(INITRD_PHYS) \
@@ -21,4 +24,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE
$(obj)/initrd.o: $(INITRD) FORCE
-.PHONY: $(INITRD) FORCE
+PHONY += $(INITRD) FORCE
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index c81a2ff6b5b..847e3e6356c 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_SHARP_LOCOMO) += locomo.o
obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o
obj-$(CONFIG_SHARPSL_PM) += sharpsl_pm.o
obj-$(CONFIG_SHARP_SCOOP) += scoop.o
+obj-$(CONFIG_ARCH_IXP2000) += uengine.o
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index ad6c89a555b..7971d0dc689 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -5,7 +5,7 @@
* limited DMA windows. These functions utilize bounce buffers to
* copy data to/from buffers located outside the DMA region. This
* only works for systems in which DMA memory is at the bottom of
- * RAM and the remainder of memory is at the top an the DMA memory
+ * RAM, the remainder of memory is at the top and the DMA memory
* can be marked as ZONE_DMA. Anything beyond that such as discontigous
* DMA windows will require custom implementations that reserve memory
* areas at early bootup.
diff --git a/arch/arm/common/locomo.c b/arch/arm/common/locomo.c
index 23609400a8e..a7dc1370695 100644
--- a/arch/arm/common/locomo.c
+++ b/arch/arm/common/locomo.c
@@ -60,7 +60,7 @@ struct locomo {
unsigned long phys;
unsigned int irq;
spinlock_t lock;
- void *base;
+ void __iomem *base;
};
struct locomo_dev_info {
@@ -162,7 +162,7 @@ static void locomo_handler(unsigned int irq, struct irqdesc *desc,
{
int req, i;
struct irqdesc *d;
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
/* Acknowledge the parent IRQ */
desc->chip->ack(irq);
@@ -189,7 +189,7 @@ static void locomo_ack_irq(unsigned int irq)
static void locomo_mask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_ICR);
r &= ~(0x0010 << (irq - LOCOMO_IRQ_START));
@@ -198,7 +198,7 @@ static void locomo_mask_irq(unsigned int irq)
static void locomo_unmask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_ICR);
r |= (0x0010 << (irq - LOCOMO_IRQ_START));
@@ -215,7 +215,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc,
struct pt_regs *regs)
{
struct irqdesc *d;
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
if (locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC) & 0x0001) {
d = irq_desc + LOCOMO_IRQ_KEY_START;
@@ -225,7 +225,7 @@ static void locomo_key_handler(unsigned int irq, struct irqdesc *desc,
static void locomo_key_ack_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
r &= ~(0x0100 << (irq - LOCOMO_IRQ_KEY_START));
@@ -234,7 +234,7 @@ static void locomo_key_ack_irq(unsigned int irq)
static void locomo_key_mask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
r &= ~(0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -243,7 +243,7 @@ static void locomo_key_mask_irq(unsigned int irq)
static void locomo_key_unmask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_KEYBOARD + LOCOMO_KIC);
r |= (0x0010 << (irq - LOCOMO_IRQ_KEY_START));
@@ -261,7 +261,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc,
{
int req, i;
struct irqdesc *d;
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
req = locomo_readl(mapbase + LOCOMO_GIR) &
locomo_readl(mapbase + LOCOMO_GPD) &
@@ -280,7 +280,7 @@ static void locomo_gpio_handler(unsigned int irq, struct irqdesc *desc,
static void locomo_gpio_ack_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_GWE);
r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -297,7 +297,7 @@ static void locomo_gpio_ack_irq(unsigned int irq)
static void locomo_gpio_mask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_GIE);
r &= ~(0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -306,7 +306,7 @@ static void locomo_gpio_mask_irq(unsigned int irq)
static void locomo_gpio_unmask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_GIE);
r |= (0x0001 << (irq - LOCOMO_IRQ_GPIO_START));
@@ -323,7 +323,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc,
struct pt_regs *regs)
{
struct irqdesc *d;
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
if (locomo_readl(mapbase + LOCOMO_LTINT) & 0x0001) {
d = irq_desc + LOCOMO_IRQ_LT_START;
@@ -333,7 +333,7 @@ static void locomo_lt_handler(unsigned int irq, struct irqdesc *desc,
static void locomo_lt_ack_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_LTINT);
r &= ~(0x0100 << (irq - LOCOMO_IRQ_LT_START));
@@ -342,7 +342,7 @@ static void locomo_lt_ack_irq(unsigned int irq)
static void locomo_lt_mask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_LTINT);
r &= ~(0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -351,7 +351,7 @@ static void locomo_lt_mask_irq(unsigned int irq)
static void locomo_lt_unmask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_LTINT);
r |= (0x0010 << (irq - LOCOMO_IRQ_LT_START));
@@ -369,7 +369,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc,
{
int req, i;
struct irqdesc *d;
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
req = locomo_readl(mapbase + LOCOMO_SPIIR) & 0x000F;
if (req) {
@@ -386,7 +386,7 @@ static void locomo_spi_handler(unsigned int irq, struct irqdesc *desc,
static void locomo_spi_ack_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_SPIWE);
r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -403,7 +403,7 @@ static void locomo_spi_ack_irq(unsigned int irq)
static void locomo_spi_mask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_SPIIE);
r &= ~(0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -412,7 +412,7 @@ static void locomo_spi_mask_irq(unsigned int irq)
static void locomo_spi_unmask_irq(unsigned int irq)
{
- void *mapbase = get_irq_chipdata(irq);
+ void __iomem *mapbase = get_irq_chipdata(irq);
unsigned int r;
r = locomo_readl(mapbase + LOCOMO_SPIIE);
r |= (0x0001 << (irq - LOCOMO_IRQ_SPI_START));
@@ -428,7 +428,7 @@ static struct irqchip locomo_spi_chip = {
static void locomo_setup_irq(struct locomo *lchip)
{
int irq;
- void *irqbase = lchip->base;
+ void __iomem *irqbase = lchip->base;
/*
* Install handler for IRQ_LOCOMO_HW.
@@ -501,12 +501,11 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
struct locomo_dev *dev;
int ret;
- dev = kmalloc(sizeof(struct locomo_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto out;
}
- memset(dev, 0, sizeof(struct locomo_dev));
strncpy(dev->dev.bus_id,info->name,sizeof(dev->dev.bus_id));
/*
@@ -664,12 +663,10 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
unsigned long r;
int i, ret = -ENODEV;
- lchip = kmalloc(sizeof(struct locomo), GFP_KERNEL);
+ lchip = kzalloc(sizeof(struct locomo), GFP_KERNEL);
if (!lchip)
return -ENOMEM;
- memset(lchip, 0, sizeof(struct locomo));
-
spin_lock_init(&lchip->lock);
lchip->dev = me;
diff --git a/arch/arm/common/sa1111.c b/arch/arm/common/sa1111.c
index 93352f6097c..3f68db84e5e 100644
--- a/arch/arm/common/sa1111.c
+++ b/arch/arm/common/sa1111.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/dma-mapping.h>
+#include <linux/clk.h>
#include <asm/hardware.h>
#include <asm/mach-types.h>
@@ -36,10 +37,6 @@
#include <asm/hardware/sa1111.h>
-#ifdef CONFIG_ARCH_PXA
-#include <asm/arch/pxa-regs.h>
-#endif
-
extern void __init sa1110_mb_enable(void);
/*
@@ -51,6 +48,7 @@ extern void __init sa1110_mb_enable(void);
*/
struct sa1111 {
struct device *dev;
+ struct clk *clk;
unsigned long phys;
int irq;
spinlock_t lock;
@@ -451,19 +449,7 @@ static void sa1111_wake(struct sa1111 *sachip)
spin_lock_irqsave(&sachip->lock, flags);
-#ifdef CONFIG_ARCH_SA1100
- /*
- * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
- * (SA-1110 Developer's Manual, section 9.1.2.1)
- */
- GAFR |= GPIO_32_768kHz;
- GPDR |= GPIO_32_768kHz;
- TUCR = TUCR_3_6864MHz;
-#elif CONFIG_ARCH_PXA
- pxa_gpio_mode(GPIO11_3_6MHz_MD);
-#else
-#error missing clock setup
-#endif
+ clk_enable(sachip->clk);
/*
* Turn VCO on, and disable PLL Bypass.
@@ -555,12 +541,11 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
struct sa1111_dev *dev;
int ret;
- dev = kmalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto out;
}
- memset(dev, 0, sizeof(struct sa1111_dev));
snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
"%4.4lx", info->offset);
@@ -635,11 +620,15 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
unsigned int has_devs, val;
int i, ret = -ENODEV;
- sachip = kmalloc(sizeof(struct sa1111), GFP_KERNEL);
+ sachip = kzalloc(sizeof(struct sa1111), GFP_KERNEL);
if (!sachip)
return -ENOMEM;
- memset(sachip, 0, sizeof(struct sa1111));
+ sachip->clk = clk_get(me, "GPIO27_CLK");
+ if (!sachip->clk) {
+ ret = PTR_ERR(sachip->clk);
+ goto err_free;
+ }
spin_lock_init(&sachip->lock);
@@ -656,7 +645,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
sachip->base = ioremap(mem->start, PAGE_SIZE * 2);
if (!sachip->base) {
ret = -ENOMEM;
- goto out;
+ goto err_clkput;
}
/*
@@ -666,7 +655,7 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
if ((id & SKID_ID_MASK) != SKID_SA1111_ID) {
printk(KERN_DEBUG "SA1111 not detected: ID = %08lx\n", id);
ret = -ENODEV;
- goto unmap;
+ goto err_unmap;
}
printk(KERN_INFO "SA1111 Microprocessor Companion Chip: "
@@ -726,9 +715,11 @@ __sa1111_probe(struct device *me, struct resource *mem, int irq)
return 0;
- unmap:
+ err_unmap:
iounmap(sachip->base);
- out:
+ err_clkput:
+ clk_put(sachip->clk);
+ err_free:
kfree(sachip);
return ret;
}
@@ -751,6 +742,8 @@ static void __sa1111_remove(struct sa1111 *sachip)
sa1111_writel(0, irqbase + SA1111_WAKEEN0);
sa1111_writel(0, irqbase + SA1111_WAKEEN1);
+ clk_disable(sachip->clk);
+
if (sachip->irq != NO_IRQ) {
set_irq_chained_handler(sachip->irq, NULL);
set_irq_data(sachip->irq, NULL);
@@ -759,6 +752,7 @@ static void __sa1111_remove(struct sa1111 *sachip)
}
iounmap(sachip->base);
+ clk_put(sachip->clk);
kfree(sachip);
}
@@ -857,6 +851,8 @@ static int sa1111_suspend(struct platform_device *dev, pm_message_t state)
sa1111_writel(0, sachip->base + SA1111_SKPWM0);
sa1111_writel(0, sachip->base + SA1111_SKPWM1);
+ clk_disable(sachip->clk);
+
spin_unlock_irqrestore(&sachip->lock, flags);
return 0;
diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c
index a2dfe0b0f1e..5e830f444c6 100644
--- a/arch/arm/common/scoop.c
+++ b/arch/arm/common/scoop.c
@@ -132,12 +132,10 @@ int __init scoop_probe(struct platform_device *pdev)
if (!mem)
return -EINVAL;
- devptr = kmalloc(sizeof(struct scoop_dev), GFP_KERNEL);
-
+ devptr = kzalloc(sizeof(struct scoop_dev), GFP_KERNEL);
if (!devptr)
- return -ENOMEM;
+ return -ENOMEM;
- memset(devptr, 0, sizeof(struct scoop_dev));
spin_lock_init(&devptr->scoop_lock);
inf = pdev->dev.platform_data;
diff --git a/arch/arm/mach-ixp2000/uengine.c b/arch/arm/common/uengine.c
index ec4e007a22e..a1310b71004 100644
--- a/arch/arm/mach-ixp2000/uengine.c
+++ b/arch/arm/common/uengine.c
@@ -19,7 +19,7 @@
#include <linux/string.h>
#include <asm/hardware.h>
#include <asm/arch/ixp2000-regs.h>
-#include <asm/arch/uengine.h>
+#include <asm/hardware/uengine.h>
#include <asm/io.h>
#define USTORE_ADDRESS 0x000
diff --git a/arch/arm/common/vic.c b/arch/arm/common/vic.c
index a45ed1687a5..a19bc4a6196 100644
--- a/arch/arm/common/vic.c
+++ b/arch/arm/common/vic.c
@@ -22,22 +22,21 @@
#include <linux/list.h>
#include <asm/io.h>
-#include <asm/irq.h>
#include <asm/mach/irq.h>
#include <asm/hardware/vic.h>
-static void __iomem *vic_base;
-
static void vic_mask_irq(unsigned int irq)
{
- irq -= IRQ_VIC_START;
- writel(1 << irq, vic_base + VIC_INT_ENABLE_CLEAR);
+ void __iomem *base = get_irq_chipdata(irq);
+ irq &= 31;
+ writel(1 << irq, base + VIC_INT_ENABLE_CLEAR);
}
static void vic_unmask_irq(unsigned int irq)
{
- irq -= IRQ_VIC_START;
- writel(1 << irq, vic_base + VIC_INT_ENABLE);
+ void __iomem *base = get_irq_chipdata(irq);
+ irq &= 31;
+ writel(1 << irq, base + VIC_INT_ENABLE);
}
static struct irqchip vic_chip = {
@@ -46,43 +45,49 @@ static struct irqchip vic_chip = {
.unmask = vic_unmask_irq,
};
-void __init vic_init(void __iomem *base, u32 vic_sources)
+/**
+ * vic_init - initialise a vectored interrupt controller
+ * @base: iomem base address
+ * @irq_start: starting interrupt number, must be muliple of 32
+ * @vic_sources: bitmask of interrupt sources to allow
+ */
+void __init vic_init(void __iomem *base, unsigned int irq_start,
+ u32 vic_sources)
{
unsigned int i;
- vic_base = base;
-
/* Disable all interrupts initially. */
- writel(0, vic_base + VIC_INT_SELECT);
- writel(0, vic_base + VIC_INT_ENABLE);
- writel(~0, vic_base + VIC_INT_ENABLE_CLEAR);
- writel(0, vic_base + VIC_IRQ_STATUS);
- writel(0, vic_base + VIC_ITCR);
- writel(~0, vic_base + VIC_INT_SOFT_CLEAR);
+ writel(0, base + VIC_INT_SELECT);
+ writel(0, base + VIC_INT_ENABLE);
+ writel(~0, base + VIC_INT_ENABLE_CLEAR);
+ writel(0, base + VIC_IRQ_STATUS);
+ writel(0, base + VIC_ITCR);
+ writel(~0, base + VIC_INT_SOFT_CLEAR);
/*
* Make sure we clear all existing interrupts
*/
- writel(0, vic_base + VIC_VECT_ADDR);
+ writel(0, base + VIC_VECT_ADDR);
for (i = 0; i < 19; i++) {
unsigned int value;
- value = readl(vic_base + VIC_VECT_ADDR);
- writel(value, vic_base + VIC_VECT_ADDR);
+ value = readl(base + VIC_VECT_ADDR);
+ writel(value, base + VIC_VECT_ADDR);
}
for (i = 0; i < 16; i++) {
- void __iomem *reg = vic_base + VIC_VECT_CNTL0 + (i * 4);
+ void __iomem *reg = base + VIC_VECT_CNTL0 + (i * 4);
writel(VIC_VECT_CNTL_ENABLE | i, reg);
}
- writel(32, vic_base + VIC_DEF_VECT_ADDR);
+ writel(32, base + VIC_DEF_VECT_ADDR);
for (i = 0; i < 32; i++) {
- unsigned int irq = IRQ_VIC_START + i;
+ unsigned int irq = irq_start + i;
set_irq_chip(irq, &vic_chip);
+ set_irq_chipdata(irq, base);
if (vic_sources & (1 << i)) {
set_irq_handler(irq, do_level_IRQ);
diff --git a/arch/arm/configs/enp2611_defconfig b/arch/arm/configs/enp2611_defconfig
deleted file mode 100644
index 5fdaf3ce9d5..00000000000
--- a/arch/arm/configs/enp2611_defconfig
+++ /dev/null
@@ -1,974 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git13
-# Thu Nov 10 15:12:48 2005
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
-CONFIG_LOCALVERSION=""
-CONFIG_LOCALVERSION_AUTO=y
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-CONFIG_BSD_PROCESS_ACCT=y
-# CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
-# CONFIG_IKCONFIG is not set
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_PRINTK=y
-CONFIG_BUG=y
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
-# CONFIG_TINY_SHMEM is not set
-CONFIG_BASE_SMALL=0
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
-# CONFIG_DEFAULT_DEADLINE is not set
-# CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
-
-#
-# System Type
-#
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-# CONFIG_ARCH_IXP4XX is not set
-CONFIG_ARCH_IXP2000=y
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE is not set
-# CONFIG_ARCH_REALVIEW is not set
-# CONFIG_ARCH_IMX is not set
-# CONFIG_ARCH_H720X is not set
-# CONFIG_ARCH_AAEC2000 is not set
-CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
-
-#
-# Intel IXP2400/2800 Implementation Options
-#
-
-#
-# IXP2400/2800 Platforms
-#
-CONFIG_ARCH_ENP2611=y
-# CONFIG_ARCH_IXDP2400 is not set
-# CONFIG_ARCH_IXDP2800 is not set
-# CONFIG_ARCH_IXDP2401 is not set
-# CONFIG_ARCH_IXDP2801 is not set
-# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
-CONFIG_CPU_CACHE_VIVT=y
-CONFIG_CPU_TLB_V4WBI=y
-
-#
-# Processor Features
-#
-# CONFIG_ARM_THUMB is not set
-CONFIG_CPU_BIG_ENDIAN=y
-CONFIG_XSCALE_PMU=y
-
-#
-# Bus support
-#
-CONFIG_ISA_DMA_API=y
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_DEBUG is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
-# CONFIG_PCCARD is not set
-
-#
-# Kernel Features
-#
-# CONFIG_PREEMPT is not set
-# CONFIG_NO_IDLE_HZ is not set
-# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
-CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4096
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Boot options
-#
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_CMDLINE="console=ttyS0,57600 root=/dev/nfs ip=bootp mem=64M@0x0"
-# CONFIG_XIP_KERNEL is not set
-
-#
-# Floating point emulation
-#
-
-#
-# At least one emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-CONFIG_FPE_NWFPE_XP=y
-# CONFIG_FPE_FASTFPE is not set
-
-#
-# Userspace binary formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_ARTHUR is not set
-
-#
-# Power management options
-#
-# CONFIG_PM is not set
-
-#
-# Networking
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_BIC=y
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# DCCP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_DCCP is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_IEEE80211 is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-# CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
-CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
-CONFIG_MTD_REDBOOT_PARTS_READONLY=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-# CONFIG_RFD_FTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-CONFIG_MTD_CFI_UTIL=y
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_XIP is not set
-
-#
-# Mapping drivers for chip access
-#
-CONFIG_MTD_COMPLEX_MAPPINGS=y
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IXP2000=y
-# CONFIG_MTD_PCI is not set
-# CONFIG_MTD_PLATRAM is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# CONFIG_MTD_BLOCK2MTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# OneNAND Flash Device Drivers
-#
-# CONFIG_MTD_ONENAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# PHY device support
-#
-# CONFIG_PHYLIB is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_CASSINI is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_SMC91X is not set
-# CONFIG_DM9000 is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_VIA_VELOCITY is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_BNX2 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_CHELSIO_T1 is not set
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-CONFIG_WAN=y
-# CONFIG_DSCC4 is not set
-# CONFIG_LANMEDIA is not set
-# CONFIG_SYNCLINK_SYNCPPP is not set
-CONFIG_HDLC=y
-CONFIG_HDLC_RAW=y
-# CONFIG_HDLC_RAW_ETH is not set
-CONFIG_HDLC_CISCO=y
-CONFIG_HDLC_FR=y
-CONFIG_HDLC_PPP=y
-
-#
-# X.25/LAPB support is disabled
-#
-# CONFIG_PCI200SYN is not set
-# CONFIG_WANXL is not set
-# CONFIG_PC300 is not set
-# CONFIG_FARSYNC is not set
-CONFIG_DLCI=y
-CONFIG_DLCI_COUNT=24
-CONFIG_DLCI_MAX=8
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Hardware I/O ports
-#
-# CONFIG_SERIO is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=2
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_IXP2000_WATCHDOG=y
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_CHARDEV=y
-
-#
-# I2C Algorithms
-#
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_IXP2000=y
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_STUB is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-# CONFIG_I2C_PCA_ISA is not set
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_SENSORS_DS1337 is not set
-# CONFIG_SENSORS_DS1374 is not set
-CONFIG_SENSORS_EEPROM=y
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-# CONFIG_SENSORS_MAX6875 is not set
-# CONFIG_RTC_X1205_I2C is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Hardware Monitoring support
-#
-CONFIG_HWMON=y
-# CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ADM1025 is not set
-# CONFIG_SENSORS_ADM1026 is not set
-# CONFIG_SENSORS_ADM1031 is not set
-# CONFIG_SENSORS_ADM9240 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_ATXP1 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_FSCPOS is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_GL520SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM63 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM77 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM87 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_LM92 is not set
-# CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SIS5595 is not set
-# CONFIG_SENSORS_SMSC47M1 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83792D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-# CONFIG_SENSORS_W83627EHF is not set
-# CONFIG_HWMON_DEBUG_CHIP is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia Capabilities Port drivers
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-# CONFIG_USB is not set
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# MMC/SD Card support
-#
-# CONFIG_MMC is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-# CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-# CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_FUSE_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_JFFS2_FS_WRITEBUFFER=y
-# CONFIG_JFFS2_SUMMARY is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
-CONFIG_JFFS2_ZLIB=y
-CONFIG_JFFS2_RTIME=y
-# CONFIG_JFFS2_RUBIN is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V3_ACL is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_SCHEDSTATS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_KOBJECT is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_DEBUG_VM is not set
-CONFIG_FRAME_POINTER=y
-# CONFIG_RCU_TORTURE_TEST is not set
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Hardware crypto devices
-#
-
-#
-# Library routines
-#
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2800_defconfig b/arch/arm/configs/ep93xx_defconfig
index 4248123815e..8dcc8e8ec81 100644
--- a/arch/arm/configs/ixdp2800_defconfig
+++ b/arch/arm/configs/ep93xx_defconfig
@@ -1,11 +1,10 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git13
-# Thu Nov 10 15:14:56 2005
+# Linux kernel version: 2.6.16
+# Mon Mar 20 14:54:51 2006
#
CONFIG_ARM=y
CONFIG_MMU=y
-CONFIG_UID16=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
@@ -13,7 +12,6 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -25,38 +23,42 @@ CONFIG_LOCALVERSION_AUTO=y
CONFIG_SWAP=y
CONFIG_SYSVIPC=y
# CONFIG_POSIX_MQUEUE is not set
-CONFIG_BSD_PROCESS_ACCT=y
-# CONFIG_BSD_PROCESS_ACCT_V3 is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
CONFIG_SYSCTL=y
# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
-# CONFIG_IKCONFIG is not set
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
CONFIG_INITRAMFS_SOURCE=""
+CONFIG_UID16=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_EMBEDDED=y
CONFIG_KALLSYMS=y
# CONFIG_KALLSYMS_ALL is not set
# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
CONFIG_PRINTK=y
CONFIG_BUG=y
+CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SHMEM=y
CONFIG_CC_ALIGN_FUNCTIONS=0
CONFIG_CC_ALIGN_LABELS=0
CONFIG_CC_ALIGN_LOOPS=0
CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+CONFIG_OBSOLETE_INTERMODULE=y
#
# Loadable module support
#
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
+CONFIG_MODULE_FORCE_UNLOAD=y
CONFIG_OBSOLETE_MODPARM=y
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
@@ -70,14 +72,14 @@ CONFIG_KMOD=y
# IO Schedulers
#
CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
+# CONFIG_IOSCHED_AS is not set
CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
-# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_IOSCHED_CFQ is not set
+# CONFIG_DEFAULT_AS is not set
+CONFIG_DEFAULT_DEADLINE=y
# CONFIG_DEFAULT_CFQ is not set
# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
+CONFIG_DEFAULT_IOSCHED="deadline"
#
# System Type
@@ -86,11 +88,12 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
# CONFIG_ARCH_CLPS711X is not set
# CONFIG_ARCH_CO285 is not set
# CONFIG_ARCH_EBSA110 is not set
+CONFIG_ARCH_EP93XX=y
# CONFIG_ARCH_FOOTBRIDGE is not set
# CONFIG_ARCH_INTEGRATOR is not set
# CONFIG_ARCH_IOP3XX is not set
# CONFIG_ARCH_IXP4XX is not set
-CONFIG_ARCH_IXP2000=y
+# CONFIG_ARCH_IXP2000 is not set
# CONFIG_ARCH_L7200 is not set
# CONFIG_ARCH_PXA is not set
# CONFIG_ARCH_RPC is not set
@@ -104,47 +107,44 @@ CONFIG_ARCH_IXP2000=y
# CONFIG_ARCH_IMX is not set
# CONFIG_ARCH_H720X is not set
# CONFIG_ARCH_AAEC2000 is not set
-CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
+# CONFIG_ARCH_AT91RM9200 is not set
#
-# Intel IXP2400/2800 Implementation Options
+# Cirrus EP93xx Implementation Options
#
+CONFIG_CRUNCH=y
#
-# IXP2400/2800 Platforms
+# EP93xx Platforms
#
-# CONFIG_ARCH_ENP2611 is not set
-# CONFIG_ARCH_IXDP2400 is not set
-CONFIG_ARCH_IXDP2800=y
-CONFIG_ARCH_IXDP2X00=y
-# CONFIG_ARCH_IXDP2401 is not set
-# CONFIG_ARCH_IXDP2801 is not set
-# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
+CONFIG_MACH_GESBC9312=y
+CONFIG_MACH_TS72XX=y
#
# Processor Type
#
CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
+CONFIG_CPU_ARM920T=y
+CONFIG_CPU_32v4=y
+CONFIG_CPU_ABRT_EV4T=y
+CONFIG_CPU_CACHE_V4WT=y
CONFIG_CPU_CACHE_VIVT=y
+CONFIG_CPU_COPY_V4WB=y
CONFIG_CPU_TLB_V4WBI=y
#
# Processor Features
#
-# CONFIG_ARM_THUMB is not set
-CONFIG_CPU_BIG_ENDIAN=y
-CONFIG_XSCALE_PMU=y
+CONFIG_ARM_THUMB=y
+# CONFIG_CPU_ICACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_DISABLE is not set
+# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
+CONFIG_ARM_VIC=y
#
# Bus support
#
-CONFIG_ISA_DMA_API=y
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_DEBUG is not set
+CONFIG_ARM_AMBA=y
#
# PCCARD (PCMCIA/CardBus) support
@@ -156,6 +156,8 @@ CONFIG_PCI_LEGACY_PROC=y
#
# CONFIG_PREEMPT is not set
# CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=100
+# CONFIG_AEABI is not set
# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
CONFIG_SELECT_MEMORY_MODEL=y
CONFIG_FLATMEM_MANUAL=y
@@ -172,7 +174,7 @@ CONFIG_ALIGNMENT_TRAP=y
#
CONFIG_ZBOOT_ROM_TEXT=0x0
CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_CMDLINE="console=ttyS0,9600 root=/dev/nfs ip=bootp mem=64M@0x0"
+CONFIG_CMDLINE="console=ttyAM0,115200 root=/dev/nfs ip=bootp"
# CONFIG_XIP_KERNEL is not set
#
@@ -198,6 +200,7 @@ CONFIG_BINFMT_ELF=y
# Power management options
#
# CONFIG_PM is not set
+# CONFIG_APM is not set
#
# Networking
@@ -207,10 +210,13 @@ CONFIG_NET=y
#
# Networking options
#
+# CONFIG_NETDEBUG is not set
CONFIG_PACKET=y
CONFIG_PACKET_MMAP=y
CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
+CONFIG_XFRM=y
+# CONFIG_XFRM_USER is not set
+CONFIG_NET_KEY=y
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
# CONFIG_IP_ADVANCED_ROUTER is not set
@@ -243,6 +249,11 @@ CONFIG_TCP_CONG_BIC=y
# SCTP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
# CONFIG_ATM is not set
# CONFIG_BRIDGE is not set
# CONFIG_VLAN_8021Q is not set
@@ -260,7 +271,6 @@ CONFIG_TCP_CONG_BIC=y
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
#
# Network testing
@@ -279,21 +289,26 @@ CONFIG_TCP_CONG_BIC=y
# Generic Driver Options
#
CONFIG_STANDALONE=y
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
+CONFIG_PREVENT_FIRMWARE_BUILD=y
# CONFIG_FW_LOADER is not set
# CONFIG_DEBUG_DRIVER is not set
#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
# Memory Technology Devices (MTD)
#
CONFIG_MTD=y
# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_CONCAT is not set
+CONFIG_MTD_CONCAT=y
CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_REDBOOT_PARTS=y
CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
-CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
-CONFIG_MTD_REDBOOT_PARTS_READONLY=y
+# CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED is not set
+# CONFIG_MTD_REDBOOT_PARTS_READONLY is not set
# CONFIG_MTD_CMDLINE_PARTS is not set
# CONFIG_MTD_AFS_PARTS is not set
@@ -313,7 +328,11 @@ CONFIG_MTD_BLOCK=y
CONFIG_MTD_CFI=y
# CONFIG_MTD_JEDECPROBE is not set
CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
+CONFIG_MTD_CFI_ADV_OPTIONS=y
+CONFIG_MTD_CFI_NOSWAP=y
+# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
+# CONFIG_MTD_CFI_GEOMETRY is not set
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
@@ -324,29 +343,31 @@ CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
# CONFIG_MTD_CFI_I4 is not set
# CONFIG_MTD_CFI_I8 is not set
+# CONFIG_MTD_OTP is not set
CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_AMDSTD_RETRY=0
+CONFIG_MTD_CFI_STAA=y
CONFIG_MTD_CFI_UTIL=y
# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
+CONFIG_MTD_ROM=y
# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_XIP is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
#
# Mapping drivers for chip access
#
-CONFIG_MTD_COMPLEX_MAPPINGS=y
-# CONFIG_MTD_PHYSMAP is not set
+# CONFIG_MTD_COMPLEX_MAPPINGS is not set
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_START=0x0
+CONFIG_MTD_PHYSMAP_LEN=0x0
+CONFIG_MTD_PHYSMAP_BANKWIDTH=1
# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IXP2000=y
-# CONFIG_MTD_PCI is not set
# CONFIG_MTD_PLATRAM is not set
#
# Self-contained MTD device drivers
#
-# CONFIG_MTD_PMC551 is not set
# CONFIG_MTD_SLRAM is not set
# CONFIG_MTD_PHRAM is not set
# CONFIG_MTD_MTDRAM is not set
@@ -363,7 +384,11 @@ CONFIG_MTD_IXP2000=y
#
# NAND Flash Device Drivers
#
-# CONFIG_MTD_NAND is not set
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_VERIFY_WRITE=y
+CONFIG_MTD_NAND_IDS=y
+# CONFIG_MTD_NAND_DISKONCHIP is not set
+# CONFIG_MTD_NAND_NANDSIM is not set
#
# OneNAND Flash Device Drivers
@@ -382,19 +407,12 @@ CONFIG_MTD_IXP2000=y
#
# Block devices
#
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_LOOP is not set
# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
+# CONFIG_BLK_DEV_UB is not set
+# CONFIG_BLK_DEV_RAM is not set
CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
# CONFIG_CDROM_PKTCDVD is not set
# CONFIG_ATA_OVER_ETH is not set
@@ -402,7 +420,40 @@ CONFIG_BLK_DEV_INITRD=y
# SCSI device support
#
# CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
+CONFIG_SCSI=y
+# CONFIG_SCSI_PROC_FS is not set
+
+#
+# SCSI support type (disk, tape, CD-ROM)
+#
+CONFIG_BLK_DEV_SD=y
+# CONFIG_CHR_DEV_ST is not set
+# CONFIG_CHR_DEV_OSST is not set
+# CONFIG_BLK_DEV_SR is not set
+# CONFIG_CHR_DEV_SG is not set
+# CONFIG_CHR_DEV_SCH is not set
+
+#
+# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
+#
+# CONFIG_SCSI_MULTI_LUN is not set
+# CONFIG_SCSI_CONSTANTS is not set
+# CONFIG_SCSI_LOGGING is not set
+
+#
+# SCSI Transport Attributes
+#
+# CONFIG_SCSI_SPI_ATTRS is not set
+# CONFIG_SCSI_FC_ATTRS is not set
+# CONFIG_SCSI_ISCSI_ATTRS is not set
+# CONFIG_SCSI_SAS_ATTRS is not set
+
+#
+# SCSI low-level drivers
+#
+# CONFIG_ISCSI_TCP is not set
+# CONFIG_SCSI_SATA is not set
+# CONFIG_SCSI_DEBUG is not set
#
# Multi-device support (RAID and LVM)
@@ -417,28 +468,21 @@ CONFIG_BLK_DEV_INITRD=y
#
# IEEE 1394 (FireWire) support
#
-# CONFIG_IEEE1394 is not set
#
# I2O device support
#
-# CONFIG_I2O is not set
#
# Network device support
#
CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
+# CONFIG_DUMMY is not set
# CONFIG_BONDING is not set
# CONFIG_EQUALIZER is not set
# CONFIG_TUN is not set
#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
# PHY device support
#
# CONFIG_PHYLIB is not set
@@ -448,66 +492,20 @@ CONFIG_DUMMY=y
#
CONFIG_NET_ETHERNET=y
CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_CASSINI is not set
-# CONFIG_NET_VENDOR_3COM is not set
# CONFIG_SMC91X is not set
# CONFIG_DM9000 is not set
#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
# Ethernet (1000 Mbit)
#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_VIA_VELOCITY is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_BNX2 is not set
#
# Ethernet (10000 Mbit)
#
-# CONFIG_CHELSIO_T1 is not set
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
#
# Token Ring devices
#
-# CONFIG_TR is not set
#
# Wireless LAN (non-hamradio)
@@ -517,29 +515,7 @@ CONFIG_EEPRO100=y
#
# Wan interfaces
#
-CONFIG_WAN=y
-# CONFIG_DSCC4 is not set
-# CONFIG_LANMEDIA is not set
-# CONFIG_SYNCLINK_SYNCPPP is not set
-CONFIG_HDLC=y
-CONFIG_HDLC_RAW=y
-# CONFIG_HDLC_RAW_ETH is not set
-CONFIG_HDLC_CISCO=y
-CONFIG_HDLC_FR=y
-CONFIG_HDLC_PPP=y
-
-#
-# X.25/LAPB support is disabled
-#
-# CONFIG_PCI200SYN is not set
-# CONFIG_WANXL is not set
-# CONFIG_PC300 is not set
-# CONFIG_FARSYNC is not set
-CONFIG_DLCI=y
-CONFIG_DLCI_COUNT=24
-CONFIG_DLCI_MAX=8
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
+# CONFIG_WAN is not set
# CONFIG_PPP is not set
# CONFIG_SLIP is not set
# CONFIG_SHAPER is not set
@@ -555,28 +531,7 @@ CONFIG_DLCI_MAX=8
#
# Input device support
#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
+# CONFIG_INPUT is not set
#
# Hardware I/O ports
@@ -593,20 +548,18 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
#
# Serial drivers
#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=1
-# CONFIG_SERIAL_8250_EXTENDED is not set
+# CONFIG_SERIAL_8250 is not set
#
# Non-8250 serial port support
#
+CONFIG_SERIAL_AMBA_PL010=y
+CONFIG_SERIAL_AMBA_PL010_CONSOLE=y
+# CONFIG_SERIAL_AMBA_PL011 is not set
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
+# CONFIG_LEGACY_PTYS is not set
#
# IPMI
@@ -623,23 +576,19 @@ CONFIG_WATCHDOG=y
# Watchdog Device Drivers
#
# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_IXP2000_WATCHDOG=y
#
-# PCI-based Watchdog Cards
+# USB-based Watchdog Cards
#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
+# CONFIG_USBPCWATCHDOG is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
# CONFIG_DTLK is not set
# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
#
# Ftape, the floppy tape device driver
#
-# CONFIG_DRM is not set
# CONFIG_RAW_DRIVER is not set
#
@@ -664,27 +613,8 @@ CONFIG_I2C_ALGOBIT=y
#
# I2C Hardware Bus support
#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_IXP2000=y
-# CONFIG_I2C_NFORCE2 is not set
# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
# CONFIG_I2C_STUB is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
# CONFIG_I2C_PCA_ISA is not set
#
@@ -692,17 +622,28 @@ CONFIG_I2C_IXP2000=y
#
# CONFIG_SENSORS_DS1337 is not set
# CONFIG_SENSORS_DS1374 is not set
-CONFIG_SENSORS_EEPROM=y
+# CONFIG_SENSORS_EEPROM is not set
# CONFIG_SENSORS_PCF8574 is not set
# CONFIG_SENSORS_PCA9539 is not set
# CONFIG_SENSORS_PCF8591 is not set
# CONFIG_SENSORS_RTC8564 is not set
# CONFIG_SENSORS_MAX6875 is not set
# CONFIG_RTC_X1205_I2C is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
+CONFIG_I2C_DEBUG_CORE=y
+CONFIG_I2C_DEBUG_ALGO=y
+CONFIG_I2C_DEBUG_BUS=y
+CONFIG_I2C_DEBUG_CHIP=y
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
#
# Hardware Monitoring support
@@ -717,6 +658,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_ASB100 is not set
# CONFIG_SENSORS_ATXP1 is not set
# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
# CONFIG_SENSORS_FSCHER is not set
# CONFIG_SENSORS_FSCPOS is not set
# CONFIG_SENSORS_GL518SM is not set
@@ -734,10 +676,8 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_LM92 is not set
# CONFIG_SENSORS_MAX1619 is not set
# CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SIS5595 is not set
# CONFIG_SENSORS_SMSC47M1 is not set
# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_VIA686A is not set
# CONFIG_SENSORS_W83781D is not set
# CONFIG_SENSORS_W83792D is not set
# CONFIG_SENSORS_W83L785TS is not set
@@ -777,14 +717,144 @@ CONFIG_HWMON=y
# USB support
#
CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-# CONFIG_USB is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+CONFIG_USB=y
+CONFIG_USB_DEBUG=y
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+CONFIG_USB_DYNAMIC_MINORS=y
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_ISP116X_HCD is not set
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
#
# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
#
#
+# may also be needed; see USB_STORAGE Help for more information
+#
+CONFIG_USB_STORAGE=y
+# CONFIG_USB_STORAGE_DEBUG is not set
+# CONFIG_USB_STORAGE_DATAFAB is not set
+# CONFIG_USB_STORAGE_FREECOM is not set
+# CONFIG_USB_STORAGE_DPCM is not set
+# CONFIG_USB_STORAGE_USBAT is not set
+# CONFIG_USB_STORAGE_SDDR09 is not set
+# CONFIG_USB_STORAGE_SDDR55 is not set
+# CONFIG_USB_STORAGE_JUMPSHOT is not set
+# CONFIG_USB_STORAGE_ALAUDA is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+# CONFIG_USB_MICROTEK is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+CONFIG_USB_RTL8150=y
+# CONFIG_USB_USBNET is not set
+# CONFIG_USB_MON is not set
+
+#
+# USB port drivers
+#
+
+#
+# USB Serial Converter support
+#
+CONFIG_USB_SERIAL=y
+CONFIG_USB_SERIAL_CONSOLE=y
+# CONFIG_USB_SERIAL_GENERIC is not set
+# CONFIG_USB_SERIAL_AIRPRIME is not set
+# CONFIG_USB_SERIAL_ANYDATA is not set
+# CONFIG_USB_SERIAL_BELKIN is not set
+# CONFIG_USB_SERIAL_WHITEHEAT is not set
+# CONFIG_USB_SERIAL_DIGI_ACCELEPORT is not set
+# CONFIG_USB_SERIAL_CP2101 is not set
+# CONFIG_USB_SERIAL_CYPRESS_M8 is not set
+# CONFIG_USB_SERIAL_EMPEG is not set
+# CONFIG_USB_SERIAL_FTDI_SIO is not set
+# CONFIG_USB_SERIAL_VISOR is not set
+# CONFIG_USB_SERIAL_IPAQ is not set
+# CONFIG_USB_SERIAL_IR is not set
+# CONFIG_USB_SERIAL_EDGEPORT is not set
+# CONFIG_USB_SERIAL_EDGEPORT_TI is not set
+# CONFIG_USB_SERIAL_GARMIN is not set
+# CONFIG_USB_SERIAL_IPW is not set
+# CONFIG_USB_SERIAL_KEYSPAN_PDA is not set
+# CONFIG_USB_SERIAL_KEYSPAN is not set
+# CONFIG_USB_SERIAL_KLSI is not set
+# CONFIG_USB_SERIAL_KOBIL_SCT is not set
+# CONFIG_USB_SERIAL_MCT_U232 is not set
+CONFIG_USB_SERIAL_PL2303=y
+# CONFIG_USB_SERIAL_HP4X is not set
+# CONFIG_USB_SERIAL_SAFE is not set
+# CONFIG_USB_SERIAL_TI is not set
+# CONFIG_USB_SERIAL_CYBERJACK is not set
+# CONFIG_USB_SERIAL_XIRCOM is not set
+# CONFIG_USB_SERIAL_OMNINET is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB DSL modem support
+#
+
+#
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set
@@ -798,21 +868,17 @@ CONFIG_USB_ARCH_HAS_OHCI=y
# File systems
#
CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
+# CONFIG_EXT2_FS_XATTR is not set
# CONFIG_EXT2_FS_XIP is not set
CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
+# CONFIG_EXT3_FS_XATTR is not set
CONFIG_JBD=y
# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
# CONFIG_REISERFS_FS is not set
# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
+# CONFIG_FS_POSIX_ACL is not set
# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_INOTIFY=y
@@ -831,8 +897,11 @@ CONFIG_DNOTIFY=y
#
# DOS/FAT/NT Filesystems
#
+CONFIG_FAT_FS=y
# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
# CONFIG_NTFS_FS is not set
#
@@ -844,6 +913,7 @@ CONFIG_TMPFS=y
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y
# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
#
# Miscellaneous filesystems
@@ -912,12 +982,52 @@ CONFIG_MSDOS_PARTITION=y
# CONFIG_SGI_PARTITION is not set
# CONFIG_ULTRIX_PARTITION is not set
# CONFIG_SUN_PARTITION is not set
+# CONFIG_KARMA_PARTITION is not set
# CONFIG_EFI_PARTITION is not set
#
# Native Language Support
#
-# CONFIG_NLS is not set
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+# CONFIG_NLS_ASCII is not set
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+# CONFIG_NLS_UTF8 is not set
#
# Profiling support
@@ -928,13 +1038,14 @@ CONFIG_MSDOS_PARTITION=y
# Kernel hacking
#
# CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_DETECT_SOFTLOCKUP=y
# CONFIG_SCHEDSTATS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
+CONFIG_DEBUG_SLAB=y
+CONFIG_DEBUG_MUTEXES=y
+CONFIG_DEBUG_SPINLOCK=y
# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
# CONFIG_DEBUG_KOBJECT is not set
CONFIG_DEBUG_BUGVERBOSE=y
@@ -942,9 +1053,10 @@ CONFIG_DEBUG_BUGVERBOSE=y
# CONFIG_DEBUG_FS is not set
# CONFIG_DEBUG_VM is not set
CONFIG_FRAME_POINTER=y
+CONFIG_FORCED_INLINING=y
# CONFIG_RCU_TORTURE_TEST is not set
CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
+CONFIG_DEBUG_WAITQ=y
CONFIG_DEBUG_ERRORS=y
CONFIG_DEBUG_LL=y
# CONFIG_DEBUG_ICEDCC is not set
@@ -970,6 +1082,6 @@ CONFIG_DEBUG_LL=y
# CONFIG_CRC_CCITT is not set
# CONFIG_CRC16 is not set
CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
+CONFIG_LIBCRC32C=y
CONFIG_ZLIB_INFLATE=y
CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2401_defconfig b/arch/arm/configs/ixdp2401_defconfig
deleted file mode 100644
index 60d66e82c51..00000000000
--- a/arch/arm/configs/ixdp2401_defconfig
+++ /dev/null
@@ -1,976 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git13
-# Thu Nov 10 15:14:50 2005
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
-CONFIG_LOCALVERSION=""
-CONFIG_LOCALVERSION_AUTO=y
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-CONFIG_BSD_PROCESS_ACCT=y
-# CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
-# CONFIG_IKCONFIG is not set
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_PRINTK=y
-CONFIG_BUG=y
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
-# CONFIG_TINY_SHMEM is not set
-CONFIG_BASE_SMALL=0
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
-# CONFIG_DEFAULT_DEADLINE is not set
-# CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
-
-#
-# System Type
-#
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-# CONFIG_ARCH_IXP4XX is not set
-CONFIG_ARCH_IXP2000=y
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE is not set
-# CONFIG_ARCH_REALVIEW is not set
-# CONFIG_ARCH_IMX is not set
-# CONFIG_ARCH_H720X is not set
-# CONFIG_ARCH_AAEC2000 is not set
-CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
-
-#
-# Intel IXP2400/2800 Implementation Options
-#
-
-#
-# IXP2400/2800 Platforms
-#
-# CONFIG_ARCH_ENP2611 is not set
-# CONFIG_ARCH_IXDP2400 is not set
-# CONFIG_ARCH_IXDP2800 is not set
-CONFIG_ARCH_IXDP2401=y
-# CONFIG_ARCH_IXDP2801 is not set
-CONFIG_ARCH_IXDP2X01=y
-# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
-CONFIG_CPU_CACHE_VIVT=y
-CONFIG_CPU_TLB_V4WBI=y
-
-#
-# Processor Features
-#
-# CONFIG_ARM_THUMB is not set
-CONFIG_CPU_BIG_ENDIAN=y
-CONFIG_XSCALE_PMU=y
-
-#
-# Bus support
-#
-CONFIG_ISA_DMA_API=y
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_DEBUG is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
-# CONFIG_PCCARD is not set
-
-#
-# Kernel Features
-#
-# CONFIG_PREEMPT is not set
-# CONFIG_NO_IDLE_HZ is not set
-# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
-CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4096
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Boot options
-#
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs ip=bootp mem=64M@0x0"
-# CONFIG_XIP_KERNEL is not set
-
-#
-# Floating point emulation
-#
-
-#
-# At least one emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-CONFIG_FPE_NWFPE_XP=y
-# CONFIG_FPE_FASTFPE is not set
-
-#
-# Userspace binary formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_ARTHUR is not set
-
-#
-# Power management options
-#
-# CONFIG_PM is not set
-
-#
-# Networking
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_BIC=y
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# DCCP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_DCCP is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_IEEE80211 is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-# CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
-CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
-CONFIG_MTD_REDBOOT_PARTS_READONLY=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-# CONFIG_RFD_FTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-CONFIG_MTD_CFI_UTIL=y
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_XIP is not set
-
-#
-# Mapping drivers for chip access
-#
-CONFIG_MTD_COMPLEX_MAPPINGS=y
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IXP2000=y
-# CONFIG_MTD_PCI is not set
-# CONFIG_MTD_PLATRAM is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# CONFIG_MTD_BLOCK2MTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# OneNAND Flash Device Drivers
-#
-# CONFIG_MTD_ONENAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# PHY device support
-#
-# CONFIG_PHYLIB is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_CASSINI is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_SMC91X is not set
-# CONFIG_DM9000 is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-CONFIG_CS89x0=y
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_VIA_VELOCITY is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_BNX2 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_CHELSIO_T1 is not set
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-CONFIG_WAN=y
-# CONFIG_DSCC4 is not set
-# CONFIG_LANMEDIA is not set
-# CONFIG_SYNCLINK_SYNCPPP is not set
-CONFIG_HDLC=y
-CONFIG_HDLC_RAW=y
-# CONFIG_HDLC_RAW_ETH is not set
-CONFIG_HDLC_CISCO=y
-CONFIG_HDLC_FR=y
-CONFIG_HDLC_PPP=y
-
-#
-# X.25/LAPB support is disabled
-#
-# CONFIG_PCI200SYN is not set
-# CONFIG_WANXL is not set
-# CONFIG_PC300 is not set
-# CONFIG_FARSYNC is not set
-CONFIG_DLCI=y
-CONFIG_DLCI_COUNT=24
-CONFIG_DLCI_MAX=8
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Hardware I/O ports
-#
-# CONFIG_SERIO is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=3
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_IXP2000_WATCHDOG=y
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_CHARDEV=y
-
-#
-# I2C Algorithms
-#
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_IXP2000=y
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_STUB is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-# CONFIG_I2C_PCA_ISA is not set
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_SENSORS_DS1337 is not set
-# CONFIG_SENSORS_DS1374 is not set
-CONFIG_SENSORS_EEPROM=y
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-# CONFIG_SENSORS_MAX6875 is not set
-# CONFIG_RTC_X1205_I2C is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Hardware Monitoring support
-#
-CONFIG_HWMON=y
-# CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ADM1025 is not set
-# CONFIG_SENSORS_ADM1026 is not set
-# CONFIG_SENSORS_ADM1031 is not set
-# CONFIG_SENSORS_ADM9240 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_ATXP1 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_FSCPOS is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_GL520SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM63 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM77 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM87 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_LM92 is not set
-# CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SIS5595 is not set
-# CONFIG_SENSORS_SMSC47M1 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83792D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-# CONFIG_SENSORS_W83627EHF is not set
-# CONFIG_HWMON_DEBUG_CHIP is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia Capabilities Port drivers
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-# CONFIG_USB is not set
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# MMC/SD Card support
-#
-# CONFIG_MMC is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-# CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-# CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_FUSE_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_JFFS2_FS_WRITEBUFFER=y
-# CONFIG_JFFS2_SUMMARY is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
-CONFIG_JFFS2_ZLIB=y
-CONFIG_JFFS2_RTIME=y
-# CONFIG_JFFS2_RUBIN is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V3_ACL is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_SCHEDSTATS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_KOBJECT is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_DEBUG_VM is not set
-CONFIG_FRAME_POINTER=y
-# CONFIG_RCU_TORTURE_TEST is not set
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Hardware crypto devices
-#
-
-#
-# Library routines
-#
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2801_defconfig b/arch/arm/configs/ixdp2801_defconfig
deleted file mode 100644
index f54f3dcc5b3..00000000000
--- a/arch/arm/configs/ixdp2801_defconfig
+++ /dev/null
@@ -1,976 +0,0 @@
-#
-# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git13
-# Thu Nov 10 15:15:03 2005
-#
-CONFIG_ARM=y
-CONFIG_MMU=y
-CONFIG_UID16=y
-CONFIG_RWSEM_GENERIC_SPINLOCK=y
-CONFIG_GENERIC_CALIBRATE_DELAY=y
-
-#
-# Code maturity level options
-#
-CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
-CONFIG_BROKEN_ON_SMP=y
-CONFIG_INIT_ENV_ARG_LIMIT=32
-
-#
-# General setup
-#
-CONFIG_LOCALVERSION=""
-CONFIG_LOCALVERSION_AUTO=y
-CONFIG_SWAP=y
-CONFIG_SYSVIPC=y
-# CONFIG_POSIX_MQUEUE is not set
-CONFIG_BSD_PROCESS_ACCT=y
-# CONFIG_BSD_PROCESS_ACCT_V3 is not set
-CONFIG_SYSCTL=y
-# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
-# CONFIG_IKCONFIG is not set
-CONFIG_INITRAMFS_SOURCE=""
-CONFIG_EMBEDDED=y
-CONFIG_KALLSYMS=y
-# CONFIG_KALLSYMS_ALL is not set
-# CONFIG_KALLSYMS_EXTRA_PASS is not set
-CONFIG_PRINTK=y
-CONFIG_BUG=y
-CONFIG_BASE_FULL=y
-CONFIG_FUTEX=y
-CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
-CONFIG_SHMEM=y
-CONFIG_CC_ALIGN_FUNCTIONS=0
-CONFIG_CC_ALIGN_LABELS=0
-CONFIG_CC_ALIGN_LOOPS=0
-CONFIG_CC_ALIGN_JUMPS=0
-# CONFIG_TINY_SHMEM is not set
-CONFIG_BASE_SMALL=0
-
-#
-# Loadable module support
-#
-CONFIG_MODULES=y
-CONFIG_MODULE_UNLOAD=y
-# CONFIG_MODULE_FORCE_UNLOAD is not set
-CONFIG_OBSOLETE_MODPARM=y
-# CONFIG_MODVERSIONS is not set
-# CONFIG_MODULE_SRCVERSION_ALL is not set
-CONFIG_KMOD=y
-
-#
-# Block layer
-#
-
-#
-# IO Schedulers
-#
-CONFIG_IOSCHED_NOOP=y
-CONFIG_IOSCHED_AS=y
-CONFIG_IOSCHED_DEADLINE=y
-CONFIG_IOSCHED_CFQ=y
-CONFIG_DEFAULT_AS=y
-# CONFIG_DEFAULT_DEADLINE is not set
-# CONFIG_DEFAULT_CFQ is not set
-# CONFIG_DEFAULT_NOOP is not set
-CONFIG_DEFAULT_IOSCHED="anticipatory"
-
-#
-# System Type
-#
-# CONFIG_ARCH_CLPS7500 is not set
-# CONFIG_ARCH_CLPS711X is not set
-# CONFIG_ARCH_CO285 is not set
-# CONFIG_ARCH_EBSA110 is not set
-# CONFIG_ARCH_FOOTBRIDGE is not set
-# CONFIG_ARCH_INTEGRATOR is not set
-# CONFIG_ARCH_IOP3XX is not set
-# CONFIG_ARCH_IXP4XX is not set
-CONFIG_ARCH_IXP2000=y
-# CONFIG_ARCH_L7200 is not set
-# CONFIG_ARCH_PXA is not set
-# CONFIG_ARCH_RPC is not set
-# CONFIG_ARCH_SA1100 is not set
-# CONFIG_ARCH_S3C2410 is not set
-# CONFIG_ARCH_SHARK is not set
-# CONFIG_ARCH_LH7A40X is not set
-# CONFIG_ARCH_OMAP is not set
-# CONFIG_ARCH_VERSATILE is not set
-# CONFIG_ARCH_REALVIEW is not set
-# CONFIG_ARCH_IMX is not set
-# CONFIG_ARCH_H720X is not set
-# CONFIG_ARCH_AAEC2000 is not set
-CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
-
-#
-# Intel IXP2400/2800 Implementation Options
-#
-
-#
-# IXP2400/2800 Platforms
-#
-# CONFIG_ARCH_ENP2611 is not set
-# CONFIG_ARCH_IXDP2400 is not set
-# CONFIG_ARCH_IXDP2800 is not set
-# CONFIG_ARCH_IXDP2401 is not set
-CONFIG_ARCH_IXDP2801=y
-CONFIG_ARCH_IXDP2X01=y
-# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
-
-#
-# Processor Type
-#
-CONFIG_CPU_32=y
-CONFIG_CPU_XSCALE=y
-CONFIG_CPU_32v5=y
-CONFIG_CPU_ABRT_EV5T=y
-CONFIG_CPU_CACHE_VIVT=y
-CONFIG_CPU_TLB_V4WBI=y
-
-#
-# Processor Features
-#
-# CONFIG_ARM_THUMB is not set
-CONFIG_CPU_BIG_ENDIAN=y
-CONFIG_XSCALE_PMU=y
-
-#
-# Bus support
-#
-CONFIG_ISA_DMA_API=y
-CONFIG_PCI=y
-CONFIG_PCI_LEGACY_PROC=y
-# CONFIG_PCI_DEBUG is not set
-
-#
-# PCCARD (PCMCIA/CardBus) support
-#
-# CONFIG_PCCARD is not set
-
-#
-# Kernel Features
-#
-# CONFIG_PREEMPT is not set
-# CONFIG_NO_IDLE_HZ is not set
-# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
-CONFIG_SELECT_MEMORY_MODEL=y
-CONFIG_FLATMEM_MANUAL=y
-# CONFIG_DISCONTIGMEM_MANUAL is not set
-# CONFIG_SPARSEMEM_MANUAL is not set
-CONFIG_FLATMEM=y
-CONFIG_FLAT_NODE_MEM_MAP=y
-# CONFIG_SPARSEMEM_STATIC is not set
-CONFIG_SPLIT_PTLOCK_CPUS=4096
-CONFIG_ALIGNMENT_TRAP=y
-
-#
-# Boot options
-#
-CONFIG_ZBOOT_ROM_TEXT=0x0
-CONFIG_ZBOOT_ROM_BSS=0x0
-CONFIG_CMDLINE="console=ttyS0,115200 root=/dev/nfs ip=bootp mem=64M@0x0"
-# CONFIG_XIP_KERNEL is not set
-
-#
-# Floating point emulation
-#
-
-#
-# At least one emulation must be selected
-#
-CONFIG_FPE_NWFPE=y
-CONFIG_FPE_NWFPE_XP=y
-# CONFIG_FPE_FASTFPE is not set
-
-#
-# Userspace binary formats
-#
-CONFIG_BINFMT_ELF=y
-# CONFIG_BINFMT_AOUT is not set
-# CONFIG_BINFMT_MISC is not set
-# CONFIG_ARTHUR is not set
-
-#
-# Power management options
-#
-# CONFIG_PM is not set
-
-#
-# Networking
-#
-CONFIG_NET=y
-
-#
-# Networking options
-#
-CONFIG_PACKET=y
-CONFIG_PACKET_MMAP=y
-CONFIG_UNIX=y
-# CONFIG_NET_KEY is not set
-CONFIG_INET=y
-# CONFIG_IP_MULTICAST is not set
-# CONFIG_IP_ADVANCED_ROUTER is not set
-CONFIG_IP_FIB_HASH=y
-CONFIG_IP_PNP=y
-CONFIG_IP_PNP_DHCP=y
-CONFIG_IP_PNP_BOOTP=y
-# CONFIG_IP_PNP_RARP is not set
-# CONFIG_NET_IPIP is not set
-# CONFIG_NET_IPGRE is not set
-# CONFIG_ARPD is not set
-CONFIG_SYN_COOKIES=y
-# CONFIG_INET_AH is not set
-# CONFIG_INET_ESP is not set
-# CONFIG_INET_IPCOMP is not set
-# CONFIG_INET_TUNNEL is not set
-CONFIG_INET_DIAG=y
-CONFIG_INET_TCP_DIAG=y
-# CONFIG_TCP_CONG_ADVANCED is not set
-CONFIG_TCP_CONG_BIC=y
-# CONFIG_IPV6 is not set
-# CONFIG_NETFILTER is not set
-
-#
-# DCCP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_DCCP is not set
-
-#
-# SCTP Configuration (EXPERIMENTAL)
-#
-# CONFIG_IP_SCTP is not set
-# CONFIG_ATM is not set
-# CONFIG_BRIDGE is not set
-# CONFIG_VLAN_8021Q is not set
-# CONFIG_DECNET is not set
-# CONFIG_LLC2 is not set
-# CONFIG_IPX is not set
-# CONFIG_ATALK is not set
-# CONFIG_X25 is not set
-# CONFIG_LAPB is not set
-# CONFIG_NET_DIVERT is not set
-# CONFIG_ECONET is not set
-# CONFIG_WAN_ROUTER is not set
-
-#
-# QoS and/or fair queueing
-#
-# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
-
-#
-# Network testing
-#
-# CONFIG_NET_PKTGEN is not set
-# CONFIG_HAMRADIO is not set
-# CONFIG_IRDA is not set
-# CONFIG_BT is not set
-# CONFIG_IEEE80211 is not set
-
-#
-# Device Drivers
-#
-
-#
-# Generic Driver Options
-#
-CONFIG_STANDALONE=y
-# CONFIG_PREVENT_FIRMWARE_BUILD is not set
-# CONFIG_FW_LOADER is not set
-# CONFIG_DEBUG_DRIVER is not set
-
-#
-# Memory Technology Devices (MTD)
-#
-CONFIG_MTD=y
-# CONFIG_MTD_DEBUG is not set
-# CONFIG_MTD_CONCAT is not set
-CONFIG_MTD_PARTITIONS=y
-CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-1
-CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED=y
-CONFIG_MTD_REDBOOT_PARTS_READONLY=y
-# CONFIG_MTD_CMDLINE_PARTS is not set
-# CONFIG_MTD_AFS_PARTS is not set
-
-#
-# User Modules And Translation Layers
-#
-CONFIG_MTD_CHAR=y
-CONFIG_MTD_BLOCK=y
-# CONFIG_FTL is not set
-# CONFIG_NFTL is not set
-# CONFIG_INFTL is not set
-# CONFIG_RFD_FTL is not set
-
-#
-# RAM/ROM/Flash chip drivers
-#
-CONFIG_MTD_CFI=y
-# CONFIG_MTD_JEDECPROBE is not set
-CONFIG_MTD_GEN_PROBE=y
-# CONFIG_MTD_CFI_ADV_OPTIONS is not set
-CONFIG_MTD_MAP_BANK_WIDTH_1=y
-CONFIG_MTD_MAP_BANK_WIDTH_2=y
-CONFIG_MTD_MAP_BANK_WIDTH_4=y
-# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
-# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
-CONFIG_MTD_CFI_I1=y
-CONFIG_MTD_CFI_I2=y
-# CONFIG_MTD_CFI_I4 is not set
-# CONFIG_MTD_CFI_I8 is not set
-CONFIG_MTD_CFI_INTELEXT=y
-# CONFIG_MTD_CFI_AMDSTD is not set
-# CONFIG_MTD_CFI_STAA is not set
-CONFIG_MTD_CFI_UTIL=y
-# CONFIG_MTD_RAM is not set
-# CONFIG_MTD_ROM is not set
-# CONFIG_MTD_ABSENT is not set
-# CONFIG_MTD_XIP is not set
-
-#
-# Mapping drivers for chip access
-#
-CONFIG_MTD_COMPLEX_MAPPINGS=y
-# CONFIG_MTD_PHYSMAP is not set
-# CONFIG_MTD_ARM_INTEGRATOR is not set
-CONFIG_MTD_IXP2000=y
-# CONFIG_MTD_PCI is not set
-# CONFIG_MTD_PLATRAM is not set
-
-#
-# Self-contained MTD device drivers
-#
-# CONFIG_MTD_PMC551 is not set
-# CONFIG_MTD_SLRAM is not set
-# CONFIG_MTD_PHRAM is not set
-# CONFIG_MTD_MTDRAM is not set
-# CONFIG_MTD_BLKMTD is not set
-# CONFIG_MTD_BLOCK2MTD is not set
-
-#
-# Disk-On-Chip Device Drivers
-#
-# CONFIG_MTD_DOC2000 is not set
-# CONFIG_MTD_DOC2001 is not set
-# CONFIG_MTD_DOC2001PLUS is not set
-
-#
-# NAND Flash Device Drivers
-#
-# CONFIG_MTD_NAND is not set
-
-#
-# OneNAND Flash Device Drivers
-#
-# CONFIG_MTD_ONENAND is not set
-
-#
-# Parallel port support
-#
-# CONFIG_PARPORT is not set
-
-#
-# Plug and Play support
-#
-
-#
-# Block devices
-#
-# CONFIG_BLK_CPQ_DA is not set
-# CONFIG_BLK_CPQ_CISS_DA is not set
-# CONFIG_BLK_DEV_DAC960 is not set
-# CONFIG_BLK_DEV_UMEM is not set
-# CONFIG_BLK_DEV_COW_COMMON is not set
-CONFIG_BLK_DEV_LOOP=y
-# CONFIG_BLK_DEV_CRYPTOLOOP is not set
-# CONFIG_BLK_DEV_NBD is not set
-# CONFIG_BLK_DEV_SX8 is not set
-CONFIG_BLK_DEV_RAM=y
-CONFIG_BLK_DEV_RAM_COUNT=16
-CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_BLK_DEV_INITRD=y
-# CONFIG_CDROM_PKTCDVD is not set
-# CONFIG_ATA_OVER_ETH is not set
-
-#
-# SCSI device support
-#
-# CONFIG_RAID_ATTRS is not set
-# CONFIG_SCSI is not set
-
-#
-# Multi-device support (RAID and LVM)
-#
-# CONFIG_MD is not set
-
-#
-# Fusion MPT device support
-#
-# CONFIG_FUSION is not set
-
-#
-# IEEE 1394 (FireWire) support
-#
-# CONFIG_IEEE1394 is not set
-
-#
-# I2O device support
-#
-# CONFIG_I2O is not set
-
-#
-# Network device support
-#
-CONFIG_NETDEVICES=y
-CONFIG_DUMMY=y
-# CONFIG_BONDING is not set
-# CONFIG_EQUALIZER is not set
-# CONFIG_TUN is not set
-
-#
-# ARCnet devices
-#
-# CONFIG_ARCNET is not set
-
-#
-# PHY device support
-#
-# CONFIG_PHYLIB is not set
-
-#
-# Ethernet (10 or 100Mbit)
-#
-CONFIG_NET_ETHERNET=y
-CONFIG_MII=y
-# CONFIG_HAPPYMEAL is not set
-# CONFIG_SUNGEM is not set
-# CONFIG_CASSINI is not set
-# CONFIG_NET_VENDOR_3COM is not set
-# CONFIG_SMC91X is not set
-# CONFIG_DM9000 is not set
-
-#
-# Tulip family network device support
-#
-# CONFIG_NET_TULIP is not set
-# CONFIG_HP100 is not set
-CONFIG_NET_PCI=y
-# CONFIG_PCNET32 is not set
-# CONFIG_AMD8111_ETH is not set
-# CONFIG_ADAPTEC_STARFIRE is not set
-# CONFIG_B44 is not set
-# CONFIG_FORCEDETH is not set
-CONFIG_CS89x0=y
-# CONFIG_DGRS is not set
-CONFIG_EEPRO100=y
-# CONFIG_E100 is not set
-# CONFIG_FEALNX is not set
-# CONFIG_NATSEMI is not set
-# CONFIG_NE2K_PCI is not set
-# CONFIG_8139CP is not set
-# CONFIG_8139TOO is not set
-# CONFIG_SIS900 is not set
-# CONFIG_EPIC100 is not set
-# CONFIG_SUNDANCE is not set
-# CONFIG_TLAN is not set
-# CONFIG_VIA_RHINE is not set
-
-#
-# Ethernet (1000 Mbit)
-#
-# CONFIG_ACENIC is not set
-# CONFIG_DL2K is not set
-# CONFIG_E1000 is not set
-# CONFIG_NS83820 is not set
-# CONFIG_HAMACHI is not set
-# CONFIG_YELLOWFIN is not set
-# CONFIG_R8169 is not set
-# CONFIG_SIS190 is not set
-# CONFIG_SKGE is not set
-# CONFIG_SK98LIN is not set
-# CONFIG_VIA_VELOCITY is not set
-# CONFIG_TIGON3 is not set
-# CONFIG_BNX2 is not set
-
-#
-# Ethernet (10000 Mbit)
-#
-# CONFIG_CHELSIO_T1 is not set
-# CONFIG_IXGB is not set
-# CONFIG_S2IO is not set
-
-#
-# Token Ring devices
-#
-# CONFIG_TR is not set
-
-#
-# Wireless LAN (non-hamradio)
-#
-# CONFIG_NET_RADIO is not set
-
-#
-# Wan interfaces
-#
-CONFIG_WAN=y
-# CONFIG_DSCC4 is not set
-# CONFIG_LANMEDIA is not set
-# CONFIG_SYNCLINK_SYNCPPP is not set
-CONFIG_HDLC=y
-CONFIG_HDLC_RAW=y
-# CONFIG_HDLC_RAW_ETH is not set
-CONFIG_HDLC_CISCO=y
-CONFIG_HDLC_FR=y
-CONFIG_HDLC_PPP=y
-
-#
-# X.25/LAPB support is disabled
-#
-# CONFIG_PCI200SYN is not set
-# CONFIG_WANXL is not set
-# CONFIG_PC300 is not set
-# CONFIG_FARSYNC is not set
-CONFIG_DLCI=y
-CONFIG_DLCI_COUNT=24
-CONFIG_DLCI_MAX=8
-# CONFIG_FDDI is not set
-# CONFIG_HIPPI is not set
-# CONFIG_PPP is not set
-# CONFIG_SLIP is not set
-# CONFIG_SHAPER is not set
-# CONFIG_NETCONSOLE is not set
-# CONFIG_NETPOLL is not set
-# CONFIG_NET_POLL_CONTROLLER is not set
-
-#
-# ISDN subsystem
-#
-# CONFIG_ISDN is not set
-
-#
-# Input device support
-#
-CONFIG_INPUT=y
-
-#
-# Userland interfaces
-#
-CONFIG_INPUT_MOUSEDEV=y
-CONFIG_INPUT_MOUSEDEV_PSAUX=y
-CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
-CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
-# CONFIG_INPUT_JOYDEV is not set
-# CONFIG_INPUT_TSDEV is not set
-# CONFIG_INPUT_EVDEV is not set
-# CONFIG_INPUT_EVBUG is not set
-
-#
-# Input Device Drivers
-#
-# CONFIG_INPUT_KEYBOARD is not set
-# CONFIG_INPUT_MOUSE is not set
-# CONFIG_INPUT_JOYSTICK is not set
-# CONFIG_INPUT_TOUCHSCREEN is not set
-# CONFIG_INPUT_MISC is not set
-
-#
-# Hardware I/O ports
-#
-# CONFIG_SERIO is not set
-# CONFIG_GAMEPORT is not set
-
-#
-# Character devices
-#
-# CONFIG_VT is not set
-# CONFIG_SERIAL_NONSTANDARD is not set
-
-#
-# Serial drivers
-#
-CONFIG_SERIAL_8250=y
-CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=3
-# CONFIG_SERIAL_8250_EXTENDED is not set
-
-#
-# Non-8250 serial port support
-#
-CONFIG_SERIAL_CORE=y
-CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
-CONFIG_UNIX98_PTYS=y
-CONFIG_LEGACY_PTYS=y
-CONFIG_LEGACY_PTY_COUNT=256
-
-#
-# IPMI
-#
-# CONFIG_IPMI_HANDLER is not set
-
-#
-# Watchdog Cards
-#
-CONFIG_WATCHDOG=y
-# CONFIG_WATCHDOG_NOWAYOUT is not set
-
-#
-# Watchdog Device Drivers
-#
-# CONFIG_SOFT_WATCHDOG is not set
-CONFIG_IXP2000_WATCHDOG=y
-
-#
-# PCI-based Watchdog Cards
-#
-# CONFIG_PCIPCWATCHDOG is not set
-# CONFIG_WDTPCI is not set
-# CONFIG_NVRAM is not set
-# CONFIG_RTC is not set
-# CONFIG_DTLK is not set
-# CONFIG_R3964 is not set
-# CONFIG_APPLICOM is not set
-
-#
-# Ftape, the floppy tape device driver
-#
-# CONFIG_DRM is not set
-# CONFIG_RAW_DRIVER is not set
-
-#
-# TPM devices
-#
-# CONFIG_TCG_TPM is not set
-# CONFIG_TELCLOCK is not set
-
-#
-# I2C support
-#
-CONFIG_I2C=y
-CONFIG_I2C_CHARDEV=y
-
-#
-# I2C Algorithms
-#
-CONFIG_I2C_ALGOBIT=y
-# CONFIG_I2C_ALGOPCF is not set
-# CONFIG_I2C_ALGOPCA is not set
-
-#
-# I2C Hardware Bus support
-#
-# CONFIG_I2C_ALI1535 is not set
-# CONFIG_I2C_ALI1563 is not set
-# CONFIG_I2C_ALI15X3 is not set
-# CONFIG_I2C_AMD756 is not set
-# CONFIG_I2C_AMD8111 is not set
-# CONFIG_I2C_I801 is not set
-# CONFIG_I2C_I810 is not set
-# CONFIG_I2C_PIIX4 is not set
-CONFIG_I2C_IXP2000=y
-# CONFIG_I2C_NFORCE2 is not set
-# CONFIG_I2C_PARPORT_LIGHT is not set
-# CONFIG_I2C_PROSAVAGE is not set
-# CONFIG_I2C_SAVAGE4 is not set
-# CONFIG_SCx200_ACB is not set
-# CONFIG_I2C_SIS5595 is not set
-# CONFIG_I2C_SIS630 is not set
-# CONFIG_I2C_SIS96X is not set
-# CONFIG_I2C_STUB is not set
-# CONFIG_I2C_VIA is not set
-# CONFIG_I2C_VIAPRO is not set
-# CONFIG_I2C_VOODOO3 is not set
-# CONFIG_I2C_PCA_ISA is not set
-
-#
-# Miscellaneous I2C Chip support
-#
-# CONFIG_SENSORS_DS1337 is not set
-# CONFIG_SENSORS_DS1374 is not set
-CONFIG_SENSORS_EEPROM=y
-# CONFIG_SENSORS_PCF8574 is not set
-# CONFIG_SENSORS_PCA9539 is not set
-# CONFIG_SENSORS_PCF8591 is not set
-# CONFIG_SENSORS_RTC8564 is not set
-# CONFIG_SENSORS_MAX6875 is not set
-# CONFIG_RTC_X1205_I2C is not set
-# CONFIG_I2C_DEBUG_CORE is not set
-# CONFIG_I2C_DEBUG_ALGO is not set
-# CONFIG_I2C_DEBUG_BUS is not set
-# CONFIG_I2C_DEBUG_CHIP is not set
-
-#
-# Hardware Monitoring support
-#
-CONFIG_HWMON=y
-# CONFIG_HWMON_VID is not set
-# CONFIG_SENSORS_ADM1021 is not set
-# CONFIG_SENSORS_ADM1025 is not set
-# CONFIG_SENSORS_ADM1026 is not set
-# CONFIG_SENSORS_ADM1031 is not set
-# CONFIG_SENSORS_ADM9240 is not set
-# CONFIG_SENSORS_ASB100 is not set
-# CONFIG_SENSORS_ATXP1 is not set
-# CONFIG_SENSORS_DS1621 is not set
-# CONFIG_SENSORS_FSCHER is not set
-# CONFIG_SENSORS_FSCPOS is not set
-# CONFIG_SENSORS_GL518SM is not set
-# CONFIG_SENSORS_GL520SM is not set
-# CONFIG_SENSORS_IT87 is not set
-# CONFIG_SENSORS_LM63 is not set
-# CONFIG_SENSORS_LM75 is not set
-# CONFIG_SENSORS_LM77 is not set
-# CONFIG_SENSORS_LM78 is not set
-# CONFIG_SENSORS_LM80 is not set
-# CONFIG_SENSORS_LM83 is not set
-# CONFIG_SENSORS_LM85 is not set
-# CONFIG_SENSORS_LM87 is not set
-# CONFIG_SENSORS_LM90 is not set
-# CONFIG_SENSORS_LM92 is not set
-# CONFIG_SENSORS_MAX1619 is not set
-# CONFIG_SENSORS_PC87360 is not set
-# CONFIG_SENSORS_SIS5595 is not set
-# CONFIG_SENSORS_SMSC47M1 is not set
-# CONFIG_SENSORS_SMSC47B397 is not set
-# CONFIG_SENSORS_VIA686A is not set
-# CONFIG_SENSORS_W83781D is not set
-# CONFIG_SENSORS_W83792D is not set
-# CONFIG_SENSORS_W83L785TS is not set
-# CONFIG_SENSORS_W83627HF is not set
-# CONFIG_SENSORS_W83627EHF is not set
-# CONFIG_HWMON_DEBUG_CHIP is not set
-
-#
-# Misc devices
-#
-
-#
-# Multimedia Capabilities Port drivers
-#
-
-#
-# Multimedia devices
-#
-# CONFIG_VIDEO_DEV is not set
-
-#
-# Digital Video Broadcasting Devices
-#
-# CONFIG_DVB is not set
-
-#
-# Graphics support
-#
-# CONFIG_FB is not set
-
-#
-# Sound
-#
-# CONFIG_SOUND is not set
-
-#
-# USB support
-#
-CONFIG_USB_ARCH_HAS_HCD=y
-CONFIG_USB_ARCH_HAS_OHCI=y
-# CONFIG_USB is not set
-
-#
-# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
-#
-
-#
-# USB Gadget Support
-#
-# CONFIG_USB_GADGET is not set
-
-#
-# MMC/SD Card support
-#
-# CONFIG_MMC is not set
-
-#
-# File systems
-#
-CONFIG_EXT2_FS=y
-CONFIG_EXT2_FS_XATTR=y
-CONFIG_EXT2_FS_POSIX_ACL=y
-# CONFIG_EXT2_FS_SECURITY is not set
-# CONFIG_EXT2_FS_XIP is not set
-CONFIG_EXT3_FS=y
-CONFIG_EXT3_FS_XATTR=y
-CONFIG_EXT3_FS_POSIX_ACL=y
-# CONFIG_EXT3_FS_SECURITY is not set
-CONFIG_JBD=y
-# CONFIG_JBD_DEBUG is not set
-CONFIG_FS_MBCACHE=y
-# CONFIG_REISERFS_FS is not set
-# CONFIG_JFS_FS is not set
-CONFIG_FS_POSIX_ACL=y
-# CONFIG_XFS_FS is not set
-# CONFIG_MINIX_FS is not set
-# CONFIG_ROMFS_FS is not set
-CONFIG_INOTIFY=y
-# CONFIG_QUOTA is not set
-CONFIG_DNOTIFY=y
-# CONFIG_AUTOFS_FS is not set
-# CONFIG_AUTOFS4_FS is not set
-# CONFIG_FUSE_FS is not set
-
-#
-# CD-ROM/DVD Filesystems
-#
-# CONFIG_ISO9660_FS is not set
-# CONFIG_UDF_FS is not set
-
-#
-# DOS/FAT/NT Filesystems
-#
-# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
-# CONFIG_NTFS_FS is not set
-
-#
-# Pseudo filesystems
-#
-CONFIG_PROC_FS=y
-CONFIG_SYSFS=y
-CONFIG_TMPFS=y
-# CONFIG_HUGETLB_PAGE is not set
-CONFIG_RAMFS=y
-# CONFIG_RELAYFS_FS is not set
-
-#
-# Miscellaneous filesystems
-#
-# CONFIG_ADFS_FS is not set
-# CONFIG_AFFS_FS is not set
-# CONFIG_HFS_FS is not set
-# CONFIG_HFSPLUS_FS is not set
-# CONFIG_BEFS_FS is not set
-# CONFIG_BFS_FS is not set
-# CONFIG_EFS_FS is not set
-# CONFIG_JFFS_FS is not set
-CONFIG_JFFS2_FS=y
-CONFIG_JFFS2_FS_DEBUG=0
-CONFIG_JFFS2_FS_WRITEBUFFER=y
-# CONFIG_JFFS2_SUMMARY is not set
-# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
-CONFIG_JFFS2_ZLIB=y
-CONFIG_JFFS2_RTIME=y
-# CONFIG_JFFS2_RUBIN is not set
-# CONFIG_CRAMFS is not set
-# CONFIG_VXFS_FS is not set
-# CONFIG_HPFS_FS is not set
-# CONFIG_QNX4FS_FS is not set
-# CONFIG_SYSV_FS is not set
-# CONFIG_UFS_FS is not set
-
-#
-# Network File Systems
-#
-CONFIG_NFS_FS=y
-CONFIG_NFS_V3=y
-# CONFIG_NFS_V3_ACL is not set
-# CONFIG_NFS_V4 is not set
-# CONFIG_NFS_DIRECTIO is not set
-# CONFIG_NFSD is not set
-CONFIG_ROOT_NFS=y
-CONFIG_LOCKD=y
-CONFIG_LOCKD_V4=y
-CONFIG_NFS_COMMON=y
-CONFIG_SUNRPC=y
-# CONFIG_RPCSEC_GSS_KRB5 is not set
-# CONFIG_RPCSEC_GSS_SPKM3 is not set
-# CONFIG_SMB_FS is not set
-# CONFIG_CIFS is not set
-# CONFIG_NCP_FS is not set
-# CONFIG_CODA_FS is not set
-# CONFIG_AFS_FS is not set
-# CONFIG_9P_FS is not set
-
-#
-# Partition Types
-#
-CONFIG_PARTITION_ADVANCED=y
-# CONFIG_ACORN_PARTITION is not set
-# CONFIG_OSF_PARTITION is not set
-# CONFIG_AMIGA_PARTITION is not set
-# CONFIG_ATARI_PARTITION is not set
-# CONFIG_MAC_PARTITION is not set
-CONFIG_MSDOS_PARTITION=y
-# CONFIG_BSD_DISKLABEL is not set
-# CONFIG_MINIX_SUBPARTITION is not set
-# CONFIG_SOLARIS_X86_PARTITION is not set
-# CONFIG_UNIXWARE_DISKLABEL is not set
-# CONFIG_LDM_PARTITION is not set
-# CONFIG_SGI_PARTITION is not set
-# CONFIG_ULTRIX_PARTITION is not set
-# CONFIG_SUN_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
-
-#
-# Native Language Support
-#
-# CONFIG_NLS is not set
-
-#
-# Profiling support
-#
-# CONFIG_PROFILING is not set
-
-#
-# Kernel hacking
-#
-# CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
-CONFIG_MAGIC_SYSRQ=y
-CONFIG_LOG_BUF_SHIFT=14
-CONFIG_DETECT_SOFTLOCKUP=y
-# CONFIG_SCHEDSTATS is not set
-# CONFIG_DEBUG_SLAB is not set
-# CONFIG_DEBUG_SPINLOCK is not set
-# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
-# CONFIG_DEBUG_KOBJECT is not set
-CONFIG_DEBUG_BUGVERBOSE=y
-# CONFIG_DEBUG_INFO is not set
-# CONFIG_DEBUG_FS is not set
-# CONFIG_DEBUG_VM is not set
-CONFIG_FRAME_POINTER=y
-# CONFIG_RCU_TORTURE_TEST is not set
-CONFIG_DEBUG_USER=y
-# CONFIG_DEBUG_WAITQ is not set
-CONFIG_DEBUG_ERRORS=y
-CONFIG_DEBUG_LL=y
-# CONFIG_DEBUG_ICEDCC is not set
-
-#
-# Security options
-#
-# CONFIG_KEYS is not set
-# CONFIG_SECURITY is not set
-
-#
-# Cryptographic options
-#
-# CONFIG_CRYPTO is not set
-
-#
-# Hardware crypto devices
-#
-
-#
-# Library routines
-#
-# CONFIG_CRC_CCITT is not set
-# CONFIG_CRC16 is not set
-CONFIG_CRC32=y
-# CONFIG_LIBCRC32C is not set
-CONFIG_ZLIB_INFLATE=y
-CONFIG_ZLIB_DEFLATE=y
diff --git a/arch/arm/configs/ixdp2400_defconfig b/arch/arm/configs/ixp2000_defconfig
index c67fc449a11..7b02ca04c3e 100644
--- a/arch/arm/configs/ixdp2400_defconfig
+++ b/arch/arm/configs/ixp2000_defconfig
@@ -1,11 +1,10 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.14-git13
-# Thu Nov 10 15:14:13 2005
+# Linux kernel version: 2.6.16-rc2
+# Wed Feb 8 04:49:11 2006
#
CONFIG_ARM=y
CONFIG_MMU=y
-CONFIG_UID16=y
CONFIG_RWSEM_GENERIC_SPINLOCK=y
CONFIG_GENERIC_CALIBRATE_DELAY=y
@@ -29,27 +28,31 @@ CONFIG_BSD_PROCESS_ACCT=y
# CONFIG_BSD_PROCESS_ACCT_V3 is not set
CONFIG_SYSCTL=y
# CONFIG_AUDIT is not set
-# CONFIG_HOTPLUG is not set
-CONFIG_KOBJECT_UEVENT=y
# CONFIG_IKCONFIG is not set
CONFIG_INITRAMFS_SOURCE=""
+CONFIG_UID16=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_EMBEDDED=y
CONFIG_KALLSYMS=y
# CONFIG_KALLSYMS_ALL is not set
# CONFIG_KALLSYMS_EXTRA_PASS is not set
+# CONFIG_HOTPLUG is not set
CONFIG_PRINTK=y
CONFIG_BUG=y
+CONFIG_ELF_CORE=y
CONFIG_BASE_FULL=y
CONFIG_FUTEX=y
CONFIG_EPOLL=y
-CONFIG_CC_OPTIMIZE_FOR_SIZE=y
CONFIG_SHMEM=y
CONFIG_CC_ALIGN_FUNCTIONS=0
CONFIG_CC_ALIGN_LABELS=0
CONFIG_CC_ALIGN_LOOPS=0
CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
# CONFIG_TINY_SHMEM is not set
CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+CONFIG_OBSOLETE_INTERMODULE=y
#
# Loadable module support
@@ -104,6 +107,7 @@ CONFIG_ARCH_IXP2000=y
# CONFIG_ARCH_IMX is not set
# CONFIG_ARCH_H720X is not set
# CONFIG_ARCH_AAEC2000 is not set
+# CONFIG_ARCH_AT91RM9200 is not set
CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
#
@@ -113,12 +117,13 @@ CONFIG_ARCH_SUPPORTS_BIG_ENDIAN=y
#
# IXP2400/2800 Platforms
#
-# CONFIG_ARCH_ENP2611 is not set
+CONFIG_ARCH_ENP2611=y
CONFIG_ARCH_IXDP2400=y
-# CONFIG_ARCH_IXDP2800 is not set
+CONFIG_ARCH_IXDP2800=y
CONFIG_ARCH_IXDP2X00=y
-# CONFIG_ARCH_IXDP2401 is not set
-# CONFIG_ARCH_IXDP2801 is not set
+CONFIG_ARCH_IXDP2401=y
+CONFIG_ARCH_IXDP2801=y
+CONFIG_ARCH_IXDP2X01=y
# CONFIG_IXP2000_SUPPORT_BROKEN_PCI_IO is not set
#
@@ -141,7 +146,6 @@ CONFIG_XSCALE_PMU=y
#
# Bus support
#
-CONFIG_ISA_DMA_API=y
CONFIG_PCI=y
CONFIG_PCI_LEGACY_PROC=y
# CONFIG_PCI_DEBUG is not set
@@ -156,6 +160,7 @@ CONFIG_PCI_LEGACY_PROC=y
#
# CONFIG_PREEMPT is not set
# CONFIG_NO_IDLE_HZ is not set
+# CONFIG_AEABI is not set
# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
CONFIG_SELECT_MEMORY_MODEL=y
CONFIG_FLATMEM_MANUAL=y
@@ -198,6 +203,7 @@ CONFIG_BINFMT_ELF=y
# Power management options
#
# CONFIG_PM is not set
+# CONFIG_APM is not set
#
# Networking
@@ -243,6 +249,11 @@ CONFIG_TCP_CONG_BIC=y
# SCTP Configuration (EXPERIMENTAL)
#
# CONFIG_IP_SCTP is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
# CONFIG_ATM is not set
# CONFIG_BRIDGE is not set
# CONFIG_VLAN_8021Q is not set
@@ -260,7 +271,6 @@ CONFIG_TCP_CONG_BIC=y
# QoS and/or fair queueing
#
# CONFIG_NET_SCHED is not set
-# CONFIG_NET_CLS_ROUTE is not set
#
# Network testing
@@ -284,6 +294,11 @@ CONFIG_STANDALONE=y
# CONFIG_DEBUG_DRIVER is not set
#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
# Memory Technology Devices (MTD)
#
CONFIG_MTD=y
@@ -331,6 +346,7 @@ CONFIG_MTD_CFI_UTIL=y
# CONFIG_MTD_RAM is not set
# CONFIG_MTD_ROM is not set
# CONFIG_MTD_ABSENT is not set
+# CONFIG_MTD_OBSOLETE_CHIPS is not set
# CONFIG_MTD_XIP is not set
#
@@ -466,6 +482,7 @@ CONFIG_NET_PCI=y
# CONFIG_ADAPTEC_STARFIRE is not set
# CONFIG_B44 is not set
# CONFIG_FORCEDETH is not set
+CONFIG_CS89x0=y
# CONFIG_DGRS is not set
CONFIG_EEPRO100=y
# CONFIG_E100 is not set
@@ -486,12 +503,14 @@ CONFIG_EEPRO100=y
# CONFIG_ACENIC is not set
# CONFIG_DL2K is not set
# CONFIG_E1000 is not set
+CONFIG_ENP2611_MSF_NET=y
# CONFIG_NS83820 is not set
# CONFIG_HAMACHI is not set
# CONFIG_YELLOWFIN is not set
# CONFIG_R8169 is not set
# CONFIG_SIS190 is not set
# CONFIG_SKGE is not set
+# CONFIG_SKY2 is not set
# CONFIG_SK98LIN is not set
# CONFIG_VIA_VELOCITY is not set
# CONFIG_TIGON3 is not set
@@ -595,7 +614,8 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
#
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
-CONFIG_SERIAL_8250_NR_UARTS=1
+CONFIG_SERIAL_8250_NR_UARTS=3
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
# CONFIG_SERIAL_8250_EXTENDED is not set
#
@@ -603,7 +623,6 @@ CONFIG_SERIAL_8250_NR_UARTS=1
#
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
-# CONFIG_SERIAL_JSM is not set
CONFIG_UNIX98_PTYS=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256
@@ -705,6 +724,12 @@ CONFIG_SENSORS_EEPROM=y
# CONFIG_I2C_DEBUG_CHIP is not set
#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
# Hardware Monitoring support
#
CONFIG_HWMON=y
@@ -738,6 +763,7 @@ CONFIG_HWMON=y
# CONFIG_SENSORS_SMSC47M1 is not set
# CONFIG_SENSORS_SMSC47B397 is not set
# CONFIG_SENSORS_VIA686A is not set
+# CONFIG_SENSORS_VT8231 is not set
# CONFIG_SENSORS_W83781D is not set
# CONFIG_SENSORS_W83792D is not set
# CONFIG_SENSORS_W83L785TS is not set
@@ -813,6 +839,7 @@ CONFIG_FS_MBCACHE=y
# CONFIG_JFS_FS is not set
CONFIG_FS_POSIX_ACL=y
# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
# CONFIG_MINIX_FS is not set
# CONFIG_ROMFS_FS is not set
CONFIG_INOTIFY=y
@@ -844,6 +871,7 @@ CONFIG_TMPFS=y
# CONFIG_HUGETLB_PAGE is not set
CONFIG_RAMFS=y
# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
#
# Miscellaneous filesystems
@@ -912,6 +940,7 @@ CONFIG_MSDOS_PARTITION=y
# CONFIG_SGI_PARTITION is not set
# CONFIG_ULTRIX_PARTITION is not set
# CONFIG_SUN_PARTITION is not set
+# CONFIG_KARMA_PARTITION is not set
# CONFIG_EFI_PARTITION is not set
#
@@ -928,12 +957,13 @@ CONFIG_MSDOS_PARTITION=y
# Kernel hacking
#
# CONFIG_PRINTK_TIME is not set
-CONFIG_DEBUG_KERNEL=y
CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
CONFIG_LOG_BUF_SHIFT=14
CONFIG_DETECT_SOFTLOCKUP=y
# CONFIG_SCHEDSTATS is not set
# CONFIG_DEBUG_SLAB is not set
+CONFIG_DEBUG_MUTEXES=y
# CONFIG_DEBUG_SPINLOCK is not set
# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
# CONFIG_DEBUG_KOBJECT is not set
@@ -942,6 +972,7 @@ CONFIG_DEBUG_BUGVERBOSE=y
# CONFIG_DEBUG_FS is not set
# CONFIG_DEBUG_VM is not set
CONFIG_FRAME_POINTER=y
+CONFIG_FORCED_INLINING=y
# CONFIG_RCU_TORTURE_TEST is not set
CONFIG_DEBUG_USER=y
# CONFIG_DEBUG_WAITQ is not set
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 6695b07cf1b..3cec29d56c8 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
-# Linux kernel version: 2.6.16-rc2
-# Mon Feb 6 11:17:23 2006
+# Linux kernel version: 2.6.16
+# Mon Mar 20 20:36:02 2006
#
CONFIG_ARM=y
CONFIG_MMU=y
@@ -12,7 +12,6 @@ CONFIG_GENERIC_CALIBRATE_DELAY=y
# Code maturity level options
#
CONFIG_EXPERIMENTAL=y
-CONFIG_CLEAN_COMPILE=y
CONFIG_BROKEN_ON_SMP=y
CONFIG_INIT_ENV_ARG_LIMIT=32
@@ -87,6 +86,7 @@ CONFIG_DEFAULT_IOSCHED="anticipatory"
# CONFIG_ARCH_CLPS711X is not set
# CONFIG_ARCH_CO285 is not set
# CONFIG_ARCH_EBSA110 is not set
+# CONFIG_ARCH_EP93XX is not set
# CONFIG_ARCH_FOOTBRIDGE is not set
# CONFIG_ARCH_INTEGRATOR is not set
# CONFIG_ARCH_IOP3XX is not set
@@ -111,6 +111,7 @@ CONFIG_ARCH_S3C2410=y
# S3C24XX Implementations
#
CONFIG_MACH_ANUBIS=y
+CONFIG_MACH_OSIRIS=y
CONFIG_ARCH_BAST=y
CONFIG_BAST_PC104_IRQ=y
CONFIG_ARCH_H1940=y
@@ -175,6 +176,7 @@ CONFIG_ISA=y
#
# CONFIG_PREEMPT is not set
# CONFIG_NO_IDLE_HZ is not set
+CONFIG_HZ=200
# CONFIG_AEABI is not set
# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
CONFIG_SELECT_MEMORY_MODEL=y
@@ -230,6 +232,7 @@ CONFIG_NET=y
#
# Networking options
#
+# CONFIG_NETDEBUG is not set
# CONFIG_PACKET is not set
CONFIG_UNIX=y
# CONFIG_NET_KEY is not set
@@ -364,7 +367,6 @@ CONFIG_MTD_CFI_UTIL=y
CONFIG_MTD_ROM=y
# CONFIG_MTD_ABSENT is not set
# CONFIG_MTD_OBSOLETE_CHIPS is not set
-# CONFIG_MTD_XIP is not set
#
# Mapping drivers for chip access
@@ -431,6 +433,7 @@ CONFIG_PARPORT_1284=y
CONFIG_BLK_DEV_LOOP=y
# CONFIG_BLK_DEV_CRYPTOLOOP is not set
CONFIG_BLK_DEV_NBD=m
+# CONFIG_BLK_DEV_UB is not set
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_COUNT=16
CONFIG_BLK_DEV_RAM_SIZE=4096
@@ -623,7 +626,6 @@ CONFIG_SERIAL_NONSTANDARD=y
# CONFIG_MOXA_SMARTIO is not set
# CONFIG_ISI is not set
# CONFIG_SYNCLINKMP is not set
-# CONFIG_SYNCLINK_GT is not set
# CONFIG_N_HDLC is not set
# CONFIG_RISCOM8 is not set
# CONFIG_SPECIALIX is not set
@@ -686,6 +688,11 @@ CONFIG_S3C2410_WATCHDOG=y
# CONFIG_PCWATCHDOG is not set
# CONFIG_MIXCOMWD is not set
# CONFIG_WDT is not set
+
+#
+# USB-based Watchdog Cards
+#
+# CONFIG_USBPCWATCHDOG is not set
# CONFIG_NVRAM is not set
# CONFIG_RTC is not set
CONFIG_S3C2410_RTC=y
@@ -751,6 +758,11 @@ CONFIG_SENSORS_EEPROM=m
# CONFIG_SPI_MASTER is not set
#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
# Hardware Monitoring support
#
CONFIG_HWMON=y
@@ -763,6 +775,7 @@ CONFIG_HWMON_VID=m
# CONFIG_SENSORS_ASB100 is not set
# CONFIG_SENSORS_ATXP1 is not set
# CONFIG_SENSORS_DS1621 is not set
+# CONFIG_SENSORS_F71805F is not set
# CONFIG_SENSORS_FSCHER is not set
# CONFIG_SENSORS_FSCPOS is not set
# CONFIG_SENSORS_GL518SM is not set
@@ -850,16 +863,138 @@ CONFIG_FONT_8x16=y
#
CONFIG_USB_ARCH_HAS_HCD=y
CONFIG_USB_ARCH_HAS_OHCI=y
-# CONFIG_USB is not set
+CONFIG_USB=y
+# CONFIG_USB_DEBUG is not set
+
+#
+# Miscellaneous USB options
+#
+CONFIG_USB_DEVICEFS=y
+# CONFIG_USB_BANDWIDTH is not set
+# CONFIG_USB_DYNAMIC_MINORS is not set
+# CONFIG_USB_SUSPEND is not set
+# CONFIG_USB_OTG is not set
+
+#
+# USB Host Controller Drivers
+#
+# CONFIG_USB_ISP116X_HCD is not set
+CONFIG_USB_OHCI_HCD=y
+# CONFIG_USB_OHCI_BIG_ENDIAN is not set
+CONFIG_USB_OHCI_LITTLE_ENDIAN=y
+# CONFIG_USB_SL811_HCD is not set
+
+#
+# USB Device Class drivers
+#
+# CONFIG_USB_ACM is not set
+# CONFIG_USB_PRINTER is not set
#
# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
#
#
+# may also be needed; see USB_STORAGE Help for more information
+#
+# CONFIG_USB_STORAGE is not set
+# CONFIG_USB_LIBUSUAL is not set
+
+#
+# USB Input Devices
+#
+# CONFIG_USB_HID is not set
+
+#
+# USB HID Boot Protocol drivers
+#
+# CONFIG_USB_KBD is not set
+# CONFIG_USB_MOUSE is not set
+# CONFIG_USB_AIPTEK is not set
+# CONFIG_USB_WACOM is not set
+# CONFIG_USB_ACECAD is not set
+# CONFIG_USB_KBTAB is not set
+# CONFIG_USB_POWERMATE is not set
+# CONFIG_USB_MTOUCH is not set
+# CONFIG_USB_ITMTOUCH is not set
+# CONFIG_USB_EGALAX is not set
+# CONFIG_USB_YEALINK is not set
+# CONFIG_USB_XPAD is not set
+# CONFIG_USB_ATI_REMOTE is not set
+# CONFIG_USB_ATI_REMOTE2 is not set
+# CONFIG_USB_KEYSPAN_REMOTE is not set
+# CONFIG_USB_APPLETOUCH is not set
+
+#
+# USB Imaging devices
+#
+# CONFIG_USB_MDC800 is not set
+
+#
+# USB Multimedia devices
+#
+# CONFIG_USB_DABUSB is not set
+
+#
+# Video4Linux support is needed for USB Multimedia device support
+#
+
+#
+# USB Network Adapters
+#
+# CONFIG_USB_CATC is not set
+# CONFIG_USB_KAWETH is not set
+# CONFIG_USB_PEGASUS is not set
+# CONFIG_USB_RTL8150 is not set
+# CONFIG_USB_USBNET is not set
+CONFIG_USB_MON=y
+
+#
+# USB port drivers
+#
+# CONFIG_USB_USS720 is not set
+
+#
+# USB Serial Converter support
+#
+# CONFIG_USB_SERIAL is not set
+
+#
+# USB Miscellaneous drivers
+#
+# CONFIG_USB_EMI62 is not set
+# CONFIG_USB_EMI26 is not set
+# CONFIG_USB_AUERSWALD is not set
+# CONFIG_USB_RIO500 is not set
+# CONFIG_USB_LEGOTOWER is not set
+# CONFIG_USB_LCD is not set
+# CONFIG_USB_LED is not set
+# CONFIG_USB_CYTHERM is not set
+# CONFIG_USB_PHIDGETKIT is not set
+# CONFIG_USB_PHIDGETSERVO is not set
+# CONFIG_USB_IDMOUSE is not set
+# CONFIG_USB_LD is not set
+# CONFIG_USB_TEST is not set
+
+#
+# USB DSL modem support
+#
+
+#
# USB Gadget Support
#
# CONFIG_USB_GADGET is not set
+# CONFIG_USB_GADGET_NET2280 is not set
+# CONFIG_USB_GADGET_PXA2XX is not set
+# CONFIG_USB_GADGET_GOKU is not set
+# CONFIG_USB_GADGET_LH7A40X is not set
+# CONFIG_USB_GADGET_OMAP is not set
+# CONFIG_USB_GADGET_DUMMY_HCD is not set
+# CONFIG_USB_ZERO is not set
+# CONFIG_USB_ETH is not set
+# CONFIG_USB_GADGETFS is not set
+# CONFIG_USB_FILE_STORAGE is not set
+# CONFIG_USB_G_SERIAL is not set
#
# MMC/SD Card support
diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c
index 766b6c05c6d..2bed290fec7 100644
--- a/arch/arm/kernel/apm.c
+++ b/arch/arm/kernel/apm.c
@@ -357,10 +357,8 @@ static int apm_open(struct inode * inode, struct file * filp)
{
struct apm_user *as;
- as = (struct apm_user *)kmalloc(sizeof(*as), GFP_KERNEL);
+ as = (struct apm_user *)kzalloc(sizeof(*as), GFP_KERNEL);
if (as) {
- memset(as, 0, sizeof(*as));
-
/*
* XXX - this is a tiny bit broken, when we consider BSD
* process accounting. If the device is opened by root, we
diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index c4923fac8df..de606dfa8db 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -540,12 +540,10 @@ static void __init pcibios_init_hw(struct hw_pci *hw)
int nr, busnr;
for (nr = busnr = 0; nr < hw->nr_controllers; nr++) {
- sys = kmalloc(sizeof(struct pci_sys_data), GFP_KERNEL);
+ sys = kzalloc(sizeof(struct pci_sys_data), GFP_KERNEL);
if (!sys)
panic("PCI: unable to allocate sys data!");
- memset(sys, 0, sizeof(struct pci_sys_data));
-
sys->hw = hw;
sys->busnr = busnr;
sys->swizzle = hw->swizzle;
diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
index caaa919ab47..da280bae3d0 100644
--- a/arch/arm/kernel/debug.S
+++ b/arch/arm/kernel/debug.S
@@ -11,7 +11,6 @@
*/
#include <linux/config.h>
#include <linux/linkage.h>
-#include <asm/hardware.h>
.text
diff --git a/arch/arm/kernel/ecard.c b/arch/arm/kernel/ecard.c
index 74ea29c3205..00aa225e8d9 100644
--- a/arch/arm/kernel/ecard.c
+++ b/arch/arm/kernel/ecard.c
@@ -807,14 +807,12 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
unsigned long base;
int i;
- ec = kmalloc(sizeof(ecard_t), GFP_KERNEL);
+ ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
if (!ec) {
ec = ERR_PTR(-ENOMEM);
goto nomem;
}
- memset(ec, 0, sizeof(ecard_t));
-
ec->slot_no = slot;
ec->type = type;
ec->irq = NO_IRQ;
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index ec48d70c6d8..355914ffb19 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -484,7 +484,6 @@ call_fpe:
movcss r7, r5, lsr #(TIF_USING_IWMMXT + 1)
bcs iwmmxt_task_enable
#endif
- enable_irq
add pc, pc, r8, lsr #6
mov r0, r0
@@ -511,6 +510,7 @@ call_fpe:
mov pc, lr @ CP#15 (Control)
do_fpe:
+ enable_irq
ldr r4, .LCfp
add r10, r10, #TI_FPSTATE @ r10 = workspace
ldr pc, [r4] @ Call FP module USR entry point
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 1aca1775b28..84277fe818a 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -28,10 +28,9 @@
#define PROCINFO_INITFUNC 12
#define MACHINFO_TYPE 0
-#define MACHINFO_PHYSRAM 4
-#define MACHINFO_PHYSIO 8
-#define MACHINFO_PGOFFIO 12
-#define MACHINFO_NAME 16
+#define MACHINFO_PHYSIO 4
+#define MACHINFO_PGOFFIO 8
+#define MACHINFO_NAME 12
#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET)
diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index 1d50d2b98f5..2d5896b3618 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -305,14 +305,19 @@ report_bad_irq(unsigned int irq, struct pt_regs *regs, struct irqdesc *desc, int
static int count = 100;
struct irqaction *action;
- if (!count || noirqdebug)
+ if (noirqdebug)
return;
- count--;
-
if (ret != IRQ_HANDLED && ret != IRQ_NONE) {
+ if (!count)
+ return;
+ count--;
printk("irq%u: bogus retval mask %x\n", irq, ret);
} else {
+ desc->irqs_unhandled++;
+ if (desc->irqs_unhandled <= 99900)
+ return;
+ desc->irqs_unhandled = 0;
printk("irq%u: nobody cared\n", irq);
}
show_regs(regs);
diff --git a/arch/arm/lib/delay.S b/arch/arm/lib/delay.S
index b3fb475b412..9183b06c0e2 100644
--- a/arch/arm/lib/delay.S
+++ b/arch/arm/lib/delay.S
@@ -9,28 +9,32 @@
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
+#include <asm/param.h>
.text
.LC0: .word loops_per_jiffy
+.LC1: .word (2199023*HZ)>>11
/*
- * 0 <= r0 <= 2000
+ * r0 <= 2000
+ * lpj <= 0x01ffffff (max. 3355 bogomips)
+ * HZ <= 1000
*/
+
ENTRY(__udelay)
- mov r2, #0x6800
- orr r2, r2, #0x00db
+ ldr r2, .LC1
mul r0, r2, r0
-ENTRY(__const_udelay) @ 0 <= r0 <= 0x01ffffff
+ENTRY(__const_udelay) @ 0 <= r0 <= 0x7fffff06
ldr r2, .LC0
- ldr r2, [r2] @ max = 0x0fffffff
- mov r0, r0, lsr #11 @ max = 0x00003fff
- mov r2, r2, lsr #11 @ max = 0x0003ffff
+ ldr r2, [r2] @ max = 0x01ffffff
+ mov r0, r0, lsr #14 @ max = 0x0001ffff
+ mov r2, r2, lsr #10 @ max = 0x00007fff
mul r0, r2, r0 @ max = 2^32-1
movs r0, r0, lsr #6
RETINSTR(moveq,pc,lr)
/*
- * loops = (r0 * 0x10c6 * 100 * loops_per_jiffy) / 2^32
+ * loops = r0 * HZ * loops_per_jiffy / 1000000
*
* Oh, if only we had a cycle counter...
*/
diff --git a/arch/arm/lib/io-acorn.S b/arch/arm/lib/io-acorn.S
index b153523631c..1b197ea7aab 100644
--- a/arch/arm/lib/io-acorn.S
+++ b/arch/arm/lib/io-acorn.S
@@ -12,7 +12,6 @@
*/
#include <linux/linkage.h>
#include <asm/assembler.h>
-#include <asm/hardware.h>
.text
.align
diff --git a/arch/arm/mach-at91rm9200/clock.c b/arch/arm/mach-at91rm9200/clock.c
index ec8195a2a3c..8b95467c6d6 100644
--- a/arch/arm/mach-at91rm9200/clock.c
+++ b/arch/arm/mach-at91rm9200/clock.c
@@ -201,6 +201,54 @@ static struct clk ohci_clk = {
.pmc_mask = 1 << AT91_ID_UHP,
.mode = pmc_periph_mode,
};
+static struct clk ether_clk = {
+ .name = "ether_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_EMAC,
+ .mode = pmc_periph_mode,
+};
+static struct clk mmc_clk = {
+ .name = "mci_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_MCI,
+ .mode = pmc_periph_mode,
+};
+static struct clk twi_clk = {
+ .name = "twi_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_TWI,
+ .mode = pmc_periph_mode,
+};
+static struct clk usart0_clk = {
+ .name = "usart0_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_US0,
+ .mode = pmc_periph_mode,
+};
+static struct clk usart1_clk = {
+ .name = "usart1_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_US1,
+ .mode = pmc_periph_mode,
+};
+static struct clk usart2_clk = {
+ .name = "usart2_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_US2,
+ .mode = pmc_periph_mode,
+};
+static struct clk usart3_clk = {
+ .name = "usart3_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_US3,
+ .mode = pmc_periph_mode,
+};
+static struct clk spi_clk = {
+ .name = "spi0_clk",
+ .parent = &mck,
+ .pmc_mask = 1 << AT91_ID_SPI,
+ .mode = pmc_periph_mode,
+};
static struct clk *const clock_list[] = {
/* four primary clocks -- MUST BE FIRST! */
@@ -223,15 +271,18 @@ static struct clk *const clock_list[] = {
/* MCK and peripherals */
&mck,
- // usart0..usart3
- // mmc
+ &usart0_clk,
+ &usart1_clk,
+ &usart2_clk,
+ &usart3_clk,
+ &mmc_clk,
&udc_clk,
- // i2c
- // spi
+ &twi_clk,
+ &spi_clk,
// ssc0..ssc2
// tc0..tc5
&ohci_clk,
- // ether
+ &ether_clk,
};
@@ -360,7 +411,7 @@ int clk_set_rate(struct clk *clk, unsigned long rate)
u32 pckr;
pckr = at91_sys_read(AT91_PMC_PCKR(clk->id));
- pckr &= 0x03;
+ pckr &= AT91_PMC_CSS_PLLB; /* clock selection */
pckr |= prescale << 2;
at91_sys_write(AT91_PMC_PCKR(clk->id), pckr);
clk->rate_hz = actual;
@@ -440,7 +491,7 @@ static int at91_clk_show(struct seq_file *s, void *unused)
else
state = "";
- seq_printf(s, "%-10s users=%d %-3s %9ld Hz %s\n",
+ seq_printf(s, "%-10s users=%2d %-3s %9ld Hz %s\n",
clk->name, clk->users, state, clk_get_rate(clk),
clk->parent ? clk->parent->name : "");
}
@@ -483,11 +534,18 @@ static u32 __init at91_pll_rate(struct clk *pll, u32 freq, u32 reg)
freq *= mul + 1;
} else
freq = 0;
- if (pll == &pllb && (reg & (1 << 28)))
- freq /= 2;
+
return freq;
}
+static u32 __init at91_usb_rate(struct clk *pll, u32 freq, u32 reg)
+{
+ if (pll == &pllb && (reg & AT91_PMC_USB96M))
+ return freq / 2;
+ else
+ return freq;
+}
+
static unsigned __init at91_pll_calc(unsigned main_freq, unsigned out_freq)
{
unsigned i, div = 0, mul = 0, diff = 1 << 30;
@@ -550,8 +608,8 @@ int __init at91_clock_init(unsigned long main_clock)
if (!main_clock) {
do {
tmp = at91_sys_read(AT91_CKGR_MCFR);
- } while (!(tmp & 0x10000));
- main_clock = (tmp & 0xffff) * (AT91_SLOW_CLOCK / 16);
+ } while (!(tmp & AT91_PMC_MAINRDY));
+ main_clock = (tmp & AT91_PMC_MAINF) * (AT91_SLOW_CLOCK / 16);
}
main_clk.rate_hz = main_clock;
@@ -566,13 +624,16 @@ int __init at91_clock_init(unsigned long main_clock)
*
* REVISIT: assumes MCK doesn't derive from PLLB!
*/
- at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | 0x10000000;
+ at91_pllb_usb_init = at91_pll_calc(main_clock, 48000000 * 2) | AT91_PMC_USB96M;
pllb.rate_hz = at91_pll_rate(&pllb, main_clock, at91_pllb_usb_init);
at91_sys_write(AT91_PMC_PCDR, (1 << AT91_ID_UHP) | (1 << AT91_ID_UDP));
at91_sys_write(AT91_PMC_SCDR, AT91_PMC_UHP | AT91_PMC_UDP);
at91_sys_write(AT91_CKGR_PLLBR, 0);
at91_sys_write(AT91_PMC_SCER, AT91_PMC_MCKUDP);
+ udpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
+ uhpck.rate_hz = at91_usb_rate(&pllb, pllb.rate_hz, at91_pllb_usb_init);
+
/*
* MCK and CPU derive from one of those primary clocks.
* For now, assume this parentage won't change.
diff --git a/arch/arm/mach-at91rm9200/gpio.c b/arch/arm/mach-at91rm9200/gpio.c
index 0e396feec46..5ab46274e1a 100644
--- a/arch/arm/mach-at91rm9200/gpio.c
+++ b/arch/arm/mach-at91rm9200/gpio.c
@@ -261,7 +261,7 @@ static void gpio_irq_handler(unsigned irq, struct irqdesc *desc, struct pt_regs
void __iomem *pio;
u32 isr;
- pio = (void __force __iomem *) desc->chipdata;
+ pio = desc->base;
/* temporarily mask (level sensitive) parent IRQ */
desc->chip->ack(irq);
@@ -312,7 +312,7 @@ void __init at91_gpio_irq_setup(unsigned banks)
__raw_writel(~0, controller + PIO_IDR);
set_irq_data(id, (void *) pin);
- set_irq_chipdata(id, (void __force *) controller);
+ set_irq_chipdata(id, controller);
for (i = 0; i < 32; i++, pin++) {
set_irq_chip(pin, &gpio_irqchip);
diff --git a/arch/arm/mach-at91rm9200/time.c b/arch/arm/mach-at91rm9200/time.c
index 1b6dd2deeb2..7ffcf443b99 100644
--- a/arch/arm/mach-at91rm9200/time.c
+++ b/arch/arm/mach-at91rm9200/time.c
@@ -71,11 +71,11 @@ static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id, struct pt_r
if (at91_sys_read(AT91_ST_SR) & AT91_ST_PITS) { /* This is a shared interrupt */
write_seqlock(&xtime_lock);
- do {
+ while (((read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV) >= LATCH) {
timer_tick(regs);
rtar = (at91_sys_read(AT91_ST_RTAR) + LATCH) & AT91_ST_ALMV;
at91_sys_write(AT91_ST_RTAR, rtar);
- } while (((read_CRTR() - at91_sys_read(AT91_ST_RTAR)) & AT91_ST_ALMV) >= LATCH);
+ }
write_sequnlock(&xtime_lock);
diff --git a/arch/arm/mach-ep93xx/Kconfig b/arch/arm/mach-ep93xx/Kconfig
new file mode 100644
index 00000000000..cec5a21ca4e
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Kconfig
@@ -0,0 +1,21 @@
+if ARCH_EP93XX
+
+menu "Cirrus EP93xx Implementation Options"
+
+comment "EP93xx Platforms"
+
+config MACH_GESBC9312
+ bool "Support Glomation GESBC-9312-sx"
+ help
+ Say 'Y' here if you want your kernel to support the Glomation
+ GESBC-9312-sx board.
+
+config MACH_TS72XX
+ bool "Support Technologic Systems TS-72xx SBC"
+ help
+ Say 'Y' here if you want your kernel to support the
+ Technologic Systems TS-72xx board.
+
+endmenu
+
+endif
diff --git a/arch/arm/mach-ep93xx/Makefile b/arch/arm/mach-ep93xx/Makefile
new file mode 100644
index 00000000000..5393af989e9
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile
@@ -0,0 +1,10 @@
+#
+# Makefile for the linux kernel.
+#
+obj-y := core.o
+obj-m :=
+obj-n :=
+obj- :=
+
+obj-$(CONFIG_MACH_GESBC9312) += gesbc9312.o
+obj-$(CONFIG_MACH_TS72XX) += ts72xx.o
diff --git a/arch/arm/mach-ep93xx/Makefile.boot b/arch/arm/mach-ep93xx/Makefile.boot
new file mode 100644
index 00000000000..d5561ad15ba
--- /dev/null
+++ b/arch/arm/mach-ep93xx/Makefile.boot
@@ -0,0 +1,2 @@
+ zreladdr-y := 0x00008000
+params_phys-y := 0x00000100
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
new file mode 100644
index 00000000000..865427bfad7
--- /dev/null
+++ b/arch/arm/mach-ep93xx/core.c
@@ -0,0 +1,374 @@
+/*
+ * arch/arm/mach-ep93xx/core.c
+ * Core routines for Cirrus EP93xx chips.
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * Thanks go to Michael Burian and Ray Lehtiniemi for their key
+ * role in the ep93xx linux community.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/spinlock.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/serial.h>
+#include <linux/tty.h>
+#include <linux/bitops.h>
+#include <linux/serial.h>
+#include <linux/serial_8250.h>
+#include <linux/serial_core.h>
+#include <linux/device.h>
+#include <linux/mm.h>
+#include <linux/time.h>
+#include <linux/timex.h>
+#include <linux/delay.h>
+#include <linux/amba/bus.h>
+
+#include <asm/types.h>
+#include <asm/setup.h>
+#include <asm/memory.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <asm/tlbflush.h>
+#include <asm/pgtable.h>
+#include <asm/io.h>
+
+#include <asm/mach/map.h>
+#include <asm/mach/time.h>
+#include <asm/mach/irq.h>
+#include <asm/arch/gpio.h>
+
+#include <asm/hardware/vic.h>
+
+
+/*************************************************************************
+ * Static I/O mappings that are needed for all EP93xx platforms
+ *************************************************************************/
+static struct map_desc ep93xx_io_desc[] __initdata = {
+ {
+ .virtual = EP93XX_AHB_VIRT_BASE,
+ .pfn = __phys_to_pfn(EP93XX_AHB_PHYS_BASE),
+ .length = EP93XX_AHB_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = EP93XX_APB_VIRT_BASE,
+ .pfn = __phys_to_pfn(EP93XX_APB_PHYS_BASE),
+ .length = EP93XX_APB_SIZE,
+ .type = MT_DEVICE,
+ },
+};
+
+void __init ep93xx_map_io(void)
+{
+ iotable_init(ep93xx_io_desc, ARRAY_SIZE(ep93xx_io_desc));
+}
+
+
+/*************************************************************************
+ * Timer handling for EP93xx
+ *************************************************************************
+ * The ep93xx has four internal timers. Timers 1, 2 (both 16 bit) and
+ * 3 (32 bit) count down at 508 kHz, are self-reloading, and can generate
+ * an interrupt on underflow. Timer 4 (40 bit) counts down at 983.04 kHz,
+ * is free-running, and can't generate interrupts.
+ *
+ * The 508 kHz timers are ideal for use for the timer interrupt, as the
+ * most common values of HZ divide 508 kHz nicely. We pick one of the 16
+ * bit timers (timer 1) since we don't need more than 16 bits of reload
+ * value as long as HZ >= 8.
+ *
+ * The higher clock rate of timer 4 makes it a better choice than the
+ * other timers for use in gettimeoffset(), while the fact that it can't
+ * generate interrupts means we don't have to worry about not being able
+ * to use this timer for something else. We also use timer 4 for keeping
+ * track of lost jiffies.
+ */
+static unsigned int last_jiffy_time;
+
+#define TIMER4_TICKS_PER_JIFFY ((CLOCK_TICK_RATE + (HZ/2)) / HZ)
+
+static int ep93xx_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ write_seqlock(&xtime_lock);
+
+ __raw_writel(1, EP93XX_TIMER1_CLEAR);
+ while (__raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time
+ >= TIMER4_TICKS_PER_JIFFY) {
+ last_jiffy_time += TIMER4_TICKS_PER_JIFFY;
+ timer_tick(regs);
+ }
+
+ write_sequnlock(&xtime_lock);
+
+ return IRQ_HANDLED;
+}
+
+static struct irqaction ep93xx_timer_irq = {
+ .name = "ep93xx timer",
+ .flags = SA_INTERRUPT | SA_TIMER,
+ .handler = ep93xx_timer_interrupt,
+};
+
+static void __init ep93xx_timer_init(void)
+{
+ /* Enable periodic HZ timer. */
+ __raw_writel(0x48, EP93XX_TIMER1_CONTROL);
+ __raw_writel((508000 / HZ) - 1, EP93XX_TIMER1_LOAD);
+ __raw_writel(0xc8, EP93XX_TIMER1_CONTROL);
+
+ /* Enable lost jiffy timer. */
+ __raw_writel(0x100, EP93XX_TIMER4_VALUE_HIGH);
+
+ setup_irq(IRQ_EP93XX_TIMER1, &ep93xx_timer_irq);
+}
+
+static unsigned long ep93xx_gettimeoffset(void)
+{
+ int offset;
+
+ offset = __raw_readl(EP93XX_TIMER4_VALUE_LOW) - last_jiffy_time;
+
+ /* Calculate (1000000 / 983040) * offset. */
+ return offset + (53 * offset / 3072);
+}
+
+struct sys_timer ep93xx_timer = {
+ .init = ep93xx_timer_init,
+ .offset = ep93xx_gettimeoffset,
+};
+
+
+/*************************************************************************
+ * GPIO handling for EP93xx
+ *************************************************************************/
+static unsigned char gpio_int_enable[2];
+static unsigned char gpio_int_type1[2];
+static unsigned char gpio_int_type2[2];
+
+static void update_gpio_ab_int_params(int port)
+{
+ if (port == 0) {
+ __raw_writeb(0, EP93XX_GPIO_A_INT_ENABLE);
+ __raw_writeb(gpio_int_type2[0], EP93XX_GPIO_A_INT_TYPE2);
+ __raw_writeb(gpio_int_type1[0], EP93XX_GPIO_A_INT_TYPE1);
+ __raw_writeb(gpio_int_enable[0], EP93XX_GPIO_A_INT_ENABLE);
+ } else if (port == 1) {
+ __raw_writeb(0, EP93XX_GPIO_B_INT_ENABLE);
+ __raw_writeb(gpio_int_type2[1], EP93XX_GPIO_B_INT_TYPE2);
+ __raw_writeb(gpio_int_type1[1], EP93XX_GPIO_B_INT_TYPE1);
+ __raw_writeb(gpio_int_enable[1], EP93XX_GPIO_B_INT_ENABLE);
+ }
+}
+
+
+static unsigned char data_register_offset[8] = {
+ 0x00, 0x04, 0x08, 0x0c, 0x20, 0x30, 0x38, 0x40,
+};
+
+static unsigned char data_direction_register_offset[8] = {
+ 0x10, 0x14, 0x18, 0x1c, 0x24, 0x34, 0x3c, 0x44,
+};
+
+void gpio_line_config(int line, int direction)
+{
+ unsigned int data_direction_register;
+ unsigned long flags;
+ unsigned char v;
+
+ data_direction_register =
+ EP93XX_GPIO_REG(data_direction_register_offset[line >> 3]);
+
+ local_irq_save(flags);
+ if (direction == GPIO_OUT) {
+ if (line >= 0 && line < 16) {
+ gpio_int_enable[line >> 3] &= ~(1 << (line & 7));
+ update_gpio_ab_int_params(line >> 3);
+ }
+
+ v = __raw_readb(data_direction_register);
+ v |= 1 << (line & 7);
+ __raw_writeb(v, data_direction_register);
+ } else if (direction == GPIO_IN) {
+ v = __raw_readb(data_direction_register);
+ v &= ~(1 << (line & 7));
+ __raw_writeb(v, data_direction_register);
+ }
+ local_irq_restore(flags);
+}
+EXPORT_SYMBOL(gpio_line_config);
+
+int gpio_line_get(int line)
+{
+ unsigned int data_register;
+
+ data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]);
+
+ return !!(__raw_readb(data_register) & (1 << (line & 7)));
+}
+EXPORT_SYMBOL(gpio_line_get);
+
+void gpio_line_set(int line, int value)
+{
+ unsigned int data_register;
+ unsigned long flags;
+ unsigned char v;
+
+ data_register = EP93XX_GPIO_REG(data_register_offset[line >> 3]);
+
+ local_irq_save(flags);
+ if (value == EP93XX_GPIO_HIGH) {
+ v = __raw_readb(data_register);
+ v |= 1 << (line & 7);
+ __raw_writeb(v, data_register);
+ } else if (value == EP93XX_GPIO_LOW) {
+ v = __raw_readb(data_register);
+ v &= ~(1 << (line & 7));
+ __raw_writeb(v, data_register);
+ }
+ local_irq_restore(flags);
+}
+EXPORT_SYMBOL(gpio_line_set);
+
+
+/*************************************************************************
+ * EP93xx IRQ handling
+ *************************************************************************/
+static void ep93xx_gpio_ab_irq_handler(unsigned int irq,
+ struct irqdesc *desc, struct pt_regs *regs)
+{
+ unsigned char status;
+ int i;
+
+ status = __raw_readb(EP93XX_GPIO_A_INT_STATUS);
+ for (i = 0; i < 8; i++) {
+ if (status & (1 << i)) {
+ desc = irq_desc + IRQ_EP93XX_GPIO(0) + i;
+ desc_handle_irq(IRQ_EP93XX_GPIO(0) + i, desc, regs);
+ }
+ }
+
+ status = __raw_readb(EP93XX_GPIO_B_INT_STATUS);
+ for (i = 0; i < 8; i++) {
+ if (status & (1 << i)) {
+ desc = irq_desc + IRQ_EP93XX_GPIO(8) + i;
+ desc_handle_irq(IRQ_EP93XX_GPIO(8) + i, desc, regs);
+ }
+ }
+}
+
+static void ep93xx_gpio_ab_irq_mask_ack(unsigned int irq)
+{
+ int line = irq - IRQ_EP93XX_GPIO(0);
+ int port = line >> 3;
+
+ gpio_int_enable[port] &= ~(1 << (line & 7));
+ update_gpio_ab_int_params(port);
+
+ if (line >> 3) {
+ __raw_writel(1 << (line & 7), EP93XX_GPIO_B_INT_ACK);
+ } else {
+ __raw_writel(1 << (line & 7), EP93XX_GPIO_A_INT_ACK);
+ }
+}
+
+static void ep93xx_gpio_ab_irq_mask(unsigned int irq)
+{
+ int line = irq - IRQ_EP93XX_GPIO(0);
+ int port = line >> 3;
+
+ gpio_int_enable[port] &= ~(1 << (line & 7));
+ update_gpio_ab_int_params(port);
+}
+
+static void ep93xx_gpio_ab_irq_unmask(unsigned int irq)
+{
+ int line = irq - IRQ_EP93XX_GPIO(0);
+ int port = line >> 3;
+
+ gpio_int_enable[port] |= 1 << (line & 7);
+ update_gpio_ab_int_params(port);
+}
+
+
+/*
+ * gpio_int_type1 controls whether the interrupt is level (0) or
+ * edge (1) triggered, while gpio_int_type2 controls whether it
+ * triggers on low/falling (0) or high/rising (1).
+ */
+static int ep93xx_gpio_ab_irq_type(unsigned int irq, unsigned int type)
+{
+ int port;
+ int line;
+
+ line = irq - IRQ_EP93XX_GPIO(0);
+ gpio_line_config(line, GPIO_IN);
+
+ port = line >> 3;
+ line &= 7;
+
+ if (type & IRQT_RISING) {
+ gpio_int_type1[port] |= 1 << line;
+ gpio_int_type2[port] |= 1 << line;
+ } else if (type & IRQT_FALLING) {
+ gpio_int_type1[port] |= 1 << line;
+ gpio_int_type2[port] &= ~(1 << line);
+ } else if (type & IRQT_HIGH) {
+ gpio_int_type1[port] &= ~(1 << line);
+ gpio_int_type2[port] |= 1 << line;
+ } else if (type & IRQT_LOW) {
+ gpio_int_type1[port] &= ~(1 << line);
+ gpio_int_type2[port] &= ~(1 << line);
+ }
+ update_gpio_ab_int_params(port);
+
+ return 0;
+}
+
+static struct irqchip ep93xx_gpio_ab_irq_chip = {
+ .ack = ep93xx_gpio_ab_irq_mask_ack,
+ .mask = ep93xx_gpio_ab_irq_mask,
+ .unmask = ep93xx_gpio_ab_irq_unmask,
+ .set_type = ep93xx_gpio_ab_irq_type,
+};
+
+
+void __init ep93xx_init_irq(void)
+{
+ int irq;
+
+ vic_init((void *)EP93XX_VIC1_BASE, 0, EP93XX_VIC1_VALID_IRQ_MASK);
+ vic_init((void *)EP93XX_VIC2_BASE, 32, EP93XX_VIC2_VALID_IRQ_MASK);
+
+ for (irq = IRQ_EP93XX_GPIO(0) ; irq <= IRQ_EP93XX_GPIO(15); irq++) {
+ set_irq_chip(irq, &ep93xx_gpio_ab_irq_chip);
+ set_irq_handler(irq, do_level_IRQ);
+ set_irq_flags(irq, IRQF_VALID);
+ }
+ set_irq_chained_handler(IRQ_EP93XX_GPIO_AB, ep93xx_gpio_ab_irq_handler);
+}
+
+
+/*************************************************************************
+ * EP93xx peripheral handling
+ *************************************************************************/
+void __init ep93xx_init_devices(void)
+{
+ unsigned int v;
+
+ /*
+ * Disallow access to MaverickCrunch initially.
+ */
+ v = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
+ v &= ~EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE;
+ __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
+ __raw_writel(v, EP93XX_SYSCON_DEVICE_CONFIG);
+}
diff --git a/arch/arm/mach-ep93xx/gesbc9312.c b/arch/arm/mach-ep93xx/gesbc9312.c
new file mode 100644
index 00000000000..d18fcb1a2f1
--- /dev/null
+++ b/arch/arm/mach-ep93xx/gesbc9312.c
@@ -0,0 +1,40 @@
+/*
+ * arch/arm/mach-ep93xx/gesbc9312.c
+ * Glomation GESBC-9312-sx support.
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/mtd/physmap.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+
+static void __init gesbc9312_init_machine(void)
+{
+ ep93xx_init_devices();
+ physmap_configure(0x60000000, 0x00800000, 4, NULL);
+}
+
+MACHINE_START(GESBC9312, "Glomation GESBC-9312-sx")
+ /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
+ .phys_io = EP93XX_APB_PHYS_BASE,
+ .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .map_io = ep93xx_map_io,
+ .init_irq = ep93xx_init_irq,
+ .timer = &ep93xx_timer,
+ .init_machine = gesbc9312_init_machine,
+MACHINE_END
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
new file mode 100644
index 00000000000..777e75daa8a
--- /dev/null
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -0,0 +1,118 @@
+/*
+ * arch/arm/mach-ep93xx/ts72xx.c
+ * Technologic Systems TS72xx SBC support.
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/mtd/physmap.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/mach-types.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+
+static struct map_desc ts72xx_io_desc[] __initdata = {
+ {
+ .virtual = TS72XX_MODEL_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_MODEL_PHYS_BASE),
+ .length = TS72XX_MODEL_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_OPTIONS_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_OPTIONS_PHYS_BASE),
+ .length = TS72XX_OPTIONS_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_OPTIONS2_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_OPTIONS2_PHYS_BASE),
+ .length = TS72XX_OPTIONS2_SIZE,
+ .type = MT_DEVICE,
+ }
+};
+
+static struct map_desc ts72xx_nand_io_desc[] __initdata = {
+ {
+ .virtual = TS72XX_NAND_DATA_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND1_DATA_PHYS_BASE),
+ .length = TS72XX_NAND_DATA_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND1_CONTROL_PHYS_BASE),
+ .length = TS72XX_NAND_CONTROL_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND1_BUSY_PHYS_BASE),
+ .length = TS72XX_NAND_BUSY_SIZE,
+ .type = MT_DEVICE,
+ }
+};
+
+static struct map_desc ts72xx_alternate_nand_io_desc[] __initdata = {
+ {
+ .virtual = TS72XX_NAND_DATA_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND2_DATA_PHYS_BASE),
+ .length = TS72XX_NAND_DATA_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_NAND_CONTROL_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND2_CONTROL_PHYS_BASE),
+ .length = TS72XX_NAND_CONTROL_SIZE,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = TS72XX_NAND_BUSY_VIRT_BASE,
+ .pfn = __phys_to_pfn(TS72XX_NAND2_BUSY_PHYS_BASE),
+ .length = TS72XX_NAND_BUSY_SIZE,
+ .type = MT_DEVICE,
+ }
+};
+
+static void __init ts72xx_map_io(void)
+{
+ ep93xx_map_io();
+ iotable_init(ts72xx_io_desc, ARRAY_SIZE(ts72xx_io_desc));
+
+ /*
+ * The TS-7200 has NOR flash, the other models have NAND flash.
+ */
+ if (!board_is_ts7200()) {
+ if (is_ts9420_installed()) {
+ iotable_init(ts72xx_alternate_nand_io_desc,
+ ARRAY_SIZE(ts72xx_alternate_nand_io_desc));
+ } else {
+ iotable_init(ts72xx_nand_io_desc,
+ ARRAY_SIZE(ts72xx_nand_io_desc));
+ }
+ }
+}
+
+static void __init ts72xx_init_machine(void)
+{
+ ep93xx_init_devices();
+ if (board_is_ts7200())
+ physmap_configure(TS72XX_NOR_PHYS_BASE, 0x01000000, 1, NULL);
+}
+
+MACHINE_START(TS72XX, "Technologic Systems TS-72xx SBC")
+ /* Maintainer: Lennert Buytenhek <buytenh@wantstofly.org> */
+ .phys_io = EP93XX_APB_PHYS_BASE,
+ .io_pg_offst = ((EP93XX_APB_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .map_io = ts72xx_map_io,
+ .init_irq = ep93xx_init_irq,
+ .timer = &ep93xx_timer,
+ .init_machine = ts72xx_init_machine,
+MACHINE_END
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c
index e79884eea1f..5dace259783 100644
--- a/arch/arm/mach-footbridge/dc21285.c
+++ b/arch/arm/mach-footbridge/dc21285.c
@@ -255,14 +255,12 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
if (nr || !footbridge_cfn_mode())
return 0;
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
if (!res) {
printk("out of memory for root bus resources");
return 0;
}
- memset(res, 0, sizeof(struct resource) * 2);
-
res[0].flags = IORESOURCE_MEM;
res[0].name = "Footbridge non-prefetch";
res[1].flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index a85d471c5bf..92d79fb3931 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -355,12 +355,11 @@ static int impd1_probe(struct lm_device *dev)
if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers"))
return -EBUSY;
- impd1 = kmalloc(sizeof(struct impd1_module), GFP_KERNEL);
+ impd1 = kzalloc(sizeof(struct impd1_module), GFP_KERNEL);
if (!impd1) {
ret = -ENOMEM;
goto release_lm;
}
- memset(impd1, 0, sizeof(struct impd1_module));
impd1->base = ioremap(dev->resource.start, SZ_4K);
if (!impd1->base) {
@@ -389,12 +388,10 @@ static int impd1_probe(struct lm_device *dev)
pc_base = dev->resource.start + idev->offset;
- d = kmalloc(sizeof(struct amba_device), GFP_KERNEL);
+ d = kzalloc(sizeof(struct amba_device), GFP_KERNEL);
if (!d)
continue;
- memset(d, 0, sizeof(struct amba_device));
-
snprintf(d->dev.bus_id, sizeof(d->dev.bus_id),
"lm%x:%5.5lx", dev->id, idev->offset >> 12);
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index d8d3c2a5a97..6d65c96ebfd 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -319,12 +319,10 @@ static void __init ap_init(void)
if ((sc_dec & (16 << i)) == 0)
continue;
- lmdev = kmalloc(sizeof(struct lm_device), GFP_KERNEL);
+ lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
if (!lmdev)
continue;
- memset(lmdev, 0, sizeof(struct lm_device));
-
lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
lmdev->resource.flags = IORESOURCE_MEM;
diff --git a/arch/arm/mach-iop3xx/iq31244-pci.c b/arch/arm/mach-iop3xx/iq31244-pci.c
index c6a973ba8fc..f3c6413fa5b 100644
--- a/arch/arm/mach-iop3xx/iq31244-pci.c
+++ b/arch/arm/mach-iop3xx/iq31244-pci.c
@@ -74,12 +74,10 @@ static int iq31244_setup(int nr, struct pci_sys_data *sys)
if(nr != 0)
return 0;
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
if (!res)
panic("PCI: unable to alloc resources");
- memset(res, 0, sizeof(struct resource) * 2);
-
res[0].start = IOP321_PCI_LOWER_IO_VA;
res[0].end = IOP321_PCI_UPPER_IO_VA;
res[0].name = "IQ31244 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80321-pci.c b/arch/arm/mach-iop3xx/iq80321-pci.c
index 802f6d091b7..d9758d3f6e7 100644
--- a/arch/arm/mach-iop3xx/iq80321-pci.c
+++ b/arch/arm/mach-iop3xx/iq80321-pci.c
@@ -68,12 +68,10 @@ static int iq80321_setup(int nr, struct pci_sys_data *sys)
if(nr != 0)
return 0;
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
if (!res)
panic("PCI: unable to alloc resources");
- memset(res, 0, sizeof(struct resource) * 2);
-
res[0].start = IOP321_PCI_LOWER_IO_VA;
res[0].end = IOP321_PCI_UPPER_IO_VA;
res[0].name = "IQ80321 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80331-pci.c b/arch/arm/mach-iop3xx/iq80331-pci.c
index 654e450a131..40d86100249 100644
--- a/arch/arm/mach-iop3xx/iq80331-pci.c
+++ b/arch/arm/mach-iop3xx/iq80331-pci.c
@@ -64,12 +64,10 @@ static int iq80331_setup(int nr, struct pci_sys_data *sys)
if(nr != 0)
return 0;
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
if (!res)
panic("PCI: unable to alloc resources");
- memset(res, 0, sizeof(struct resource) * 2);
-
res[0].start = IOP331_PCI_LOWER_IO_VA;
res[0].end = IOP331_PCI_UPPER_IO_VA;
res[0].name = "IQ80331 PCI I/O Space";
diff --git a/arch/arm/mach-iop3xx/iq80332-pci.c b/arch/arm/mach-iop3xx/iq80332-pci.c
index 65951ffe463..afc0676318e 100644
--- a/arch/arm/mach-iop3xx/iq80332-pci.c
+++ b/arch/arm/mach-iop3xx/iq80332-pci.c
@@ -70,12 +70,10 @@ static int iq80332_setup(int nr, struct pci_sys_data *sys)
if(nr != 0)
return 0;
- res = kmalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
if (!res)
panic("PCI: unable to alloc resources");
- memset(res, 0, sizeof(struct resource) * 2);
-
res[0].start = IOP331_PCI_LOWER_IO_VA;
res[0].end = IOP331_PCI_UPPER_IO_VA;
res[0].name = "IQ80332 PCI I/O Space";
diff --git a/arch/arm/mach-ixp2000/Kconfig b/arch/arm/mach-ixp2000/Kconfig
index ecb58d83478..86f53f8ccbf 100644
--- a/arch/arm/mach-ixp2000/Kconfig
+++ b/arch/arm/mach-ixp2000/Kconfig
@@ -43,12 +43,17 @@ config ARCH_IXDP2401
this platform, see <file:Documentation/arm/IXP2000>.
config ARCH_IXDP2801
- bool "Support Intel IXDP2801"
+ bool "Support Intel IXDP2801 and IXDP28x5"
help
Say 'Y' here if you want your kernel to support the Intel
- IXDP2801 reference platform. For more information on
+ IXDP2801/2805/2855 reference platforms. For more information on
this platform, see <file:Documentation/arm/IXP2000>.
+config MACH_IXDP28X5
+ bool
+ depends on ARCH_IXDP2801
+ default y
+
config ARCH_IXDP2X01
bool
depends on ARCH_IXDP2401 || ARCH_IXDP2801
diff --git a/arch/arm/mach-ixp2000/Makefile b/arch/arm/mach-ixp2000/Makefile
index 9621aeb61f4..1e6139d42a9 100644
--- a/arch/arm/mach-ixp2000/Makefile
+++ b/arch/arm/mach-ixp2000/Makefile
@@ -1,7 +1,7 @@
#
# Makefile for the linux kernel.
#
-obj-y := core.o pci.o uengine.o
+obj-y := core.o pci.o
obj-m :=
obj-n :=
obj- :=
diff --git a/arch/arm/mach-ixp2000/core.c b/arch/arm/mach-ixp2000/core.c
index cfd5bef3190..6e8d504aca5 100644
--- a/arch/arm/mach-ixp2000/core.c
+++ b/arch/arm/mach-ixp2000/core.c
@@ -288,8 +288,6 @@ void gpio_line_config(int line, int direction)
local_irq_save(flags);
if (direction == GPIO_OUT) {
- irq_desc[line + IRQ_IXP2000_GPIO0].valid = 0;
-
/* if it's an output, it ain't an interrupt anymore */
GPIO_IRQ_falling_edge &= ~(1 << line);
GPIO_IRQ_rising_edge &= ~(1 << line);
@@ -351,11 +349,6 @@ static int ixp2000_GPIO_irq_type(unsigned int irq, unsigned int type)
GPIO_IRQ_level_high &= ~(1 << line);
update_gpio_int_csrs();
- /*
- * Finally, mark the corresponding IRQ as valid.
- */
- irq_desc[irq].valid = 1;
-
return 0;
}
@@ -506,14 +499,10 @@ void __init ixp2000_init_irq(void)
}
set_irq_chained_handler(IRQ_IXP2000_ERRSUM, ixp2000_err_irq_handler);
- /*
- * GPIO IRQs are invalid until someone sets the interrupt mode
- * by calling set_irq_type().
- */
for (irq = IRQ_IXP2000_GPIO0; irq <= IRQ_IXP2000_GPIO7; irq++) {
set_irq_chip(irq, &ixp2000_GPIO_irq_chip);
set_irq_handler(irq, do_level_IRQ);
- set_irq_flags(irq, 0);
+ set_irq_flags(irq, IRQF_VALID);
}
set_irq_chained_handler(IRQ_IXP2000_GPIO, ixp2000_GPIO_irq_handler);
diff --git a/arch/arm/mach-ixp2000/ixdp2x01.c b/arch/arm/mach-ixp2000/ixdp2x01.c
index 150519fb38e..f9d4968c1d6 100644
--- a/arch/arm/mach-ixp2000/ixdp2x01.c
+++ b/arch/arm/mach-ixp2000/ixdp2x01.c
@@ -284,7 +284,7 @@ static int ixdp2x01_pci_setup(int nr, struct pci_sys_data *sys)
{
sys->mem_offset = 0xe0000000;
- if (machine_is_ixdp2801())
+ if (machine_is_ixdp2801() || machine_is_ixdp28x5())
sys->mem_offset -= ((*IXP2000_PCI_ADDR_EXT & 0xE000) << 16);
return ixp2000_pci_setup(nr, sys);
@@ -300,7 +300,8 @@ struct hw_pci ixdp2x01_pci __initdata = {
int __init ixdp2x01_pci_init(void)
{
- if (machine_is_ixdp2401() || machine_is_ixdp2801())
+ if (machine_is_ixdp2401() || machine_is_ixdp2801() ||\
+ machine_is_ixdp28x5())
pci_common_init(&ixdp2x01_pci);
return 0;
@@ -400,6 +401,21 @@ MACHINE_START(IXDP2801, "Intel IXDP2801 Development Platform")
.timer = &ixdp2x01_timer,
.init_machine = ixdp2x01_init_machine,
MACHINE_END
+
+/*
+ * IXDP28x5 is basically an IXDP2801 with a different CPU but Intel
+ * changed the machine ID in the bootloader
+ */
+MACHINE_START(IXDP28X5, "Intel IXDP2805/2855 Development Platform")
+ /* Maintainer: MontaVista Software, Inc. */
+ .phys_io = IXP2000_UART_PHYS_BASE,
+ .io_pg_offst = ((IXP2000_UART_VIRT_BASE) >> 18) & 0xfffc,
+ .boot_params = 0x00000100,
+ .map_io = ixdp2x01_map_io,
+ .init_irq = ixdp2x01_init_irq,
+ .timer = &ixdp2x01_timer,
+ .init_machine = ixdp2x01_init_machine,
+MACHINE_END
#endif
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c
index 6e3462ed530..2d40fe1145f 100644
--- a/arch/arm/mach-ixp4xx/common-pci.c
+++ b/arch/arm/mach-ixp4xx/common-pci.c
@@ -463,7 +463,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
if (nr >= 1)
return 0;
- res = kmalloc(sizeof(*res) * 2, GFP_KERNEL);
+ res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
if (res == NULL) {
/*
* If we're out of memory this early, something is wrong,
@@ -471,7 +471,6 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
*/
panic("PCI: unable to allocate resources?\n");
}
- memset(res, 0, sizeof(*res) * 2);
local_write_config(PCI_COMMAND, 2, PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY);
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index fbadf3021b9..a0888e160e3 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -91,7 +91,7 @@ static void ixp4xx_config_irq(unsigned irq, enum ixp4xx_irq_type type);
/*
* IRQ -> GPIO mapping table
*/
-static int irq2gpio[32] = {
+static char irq2gpio[32] = {
-1, -1, -1, -1, -1, -1, 0, 1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 2, 3, 4, 5, 6,
@@ -153,6 +153,9 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
/* Set the new style */
*int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
+ /* Configure the line as an input */
+ gpio_line_config(line, IXP4XX_GPIO_IN);
+
return 0;
}
diff --git a/arch/arm/mach-lh7a40x/common.h b/arch/arm/mach-lh7a40x/common.h
index 578a52461fd..ea8de7e3ab1 100644
--- a/arch/arm/mach-lh7a40x/common.h
+++ b/arch/arm/mach-lh7a40x/common.h
@@ -12,5 +12,6 @@ extern struct sys_timer lh7a40x_timer;
extern void lh7a400_init_irq (void);
extern void lh7a404_init_irq (void);
+extern void lh7a40x_init_board_irq (void);
#define IRQ_DISPATCH(irq) desc_handle_irq((irq),(irq_desc + irq), regs)
diff --git a/arch/arm/mach-lh7a40x/irq-kev7a400.c b/arch/arm/mach-lh7a40x/irq-kev7a400.c
index 691bb09232a..8535764d89c 100644
--- a/arch/arm/mach-lh7a40x/irq-kev7a400.c
+++ b/arch/arm/mach-lh7a40x/irq-kev7a400.c
@@ -16,6 +16,7 @@
#include <asm/mach/hardware.h>
#include <asm/mach/irqs.h>
+#include "common.h"
/* KEV7a400 CPLD IRQ handling */
diff --git a/arch/arm/mach-lh7a40x/irq-lh7a400.c b/arch/arm/mach-lh7a40x/irq-lh7a400.c
index f334d81c2cd..f9fdefef6d6 100644
--- a/arch/arm/mach-lh7a40x/irq-lh7a400.c
+++ b/arch/arm/mach-lh7a40x/irq-lh7a400.c
@@ -16,9 +16,9 @@
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
-#include <asm/arch/irq.h>
#include <asm/arch/irqs.h>
+#include "common.h"
/* CPU IRQ handling */
diff --git a/arch/arm/mach-lh7a40x/irq-lh7a404.c b/arch/arm/mach-lh7a40x/irq-lh7a404.c
index 122fadabc97..e902e3d87da 100644
--- a/arch/arm/mach-lh7a40x/irq-lh7a404.c
+++ b/arch/arm/mach-lh7a40x/irq-lh7a404.c
@@ -16,9 +16,10 @@
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/mach/irq.h>
-#include <asm/arch/irq.h>
#include <asm/arch/irqs.h>
+#include "common.h"
+
#define USE_PRIORITIES
/* See Documentation/arm/Sharp-LH/VectoredInterruptController for more
diff --git a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
index 6262d449120..dcb4e17b941 100644
--- a/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
+++ b/arch/arm/mach-lh7a40x/irq-lpd7a40x.c
@@ -19,6 +19,7 @@
#include <asm/mach/irq.h>
#include <asm/arch/irqs.h>
+#include "common.h"
static void lh7a40x_ack_cpld_irq (u32 irq)
{
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 32526a0a6f8..382644401a4 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -3,7 +3,7 @@
#
# Common support (must be linked before board specific support)
-obj-y += generic.o irq.o dma.o time.o
+obj-y += clock.o generic.o irq.o dma.o time.o
obj-$(CONFIG_PXA25x) += pxa25x.o
obj-$(CONFIG_PXA27x) += pxa27x.o
diff --git a/arch/arm/mach-pxa/clock.c b/arch/arm/mach-pxa/clock.c
new file mode 100644
index 00000000000..8f7c90a0593
--- /dev/null
+++ b/arch/arm/mach-pxa/clock.c
@@ -0,0 +1,124 @@
+/*
+ * linux/arch/arm/mach-sa1100/clock.c
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/clk.h>
+#include <linux/spinlock.h>
+
+#include <asm/arch/pxa-regs.h>
+#include <asm/hardware.h>
+#include <asm/semaphore.h>
+
+struct clk {
+ struct list_head node;
+ unsigned long rate;
+ struct module *owner;
+ const char *name;
+ unsigned int enabled;
+ void (*enable)(void);
+ void (*disable)(void);
+};
+
+static LIST_HEAD(clocks);
+static DECLARE_MUTEX(clocks_sem);
+static DEFINE_SPINLOCK(clocks_lock);
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+ struct clk *p, *clk = ERR_PTR(-ENOENT);
+
+ down(&clocks_sem);
+ list_for_each_entry(p, &clocks, node) {
+ if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+ clk = p;
+ break;
+ }
+ }
+ up(&clocks_sem);
+
+ return clk;
+}
+EXPORT_SYMBOL(clk_get);
+
+void clk_put(struct clk *clk)
+{
+ module_put(clk->owner);
+}
+EXPORT_SYMBOL(clk_put);
+
+int clk_enable(struct clk *clk)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&clocks_lock, flags);
+ if (clk->enabled++ == 0)
+ clk->enable();
+ spin_unlock_irqrestore(&clocks_lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL(clk_enable);
+
+void clk_disable(struct clk *clk)
+{
+ unsigned long flags;
+
+ WARN_ON(clk->enabled == 0);
+
+ spin_lock_irqsave(&clocks_lock, flags);
+ if (--clk->enabled == 0)
+ clk->disable();
+ spin_unlock_irqrestore(&clocks_lock, flags);
+}
+EXPORT_SYMBOL(clk_disable);
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+ return clk->rate;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
+
+static void clk_gpio27_enable(void)
+{
+ pxa_gpio_mode(GPIO11_3_6MHz_MD);
+}
+
+static void clk_gpio27_disable(void)
+{
+}
+
+static struct clk clk_gpio27 = {
+ .name = "GPIO27_CLK",
+ .rate = 3686400,
+ .enable = clk_gpio27_enable,
+ .disable = clk_gpio27_disable,
+};
+
+int clk_register(struct clk *clk)
+{
+ down(&clocks_sem);
+ list_add(&clk->node, &clocks);
+ up(&clocks_sem);
+ return 0;
+}
+EXPORT_SYMBOL(clk_register);
+
+void clk_unregister(struct clk *clk)
+{
+ down(&clocks_sem);
+ list_del(&clk->node);
+ up(&clocks_sem);
+}
+EXPORT_SYMBOL(clk_unregister);
+
+static int __init clk_init(void)
+{
+ clk_register(&clk_gpio27);
+ return 0;
+}
+arch_initcall(clk_init);
diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c
index 7ffd2de8f2f..68923b1d2b6 100644
--- a/arch/arm/mach-pxa/corgi.c
+++ b/arch/arm/mach-pxa/corgi.c
@@ -32,7 +32,6 @@
#include <asm/mach/irq.h>
#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irq.h>
#include <asm/arch/irda.h>
#include <asm/arch/mmc.h>
#include <asm/arch/udc.h>
diff --git a/arch/arm/mach-pxa/leds-mainstone.c b/arch/arm/mach-pxa/leds-mainstone.c
index bbd3f87a9fc..c06d3d7a8dd 100644
--- a/arch/arm/mach-pxa/leds-mainstone.c
+++ b/arch/arm/mach-pxa/leds-mainstone.c
@@ -85,7 +85,7 @@ void mainstone_leds_event(led_event_t evt)
break;
case led_green_on:
- hw_led_state |= D21;;
+ hw_led_state |= D21;
break;
case led_green_off:
@@ -93,7 +93,7 @@ void mainstone_leds_event(led_event_t evt)
break;
case led_amber_on:
- hw_led_state |= D22;;
+ hw_led_state |= D22;
break;
case led_amber_off:
@@ -101,7 +101,7 @@ void mainstone_leds_event(led_event_t evt)
break;
case led_red_on:
- hw_led_state |= D23;;
+ hw_led_state |= D23;
break;
case led_red_off:
diff --git a/arch/arm/mach-pxa/poodle.c b/arch/arm/mach-pxa/poodle.c
index 911e6ff5a9b..b45560a8f6c 100644
--- a/arch/arm/mach-pxa/poodle.c
+++ b/arch/arm/mach-pxa/poodle.c
@@ -29,7 +29,6 @@
#include <asm/mach/irq.h>
#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irq.h>
#include <asm/arch/mmc.h>
#include <asm/arch/udc.h>
#include <asm/arch/irda.h>
diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c
index c094d99ebf5..30ec317bbb9 100644
--- a/arch/arm/mach-pxa/spitz.c
+++ b/arch/arm/mach-pxa/spitz.c
@@ -33,7 +33,6 @@
#include <asm/mach/irq.h>
#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irq.h>
#include <asm/arch/irda.h>
#include <asm/arch/mmc.h>
#include <asm/arch/ohci.h>
diff --git a/arch/arm/mach-pxa/tosa.c b/arch/arm/mach-pxa/tosa.c
index d168286ed47..66ec71756d0 100644
--- a/arch/arm/mach-pxa/tosa.c
+++ b/arch/arm/mach-pxa/tosa.c
@@ -34,7 +34,6 @@
#include <asm/mach/irq.h>
#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irq.h>
#include <asm/arch/tosa.h>
#include <asm/hardware/scoop.h>
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index 0b9d7ca49ec..ed07c4149d8 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -9,6 +9,13 @@ config MACH_ANUBIS
Say Y gere if you are using the Simtec Electronics ANUBIS
development system
+config MACH_OSIRIS
+ bool "Simtec IM2440D20 (OSIRIS) module"
+ select CPU_S3C2440
+ help
+ Say Y here if you are using the Simtec IM2440D20 module, also
+ known as the Osiris.
+
config ARCH_BAST
bool "Simtec Electronics BAST (EB2410ITX)"
select CPU_S3C2410
diff --git a/arch/arm/mach-s3c2410/Makefile b/arch/arm/mach-s3c2410/Makefile
index 1217bf00309..1b3b476e563 100644
--- a/arch/arm/mach-s3c2410/Makefile
+++ b/arch/arm/mach-s3c2410/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_BAST_PC104_IRQ) += bast-irq.o
# machine specific support
obj-$(CONFIG_MACH_ANUBIS) += mach-anubis.o
+obj-$(CONFIG_MACH_OSIRIS) += mach-osiris.o
obj-$(CONFIG_ARCH_BAST) += mach-bast.o usb-simtec.o
obj-$(CONFIG_ARCH_H1940) += mach-h1940.o
obj-$(CONFIG_MACH_N30) += mach-n30.o
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index 08489efdaf0..fec02c92f95 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -38,12 +38,14 @@
#include <linux/ioport.h>
#include <linux/clk.h>
#include <linux/mutex.h>
+#include <linux/delay.h>
#include <asm/hardware.h>
#include <asm/irq.h>
#include <asm/io.h>
#include <asm/arch/regs-clock.h>
+#include <asm/arch/regs-gpio.h>
#include "clock.h"
#include "cpu.h"
@@ -51,7 +53,8 @@
/* clock information */
static LIST_HEAD(clocks);
-static DEFINE_MUTEX(clocks_mutex);
+
+DEFINE_MUTEX(clocks_mutex);
/* old functions */
@@ -178,12 +181,24 @@ unsigned long clk_get_rate(struct clk *clk)
long clk_round_rate(struct clk *clk, unsigned long rate)
{
+ if (!IS_ERR(clk) && clk->round_rate)
+ return (clk->round_rate)(clk, rate);
+
return rate;
}
int clk_set_rate(struct clk *clk, unsigned long rate)
{
- return -EINVAL;
+ int ret;
+
+ if (IS_ERR(clk))
+ return -EINVAL;
+
+ mutex_lock(&clocks_mutex);
+ ret = (clk->set_rate)(clk, rate);
+ mutex_unlock(&clocks_mutex);
+
+ return ret;
}
struct clk *clk_get_parent(struct clk *clk)
@@ -191,6 +206,23 @@ struct clk *clk_get_parent(struct clk *clk)
return clk->parent;
}
+int clk_set_parent(struct clk *clk, struct clk *parent)
+{
+ int ret = 0;
+
+ if (IS_ERR(clk))
+ return -EINVAL;
+
+ mutex_lock(&clocks_mutex);
+
+ if (clk->set_parent)
+ ret = (clk->set_parent)(clk, parent);
+
+ mutex_unlock(&clocks_mutex);
+
+ return ret;
+}
+
EXPORT_SYMBOL(clk_get);
EXPORT_SYMBOL(clk_put);
EXPORT_SYMBOL(clk_enable);
@@ -199,6 +231,29 @@ EXPORT_SYMBOL(clk_get_rate);
EXPORT_SYMBOL(clk_round_rate);
EXPORT_SYMBOL(clk_set_rate);
EXPORT_SYMBOL(clk_get_parent);
+EXPORT_SYMBOL(clk_set_parent);
+
+/* base clock enable */
+
+static int s3c24xx_upll_enable(struct clk *clk, int enable)
+{
+ unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
+ unsigned long orig = clkslow;
+
+ if (enable)
+ clkslow &= ~S3C2410_CLKSLOW_UCLK_OFF;
+ else
+ clkslow |= S3C2410_CLKSLOW_UCLK_OFF;
+
+ __raw_writel(clkslow, S3C2410_CLKSLOW);
+
+ /* if we started the UPLL, then allow to settle */
+
+ if (enable && !(orig & S3C2410_CLKSLOW_UCLK_OFF))
+ udelay(200);
+
+ return 0;
+}
/* base clocks */
@@ -210,6 +265,14 @@ static struct clk clk_xtal = {
.ctrlbit = 0,
};
+static struct clk clk_upll = {
+ .name = "upll",
+ .id = -1,
+ .parent = NULL,
+ .enable = s3c24xx_upll_enable,
+ .ctrlbit = 0,
+};
+
static struct clk clk_f = {
.name = "fclk",
.id = -1,
@@ -234,26 +297,124 @@ static struct clk clk_p = {
.ctrlbit = 0,
};
+struct clk clk_usb_bus = {
+ .name = "usb-bus",
+ .id = -1,
+ .rate = 0,
+ .parent = &clk_upll,
+};
+
/* clocks that could be registered by external code */
+static int s3c24xx_dclk_enable(struct clk *clk, int enable)
+{
+ unsigned long dclkcon = __raw_readl(S3C2410_DCLKCON);
+
+ if (enable)
+ dclkcon |= clk->ctrlbit;
+ else
+ dclkcon &= ~clk->ctrlbit;
+
+ __raw_writel(dclkcon, S3C2410_DCLKCON);
+
+ return 0;
+}
+
+static int s3c24xx_dclk_setparent(struct clk *clk, struct clk *parent)
+{
+ unsigned long dclkcon;
+ unsigned int uclk;
+
+ if (parent == &clk_upll)
+ uclk = 1;
+ else if (parent == &clk_p)
+ uclk = 0;
+ else
+ return -EINVAL;
+
+ clk->parent = parent;
+
+ dclkcon = __raw_readl(S3C2410_DCLKCON);
+
+ if (clk->ctrlbit == S3C2410_DCLKCON_DCLK0EN) {
+ if (uclk)
+ dclkcon |= S3C2410_DCLKCON_DCLK0_UCLK;
+ else
+ dclkcon &= ~S3C2410_DCLKCON_DCLK0_UCLK;
+ } else {
+ if (uclk)
+ dclkcon |= S3C2410_DCLKCON_DCLK1_UCLK;
+ else
+ dclkcon &= ~S3C2410_DCLKCON_DCLK1_UCLK;
+ }
+
+ __raw_writel(dclkcon, S3C2410_DCLKCON);
+
+ return 0;
+}
+
+
+static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
+{
+ unsigned long mask;
+ unsigned long source;
+
+ /* calculate the MISCCR setting for the clock */
+
+ if (parent == &clk_xtal)
+ source = S3C2410_MISCCR_CLK0_MPLL;
+ else if (parent == &clk_upll)
+ source = S3C2410_MISCCR_CLK0_UPLL;
+ else if (parent == &clk_f)
+ source = S3C2410_MISCCR_CLK0_FCLK;
+ else if (parent == &clk_p)
+ source = S3C2410_MISCCR_CLK0_PCLK;
+ else if (clk == &s3c24xx_clkout0 && parent == &s3c24xx_dclk0)
+ source = S3C2410_MISCCR_CLK0_DCLK0;
+ else if (clk == &s3c24xx_clkout1 && parent == &s3c24xx_dclk1)
+ source = S3C2410_MISCCR_CLK0_DCLK0;
+ else
+ return -EINVAL;
+
+ if (clk == &s3c24xx_dclk0)
+ mask = S3C2410_MISCCR_CLK0_MASK;
+ else {
+ source <<= 4;
+ mask = S3C2410_MISCCR_CLK1_MASK;
+ }
+
+ s3c2410_modify_misccr(mask, source);
+ return 0;
+}
+
+/* external clock definitions */
+
struct clk s3c24xx_dclk0 = {
.name = "dclk0",
.id = -1,
+ .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
+ .enable = s3c24xx_dclk_enable,
+ .set_parent = s3c24xx_dclk_setparent,
};
struct clk s3c24xx_dclk1 = {
.name = "dclk1",
.id = -1,
+ .ctrlbit = S3C2410_DCLKCON_DCLK0EN,
+ .enable = s3c24xx_dclk_enable,
+ .set_parent = s3c24xx_dclk_setparent,
};
struct clk s3c24xx_clkout0 = {
.name = "clkout0",
.id = -1,
+ .set_parent = s3c24xx_clkout_setparent,
};
struct clk s3c24xx_clkout1 = {
.name = "clkout1",
.id = -1,
+ .set_parent = s3c24xx_clkout_setparent,
};
struct clk s3c24xx_uclk = {
@@ -262,7 +423,7 @@ struct clk s3c24xx_uclk = {
};
-/* clock definitions */
+/* standard clock definitions */
static struct clk init_clocks[] = {
{
@@ -374,7 +535,7 @@ int s3c24xx_register_clock(struct clk *clk)
/* if this is a standard clock, set the usage state */
- if (clk->ctrlbit) {
+ if (clk->ctrlbit && clk->enable == s3c24xx_clkcon_enable) {
unsigned long clkcon = __raw_readl(S3C2410_CLKCON);
clk->usage = (clkcon & clk->ctrlbit) ? 1 : 0;
@@ -396,6 +557,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
unsigned long hclk,
unsigned long pclk)
{
+ unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
unsigned long clkslow = __raw_readl(S3C2410_CLKSLOW);
struct clk *clkp = init_clocks;
int ptr;
@@ -406,6 +568,7 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
/* initialise the main system clocks */
clk_xtal.rate = xtal;
+ clk_upll.rate = s3c2410_get_pll(upllcon, xtal);
clk_h.rate = hclk;
clk_p.rate = pclk;
@@ -439,6 +602,9 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
if (s3c24xx_register_clock(&clk_xtal) < 0)
printk(KERN_ERR "failed to register master xtal\n");
+ if (s3c24xx_register_clock(&clk_upll) < 0)
+ printk(KERN_ERR "failed to register upll clock\n");
+
if (s3c24xx_register_clock(&clk_f) < 0)
printk(KERN_ERR "failed to register cpu fclk\n");
@@ -448,6 +614,10 @@ int __init s3c24xx_setup_clocks(unsigned long xtal,
if (s3c24xx_register_clock(&clk_p) < 0)
printk(KERN_ERR "failed to register cpu pclk\n");
+
+ if (s3c24xx_register_clock(&clk_usb_bus) < 0)
+ printk(KERN_ERR "failed to register usb bus clock\n");
+
/* register clocks from clock array */
for (ptr = 0; ptr < ARRAY_SIZE(init_clocks); ptr++, clkp++) {
diff --git a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h
index eb5c95d1e7f..01bb458bf8e 100644
--- a/arch/arm/mach-s3c2410/clock.h
+++ b/arch/arm/mach-s3c2410/clock.h
@@ -19,7 +19,11 @@ struct clk {
int usage;
unsigned long rate;
unsigned long ctrlbit;
+
int (*enable)(struct clk *, int enable);
+ int (*set_rate)(struct clk *c, unsigned long rate);
+ unsigned long (*round_rate)(struct clk *c, unsigned long rate);
+ int (*set_parent)(struct clk *c, struct clk *parent);
};
/* other clocks which may be registered by board support */
@@ -30,11 +34,15 @@ extern struct clk s3c24xx_clkout0;
extern struct clk s3c24xx_clkout1;
extern struct clk s3c24xx_uclk;
+extern struct clk clk_usb_bus;
+
/* exports for arch/arm/mach-s3c2410
*
* Please DO NOT use these outside of arch/arm/mach-s3c2410
*/
+extern struct mutex clocks_mutex;
+
extern int s3c24xx_clkcon_enable(struct clk *clk, int enable);
extern int s3c24xx_register_clock(struct clk *clk);
diff --git a/arch/arm/mach-s3c2410/cpu.c b/arch/arm/mach-s3c2410/cpu.c
index 00a379334b6..70c34fcf785 100644
--- a/arch/arm/mach-s3c2410/cpu.c
+++ b/arch/arm/mach-s3c2410/cpu.c
@@ -146,7 +146,7 @@ void s3c24xx_set_board(struct s3c24xx_board *b)
board = b;
if (b->clocks_count != 0) {
- struct clk **ptr = b->clocks;;
+ struct clk **ptr = b->clocks;
for (i = b->clocks_count; i > 0; i--, ptr++)
s3c24xx_register_clock(*ptr);
diff --git a/arch/arm/mach-s3c2410/mach-osiris.c b/arch/arm/mach-s3c2410/mach-osiris.c
new file mode 100644
index 00000000000..ae078755775
--- /dev/null
+++ b/arch/arm/mach-s3c2410/mach-osiris.c
@@ -0,0 +1,294 @@
+/* linux/arch/arm/mach-s3c2410/mach-osiris.c
+ *
+ * Copyright (c) 2005 Simtec Electronics
+ * http://armlinux.simtec.co.uk/
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/timer.h>
+#include <linux/init.h>
+#include <linux/device.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/map.h>
+#include <asm/mach/irq.h>
+
+#include <asm/arch/osiris-map.h>
+#include <asm/arch/osiris-cpld.h>
+
+#include <asm/hardware.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/regs-serial.h>
+#include <asm/arch/regs-gpio.h>
+#include <asm/arch/regs-mem.h>
+#include <asm/arch/regs-lcd.h>
+#include <asm/arch/nand.h>
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/nand.h>
+#include <linux/mtd/nand_ecc.h>
+#include <linux/mtd/partitions.h>
+
+#include "clock.h"
+#include "devs.h"
+#include "cpu.h"
+
+/* onboard perihpheral map */
+
+static struct map_desc osiris_iodesc[] __initdata = {
+ /* ISA IO areas (may be over-written later) */
+
+ {
+ .virtual = (u32)S3C24XX_VA_ISA_BYTE,
+ .pfn = __phys_to_pfn(S3C2410_CS5),
+ .length = SZ_16M,
+ .type = MT_DEVICE,
+ }, {
+ .virtual = (u32)S3C24XX_VA_ISA_WORD,
+ .pfn = __phys_to_pfn(S3C2410_CS5),
+ .length = SZ_16M,
+ .type = MT_DEVICE,
+ },
+
+ /* CPLD control registers */
+
+ {
+ .virtual = (u32)OSIRIS_VA_CTRL1,
+ .pfn = __phys_to_pfn(OSIRIS_PA_CTRL1),
+ .length = SZ_16K,
+ .type = MT_DEVICE
+ }, {
+ .virtual = (u32)OSIRIS_VA_CTRL2,
+ .pfn = __phys_to_pfn(OSIRIS_PA_CTRL2),
+ .length = SZ_16K,
+ .type = MT_DEVICE
+ },
+};
+
+#define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
+#define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
+#define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
+
+static struct s3c24xx_uart_clksrc osiris_serial_clocks[] = {
+ [0] = {
+ .name = "uclk",
+ .divisor = 1,
+ .min_baud = 0,
+ .max_baud = 0,
+ },
+ [1] = {
+ .name = "pclk",
+ .divisor = 1,
+ .min_baud = 0,
+ .max_baud = 0.
+ }
+};
+
+
+static struct s3c2410_uartcfg osiris_uartcfgs[] = {
+ [0] = {
+ .hwport = 0,
+ .flags = 0,
+ .ucon = UCON,
+ .ulcon = ULCON,
+ .ufcon = UFCON,
+ .clocks = osiris_serial_clocks,
+ .clocks_size = ARRAY_SIZE(osiris_serial_clocks)
+ },
+ [1] = {
+ .hwport = 2,
+ .flags = 0,
+ .ucon = UCON,
+ .ulcon = ULCON,
+ .ufcon = UFCON,
+ .clocks = osiris_serial_clocks,
+ .clocks_size = ARRAY_SIZE(osiris_serial_clocks)
+ },
+};
+
+/* NAND Flash on Osiris board */
+
+static int external_map[] = { 2 };
+static int chip0_map[] = { 0 };
+static int chip1_map[] = { 1 };
+
+static struct mtd_partition osiris_default_nand_part[] = {
+ [0] = {
+ .name = "Boot Agent",
+ .size = SZ_16K,
+ .offset = 0
+ },
+ [1] = {
+ .name = "/boot",
+ .size = SZ_4M - SZ_16K,
+ .offset = SZ_16K,
+ },
+ [2] = {
+ .name = "user1",
+ .offset = SZ_4M,
+ .size = SZ_32M - SZ_4M,
+ },
+ [3] = {
+ .name = "user2",
+ .offset = SZ_32M,
+ .size = MTDPART_SIZ_FULL,
+ }
+};
+
+/* the Osiris has 3 selectable slots for nand-flash, the two
+ * on-board chip areas, as well as the external slot.
+ *
+ * Note, there is no current hot-plug support for the External
+ * socket.
+*/
+
+static struct s3c2410_nand_set osiris_nand_sets[] = {
+ [1] = {
+ .name = "External",
+ .nr_chips = 1,
+ .nr_map = external_map,
+ .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
+ .partitions = osiris_default_nand_part
+ },
+ [0] = {
+ .name = "chip0",
+ .nr_chips = 1,
+ .nr_map = chip0_map,
+ .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
+ .partitions = osiris_default_nand_part
+ },
+ [2] = {
+ .name = "chip1",
+ .nr_chips = 1,
+ .nr_map = chip1_map,
+ .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
+ .partitions = osiris_default_nand_part
+ },
+};
+
+static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
+{
+ unsigned int tmp;
+
+ slot = set->nr_map[slot] & 3;
+
+ pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
+ slot, set, set->nr_map);
+
+ tmp = __raw_readb(OSIRIS_VA_CTRL1);
+ tmp &= ~OSIRIS_CTRL1_NANDSEL;
+ tmp |= slot;
+
+ pr_debug("osiris_nand: ctrl1 now %02x\n", tmp);
+
+ __raw_writeb(tmp, OSIRIS_VA_CTRL1);
+}
+
+static struct s3c2410_platform_nand osiris_nand_info = {
+ .tacls = 25,
+ .twrph0 = 60,
+ .twrph1 = 60,
+ .nr_sets = ARRAY_SIZE(osiris_nand_sets),
+ .sets = osiris_nand_sets,
+ .select_chip = osiris_nand_select,
+};
+
+/* PCMCIA control and configuration */
+
+static struct resource osiris_pcmcia_resource[] = {
+ [0] = {
+ .start = 0x0f000000,
+ .end = 0x0f100000,
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = {
+ .start = 0x0c000000,
+ .end = 0x0c100000,
+ .flags = IORESOURCE_MEM,
+ }
+};
+
+static struct platform_device osiris_pcmcia = {
+ .name = "osiris-pcmcia",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
+ .resource = osiris_pcmcia_resource,
+};
+
+/* Standard Osiris devices */
+
+static struct platform_device *osiris_devices[] __initdata = {
+ &s3c_device_i2c,
+ &s3c_device_nand,
+ &osiris_pcmcia,
+};
+
+static struct clk *osiris_clocks[] = {
+ &s3c24xx_dclk0,
+ &s3c24xx_dclk1,
+ &s3c24xx_clkout0,
+ &s3c24xx_clkout1,
+ &s3c24xx_uclk,
+};
+
+static struct s3c24xx_board osiris_board __initdata = {
+ .devices = osiris_devices,
+ .devices_count = ARRAY_SIZE(osiris_devices),
+ .clocks = osiris_clocks,
+ .clocks_count = ARRAY_SIZE(osiris_clocks)
+};
+
+static void __init osiris_map_io(void)
+{
+ unsigned long flags;
+
+ /* initialise the clocks */
+
+ s3c24xx_dclk0.parent = NULL;
+ s3c24xx_dclk0.rate = 12*1000*1000;
+
+ s3c24xx_dclk1.parent = NULL;
+ s3c24xx_dclk1.rate = 24*1000*1000;
+
+ s3c24xx_clkout0.parent = &s3c24xx_dclk0;
+ s3c24xx_clkout1.parent = &s3c24xx_dclk1;
+
+ s3c24xx_uclk.parent = &s3c24xx_clkout1;
+
+ s3c_device_nand.dev.platform_data = &osiris_nand_info;
+
+ s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
+ s3c24xx_init_clocks(0);
+ s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
+ s3c24xx_set_board(&osiris_board);
+
+ /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
+
+ local_irq_save(flags);
+ __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
+ local_irq_restore(flags);
+
+ /* write-protect line to the NAND */
+ s3c2410_gpio_setpin(S3C2410_GPA0, 1);
+}
+
+MACHINE_START(OSIRIS, "Simtec-OSIRIS")
+ /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
+ .phys_io = S3C2410_PA_UART,
+ .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
+ .boot_params = S3C2410_SDRAM_PA + 0x100,
+ .map_io = osiris_map_io,
+ .init_irq = s3c24xx_init_irq,
+ .timer = &s3c24xx_timer,
+MACHINE_END
diff --git a/arch/arm/mach-s3c2410/s3c2440-clock.c b/arch/arm/mach-s3c2410/s3c2440-clock.c
index b557a2be8a0..57a15974d4b 100644
--- a/arch/arm/mach-s3c2410/s3c2440-clock.c
+++ b/arch/arm/mach-s3c2410/s3c2440-clock.c
@@ -31,6 +31,7 @@
#include <linux/sysdev.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
+#include <linux/mutex.h>
#include <linux/clk.h>
#include <asm/hardware.h>
@@ -45,10 +46,47 @@
/* S3C2440 extended clock support */
-static struct clk s3c2440_clk_upll = {
- .name = "upll",
- .id = -1,
-};
+static unsigned long s3c2440_camif_upll_round(struct clk *clk,
+ unsigned long rate)
+{
+ unsigned long parent_rate = clk_get_rate(clk->parent);
+ int div;
+
+ if (rate > parent_rate)
+ return parent_rate;
+
+ /* note, we remove the +/- 1 calculations for the divisor */
+
+ div = (parent_rate / rate) / 2;
+
+ if (div < 1)
+ div = 1;
+ else if (div > 16)
+ div = 16;
+
+ return parent_rate / (div * 2);
+}
+
+static int s3c2440_camif_upll_setrate(struct clk *clk, unsigned long rate)
+{
+ unsigned long parent_rate = clk_get_rate(clk->parent);
+ unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
+
+ rate = s3c2440_camif_upll_round(clk, rate);
+
+ camdivn &= ~(S3C2440_CAMDIVN_CAMCLK_SEL | S3C2440_CAMDIVN_CAMCLK_MASK);
+
+ if (rate != parent_rate) {
+ camdivn |= S3C2440_CAMDIVN_CAMCLK_SEL;
+ camdivn |= (((parent_rate / rate) / 2) - 1);
+ }
+
+ __raw_writel(camdivn, S3C2440_CAMDIVN);
+
+ return 0;
+}
+
+/* Extra S3C2440 clocks */
static struct clk s3c2440_clk_cam = {
.name = "camif",
@@ -57,6 +95,13 @@ static struct clk s3c2440_clk_cam = {
.ctrlbit = S3C2440_CLKCON_CAMERA,
};
+static struct clk s3c2440_clk_cam_upll = {
+ .name = "camif-upll",
+ .id = -1,
+ .set_rate = s3c2440_camif_upll_setrate,
+ .round_rate = s3c2440_camif_upll_round,
+};
+
static struct clk s3c2440_clk_ac97 = {
.name = "ac97",
.id = -1,
@@ -66,38 +111,46 @@ static struct clk s3c2440_clk_ac97 = {
static int s3c2440_clk_add(struct sys_device *sysdev)
{
- unsigned long upllcon = __raw_readl(S3C2410_UPLLCON);
unsigned long camdivn = __raw_readl(S3C2440_CAMDIVN);
+ unsigned long clkdivn;
struct clk *clk_h;
struct clk *clk_p;
- struct clk *clk_xtal;
-
- clk_xtal = clk_get(NULL, "xtal");
- if (IS_ERR(clk_xtal)) {
- printk(KERN_ERR "S3C2440: Failed to get clk_xtal\n");
- return -EINVAL;
- }
-
- s3c2440_clk_upll.rate = s3c2410_get_pll(upllcon, clk_xtal->rate);
+ struct clk *clk_upll;
- printk("S3C2440: Clock Support, UPLL %ld.%03ld MHz, DVS %s\n",
- print_mhz(s3c2440_clk_upll.rate),
+ printk("S3C2440: Clock Support, DVS %s\n",
(camdivn & S3C2440_CAMDIVN_DVSEN) ? "on" : "off");
clk_p = clk_get(NULL, "pclk");
clk_h = clk_get(NULL, "hclk");
+ clk_upll = clk_get(NULL, "upll");
- if (IS_ERR(clk_p) || IS_ERR(clk_h)) {
+ if (IS_ERR(clk_p) || IS_ERR(clk_h) || IS_ERR(clk_upll)) {
printk(KERN_ERR "S3C2440: Failed to get parent clocks\n");
return -EINVAL;
}
+ /* check rate of UPLL, and if it is near 96MHz, then change
+ * to using half the UPLL rate for the system */
+
+ if (clk_get_rate(clk_upll) > (94 * MHZ)) {
+ clk_usb_bus.rate = clk_get_rate(clk_upll) / 2;
+
+ mutex_lock(&clocks_mutex);
+
+ clkdivn = __raw_readl(S3C2410_CLKDIVN);
+ clkdivn |= S3C2440_CLKDIVN_UCLK;
+ __raw_writel(camdivn, S3C2410_CLKDIVN);
+
+ mutex_unlock(&clocks_mutex);
+ }
+
s3c2440_clk_cam.parent = clk_h;
s3c2440_clk_ac97.parent = clk_p;
+ s3c2440_clk_cam_upll.parent = clk_upll;
s3c24xx_register_clock(&s3c2440_clk_ac97);
s3c24xx_register_clock(&s3c2440_clk_cam);
- s3c24xx_register_clock(&s3c2440_clk_upll);
+ s3c24xx_register_clock(&s3c2440_clk_cam_upll);
clk_disable(&s3c2440_clk_ac97);
clk_disable(&s3c2440_clk_cam);
diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c
index 10a2976aefd..9d7b799ea4a 100644
--- a/arch/arm/mach-s3c2410/time.c
+++ b/arch/arm/mach-s3c2410/time.c
@@ -142,6 +142,12 @@ static struct irqaction s3c2410_timer_irq = {
.handler = s3c2410_timer_interrupt,
};
+#define use_tclk1_12() ( \
+ machine_is_bast() || \
+ machine_is_vr1000() || \
+ machine_is_anubis() || \
+ machine_is_osiris() )
+
/*
* Set up timer interrupt, and return the current time in seconds.
*
@@ -165,7 +171,7 @@ static void s3c2410_timer_setup (void)
/* configure the system for whichever machine is in use */
- if (machine_is_bast() || machine_is_vr1000() || machine_is_anubis()) {
+ if (use_tclk1_12()) {
/* timer is at 12MHz, scaler is 1 */
timer_usec_ticks = timer_mask_usec_ticks(1, 12000000);
tcnt = 12000000 / HZ;
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
index e4a4a3e8aa8..e27f15042a2 100644
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -3,7 +3,7 @@
#
# Common support
-obj-y := generic.o irq.o dma.o time.o
+obj-y := clock.o generic.o irq.o dma.o time.o #nmi-oopser.o
obj-m :=
obj-n :=
obj- :=
diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c
new file mode 100644
index 00000000000..b1e8fd766c1
--- /dev/null
+++ b/arch/arm/mach-sa1100/clock.c
@@ -0,0 +1,132 @@
+/*
+ * linux/arch/arm/mach-sa1100/clock.c
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/errno.h>
+#include <linux/err.h>
+#include <linux/string.h>
+#include <linux/clk.h>
+#include <linux/spinlock.h>
+
+#include <asm/hardware.h>
+#include <asm/semaphore.h>
+
+struct clk {
+ struct list_head node;
+ unsigned long rate;
+ struct module *owner;
+ const char *name;
+ unsigned int enabled;
+ void (*enable)(void);
+ void (*disable)(void);
+};
+
+static LIST_HEAD(clocks);
+static DECLARE_MUTEX(clocks_sem);
+static DEFINE_SPINLOCK(clocks_lock);
+
+struct clk *clk_get(struct device *dev, const char *id)
+{
+ struct clk *p, *clk = ERR_PTR(-ENOENT);
+
+ down(&clocks_sem);
+ list_for_each_entry(p, &clocks, node) {
+ if (strcmp(id, p->name) == 0 && try_module_get(p->owner)) {
+ clk = p;
+ break;
+ }
+ }
+ up(&clocks_sem);
+
+ return clk;
+}
+EXPORT_SYMBOL(clk_get);
+
+void clk_put(struct clk *clk)
+{
+ module_put(clk->owner);
+}
+EXPORT_SYMBOL(clk_put);
+
+int clk_enable(struct clk *clk)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&clocks_lock, flags);
+ if (clk->enabled++ == 0)
+ clk->enable();
+ spin_unlock_irqrestore(&clocks_lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL(clk_enable);
+
+void clk_disable(struct clk *clk)
+{
+ unsigned long flags;
+
+ WARN_ON(clk->enabled == 0);
+
+ spin_lock_irqsave(&clocks_lock, flags);
+ if (--clk->enabled == 0)
+ clk->disable();
+ spin_unlock_irqrestore(&clocks_lock, flags);
+}
+EXPORT_SYMBOL(clk_disable);
+
+unsigned long clk_get_rate(struct clk *clk)
+{
+ return clk->rate;
+}
+EXPORT_SYMBOL(clk_get_rate);
+
+
+static void clk_gpio27_enable(void)
+{
+ /*
+ * First, set up the 3.6864MHz clock on GPIO 27 for the SA-1111:
+ * (SA-1110 Developer's Manual, section 9.1.2.1)
+ */
+ GAFR |= GPIO_32_768kHz;
+ GPDR |= GPIO_32_768kHz;
+ TUCR = TUCR_3_6864MHz;
+}
+
+static void clk_gpio27_disable(void)
+{
+ TUCR = 0;
+ GPDR &= ~GPIO_32_768kHz;
+ GAFR &= ~GPIO_32_768kHz;
+}
+
+static struct clk clk_gpio27 = {
+ .name = "GPIO27_CLK",
+ .rate = 3686400,
+ .enable = clk_gpio27_enable,
+ .disable = clk_gpio27_disable,
+};
+
+int clk_register(struct clk *clk)
+{
+ down(&clocks_sem);
+ list_add(&clk->node, &clocks);
+ up(&clocks_sem);
+ return 0;
+}
+EXPORT_SYMBOL(clk_register);
+
+void clk_unregister(struct clk *clk)
+{
+ down(&clocks_sem);
+ list_del(&clk->node);
+ up(&clocks_sem);
+}
+EXPORT_SYMBOL(clk_unregister);
+
+static int __init clk_init(void)
+{
+ clk_register(&clk_gpio27);
+ return 0;
+}
+arch_initcall(clk_init);
diff --git a/arch/arm/mach-sa1100/collie.c b/arch/arm/mach-sa1100/collie.c
index 6888816a193..10245408247 100644
--- a/arch/arm/mach-sa1100/collie.c
+++ b/arch/arm/mach-sa1100/collie.c
@@ -40,6 +40,7 @@
#include <asm/hardware/scoop.h>
#include <asm/mach/sharpsl_param.h>
#include <asm/hardware/locomo.h>
+#include <asm/arch/mcp.h>
#include "generic.h"
@@ -66,6 +67,32 @@ struct platform_device colliescoop_device = {
.resource = collie_scoop_resources,
};
+static struct scoop_pcmcia_dev collie_pcmcia_scoop[] = {
+{
+ .dev = &colliescoop_device.dev,
+ .irq = COLLIE_IRQ_GPIO_CF_IRQ,
+ .cd_irq = COLLIE_IRQ_GPIO_CF_CD,
+ .cd_irq_str = "PCMCIA0 CD",
+},
+};
+
+static struct scoop_pcmcia_config collie_pcmcia_config = {
+ .devs = &collie_pcmcia_scoop[0],
+ .num_devs = 1,
+};
+
+
+static struct mcp_plat_data collie_mcp_data = {
+ .mccr0 = MCCR0_ADM,
+ .sclk_rate = 11981000,
+};
+
+
+static struct sa1100_port_fns collie_port_fns __initdata = {
+ .set_mctrl = collie_uart_set_mctrl,
+ .get_mctrl = collie_uart_get_mctrl,
+};
+
static struct resource locomo_resources[] = {
[0] = {
@@ -159,6 +186,8 @@ static void __init collie_init(void)
GPDR |= GPIO_32_768kHz;
TUCR = TUCR_32_768kHz;
+ platform_scoop_config = &collie_pcmcia_config;
+
ret = platform_add_devices(devices, ARRAY_SIZE(devices));
if (ret) {
printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
@@ -166,6 +195,7 @@ static void __init collie_init(void)
sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
ARRAY_SIZE(collie_flash_resources));
+ sa11x0_set_mcp_data(&collie_mcp_data);
sharpsl_save_param();
}
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c
index 9ebbe808b41..799697d32de 100644
--- a/arch/arm/mach-versatile/core.c
+++ b/arch/arm/mach-versatile/core.c
@@ -112,7 +112,7 @@ void __init versatile_init_irq(void)
{
unsigned int i;
- vic_init(VA_VIC_BASE, ~(1 << 31));
+ vic_init(VA_VIC_BASE, IRQ_VIC_START, ~(1 << 31));
set_irq_handler(IRQ_VICSOURCE31, sic_handle_irq);
enable_irq(IRQ_VICSOURCE31);
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index 3b79d0e2345..eaaec90db97 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -62,7 +62,7 @@ config CPU_ARM720T
# ARM920T
config CPU_ARM920T
bool "Support ARM920T processor" if !ARCH_S3C2410
- depends on ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200
+ depends on ARCH_EP93XX || ARCH_INTEGRATOR || ARCH_S3C2410 || ARCH_IMX || ARCH_AAEC2000 || ARCH_AT91RM9200
default y if ARCH_S3C2410 || ARCH_AT91RM9200
select CPU_32v4
select CPU_ABRT_EV4T
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index b0321e943b7..88279124317 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -19,7 +19,6 @@
#include <linux/initrd.h>
#include <asm/mach-types.h>
-#include <asm/hardware.h>
#include <asm/setup.h>
#include <asm/tlb.h>
diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
index da9b3597411..25e0ca3e598 100644
--- a/arch/arm/mm/ioremap.c
+++ b/arch/arm/mm/ioremap.c
@@ -26,7 +26,6 @@
#include <linux/vmalloc.h>
#include <asm/cacheflush.h>
-#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/tlbflush.h>
diff --git a/arch/arm/mm/proc-arm1020.S b/arch/arm/mm/proc-arm1020.S
index 82ec954e45b..3aa80094012 100644
--- a/arch/arm/mm/proc-arm1020.S
+++ b/arch/arm/mm/proc-arm1020.S
@@ -32,7 +32,6 @@
#include <asm/pgtable.h>
#include <asm/procinfo.h>
#include <asm/ptrace.h>
-#include <asm/hardware.h>
/*
* This is the maximum size of an area which will be invalidated
diff --git a/arch/arm/mm/proc-arm1020e.S b/arch/arm/mm/proc-arm1020e.S
index 7375fe930f7..767d158f211 100644
--- a/arch/arm/mm/proc-arm1020e.S
+++ b/arch/arm/mm/proc-arm1020e.S
@@ -32,7 +32,6 @@
#include <asm/pgtable.h>
#include <asm/procinfo.h>
#include <asm/ptrace.h>
-#include <asm/hardware.h>
/*
* This is the maximum size of an area which will be invalidated
diff --git a/arch/arm/mm/proc-arm720.S b/arch/arm/mm/proc-arm720.S
index a13e0184d34..471286fdf78 100644
--- a/arch/arm/mm/proc-arm720.S
+++ b/arch/arm/mm/proc-arm720.S
@@ -37,7 +37,6 @@
#include <asm/pgtable.h>
#include <asm/procinfo.h>
#include <asm/ptrace.h>
-#include <asm/hardware.h>
/*
* Function: arm720_proc_init (void)
diff --git a/arch/arm/mm/proc-arm920.S b/arch/arm/mm/proc-arm920.S
index d1651389999..950d3b664c1 100644
--- a/arch/arm/mm/proc-arm920.S
+++ b/arch/arm/mm/proc-arm920.S
@@ -30,7 +30,6 @@
#include <asm/assembler.h>
#include <asm/pgtable.h>
#include <asm/procinfo.h>
-#include <asm/hardware.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm922.S b/arch/arm/mm/proc-arm922.S
index 23b8ed97f4e..410b032faa3 100644
--- a/arch/arm/mm/proc-arm922.S
+++ b/arch/arm/mm/proc-arm922.S
@@ -31,7 +31,6 @@
#include <asm/assembler.h>
#include <asm/pgtable.h>
#include <asm/procinfo.h>
-#include <asm/hardware.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm925.S b/arch/arm/mm/proc-arm925.S
index ee95c52db51..6dd2be7cd05 100644
--- a/arch/arm/mm/proc-arm925.S
+++ b/arch/arm/mm/proc-arm925.S
@@ -53,7 +53,6 @@
#include <asm/assembler.h>
#include <asm/pgtable.h>
#include <asm/procinfo.h>
-#include <asm/hardware.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-arm926.S b/arch/arm/mm/proc-arm926.S
index 7d042dc20c4..022e8684204 100644
--- a/arch/arm/mm/proc-arm926.S
+++ b/arch/arm/mm/proc-arm926.S
@@ -30,7 +30,6 @@
#include <asm/assembler.h>
#include <asm/pgtable.h>
#include <asm/procinfo.h>
-#include <asm/hardware.h>
#include <asm/page.h>
#include <asm/ptrace.h>
#include "proc-macros.S"
diff --git a/arch/arm/mm/proc-xscale.S b/arch/arm/mm/proc-xscale.S
index 2d3823ec315..b50f87a0ee7 100644
--- a/arch/arm/mm/proc-xscale.S
+++ b/arch/arm/mm/proc-xscale.S
@@ -24,7 +24,6 @@
#include <linux/init.h>
#include <asm/assembler.h>
#include <asm/procinfo.h>
-#include <asm/hardware.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/ptrace.h>
diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c
index 6f8bc1f0e6a..6f833358cd0 100644
--- a/arch/arm/oprofile/common.c
+++ b/arch/arm/oprofile/common.c
@@ -10,17 +10,18 @@
#include <linux/init.h>
#include <linux/oprofile.h>
#include <linux/errno.h>
+#include <linux/slab.h>
#include <linux/sysdev.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include "op_counter.h"
#include "op_arm_model.h"
static struct op_arm_model_spec *op_arm_model;
static int op_arm_enabled;
-static struct semaphore op_arm_sem;
+static DEFINE_MUTEX(op_arm_mutex);
-struct op_counter_config counter_config[OP_MAX_COUNTER];
+struct op_counter_config *counter_config;
static int op_arm_create_files(struct super_block *sb, struct dentry *root)
{
@@ -28,7 +29,7 @@ static int op_arm_create_files(struct super_block *sb, struct dentry *root)
for (i = 0; i < op_arm_model->num_counters; i++) {
struct dentry *dir;
- char buf[2];
+ char buf[4];
snprintf(buf, sizeof buf, "%d", i);
dir = oprofilefs_mkdir(sb, root, buf);
@@ -57,40 +58,40 @@ static int op_arm_start(void)
{
int ret = -EBUSY;
- down(&op_arm_sem);
+ mutex_lock(&op_arm_mutex);
if (!op_arm_enabled) {
ret = op_arm_model->start();
op_arm_enabled = !ret;
}
- up(&op_arm_sem);
+ mutex_unlock(&op_arm_mutex);
return ret;
}
static void op_arm_stop(void)
{
- down(&op_arm_sem);
+ mutex_lock(&op_arm_mutex);
if (op_arm_enabled)
op_arm_model->stop();
op_arm_enabled = 0;
- up(&op_arm_sem);
+ mutex_unlock(&op_arm_mutex);
}
#ifdef CONFIG_PM
static int op_arm_suspend(struct sys_device *dev, pm_message_t state)
{
- down(&op_arm_sem);
+ mutex_lock(&op_arm_mutex);
if (op_arm_enabled)
op_arm_model->stop();
- up(&op_arm_sem);
+ mutex_unlock(&op_arm_mutex);
return 0;
}
static int op_arm_resume(struct sys_device *dev)
{
- down(&op_arm_sem);
+ mutex_lock(&op_arm_mutex);
if (op_arm_enabled && op_arm_model->start())
op_arm_enabled = 0;
- up(&op_arm_sem);
+ mutex_unlock(&op_arm_mutex);
return 0;
}
@@ -135,12 +136,15 @@ int __init oprofile_arch_init(struct oprofile_operations *ops)
#endif
if (spec) {
- init_MUTEX(&op_arm_sem);
-
ret = spec->init();
if (ret < 0)
return ret;
+ counter_config = kcalloc(spec->num_counters, sizeof(struct op_counter_config),
+ GFP_KERNEL);
+ if (!counter_config)
+ return -ENOMEM;
+
op_arm_model = spec;
init_driverfs();
ops->create_files = op_arm_create_files;
@@ -162,5 +166,5 @@ void oprofile_arch_exit(void)
exit_driverfs();
op_arm_model = NULL;
}
+ kfree(counter_config);
}
-
diff --git a/arch/arm/oprofile/op_counter.h b/arch/arm/oprofile/op_counter.h
index 153c1d467f2..8c5351d751c 100644
--- a/arch/arm/oprofile/op_counter.h
+++ b/arch/arm/oprofile/op_counter.h
@@ -24,6 +24,6 @@ struct op_counter_config {
unsigned long user;
};
-extern struct op_counter_config counter_config[];
+extern struct op_counter_config *counter_config;
#endif /* OP_COUNTER_H */
diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S
index 6f17187ab32..9ab1abfbe7a 100644
--- a/arch/arm/vfp/entry.S
+++ b/arch/arm/vfp/entry.S
@@ -22,6 +22,7 @@
.globl do_vfp
do_vfp:
+ enable_irq
ldr r4, .LCvfp
add r10, r10, #TI_VFPSTATE @ r10 = workspace
ldr pc, [r4] @ call VFP entry point
diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile
index 844a9e46886..fe91eda98a9 100644
--- a/arch/arm26/Makefile
+++ b/arch/arm26/Makefile
@@ -1,6 +1,9 @@
#
# arch/arm26/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -49,9 +52,9 @@ all: zImage
boot := arch/arm26/boot
-.PHONY: maketools FORCE
+PHONY += maketools FORCE
maketools: FORCE
-
+
# Convert bzImage to zImage
bzImage: vmlinux
diff --git a/arch/arm26/boot/Makefile b/arch/arm26/boot/Makefile
index b5c2277654d..68acb7b0d47 100644
--- a/arch/arm26/boot/Makefile
+++ b/arch/arm26/boot/Makefile
@@ -1,6 +1,9 @@
#
# arch/arm26/boot/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -60,7 +63,7 @@ $(obj)/xipImage: vmlinux FORCE
@echo ' Kernel: $@ is ready'
endif
-.PHONY: initrd
+PHONY += initrd
initrd:
@test "$(INITRD_PHYS)" != "" || \
(echo This machine does not support INITRD; exit -1)
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 501fa52d8d3..c59ee28a35f 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2944,7 +2944,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
int spdl_err;
/* Mark output pages dirty. */
spdl_err = set_page_dirty_lock(outpages[i]);
- DEBUG(if (spdl_err)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err));
+ DEBUG(if (spdl_err < 0)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err));
}
for (i = 0; i < nooutpages; i++){
put_page(outpages[i]);
diff --git a/arch/cris/kernel/irq.c b/arch/cris/kernel/irq.c
index 30deaf1b728..b504def3e34 100644
--- a/arch/cris/kernel/irq.c
+++ b/arch/cris/kernel/irq.c
@@ -52,9 +52,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_printf(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
@@ -67,9 +66,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
#endif
seq_printf(p, " %14s", irq_desc[i].handler->typename);
seq_printf(p, " %s", action->name);
diff --git a/arch/cris/kernel/process.c b/arch/cris/kernel/process.c
index 4ab3e87115b..123451c4415 100644
--- a/arch/cris/kernel/process.c
+++ b/arch/cris/kernel/process.c
@@ -116,6 +116,7 @@
#include <asm/pgtable.h>
#include <asm/uaccess.h>
#include <asm/irq.h>
+#include <asm/system.h>
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/fs_struct.h>
@@ -194,8 +195,6 @@ EXPORT_SYMBOL(enable_hlt);
*/
void (*pm_idle)(void);
-extern void default_idle(void);
-
/*
* The idle thread. There's no useful work to be
* done, so just try to conserve power and have a
diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c
index 8f860d9c494..508601fad07 100644
--- a/arch/frv/kernel/gdb-stub.c
+++ b/arch/frv/kernel/gdb-stub.c
@@ -1406,7 +1406,7 @@ void gdbstub(int sigval)
__debug_frame->psr |= PSR_S;
__debug_regs->brr = (__debug_frame->tbr & TBR_TT) << 12;
__debug_regs->brr |= BRR_EB;
- sigval = SIGXCPU;;
+ sigval = SIGXCPU;
}
LEDS(0x5002);
diff --git a/arch/frv/kernel/irq.c b/arch/frv/kernel/irq.c
index 27ab4c30aac..11fa326a8f6 100644
--- a/arch/frv/kernel/irq.c
+++ b/arch/frv/kernel/irq.c
@@ -75,9 +75,8 @@ int show_interrupts(struct seq_file *p, void *v)
switch (i) {
case 0:
seq_printf(p, " ");
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
break;
@@ -100,9 +99,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", kstat_cpu(j).irqs[i - 1]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i - 1]);
#endif
level = group->sources[ix]->level - frv_irq_levels;
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c
index dd344f112cf..16ccddc69c2 100644
--- a/arch/h8300/kernel/process.c
+++ b/arch/h8300/kernel/process.c
@@ -54,7 +54,7 @@ asmlinkage void ret_from_fork(void);
* The idle loop on an H8/300..
*/
#if !defined(CONFIG_H8300H_SIM) && !defined(CONFIG_H8S_SIM)
-void default_idle(void)
+static void default_idle(void)
{
local_irq_disable();
if (!need_resched()) {
@@ -65,7 +65,7 @@ void default_idle(void)
local_irq_enable();
}
#else
-void default_idle(void)
+static void default_idle(void)
{
cpu_relax();
}
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 5b1a7d46d1d..b008fb0cd7b 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -80,6 +80,7 @@ config X86_VOYAGER
config X86_NUMAQ
bool "NUMAQ (IBM/Sequent)"
+ select SMP
select NUMA
help
This option is used for getting Linux to run on a (IBM/Sequent) NUMA
@@ -400,6 +401,7 @@ choice
config NOHIGHMEM
bool "off"
+ depends on !X86_NUMAQ
---help---
Linux can use up to 64 Gigabytes of physical memory on x86 systems.
However, the address space of 32-bit x86 processors is only 4
@@ -436,6 +438,7 @@ config NOHIGHMEM
config HIGHMEM4G
bool "4GB"
+ depends on !X86_NUMAQ
help
Select this if you have a 32-bit processor and between 1 and 4
gigabytes of physical RAM.
@@ -503,10 +506,6 @@ config NUMA
default n if X86_PC
default y if (X86_NUMAQ || X86_SUMMIT)
-# Need comments to help the hapless user trying to turn on NUMA support
-comment "NUMA (NUMA-Q) requires SMP, 64GB highmem support"
- depends on X86_NUMAQ && (!HIGHMEM64G || !SMP)
-
comment "NUMA (Summit) requires SMP, 64GB highmem support, ACPI"
depends on X86_SUMMIT && (!HIGHMEM64G || !ACPI)
@@ -660,13 +659,18 @@ config BOOT_IOREMAP
default y
config REGPARM
- bool "Use register arguments (EXPERIMENTAL)"
- depends on EXPERIMENTAL
- default n
+ bool "Use register arguments"
+ default y
help
- Compile the kernel with -mregparm=3. This uses a different ABI
- and passes the first three arguments of a function call in registers.
- This will probably break binary only modules.
+ Compile the kernel with -mregparm=3. This instructs gcc to use
+ a more efficient function call ABI which passes the first three
+ arguments of a function call via registers, which results in denser
+ and faster code.
+
+ If this option is disabled, then the default ABI of passing
+ arguments via the stack is used.
+
+ If unsure, say Y.
config SECCOMP
bool "Enable seccomp to safely compute untrusted bytecode"
@@ -733,7 +737,7 @@ config PHYSICAL_START
config HOTPLUG_CPU
bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
- depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER
+ depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER && !X86_PC
---help---
Say Y here to experiment with turning CPUs off and on. CPUs
can be controlled through /sys/devices/system/cpu.
diff --git a/arch/i386/Kconfig.debug b/arch/i386/Kconfig.debug
index bf32ecc9ad0..6e97df6979e 100644
--- a/arch/i386/Kconfig.debug
+++ b/arch/i386/Kconfig.debug
@@ -31,12 +31,21 @@ config DEBUG_STACK_USAGE
This option will slow down process creation somewhat.
+config STACK_BACKTRACE_COLS
+ int "Stack backtraces per line" if DEBUG_KERNEL
+ range 1 3
+ default 2
+ help
+ Selects how many stack backtrace entries per line to display.
+
+ This can save screen space when displaying traces.
+
comment "Page alloc debug is incompatible with Software Suspend on i386"
depends on DEBUG_KERNEL && SOFTWARE_SUSPEND
config DEBUG_PAGEALLOC
- bool "Page alloc debugging"
- depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND
+ bool "Debug page memory allocations"
+ depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND && !HUGETLBFS
help
Unmap pages from the kernel linear mapping after free_pages().
This results in a large slowdown, but helps to find certain types
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 36bef6543ac..ff6973a85c8 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -99,8 +99,8 @@ AFLAGS += $(mflags-y)
boot := arch/i386/boot
-.PHONY: zImage bzImage compressed zlilo bzlilo \
- zdisk bzdisk fdimage fdimage144 fdimage288 install
+PHONY += zImage bzImage compressed zlilo bzlilo \
+ zdisk bzdisk fdimage fdimage144 fdimage288 install
all: bzImage
diff --git a/arch/i386/boot/edd.S b/arch/i386/boot/edd.S
index d8d69f2b911..4b84ea216f2 100644
--- a/arch/i386/boot/edd.S
+++ b/arch/i386/boot/edd.S
@@ -76,6 +76,8 @@ edd_mbr_sig_read:
popw %es
popw %bx
jc edd_mbr_sig_done # on failure, we're done.
+ cmpb $0, %ah # some BIOSes do not set CF
+ jne edd_mbr_sig_done # on failure, we're done.
movl (EDDBUF+EDD_MBR_SIG_OFFSET), %eax # read sig out of the MBR
movl %eax, (%bx) # store success
incb (EDD_MBR_SIG_NR_BUF) # note that we stored something
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 65656c033d7..5b9ed21216c 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -7,7 +7,7 @@ extra-y := head.o init_task.o vmlinux.lds
obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
ptrace.o time.o ioport.o ldt.o setup.o i8259.o sys_i386.o \
pci-dma.o i386_ksyms.o i387.o dmi_scan.o bootflag.o \
- quirks.o i8237.o topology.o
+ quirks.o i8237.o topology.o alternative.o
obj-y += cpu/
obj-y += timers/
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
new file mode 100644
index 00000000000..5cbd6f99fb2
--- /dev/null
+++ b/arch/i386/kernel/alternative.c
@@ -0,0 +1,321 @@
+#include <linux/module.h>
+#include <linux/spinlock.h>
+#include <linux/list.h>
+#include <asm/alternative.h>
+#include <asm/sections.h>
+
+#define DEBUG 0
+#if DEBUG
+# define DPRINTK(fmt, args...) printk(fmt, args)
+#else
+# define DPRINTK(fmt, args...)
+#endif
+
+/* Use inline assembly to define this because the nops are defined
+ as inline assembly strings in the include files and we cannot
+ get them easily into strings. */
+asm("\t.data\nintelnops: "
+ GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
+ GENERIC_NOP7 GENERIC_NOP8);
+asm("\t.data\nk8nops: "
+ K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
+ K8_NOP7 K8_NOP8);
+asm("\t.data\nk7nops: "
+ K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
+ K7_NOP7 K7_NOP8);
+
+extern unsigned char intelnops[], k8nops[], k7nops[];
+static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
+ NULL,
+ intelnops,
+ intelnops + 1,
+ intelnops + 1 + 2,
+ intelnops + 1 + 2 + 3,
+ intelnops + 1 + 2 + 3 + 4,
+ intelnops + 1 + 2 + 3 + 4 + 5,
+ intelnops + 1 + 2 + 3 + 4 + 5 + 6,
+ intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+};
+static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
+ NULL,
+ k8nops,
+ k8nops + 1,
+ k8nops + 1 + 2,
+ k8nops + 1 + 2 + 3,
+ k8nops + 1 + 2 + 3 + 4,
+ k8nops + 1 + 2 + 3 + 4 + 5,
+ k8nops + 1 + 2 + 3 + 4 + 5 + 6,
+ k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+};
+static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
+ NULL,
+ k7nops,
+ k7nops + 1,
+ k7nops + 1 + 2,
+ k7nops + 1 + 2 + 3,
+ k7nops + 1 + 2 + 3 + 4,
+ k7nops + 1 + 2 + 3 + 4 + 5,
+ k7nops + 1 + 2 + 3 + 4 + 5 + 6,
+ k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
+};
+static struct nop {
+ int cpuid;
+ unsigned char **noptable;
+} noptypes[] = {
+ { X86_FEATURE_K8, k8_nops },
+ { X86_FEATURE_K7, k7_nops },
+ { -1, NULL }
+};
+
+
+extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
+extern struct alt_instr __smp_alt_instructions[], __smp_alt_instructions_end[];
+extern u8 *__smp_locks[], *__smp_locks_end[];
+
+extern u8 __smp_alt_begin[], __smp_alt_end[];
+
+
+static unsigned char** find_nop_table(void)
+{
+ unsigned char **noptable = intel_nops;
+ int i;
+
+ for (i = 0; noptypes[i].cpuid >= 0; i++) {
+ if (boot_cpu_has(noptypes[i].cpuid)) {
+ noptable = noptypes[i].noptable;
+ break;
+ }
+ }
+ return noptable;
+}
+
+/* Replace instructions with better alternatives for this CPU type.
+ This runs before SMP is initialized to avoid SMP problems with
+ self modifying code. This implies that assymetric systems where
+ APs have less capabilities than the boot processor are not handled.
+ Tough. Make sure you disable such features by hand. */
+
+void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
+{
+ unsigned char **noptable = find_nop_table();
+ struct alt_instr *a;
+ int diff, i, k;
+
+ DPRINTK("%s: alt table %p -> %p\n", __FUNCTION__, start, end);
+ for (a = start; a < end; a++) {
+ BUG_ON(a->replacementlen > a->instrlen);
+ if (!boot_cpu_has(a->cpuid))
+ continue;
+ memcpy(a->instr, a->replacement, a->replacementlen);
+ diff = a->instrlen - a->replacementlen;
+ /* Pad the rest with nops */
+ for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
+ k = diff;
+ if (k > ASM_NOP_MAX)
+ k = ASM_NOP_MAX;
+ memcpy(a->instr + i, noptable[k], k);
+ }
+ }
+}
+
+static void alternatives_smp_save(struct alt_instr *start, struct alt_instr *end)
+{
+ struct alt_instr *a;
+
+ DPRINTK("%s: alt table %p-%p\n", __FUNCTION__, start, end);
+ for (a = start; a < end; a++) {
+ memcpy(a->replacement + a->replacementlen,
+ a->instr,
+ a->instrlen);
+ }
+}
+
+static void alternatives_smp_apply(struct alt_instr *start, struct alt_instr *end)
+{
+ struct alt_instr *a;
+
+ for (a = start; a < end; a++) {
+ memcpy(a->instr,
+ a->replacement + a->replacementlen,
+ a->instrlen);
+ }
+}
+
+static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
+{
+ u8 **ptr;
+
+ for (ptr = start; ptr < end; ptr++) {
+ if (*ptr < text)
+ continue;
+ if (*ptr > text_end)
+ continue;
+ **ptr = 0xf0; /* lock prefix */
+ };
+}
+
+static void alternatives_smp_unlock(u8 **start, u8 **end, u8 *text, u8 *text_end)
+{
+ unsigned char **noptable = find_nop_table();
+ u8 **ptr;
+
+ for (ptr = start; ptr < end; ptr++) {
+ if (*ptr < text)
+ continue;
+ if (*ptr > text_end)
+ continue;
+ **ptr = noptable[1][0];
+ };
+}
+
+struct smp_alt_module {
+ /* what is this ??? */
+ struct module *mod;
+ char *name;
+
+ /* ptrs to lock prefixes */
+ u8 **locks;
+ u8 **locks_end;
+
+ /* .text segment, needed to avoid patching init code ;) */
+ u8 *text;
+ u8 *text_end;
+
+ struct list_head next;
+};
+static LIST_HEAD(smp_alt_modules);
+static DEFINE_SPINLOCK(smp_alt);
+
+static int smp_alt_once = 0;
+static int __init bootonly(char *str)
+{
+ smp_alt_once = 1;
+ return 1;
+}
+__setup("smp-alt-boot", bootonly);
+
+void alternatives_smp_module_add(struct module *mod, char *name,
+ void *locks, void *locks_end,
+ void *text, void *text_end)
+{
+ struct smp_alt_module *smp;
+ unsigned long flags;
+
+ if (smp_alt_once) {
+ if (boot_cpu_has(X86_FEATURE_UP))
+ alternatives_smp_unlock(locks, locks_end,
+ text, text_end);
+ return;
+ }
+
+ smp = kzalloc(sizeof(*smp), GFP_KERNEL);
+ if (NULL == smp)
+ return; /* we'll run the (safe but slow) SMP code then ... */
+
+ smp->mod = mod;
+ smp->name = name;
+ smp->locks = locks;
+ smp->locks_end = locks_end;
+ smp->text = text;
+ smp->text_end = text_end;
+ DPRINTK("%s: locks %p -> %p, text %p -> %p, name %s\n",
+ __FUNCTION__, smp->locks, smp->locks_end,
+ smp->text, smp->text_end, smp->name);
+
+ spin_lock_irqsave(&smp_alt, flags);
+ list_add_tail(&smp->next, &smp_alt_modules);
+ if (boot_cpu_has(X86_FEATURE_UP))
+ alternatives_smp_unlock(smp->locks, smp->locks_end,
+ smp->text, smp->text_end);
+ spin_unlock_irqrestore(&smp_alt, flags);
+}
+
+void alternatives_smp_module_del(struct module *mod)
+{
+ struct smp_alt_module *item;
+ unsigned long flags;
+
+ if (smp_alt_once)
+ return;
+
+ spin_lock_irqsave(&smp_alt, flags);
+ list_for_each_entry(item, &smp_alt_modules, next) {
+ if (mod != item->mod)
+ continue;
+ list_del(&item->next);
+ spin_unlock_irqrestore(&smp_alt, flags);
+ DPRINTK("%s: %s\n", __FUNCTION__, item->name);
+ kfree(item);
+ return;
+ }
+ spin_unlock_irqrestore(&smp_alt, flags);
+}
+
+void alternatives_smp_switch(int smp)
+{
+ struct smp_alt_module *mod;
+ unsigned long flags;
+
+ if (smp_alt_once)
+ return;
+ BUG_ON(!smp && (num_online_cpus() > 1));
+
+ spin_lock_irqsave(&smp_alt, flags);
+ if (smp) {
+ printk(KERN_INFO "SMP alternatives: switching to SMP code\n");
+ clear_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
+ clear_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
+ alternatives_smp_apply(__smp_alt_instructions,
+ __smp_alt_instructions_end);
+ list_for_each_entry(mod, &smp_alt_modules, next)
+ alternatives_smp_lock(mod->locks, mod->locks_end,
+ mod->text, mod->text_end);
+ } else {
+ printk(KERN_INFO "SMP alternatives: switching to UP code\n");
+ set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
+ set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
+ apply_alternatives(__smp_alt_instructions,
+ __smp_alt_instructions_end);
+ list_for_each_entry(mod, &smp_alt_modules, next)
+ alternatives_smp_unlock(mod->locks, mod->locks_end,
+ mod->text, mod->text_end);
+ }
+ spin_unlock_irqrestore(&smp_alt, flags);
+}
+
+void __init alternative_instructions(void)
+{
+ apply_alternatives(__alt_instructions, __alt_instructions_end);
+
+ /* switch to patch-once-at-boottime-only mode and free the
+ * tables in case we know the number of CPUs will never ever
+ * change */
+#ifdef CONFIG_HOTPLUG_CPU
+ if (num_possible_cpus() < 2)
+ smp_alt_once = 1;
+#else
+ smp_alt_once = 1;
+#endif
+
+ if (smp_alt_once) {
+ if (1 == num_possible_cpus()) {
+ printk(KERN_INFO "SMP alternatives: switching to UP code\n");
+ set_bit(X86_FEATURE_UP, boot_cpu_data.x86_capability);
+ set_bit(X86_FEATURE_UP, cpu_data[0].x86_capability);
+ apply_alternatives(__smp_alt_instructions,
+ __smp_alt_instructions_end);
+ alternatives_smp_unlock(__smp_locks, __smp_locks_end,
+ _text, _etext);
+ }
+ free_init_pages("SMP alternatives",
+ (unsigned long)__smp_alt_begin,
+ (unsigned long)__smp_alt_end);
+ } else {
+ alternatives_smp_save(__smp_alt_instructions,
+ __smp_alt_instructions_end);
+ alternatives_smp_module_add(NULL, "core kernel",
+ __smp_locks, __smp_locks_end,
+ _text, _etext);
+ alternatives_smp_switch(0);
+ }
+}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 776c90989e0..eb5279d23b7 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -38,6 +38,7 @@
#include <asm/i8253.h>
#include <mach_apic.h>
+#include <mach_apicdef.h>
#include <mach_ipi.h>
#include "io_ports.h"
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index 05312a8abb8..da30a374dd4 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -824,8 +824,6 @@ static void apm_do_busy(void)
static void (*original_pm_idle)(void);
-extern void default_idle(void);
-
/**
* apm_cpu_idle - cpu idling for APM capable Linux
*
diff --git a/arch/i386/kernel/cpu/centaur.c b/arch/i386/kernel/cpu/centaur.c
index f52669ecb93..bd75629dd26 100644
--- a/arch/i386/kernel/cpu/centaur.c
+++ b/arch/i386/kernel/cpu/centaur.c
@@ -4,6 +4,7 @@
#include <asm/processor.h>
#include <asm/msr.h>
#include <asm/e820.h>
+#include <asm/mtrr.h>
#include "cpu.h"
#ifdef CONFIG_X86_OOSTORE
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index e6bd095ae10..7e3d6b6a4e9 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -25,9 +25,10 @@ EXPORT_PER_CPU_SYMBOL(cpu_gdt_descr);
DEFINE_PER_CPU(unsigned char, cpu_16bit_stack[CPU_16BIT_STACK_SIZE]);
EXPORT_PER_CPU_SYMBOL(cpu_16bit_stack);
-static int cachesize_override __devinitdata = -1;
-static int disable_x86_fxsr __devinitdata = 0;
-static int disable_x86_serial_nr __devinitdata = 1;
+static int cachesize_override __cpuinitdata = -1;
+static int disable_x86_fxsr __cpuinitdata;
+static int disable_x86_serial_nr __cpuinitdata = 1;
+static int disable_x86_sep __cpuinitdata;
struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
@@ -59,7 +60,7 @@ static int __init cachesize_setup(char *str)
}
__setup("cachesize=", cachesize_setup);
-int __devinit get_model_name(struct cpuinfo_x86 *c)
+int __cpuinit get_model_name(struct cpuinfo_x86 *c)
{
unsigned int *v;
char *p, *q;
@@ -89,7 +90,7 @@ int __devinit get_model_name(struct cpuinfo_x86 *c)
}
-void __devinit display_cacheinfo(struct cpuinfo_x86 *c)
+void __cpuinit display_cacheinfo(struct cpuinfo_x86 *c)
{
unsigned int n, dummy, ecx, edx, l2size;
@@ -130,7 +131,7 @@ void __devinit display_cacheinfo(struct cpuinfo_x86 *c)
/* in particular, if CPUID levels 0x80000002..4 are supported, this isn't used */
/* Look up CPU names by table lookup. */
-static char __devinit *table_lookup_model(struct cpuinfo_x86 *c)
+static char __cpuinit *table_lookup_model(struct cpuinfo_x86 *c)
{
struct cpu_model_info *info;
@@ -151,7 +152,7 @@ static char __devinit *table_lookup_model(struct cpuinfo_x86 *c)
}
-static void __devinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
+static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c, int early)
{
char *v = c->x86_vendor_id;
int i;
@@ -187,6 +188,14 @@ static int __init x86_fxsr_setup(char * s)
__setup("nofxsr", x86_fxsr_setup);
+static int __init x86_sep_setup(char * s)
+{
+ disable_x86_sep = 1;
+ return 1;
+}
+__setup("nosep", x86_sep_setup);
+
+
/* Standard macro to see if a specific flag is changeable */
static inline int flag_is_changeable_p(u32 flag)
{
@@ -210,7 +219,7 @@ static inline int flag_is_changeable_p(u32 flag)
/* Probe for the CPUID instruction */
-static int __devinit have_cpuid_p(void)
+static int __cpuinit have_cpuid_p(void)
{
return flag_is_changeable_p(X86_EFLAGS_ID);
}
@@ -254,7 +263,7 @@ static void __init early_cpu_detect(void)
}
}
-void __devinit generic_identify(struct cpuinfo_x86 * c)
+void __cpuinit generic_identify(struct cpuinfo_x86 * c)
{
u32 tfms, xlvl;
int junk;
@@ -307,7 +316,7 @@ void __devinit generic_identify(struct cpuinfo_x86 * c)
#endif
}
-static void __devinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
+static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
{
if (cpu_has(c, X86_FEATURE_PN) && disable_x86_serial_nr ) {
/* Disable processor serial number */
@@ -335,7 +344,7 @@ __setup("serialnumber", x86_serial_nr_setup);
/*
* This does the hard work of actually picking apart the CPU stuff...
*/
-void __devinit identify_cpu(struct cpuinfo_x86 *c)
+void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
{
int i;
@@ -405,6 +414,10 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
clear_bit(X86_FEATURE_XMM, c->x86_capability);
}
+ /* SEP disabled? */
+ if (disable_x86_sep)
+ clear_bit(X86_FEATURE_SEP, c->x86_capability);
+
if (disable_pse)
clear_bit(X86_FEATURE_PSE, c->x86_capability);
@@ -417,7 +430,7 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
else
/* Last resort... */
sprintf(c->x86_model_id, "%02x/%02x",
- c->x86_vendor, c->x86_model);
+ c->x86, c->x86_model);
}
/* Now the feature flags better reflect actual CPU features! */
@@ -453,7 +466,7 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
}
#ifdef CONFIG_X86_HT
-void __devinit detect_ht(struct cpuinfo_x86 *c)
+void __cpuinit detect_ht(struct cpuinfo_x86 *c)
{
u32 eax, ebx, ecx, edx;
int index_msb, core_bits;
@@ -500,7 +513,7 @@ void __devinit detect_ht(struct cpuinfo_x86 *c)
}
#endif
-void __devinit print_cpu_info(struct cpuinfo_x86 *c)
+void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
{
char *vendor = NULL;
@@ -523,7 +536,7 @@ void __devinit print_cpu_info(struct cpuinfo_x86 *c)
printk("\n");
}
-cpumask_t cpu_initialized __devinitdata = CPU_MASK_NONE;
+cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
/* This is hacky. :)
* We're emulating future behavior.
@@ -570,7 +583,7 @@ void __init early_cpu_init(void)
* and IDT. We reload them nevertheless, this function acts as a
* 'CPU state barrier', nothing should get across.
*/
-void __devinit cpu_init(void)
+void __cpuinit cpu_init(void)
{
int cpu = smp_processor_id();
struct tss_struct * t = &per_cpu(init_tss, cpu);
@@ -670,7 +683,7 @@ void __devinit cpu_init(void)
}
#ifdef CONFIG_HOTPLUG_CPU
-void __devinit cpu_uninit(void)
+void __cpuinit cpu_uninit(void)
{
int cpu = raw_smp_processor_id();
cpu_clear(cpu, cpu_initialized);
diff --git a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
index e11a09207ec..798da7c2b5d 100644
--- a/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
+++ b/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -1145,16 +1145,14 @@ static int __cpuinit powernowk8_init(void)
{
unsigned int i, supported_cpus = 0;
- for (i=0; i<NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (check_supported_cpu(i))
supported_cpus++;
}
if (supported_cpus == num_online_cpus()) {
- printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron processors (" VERSION ")\n",
- supported_cpus);
+ printk(KERN_INFO PFX "Found %d AMD Athlon 64 / Opteron "
+ "processors (" VERSION ")\n", supported_cpus);
return cpufreq_register_driver(&cpufreq_amd64_driver);
}
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
index 28cc5d524af..cfc4276e670 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-smi.c
@@ -75,7 +75,9 @@ static int speedstep_smi_ownership (void)
__asm__ __volatile__(
"out %%al, (%%dx)\n"
: "=D" (result)
- : "a" (command), "b" (function), "c" (0), "d" (smi_port), "D" (0), "S" (magic)
+ : "a" (command), "b" (function), "c" (0), "d" (smi_port),
+ "D" (0), "S" (magic)
+ : "memory"
);
dprintk("result is %x\n", result);
diff --git a/arch/i386/kernel/cpu/intel.c b/arch/i386/kernel/cpu/intel.c
index 8c0120186b9..5386b29bb5a 100644
--- a/arch/i386/kernel/cpu/intel.c
+++ b/arch/i386/kernel/cpu/intel.c
@@ -29,7 +29,7 @@ extern int trap_init_f00f_bug(void);
struct movsl_mask movsl_mask __read_mostly;
#endif
-void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
+void __cpuinit early_intel_workaround(struct cpuinfo_x86 *c)
{
if (c->x86_vendor != X86_VENDOR_INTEL)
return;
@@ -44,7 +44,7 @@ void __devinit early_intel_workaround(struct cpuinfo_x86 *c)
* This is called before we do cpu ident work
*/
-int __devinit ppro_with_ram_bug(void)
+int __cpuinit ppro_with_ram_bug(void)
{
/* Uses data from early_cpu_detect now */
if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
@@ -62,7 +62,7 @@ int __devinit ppro_with_ram_bug(void)
* P4 Xeon errata 037 workaround.
* Hardware prefetcher may cause stale data to be loaded into the cache.
*/
-static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
+static void __cpuinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
{
unsigned long lo, hi;
@@ -81,7 +81,7 @@ static void __devinit Intel_errata_workarounds(struct cpuinfo_x86 *c)
/*
* find out the number of processor cores on the die
*/
-static int __devinit num_cpu_cores(struct cpuinfo_x86 *c)
+static int __cpuinit num_cpu_cores(struct cpuinfo_x86 *c)
{
unsigned int eax, ebx, ecx, edx;
@@ -96,7 +96,7 @@ static int __devinit num_cpu_cores(struct cpuinfo_x86 *c)
return 1;
}
-static void __devinit init_intel(struct cpuinfo_x86 *c)
+static void __cpuinit init_intel(struct cpuinfo_x86 *c)
{
unsigned int l2 = 0;
char *p = NULL;
@@ -205,7 +205,7 @@ static unsigned int intel_size_cache(struct cpuinfo_x86 * c, unsigned int size)
return size;
}
-static struct cpu_dev intel_cpu_dev __devinitdata = {
+static struct cpu_dev intel_cpu_dev __cpuinitdata = {
.c_vendor = "Intel",
.c_ident = { "GenuineIntel" },
.c_models = {
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index ffe58cee0c4..ce61921369e 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -174,7 +174,7 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
- if (c->cpuid_level > 4) {
+ if (c->cpuid_level > 3) {
static int is_initialized;
if (is_initialized == 0) {
@@ -330,7 +330,7 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
}
}
}
-static void __devinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
+static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
{
struct _cpuid4_info *this_leaf, *sibling_leaf;
int sibling;
diff --git a/arch/i386/kernel/cpu/proc.c b/arch/i386/kernel/cpu/proc.c
index 89a85af33d2..5cfbd801169 100644
--- a/arch/i386/kernel/cpu/proc.c
+++ b/arch/i386/kernel/cpu/proc.c
@@ -40,7 +40,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
/* Other (Linux-defined) */
"cxmmx", "k6_mtrr", "cyrix_arr", "centaur_mcr",
NULL, NULL, NULL, NULL,
- "constant_tsc", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "constant_tsc", "up", NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
diff --git a/arch/i386/kernel/crash.c b/arch/i386/kernel/crash.c
index d49dbe8dc96..e3c5fca0aa8 100644
--- a/arch/i386/kernel/crash.c
+++ b/arch/i386/kernel/crash.c
@@ -105,7 +105,7 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
return 1;
local_irq_disable();
- if (!user_mode(regs)) {
+ if (!user_mode_vm(regs)) {
crash_fixup_ss_esp(&fixed_regs, regs);
regs = &fixed_regs;
}
diff --git a/arch/i386/kernel/dmi_scan.c b/arch/i386/kernel/dmi_scan.c
index 6a93d75db43..ca2a0cbcac0 100644
--- a/arch/i386/kernel/dmi_scan.c
+++ b/arch/i386/kernel/dmi_scan.c
@@ -106,7 +106,7 @@ static void __init dmi_save_devices(struct dmi_header *dm)
struct dmi_device *dev;
for (i = 0; i < count; i++) {
- char *d = ((char *) dm) + (i * 2);
+ char *d = (char *)(dm + 1) + (i * 2);
/* Skip disabled device */
if ((*d & 0x80) == 0)
diff --git a/arch/i386/kernel/efi.c b/arch/i386/kernel/efi.c
index aeabb419686..7ec6cfa01fb 100644
--- a/arch/i386/kernel/efi.c
+++ b/arch/i386/kernel/efi.c
@@ -543,7 +543,7 @@ efi_initialize_iomem_resources(struct resource *code_resource,
if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
0x100000000ULL)
continue;
- res = alloc_bootmem_low(sizeof(struct resource));
+ res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
switch (md->type) {
case EFI_RESERVED_TYPE:
res->name = "Reserved Memory";
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S
index 4d704724b2f..cfc683f153b 100644
--- a/arch/i386/kernel/entry.S
+++ b/arch/i386/kernel/entry.S
@@ -226,6 +226,10 @@ ENTRY(system_call)
pushl %eax # save orig_eax
SAVE_ALL
GET_THREAD_INFO(%ebp)
+ testl $TF_MASK,EFLAGS(%esp)
+ jz no_singlestep
+ orl $_TIF_SINGLESTEP,TI_flags(%ebp)
+no_singlestep:
# system call tracing in operation / emulation
/* Note, _TIF_SECCOMP is bit number 8, and so it needs testw and not testb */
testw $(_TIF_SYSCALL_EMU|_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT),TI_flags(%ebp)
diff --git a/arch/i386/kernel/head.S b/arch/i386/kernel/head.S
index e0b7c632efb..3debc2e2654 100644
--- a/arch/i386/kernel/head.S
+++ b/arch/i386/kernel/head.S
@@ -450,7 +450,6 @@ int_msg:
.globl boot_gdt_descr
.globl idt_descr
-.globl cpu_gdt_descr
ALIGN
# early boot GDT descriptor (must use 1:1 address mapping)
@@ -470,8 +469,6 @@ cpu_gdt_descr:
.word GDT_ENTRIES*8-1
.long cpu_gdt_table
- .fill NR_CPUS-1,8,0 # space for the other GDT descriptors
-
/*
* The boot_gdt_table must mirror the equivalent in setup.S and is
* used only for booting.
@@ -485,7 +482,7 @@ ENTRY(boot_gdt_table)
/*
* The Global Descriptor Table contains 28 quadwords, per-CPU.
*/
- .align PAGE_SIZE_asm
+ .align L1_CACHE_BYTES
ENTRY(cpu_gdt_table)
.quad 0x0000000000000000 /* NULL descriptor */
.quad 0x0000000000000000 /* 0x0b reserved */
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 39d9a5fa907..311b4e7266f 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -351,8 +351,8 @@ static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold)
{
int i, j;
Dprintk("Rotating IRQs among CPUs.\n");
- for (i = 0; i < NR_CPUS; i++) {
- for (j = 0; cpu_online(i) && (j < NR_IRQS); j++) {
+ for_each_online_cpu(i) {
+ for (j = 0; j < NR_IRQS; j++) {
if (!irq_desc[j].action)
continue;
/* Is it a significant load ? */
@@ -381,7 +381,7 @@ static void do_irq_balance(void)
unsigned long imbalance = 0;
cpumask_t allowed_mask, target_cpu_mask, tmp;
- for (i = 0; i < NR_CPUS; i++) {
+ for_each_cpu(i) {
int package_index;
CPU_IRQ(i) = 0;
if (!cpu_online(i))
@@ -422,9 +422,7 @@ static void do_irq_balance(void)
}
}
/* Find the least loaded processor package */
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (i != CPU_TO_PACKAGEINDEX(i))
continue;
if (min_cpu_irq > CPU_IRQ(i)) {
@@ -441,9 +439,7 @@ tryanothercpu:
*/
tmp_cpu_irq = 0;
tmp_loaded = -1;
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (i != CPU_TO_PACKAGEINDEX(i))
continue;
if (max_cpu_irq <= CPU_IRQ(i))
@@ -619,9 +615,7 @@ static int __init balanced_irq_init(void)
if (smp_num_siblings > 1 && !cpus_empty(tmp))
physical_balance = 1;
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
irq_cpu_data[i].irq_delta = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL);
irq_cpu_data[i].last_irq = kmalloc(sizeof(unsigned long) * NR_IRQS, GFP_KERNEL);
if (irq_cpu_data[i].irq_delta == NULL || irq_cpu_data[i].last_irq == NULL) {
@@ -638,9 +632,11 @@ static int __init balanced_irq_init(void)
else
printk(KERN_ERR "balanced_irq_init: failed to spawn balanced_irq");
failed:
- for (i = 0; i < NR_CPUS; i++) {
+ for_each_cpu(i) {
kfree(irq_cpu_data[i].irq_delta);
+ irq_cpu_data[i].irq_delta = NULL;
kfree(irq_cpu_data[i].last_irq);
+ irq_cpu_data[i].last_irq = NULL;
}
return 0;
}
@@ -1761,7 +1757,8 @@ static void __init setup_ioapic_ids_from_mpc(void)
* Don't check I/O APIC IDs for xAPIC systems. They have
* no meaning without the serial APIC bus.
*/
- if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && boot_cpu_data.x86 < 15))
+ if (!(boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+ || APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
return;
/*
* This is broken; anything with a real cpu count has to
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 694a1399763..7a59050242a 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -84,9 +84,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
void __kprobes arch_remove_kprobe(struct kprobe *p)
{
- down(&kprobe_mutex);
+ mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
}
static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
diff --git a/arch/i386/kernel/module.c b/arch/i386/kernel/module.c
index 5149c8a621f..470cf97e7cd 100644
--- a/arch/i386/kernel/module.c
+++ b/arch/i386/kernel/module.c
@@ -104,26 +104,38 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
return -ENOEXEC;
}
-extern void apply_alternatives(void *start, void *end);
-
int module_finalize(const Elf_Ehdr *hdr,
const Elf_Shdr *sechdrs,
struct module *me)
{
- const Elf_Shdr *s;
+ const Elf_Shdr *s, *text = NULL, *alt = NULL, *locks = NULL;
char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset;
- /* look for .altinstructions to patch */
for (s = sechdrs; s < sechdrs + hdr->e_shnum; s++) {
- void *seg;
- if (strcmp(".altinstructions", secstrings + s->sh_name))
- continue;
- seg = (void *)s->sh_addr;
- apply_alternatives(seg, seg + s->sh_size);
- }
+ if (!strcmp(".text", secstrings + s->sh_name))
+ text = s;
+ if (!strcmp(".altinstructions", secstrings + s->sh_name))
+ alt = s;
+ if (!strcmp(".smp_locks", secstrings + s->sh_name))
+ locks= s;
+ }
+
+ if (alt) {
+ /* patch .altinstructions */
+ void *aseg = (void *)alt->sh_addr;
+ apply_alternatives(aseg, aseg + alt->sh_size);
+ }
+ if (locks && text) {
+ void *lseg = (void *)locks->sh_addr;
+ void *tseg = (void *)text->sh_addr;
+ alternatives_smp_module_add(me, me->name,
+ lseg, lseg + locks->sh_size,
+ tseg, tseg + text->sh_size);
+ }
return 0;
}
void module_arch_cleanup(struct module *mod)
{
+ alternatives_smp_module_del(mod);
}
diff --git a/arch/i386/kernel/mpparse.c b/arch/i386/kernel/mpparse.c
index e6e2f43db85..8d8aa9d1796 100644
--- a/arch/i386/kernel/mpparse.c
+++ b/arch/i386/kernel/mpparse.c
@@ -828,6 +828,8 @@ void __init find_smp_config (void)
smp_scan_config(address, 0x400);
}
+int es7000_plat;
+
/* --------------------------------------------------------------------------
ACPI-based MP Configuration
-------------------------------------------------------------------------- */
@@ -935,7 +937,8 @@ void __init mp_register_ioapic (
mp_ioapics[idx].mpc_apicaddr = address;
set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
- if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) && (boot_cpu_data.x86 < 15))
+ if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
+ && !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
tmpid = io_apic_get_unique_id(idx, id);
else
tmpid = id;
@@ -1011,8 +1014,6 @@ void __init mp_override_legacy_irq (
return;
}
-int es7000_plat;
-
void __init mp_config_acpi_legacy_irqs (void)
{
struct mpc_config_intsrc intsrc;
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index be87c5e2ee9..9074818b947 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -143,7 +143,7 @@ static int __init check_nmi_watchdog(void)
local_irq_enable();
mdelay((10*1000)/nmi_hz); // wait 10 ticks
- for (cpu = 0; cpu < NR_CPUS; cpu++) {
+ for_each_cpu(cpu) {
#ifdef CONFIG_SMP
/* Check cpu_callin_map here because that is set
after the timer is started. */
@@ -510,7 +510,7 @@ void touch_nmi_watchdog (void)
* Just reset the alert counters, (other CPUs might be
* spinning on locks we hold):
*/
- for (i = 0; i < NR_CPUS; i++)
+ for_each_cpu(i)
alert_counter[i] = 0;
/*
@@ -543,7 +543,7 @@ void nmi_watchdog_tick (struct pt_regs * regs)
/*
* die_nmi will return ONLY if NOTIFY_STOP happens..
*/
- die_nmi(regs, "NMI Watchdog detected LOCKUP");
+ die_nmi(regs, "BUG: NMI Watchdog detected LOCKUP");
} else {
last_irq_sums[cpu] = sum;
alert_counter[cpu] = 0;
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 0480454ebff..299e6167408 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -295,7 +295,7 @@ void show_regs(struct pt_regs * regs)
printk("EIP: %04x:[<%08lx>] CPU: %d\n",0xffff & regs->xcs,regs->eip, smp_processor_id());
print_symbol("EIP is at %s\n", regs->eip);
- if (user_mode(regs))
+ if (user_mode_vm(regs))
printk(" ESP: %04x:%08lx",0xffff & regs->xss,regs->esp);
printk(" EFLAGS: %08lx %s (%s %.*s)\n",
regs->eflags, print_tainted(), system_utsname.release,
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index 5c1fb6aada5..506462ef36a 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -34,10 +34,10 @@
/*
* Determines which flags the user has access to [1 = access, 0 = no access].
- * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), IOPL(12-13), IF(9).
+ * Prohibits changing ID(21), VIP(20), VIF(19), VM(17), NT(14), IOPL(12-13), IF(9).
* Also masks reserved bits (31-22, 15, 5, 3, 1).
*/
-#define FLAG_MASK 0x00054dd5
+#define FLAG_MASK 0x00050dd5
/* set's the trap flag. */
#define TRAP_FLAG 0x100
diff --git a/arch/i386/kernel/semaphore.c b/arch/i386/kernel/semaphore.c
index 7455ab64394..967dc74df9e 100644
--- a/arch/i386/kernel/semaphore.c
+++ b/arch/i386/kernel/semaphore.c
@@ -110,11 +110,11 @@ asm(
".align 4\n"
".globl __write_lock_failed\n"
"__write_lock_failed:\n\t"
- LOCK "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
+ LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
"1: rep; nop\n\t"
"cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
"jne 1b\n\t"
- LOCK "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
+ LOCK_PREFIX "subl $" RW_LOCK_BIAS_STR ",(%eax)\n\t"
"jnz __write_lock_failed\n\t"
"ret"
);
@@ -124,11 +124,11 @@ asm(
".align 4\n"
".globl __read_lock_failed\n"
"__read_lock_failed:\n\t"
- LOCK "incl (%eax)\n"
+ LOCK_PREFIX "incl (%eax)\n"
"1: rep; nop\n\t"
"cmpl $1,(%eax)\n\t"
"js 1b\n\t"
- LOCK "decl (%eax)\n\t"
+ LOCK_PREFIX "decl (%eax)\n\t"
"js __read_lock_failed\n\t"
"ret"
);
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index ab62a9f4701..d313a11acaf 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -1288,7 +1288,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
struct resource *res;
if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL)
continue;
- res = alloc_bootmem_low(sizeof(struct resource));
+ res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
switch (e820.map[i].type) {
case E820_RAM: res->name = "System RAM"; break;
case E820_ACPI: res->name = "ACPI Tables"; break;
@@ -1316,13 +1316,15 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
/*
* Request address space for all standard resources
+ *
+ * This is called just before pcibios_assign_resources(), which is also
+ * an fs_initcall, but is linked in later (in arch/i386/pci/i386.c).
*/
-static void __init register_memory(void)
+static int __init request_standard_resources(void)
{
- unsigned long gapstart, gapsize, round;
- unsigned long long last;
- int i;
+ int i;
+ printk("Setting up standard PCI resources\n");
if (efi_enabled)
efi_initialize_iomem_resources(&code_resource, &data_resource);
else
@@ -1334,6 +1336,16 @@ static void __init register_memory(void)
/* request I/O space for devices used on all i[345]86 PCs */
for (i = 0; i < STANDARD_IO_RESOURCES; i++)
request_resource(&ioport_resource, &standard_io_resources[i]);
+ return 0;
+}
+
+fs_initcall(request_standard_resources);
+
+static void __init register_memory(void)
+{
+ unsigned long gapstart, gapsize, round;
+ unsigned long long last;
+ int i;
/*
* Search for the bigest gap in the low 32 bits of the e820
@@ -1377,101 +1389,6 @@ static void __init register_memory(void)
pci_mem_start, gapstart, gapsize);
}
-/* Use inline assembly to define this because the nops are defined
- as inline assembly strings in the include files and we cannot
- get them easily into strings. */
-asm("\t.data\nintelnops: "
- GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
- GENERIC_NOP7 GENERIC_NOP8);
-asm("\t.data\nk8nops: "
- K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
- K8_NOP7 K8_NOP8);
-asm("\t.data\nk7nops: "
- K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
- K7_NOP7 K7_NOP8);
-
-extern unsigned char intelnops[], k8nops[], k7nops[];
-static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
- NULL,
- intelnops,
- intelnops + 1,
- intelnops + 1 + 2,
- intelnops + 1 + 2 + 3,
- intelnops + 1 + 2 + 3 + 4,
- intelnops + 1 + 2 + 3 + 4 + 5,
- intelnops + 1 + 2 + 3 + 4 + 5 + 6,
- intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
-};
-static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
- NULL,
- k8nops,
- k8nops + 1,
- k8nops + 1 + 2,
- k8nops + 1 + 2 + 3,
- k8nops + 1 + 2 + 3 + 4,
- k8nops + 1 + 2 + 3 + 4 + 5,
- k8nops + 1 + 2 + 3 + 4 + 5 + 6,
- k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
-};
-static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
- NULL,
- k7nops,
- k7nops + 1,
- k7nops + 1 + 2,
- k7nops + 1 + 2 + 3,
- k7nops + 1 + 2 + 3 + 4,
- k7nops + 1 + 2 + 3 + 4 + 5,
- k7nops + 1 + 2 + 3 + 4 + 5 + 6,
- k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
-};
-static struct nop {
- int cpuid;
- unsigned char **noptable;
-} noptypes[] = {
- { X86_FEATURE_K8, k8_nops },
- { X86_FEATURE_K7, k7_nops },
- { -1, NULL }
-};
-
-/* Replace instructions with better alternatives for this CPU type.
-
- This runs before SMP is initialized to avoid SMP problems with
- self modifying code. This implies that assymetric systems where
- APs have less capabilities than the boot processor are not handled.
- Tough. Make sure you disable such features by hand. */
-void apply_alternatives(void *start, void *end)
-{
- struct alt_instr *a;
- int diff, i, k;
- unsigned char **noptable = intel_nops;
- for (i = 0; noptypes[i].cpuid >= 0; i++) {
- if (boot_cpu_has(noptypes[i].cpuid)) {
- noptable = noptypes[i].noptable;
- break;
- }
- }
- for (a = start; (void *)a < end; a++) {
- if (!boot_cpu_has(a->cpuid))
- continue;
- BUG_ON(a->replacementlen > a->instrlen);
- memcpy(a->instr, a->replacement, a->replacementlen);
- diff = a->instrlen - a->replacementlen;
- /* Pad the rest with nops */
- for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
- k = diff;
- if (k > ASM_NOP_MAX)
- k = ASM_NOP_MAX;
- memcpy(a->instr + i, noptable[k], k);
- }
- }
-}
-
-void __init alternative_instructions(void)
-{
- extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
- apply_alternatives(__alt_instructions, __alt_instructions_end);
-}
-
static char * __init machine_specific_memory_setup(void);
#ifdef CONFIG_MCA
@@ -1554,6 +1471,16 @@ void __init setup_arch(char **cmdline_p)
parse_cmdline_early(cmdline_p);
+#ifdef CONFIG_EARLY_PRINTK
+ {
+ char *s = strstr(*cmdline_p, "earlyprintk=");
+ if (s) {
+ setup_early_printk(strchr(s, '=') + 1);
+ printk("early console enabled\n");
+ }
+ }
+#endif
+
max_low_pfn = setup_memory();
/*
@@ -1578,19 +1505,6 @@ void __init setup_arch(char **cmdline_p)
* NOTE: at this point the bootmem allocator is fully available.
*/
-#ifdef CONFIG_EARLY_PRINTK
- {
- char *s = strstr(*cmdline_p, "earlyprintk=");
- if (s) {
- extern void setup_early_printk(char *);
-
- setup_early_printk(strchr(s, '=') + 1);
- printk("early console enabled\n");
- }
- }
-#endif
-
-
dmi_scan_machine();
#ifdef CONFIG_X86_GENERICARCH
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index 963616d364e..5c352c3a9e7 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -123,7 +123,8 @@ restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc, int *peax
err |= __get_user(tmp, &sc->seg); \
loadsegment(seg,tmp); }
-#define FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_OF | X86_EFLAGS_DF | \
+#define FIX_EFLAGS (X86_EFLAGS_AC | X86_EFLAGS_RF | \
+ X86_EFLAGS_OF | X86_EFLAGS_DF | \
X86_EFLAGS_TF | X86_EFLAGS_SF | X86_EFLAGS_ZF | \
X86_EFLAGS_AF | X86_EFLAGS_PF | X86_EFLAGS_CF)
@@ -582,9 +583,6 @@ static void fastcall do_signal(struct pt_regs *regs)
if (!user_mode(regs))
return;
- if (try_to_freeze())
- goto no_signal;
-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
oldset = &current->saved_sigmask;
else
@@ -613,7 +611,6 @@ static void fastcall do_signal(struct pt_regs *regs)
return;
}
-no_signal:
/* Did we come from a system call? */
if (regs->orig_eax >= 0) {
/* Restart the system call - no handlers present */
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 7007e178379..82371d83bfa 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -899,6 +899,7 @@ static int __devinit do_boot_cpu(int apicid, int cpu)
unsigned short nmi_high = 0, nmi_low = 0;
++cpucount;
+ alternatives_smp_switch(1);
/*
* We can't use kernel_thread since we must avoid to
@@ -1002,7 +1003,6 @@ void cpu_exit_clear(void)
cpu_clear(cpu, cpu_callout_map);
cpu_clear(cpu, cpu_callin_map);
- cpu_clear(cpu, cpu_present_map);
cpu_clear(cpu, smp_commenced_mask);
unmap_cpu_to_logical_apicid(cpu);
@@ -1014,31 +1014,20 @@ struct warm_boot_cpu_info {
int cpu;
};
-static void __devinit do_warm_boot_cpu(void *p)
+static void __cpuinit do_warm_boot_cpu(void *p)
{
struct warm_boot_cpu_info *info = p;
do_boot_cpu(info->apicid, info->cpu);
complete(info->complete);
}
-int __devinit smp_prepare_cpu(int cpu)
+static int __cpuinit __smp_prepare_cpu(int cpu)
{
DECLARE_COMPLETION(done);
struct warm_boot_cpu_info info;
struct work_struct task;
int apicid, ret;
- lock_cpu_hotplug();
-
- /*
- * On x86, CPU0 is never offlined. Trying to bring up an
- * already-booted CPU will hang. So check for that case.
- */
- if (cpu_online(cpu)) {
- ret = -EINVAL;
- goto exit;
- }
-
apicid = x86_cpu_to_apicid[cpu];
if (apicid == BAD_APICID) {
ret = -ENODEV;
@@ -1063,7 +1052,6 @@ int __devinit smp_prepare_cpu(int cpu)
zap_low_mappings();
ret = 0;
exit:
- unlock_cpu_hotplug();
return ret;
}
#endif
@@ -1368,6 +1356,8 @@ void __cpu_die(unsigned int cpu)
/* They ack this in play_dead by setting CPU_DEAD */
if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
printk ("CPU %d is now offline\n", cpu);
+ if (1 == num_online_cpus())
+ alternatives_smp_switch(0);
return;
}
msleep(100);
@@ -1389,6 +1379,22 @@ void __cpu_die(unsigned int cpu)
int __devinit __cpu_up(unsigned int cpu)
{
+#ifdef CONFIG_HOTPLUG_CPU
+ int ret=0;
+
+ /*
+ * We do warm boot only on cpus that had booted earlier
+ * Otherwise cold boot is all handled from smp_boot_cpus().
+ * cpu_callin_map is set during AP kickstart process. Its reset
+ * when a cpu is taken offline from cpu_exit_clear().
+ */
+ if (!cpu_isset(cpu, cpu_callin_map))
+ ret = __smp_prepare_cpu(cpu);
+
+ if (ret)
+ return -EIO;
+#endif
+
/* In case one didn't come up */
if (!cpu_isset(cpu, cpu_callin_map)) {
printk(KERN_DEBUG "skipping cpu%d, didn't come online\n", cpu);
diff --git a/arch/i386/kernel/topology.c b/arch/i386/kernel/topology.c
index 67a0e1baa28..296355292c7 100644
--- a/arch/i386/kernel/topology.c
+++ b/arch/i386/kernel/topology.c
@@ -41,6 +41,15 @@ int arch_register_cpu(int num){
parent = &node_devices[node].node;
#endif /* CONFIG_NUMA */
+ /*
+ * CPU0 cannot be offlined due to several
+ * restrictions and assumptions in kernel. This basically
+ * doesnt add a control file, one cannot attempt to offline
+ * BSP.
+ */
+ if (!num)
+ cpu_devices[num].cpu.no_control = 1;
+
return register_cpu(&cpu_devices[num].cpu, num, parent);
}
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index b814dbdcc91..de5386b01d3 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -99,6 +99,8 @@ int register_die_notifier(struct notifier_block *nb)
{
int err = 0;
unsigned long flags;
+
+ vmalloc_sync_all();
spin_lock_irqsave(&die_notifier_lock, flags);
err = notifier_chain_register(&i386die_chain, nb);
spin_unlock_irqrestore(&die_notifier_lock, flags);
@@ -112,12 +114,30 @@ static inline int valid_stack_ptr(struct thread_info *tinfo, void *p)
p < (void *)tinfo + THREAD_SIZE - 3;
}
-static void print_addr_and_symbol(unsigned long addr, char *log_lvl)
+/*
+ * Print CONFIG_STACK_BACKTRACE_COLS address/symbol entries per line.
+ */
+static inline int print_addr_and_symbol(unsigned long addr, char *log_lvl,
+ int printed)
{
- printk(log_lvl);
+ if (!printed)
+ printk(log_lvl);
+
+#if CONFIG_STACK_BACKTRACE_COLS == 1
printk(" [<%08lx>] ", addr);
+#else
+ printk(" <%08lx> ", addr);
+#endif
print_symbol("%s", addr);
- printk("\n");
+
+ printed = (printed + 1) % CONFIG_STACK_BACKTRACE_COLS;
+
+ if (printed)
+ printk(" ");
+ else
+ printk("\n");
+
+ return printed;
}
static inline unsigned long print_context_stack(struct thread_info *tinfo,
@@ -125,20 +145,24 @@ static inline unsigned long print_context_stack(struct thread_info *tinfo,
char *log_lvl)
{
unsigned long addr;
+ int printed = 0; /* nr of entries already printed on current line */
#ifdef CONFIG_FRAME_POINTER
while (valid_stack_ptr(tinfo, (void *)ebp)) {
addr = *(unsigned long *)(ebp + 4);
- print_addr_and_symbol(addr, log_lvl);
+ printed = print_addr_and_symbol(addr, log_lvl, printed);
ebp = *(unsigned long *)ebp;
}
#else
while (valid_stack_ptr(tinfo, stack)) {
addr = *stack++;
if (__kernel_text_address(addr))
- print_addr_and_symbol(addr, log_lvl);
+ printed = print_addr_and_symbol(addr, log_lvl, printed);
}
#endif
+ if (printed)
+ printk("\n");
+
return ebp;
}
@@ -166,8 +190,7 @@ static void show_trace_log_lvl(struct task_struct *task,
stack = (unsigned long*)context->previous_esp;
if (!stack)
break;
- printk(log_lvl);
- printk(" =======================\n");
+ printk("%s =======================\n", log_lvl);
}
}
@@ -194,21 +217,17 @@ static void show_stack_log_lvl(struct task_struct *task, unsigned long *esp,
for(i = 0; i < kstack_depth_to_print; i++) {
if (kstack_end(stack))
break;
- if (i && ((i % 8) == 0)) {
- printk("\n");
- printk(log_lvl);
- printk(" ");
- }
+ if (i && ((i % 8) == 0))
+ printk("\n%s ", log_lvl);
printk("%08lx ", *stack++);
}
- printk("\n");
- printk(log_lvl);
- printk("Call Trace:\n");
+ printk("\n%sCall Trace:\n", log_lvl);
show_trace_log_lvl(task, esp, log_lvl);
}
void show_stack(struct task_struct *task, unsigned long *esp)
{
+ printk(" ");
show_stack_log_lvl(task, esp, "");
}
@@ -233,7 +252,7 @@ void show_registers(struct pt_regs *regs)
esp = (unsigned long) (&regs->esp);
savesegment(ss, ss);
- if (user_mode(regs)) {
+ if (user_mode_vm(regs)) {
in_kernel = 0;
esp = regs->esp;
ss = regs->xss & 0xffff;
@@ -333,6 +352,8 @@ void die(const char * str, struct pt_regs * regs, long err)
static int die_counter;
unsigned long flags;
+ oops_enter();
+
if (die.lock_owner != raw_smp_processor_id()) {
console_verbose();
spin_lock_irqsave(&die.lock, flags);
@@ -385,6 +406,7 @@ void die(const char * str, struct pt_regs * regs, long err)
ssleep(5);
panic("Fatal exception");
}
+ oops_exit();
do_exit(SIGSEGV);
}
@@ -623,7 +645,7 @@ void die_nmi (struct pt_regs *regs, const char *msg)
/* If we are in kernel we are probably nested up pretty bad
* and might aswell get out now while we still can.
*/
- if (!user_mode(regs)) {
+ if (!user_mode_vm(regs)) {
current->thread.trap_no = 2;
crash_kexec(regs);
}
@@ -694,6 +716,7 @@ fastcall void do_nmi(struct pt_regs * regs, long error_code)
void set_nmi_callback(nmi_callback_t callback)
{
+ vmalloc_sync_all();
rcu_assign_pointer(nmi_callback, callback);
}
EXPORT_SYMBOL_GPL(set_nmi_callback);
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 4710195b6b7..8831303a473 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -7,6 +7,7 @@
#include <asm-generic/vmlinux.lds.h>
#include <asm/thread_info.h>
#include <asm/page.h>
+#include <asm/cache.h>
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
@@ -68,6 +69,26 @@ SECTIONS
*(.data.init_task)
}
+ /* might get freed after init */
+ . = ALIGN(4096);
+ __smp_alt_begin = .;
+ __smp_alt_instructions = .;
+ .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
+ *(.smp_altinstructions)
+ }
+ __smp_alt_instructions_end = .;
+ . = ALIGN(4);
+ __smp_locks = .;
+ .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
+ *(.smp_locks)
+ }
+ __smp_locks_end = .;
+ .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
+ *(.smp_altinstr_replacement)
+ }
+ . = ALIGN(4096);
+ __smp_alt_end = .;
+
/* will be freed after init */
. = ALIGN(4096); /* Init code and data */
__init_begin = .;
@@ -115,7 +136,7 @@ SECTIONS
__initramfs_start = .;
.init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
__initramfs_end = .;
- . = ALIGN(32);
+ . = ALIGN(L1_CACHE_BYTES);
__per_cpu_start = .;
.data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
__per_cpu_end = .;
diff --git a/arch/i386/kernel/vsyscall-sysenter.S b/arch/i386/kernel/vsyscall-sysenter.S
index 76b72815940..3b62baa6a37 100644
--- a/arch/i386/kernel/vsyscall-sysenter.S
+++ b/arch/i386/kernel/vsyscall-sysenter.S
@@ -21,6 +21,9 @@
* instruction clobbers %esp, the user's %esp won't even survive entry
* into the kernel. We store %esp in %ebp. Code in entry.S must fetch
* arg6 from the stack.
+ *
+ * You can not use this vsyscall for the clone() syscall because the
+ * three dwords on the parent stack do not get copied to the child.
*/
.text
.globl __kernel_vsyscall
diff --git a/arch/i386/mach-es7000/es7000.h b/arch/i386/mach-es7000/es7000.h
index f1e3204f5de..80566ca4a80 100644
--- a/arch/i386/mach-es7000/es7000.h
+++ b/arch/i386/mach-es7000/es7000.h
@@ -83,6 +83,7 @@ struct es7000_oem_table {
struct psai psai;
};
+#ifdef CONFIG_ACPI
struct acpi_table_sdt {
unsigned long pa;
unsigned long count;
@@ -99,6 +100,9 @@ struct oem_table {
u32 OEMTableSize;
};
+extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
+#endif
+
struct mip_reg {
unsigned long long off_0;
unsigned long long off_8;
@@ -114,7 +118,6 @@ struct mip_reg {
#define MIP_FUNC(VALUE) (VALUE & 0xff)
extern int parse_unisys_oem (char *oemptr);
-extern int find_unisys_acpi_oem_table(unsigned long *oem_addr);
extern void setup_unisys(void);
extern int es7000_start_cpu(int cpu, unsigned long eip);
extern void es7000_sw_apic(void);
diff --git a/arch/i386/mach-es7000/es7000plat.c b/arch/i386/mach-es7000/es7000plat.c
index a9ab0644f40..3d0fc853516 100644
--- a/arch/i386/mach-es7000/es7000plat.c
+++ b/arch/i386/mach-es7000/es7000plat.c
@@ -51,8 +51,6 @@ struct mip_reg *host_reg;
int mip_port;
unsigned long mip_addr, host_addr;
-#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_ACPI)
-
/*
* GSI override for ES7000 platforms.
*/
@@ -76,8 +74,6 @@ es7000_rename_gsi(int ioapic, int gsi)
return gsi;
}
-#endif /* (CONFIG_X86_IO_APIC) && (CONFIG_ACPI) */
-
void __init
setup_unisys(void)
{
@@ -160,6 +156,7 @@ parse_unisys_oem (char *oemptr)
return es7000_plat;
}
+#ifdef CONFIG_ACPI
int __init
find_unisys_acpi_oem_table(unsigned long *oem_addr)
{
@@ -212,6 +209,7 @@ find_unisys_acpi_oem_table(unsigned long *oem_addr)
}
return -1;
}
+#endif
static void
es7000_spin(int n)
diff --git a/arch/i386/mach-visws/reboot.c b/arch/i386/mach-visws/reboot.c
index 5d73e042ed0..99332abfad4 100644
--- a/arch/i386/mach-visws/reboot.c
+++ b/arch/i386/mach-visws/reboot.c
@@ -1,7 +1,6 @@
#include <linux/module.h>
#include <linux/smp.h>
#include <linux/delay.h>
-#include <linux/platform.h>
#include <asm/io.h>
#include "piix4.h"
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index cf572d9a3b6..7f0fcf219a2 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -214,6 +214,68 @@ static noinline void force_sig_info_fault(int si_signo, int si_code,
fastcall void do_invalid_op(struct pt_regs *, unsigned long);
+static inline pmd_t *vmalloc_sync_one(pgd_t *pgd, unsigned long address)
+{
+ unsigned index = pgd_index(address);
+ pgd_t *pgd_k;
+ pud_t *pud, *pud_k;
+ pmd_t *pmd, *pmd_k;
+
+ pgd += index;
+ pgd_k = init_mm.pgd + index;
+
+ if (!pgd_present(*pgd_k))
+ return NULL;
+
+ /*
+ * set_pgd(pgd, *pgd_k); here would be useless on PAE
+ * and redundant with the set_pmd() on non-PAE. As would
+ * set_pud.
+ */
+
+ pud = pud_offset(pgd, address);
+ pud_k = pud_offset(pgd_k, address);
+ if (!pud_present(*pud_k))
+ return NULL;
+
+ pmd = pmd_offset(pud, address);
+ pmd_k = pmd_offset(pud_k, address);
+ if (!pmd_present(*pmd_k))
+ return NULL;
+ if (!pmd_present(*pmd))
+ set_pmd(pmd, *pmd_k);
+ else
+ BUG_ON(pmd_page(*pmd) != pmd_page(*pmd_k));
+ return pmd_k;
+}
+
+/*
+ * Handle a fault on the vmalloc or module mapping area
+ *
+ * This assumes no large pages in there.
+ */
+static inline int vmalloc_fault(unsigned long address)
+{
+ unsigned long pgd_paddr;
+ pmd_t *pmd_k;
+ pte_t *pte_k;
+ /*
+ * Synchronize this task's top level page-table
+ * with the 'reference' page table.
+ *
+ * Do _not_ use "current" here. We might be inside
+ * an interrupt in the middle of a task switch..
+ */
+ pgd_paddr = read_cr3();
+ pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
+ if (!pmd_k)
+ return -1;
+ pte_k = pte_offset_kernel(pmd_k, address);
+ if (!pte_present(*pte_k))
+ return -1;
+ return 0;
+}
+
/*
* This routine handles page faults. It determines the address,
* and the problem, and then passes it off to one of the appropriate
@@ -223,6 +285,8 @@ fastcall void do_invalid_op(struct pt_regs *, unsigned long);
* bit 0 == 0 means no page found, 1 means protection fault
* bit 1 == 0 means read, 1 means write
* bit 2 == 0 means kernel, 1 means user-mode
+ * bit 3 == 1 means use of reserved bit detected
+ * bit 4 == 1 means fault was an instruction fetch
*/
fastcall void __kprobes do_page_fault(struct pt_regs *regs,
unsigned long error_code)
@@ -237,13 +301,6 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs,
/* get the address */
address = read_cr2();
- if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
- SIGSEGV) == NOTIFY_STOP)
- return;
- /* It's safe to allow irq's after cr2 has been saved */
- if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
- local_irq_enable();
-
tsk = current;
si_code = SEGV_MAPERR;
@@ -259,17 +316,29 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs,
*
* This verifies that the fault happens in kernel space
* (error_code & 4) == 0, and that the fault was not a
- * protection error (error_code & 1) == 0.
+ * protection error (error_code & 9) == 0.
*/
- if (unlikely(address >= TASK_SIZE)) {
- if (!(error_code & 5))
- goto vmalloc_fault;
- /*
+ if (unlikely(address >= TASK_SIZE)) {
+ if (!(error_code & 0x0000000d) && vmalloc_fault(address) >= 0)
+ return;
+ if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
+ SIGSEGV) == NOTIFY_STOP)
+ return;
+ /*
* Don't take the mm semaphore here. If we fixup a prefetch
* fault we could otherwise deadlock.
*/
goto bad_area_nosemaphore;
- }
+ }
+
+ if (notify_die(DIE_PAGE_FAULT, "page fault", regs, error_code, 14,
+ SIGSEGV) == NOTIFY_STOP)
+ return;
+
+ /* It's safe to allow irq's after cr2 has been saved and the vmalloc
+ fault has been handled. */
+ if (regs->eflags & (X86_EFLAGS_IF|VM_MASK))
+ local_irq_enable();
mm = tsk->mm;
@@ -440,24 +509,31 @@ no_context:
bust_spinlocks(1);
-#ifdef CONFIG_X86_PAE
- if (error_code & 16) {
- pte_t *pte = lookup_address(address);
+ if (oops_may_print()) {
+ #ifdef CONFIG_X86_PAE
+ if (error_code & 16) {
+ pte_t *pte = lookup_address(address);
- if (pte && pte_present(*pte) && !pte_exec_kernel(*pte))
- printk(KERN_CRIT "kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n", current->uid);
+ if (pte && pte_present(*pte) && !pte_exec_kernel(*pte))
+ printk(KERN_CRIT "kernel tried to execute "
+ "NX-protected page - exploit attempt? "
+ "(uid: %d)\n", current->uid);
+ }
+ #endif
+ if (address < PAGE_SIZE)
+ printk(KERN_ALERT "BUG: unable to handle kernel NULL "
+ "pointer dereference");
+ else
+ printk(KERN_ALERT "BUG: unable to handle kernel paging"
+ " request");
+ printk(" at virtual address %08lx\n",address);
+ printk(KERN_ALERT " printing eip:\n");
+ printk("%08lx\n", regs->eip);
}
-#endif
- if (address < PAGE_SIZE)
- printk(KERN_ALERT "Unable to handle kernel NULL pointer dereference");
- else
- printk(KERN_ALERT "Unable to handle kernel paging request");
- printk(" at virtual address %08lx\n",address);
- printk(KERN_ALERT " printing eip:\n");
- printk("%08lx\n", regs->eip);
page = read_cr3();
page = ((unsigned long *) __va(page))[address >> 22];
- printk(KERN_ALERT "*pde = %08lx\n", page);
+ if (oops_may_print())
+ printk(KERN_ALERT "*pde = %08lx\n", page);
/*
* We must not directly access the pte in the highpte
* case, the page table might be allocated in highmem.
@@ -465,7 +541,7 @@ no_context:
* it's allocated already.
*/
#ifndef CONFIG_HIGHPTE
- if (page & 1) {
+ if ((page & 1) && oops_may_print()) {
page &= PAGE_MASK;
address &= 0x003ff000;
page = ((unsigned long *) __va(page))[address >> PAGE_SHIFT];
@@ -510,51 +586,41 @@ do_sigbus:
tsk->thread.error_code = error_code;
tsk->thread.trap_no = 14;
force_sig_info_fault(SIGBUS, BUS_ADRERR, address, tsk);
- return;
-
-vmalloc_fault:
- {
- /*
- * Synchronize this task's top level page-table
- * with the 'reference' page table.
- *
- * Do _not_ use "tsk" here. We might be inside
- * an interrupt in the middle of a task switch..
- */
- int index = pgd_index(address);
- unsigned long pgd_paddr;
- pgd_t *pgd, *pgd_k;
- pud_t *pud, *pud_k;
- pmd_t *pmd, *pmd_k;
- pte_t *pte_k;
-
- pgd_paddr = read_cr3();
- pgd = index + (pgd_t *)__va(pgd_paddr);
- pgd_k = init_mm.pgd + index;
-
- if (!pgd_present(*pgd_k))
- goto no_context;
-
- /*
- * set_pgd(pgd, *pgd_k); here would be useless on PAE
- * and redundant with the set_pmd() on non-PAE. As would
- * set_pud.
- */
+}
- pud = pud_offset(pgd, address);
- pud_k = pud_offset(pgd_k, address);
- if (!pud_present(*pud_k))
- goto no_context;
-
- pmd = pmd_offset(pud, address);
- pmd_k = pmd_offset(pud_k, address);
- if (!pmd_present(*pmd_k))
- goto no_context;
- set_pmd(pmd, *pmd_k);
+#ifndef CONFIG_X86_PAE
+void vmalloc_sync_all(void)
+{
+ /*
+ * Note that races in the updates of insync and start aren't
+ * problematic: insync can only get set bits added, and updates to
+ * start are only improving performance (without affecting correctness
+ * if undone).
+ */
+ static DECLARE_BITMAP(insync, PTRS_PER_PGD);
+ static unsigned long start = TASK_SIZE;
+ unsigned long address;
- pte_k = pte_offset_kernel(pmd_k, address);
- if (!pte_present(*pte_k))
- goto no_context;
- return;
+ BUILD_BUG_ON(TASK_SIZE & ~PGDIR_MASK);
+ for (address = start; address >= TASK_SIZE; address += PGDIR_SIZE) {
+ if (!test_bit(pgd_index(address), insync)) {
+ unsigned long flags;
+ struct page *page;
+
+ spin_lock_irqsave(&pgd_lock, flags);
+ for (page = pgd_list; page; page =
+ (struct page *)page->index)
+ if (!vmalloc_sync_one(page_address(page),
+ address)) {
+ BUG_ON(page != pgd_list);
+ break;
+ }
+ spin_unlock_irqrestore(&pgd_lock, flags);
+ if (!page)
+ set_bit(pgd_index(address), insync);
+ }
+ if (address == start && test_bit(pgd_index(address), insync))
+ start = address + PGDIR_SIZE;
}
}
+#endif
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 7ba55a6e2db..9f66ac582a8 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -720,21 +720,6 @@ static int noinline do_test_wp_bit(void)
return flag;
}
-void free_initmem(void)
-{
- unsigned long addr;
-
- addr = (unsigned long)(&__init_begin);
- for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(addr));
- init_page_count(virt_to_page(addr));
- memset((void *)addr, 0xcc, PAGE_SIZE);
- free_page(addr);
- totalram_pages++;
- }
- printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (__init_end - __init_begin) >> 10);
-}
-
#ifdef CONFIG_DEBUG_RODATA
extern char __start_rodata, __end_rodata;
@@ -758,17 +743,31 @@ void mark_rodata_ro(void)
}
#endif
+void free_init_pages(char *what, unsigned long begin, unsigned long end)
+{
+ unsigned long addr;
+
+ for (addr = begin; addr < end; addr += PAGE_SIZE) {
+ ClearPageReserved(virt_to_page(addr));
+ init_page_count(virt_to_page(addr));
+ memset((void *)addr, 0xcc, PAGE_SIZE);
+ free_page(addr);
+ totalram_pages++;
+ }
+ printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
+}
+
+void free_initmem(void)
+{
+ free_init_pages("unused kernel memory",
+ (unsigned long)(&__init_begin),
+ (unsigned long)(&__init_end));
+}
#ifdef CONFIG_BLK_DEV_INITRD
void free_initrd_mem(unsigned long start, unsigned long end)
{
- if (start < end)
- printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
- for (; start < end; start += PAGE_SIZE) {
- ClearPageReserved(virt_to_page(start));
- init_page_count(virt_to_page(start));
- free_page(start);
- totalram_pages++;
- }
+ free_init_pages("initrd memory", start, end);
}
#endif
+
diff --git a/arch/i386/oprofile/nmi_int.c b/arch/i386/oprofile/nmi_int.c
index 0493e8b8ec4..1accce50c2c 100644
--- a/arch/i386/oprofile/nmi_int.c
+++ b/arch/i386/oprofile/nmi_int.c
@@ -122,7 +122,7 @@ static void nmi_save_registers(void * dummy)
static void free_msrs(void)
{
int i;
- for (i = 0; i < NR_CPUS; ++i) {
+ for_each_cpu(i) {
kfree(cpu_msrs[i].counters);
cpu_msrs[i].counters = NULL;
kfree(cpu_msrs[i].controls);
@@ -138,10 +138,7 @@ static int allocate_msrs(void)
size_t counters_size = sizeof(struct op_msr) * model->num_counters;
int i;
- for (i = 0; i < NR_CPUS; ++i) {
- if (!cpu_online(i))
- continue;
-
+ for_each_online_cpu(i) {
cpu_msrs[i].counters = kmalloc(counters_size, GFP_KERNEL);
if (!cpu_msrs[i].counters) {
success = 0;
diff --git a/arch/i386/pci/Makefile b/arch/i386/pci/Makefile
index 5461d4d5ea1..62ad75c57e6 100644
--- a/arch/i386/pci/Makefile
+++ b/arch/i386/pci/Makefile
@@ -1,4 +1,4 @@
-obj-y := i386.o
+obj-y := i386.o init.o
obj-$(CONFIG_PCI_BIOS) += pcbios.o
obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o direct.o
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index f6bc48da4d2..dbece776c5b 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -8,6 +8,7 @@
#include <linux/pci.h>
#include <linux/ioport.h>
#include <linux/init.h>
+#include <linux/dmi.h>
#include <asm/acpi.h>
#include <asm/segment.h>
@@ -120,11 +121,42 @@ void __devinit pcibios_fixup_bus(struct pci_bus *b)
pci_read_bridge_bases(b);
}
+/*
+ * Enable renumbering of PCI bus# ranges to reach all PCI busses (Cardbus)
+ */
+#ifdef __i386__
+static int __devinit assign_all_busses(struct dmi_system_id *d)
+{
+ pci_probe |= PCI_ASSIGN_ALL_BUSSES;
+ printk(KERN_INFO "%s detected: enabling PCI bus# renumbering"
+ " (pci=assign-busses)\n", d->ident);
+ return 0;
+}
+#endif
+
+/*
+ * Laptops which need pci=assign-busses to see Cardbus cards
+ */
+static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
+#ifdef __i386__
+ {
+ .callback = assign_all_busses,
+ .ident = "Samsung X20 Laptop",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Samsung Electronics"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "SX20S"),
+ },
+ },
+#endif /* __i386__ */
+ {}
+};
struct pci_bus * __devinit pcibios_scan_root(int busnum)
{
struct pci_bus *bus = NULL;
+ dmi_check_system(pciprobe_dmi_table);
+
while ((bus = pci_find_next_bus(bus)) != NULL) {
if (bus->number == busnum) {
/* Already scanned */
diff --git a/arch/i386/pci/direct.c b/arch/i386/pci/direct.c
index e3ac502bf2f..99012b93bd1 100644
--- a/arch/i386/pci/direct.c
+++ b/arch/i386/pci/direct.c
@@ -245,7 +245,7 @@ static int __init pci_check_type2(void)
return works;
}
-static int __init pci_direct_init(void)
+void __init pci_direct_init(void)
{
struct resource *region, *region2;
@@ -258,16 +258,16 @@ static int __init pci_direct_init(void)
if (pci_check_type1()) {
printk(KERN_INFO "PCI: Using configuration type 1\n");
raw_pci_ops = &pci_direct_conf1;
- return 0;
+ return;
}
release_resource(region);
type2:
if ((pci_probe & PCI_PROBE_CONF2) == 0)
- goto out;
+ return;
region = request_region(0xCF8, 4, "PCI conf2");
if (!region)
- goto out;
+ return;
region2 = request_region(0xC000, 0x1000, "PCI conf2");
if (!region2)
goto fail2;
@@ -275,15 +275,10 @@ static int __init pci_direct_init(void)
if (pci_check_type2()) {
printk(KERN_INFO "PCI: Using configuration type 2\n");
raw_pci_ops = &pci_direct_conf2;
- return 0;
+ return;
}
release_resource(region2);
fail2:
release_resource(region);
-
- out:
- return 0;
}
-
-arch_initcall(pci_direct_init);
diff --git a/arch/i386/pci/init.c b/arch/i386/pci/init.c
new file mode 100644
index 00000000000..f9156d3ac72
--- /dev/null
+++ b/arch/i386/pci/init.c
@@ -0,0 +1,25 @@
+#include <linux/config.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include "pci.h"
+
+/* arch_initcall has too random ordering, so call the initializers
+ in the right sequence from here. */
+static __init int pci_access_init(void)
+{
+#ifdef CONFIG_PCI_MMCONFIG
+ pci_mmcfg_init();
+#endif
+ if (raw_pci_ops)
+ return 0;
+#ifdef CONFIG_PCI_BIOS
+ pci_pcbios_init();
+#endif
+ if (raw_pci_ops)
+ return 0;
+#ifdef CONFIG_PCI_DIRECT
+ pci_direct_init();
+#endif
+ return 0;
+}
+arch_initcall(pci_access_init);
diff --git a/arch/i386/pci/mmconfig.c b/arch/i386/pci/mmconfig.c
index 0ee8a983708..613789071f3 100644
--- a/arch/i386/pci/mmconfig.c
+++ b/arch/i386/pci/mmconfig.c
@@ -172,25 +172,20 @@ static __init void unreachable_devices(void)
}
}
-static int __init pci_mmcfg_init(void)
+void __init pci_mmcfg_init(void)
{
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
- goto out;
+ return;
acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
if ((pci_mmcfg_config_num == 0) ||
(pci_mmcfg_config == NULL) ||
(pci_mmcfg_config[0].base_address == 0))
- goto out;
+ return;
printk(KERN_INFO "PCI: Using MMCONFIG\n");
raw_pci_ops = &pci_mmcfg;
pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
unreachable_devices();
-
- out:
- return 0;
}
-
-arch_initcall(pci_mmcfg_init);
diff --git a/arch/i386/pci/pcbios.c b/arch/i386/pci/pcbios.c
index b9d65f0bc2d..1eec0868f4b 100644
--- a/arch/i386/pci/pcbios.c
+++ b/arch/i386/pci/pcbios.c
@@ -476,14 +476,12 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
}
EXPORT_SYMBOL(pcibios_set_irq_routing);
-static int __init pci_pcbios_init(void)
+void __init pci_pcbios_init(void)
{
if ((pci_probe & PCI_PROBE_BIOS)
&& ((raw_pci_ops = pci_find_bios()))) {
pci_probe |= PCI_BIOS_SORT;
pci_bios_present = 1;
}
- return 0;
}
-arch_initcall(pci_pcbios_init);
diff --git a/arch/i386/pci/pci.h b/arch/i386/pci/pci.h
index f550781ec31..12035e29108 100644
--- a/arch/i386/pci/pci.h
+++ b/arch/i386/pci/pci.h
@@ -80,4 +80,7 @@ extern int pci_conf1_write(unsigned int seg, unsigned int bus,
extern int pci_conf1_read(unsigned int seg, unsigned int bus,
unsigned int devfn, int reg, int len, u32 *value);
+extern void pci_direct_init(void);
+extern void pci_pcbios_init(void);
+extern void pci_mmcfg_init(void);
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index f722e1a2594..80ea7506fa1 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -1,6 +1,9 @@
#
# ia64/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -62,7 +65,7 @@ drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/
boot := arch/ia64/hp/sim/boot
-.PHONY: boot compressed check
+PHONY += boot compressed check
all: compressed unwcheck
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index 626cdc83668..0e5c6ae5022 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -46,11 +46,6 @@
#define KEYBOARD_INTR 3 /* must match with simulator! */
#define NR_PORTS 1 /* only one port for now */
-#define SERIAL_INLINE 1
-
-#ifdef SERIAL_INLINE
-#define _INLINE_ inline
-#endif
#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
@@ -237,7 +232,7 @@ static void rs_put_char(struct tty_struct *tty, unsigned char ch)
local_irq_restore(flags);
}
-static _INLINE_ void transmit_chars(struct async_struct *info, int *intr_done)
+static void transmit_chars(struct async_struct *info, int *intr_done)
{
int count;
unsigned long flags;
diff --git a/arch/ia64/ia32/sys_ia32.c b/arch/ia64/ia32/sys_ia32.c
index 70dba1f0e2e..13e739e4c84 100644
--- a/arch/ia64/ia32/sys_ia32.c
+++ b/arch/ia64/ia32/sys_ia32.c
@@ -1166,19 +1166,7 @@ put_tv32 (struct compat_timeval __user *o, struct timeval *i)
asmlinkage unsigned long
sys32_alarm (unsigned int seconds)
{
- struct itimerval it_new, it_old;
- unsigned int oldalarm;
-
- it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
- it_new.it_value.tv_sec = seconds;
- it_new.it_value.tv_usec = 0;
- do_setitimer(ITIMER_REAL, &it_new, &it_old);
- oldalarm = it_old.it_value.tv_sec;
- /* ehhh.. We can't return 0 if we have an alarm pending.. */
- /* And we'd better return too much than too little anyway */
- if (it_old.it_value.tv_usec)
- oldalarm++;
- return oldalarm;
+ return alarm_setitimer(seconds);
}
/* Translations due to time_t size differences. Which affects all
diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c
index fc860778fa4..eb388e271b2 100644
--- a/arch/ia64/kernel/setup.c
+++ b/arch/ia64/kernel/setup.c
@@ -41,7 +41,6 @@
#include <linux/serial_core.h>
#include <linux/efi.h>
#include <linux/initrd.h>
-#include <linux/platform.h>
#include <linux/pm.h>
#include <linux/cpufreq.h>
diff --git a/arch/ia64/sn/kernel/bte.c b/arch/ia64/sn/kernel/bte.c
index 1f11db470d9..e952ef4f6d9 100644
--- a/arch/ia64/sn/kernel/bte.c
+++ b/arch/ia64/sn/kernel/bte.c
@@ -36,7 +36,7 @@ static struct bteinfo_s *bte_if_on_node(nasid_t nasid, int interface)
nodepda_t *tmp_nodepda;
if (nasid_to_cnodeid(nasid) == -1)
- return (struct bteinfo_s *)NULL;;
+ return (struct bteinfo_s *)NULL;
tmp_nodepda = NODEPDA(nasid_to_cnodeid(nasid));
return &tmp_nodepda->bte_if[interface];
diff --git a/arch/ia64/sn/pci/tioca_provider.c b/arch/ia64/sn/pci/tioca_provider.c
index 7571a402552..be017691296 100644
--- a/arch/ia64/sn/pci/tioca_provider.c
+++ b/arch/ia64/sn/pci/tioca_provider.c
@@ -377,7 +377,7 @@ tioca_dma_mapped(struct pci_dev *pdev, u64 paddr, size_t req_size)
struct tioca_dmamap *ca_dmamap;
void *map;
unsigned long flags;
- struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);;
+ struct pcidev_info *pcidev_info = SN_PCIDEV_INFO(pdev);
tioca_common = (struct tioca_common *)pcidev_info->pdi_pcibus_info;
tioca_kern = (struct tioca_kernel *)tioca_common->ca_kernel_private;
diff --git a/arch/m32r/Kconfig.debug b/arch/m32r/Kconfig.debug
index bbf711bab69..2e1019ddbb2 100644
--- a/arch/m32r/Kconfig.debug
+++ b/arch/m32r/Kconfig.debug
@@ -19,7 +19,7 @@ config DEBUG_STACK_USAGE
This option will slow down process creation somewhat.
config DEBUG_PAGEALLOC
- bool "Page alloc debugging"
+ bool "Debug page memory allocations"
depends on DEBUG_KERNEL && BROKEN
help
Unmap pages from the kernel linear mapping after free_pages().
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 4b3c90ba926..f219c47d334 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -1,6 +1,9 @@
#
# m32r/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
LDFLAGS :=
OBJCOPYFLAGS := -O binary -R .note -R .comment -S
@@ -39,7 +42,7 @@ drivers-$(CONFIG_OPROFILE) += arch/m32r/oprofile/
boot := arch/m32r/boot
-.PHONY: zImage
+PHONY += zImage
all: zImage
diff --git a/arch/m32r/kernel/irq.c b/arch/m32r/kernel/irq.c
index 1ce63926a3c..a4634b06f67 100644
--- a/arch/m32r/kernel/irq.c
+++ b/arch/m32r/kernel/irq.c
@@ -37,9 +37,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_printf(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
@@ -52,9 +51,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
#endif
seq_printf(p, " %14s", irq_desc[i].handler->typename);
seq_printf(p, " %s", action->name);
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c
index 703cbc6dc9c..15c16b62dff 100644
--- a/arch/m68k/bvme6000/rtc.c
+++ b/arch/m68k/bvme6000/rtc.c
@@ -18,6 +18,7 @@
#include <linux/module.h>
#include <linux/mc146818rtc.h> /* For struct rtc_time and ioctls, etc */
#include <linux/smp_lock.h>
+#include <linux/bcd.h>
#include <asm/bvme6000hw.h>
#include <asm/io.h>
@@ -32,9 +33,6 @@
* ioctls.
*/
-#define BCD2BIN(val) (((val)&15) + ((val)>>4)*10)
-#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
-
static unsigned char days_in_mo[] =
{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
diff --git a/arch/m68k/kernel/process.c b/arch/m68k/kernel/process.c
index 2d8ad0727b6..33648efb772 100644
--- a/arch/m68k/kernel/process.c
+++ b/arch/m68k/kernel/process.c
@@ -77,7 +77,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
/*
* The idle loop on an m68k..
*/
-void default_idle(void)
+static void default_idle(void)
{
if (!need_resched())
#if defined(MACH_ATARI_ONLY) && !defined(CONFIG_HADES)
diff --git a/arch/m68knommu/kernel/process.c b/arch/m68knommu/kernel/process.c
index 63c117dae0c..f861755ec88 100644
--- a/arch/m68knommu/kernel/process.c
+++ b/arch/m68knommu/kernel/process.c
@@ -51,7 +51,7 @@ EXPORT_SYMBOL(pm_power_off);
/*
* The idle loop on an m68knommu..
*/
-void default_idle(void)
+static void default_idle(void)
{
local_irq_disable();
while (!need_resched()) {
diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
index 7d93992e462..3dd76b3d296 100644
--- a/arch/mips/kernel/irq.c
+++ b/arch/mips/kernel/irq.c
@@ -68,9 +68,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_printf(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
@@ -83,9 +82,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
#endif
seq_printf(p, " %14s", irq_desc[i].handler->typename);
seq_printf(p, " %s", action->name);
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c
index 06ed9075242..78d171bfa33 100644
--- a/arch/mips/kernel/smp.c
+++ b/arch/mips/kernel/smp.c
@@ -167,8 +167,8 @@ int smp_call_function (void (*func) (void *info), void *info, int retry,
mb();
/* Send a message to all other CPUs and wait for them to respond */
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_online(i) && i != cpu)
+ for_each_online_cpu(i)
+ if (i != cpu)
core_send_ipi(i, SMP_CALL_FUNCTION);
/* Wait for response */
diff --git a/arch/mips/kernel/sysirix.c b/arch/mips/kernel/sysirix.c
index 0fc3730a294..5407b784cd0 100644
--- a/arch/mips/kernel/sysirix.c
+++ b/arch/mips/kernel/sysirix.c
@@ -645,27 +645,7 @@ static inline void getitimer_real(struct itimerval *value)
asmlinkage unsigned int irix_alarm(unsigned int seconds)
{
- struct itimerval it_new, it_old;
- unsigned int oldalarm;
-
- if (!seconds) {
- getitimer_real(&it_old);
- del_timer(&current->real_timer);
- } else {
- it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
- it_new.it_value.tv_sec = seconds;
- it_new.it_value.tv_usec = 0;
- do_setitimer(ITIMER_REAL, &it_new, &it_old);
- }
- oldalarm = it_old.it_value.tv_sec;
- /*
- * ehhh.. We can't return 0 if we have an alarm pending ...
- * And we'd better return too much than too little anyway
- */
- if (it_old.it_value.tv_usec)
- oldalarm++;
-
- return oldalarm;
+ return alarm_setitimer(seconds);
}
asmlinkage int irix_pause(void)
diff --git a/arch/mips/mm/dma-ip32.c b/arch/mips/mm/dma-ip32.c
index a7e3072ff78..ec54ed0d26f 100644
--- a/arch/mips/mm/dma-ip32.c
+++ b/arch/mips/mm/dma-ip32.c
@@ -138,7 +138,7 @@ dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size,
BUG();
}
- addr = virt_to_phys(ptr)&RAM_OFFSET_MASK;;
+ addr = virt_to_phys(ptr)&RAM_OFFSET_MASK;
if(dev == NULL)
addr+=CRIME_HI_MEM_BASE;
return (dma_addr_t)addr;
@@ -179,7 +179,7 @@ int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
addr = (unsigned long) page_address(sg->page)+sg->offset;
if (addr)
__dma_sync(addr, sg->length, direction);
- addr = __pa(addr)&RAM_OFFSET_MASK;;
+ addr = __pa(addr)&RAM_OFFSET_MASK;
if(dev == NULL)
addr += CRIME_HI_MEM_BASE;
sg->dma_address = (dma_addr_t)addr;
@@ -199,7 +199,7 @@ dma_addr_t dma_map_page(struct device *dev, struct page *page,
addr = (unsigned long) page_address(page) + offset;
dma_cache_wback_inv(addr, size);
- addr = __pa(addr)&RAM_OFFSET_MASK;;
+ addr = __pa(addr)&RAM_OFFSET_MASK;
if(dev == NULL)
addr += CRIME_HI_MEM_BASE;
diff --git a/arch/mips/sgi-ip27/ip27-irq.c b/arch/mips/sgi-ip27/ip27-irq.c
index 73e5e52781d..2854ac4c9be 100644
--- a/arch/mips/sgi-ip27/ip27-irq.c
+++ b/arch/mips/sgi-ip27/ip27-irq.c
@@ -88,12 +88,9 @@ static inline int find_level(cpuid_t *cpunum, int irq)
{
int cpu, i;
- for (cpu = 0; cpu <= NR_CPUS; cpu++) {
+ for_each_online_cpu(cpu) {
struct slice_data *si = cpu_data[cpu].data;
- if (!cpu_online(cpu))
- continue;
-
for (i = BASE_PCI_IRQ; i < LEVELS_PER_SLICE; i++)
if (si->level_to_irq[i] == irq) {
*cpunum = cpu;
diff --git a/arch/parisc/kernel/process.c b/arch/parisc/kernel/process.c
index e8dea417711..0b485ef4be8 100644
--- a/arch/parisc/kernel/process.c
+++ b/arch/parisc/kernel/process.c
@@ -54,11 +54,6 @@
#include <asm/uaccess.h>
#include <asm/unwind.h>
-void default_idle(void)
-{
- barrier();
-}
-
/*
* The idle thread. There's no useful work to be
* done, so just try to conserve power and have a
diff --git a/arch/parisc/kernel/smp.c b/arch/parisc/kernel/smp.c
index 25564b7ca6b..d6ac1c60a47 100644
--- a/arch/parisc/kernel/smp.c
+++ b/arch/parisc/kernel/smp.c
@@ -298,8 +298,8 @@ send_IPI_allbutself(enum ipi_message_type op)
{
int i;
- for (i = 0; i < NR_CPUS; i++) {
- if (cpu_online(i) && i != smp_processor_id())
+ for_each_online_cpu(i) {
+ if (i != smp_processor_id())
send_IPI_single(i, op);
}
}
@@ -643,14 +643,13 @@ int sys_cpus(int argc, char **argv)
if ( argc == 1 ){
#ifdef DUMP_MORE_STATE
- for(i=0; i<NR_CPUS; i++) {
+ for_each_online_cpu(i) {
int cpus_per_line = 4;
- if(cpu_online(i)) {
- if (j++ % cpus_per_line)
- printk(" %3d",i);
- else
- printk("\n %3d",i);
- }
+
+ if (j++ % cpus_per_line)
+ printk(" %3d",i);
+ else
+ printk("\n %3d",i);
}
printk("\n");
#else
@@ -659,9 +658,7 @@ int sys_cpus(int argc, char **argv)
} else if((argc==2) && !(strcmp(argv[1],"-l"))) {
printk("\nCPUSTATE TASK CPUNUM CPUID HARDCPU(HPA)\n");
#ifdef DUMP_MORE_STATE
- for(i=0;i<NR_CPUS;i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (cpu_data[i].cpuid != NO_PROC_ID) {
switch(cpu_data[i].state) {
case STATE_RENDEZVOUS:
@@ -695,9 +692,7 @@ int sys_cpus(int argc, char **argv)
} else if ((argc==2) && !(strcmp(argv[1],"-s"))) {
#ifdef DUMP_MORE_STATE
printk("\nCPUSTATE CPUID\n");
- for (i=0;i<NR_CPUS;i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (cpu_data[i].cpuid != NO_PROC_ID) {
switch(cpu_data[i].state) {
case STATE_RENDEZVOUS:
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index dfba81719de..fae42da7468 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -127,6 +127,12 @@ config PPC_83xx
select 83xx
select PPC_FPU
+config PPC_85xx
+ bool "Freescale 85xx"
+ select E500
+ select FSL_SOC
+ select 85xx
+
config 40x
bool "AMCC 40x"
@@ -139,8 +145,6 @@ config 8xx
config E200
bool "Freescale e200"
-config E500
- bool "Freescale e500"
endchoice
config POWER4_ONLY
@@ -168,6 +172,13 @@ config 6xx
config 83xx
bool
+# this is temp to handle compat with arch=ppc
+config 85xx
+ bool
+
+config E500
+ bool
+
config PPC_FPU
bool
default y if PPC64
@@ -217,6 +228,7 @@ config ALTIVEC
config SPE
bool "SPE Support"
depends on E200 || E500
+ default y
---help---
This option enables kernel support for the Signal Processing
Extensions (SPE) to the PowerPC processor. The kernel currently
@@ -238,6 +250,21 @@ config PPC_STD_MMU_32
def_bool y
depends on PPC_STD_MMU && PPC32
+config VIRT_CPU_ACCOUNTING
+ bool "Deterministic task and CPU time accounting"
+ depends on PPC64
+ default y
+ help
+ Select this option to enable more accurate task and CPU time
+ accounting. This is done by reading a CPU counter on each
+ kernel entry and exit and on transitions within the kernel
+ between system, softirq and hardirq state, so there is a
+ small performance impact. This also enables accounting of
+ stolen time on logically-partitioned systems running on
+ IBM POWER5-based machines.
+
+ If in doubt, say Y here.
+
config SMP
depends on PPC_STD_MMU
bool "Symmetric multi-processing support"
@@ -734,13 +761,12 @@ config GENERIC_ISA_DMA
config PPC_I8259
bool
- default y if 85xx
default n
config PPC_INDIRECT_PCI
bool
depends on PCI
- default y if 40x || 44x || 85xx
+ default y if 40x || 44x
default n
config EISA
@@ -757,8 +783,8 @@ config MCA
bool
config PCI
- bool "PCI support" if 40x || CPM2 || PPC_83xx || 85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
- default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !85xx
+ bool "PCI support" if 40x || CPM2 || PPC_83xx || PPC_85xx || PPC_MPC52xx || (EMBEDDED && PPC_ISERIES)
+ default y if !40x && !CPM2 && !8xx && !APUS && !PPC_83xx && !PPC_85xx
default PCI_PERMEDIA if !4xx && !CPM2 && !8xx && APUS
default PCI_QSPAN if !4xx && !CPM2 && 8xx
help
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 5500ab55d04..829e017b8a5 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -148,9 +148,9 @@ all: $(KBUILD_IMAGE)
CPPFLAGS_vmlinux.lds := -Upowerpc
-BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage
+BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
-.PHONY: $(BOOT_TARGETS)
+PHONY += $(BOOT_TARGETS)
boot := arch/$(ARCH)/boot
diff --git a/arch/powerpc/boot/install.sh b/arch/powerpc/boot/install.sh
index eacce959081..b002bfd5678 100644
--- a/arch/powerpc/boot/install.sh
+++ b/arch/powerpc/boot/install.sh
@@ -1,7 +1,5 @@
#!/bin/sh
#
-# arch/ppc64/boot/install.sh
-#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 55ec5986725..816446f0e49 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -152,7 +152,7 @@ static int is_elf64(void *hdr)
elf64ph = (Elf64_Phdr *)((unsigned long)elf64 +
(unsigned long)elf64->e_phoff);
for (i = 0; i < (unsigned int)elf64->e_phnum; i++, elf64ph++)
- if (elf64ph->p_type == PT_LOAD && elf64ph->p_offset != 0)
+ if (elf64ph->p_type == PT_LOAD)
break;
if (i >= (unsigned int)elf64->e_phnum)
return 0;
@@ -193,7 +193,7 @@ static int is_elf32(void *hdr)
elf32 = (Elf32_Ehdr *)elfheader;
elf32ph = (Elf32_Phdr *) ((unsigned long)elf32 + elf32->e_phoff);
for (i = 0; i < elf32->e_phnum; i++, elf32ph++)
- if (elf32ph->p_type == PT_LOAD && elf32ph->p_offset != 0)
+ if (elf32ph->p_type == PT_LOAD)
break;
if (i >= elf32->e_phnum)
return 0;
diff --git a/arch/powerpc/configs/mpc8540_ads_defconfig b/arch/powerpc/configs/mpc8540_ads_defconfig
new file mode 100644
index 00000000000..2a8290ee15c
--- /dev/null
+++ b/arch/powerpc/configs/mpc8540_ads_defconfig
@@ -0,0 +1,721 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version:
+# Sat Jan 14 15:57:54 2006
+#
+# CONFIG_PPC64 is not set
+CONFIG_PPC32=y
+CONFIG_PPC_MERGE=y
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_PPC=y
+CONFIG_EARLY_PRINTK=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+CONFIG_PPC_OF=y
+CONFIG_PPC_UDBG_16550=y
+# CONFIG_GENERIC_TBSYNC is not set
+
+#
+# Processor support
+#
+# CONFIG_CLASSIC32 is not set
+# CONFIG_PPC_52xx is not set
+# CONFIG_PPC_82xx is not set
+# CONFIG_PPC_83xx is not set
+CONFIG_PPC_85xx=y
+# CONFIG_40x is not set
+# CONFIG_44x is not set
+# CONFIG_8xx is not set
+# CONFIG_E200 is not set
+CONFIG_85xx=y
+CONFIG_E500=y
+CONFIG_BOOKE=y
+CONFIG_FSL_BOOKE=y
+# CONFIG_PHYS_64BIT is not set
+CONFIG_SPE=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+CONFIG_SWAP=y
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+# CONFIG_BSD_PROCESS_ACCT is not set
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_INITRAMFS_SOURCE=""
+# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
+CONFIG_EMBEDDED=y
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+# CONFIG_MODULES is not set
+
+#
+# Block layer
+#
+# CONFIG_LBD is not set
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+CONFIG_MPIC=y
+# CONFIG_WANT_EARLY_SERIAL is not set
+
+#
+# Platform support
+#
+CONFIG_MPC8540_ADS=y
+CONFIG_MPC8540=y
+CONFIG_PPC_INDIRECT_PCI_BE=y
+
+#
+# Kernel options
+#
+# CONFIG_HIGHMEM is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_BINFMT_ELF=y
+CONFIG_BINFMT_MISC=y
+CONFIG_MATH_EMULATION=y
+CONFIG_ARCH_FLATMEM_ENABLE=y
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_PROC_DEVICETREE=y
+# CONFIG_CMDLINE_BOOL is not set
+# CONFIG_PM is not set
+# CONFIG_SOFTWARE_SUSPEND is not set
+# CONFIG_SECCOMP is not set
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+# CONFIG_PPC_I8259 is not set
+CONFIG_PPC_INDIRECT_PCI=y
+CONFIG_FSL_SOC=y
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# PCI Hotplug Support
+#
+
+#
+# Advanced setup
+#
+# CONFIG_ADVANCED_OPTIONS is not set
+
+#
+# Default settings for advanced configuration options are used
+#
+CONFIG_HIGHMEM_START=0xfe000000
+CONFIG_LOWMEM_SIZE=0x30000000
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_TASK_SIZE=0x80000000
+CONFIG_BOOT_LOAD=0x00800000
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+# CONFIG_PACKET_MMAP is not set
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_MROUTE is not set
+# CONFIG_ARPD is not set
+CONFIG_SYN_COOKIES=y
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+CONFIG_BLK_DEV_LOOP=y
+# CONFIG_BLK_DEV_CRYPTOLOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=32768
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Macintosh device drivers
+#
+# CONFIG_WINDFARM is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+# CONFIG_TUN is not set
+
+#
+# PHY device support
+#
+CONFIG_PHYLIB=y
+
+#
+# MII PHY device drivers
+#
+# CONFIG_MARVELL_PHY is not set
+# CONFIG_DAVICOM_PHY is not set
+# CONFIG_QSEMI_PHY is not set
+# CONFIG_LXT_PHY is not set
+# CONFIG_CICADA_PHY is not set
+
+#
+# Ethernet (10 or 100Mbit)
+#
+CONFIG_NET_ETHERNET=y
+CONFIG_MII=y
+
+#
+# Ethernet (1000 Mbit)
+#
+CONFIG_GIANFAR=y
+CONFIG_GFAR_NAPI=y
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+# CONFIG_VT is not set
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+CONFIG_LEGACY_PTYS=y
+CONFIG_LEGACY_PTY_COUNT=256
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_NVRAM is not set
+CONFIG_GEN_RTC=y
+# CONFIG_GEN_RTC_X is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+# CONFIG_TELCLOCK is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+CONFIG_HWMON=y
+# CONFIG_HWMON_VID is not set
+# CONFIG_HWMON_DEBUG_CHIP is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia Capabilities Port drivers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+
+#
+# SN Devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+CONFIG_EXT3_FS=y
+CONFIG_EXT3_FS_XATTR=y
+# CONFIG_EXT3_FS_POSIX_ACL is not set
+# CONFIG_EXT3_FS_SECURITY is not set
+CONFIG_JBD=y
+# CONFIG_JBD_DEBUG is not set
+CONFIG_FS_MBCACHE=y
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+# CONFIG_MSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+CONFIG_NFS_FS=y
+# CONFIG_NFS_V3 is not set
+# CONFIG_NFS_V4 is not set
+# CONFIG_NFS_DIRECTIO is not set
+# CONFIG_NFSD is not set
+CONFIG_ROOT_NFS=y
+CONFIG_LOCKD=y
+CONFIG_NFS_COMMON=y
+CONFIG_SUNRPC=y
+# CONFIG_RPCSEC_GSS_KRB5 is not set
+# CONFIG_RPCSEC_GSS_SPKM3 is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+CONFIG_PARTITION_ADVANCED=y
+# CONFIG_ACORN_PARTITION is not set
+# CONFIG_OSF_PARTITION is not set
+# CONFIG_AMIGA_PARTITION is not set
+# CONFIG_ATARI_PARTITION is not set
+# CONFIG_MAC_PARTITION is not set
+# CONFIG_MSDOS_PARTITION is not set
+# CONFIG_LDM_PARTITION is not set
+# CONFIG_SGI_PARTITION is not set
+# CONFIG_ULTRIX_PARTITION is not set
+# CONFIG_SUN_PARTITION is not set
+# CONFIG_EFI_PARTITION is not set
+
+#
+# Native Language Support
+#
+# CONFIG_NLS is not set
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+
+#
+# Instrumentation Support
+#
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+# CONFIG_PRINTK_TIME is not set
+# CONFIG_MAGIC_SYSRQ is not set
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+# CONFIG_DEBUG_INFO is not set
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_DEBUGGER is not set
+# CONFIG_BDI_SWITCH is not set
+# CONFIG_BOOTX_TEXT is not set
+# CONFIG_PPC_EARLY_DEBUG_LPAR is not set
+# CONFIG_PPC_EARLY_DEBUG_G5 is not set
+# CONFIG_PPC_EARLY_DEBUG_RTAS is not set
+# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set
+# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Hardware crypto devices
+#
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index c9a660e4c2d..882889b1592 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -136,6 +136,9 @@ int main(void)
DEFINE(PACAEMERGSP, offsetof(struct paca_struct, emergency_sp));
DEFINE(PACALPPACAPTR, offsetof(struct paca_struct, lppaca_ptr));
DEFINE(PACAHWCPUID, offsetof(struct paca_struct, hw_cpu_id));
+ DEFINE(PACA_STARTPURR, offsetof(struct paca_struct, startpurr));
+ DEFINE(PACA_USER_TIME, offsetof(struct paca_struct, user_time));
+ DEFINE(PACA_SYSTEM_TIME, offsetof(struct paca_struct, system_time));
DEFINE(LPPACASRR0, offsetof(struct lppaca, saved_srr0));
DEFINE(LPPACASRR1, offsetof(struct lppaca, saved_srr1));
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c
index e4e81374cb9..39e348a3ade 100644
--- a/arch/powerpc/kernel/cputable.c
+++ b/arch/powerpc/kernel/cputable.c
@@ -894,7 +894,7 @@ struct cpu_spec cpu_specs[] = {
.platform = "ppc405",
},
{ /* Xilinx Virtex-II Pro */
- .pvr_mask = 0xffff0000,
+ .pvr_mask = 0xfffff000,
.pvr_value = 0x20010000,
.cpu_name = "Virtex-II Pro",
.cpu_features = CPU_FTRS_40X,
@@ -904,6 +904,16 @@ struct cpu_spec cpu_specs[] = {
.dcache_bsize = 32,
.platform = "ppc405",
},
+ { /* Xilinx Virtex-4 FX */
+ .pvr_mask = 0xfffff000,
+ .pvr_value = 0x20011000,
+ .cpu_name = "Virtex-4 FX",
+ .cpu_features = CPU_FTRS_40X,
+ .cpu_user_features = PPC_FEATURE_32 |
+ PPC_FEATURE_HAS_MMU | PPC_FEATURE_HAS_4xxMAC,
+ .icache_bsize = 32,
+ .dcache_bsize = 32,
+ },
{ /* 405EP */
.pvr_mask = 0xffff0000,
.pvr_value = 0x51210000,
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 24be0cf86d7..1060155d84c 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/entry.S
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
* Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
@@ -63,6 +61,7 @@ system_call_common:
std r12,_MSR(r1)
std r0,GPR0(r1)
std r10,GPR1(r1)
+ ACCOUNT_CPU_USER_ENTRY(r10, r11)
std r2,GPR2(r1)
std r3,GPR3(r1)
std r4,GPR4(r1)
@@ -170,8 +169,9 @@ syscall_error_cont:
stdcx. r0,0,r1 /* to clear the reservation */
andi. r6,r8,MSR_PR
ld r4,_LINK(r1)
- beq- 1f /* only restore r13 if */
- ld r13,GPR13(r1) /* returning to usermode */
+ beq- 1f
+ ACCOUNT_CPU_USER_EXIT(r11, r12)
+ ld r13,GPR13(r1) /* only restore r13 if returning to usermode */
1: ld r2,GPR2(r1)
li r12,MSR_RI
andc r11,r10,r12
@@ -322,7 +322,7 @@ _GLOBAL(ret_from_fork)
* the fork code also.
*
* The code which creates the new task context is in 'copy_thread'
- * in arch/ppc64/kernel/process.c
+ * in arch/powerpc/kernel/process.c
*/
.align 7
_GLOBAL(_switch)
@@ -486,6 +486,7 @@ restore:
* userspace
*/
beq 1f
+ ACCOUNT_CPU_USER_EXIT(r3, r4)
REST_GPR(13, r1)
1:
ld r3,_CTR(r1)
diff --git a/arch/powerpc/kernel/firmware.c b/arch/powerpc/kernel/firmware.c
index 65eae752a52..4d37a3cb80f 100644
--- a/arch/powerpc/kernel/firmware.c
+++ b/arch/powerpc/kernel/firmware.c
@@ -18,28 +18,3 @@
#include <asm/firmware.h>
unsigned long ppc64_firmware_features;
-
-#ifdef CONFIG_PPC_PSERIES
-firmware_feature_t firmware_features_table[FIRMWARE_MAX_FEATURES] = {
- {FW_FEATURE_PFT, "hcall-pft"},
- {FW_FEATURE_TCE, "hcall-tce"},
- {FW_FEATURE_SPRG0, "hcall-sprg0"},
- {FW_FEATURE_DABR, "hcall-dabr"},
- {FW_FEATURE_COPY, "hcall-copy"},
- {FW_FEATURE_ASR, "hcall-asr"},
- {FW_FEATURE_DEBUG, "hcall-debug"},
- {FW_FEATURE_PERF, "hcall-perf"},
- {FW_FEATURE_DUMP, "hcall-dump"},
- {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
- {FW_FEATURE_MIGRATE, "hcall-migrate"},
- {FW_FEATURE_PERFMON, "hcall-perfmon"},
- {FW_FEATURE_CRQ, "hcall-crq"},
- {FW_FEATURE_VIO, "hcall-vio"},
- {FW_FEATURE_RDMA, "hcall-rdma"},
- {FW_FEATURE_LLAN, "hcall-lLAN"},
- {FW_FEATURE_BULK, "hcall-bulk"},
- {FW_FEATURE_XDABR, "hcall-xdabr"},
- {FW_FEATURE_MULTITCE, "hcall-multi-tce"},
- {FW_FEATURE_SPLPAR, "hcall-splpar"},
-};
-#endif
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index 8b49679fad5..47c7fa148c9 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/head_44x.S
- *
* Kernel execution entry point code.
*
* Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S
index 9b65029dd2a..35084f3a841 100644
--- a/arch/powerpc/kernel/head_64.S
+++ b/arch/powerpc/kernel/head_64.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/head.S
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
*
@@ -279,6 +277,7 @@ exception_marker:
std r10,0(r1); /* make stack chain pointer */ \
std r0,GPR0(r1); /* save r0 in stackframe */ \
std r10,GPR1(r1); /* save r1 in stackframe */ \
+ ACCOUNT_CPU_USER_ENTRY(r9, r10); \
std r2,GPR2(r1); /* save r2 in stackframe */ \
SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \
SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
@@ -846,6 +845,14 @@ fast_exception_return:
ld r11,_NIP(r1)
andi. r3,r12,MSR_RI /* check if RI is set */
beq- unrecov_fer
+
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+ andi. r3,r12,MSR_PR
+ beq 2f
+ ACCOUNT_CPU_USER_EXIT(r3, r4)
+2:
+#endif
+
ld r3,_CCR(r1)
ld r4,_LINK(r1)
ld r5,_CTR(r1)
diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S
index bc6d1ac5523..28941f5ce67 100644
--- a/arch/powerpc/kernel/head_8xx.S
+++ b/arch/powerpc/kernel/head_8xx.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/except_8xx.S
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
* Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
new file mode 100644
index 00000000000..8536e767616
--- /dev/null
+++ b/arch/powerpc/kernel/head_booke.h
@@ -0,0 +1,363 @@
+#ifndef __HEAD_BOOKE_H__
+#define __HEAD_BOOKE_H__
+
+/*
+ * Macros used for common Book-e exception handling
+ */
+
+#define SET_IVOR(vector_number, vector_label) \
+ li r26,vector_label@l; \
+ mtspr SPRN_IVOR##vector_number,r26; \
+ sync
+
+#define NORMAL_EXCEPTION_PROLOG \
+ mtspr SPRN_SPRG0,r10; /* save two registers to work with */\
+ mtspr SPRN_SPRG1,r11; \
+ mtspr SPRN_SPRG4W,r1; \
+ mfcr r10; /* save CR in r10 for now */\
+ mfspr r11,SPRN_SRR1; /* check whether user or kernel */\
+ andi. r11,r11,MSR_PR; \
+ beq 1f; \
+ mfspr r1,SPRN_SPRG3; /* if from user, start at top of */\
+ lwz r1,THREAD_INFO-THREAD(r1); /* this thread's kernel stack */\
+ addi r1,r1,THREAD_SIZE; \
+1: subi r1,r1,INT_FRAME_SIZE; /* Allocate an exception frame */\
+ mr r11,r1; \
+ stw r10,_CCR(r11); /* save various registers */\
+ stw r12,GPR12(r11); \
+ stw r9,GPR9(r11); \
+ mfspr r10,SPRN_SPRG0; \
+ stw r10,GPR10(r11); \
+ mfspr r12,SPRN_SPRG1; \
+ stw r12,GPR11(r11); \
+ mflr r10; \
+ stw r10,_LINK(r11); \
+ mfspr r10,SPRN_SPRG4R; \
+ mfspr r12,SPRN_SRR0; \
+ stw r10,GPR1(r11); \
+ mfspr r9,SPRN_SRR1; \
+ stw r10,0(r11); \
+ rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
+ stw r0,GPR0(r11); \
+ SAVE_4GPRS(3, r11); \
+ SAVE_2GPRS(7, r11)
+
+/* To handle the additional exception priority levels on 40x and Book-E
+ * processors we allocate a 4k stack per additional priority level. The various
+ * head_xxx.S files allocate space (exception_stack_top) for each priority's
+ * stack times the number of CPUs
+ *
+ * On 40x critical is the only additional level
+ * On 44x/e500 we have critical and machine check
+ * On e200 we have critical and debug (machine check occurs via critical)
+ *
+ * Additionally we reserve a SPRG for each priority level so we can free up a
+ * GPR to use as the base for indirect access to the exception stacks. This
+ * is necessary since the MMU is always on, for Book-E parts, and the stacks
+ * are offset from KERNELBASE.
+ *
+ */
+#define BOOKE_EXCEPTION_STACK_SIZE (8192)
+
+/* CRIT_SPRG only used in critical exception handling */
+#define CRIT_SPRG SPRN_SPRG2
+/* MCHECK_SPRG only used in machine check exception handling */
+#define MCHECK_SPRG SPRN_SPRG6W
+
+#define MCHECK_STACK_TOP (exception_stack_top - 4096)
+#define CRIT_STACK_TOP (exception_stack_top)
+
+/* only on e200 for now */
+#define DEBUG_STACK_TOP (exception_stack_top - 4096)
+#define DEBUG_SPRG SPRN_SPRG6W
+
+#ifdef CONFIG_SMP
+#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
+ mfspr r8,SPRN_PIR; \
+ mulli r8,r8,BOOKE_EXCEPTION_STACK_SIZE; \
+ neg r8,r8; \
+ addis r8,r8,level##_STACK_TOP@ha; \
+ addi r8,r8,level##_STACK_TOP@l
+#else
+#define BOOKE_LOAD_EXC_LEVEL_STACK(level) \
+ lis r8,level##_STACK_TOP@h; \
+ ori r8,r8,level##_STACK_TOP@l
+#endif
+
+/*
+ * Exception prolog for critical/machine check exceptions. This is a
+ * little different from the normal exception prolog above since a
+ * critical/machine check exception can potentially occur at any point
+ * during normal exception processing. Thus we cannot use the same SPRG
+ * registers as the normal prolog above. Instead we use a portion of the
+ * critical/machine check exception stack at low physical addresses.
+ */
+#define EXC_LEVEL_EXCEPTION_PROLOG(exc_level, exc_level_srr0, exc_level_srr1) \
+ mtspr exc_level##_SPRG,r8; \
+ BOOKE_LOAD_EXC_LEVEL_STACK(exc_level);/* r8 points to the exc_level stack*/ \
+ stw r10,GPR10-INT_FRAME_SIZE(r8); \
+ stw r11,GPR11-INT_FRAME_SIZE(r8); \
+ mfcr r10; /* save CR in r10 for now */\
+ mfspr r11,exc_level_srr1; /* check whether user or kernel */\
+ andi. r11,r11,MSR_PR; \
+ mr r11,r8; \
+ mfspr r8,exc_level##_SPRG; \
+ beq 1f; \
+ /* COMING FROM USER MODE */ \
+ mfspr r11,SPRN_SPRG3; /* if from user, start at top of */\
+ lwz r11,THREAD_INFO-THREAD(r11); /* this thread's kernel stack */\
+ addi r11,r11,THREAD_SIZE; \
+1: subi r11,r11,INT_FRAME_SIZE; /* Allocate an exception frame */\
+ stw r10,_CCR(r11); /* save various registers */\
+ stw r12,GPR12(r11); \
+ stw r9,GPR9(r11); \
+ mflr r10; \
+ stw r10,_LINK(r11); \
+ mfspr r12,SPRN_DEAR; /* save DEAR and ESR in the frame */\
+ stw r12,_DEAR(r11); /* since they may have had stuff */\
+ mfspr r9,SPRN_ESR; /* in them at the point where the */\
+ stw r9,_ESR(r11); /* exception was taken */\
+ mfspr r12,exc_level_srr0; \
+ stw r1,GPR1(r11); \
+ mfspr r9,exc_level_srr1; \
+ stw r1,0(r11); \
+ mr r1,r11; \
+ rlwinm r9,r9,0,14,12; /* clear MSR_WE (necessary?) */\
+ stw r0,GPR0(r11); \
+ SAVE_4GPRS(3, r11); \
+ SAVE_2GPRS(7, r11)
+
+#define CRITICAL_EXCEPTION_PROLOG \
+ EXC_LEVEL_EXCEPTION_PROLOG(CRIT, SPRN_CSRR0, SPRN_CSRR1)
+#define DEBUG_EXCEPTION_PROLOG \
+ EXC_LEVEL_EXCEPTION_PROLOG(DEBUG, SPRN_DSRR0, SPRN_DSRR1)
+#define MCHECK_EXCEPTION_PROLOG \
+ EXC_LEVEL_EXCEPTION_PROLOG(MCHECK, SPRN_MCSRR0, SPRN_MCSRR1)
+
+/*
+ * Exception vectors.
+ */
+#define START_EXCEPTION(label) \
+ .align 5; \
+label:
+
+#define FINISH_EXCEPTION(func) \
+ bl transfer_to_handler_full; \
+ .long func; \
+ .long ret_from_except_full
+
+#define EXCEPTION(n, label, hdlr, xfer) \
+ START_EXCEPTION(label); \
+ NORMAL_EXCEPTION_PROLOG; \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ xfer(n, hdlr)
+
+#define CRITICAL_EXCEPTION(n, label, hdlr) \
+ START_EXCEPTION(label); \
+ CRITICAL_EXCEPTION_PROLOG; \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
+ NOCOPY, crit_transfer_to_handler, \
+ ret_from_crit_exc)
+
+#define MCHECK_EXCEPTION(n, label, hdlr) \
+ START_EXCEPTION(label); \
+ MCHECK_EXCEPTION_PROLOG; \
+ mfspr r5,SPRN_ESR; \
+ stw r5,_ESR(r11); \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_TEMPLATE(hdlr, n+2, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), \
+ NOCOPY, mcheck_transfer_to_handler, \
+ ret_from_mcheck_exc)
+
+#define EXC_XFER_TEMPLATE(hdlr, trap, msr, copyee, tfer, ret) \
+ li r10,trap; \
+ stw r10,_TRAP(r11); \
+ lis r10,msr@h; \
+ ori r10,r10,msr@l; \
+ copyee(r10, r9); \
+ bl tfer; \
+ .long hdlr; \
+ .long ret
+
+#define COPY_EE(d, s) rlwimi d,s,0,16,16
+#define NOCOPY(d, s)
+
+#define EXC_XFER_STD(n, hdlr) \
+ EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, NOCOPY, transfer_to_handler_full, \
+ ret_from_except_full)
+
+#define EXC_XFER_LITE(n, hdlr) \
+ EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, NOCOPY, transfer_to_handler, \
+ ret_from_except)
+
+#define EXC_XFER_EE(n, hdlr) \
+ EXC_XFER_TEMPLATE(hdlr, n, MSR_KERNEL, COPY_EE, transfer_to_handler_full, \
+ ret_from_except_full)
+
+#define EXC_XFER_EE_LITE(n, hdlr) \
+ EXC_XFER_TEMPLATE(hdlr, n+1, MSR_KERNEL, COPY_EE, transfer_to_handler, \
+ ret_from_except)
+
+/* Check for a single step debug exception while in an exception
+ * handler before state has been saved. This is to catch the case
+ * where an instruction that we are trying to single step causes
+ * an exception (eg ITLB/DTLB miss) and thus the first instruction of
+ * the exception handler generates a single step debug exception.
+ *
+ * If we get a debug trap on the first instruction of an exception handler,
+ * we reset the MSR_DE in the _exception handler's_ MSR (the debug trap is
+ * a critical exception, so we are using SPRN_CSRR1 to manipulate the MSR).
+ * The exception handler was handling a non-critical interrupt, so it will
+ * save (and later restore) the MSR via SPRN_CSRR1, which will still have
+ * the MSR_DE bit set.
+ */
+#ifdef CONFIG_E200
+#define DEBUG_EXCEPTION \
+ START_EXCEPTION(Debug); \
+ DEBUG_EXCEPTION_PROLOG; \
+ \
+ /* \
+ * If there is a single step or branch-taken exception in an \
+ * exception entry sequence, it was probably meant to apply to \
+ * the code where the exception occurred (since exception entry \
+ * doesn't turn off DE automatically). We simulate the effect \
+ * of turning off DE on entry to an exception handler by turning \
+ * off DE in the CSRR1 value and clearing the debug status. \
+ */ \
+ mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
+ andis. r10,r10,DBSR_IC@h; \
+ beq+ 2f; \
+ \
+ lis r10,KERNELBASE@h; /* check if exception in vectors */ \
+ ori r10,r10,KERNELBASE@l; \
+ cmplw r12,r10; \
+ blt+ 2f; /* addr below exception vectors */ \
+ \
+ lis r10,Debug@h; \
+ ori r10,r10,Debug@l; \
+ cmplw r12,r10; \
+ bgt+ 2f; /* addr above exception vectors */ \
+ \
+ /* here it looks like we got an inappropriate debug exception. */ \
+1: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CDRR1 value */ \
+ lis r10,DBSR_IC@h; /* clear the IC event */ \
+ mtspr SPRN_DBSR,r10; \
+ /* restore state and get out */ \
+ lwz r10,_CCR(r11); \
+ lwz r0,GPR0(r11); \
+ lwz r1,GPR1(r11); \
+ mtcrf 0x80,r10; \
+ mtspr SPRN_DSRR0,r12; \
+ mtspr SPRN_DSRR1,r9; \
+ lwz r9,GPR9(r11); \
+ lwz r12,GPR12(r11); \
+ mtspr DEBUG_SPRG,r8; \
+ BOOKE_LOAD_EXC_LEVEL_STACK(DEBUG); /* r8 points to the debug stack */ \
+ lwz r10,GPR10-INT_FRAME_SIZE(r8); \
+ lwz r11,GPR11-INT_FRAME_SIZE(r8); \
+ mfspr r8,DEBUG_SPRG; \
+ \
+ RFDI; \
+ b .; \
+ \
+ /* continue normal handling for a critical exception... */ \
+2: mfspr r4,SPRN_DBSR; \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, debug_transfer_to_handler, ret_from_debug_exc)
+#else
+#define DEBUG_EXCEPTION \
+ START_EXCEPTION(Debug); \
+ CRITICAL_EXCEPTION_PROLOG; \
+ \
+ /* \
+ * If there is a single step or branch-taken exception in an \
+ * exception entry sequence, it was probably meant to apply to \
+ * the code where the exception occurred (since exception entry \
+ * doesn't turn off DE automatically). We simulate the effect \
+ * of turning off DE on entry to an exception handler by turning \
+ * off DE in the CSRR1 value and clearing the debug status. \
+ */ \
+ mfspr r10,SPRN_DBSR; /* check single-step/branch taken */ \
+ andis. r10,r10,DBSR_IC@h; \
+ beq+ 2f; \
+ \
+ lis r10,KERNELBASE@h; /* check if exception in vectors */ \
+ ori r10,r10,KERNELBASE@l; \
+ cmplw r12,r10; \
+ blt+ 2f; /* addr below exception vectors */ \
+ \
+ lis r10,Debug@h; \
+ ori r10,r10,Debug@l; \
+ cmplw r12,r10; \
+ bgt+ 2f; /* addr above exception vectors */ \
+ \
+ /* here it looks like we got an inappropriate debug exception. */ \
+1: rlwinm r9,r9,0,~MSR_DE; /* clear DE in the CSRR1 value */ \
+ lis r10,DBSR_IC@h; /* clear the IC event */ \
+ mtspr SPRN_DBSR,r10; \
+ /* restore state and get out */ \
+ lwz r10,_CCR(r11); \
+ lwz r0,GPR0(r11); \
+ lwz r1,GPR1(r11); \
+ mtcrf 0x80,r10; \
+ mtspr SPRN_CSRR0,r12; \
+ mtspr SPRN_CSRR1,r9; \
+ lwz r9,GPR9(r11); \
+ lwz r12,GPR12(r11); \
+ mtspr CRIT_SPRG,r8; \
+ BOOKE_LOAD_EXC_LEVEL_STACK(CRIT); /* r8 points to the debug stack */ \
+ lwz r10,GPR10-INT_FRAME_SIZE(r8); \
+ lwz r11,GPR11-INT_FRAME_SIZE(r8); \
+ mfspr r8,CRIT_SPRG; \
+ \
+ rfci; \
+ b .; \
+ \
+ /* continue normal handling for a critical exception... */ \
+2: mfspr r4,SPRN_DBSR; \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_TEMPLATE(DebugException, 0x2002, (MSR_KERNEL & ~(MSR_ME|MSR_DE|MSR_CE)), NOCOPY, crit_transfer_to_handler, ret_from_crit_exc)
+#endif
+
+#define INSTRUCTION_STORAGE_EXCEPTION \
+ START_EXCEPTION(InstructionStorage) \
+ NORMAL_EXCEPTION_PROLOG; \
+ mfspr r5,SPRN_ESR; /* Grab the ESR and save it */ \
+ stw r5,_ESR(r11); \
+ mr r4,r12; /* Pass SRR0 as arg2 */ \
+ li r5,0; /* Pass zero as arg3 */ \
+ EXC_XFER_EE_LITE(0x0400, handle_page_fault)
+
+#define ALIGNMENT_EXCEPTION \
+ START_EXCEPTION(Alignment) \
+ NORMAL_EXCEPTION_PROLOG; \
+ mfspr r4,SPRN_DEAR; /* Grab the DEAR and save it */ \
+ stw r4,_DEAR(r11); \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_EE(0x0600, alignment_exception)
+
+#define PROGRAM_EXCEPTION \
+ START_EXCEPTION(Program) \
+ NORMAL_EXCEPTION_PROLOG; \
+ mfspr r4,SPRN_ESR; /* Grab the ESR and save it */ \
+ stw r4,_ESR(r11); \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_STD(0x0700, program_check_exception)
+
+#define DECREMENTER_EXCEPTION \
+ START_EXCEPTION(Decrementer) \
+ NORMAL_EXCEPTION_PROLOG; \
+ lis r0,TSR_DIS@h; /* Setup the DEC interrupt mask */ \
+ mtspr SPRN_TSR,r0; /* Clear the DEC interrupt */ \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_LITE(0x0900, timer_interrupt)
+
+#define FP_UNAVAILABLE_EXCEPTION \
+ START_EXCEPTION(FloatingPointUnavailable) \
+ NORMAL_EXCEPTION_PROLOG; \
+ bne load_up_fpu; /* if from user, just load it up */ \
+ addi r3,r1,STACK_FRAME_OVERHEAD; \
+ EXC_XFER_EE_LITE(0x800, kernel_fp_unavailable_exception)
+
+#endif /* __HEAD_BOOKE_H__ */
diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S
index 8d60fa99fc4..dd86bbed762 100644
--- a/arch/powerpc/kernel/head_fsl_booke.S
+++ b/arch/powerpc/kernel/head_fsl_booke.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/head_fsl_booke.S
- *
* Kernel execution entry point code.
*
* Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
@@ -316,6 +314,7 @@ skpinv: addi r6,r6,1 /* Increment */
*/
lis r2,DBCR0_IDM@h
mtspr SPRN_DBCR0,r2
+ isync
/* clear any residual debug events */
li r2,-1
mtspr SPRN_DBSR,r2
@@ -1002,12 +1001,15 @@ _GLOBAL(giveup_fpu)
_GLOBAL(abort)
li r13,0
mtspr SPRN_DBCR0,r13 /* disable all debug events */
+ isync
mfmsr r13
ori r13,r13,MSR_DE@l /* Enable Debug Events */
mtmsr r13
+ isync
mfspr r13,SPRN_DBCR0
lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h
mtspr SPRN_DBCR0,r13
+ isync
_GLOBAL(set_context)
diff --git a/arch/powerpc/kernel/iomap.c b/arch/powerpc/kernel/iomap.c
index 6160c8dbb7c..fd8214caede 100644
--- a/arch/powerpc/kernel/iomap.c
+++ b/arch/powerpc/kernel/iomap.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/iomap.c
- *
* ppc64 "iomap" interface implementation.
*
* (C) Copyright 2004 Linus Torvalds
diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
index 946f3219fd2..d9a7fdef59b 100644
--- a/arch/powerpc/kernel/iommu.c
+++ b/arch/powerpc/kernel/iommu.c
@@ -1,5 +1,4 @@
/*
- * arch/ppc64/kernel/iommu.c
* Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
*
* Rewrite, cleanup, new allocation schemes, virtual merging:
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index d1fffce86df..771a59cbd21 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/irq.c
- *
* Derived from arch/i386/kernel/irq.c
* Copyright (C) 1992 Linus Torvalds
* Adapted from arch/i386 by Gary Thomas
@@ -137,9 +135,8 @@ skip:
#ifdef CONFIG_TAU_INT
if (tau_initialized){
seq_puts(p, "TAU: ");
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", tau_interrupts(j));
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", tau_interrupts(j));
seq_puts(p, " PowerPC Thermal Assist (cpu temp)\n");
}
#endif
@@ -371,6 +368,7 @@ unsigned int real_irq_to_virt_slowpath(unsigned int real_irq)
return NO_IRQ;
}
+#endif /* CONFIG_PPC64 */
#ifdef CONFIG_IRQSTACKS
struct thread_info *softirq_ctx[NR_CPUS];
@@ -394,10 +392,24 @@ void irq_ctx_init(void)
}
}
+static inline void do_softirq_onstack(void)
+{
+ struct thread_info *curtp, *irqtp;
+
+ curtp = current_thread_info();
+ irqtp = softirq_ctx[smp_processor_id()];
+ irqtp->task = curtp->task;
+ call_do_softirq(irqtp);
+ irqtp->task = NULL;
+}
+
+#else
+#define do_softirq_onstack() __do_softirq()
+#endif /* CONFIG_IRQSTACKS */
+
void do_softirq(void)
{
unsigned long flags;
- struct thread_info *curtp, *irqtp;
if (in_interrupt())
return;
@@ -405,19 +417,18 @@ void do_softirq(void)
local_irq_save(flags);
if (local_softirq_pending()) {
- curtp = current_thread_info();
- irqtp = softirq_ctx[smp_processor_id()];
- irqtp->task = curtp->task;
- call_do_softirq(irqtp);
- irqtp->task = NULL;
+ account_system_vtime(current);
+ local_bh_disable();
+ do_softirq_onstack();
+ account_system_vtime(current);
+ __local_bh_enable();
}
local_irq_restore(flags);
}
EXPORT_SYMBOL(do_softirq);
-#endif /* CONFIG_IRQSTACKS */
-
+#ifdef CONFIG_PPC64
static int __init setup_noirqdistrib(char *str)
{
distribute_irqs = 0;
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index cfab48566db..cb1fe5878e8 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -1,6 +1,5 @@
/*
* Kernel Probes (KProbes)
- * arch/ppc64/kernel/kprobes.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -82,9 +81,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
void __kprobes arch_remove_kprobe(struct kprobe *p)
{
- down(&kprobe_mutex);
+ mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
}
static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
diff --git a/arch/powerpc/kernel/of_device.c b/arch/powerpc/kernel/of_device.c
index 22d83d4d1af..9feeeef5a87 100644
--- a/arch/powerpc/kernel/of_device.c
+++ b/arch/powerpc/kernel/of_device.c
@@ -147,15 +147,12 @@ postcore_initcall(of_bus_driver_init);
int of_register_driver(struct of_platform_driver *drv)
{
- int count = 0;
-
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &of_platform_bus_type;
/* register with core */
- count = driver_register(&drv->driver);
- return count ? count : 1;
+ return driver_register(&drv->driver);
}
void of_unregister_driver(struct of_platform_driver *drv)
diff --git a/arch/powerpc/kernel/pci_iommu.c b/arch/powerpc/kernel/pci_iommu.c
index bdf15dbbf4f..c336f3e31cf 100644
--- a/arch/powerpc/kernel/pci_iommu.c
+++ b/arch/powerpc/kernel/pci_iommu.c
@@ -1,5 +1,4 @@
/*
- * arch/ppc64/kernel/pci_iommu.c
* Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
*
* Rewrite, cleanup, new allocation schemes:
diff --git a/arch/powerpc/kernel/ppc_ksyms.c b/arch/powerpc/kernel/ppc_ksyms.c
index 63ecbec0520..dfa5398ab3c 100644
--- a/arch/powerpc/kernel/ppc_ksyms.c
+++ b/arch/powerpc/kernel/ppc_ksyms.c
@@ -57,7 +57,6 @@ extern void machine_check_exception(struct pt_regs *regs);
extern void alignment_exception(struct pt_regs *regs);
extern void program_check_exception(struct pt_regs *regs);
extern void single_step_exception(struct pt_regs *regs);
-extern int pmac_newworld;
extern int sys_sigreturn(struct pt_regs *regs);
EXPORT_SYMBOL(clear_pages);
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index c225cf154bf..1770a066c21 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/process.c
- *
* Derived from "arch/i386/kernel/process.c"
* Copyright (C) 1995 Linus Torvalds
*
@@ -47,9 +45,9 @@
#include <asm/mmu.h>
#include <asm/prom.h>
#include <asm/machdep.h>
+#include <asm/time.h>
#ifdef CONFIG_PPC64
#include <asm/firmware.h>
-#include <asm/time.h>
#endif
extern unsigned long _get_SP(void);
@@ -330,6 +328,11 @@ struct task_struct *__switch_to(struct task_struct *prev,
#endif
local_irq_save(flags);
+
+ account_system_vtime(current);
+ account_process_vtime(current);
+ calculate_steal_time();
+
last = _switch(old_thread, new_thread);
local_irq_restore(flags);
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index 6dbd2172677..d63cd562d9d 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -829,10 +829,6 @@ void __init unflatten_device_tree(void)
/* Allocate memory for the expanded device tree */
mem = lmb_alloc(size + 4, __alignof__(struct device_node));
- if (!mem) {
- DBG("Couldn't allocate memory with lmb_alloc()!\n");
- panic("Couldn't allocate memory with lmb_alloc()!\n");
- }
mem = (unsigned long) __va(mem);
((u32 *)mem)[size / 4] = 0xdeadbeef;
diff --git a/arch/powerpc/kernel/ptrace-common.h b/arch/powerpc/kernel/ptrace-common.h
index 5ccbdbe0d5c..c42a860c8d2 100644
--- a/arch/powerpc/kernel/ptrace-common.h
+++ b/arch/powerpc/kernel/ptrace-common.h
@@ -1,6 +1,4 @@
/*
- * linux/arch/ppc64/kernel/ptrace-common.h
- *
* Copyright (c) 2002 Stephen Rothwell, IBM Coproration
* Extracted from ptrace.c and ptrace32.c
*
diff --git a/arch/powerpc/kernel/rtas-proc.c b/arch/powerpc/kernel/rtas-proc.c
index 7a95b8a2835..1f03fb28cc0 100644
--- a/arch/powerpc/kernel/rtas-proc.c
+++ b/arch/powerpc/kernel/rtas-proc.c
@@ -1,5 +1,4 @@
/*
- * arch/ppc64/kernel/rtas-proc.c
* Copyright (C) 2000 Tilmann Bitterberg
* (tilmann@bitterberg.de)
*
diff --git a/arch/powerpc/kernel/rtas_pci.c b/arch/powerpc/kernel/rtas_pci.c
index 7442775ef2a..57b539a03fa 100644
--- a/arch/powerpc/kernel/rtas_pci.c
+++ b/arch/powerpc/kernel/rtas_pci.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/rtas_pci.c
- *
* Copyright (C) 2001 Dave Engebretsen, IBM Corporation
* Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
*
diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
index be12041c0fc..c1d62bf11f2 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -162,9 +162,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
#if defined(CONFIG_SMP) && defined(CONFIG_PPC32)
unsigned long bogosum = 0;
int i;
- for (i = 0; i < NR_CPUS; ++i)
- if (cpu_online(i))
- bogosum += loops_per_jiffy;
+ for_each_online_cpu(i)
+ bogosum += loops_per_jiffy;
seq_printf(m, "total bogomips\t: %lu.%02lu\n",
bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
#endif /* CONFIG_SMP && CONFIG_PPC32 */
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index db72a92943b..dc2770df25b 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -272,9 +272,8 @@ int __init ppc_init(void)
if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
/* register CPU devices */
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_possible(i))
- register_cpu(&cpu_devices[i], i, NULL);
+ for_each_cpu(i)
+ register_cpu(&cpu_devices[i], i, NULL);
/* call platform init */
if (ppc_md.init != NULL) {
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index f96c49b03ba..2f3fdad3559 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -497,8 +497,6 @@ void __init setup_system(void)
#endif
printk("-----------------------------------------------------\n");
- mm_init_ppc64();
-
DBG(" <- setup_system()\n");
}
diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
index 4324f8a8ba2..47f910380a6 100644
--- a/arch/powerpc/kernel/signal_64.c
+++ b/arch/powerpc/kernel/signal_64.c
@@ -1,6 +1,4 @@
/*
- * linux/arch/ppc64/kernel/signal.c
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
*
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 13595a64f01..805eaedbc30 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -541,7 +541,7 @@ int __devinit start_secondary(void *unused)
smp_ops->take_timebase();
if (system_state > SYSTEM_BOOTING)
- per_cpu(last_jiffy, cpu) = get_tb();
+ snapshot_timebase();
spin_lock(&call_lock);
cpu_set(cpu, cpu_online_map);
@@ -573,6 +573,8 @@ void __init smp_cpus_done(unsigned int max_cpus)
set_cpus_allowed(current, old_mask);
+ snapshot_timebases();
+
dump_numa_cpu_topology();
}
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 86f7e3d154d..4a27218a086 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -51,6 +51,7 @@
#include <linux/percpu.h>
#include <linux/rtc.h>
#include <linux/jiffies.h>
+#include <linux/posix-timers.h>
#include <asm/io.h>
#include <asm/processor.h>
@@ -98,6 +99,7 @@ unsigned long tb_ticks_per_jiffy;
unsigned long tb_ticks_per_usec = 100; /* sane default */
EXPORT_SYMBOL(tb_ticks_per_usec);
unsigned long tb_ticks_per_sec;
+EXPORT_SYMBOL(tb_ticks_per_sec); /* for cputime_t conversions */
u64 tb_to_xs;
unsigned tb_to_us;
@@ -135,6 +137,224 @@ unsigned long tb_last_stamp;
*/
DEFINE_PER_CPU(unsigned long, last_jiffy);
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+/*
+ * Factors for converting from cputime_t (timebase ticks) to
+ * jiffies, milliseconds, seconds, and clock_t (1/USER_HZ seconds).
+ * These are all stored as 0.64 fixed-point binary fractions.
+ */
+u64 __cputime_jiffies_factor;
+EXPORT_SYMBOL(__cputime_jiffies_factor);
+u64 __cputime_msec_factor;
+EXPORT_SYMBOL(__cputime_msec_factor);
+u64 __cputime_sec_factor;
+EXPORT_SYMBOL(__cputime_sec_factor);
+u64 __cputime_clockt_factor;
+EXPORT_SYMBOL(__cputime_clockt_factor);
+
+static void calc_cputime_factors(void)
+{
+ struct div_result res;
+
+ div128_by_32(HZ, 0, tb_ticks_per_sec, &res);
+ __cputime_jiffies_factor = res.result_low;
+ div128_by_32(1000, 0, tb_ticks_per_sec, &res);
+ __cputime_msec_factor = res.result_low;
+ div128_by_32(1, 0, tb_ticks_per_sec, &res);
+ __cputime_sec_factor = res.result_low;
+ div128_by_32(USER_HZ, 0, tb_ticks_per_sec, &res);
+ __cputime_clockt_factor = res.result_low;
+}
+
+/*
+ * Read the PURR on systems that have it, otherwise the timebase.
+ */
+static u64 read_purr(void)
+{
+ if (cpu_has_feature(CPU_FTR_PURR))
+ return mfspr(SPRN_PURR);
+ return mftb();
+}
+
+/*
+ * Account time for a transition between system, hard irq
+ * or soft irq state.
+ */
+void account_system_vtime(struct task_struct *tsk)
+{
+ u64 now, delta;
+ unsigned long flags;
+
+ local_irq_save(flags);
+ now = read_purr();
+ delta = now - get_paca()->startpurr;
+ get_paca()->startpurr = now;
+ if (!in_interrupt()) {
+ delta += get_paca()->system_time;
+ get_paca()->system_time = 0;
+ }
+ account_system_time(tsk, 0, delta);
+ local_irq_restore(flags);
+}
+
+/*
+ * Transfer the user and system times accumulated in the paca
+ * by the exception entry and exit code to the generic process
+ * user and system time records.
+ * Must be called with interrupts disabled.
+ */
+void account_process_vtime(struct task_struct *tsk)
+{
+ cputime_t utime;
+
+ utime = get_paca()->user_time;
+ get_paca()->user_time = 0;
+ account_user_time(tsk, utime);
+}
+
+static void account_process_time(struct pt_regs *regs)
+{
+ int cpu = smp_processor_id();
+
+ account_process_vtime(current);
+ run_local_timers();
+ if (rcu_pending(cpu))
+ rcu_check_callbacks(cpu, user_mode(regs));
+ scheduler_tick();
+ run_posix_cpu_timers(current);
+}
+
+#ifdef CONFIG_PPC_SPLPAR
+/*
+ * Stuff for accounting stolen time.
+ */
+struct cpu_purr_data {
+ int initialized; /* thread is running */
+ u64 tb0; /* timebase at origin time */
+ u64 purr0; /* PURR at origin time */
+ u64 tb; /* last TB value read */
+ u64 purr; /* last PURR value read */
+ u64 stolen; /* stolen time so far */
+ spinlock_t lock;
+};
+
+static DEFINE_PER_CPU(struct cpu_purr_data, cpu_purr_data);
+
+static void snapshot_tb_and_purr(void *data)
+{
+ struct cpu_purr_data *p = &__get_cpu_var(cpu_purr_data);
+
+ p->tb0 = mftb();
+ p->purr0 = mfspr(SPRN_PURR);
+ p->tb = p->tb0;
+ p->purr = 0;
+ wmb();
+ p->initialized = 1;
+}
+
+/*
+ * Called during boot when all cpus have come up.
+ */
+void snapshot_timebases(void)
+{
+ int cpu;
+
+ if (!cpu_has_feature(CPU_FTR_PURR))
+ return;
+ for_each_cpu(cpu)
+ spin_lock_init(&per_cpu(cpu_purr_data, cpu).lock);
+ on_each_cpu(snapshot_tb_and_purr, NULL, 0, 1);
+}
+
+void calculate_steal_time(void)
+{
+ u64 tb, purr, t0;
+ s64 stolen;
+ struct cpu_purr_data *p0, *pme, *phim;
+ int cpu;
+
+ if (!cpu_has_feature(CPU_FTR_PURR))
+ return;
+ cpu = smp_processor_id();
+ pme = &per_cpu(cpu_purr_data, cpu);
+ if (!pme->initialized)
+ return; /* this can happen in early boot */
+ p0 = &per_cpu(cpu_purr_data, cpu & ~1);
+ phim = &per_cpu(cpu_purr_data, cpu ^ 1);
+ spin_lock(&p0->lock);
+ tb = mftb();
+ purr = mfspr(SPRN_PURR) - pme->purr0;
+ if (!phim->initialized || !cpu_online(cpu ^ 1)) {
+ stolen = (tb - pme->tb) - (purr - pme->purr);
+ } else {
+ t0 = pme->tb0;
+ if (phim->tb0 < t0)
+ t0 = phim->tb0;
+ stolen = phim->tb - t0 - phim->purr - purr - p0->stolen;
+ }
+ if (stolen > 0) {
+ account_steal_time(current, stolen);
+ p0->stolen += stolen;
+ }
+ pme->tb = tb;
+ pme->purr = purr;
+ spin_unlock(&p0->lock);
+}
+
+/*
+ * Must be called before the cpu is added to the online map when
+ * a cpu is being brought up at runtime.
+ */
+static void snapshot_purr(void)
+{
+ int cpu;
+ u64 purr;
+ struct cpu_purr_data *p0, *pme, *phim;
+ unsigned long flags;
+
+ if (!cpu_has_feature(CPU_FTR_PURR))
+ return;
+ cpu = smp_processor_id();
+ pme = &per_cpu(cpu_purr_data, cpu);
+ p0 = &per_cpu(cpu_purr_data, cpu & ~1);
+ phim = &per_cpu(cpu_purr_data, cpu ^ 1);
+ spin_lock_irqsave(&p0->lock, flags);
+ pme->tb = pme->tb0 = mftb();
+ purr = mfspr(SPRN_PURR);
+ if (!phim->initialized) {
+ pme->purr = 0;
+ pme->purr0 = purr;
+ } else {
+ /* set p->purr and p->purr0 for no change in p0->stolen */
+ pme->purr = phim->tb - phim->tb0 - phim->purr - p0->stolen;
+ pme->purr0 = purr - pme->purr;
+ }
+ pme->initialized = 1;
+ spin_unlock_irqrestore(&p0->lock, flags);
+}
+
+#endif /* CONFIG_PPC_SPLPAR */
+
+#else /* ! CONFIG_VIRT_CPU_ACCOUNTING */
+#define calc_cputime_factors()
+#define account_process_time(regs) update_process_times(user_mode(regs))
+#define calculate_steal_time() do { } while (0)
+#endif
+
+#if !(defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR))
+#define snapshot_purr() do { } while (0)
+#endif
+
+/*
+ * Called when a cpu comes up after the system has finished booting,
+ * i.e. as a result of a hotplug cpu action.
+ */
+void snapshot_timebase(void)
+{
+ __get_cpu_var(last_jiffy) = get_tb();
+ snapshot_purr();
+}
+
void __delay(unsigned long loops)
{
unsigned long start;
@@ -392,6 +612,7 @@ static void iSeries_tb_recal(void)
new_tb_ticks_per_jiffy, sign, tick_diff );
tb_ticks_per_jiffy = new_tb_ticks_per_jiffy;
tb_ticks_per_sec = new_tb_ticks_per_sec;
+ calc_cputime_factors();
div128_by_32( XSEC_PER_SEC, 0, tb_ticks_per_sec, &divres );
do_gtod.tb_ticks_per_sec = tb_ticks_per_sec;
tb_to_xs = divres.result_low;
@@ -440,6 +661,7 @@ void timer_interrupt(struct pt_regs * regs)
irq_enter();
profile_tick(CPU_PROFILING, regs);
+ calculate_steal_time();
#ifdef CONFIG_PPC_ISERIES
get_lppaca()->int_dword.fields.decr_int = 0;
@@ -461,7 +683,7 @@ void timer_interrupt(struct pt_regs * regs)
* is the case.
*/
if (!cpu_is_offline(cpu))
- update_process_times(user_mode(regs));
+ account_process_time(regs);
/*
* No need to check whether cpu is offline here; boot_cpuid
@@ -518,13 +740,27 @@ void wakeup_decrementer(void)
void __init smp_space_timers(unsigned int max_cpus)
{
int i;
+ unsigned long half = tb_ticks_per_jiffy / 2;
unsigned long offset = tb_ticks_per_jiffy / max_cpus;
unsigned long previous_tb = per_cpu(last_jiffy, boot_cpuid);
/* make sure tb > per_cpu(last_jiffy, cpu) for all cpus always */
previous_tb -= tb_ticks_per_jiffy;
+ /*
+ * The stolen time calculation for POWER5 shared-processor LPAR
+ * systems works better if the two threads' timebase interrupts
+ * are staggered by half a jiffy with respect to each other.
+ */
for_each_cpu(i) {
- if (i != boot_cpuid) {
+ if (i == boot_cpuid)
+ continue;
+ if (i == (boot_cpuid ^ 1))
+ per_cpu(last_jiffy, i) =
+ per_cpu(last_jiffy, boot_cpuid) - half;
+ else if (i & 1)
+ per_cpu(last_jiffy, i) =
+ per_cpu(last_jiffy, i ^ 1) + half;
+ else {
previous_tb += offset;
per_cpu(last_jiffy, i) = previous_tb;
}
@@ -720,6 +956,7 @@ void __init time_init(void)
tb_ticks_per_sec = ppc_tb_freq;
tb_ticks_per_usec = ppc_tb_freq / 1000000;
tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000);
+ calc_cputime_factors();
/*
* Calculate the length of each tick in ns. It will not be
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
index 04f7df39ffb..ec837036842 100644
--- a/arch/powerpc/kernel/vdso.c
+++ b/arch/powerpc/kernel/vdso.c
@@ -1,6 +1,4 @@
/*
- * linux/arch/ppc64/kernel/vdso.c
- *
* Copyright (C) 2004 Benjamin Herrenschmidt, IBM Corp.
* <benh@kernel.crashing.org>
*
diff --git a/arch/powerpc/lib/copypage_64.S b/arch/powerpc/lib/copypage_64.S
index 40523b14010..f9837f44ac0 100644
--- a/arch/powerpc/lib/copypage_64.S
+++ b/arch/powerpc/lib/copypage_64.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/lib/copypage.S
- *
* Copyright (C) 2002 Paul Mackerras, IBM Corp.
*
* This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/copyuser_64.S b/arch/powerpc/lib/copyuser_64.S
index 6d69ef39b7d..a6b54cb97c4 100644
--- a/arch/powerpc/lib/copyuser_64.S
+++ b/arch/powerpc/lib/copyuser_64.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/lib/copyuser.S
- *
* Copyright (C) 2002 Paul Mackerras, IBM Corp.
*
* This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/e2a.c b/arch/powerpc/lib/e2a.c
index d2b83488792..4b72ed8fd50 100644
--- a/arch/powerpc/lib/e2a.c
+++ b/arch/powerpc/lib/e2a.c
@@ -1,9 +1,7 @@
/*
- * arch/ppc64/lib/e2a.c
- *
* EBCDIC to ASCII conversion
*
- * This function moved here from arch/ppc64/kernel/viopath.c
+ * This function moved here from arch/powerpc/platforms/iseries/viopath.c
*
* (C) Copyright 2000-2004 IBM Corporation
*
@@ -105,4 +103,14 @@ unsigned char e2a(unsigned char x)
}
EXPORT_SYMBOL(e2a);
+unsigned char* strne2a(unsigned char *dest, const unsigned char *src, size_t n)
+{
+ int i;
+
+ n = strnlen(src, n);
+ for (i = 0; i < n; i++)
+ dest[i] = e2a(src[i]);
+
+ return dest;
+}
diff --git a/arch/powerpc/lib/memcpy_64.S b/arch/powerpc/lib/memcpy_64.S
index 9ccacdf5bcb..fd66acfd3e3 100644
--- a/arch/powerpc/lib/memcpy_64.S
+++ b/arch/powerpc/lib/memcpy_64.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/lib/memcpy.S
- *
* Copyright (C) 2002 Paul Mackerras, IBM Corp.
*
* This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 42c5de2c898..31e511856dc 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/rheap.c
- *
* A Remote Heap. Remote means that we don't touch the memory that the
* heap points to. Normal heap implementations use the memory they manage
* to place their list. We cannot do that because the memory we manage may
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index a4815d31672..ec4adcb4bc2 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/mm/fault.c
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
*
diff --git a/arch/powerpc/mm/hash_low_32.S b/arch/powerpc/mm/hash_low_32.S
index 12ccd7155ba..ea469eefa14 100644
--- a/arch/powerpc/mm/hash_low_32.S
+++ b/arch/powerpc/mm/hash_low_32.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/hashtable.S
- *
* $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $
*
* PowerPC version
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index e9d589eefc1..89b35c18131 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -169,7 +169,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
#ifdef CONFIG_PPC_ISERIES
if (_machine == PLATFORM_ISERIES_LPAR)
ret = iSeries_hpte_insert(hpteg, va,
- __pa(vaddr),
+ paddr,
tmp_mode,
HPTE_V_BOLTED,
psize);
@@ -178,7 +178,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
#ifdef CONFIG_PPC_PSERIES
if (_machine & PLATFORM_LPAR)
ret = pSeries_lpar_hpte_insert(hpteg, va,
- virt_to_abs(paddr),
+ paddr,
tmp_mode,
HPTE_V_BOLTED,
psize);
@@ -186,7 +186,7 @@ int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
#endif
#ifdef CONFIG_PPC_MULTIPLATFORM
ret = native_hpte_insert(hpteg, va,
- virt_to_abs(paddr),
+ paddr,
tmp_mode, HPTE_V_BOLTED,
psize);
#endif
@@ -392,7 +392,7 @@ static unsigned long __init htab_get_table_size(void)
#ifdef CONFIG_MEMORY_HOTPLUG
void create_section_mapping(unsigned long start, unsigned long end)
{
- BUG_ON(htab_bolt_mapping(start, end, start,
+ BUG_ON(htab_bolt_mapping(start, end, __pa(start),
_PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_COHERENT | PP_RWXX,
mmu_linear_psize));
}
@@ -422,7 +422,7 @@ void __init htab_initialize(void)
htab_hash_mask = pteg_count - 1;
- if (platform_is_lpar()) {
+ if (firmware_has_feature(FW_FEATURE_LPAR)) {
/* Using a hypervisor which owns the htab */
htab_address = NULL;
_SDR1 = 0;
@@ -431,7 +431,6 @@ void __init htab_initialize(void)
* the absolute address space.
*/
table = lmb_alloc(htab_size_bytes, htab_size_bytes);
- BUG_ON(table == 0);
DBG("Hash table allocated at %lx, size: %lx\n", table,
htab_size_bytes);
@@ -474,21 +473,22 @@ void __init htab_initialize(void)
if (dart_tablebase != 0 && dart_tablebase >= base
&& dart_tablebase < (base + size)) {
+ unsigned long dart_table_end = dart_tablebase + 16 * MB;
if (base != dart_tablebase)
BUG_ON(htab_bolt_mapping(base, dart_tablebase,
- base, mode_rw,
- mmu_linear_psize));
- if ((base + size) > (dart_tablebase + 16*MB))
+ __pa(base), mode_rw,
+ mmu_linear_psize));
+ if ((base + size) > dart_table_end)
BUG_ON(htab_bolt_mapping(dart_tablebase+16*MB,
- base + size,
- dart_tablebase+16*MB,
+ base + size,
+ __pa(dart_table_end),
mode_rw,
mmu_linear_psize));
continue;
}
#endif /* CONFIG_U3_DART */
- BUG_ON(htab_bolt_mapping(base, base + size, base,
- mode_rw, mmu_linear_psize));
+ BUG_ON(htab_bolt_mapping(base, base + size, __pa(base),
+ mode_rw, mmu_linear_psize));
}
/*
@@ -505,8 +505,8 @@ void __init htab_initialize(void)
if (base + size >= tce_alloc_start)
tce_alloc_start = base + size + 1;
- BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end,
- tce_alloc_start, mode_rw,
+ BUG_ON(htab_bolt_mapping(tce_alloc_start, tce_alloc_end,
+ __pa(tce_alloc_start), mode_rw,
mmu_linear_psize));
}
@@ -517,7 +517,7 @@ void __init htab_initialize(void)
void htab_initialize_secondary(void)
{
- if (!platform_is_lpar())
+ if (!firmware_has_feature(FW_FEATURE_LPAR))
mtspr(SPRN_SDR1, _SDR1);
}
diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
index bacb71c8981..babebd15bdc 100644
--- a/arch/powerpc/mm/init_64.c
+++ b/arch/powerpc/mm/init_64.c
@@ -84,54 +84,6 @@
/* max amount of RAM to use */
unsigned long __max_memory;
-/* info on what we think the IO hole is */
-unsigned long io_hole_start;
-unsigned long io_hole_size;
-
-/*
- * Do very early mm setup.
- */
-void __init mm_init_ppc64(void)
-{
-#ifndef CONFIG_PPC_ISERIES
- unsigned long i;
-#endif
-
- ppc64_boot_msg(0x100, "MM Init");
-
- /* This is the story of the IO hole... please, keep seated,
- * unfortunately, we are out of oxygen masks at the moment.
- * So we need some rough way to tell where your big IO hole
- * is. On pmac, it's between 2G and 4G, on POWER3, it's around
- * that area as well, on POWER4 we don't have one, etc...
- * We need that as a "hint" when sizing the TCE table on POWER3
- * So far, the simplest way that seem work well enough for us it
- * to just assume that the first discontinuity in our physical
- * RAM layout is the IO hole. That may not be correct in the future
- * (and isn't on iSeries but then we don't care ;)
- */
-
-#ifndef CONFIG_PPC_ISERIES
- for (i = 1; i < lmb.memory.cnt; i++) {
- unsigned long base, prevbase, prevsize;
-
- prevbase = lmb.memory.region[i-1].base;
- prevsize = lmb.memory.region[i-1].size;
- base = lmb.memory.region[i].base;
- if (base > (prevbase + prevsize)) {
- io_hole_start = prevbase + prevsize;
- io_hole_size = base - (prevbase + prevsize);
- break;
- }
- }
-#endif /* CONFIG_PPC_ISERIES */
- if (io_hole_start)
- printk("IO Hole assumed to be %lx -> %lx\n",
- io_hole_start, io_hole_start + io_hole_size - 1);
-
- ppc64_boot_msg(0x100, "MM Init Done");
-}
-
void free_initmem(void)
{
unsigned long addr;
diff --git a/arch/powerpc/mm/lmb.c b/arch/powerpc/mm/lmb.c
index bbe3eac918e..417d5851855 100644
--- a/arch/powerpc/mm/lmb.c
+++ b/arch/powerpc/mm/lmb.c
@@ -31,6 +31,8 @@
#define DBG(fmt...)
#endif
+#define LMB_ALLOC_ANYWHERE 0
+
struct lmb lmb;
void lmb_dump_all(void)
@@ -226,6 +228,20 @@ unsigned long __init lmb_alloc(unsigned long size, unsigned long align)
unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align,
unsigned long max_addr)
{
+ unsigned long alloc;
+
+ alloc = __lmb_alloc_base(size, align, max_addr);
+
+ if (alloc == 0)
+ panic("ERROR: Failed to allocate 0x%lx bytes below 0x%lx.\n",
+ size, max_addr);
+
+ return alloc;
+}
+
+unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
+ unsigned long max_addr)
+{
long i, j;
unsigned long base = 0;
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 454cac01d8c..badac10d700 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -125,7 +125,7 @@ int __devinit add_memory(u64 start, u64 size)
nid = hot_add_scn_to_nid(start);
pgdata = NODE_DATA(nid);
- start = __va(start);
+ start = (unsigned long)__va(start);
create_section_mapping(start, start + size);
/* this should work for most non-highmem platforms */
@@ -249,7 +249,6 @@ void __init do_init_bootmem(void)
bootmap_pages = bootmem_bootmap_pages(total_pages);
start = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
- BUG_ON(!start);
boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
index fe65f522aff..972a8e884b9 100644
--- a/arch/powerpc/mm/mmap.c
+++ b/arch/powerpc/mm/mmap.c
@@ -1,6 +1,4 @@
/*
- * linux/arch/ppc64/mm/mmap.c
- *
* flexible mmap layout support
*
* Copyright 2003-2004 Red Hat Inc., Durham, North Carolina.
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
index 2863a912bcd..e89b22aa539 100644
--- a/arch/powerpc/mm/numa.c
+++ b/arch/powerpc/mm/numa.c
@@ -129,10 +129,12 @@ void __init get_region(unsigned int nid, unsigned long *start_pfn,
*start_pfn = 0;
}
-static inline void map_cpu_to_node(int cpu, int node)
+static void __cpuinit map_cpu_to_node(int cpu, int node)
{
numa_cpu_lookup_table[cpu] = node;
+ dbg("adding cpu %d to node %d\n", cpu, node);
+
if (!(cpu_isset(cpu, numa_cpumask_lookup_table[node])))
cpu_set(cpu, numa_cpumask_lookup_table[node]);
}
@@ -153,7 +155,7 @@ static void unmap_cpu_from_node(unsigned long cpu)
}
#endif /* CONFIG_HOTPLUG_CPU */
-static struct device_node *find_cpu_node(unsigned int cpu)
+static struct device_node * __cpuinit find_cpu_node(unsigned int cpu)
{
unsigned int hw_cpuid = get_hard_smp_processor_id(cpu);
struct device_node *cpu_node = NULL;
@@ -189,23 +191,29 @@ static int *of_get_associativity(struct device_node *dev)
return (unsigned int *)get_property(dev, "ibm,associativity", NULL);
}
-static int of_node_numa_domain(struct device_node *device)
+/* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa
+ * info is found.
+ */
+static int of_node_to_nid(struct device_node *device)
{
- int numa_domain;
+ int nid = -1;
unsigned int *tmp;
if (min_common_depth == -1)
- return 0;
+ goto out;
tmp = of_get_associativity(device);
- if (tmp && (tmp[0] >= min_common_depth)) {
- numa_domain = tmp[min_common_depth];
- } else {
- dbg("WARNING: no NUMA information for %s\n",
- device->full_name);
- numa_domain = 0;
- }
- return numa_domain;
+ if (!tmp)
+ goto out;
+
+ if (tmp[0] >= min_common_depth)
+ nid = tmp[min_common_depth];
+
+ /* POWER4 LPAR uses 0xffff as invalid node */
+ if (nid == 0xffff || nid >= MAX_NUMNODES)
+ nid = -1;
+out:
+ return nid;
}
/*
@@ -246,8 +254,7 @@ static int __init find_min_common_depth(void)
if ((len >= 1) && ref_points) {
depth = ref_points[1];
} else {
- dbg("WARNING: could not find NUMA "
- "associativity reference point\n");
+ dbg("NUMA: ibm,associativity-reference-points not found.\n");
depth = -1;
}
of_node_put(rtas_root);
@@ -283,9 +290,9 @@ static unsigned long __devinit read_n_cells(int n, unsigned int **buf)
* Figure out to which domain a cpu belongs and stick it there.
* Return the id of the domain used.
*/
-static int numa_setup_cpu(unsigned long lcpu)
+static int __cpuinit numa_setup_cpu(unsigned long lcpu)
{
- int numa_domain = 0;
+ int nid = 0;
struct device_node *cpu = find_cpu_node(lcpu);
if (!cpu) {
@@ -293,27 +300,16 @@ static int numa_setup_cpu(unsigned long lcpu)
goto out;
}
- numa_domain = of_node_numa_domain(cpu);
+ nid = of_node_to_nid(cpu);
- if (numa_domain >= num_online_nodes()) {
- /*
- * POWER4 LPAR uses 0xffff as invalid node,
- * dont warn in this case.
- */
- if (numa_domain != 0xffff)
- printk(KERN_ERR "WARNING: cpu %ld "
- "maps to invalid NUMA node %d\n",
- lcpu, numa_domain);
- numa_domain = 0;
- }
+ if (nid < 0 || !node_online(nid))
+ nid = any_online_node(NODE_MASK_ALL);
out:
- node_set_online(numa_domain);
-
- map_cpu_to_node(lcpu, numa_domain);
+ map_cpu_to_node(lcpu, nid);
of_node_put(cpu);
- return numa_domain;
+ return nid;
}
static int cpu_numa_callback(struct notifier_block *nfb,
@@ -325,10 +321,7 @@ static int cpu_numa_callback(struct notifier_block *nfb,
switch (action) {
case CPU_UP_PREPARE:
- if (min_common_depth == -1 || !numa_enabled)
- map_cpu_to_node(lcpu, 0);
- else
- numa_setup_cpu(lcpu);
+ numa_setup_cpu(lcpu);
ret = NOTIFY_OK;
break;
#ifdef CONFIG_HOTPLUG_CPU
@@ -375,7 +368,7 @@ static int __init parse_numa_properties(void)
{
struct device_node *cpu = NULL;
struct device_node *memory = NULL;
- int max_domain;
+ int default_nid = 0;
unsigned long i;
if (numa_enabled == 0) {
@@ -385,32 +378,32 @@ static int __init parse_numa_properties(void)
min_common_depth = find_min_common_depth();
- dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
if (min_common_depth < 0)
return min_common_depth;
- max_domain = numa_setup_cpu(boot_cpuid);
+ dbg("NUMA associativity depth for CPU/Memory: %d\n", min_common_depth);
/*
- * Even though we connect cpus to numa domains later in SMP init,
- * we need to know the maximum node id now. This is because each
- * node id must have NODE_DATA etc backing it.
- * As a result of hotplug we could still have cpus appear later on
- * with larger node ids. In that case we force the cpu into node 0.
+ * Even though we connect cpus to numa domains later in SMP
+ * init, we need to know the node ids now. This is because
+ * each node to be onlined must have NODE_DATA etc backing it.
*/
- for_each_cpu(i) {
- int numa_domain;
+ for_each_present_cpu(i) {
+ int nid;
cpu = find_cpu_node(i);
+ BUG_ON(!cpu);
+ nid = of_node_to_nid(cpu);
+ of_node_put(cpu);
- if (cpu) {
- numa_domain = of_node_numa_domain(cpu);
- of_node_put(cpu);
-
- if (numa_domain < MAX_NUMNODES &&
- max_domain < numa_domain)
- max_domain = numa_domain;
- }
+ /*
+ * Don't fall back to default_nid yet -- we will plug
+ * cpus into nodes once the memory scan has discovered
+ * the topology.
+ */
+ if (nid < 0)
+ continue;
+ node_set_online(nid);
}
get_n_mem_cells(&n_mem_addr_cells, &n_mem_size_cells);
@@ -418,7 +411,7 @@ static int __init parse_numa_properties(void)
while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
unsigned long start;
unsigned long size;
- int numa_domain;
+ int nid;
int ranges;
unsigned int *memcell_buf;
unsigned int len;
@@ -439,18 +432,15 @@ new_range:
start = read_n_cells(n_mem_addr_cells, &memcell_buf);
size = read_n_cells(n_mem_size_cells, &memcell_buf);
- numa_domain = of_node_numa_domain(memory);
-
- if (numa_domain >= MAX_NUMNODES) {
- if (numa_domain != 0xffff)
- printk(KERN_ERR "WARNING: memory at %lx maps "
- "to invalid NUMA node %d\n", start,
- numa_domain);
- numa_domain = 0;
- }
-
- if (max_domain < numa_domain)
- max_domain = numa_domain;
+ /*
+ * Assumption: either all memory nodes or none will
+ * have associativity properties. If none, then
+ * everything goes to default_nid.
+ */
+ nid = of_node_to_nid(memory);
+ if (nid < 0)
+ nid = default_nid;
+ node_set_online(nid);
if (!(size = numa_enforce_memory_limit(start, size))) {
if (--ranges)
@@ -459,16 +449,13 @@ new_range:
continue;
}
- add_region(numa_domain, start >> PAGE_SHIFT,
+ add_region(nid, start >> PAGE_SHIFT,
size >> PAGE_SHIFT);
if (--ranges)
goto new_range;
}
- for (i = 0; i <= max_domain; i++)
- node_set_online(i);
-
return 0;
}
@@ -483,7 +470,6 @@ static void __init setup_nonnuma(void)
printk(KERN_INFO "Memory hole size: %ldMB\n",
(top_of_ram - total_ram) >> 20);
- map_cpu_to_node(boot_cpuid, 0);
for (i = 0; i < lmb.memory.cnt; ++i)
add_region(0, lmb.memory.region[i].base >> PAGE_SHIFT,
lmb_size_pages(&lmb.memory, i));
@@ -570,11 +556,11 @@ static void __init *careful_allocation(int nid, unsigned long size,
unsigned long end_pfn)
{
int new_nid;
- unsigned long ret = lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT);
+ unsigned long ret = __lmb_alloc_base(size, align, end_pfn << PAGE_SHIFT);
/* retry over all memory */
if (!ret)
- ret = lmb_alloc_base(size, align, lmb_end_of_DRAM());
+ ret = __lmb_alloc_base(size, align, lmb_end_of_DRAM());
if (!ret)
panic("numa.c: cannot allocate %lu bytes on node %d",
@@ -620,6 +606,8 @@ void __init do_init_bootmem(void)
dump_numa_memory_topology();
register_cpu_notifier(&ppc64_numa_nb);
+ cpu_numa_callback(&ppc64_numa_nb, CPU_UP_PREPARE,
+ (void *)(unsigned long)boot_cpuid);
for_each_online_node(nid) {
unsigned long start_pfn, end_pfn, pages_present;
@@ -767,10 +755,10 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
{
struct device_node *memory = NULL;
nodemask_t nodes;
- int numa_domain = 0;
+ int default_nid = any_online_node(NODE_MASK_ALL);
if (!numa_enabled || (min_common_depth < 0))
- return numa_domain;
+ return default_nid;
while ((memory = of_find_node_by_type(memory, "memory")) != NULL) {
unsigned long start, size;
@@ -787,15 +775,15 @@ int hot_add_scn_to_nid(unsigned long scn_addr)
ha_new_range:
start = read_n_cells(n_mem_addr_cells, &memcell_buf);
size = read_n_cells(n_mem_size_cells, &memcell_buf);
- numa_domain = of_node_numa_domain(memory);
+ nid = of_node_to_nid(memory);
/* Domains not present at boot default to 0 */
- if (!node_online(numa_domain))
- numa_domain = any_online_node(NODE_MASK_ALL);
+ if (nid < 0 || !node_online(nid))
+ nid = default_nid;
if ((scn_addr >= start) && (scn_addr < (start + size))) {
of_node_put(memory);
- goto got_numa_domain;
+ goto got_nid;
}
if (--ranges) /* process all ranges in cell */
@@ -804,12 +792,12 @@ ha_new_range:
BUG(); /* section address should be found above */
/* Temporary code to ensure that returned node is not empty */
-got_numa_domain:
+got_nid:
nodes_setall(nodes);
- while (NODE_DATA(numa_domain)->node_spanned_pages == 0) {
- node_clear(numa_domain, nodes);
- numa_domain = any_online_node(nodes);
+ while (NODE_DATA(nid)->node_spanned_pages == 0) {
+ node_clear(nid, nodes);
+ nid = any_online_node(nodes);
}
- return numa_domain;
+ return nid;
}
#endif /* CONFIG_MEMORY_HOTPLUG */
diff --git a/arch/powerpc/mm/slb_low.S b/arch/powerpc/mm/slb_low.S
index d1acee38f16..abfaabf667b 100644
--- a/arch/powerpc/mm/slb_low.S
+++ b/arch/powerpc/mm/slb_low.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/mm/slb_low.S
- *
* Low-level SLB routines
*
* Copyright (C) 2004 David Gibson <dwg@au.ibm.com>, IBM
diff --git a/arch/powerpc/mm/stab.c b/arch/powerpc/mm/stab.c
index 82e4951826b..91d25fb27f8 100644
--- a/arch/powerpc/mm/stab.c
+++ b/arch/powerpc/mm/stab.c
@@ -247,10 +247,6 @@ void stabs_alloc(void)
newstab = lmb_alloc_base(HW_PAGE_SIZE, HW_PAGE_SIZE,
1<<SID_SHIFT);
- if (! newstab)
- panic("Unable to allocate segment table for CPU %d.\n",
- cpu);
-
newstab = (unsigned long)__va(newstab);
memset((void *)newstab, 0, HW_PAGE_SIZE);
diff --git a/arch/powerpc/mm/tlb_64.c b/arch/powerpc/mm/tlb_64.c
index bb3afb6e631..f734b11566c 100644
--- a/arch/powerpc/mm/tlb_64.c
+++ b/arch/powerpc/mm/tlb_64.c
@@ -36,7 +36,7 @@
DEFINE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
/* This is declared as we are using the more or less generic
- * include/asm-ppc64/tlb.h file -- tgall
+ * include/asm-powerpc/tlb.h file -- tgall
*/
DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
DEFINE_PER_CPU(struct pte_freelist_batch *, pte_freelist_cur);
diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c
index 659a021da0c..4b06e53eb9b 100644
--- a/arch/powerpc/oprofile/op_model_power4.c
+++ b/arch/powerpc/oprofile/op_model_power4.c
@@ -10,6 +10,7 @@
#include <linux/oprofile.h>
#include <linux/init.h>
#include <linux/smp.h>
+#include <asm/firmware.h>
#include <asm/ptrace.h>
#include <asm/system.h>
#include <asm/processor.h>
@@ -232,7 +233,7 @@ static unsigned long get_pc(struct pt_regs *regs)
mmcra = mfspr(SPRN_MMCRA);
/* Were we in the hypervisor? */
- if (platform_is_lpar() && (mmcra & MMCRA_SIHV))
+ if (firmware_has_feature(FW_FEATURE_LPAR) && (mmcra & MMCRA_SIHV))
/* function descriptor madness */
return *((unsigned long *)hypervisor_bucket);
diff --git a/arch/powerpc/platforms/83xx/Makefile b/arch/powerpc/platforms/83xx/Makefile
index 9d8b28ef334..5c72367441a 100644
--- a/arch/powerpc/platforms/83xx/Makefile
+++ b/arch/powerpc/platforms/83xx/Makefile
@@ -1,4 +1,6 @@
#
# Makefile for the PowerPC 83xx linux kernel.
#
-obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o pci.o
+obj-y := misc.o
+obj-$(CONFIG_PCI) += pci.o
+obj-$(CONFIG_MPC834x_SYS) += mpc834x_sys.o
diff --git a/arch/powerpc/platforms/83xx/misc.c b/arch/powerpc/platforms/83xx/misc.c
new file mode 100644
index 00000000000..1455bcef489
--- /dev/null
+++ b/arch/powerpc/platforms/83xx/misc.c
@@ -0,0 +1,55 @@
+/*
+ * misc setup functions for MPC83xx
+ *
+ * Maintainer: Kumar Gala <galak@kernel.crashing.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+
+#include <asm/io.h>
+#include <asm/hw_irq.h>
+#include <sysdev/fsl_soc.h>
+
+#include "mpc83xx.h"
+
+void mpc83xx_restart(char *cmd)
+{
+#define RST_OFFSET 0x00000900
+#define RST_PROT_REG 0x00000018
+#define RST_CTRL_REG 0x0000001c
+ __be32 __iomem *reg;
+
+ /* map reset register space */
+ reg = ioremap(get_immrbase() + 0x900, 0xff);
+
+ local_irq_disable();
+
+ /* enable software reset "RSTE" */
+ out_be32(reg + (RST_PROT_REG >> 2), 0x52535445);
+
+ /* set software hard reset */
+ out_be32(reg + (RST_CTRL_REG >> 2), 0x2);
+ for (;;) ;
+}
+
+long __init mpc83xx_time_init(void)
+{
+#define SPCR_OFFSET 0x00000110
+#define SPCR_TBEN 0x00400000
+ __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
+ __be32 tmp;
+
+ tmp = in_be32(spcr);
+ out_be32(spcr, tmp | SPCR_TBEN);
+
+ iounmap(spcr);
+
+ return 0;
+}
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.c b/arch/powerpc/platforms/83xx/mpc834x_sys.c
index 2098dd05a77..7c18b4cd5db 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.c
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.c
@@ -24,22 +24,15 @@
#include <linux/delay.h>
#include <linux/seq_file.h>
#include <linux/root_dev.h>
-#include <linux/module.h>
-#include <linux/fsl_devices.h>
#include <asm/system.h>
-#include <asm/pgtable.h>
-#include <asm/page.h>
#include <asm/atomic.h>
#include <asm/time.h>
#include <asm/io.h>
#include <asm/machdep.h>
#include <asm/ipic.h>
#include <asm/bootinfo.h>
-#include <asm/pci-bridge.h>
-#include <asm/mpc83xx.h>
#include <asm/irq.h>
-#include <mm/mmu_decl.h>
#include <asm/prom.h>
#include <asm/udbg.h>
#include <sysdev/fsl_soc.h>
@@ -52,8 +45,6 @@ unsigned long isa_mem_base = 0;
#endif
#ifdef CONFIG_PCI
-extern int mpc83xx_pci2_busno;
-
static int
mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
{
@@ -78,26 +69,14 @@ mpc83xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
const long min_idsel = 0x11, max_idsel = 0x20, irqs_per_slot = 4;
return PCI_IRQ_TABLE_LOOKUP;
}
-
-static int
-mpc83xx_exclude_device(u_char bus, u_char devfn)
-{
- if (bus == 0 && PCI_SLOT(devfn) == 0)
- return PCIBIOS_DEVICE_NOT_FOUND;
- if (mpc83xx_pci2_busno)
- if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0)
- return PCIBIOS_DEVICE_NOT_FOUND;
- return PCIBIOS_SUCCESSFUL;
-}
-#endif /* CONFIG_PCI */
+#endif /* CONFIG_PCI */
/* ************************************************************************
*
* Setup the architecture
*
*/
-static void __init
-mpc834x_sys_setup_arch(void)
+static void __init mpc834x_sys_setup_arch(void)
{
struct device_node *np;
@@ -106,14 +85,14 @@ mpc834x_sys_setup_arch(void)
np = of_find_node_by_type(NULL, "cpu");
if (np != 0) {
- unsigned int *fp = (int *) get_property(np, "clock-frequency", NULL);
+ unsigned int *fp =
+ (int *)get_property(np, "clock-frequency", NULL);
if (fp != 0)
loops_per_jiffy = *fp / HZ;
else
loops_per_jiffy = 50000000 / HZ;
of_node_put(np);
}
-
#ifdef CONFIG_PCI
for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
add_bridge(np);
@@ -124,14 +103,13 @@ mpc834x_sys_setup_arch(void)
#endif
#ifdef CONFIG_ROOT_NFS
- ROOT_DEV = Root_NFS;
+ ROOT_DEV = Root_NFS;
#else
- ROOT_DEV = Root_HDA1;
+ ROOT_DEV = Root_HDA1;
#endif
}
-void __init
-mpc834x_sys_init_IRQ(void)
+void __init mpc834x_sys_init_IRQ(void)
{
u8 senses[8] = {
0, /* EXT 0 */
@@ -160,64 +138,27 @@ mpc834x_sys_init_IRQ(void)
}
#if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
-extern ulong ds1374_get_rtc_time(void);
-extern int ds1374_set_rtc_time(ulong);
+extern ulong ds1374_get_rtc_time(void);
+extern int ds1374_set_rtc_time(ulong);
-static int __init
-mpc834x_rtc_hookup(void)
+static int __init mpc834x_rtc_hookup(void)
{
- struct timespec tv;
+ struct timespec tv;
ppc_md.get_rtc_time = ds1374_get_rtc_time;
ppc_md.set_rtc_time = ds1374_set_rtc_time;
tv.tv_nsec = 0;
- tv.tv_sec = (ppc_md.get_rtc_time)();
+ tv.tv_sec = (ppc_md.get_rtc_time) ();
do_settimeofday(&tv);
return 0;
}
+
late_initcall(mpc834x_rtc_hookup);
#endif
-static void
-mpc83xx_restart(char *cmd)
-{
-#define RST_OFFSET 0x00000900
-#define RST_PROT_REG 0x00000018
-#define RST_CTRL_REG 0x0000001c
- __be32 __iomem *reg;
-
- // map reset register space
- reg = ioremap(get_immrbase() + 0x900, 0xff);
-
- local_irq_disable();
-
- /* enable software reset "RSTE" */
- out_be32(reg + (RST_PROT_REG >> 2), 0x52535445);
-
- /* set software hard reset */
- out_be32(reg + (RST_CTRL_REG >> 2), 0x52535445);
- for(;;);
-}
-
-static long __init
-mpc83xx_time_init(void)
-{
-#define SPCR_OFFSET 0x00000110
-#define SPCR_TBEN 0x00400000
- __be32 __iomem *spcr = ioremap(get_immrbase() + SPCR_OFFSET, 4);
- __be32 tmp;
-
- tmp = in_be32(spcr);
- out_be32(spcr, tmp|SPCR_TBEN);
-
- iounmap(spcr);
-
- return 0;
-}
-void __init
-platform_init(void)
+void __init platform_init(void)
{
/* setup the PowerPC module struct */
ppc_md.setup_arch = mpc834x_sys_setup_arch;
@@ -239,5 +180,3 @@ platform_init(void)
return;
}
-
-
diff --git a/arch/powerpc/platforms/83xx/mpc834x_sys.h b/arch/powerpc/platforms/83xx/mpc834x_sys.h
index e4ca39f6a86..fedecb73f7f 100644
--- a/arch/powerpc/platforms/83xx/mpc834x_sys.h
+++ b/arch/powerpc/platforms/83xx/mpc834x_sys.h
@@ -20,4 +20,4 @@
#define PIRQC MPC83xx_IRQ_EXT6
#define PIRQD MPC83xx_IRQ_EXT7
-#endif /* __MACH_MPC83XX_SYS_H__ */
+#endif /* __MACH_MPC83XX_SYS_H__ */
diff --git a/arch/powerpc/platforms/83xx/mpc83xx.h b/arch/powerpc/platforms/83xx/mpc83xx.h
index ce9e66abef2..01cae106912 100644
--- a/arch/powerpc/platforms/83xx/mpc83xx.h
+++ b/arch/powerpc/platforms/83xx/mpc83xx.h
@@ -10,5 +10,8 @@
*/
extern int add_bridge(struct device_node *dev);
+extern int mpc83xx_exclude_device(u_char bus, u_char devfn);
+extern void mpc83xx_restart(char *cmd);
+extern long mpc83xx_time_init(void);
-#endif /* __MPC83XX_H__ */
+#endif /* __MPC83XX_H__ */
diff --git a/arch/powerpc/platforms/83xx/pci.c b/arch/powerpc/platforms/83xx/pci.c
index 469cdacc5bd..16f7d3b30e1 100644
--- a/arch/powerpc/platforms/83xx/pci.c
+++ b/arch/powerpc/platforms/83xx/pci.c
@@ -36,7 +36,16 @@
int mpc83xx_pci2_busno;
-#ifdef CONFIG_PCI
+int mpc83xx_exclude_device(u_char bus, u_char devfn)
+{
+ if (bus == 0 && PCI_SLOT(devfn) == 0)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ if (mpc83xx_pci2_busno)
+ if (bus == (mpc83xx_pci2_busno) && PCI_SLOT(devfn) == 0)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ return PCIBIOS_SUCCESSFUL;
+}
+
int __init add_bridge(struct device_node *dev)
{
int len;
@@ -52,7 +61,7 @@ int __init add_bridge(struct device_node *dev)
has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
/* Get bus range if any */
- bus_range = (int *) get_property(dev, "bus-range", &len);
+ bus_range = (int *)get_property(dev, "bus-range", &len);
if (bus_range == NULL || len < 2 * sizeof(int)) {
printk(KERN_WARNING "Can't get bus-range for %s, assume"
" bus 0\n", dev->full_name);
@@ -74,7 +83,7 @@ int __init add_bridge(struct device_node *dev)
if ((rsrc.start & 0xfffff) == 0x8500) {
setup_indirect_pci(hose, immr + 0x8300, immr + 0x8304);
}
- /* PCI 2*/
+ /* PCI 2 */
if ((rsrc.start & 0xfffff) == 0x8600) {
setup_indirect_pci(hose, immr + 0x8380, immr + 0x8384);
primary = 0;
@@ -84,10 +93,10 @@ int __init add_bridge(struct device_node *dev)
printk(KERN_INFO "Found MPC83xx PCI host bridge at 0x%08lx. "
"Firmware bus number: %d->%d\n",
- rsrc.start, hose->first_busno, hose->last_busno);
+ rsrc.start, hose->first_busno, hose->last_busno);
DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
- hose, hose->cfg_addr, hose->cfg_data);
+ hose, hose->cfg_addr, hose->cfg_data);
/* Interpret the "ranges" property */
/* This also maps the I/O region and sets isa_io/mem_base */
@@ -95,5 +104,3 @@ int __init add_bridge(struct device_node *dev)
return 0;
}
-
-#endif
diff --git a/arch/powerpc/platforms/85xx/Kconfig b/arch/powerpc/platforms/85xx/Kconfig
index c5bc2821d99..d3d0ff745e8 100644
--- a/arch/powerpc/platforms/85xx/Kconfig
+++ b/arch/powerpc/platforms/85xx/Kconfig
@@ -1,86 +1,30 @@
-config 85xx
- bool
- depends on E500
- default y
-
-config PPC_INDIRECT_PCI_BE
- bool
- depends on 85xx
- default y
-
-menu "Freescale 85xx options"
- depends on E500
+menu "Platform support"
+ depends on PPC_85xx
choice
prompt "Machine Type"
- depends on 85xx
default MPC8540_ADS
config MPC8540_ADS
bool "Freescale MPC8540 ADS"
help
- This option enables support for the MPC 8540 ADS evaluation board.
-
-config MPC8548_CDS
- bool "Freescale MPC8548 CDS"
- help
- This option enablese support for the MPC8548 CDS evaluation board.
-
-config MPC8555_CDS
- bool "Freescale MPC8555 CDS"
- help
- This option enablese support for the MPC8555 CDS evaluation board.
-
-config MPC8560_ADS
- bool "Freescale MPC8560 ADS"
- help
- This option enables support for the MPC 8560 ADS evaluation board.
-
-config SBC8560
- bool "WindRiver PowerQUICC III SBC8560"
- help
- This option enables support for the WindRiver PowerQUICC III
- SBC8560 board.
-
-config STX_GP3
- bool "Silicon Turnkey Express GP3"
- help
- This option enables support for the Silicon Turnkey Express GP3
- board.
+ This option enables support for the MPC 8540 ADS board
endchoice
-# It's often necessary to know the specific 85xx processor type.
-# Fortunately, it is implied (so far) from the board type, so we
-# don't need to ask more redundant questions.
config MPC8540
bool
- depends on MPC8540_ADS
- default y
-
-config MPC8548
- bool
- depends on MPC8548_CDS
- default y
+ select PPC_UDBG_16550
+ select PPC_INDIRECT_PCI
+ default y if MPC8540_ADS
-config MPC8555
- bool
- depends on MPC8555_CDS
- default y
-
-config MPC8560
+config PPC_INDIRECT_PCI_BE
bool
- depends on SBC8560 || MPC8560_ADS || STX_GP3
- default y
-
-config 85xx_PCI2
- bool "Supprt for 2nd PCI host controller"
- depends on MPC8555_CDS
+ depends on PPC_85xx
default y
-config PPC_GEN550
+config MPIC
bool
- depends on MPC8540 || SBC8560 || MPC8555
default y
endmenu
diff --git a/arch/powerpc/platforms/85xx/Makefile b/arch/powerpc/platforms/85xx/Makefile
index 6407197ffd8..ffc4139cb21 100644
--- a/arch/powerpc/platforms/85xx/Makefile
+++ b/arch/powerpc/platforms/85xx/Makefile
@@ -1 +1,5 @@
-# empty makefile so make clean works
+#
+# Makefile for the PowerPC 85xx linux kernel.
+#
+obj-$(CONFIG_PPC_85xx) += misc.o pci.o
+obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o
diff --git a/arch/powerpc/platforms/85xx/misc.c b/arch/powerpc/platforms/85xx/misc.c
new file mode 100644
index 00000000000..26c5e822c7c
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/misc.c
@@ -0,0 +1,31 @@
+/*
+ * MPC85xx generic code.
+ *
+ * Maintained by Kumar Gala (see MAINTAINERS for contact information)
+ *
+ * Copyright 2005 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+#include <linux/irq.h>
+#include <linux/module.h>
+#include <asm/irq.h>
+
+extern void abort(void);
+
+void mpc85xx_restart(char *cmd)
+{
+ local_irq_disable();
+ abort();
+}
+
+/* For now this is a pass through */
+phys_addr_t fixup_bigphys_addr(phys_addr_t addr, phys_addr_t size)
+{
+ return addr;
+};
+
+EXPORT_SYMBOL(fixup_bigphys_addr);
diff --git a/arch/powerpc/platforms/85xx/mpc8540_ads.h b/arch/powerpc/platforms/85xx/mpc8540_ads.h
new file mode 100644
index 00000000000..f770cadb208
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc8540_ads.h
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc/platforms/85xx/mpc8540_ads.h
+ *
+ * MPC8540ADS board definitions
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * Copyright 2004 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+#ifndef __MACH_MPC8540ADS_H__
+#define __MACH_MPC8540ADS_H__
+
+#include <linux/config.h>
+#include <linux/initrd.h>
+
+#define BOARD_CCSRBAR ((uint)0xe0000000)
+#define BCSR_ADDR ((uint)0xf8000000)
+#define BCSR_SIZE ((uint)(32 * 1024))
+
+/* PCI interrupt controller */
+#define PIRQA MPC85xx_IRQ_EXT1
+#define PIRQB MPC85xx_IRQ_EXT2
+#define PIRQC MPC85xx_IRQ_EXT3
+#define PIRQD MPC85xx_IRQ_EXT4
+
+/* Offset of CPM register space */
+#define CPM_MAP_ADDR (CCSRBAR + MPC85xx_CPM_OFFSET)
+
+#endif /* __MACH_MPC8540ADS_H__ */
diff --git a/arch/powerpc/platforms/85xx/mpc85xx.h b/arch/powerpc/platforms/85xx/mpc85xx.h
new file mode 100644
index 00000000000..b44db6268f3
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx.h
@@ -0,0 +1,18 @@
+/*
+ * arch/ppc/platforms/85xx/mpc85xx.h
+ *
+ * MPC85xx soc definitions/function decls
+ *
+ * Maintainer: Kumar Gala <kumar.gala@freescale.com>
+ *
+ * Copyright 2005 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+
+extern void mpc85xx_restart(char *);
+extern int add_bridge(struct device_node *dev);
diff --git a/arch/powerpc/platforms/85xx/mpc85xx_ads.c b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
new file mode 100644
index 00000000000..b7821dbae00
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/mpc85xx_ads.c
@@ -0,0 +1,244 @@
+/*
+ * MPC85xx setup and early boot code plus other random bits.
+ *
+ * Maintained by Kumar Gala (see MAINTAINERS for contact information)
+ *
+ * Copyright 2005 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/kdev_t.h>
+#include <linux/delay.h>
+#include <linux/seq_file.h>
+#include <linux/root_dev.h>
+
+#include <asm/system.h>
+#include <asm/time.h>
+#include <asm/machdep.h>
+#include <asm/pci-bridge.h>
+#include <asm/mpc85xx.h>
+#include <asm/prom.h>
+#include <asm/mpic.h>
+#include <mm/mmu_decl.h>
+#include <asm/udbg.h>
+
+#include <sysdev/fsl_soc.h>
+#include "mpc85xx.h"
+
+#ifndef CONFIG_PCI
+unsigned long isa_io_base = 0;
+unsigned long isa_mem_base = 0;
+#endif
+
+/*
+ * Internal interrupts are all Level Sensitive, and Positive Polarity
+ *
+ * Note: Likely, this table and the following function should be
+ * obtained and derived from the OF Device Tree.
+ */
+static u_char mpc85xx_ads_openpic_initsenses[] __initdata = {
+ MPC85XX_INTERNAL_IRQ_SENSES,
+ 0x0, /* External 0: */
+#if defined(CONFIG_PCI)
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 1: PCI slot 0 */
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 2: PCI slot 1 */
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 3: PCI slot 2 */
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* Ext 4: PCI slot 3 */
+#else
+ 0x0, /* External 1: */
+ 0x0, /* External 2: */
+ 0x0, /* External 3: */
+ 0x0, /* External 4: */
+#endif
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 5: PHY */
+ 0x0, /* External 6: */
+ (IRQ_SENSE_LEVEL | IRQ_POLARITY_NEGATIVE), /* External 7: PHY */
+ 0x0, /* External 8: */
+ 0x0, /* External 9: */
+ 0x0, /* External 10: */
+ 0x0, /* External 11: */
+};
+
+#ifdef CONFIG_PCI
+/*
+ * interrupt routing
+ */
+
+int
+mpc85xx_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
+{
+ static char pci_irq_table[][4] =
+ /*
+ * This is little evil, but works around the fact
+ * that revA boards have IDSEL starting at 18
+ * and others boards (older) start at 12
+ *
+ * PCI IDSEL/INTPIN->INTLINE
+ * A B C D
+ */
+ {
+ {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 2 */
+ {PIRQD, PIRQA, PIRQB, PIRQC},
+ {PIRQC, PIRQD, PIRQA, PIRQB},
+ {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 5 */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 12 */
+ {PIRQD, PIRQA, PIRQB, PIRQC},
+ {PIRQC, PIRQD, PIRQA, PIRQB},
+ {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 15 */
+ {0, 0, 0, 0}, /* -- */
+ {0, 0, 0, 0}, /* -- */
+ {PIRQA, PIRQB, PIRQC, PIRQD}, /* IDSEL 18 */
+ {PIRQD, PIRQA, PIRQB, PIRQC},
+ {PIRQC, PIRQD, PIRQA, PIRQB},
+ {PIRQB, PIRQC, PIRQD, PIRQA}, /* IDSEL 21 */
+ };
+
+ const long min_idsel = 2, max_idsel = 21, irqs_per_slot = 4;
+ return PCI_IRQ_TABLE_LOOKUP;
+}
+
+int
+mpc85xx_exclude_device(u_char bus, u_char devfn)
+{
+ if (bus == 0 && PCI_SLOT(devfn) == 0)
+ return PCIBIOS_DEVICE_NOT_FOUND;
+ else
+ return PCIBIOS_SUCCESSFUL;
+}
+
+#endif /* CONFIG_PCI */
+
+
+void __init mpc85xx_ads_pic_init(void)
+{
+ struct mpic *mpic1;
+ phys_addr_t OpenPIC_PAddr;
+
+ /* Determine the Physical Address of the OpenPIC regs */
+ OpenPIC_PAddr = get_immrbase() + MPC85xx_OPENPIC_OFFSET;
+
+ mpic1 = mpic_alloc(OpenPIC_PAddr,
+ MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,
+ 4, MPC85xx_OPENPIC_IRQ_OFFSET, 0, 250,
+ mpc85xx_ads_openpic_initsenses,
+ sizeof(mpc85xx_ads_openpic_initsenses),
+ " OpenPIC ");
+ BUG_ON(mpic1 == NULL);
+ mpic_assign_isu(mpic1, 0, OpenPIC_PAddr + 0x10200);
+ mpic_assign_isu(mpic1, 1, OpenPIC_PAddr + 0x10280);
+ mpic_assign_isu(mpic1, 2, OpenPIC_PAddr + 0x10300);
+ mpic_assign_isu(mpic1, 3, OpenPIC_PAddr + 0x10380);
+ mpic_assign_isu(mpic1, 4, OpenPIC_PAddr + 0x10400);
+ mpic_assign_isu(mpic1, 5, OpenPIC_PAddr + 0x10480);
+ mpic_assign_isu(mpic1, 6, OpenPIC_PAddr + 0x10500);
+ mpic_assign_isu(mpic1, 7, OpenPIC_PAddr + 0x10580);
+
+ /* dummy mappings to get to 48 */
+ mpic_assign_isu(mpic1, 8, OpenPIC_PAddr + 0x10600);
+ mpic_assign_isu(mpic1, 9, OpenPIC_PAddr + 0x10680);
+ mpic_assign_isu(mpic1, 10, OpenPIC_PAddr + 0x10700);
+ mpic_assign_isu(mpic1, 11, OpenPIC_PAddr + 0x10780);
+
+ /* External ints */
+ mpic_assign_isu(mpic1, 12, OpenPIC_PAddr + 0x10000);
+ mpic_assign_isu(mpic1, 13, OpenPIC_PAddr + 0x10080);
+ mpic_assign_isu(mpic1, 14, OpenPIC_PAddr + 0x10100);
+ mpic_init(mpic1);
+}
+
+/*
+ * Setup the architecture
+ */
+static void __init mpc85xx_ads_setup_arch(void)
+{
+ struct device_node *cpu;
+ struct device_node *np;
+
+ if (ppc_md.progress)
+ ppc_md.progress("mpc85xx_ads_setup_arch()", 0);
+
+ cpu = of_find_node_by_type(NULL, "cpu");
+ if (cpu != 0) {
+ unsigned int *fp;
+
+ fp = (int *)get_property(cpu, "clock-frequency", NULL);
+ if (fp != 0)
+ loops_per_jiffy = *fp / HZ;
+ else
+ loops_per_jiffy = 50000000 / HZ;
+ of_node_put(cpu);
+ }
+
+#ifdef CONFIG_PCI
+ for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
+ add_bridge(np);
+
+ ppc_md.pci_swizzle = common_swizzle;
+ ppc_md.pci_map_irq = mpc85xx_map_irq;
+ ppc_md.pci_exclude_device = mpc85xx_exclude_device;
+#endif
+
+#ifdef CONFIG_ROOT_NFS
+ ROOT_DEV = Root_NFS;
+#else
+ ROOT_DEV = Root_HDA1;
+#endif
+}
+
+void mpc85xx_ads_show_cpuinfo(struct seq_file *m)
+{
+ uint pvid, svid, phid1;
+ uint memsize = total_memory;
+
+ pvid = mfspr(SPRN_PVR);
+ svid = mfspr(SPRN_SVR);
+
+ seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
+ seq_printf(m, "Machine\t\t: mpc85xx\n");
+ seq_printf(m, "PVR\t\t: 0x%x\n", pvid);
+ seq_printf(m, "SVR\t\t: 0x%x\n", svid);
+
+ /* Display cpu Pll setting */
+ phid1 = mfspr(SPRN_HID1);
+ seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));
+
+ /* Display the amount of memory */
+ seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
+}
+
+void __init platform_init(void)
+{
+ ppc_md.setup_arch = mpc85xx_ads_setup_arch;
+ ppc_md.show_cpuinfo = mpc85xx_ads_show_cpuinfo;
+
+ ppc_md.init_IRQ = mpc85xx_ads_pic_init;
+ ppc_md.get_irq = mpic_get_irq;
+
+ ppc_md.restart = mpc85xx_restart;
+ ppc_md.power_off = NULL;
+ ppc_md.halt = NULL;
+
+ ppc_md.time_init = NULL;
+ ppc_md.set_rtc_time = NULL;
+ ppc_md.get_rtc_time = NULL;
+ ppc_md.calibrate_decr = generic_calibrate_decr;
+
+ ppc_md.progress = udbg_progress;
+
+ if (ppc_md.progress)
+ ppc_md.progress("mpc85xx_ads platform_init(): exit", 0);
+}
diff --git a/arch/powerpc/platforms/85xx/pci.c b/arch/powerpc/platforms/85xx/pci.c
new file mode 100644
index 00000000000..bad290110ed
--- /dev/null
+++ b/arch/powerpc/platforms/85xx/pci.c
@@ -0,0 +1,96 @@
+/*
+ * FSL SoC setup code
+ *
+ * Maintained by Kumar Gala (see MAINTAINERS for contact information)
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/config.h>
+#include <linux/stddef.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/errno.h>
+#include <linux/pci.h>
+#include <linux/delay.h>
+#include <linux/irq.h>
+#include <linux/module.h>
+
+#include <asm/system.h>
+#include <asm/atomic.h>
+#include <asm/io.h>
+#include <asm/pci-bridge.h>
+#include <asm/prom.h>
+#include <sysdev/fsl_soc.h>
+
+#undef DEBUG
+
+#ifdef DEBUG
+#define DBG(x...) printk(x)
+#else
+#define DBG(x...)
+#endif
+
+int mpc85xx_pci2_busno = 0;
+
+#ifdef CONFIG_PCI
+int __init add_bridge(struct device_node *dev)
+{
+ int len;
+ struct pci_controller *hose;
+ struct resource rsrc;
+ int *bus_range;
+ int primary = 1, has_address = 0;
+ phys_addr_t immr = get_immrbase();
+
+ DBG("Adding PCI host bridge %s\n", dev->full_name);
+
+ /* Fetch host bridge registers address */
+ has_address = (of_address_to_resource(dev, 0, &rsrc) == 0);
+
+ /* Get bus range if any */
+ bus_range = (int *) get_property(dev, "bus-range", &len);
+ if (bus_range == NULL || len < 2 * sizeof(int)) {
+ printk(KERN_WARNING "Can't get bus-range for %s, assume"
+ " bus 0\n", dev->full_name);
+ }
+
+ hose = pcibios_alloc_controller();
+ if (!hose)
+ return -ENOMEM;
+ hose->arch_data = dev;
+ hose->set_cfg_type = 1;
+
+ hose->first_busno = bus_range ? bus_range[0] : 0;
+ hose->last_busno = bus_range ? bus_range[1] : 0xff;
+
+ /* PCI 1 */
+ if ((rsrc.start & 0xfffff) == 0x8000) {
+ setup_indirect_pci(hose, immr + 0x8000, immr + 0x8004);
+ }
+ /* PCI 2 */
+ if ((rsrc.start & 0xfffff) == 0x9000) {
+ setup_indirect_pci(hose, immr + 0x9000, immr + 0x9004);
+ primary = 0;
+ hose->bus_offset = hose->first_busno;
+ mpc85xx_pci2_busno = hose->first_busno;
+ }
+
+ printk(KERN_INFO "Found MPC85xx PCI host bridge at 0x%08lx. "
+ "Firmware bus number: %d->%d\n",
+ rsrc.start, hose->first_busno, hose->last_busno);
+
+ DBG(" ->Hose at 0x%p, cfg_addr=0x%p,cfg_data=0x%p\n",
+ hose, hose->cfg_addr, hose->cfg_data);
+
+ /* Interpret the "ranges" property */
+ /* This also maps the I/O region and sets isa_io/mem_base */
+ pci_process_bridge_OF_ranges(hose, dev, primary);
+
+ return 0;
+}
+
+#endif
diff --git a/arch/powerpc/platforms/Makefile b/arch/powerpc/platforms/Makefile
index 04073fd987e..c4f6b0d2d14 100644
--- a/arch/powerpc/platforms/Makefile
+++ b/arch/powerpc/platforms/Makefile
@@ -8,7 +8,7 @@ endif
obj-$(CONFIG_PPC_CHRP) += chrp/
obj-$(CONFIG_4xx) += 4xx/
obj-$(CONFIG_PPC_83xx) += 83xx/
-obj-$(CONFIG_85xx) += 85xx/
+obj-$(CONFIG_PPC_85xx) += 85xx/
obj-$(CONFIG_PPC_PSERIES) += pseries/
obj-$(CONFIG_PPC_ISERIES) += iseries/
obj-$(CONFIG_PPC_MAPLE) += maple/
diff --git a/arch/powerpc/platforms/chrp/pegasos_eth.c b/arch/powerpc/platforms/chrp/pegasos_eth.c
index 29c86781c49..6ad4b1a72c9 100644
--- a/arch/powerpc/platforms/chrp/pegasos_eth.c
+++ b/arch/powerpc/platforms/chrp/pegasos_eth.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chrp_pegasos_eth.c
- *
* Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de>
* Thanks to :
* Dale Farnsworth <dale@farnsworth.org>
diff --git a/arch/powerpc/platforms/chrp/setup.c b/arch/powerpc/platforms/chrp/setup.c
index e1fadbf4915..8bf4307e323 100644
--- a/arch/powerpc/platforms/chrp/setup.c
+++ b/arch/powerpc/platforms/chrp/setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/powerpc/platforms/chrp/time.c b/arch/powerpc/platforms/chrp/time.c
index 78df2e7ca88..12c6f689b1a 100644
--- a/arch/powerpc/platforms/chrp/time.c
+++ b/arch/powerpc/platforms/chrp/time.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chrp_time.c
- *
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
*
* Adapted for PowerPC (PReP) by Gary Thomas
diff --git a/arch/powerpc/platforms/iseries/mf.c b/arch/powerpc/platforms/iseries/mf.c
index a41d8b78c0c..d771b8ee857 100644
--- a/arch/powerpc/platforms/iseries/mf.c
+++ b/arch/powerpc/platforms/iseries/mf.c
@@ -46,6 +46,7 @@
#include "setup.h"
extern int piranha_simulator;
+static int mf_initialized;
/*
* This is the structure layout for the Machine Facilites LPAR event
@@ -143,7 +144,8 @@ static spinlock_t pending_event_spinlock;
static struct pending_event *pending_event_head;
static struct pending_event *pending_event_tail;
static struct pending_event *pending_event_avail;
-static struct pending_event pending_event_prealloc[16];
+#define PENDING_EVENT_PREALLOC_LEN 16
+static struct pending_event pending_event_prealloc[PENDING_EVENT_PREALLOC_LEN];
/*
* Put a pending event onto the available queue, so it can get reused.
@@ -597,7 +599,7 @@ void mf_power_off(void)
* Global kernel interface to tell the VSP object in the primary
* partition to reboot this partition.
*/
-void mf_reboot(void)
+void mf_reboot(char *cmd)
{
printk(KERN_INFO "mf.c: Preparing to bounce...\n");
signal_ce_msg_simple(0x4e, NULL);
@@ -625,7 +627,7 @@ void mf_display_src(u32 word)
/*
* Display a single word SRC of the form "PROGXXXX" on the VSP control panel.
*/
-void mf_display_progress(u16 value)
+static __init void mf_display_progress_src(u16 value)
{
u8 ce[12];
u8 src[72];
@@ -649,30 +651,42 @@ void mf_display_progress(u16 value)
* Clear the VSP control panel. Used to "erase" an SRC that was
* previously displayed.
*/
-void mf_clear_src(void)
+static void mf_clear_src(void)
{
signal_ce_msg_simple(0x4b, NULL);
}
+void __init mf_display_progress(u16 value)
+{
+ if (piranha_simulator || !mf_initialized)
+ return;
+
+ if (0xFFFF == value)
+ mf_clear_src();
+ else
+ mf_display_progress_src(value);
+}
+
/*
* Initialization code here.
*/
-void mf_init(void)
+void __init mf_init(void)
{
int i;
- /* initialize */
spin_lock_init(&pending_event_spinlock);
- for (i = 0;
- i < sizeof(pending_event_prealloc) / sizeof(*pending_event_prealloc);
- ++i)
+
+ for (i = 0; i < PENDING_EVENT_PREALLOC_LEN; i++)
free_pending_event(&pending_event_prealloc[i]);
+
HvLpEvent_registerHandler(HvLpEvent_Type_MachineFac, &hv_handler);
/* virtual continue ack */
signal_ce_msg_simple(0x57, NULL);
- /* initialization complete */
+ mf_initialized = 1;
+ mb();
+
printk(KERN_NOTICE "mf.c: iSeries Linux LPAR Machine Facilities "
"initialized\n");
}
@@ -692,6 +706,43 @@ static void get_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
complete(&rtc->com);
}
+static int mf_set_rtc(struct rtc_time *tm)
+{
+ char ce_time[12];
+ u8 day, mon, hour, min, sec, y1, y2;
+ unsigned year;
+
+ year = 1900 + tm->tm_year;
+ y1 = year / 100;
+ y2 = year % 100;
+
+ sec = tm->tm_sec;
+ min = tm->tm_min;
+ hour = tm->tm_hour;
+ day = tm->tm_mday;
+ mon = tm->tm_mon + 1;
+
+ BIN_TO_BCD(sec);
+ BIN_TO_BCD(min);
+ BIN_TO_BCD(hour);
+ BIN_TO_BCD(mon);
+ BIN_TO_BCD(day);
+ BIN_TO_BCD(y1);
+ BIN_TO_BCD(y2);
+
+ memset(ce_time, 0, sizeof(ce_time));
+ ce_time[3] = 0x41;
+ ce_time[4] = y1;
+ ce_time[5] = y2;
+ ce_time[6] = sec;
+ ce_time[7] = min;
+ ce_time[8] = hour;
+ ce_time[10] = day;
+ ce_time[11] = mon;
+
+ return signal_ce_msg(ce_time, NULL);
+}
+
static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
{
tm->tm_wday = 0;
@@ -747,7 +798,7 @@ static int rtc_set_tm(int rc, u8 *ce_msg, struct rtc_time *tm)
return 0;
}
-int mf_get_rtc(struct rtc_time *tm)
+static int mf_get_rtc(struct rtc_time *tm)
{
struct ce_msg_comp_data ce_complete;
struct rtc_time_data rtc_data;
@@ -780,7 +831,7 @@ static void get_boot_rtc_time_complete(void *token, struct ce_msg_data *ce_msg)
rtc->busy = 0;
}
-int mf_get_boot_rtc(struct rtc_time *tm)
+static int mf_get_boot_rtc(struct rtc_time *tm)
{
struct ce_msg_comp_data ce_complete;
struct boot_rtc_time_data rtc_data;
@@ -802,43 +853,6 @@ int mf_get_boot_rtc(struct rtc_time *tm)
return rtc_set_tm(rtc_data.rc, rtc_data.ce_msg.ce_msg, tm);
}
-int mf_set_rtc(struct rtc_time *tm)
-{
- char ce_time[12];
- u8 day, mon, hour, min, sec, y1, y2;
- unsigned year;
-
- year = 1900 + tm->tm_year;
- y1 = year / 100;
- y2 = year % 100;
-
- sec = tm->tm_sec;
- min = tm->tm_min;
- hour = tm->tm_hour;
- day = tm->tm_mday;
- mon = tm->tm_mon + 1;
-
- BIN_TO_BCD(sec);
- BIN_TO_BCD(min);
- BIN_TO_BCD(hour);
- BIN_TO_BCD(mon);
- BIN_TO_BCD(day);
- BIN_TO_BCD(y1);
- BIN_TO_BCD(y2);
-
- memset(ce_time, 0, sizeof(ce_time));
- ce_time[3] = 0x41;
- ce_time[4] = y1;
- ce_time[5] = y2;
- ce_time[6] = sec;
- ce_time[7] = min;
- ce_time[8] = hour;
- ce_time[10] = day;
- ce_time[11] = mon;
-
- return signal_ce_msg(ce_time, NULL);
-}
-
#ifdef CONFIG_PROC_FS
static int proc_mf_dump_cmdline(char *page, char **start, off_t off,
diff --git a/arch/powerpc/platforms/iseries/setup.c b/arch/powerpc/platforms/iseries/setup.c
index 3ecc4a652d8..fa4550611c1 100644
--- a/arch/powerpc/platforms/iseries/setup.c
+++ b/arch/powerpc/platforms/iseries/setup.c
@@ -50,6 +50,7 @@
#include <asm/iseries/hv_call_xm.h>
#include <asm/iseries/it_lp_queue.h>
#include <asm/iseries/mf.h>
+#include <asm/iseries/it_exp_vpd_panel.h>
#include <asm/iseries/hv_lp_event.h>
#include <asm/iseries/lpar_map.h>
#include <asm/udbg.h>
@@ -89,8 +90,6 @@ extern unsigned long embedded_sysmap_end;
extern unsigned long iSeries_recal_tb;
extern unsigned long iSeries_recal_titan;
-static int mf_initialized;
-
static unsigned long cmd_mem_limit;
struct MemoryBlock {
@@ -303,8 +302,6 @@ static void __init iSeries_init_early(void)
{
DBG(" -> iSeries_init_early()\n");
- ppc64_firmware_features = FW_FEATURE_ISERIES;
-
ppc64_interrupt_controller = IC_ISERIES;
#if defined(CONFIG_BLK_DEV_INITRD)
@@ -349,8 +346,6 @@ static void __init iSeries_init_early(void)
HvCallEvent_setLpEventQueueInterruptProc(0, 0);
mf_init();
- mf_initialized = 1;
- mb();
/* If we were passed an initrd, set the ROOT_DEV properly if the values
* look sensible. If not, clear initrd reference.
@@ -560,39 +555,10 @@ static void iSeries_show_cpuinfo(struct seq_file *m)
seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n");
}
-/*
- * Document me.
- */
-static void iSeries_restart(char *cmd)
-{
- mf_reboot();
-}
-
-/*
- * Document me.
- */
-static void iSeries_power_off(void)
-{
- mf_power_off();
-}
-
-/*
- * Document me.
- */
-static void iSeries_halt(void)
-{
- mf_power_off();
-}
-
static void __init iSeries_progress(char * st, unsigned short code)
{
printk("Progress: [%04x] - %s\n", (unsigned)code, st);
- if (!piranha_simulator && mf_initialized) {
- if (code != 0xffff)
- mf_display_progress(code);
- else
- mf_clear_src();
- }
+ mf_display_progress(code);
}
static void __init iSeries_fixup_klimit(void)
@@ -711,7 +677,13 @@ void __init iSeries_init_IRQ(void) { }
static int __init iseries_probe(int platform)
{
- return PLATFORM_ISERIES_LPAR == platform;
+ if (PLATFORM_ISERIES_LPAR != platform)
+ return 0;
+
+ ppc64_firmware_features |= FW_FEATURE_ISERIES;
+ ppc64_firmware_features |= FW_FEATURE_LPAR;
+
+ return 1;
}
struct machdep_calls __initdata iseries_md = {
@@ -721,9 +693,9 @@ struct machdep_calls __initdata iseries_md = {
.get_irq = iSeries_get_irq,
.init_early = iSeries_init_early,
.pcibios_fixup = iSeries_pci_final_fixup,
- .restart = iSeries_restart,
- .power_off = iSeries_power_off,
- .halt = iSeries_halt,
+ .restart = mf_reboot,
+ .power_off = mf_power_off,
+ .halt = mf_power_off,
.get_boot_time = iSeries_get_boot_time,
.set_rtc_time = iSeries_set_rtc_time,
.get_rtc_time = iSeries_get_rtc_time,
@@ -917,6 +889,24 @@ void dt_cpus(struct iseries_flat_dt *dt)
dt_end_node(dt);
}
+void dt_model(struct iseries_flat_dt *dt)
+{
+ char buf[16] = "IBM,";
+
+ /* "IBM," + mfgId[2:3] + systemSerial[1:5] */
+ strne2a(buf + 4, xItExtVpdPanel.mfgID + 2, 2);
+ strne2a(buf + 6, xItExtVpdPanel.systemSerial + 1, 5);
+ buf[11] = '\0';
+ dt_prop_str(dt, "system-id", buf);
+
+ /* "IBM," + machineType[0:4] */
+ strne2a(buf + 4, xItExtVpdPanel.machineType, 4);
+ buf[8] = '\0';
+ dt_prop_str(dt, "model", buf);
+
+ dt_prop_str(dt, "compatible", "IBM,iSeries");
+}
+
void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
{
u64 tmp[2];
@@ -927,6 +917,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
dt_prop_u32(dt, "#address-cells", 2);
dt_prop_u32(dt, "#size-cells", 2);
+ dt_model(dt);
/* /memory */
dt_start_node(dt, "memory@0");
@@ -940,6 +931,7 @@ void build_flat_dt(struct iseries_flat_dt *dt, unsigned long phys_mem_size)
/* /chosen */
dt_start_node(dt, "chosen");
dt_prop_u32(dt, "linux,platform", PLATFORM_ISERIES_LPAR);
+ dt_prop_str(dt, "bootargs", cmd_line);
if (cmd_mem_limit)
dt_prop_u64(dt, "linux,memory-limit", cmd_mem_limit);
dt_end_node(dt);
diff --git a/arch/powerpc/platforms/maple/time.c b/arch/powerpc/platforms/maple/time.c
index 50bc4eb8535..5e6981d1737 100644
--- a/arch/powerpc/platforms/maple/time.c
+++ b/arch/powerpc/platforms/maple/time.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/maple_time.c
- *
* (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org),
* IBM Corp.
*
diff --git a/arch/powerpc/platforms/powermac/cpufreq_32.c b/arch/powerpc/platforms/powermac/cpufreq_32.c
index 56fd4e05fed..cfd6527a0d7 100644
--- a/arch/powerpc/platforms/powermac/cpufreq_32.c
+++ b/arch/powerpc/platforms/powermac/cpufreq_32.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pmac_cpufreq.c
- *
* Copyright (C) 2002 - 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
* Copyright (C) 2004 John Steele Scott <toojays@toojays.net>
*
diff --git a/arch/powerpc/platforms/powermac/feature.c b/arch/powerpc/platforms/powermac/feature.c
index bbe794891a2..e49eddd5042 100644
--- a/arch/powerpc/platforms/powermac/feature.c
+++ b/arch/powerpc/platforms/powermac/feature.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pmac_feature.c
- *
* Copyright (C) 1996-2001 Paul Mackerras (paulus@cs.anu.edu.au)
* Ben. Herrenschmidt (benh@kernel.crashing.org)
*
diff --git a/arch/powerpc/platforms/powermac/nvram.c b/arch/powerpc/platforms/powermac/nvram.c
index 3ebd045a335..5fd28995c74 100644
--- a/arch/powerpc/platforms/powermac/nvram.c
+++ b/arch/powerpc/platforms/powermac/nvram.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pmac_nvram.c
- *
* Copyright (C) 2002 Benjamin Herrenschmidt (benh@kernel.crashing.org)
*
* This program is free software; you can redistribute it and/or
diff --git a/arch/powerpc/platforms/powermac/setup.c b/arch/powerpc/platforms/powermac/setup.c
index 29c2946f1c7..385aab90c4d 100644
--- a/arch/powerpc/platforms/powermac/setup.c
+++ b/arch/powerpc/platforms/powermac/setup.c
@@ -86,11 +86,10 @@ int ppc_override_l2cr = 0;
int ppc_override_l2cr_value;
int has_l2cache = 0;
-int pmac_newworld = 1;
+int pmac_newworld;
static int current_root_goodness = -1;
-extern int pmac_newworld;
extern struct machdep_calls pmac_md;
#define DEFAULT_ROOT_DEVICE Root_SDA1 /* sda1 - slightly silly choice */
@@ -308,9 +307,10 @@ static void __init pmac_setup_arch(void)
for (ic = NULL; (ic = of_find_all_nodes(ic)) != NULL; )
if (get_property(ic, "interrupt-controller", NULL))
break;
- pmac_newworld = (ic != NULL);
- if (ic)
+ if (ic) {
+ pmac_newworld = 1;
of_node_put(ic);
+ }
/* Lookup PCI hosts */
pmac_pci_init();
diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
index 6d64a9bf347..1065d87fc27 100644
--- a/arch/powerpc/platforms/powermac/smp.c
+++ b/arch/powerpc/platforms/powermac/smp.c
@@ -191,9 +191,7 @@ static void smp_psurge_message_pass(int target, int msg)
if (num_online_cpus() < 2)
return;
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_online(i))
- continue;
+ for_each_online_cpu(i) {
if (target == MSG_ALL
|| (target == MSG_ALL_BUT_SELF && i != smp_processor_id())
|| target == i) {
diff --git a/arch/powerpc/platforms/pseries/Makefile b/arch/powerpc/platforms/pseries/Makefile
index 61616d14407..930898635c9 100644
--- a/arch/powerpc/platforms/pseries/Makefile
+++ b/arch/powerpc/platforms/pseries/Makefile
@@ -1,5 +1,6 @@
obj-y := pci.o lpar.o hvCall.o nvram.o reconfig.o \
- setup.o iommu.o ras.o rtasd.o pci_dlpar.o
+ setup.o iommu.o ras.o rtasd.o pci_dlpar.o \
+ firmware.o
obj-$(CONFIG_SMP) += smp.o
obj-$(CONFIG_IBMVIO) += vio.o
obj-$(CONFIG_XICS) += xics.o
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
new file mode 100644
index 00000000000..989f4bc136c
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -0,0 +1,103 @@
+/*
+ * pSeries firmware setup code.
+ *
+ * Portions from arch/powerpc/platforms/pseries/setup.c:
+ * Copyright (C) 1995 Linus Torvalds
+ * Adapted from 'alpha' version by Gary Thomas
+ * Modified by Cort Dougan (cort@cs.nmt.edu)
+ * Modified by PPC64 Team, IBM Corp
+ *
+ * Portions from arch/powerpc/kernel/firmware.c
+ * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
+ * Modifications for ppc64:
+ * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
+ * Copyright (C) 2005 Stephen Rothwell, IBM Corporation
+ *
+ * Copyright 2006 IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#undef DEBUG
+
+#include <asm/firmware.h>
+#include <asm/prom.h>
+
+#ifdef DEBUG
+#define DBG(fmt...) udbg_printf(fmt)
+#else
+#define DBG(fmt...)
+#endif
+
+typedef struct {
+ unsigned long val;
+ char * name;
+} firmware_feature_t;
+
+static __initdata firmware_feature_t
+firmware_features_table[FIRMWARE_MAX_FEATURES] = {
+ {FW_FEATURE_PFT, "hcall-pft"},
+ {FW_FEATURE_TCE, "hcall-tce"},
+ {FW_FEATURE_SPRG0, "hcall-sprg0"},
+ {FW_FEATURE_DABR, "hcall-dabr"},
+ {FW_FEATURE_COPY, "hcall-copy"},
+ {FW_FEATURE_ASR, "hcall-asr"},
+ {FW_FEATURE_DEBUG, "hcall-debug"},
+ {FW_FEATURE_PERF, "hcall-perf"},
+ {FW_FEATURE_DUMP, "hcall-dump"},
+ {FW_FEATURE_INTERRUPT, "hcall-interrupt"},
+ {FW_FEATURE_MIGRATE, "hcall-migrate"},
+ {FW_FEATURE_PERFMON, "hcall-perfmon"},
+ {FW_FEATURE_CRQ, "hcall-crq"},
+ {FW_FEATURE_VIO, "hcall-vio"},
+ {FW_FEATURE_RDMA, "hcall-rdma"},
+ {FW_FEATURE_LLAN, "hcall-lLAN"},
+ {FW_FEATURE_BULK, "hcall-bulk"},
+ {FW_FEATURE_XDABR, "hcall-xdabr"},
+ {FW_FEATURE_MULTITCE, "hcall-multi-tce"},
+ {FW_FEATURE_SPLPAR, "hcall-splpar"},
+};
+
+/* Build up the firmware features bitmask using the contents of
+ * device-tree/ibm,hypertas-functions. Ultimately this functionality may
+ * be moved into prom.c prom_init().
+ */
+void __init fw_feature_init(void)
+{
+ struct device_node *dn;
+ char *hypertas, *s;
+ int len, i;
+
+ DBG(" -> fw_feature_init()\n");
+
+ dn = of_find_node_by_path("/rtas");
+ if (dn == NULL) {
+ printk(KERN_ERR "WARNING! Cannot find RTAS in device-tree!\n");
+ goto out;
+ }
+
+ hypertas = get_property(dn, "ibm,hypertas-functions", &len);
+ if (hypertas == NULL)
+ goto out;
+
+ for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
+ for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) {
+ /* check value against table of strings */
+ if (!firmware_features_table[i].name ||
+ strcmp(firmware_features_table[i].name, s))
+ continue;
+
+ /* we have a match */
+ ppc64_firmware_features |=
+ firmware_features_table[i].val;
+ break;
+ }
+ }
+
+out:
+ of_node_put(dn);
+ DBG(" <- fw_feature_init()\n");
+}
diff --git a/arch/powerpc/platforms/pseries/firmware.h b/arch/powerpc/platforms/pseries/firmware.h
new file mode 100644
index 00000000000..714f56f5536
--- /dev/null
+++ b/arch/powerpc/platforms/pseries/firmware.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2006 IBM Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef _PSERIES_FIRMWARE_H
+#define _PSERIES_FIRMWARE_H
+
+#include <asm/firmware.h>
+
+extern void __init fw_feature_init(void);
+
+#endif /* _PSERIES_FIRMWARE_H */
diff --git a/arch/powerpc/platforms/pseries/hvCall.S b/arch/powerpc/platforms/pseries/hvCall.S
index 176e8da7646..db7c19fe929 100644
--- a/arch/powerpc/platforms/pseries/hvCall.S
+++ b/arch/powerpc/platforms/pseries/hvCall.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/pSeries_hvCall.S
- *
* This file contains the generic code to perform a call to the
* pSeries LPAR hypervisor.
* NOTE: this file will go away when we move to inline this work.
diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c
index 48cfbfc43f9..2643078433f 100644
--- a/arch/powerpc/platforms/pseries/iommu.c
+++ b/arch/powerpc/platforms/pseries/iommu.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/pSeries_iommu.c
- *
* Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
*
* Rewrite, cleanup:
@@ -582,7 +580,7 @@ void iommu_init_early_pSeries(void)
return;
}
- if (platform_is_lpar()) {
+ if (firmware_has_feature(FW_FEATURE_LPAR)) {
if (firmware_has_feature(FW_FEATURE_MULTITCE)) {
ppc_md.tce_build = tce_buildmulti_pSeriesLP;
ppc_md.tce_free = tce_freemulti_pSeriesLP;
diff --git a/arch/powerpc/platforms/pseries/pci.c b/arch/powerpc/platforms/pseries/pci.c
index 999a9620b5c..946ad59e335 100644
--- a/arch/powerpc/platforms/pseries/pci.c
+++ b/arch/powerpc/platforms/pseries/pci.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc64/kernel/pSeries_pci.c
- *
* Copyright (C) 2001 Dave Engebretsen, IBM Corporation
* Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
*
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 9edeca83f43..44d5c7fdcd9 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -60,7 +60,6 @@
#include <asm/time.h>
#include <asm/nvram.h>
#include "xics.h"
-#include <asm/firmware.h>
#include <asm/pmc.h>
#include <asm/mpic.h>
#include <asm/ppc-pci.h>
@@ -70,6 +69,7 @@
#include "plpar_wrappers.h"
#include "ras.h"
+#include "firmware.h"
#ifdef DEBUG
#define DBG(fmt...) udbg_printf(fmt)
@@ -246,7 +246,7 @@ static void __init pSeries_setup_arch(void)
ppc_md.idle_loop = default_idle;
}
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
ppc_md.enable_pmcs = pseries_lpar_enable_pmcs;
else
ppc_md.enable_pmcs = power4_enable_pmcs;
@@ -262,53 +262,6 @@ static int __init pSeries_init_panel(void)
}
arch_initcall(pSeries_init_panel);
-
-/* Build up the ppc64_firmware_features bitmask field
- * using contents of device-tree/ibm,hypertas-functions.
- * Ultimately this functionality may be moved into prom.c prom_init().
- */
-static void __init fw_feature_init(void)
-{
- struct device_node * dn;
- char * hypertas;
- unsigned int len;
-
- DBG(" -> fw_feature_init()\n");
-
- ppc64_firmware_features = 0;
- dn = of_find_node_by_path("/rtas");
- if (dn == NULL) {
- printk(KERN_ERR "WARNING ! Cannot find RTAS in device-tree !\n");
- goto no_rtas;
- }
-
- hypertas = get_property(dn, "ibm,hypertas-functions", &len);
- if (hypertas) {
- while (len > 0){
- int i, hypertas_len;
- /* check value against table of strings */
- for(i=0; i < FIRMWARE_MAX_FEATURES ;i++) {
- if ((firmware_features_table[i].name) &&
- (strcmp(firmware_features_table[i].name,hypertas))==0) {
- /* we have a match */
- ppc64_firmware_features |=
- (firmware_features_table[i].val);
- break;
- }
- }
- hypertas_len = strlen(hypertas);
- len -= hypertas_len +1;
- hypertas+= hypertas_len +1;
- }
- }
-
- of_node_put(dn);
-no_rtas:
-
- DBG(" <- fw_feature_init()\n");
-}
-
-
static void __init pSeries_discover_pic(void)
{
struct device_node *np;
@@ -367,21 +320,16 @@ static int pseries_set_xdabr(unsigned long dabr)
*/
static void __init pSeries_init_early(void)
{
- int iommu_off = 0;
-
DBG(" -> pSeries_init_early()\n");
fw_feature_init();
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
hpte_init_lpar();
- else {
+ else
hpte_init_native();
- iommu_off = (of_chosen &&
- get_property(of_chosen, "linux,iommu-off", NULL));
- }
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
find_udbg_vterm();
if (firmware_has_feature(FW_FEATURE_DABR))
@@ -437,6 +385,9 @@ static int __init pSeries_probe(int platform)
* it here ...
*/
+ if (platform == PLATFORM_PSERIES_LPAR)
+ ppc64_firmware_features |= FW_FEATURE_LPAR;
+
return 1;
}
@@ -576,7 +527,7 @@ static void pseries_shared_idle(void)
static int pSeries_pci_probe_mode(struct pci_bus *bus)
{
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
return PCI_PROBE_DEVTREE;
return PCI_PROBE_NORMAL;
}
diff --git a/arch/powerpc/platforms/pseries/smp.c b/arch/powerpc/platforms/pseries/smp.c
index 8d710af5075..3cf78a6cd27 100644
--- a/arch/powerpc/platforms/pseries/smp.c
+++ b/arch/powerpc/platforms/pseries/smp.c
@@ -443,7 +443,7 @@ void __init smp_init_pSeries(void)
smp_ops->cpu_die = pSeries_cpu_die;
/* Processors can be added/removed only on LPAR */
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
pSeries_reconfig_notifier_register(&pSeries_smp_nb);
#endif
diff --git a/arch/powerpc/platforms/pseries/xics.c b/arch/powerpc/platforms/pseries/xics.c
index fd823c7c9ac..eb86cdb9b80 100644
--- a/arch/powerpc/platforms/pseries/xics.c
+++ b/arch/powerpc/platforms/pseries/xics.c
@@ -20,6 +20,7 @@
#include <linux/gfp.h>
#include <linux/radix-tree.h>
#include <linux/cpu.h>
+#include <asm/firmware.h>
#include <asm/prom.h>
#include <asm/io.h>
#include <asm/pgtable.h>
@@ -536,7 +537,7 @@ nextnode:
of_node_put(np);
}
- if (platform_is_lpar())
+ if (firmware_has_feature(FW_FEATURE_LPAR))
ops = &pSeriesLP_ops;
else {
#ifdef CONFIG_SMP
diff --git a/arch/powerpc/sysdev/dart_iommu.c b/arch/powerpc/sysdev/dart_iommu.c
index 6298264efe3..61d31742861 100644
--- a/arch/powerpc/sysdev/dart_iommu.c
+++ b/arch/powerpc/sysdev/dart_iommu.c
@@ -194,8 +194,6 @@ static int dart_init(struct device_node *dart_node)
* prefetching into invalid pages and corrupting data
*/
tmp = lmb_alloc(DART_PAGE_SIZE, DART_PAGE_SIZE);
- if (!tmp)
- panic("DART: Cannot allocate spare page!");
dart_emptyval = DARTMAP_VALID | ((tmp >> DART_PAGE_SHIFT) &
DARTMAP_RPNMASK);
diff --git a/arch/powerpc/sysdev/dcr.S b/arch/powerpc/sysdev/dcr.S
index 895f10243a4..2078f39e2f1 100644
--- a/arch/powerpc/sysdev/dcr.S
+++ b/arch/powerpc/sysdev/dcr.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/dcr.S
- *
* "Indirect" DCR access
*
* Copyright (c) 2004 Eugene Surovegin <ebs@ebshome.net>
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 064c9de4773..ceb584682fa 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -40,7 +40,7 @@ phys_addr_t get_immrbase(void)
return immrbase;
soc = of_find_node_by_type(NULL, "soc");
- if (soc != 0) {
+ if (soc) {
unsigned int size;
void *prop = get_property(soc, "reg", &size);
immrbase = of_translate_address(soc, prop);
@@ -49,21 +49,20 @@ phys_addr_t get_immrbase(void)
return immrbase;
}
-EXPORT_SYMBOL(get_immrbase);
-static const char * gfar_tx_intr = "tx";
-static const char * gfar_rx_intr = "rx";
-static const char * gfar_err_intr = "error";
+EXPORT_SYMBOL(get_immrbase);
-static int __init gfar_of_init(void)
+static int __init gfar_mdio_of_init(void)
{
struct device_node *np;
unsigned int i;
- struct platform_device *mdio_dev, *gfar_dev;
+ struct platform_device *mdio_dev;
struct resource res;
int ret;
- for (np = NULL, i = 0; (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL; i++) {
+ for (np = NULL, i = 0;
+ (np = of_find_compatible_node(np, "mdio", "gianfar")) != NULL;
+ i++) {
int k;
struct device_node *child = NULL;
struct gianfar_mdio_data mdio_data;
@@ -73,12 +72,14 @@ static int __init gfar_of_init(void)
ret = of_address_to_resource(np, 0, &res);
if (ret)
- goto mdio_err;
+ goto err;
- mdio_dev = platform_device_register_simple("fsl-gianfar_mdio", res.start, &res, 1);
+ mdio_dev =
+ platform_device_register_simple("fsl-gianfar_mdio",
+ res.start, &res, 1);
if (IS_ERR(mdio_dev)) {
ret = PTR_ERR(mdio_dev);
- goto mdio_err;
+ goto err;
}
for (k = 0; k < 32; k++)
@@ -86,17 +87,44 @@ static int __init gfar_of_init(void)
while ((child = of_get_next_child(np, child)) != NULL) {
if (child->n_intrs) {
- u32 *id = (u32 *) get_property(child, "reg", NULL);
+ u32 *id =
+ (u32 *) get_property(child, "reg", NULL);
mdio_data.irq[*id] = child->intrs[0].line;
}
}
- ret = platform_device_add_data(mdio_dev, &mdio_data, sizeof(struct gianfar_mdio_data));
+ ret =
+ platform_device_add_data(mdio_dev, &mdio_data,
+ sizeof(struct gianfar_mdio_data));
if (ret)
- goto mdio_unreg;
+ goto unreg;
}
- for (np = NULL, i = 0; (np = of_find_compatible_node(np, "network", "gianfar")) != NULL; i++) {
+ return 0;
+
+unreg:
+ platform_device_unregister(mdio_dev);
+err:
+ return ret;
+}
+
+arch_initcall(gfar_mdio_of_init);
+
+static const char *gfar_tx_intr = "tx";
+static const char *gfar_rx_intr = "rx";
+static const char *gfar_err_intr = "error";
+
+static int __init gfar_of_init(void)
+{
+ struct device_node *np;
+ unsigned int i;
+ struct platform_device *gfar_dev;
+ struct resource res;
+ int ret;
+
+ for (np = NULL, i = 0;
+ (np = of_find_compatible_node(np, "network", "gianfar")) != NULL;
+ i++) {
struct resource r[4];
struct device_node *phy, *mdio;
struct gianfar_platform_data gfar_data;
@@ -110,7 +138,7 @@ static int __init gfar_of_init(void)
ret = of_address_to_resource(np, 0, &r[0]);
if (ret)
- goto gfar_err;
+ goto err;
r[1].start = np->intrs[0].line;
r[1].end = np->intrs[0].line;
@@ -133,11 +161,13 @@ static int __init gfar_of_init(void)
r[3].flags = IORESOURCE_IRQ;
}
- gfar_dev = platform_device_register_simple("fsl-gianfar", i, &r[0], np->n_intrs + 1);
+ gfar_dev =
+ platform_device_register_simple("fsl-gianfar", i, &r[0],
+ np->n_intrs + 1);
if (IS_ERR(gfar_dev)) {
ret = PTR_ERR(gfar_dev);
- goto gfar_err;
+ goto err;
}
mac_addr = get_property(np, "address", NULL);
@@ -145,26 +175,26 @@ static int __init gfar_of_init(void)
if (model && !strcasecmp(model, "TSEC"))
gfar_data.device_flags =
- FSL_GIANFAR_DEV_HAS_GIGABIT |
- FSL_GIANFAR_DEV_HAS_COALESCE |
- FSL_GIANFAR_DEV_HAS_RMON |
- FSL_GIANFAR_DEV_HAS_MULTI_INTR;
+ FSL_GIANFAR_DEV_HAS_GIGABIT |
+ FSL_GIANFAR_DEV_HAS_COALESCE |
+ FSL_GIANFAR_DEV_HAS_RMON |
+ FSL_GIANFAR_DEV_HAS_MULTI_INTR;
if (model && !strcasecmp(model, "eTSEC"))
gfar_data.device_flags =
- FSL_GIANFAR_DEV_HAS_GIGABIT |
- FSL_GIANFAR_DEV_HAS_COALESCE |
- FSL_GIANFAR_DEV_HAS_RMON |
- FSL_GIANFAR_DEV_HAS_MULTI_INTR |
- FSL_GIANFAR_DEV_HAS_CSUM |
- FSL_GIANFAR_DEV_HAS_VLAN |
- FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
+ FSL_GIANFAR_DEV_HAS_GIGABIT |
+ FSL_GIANFAR_DEV_HAS_COALESCE |
+ FSL_GIANFAR_DEV_HAS_RMON |
+ FSL_GIANFAR_DEV_HAS_MULTI_INTR |
+ FSL_GIANFAR_DEV_HAS_CSUM |
+ FSL_GIANFAR_DEV_HAS_VLAN |
+ FSL_GIANFAR_DEV_HAS_EXTENDED_HASH;
ph = (phandle *) get_property(np, "phy-handle", NULL);
phy = of_find_node_by_phandle(*ph);
if (phy == NULL) {
ret = -ENODEV;
- goto gfar_unreg;
+ goto unreg;
}
mdio = of_get_parent(phy);
@@ -174,7 +204,7 @@ static int __init gfar_of_init(void)
if (ret) {
of_node_put(phy);
of_node_put(mdio);
- goto gfar_unreg;
+ goto unreg;
}
gfar_data.phy_id = *id;
@@ -183,23 +213,22 @@ static int __init gfar_of_init(void)
of_node_put(phy);
of_node_put(mdio);
- ret = platform_device_add_data(gfar_dev, &gfar_data, sizeof(struct gianfar_platform_data));
+ ret =
+ platform_device_add_data(gfar_dev, &gfar_data,
+ sizeof(struct
+ gianfar_platform_data));
if (ret)
- goto gfar_unreg;
+ goto unreg;
}
return 0;
-mdio_unreg:
- platform_device_unregister(mdio_dev);
-mdio_err:
- return ret;
-
-gfar_unreg:
+unreg:
platform_device_unregister(gfar_dev);
-gfar_err:
+err:
return ret;
}
+
arch_initcall(gfar_of_init);
static int __init fsl_i2c_of_init(void)
@@ -209,17 +238,19 @@ static int __init fsl_i2c_of_init(void)
struct platform_device *i2c_dev;
int ret;
- for (np = NULL, i = 0; (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL; i++) {
+ for (np = NULL, i = 0;
+ (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
+ i++) {
struct resource r[2];
struct fsl_i2c_platform_data i2c_data;
- unsigned char * flags = NULL;
+ unsigned char *flags = NULL;
memset(&r, 0, sizeof(r));
memset(&i2c_data, 0, sizeof(i2c_data));
ret = of_address_to_resource(np, 0, &r[0]);
if (ret)
- goto i2c_err;
+ goto err;
r[1].start = np->intrs[0].line;
r[1].end = np->intrs[0].line;
@@ -228,7 +259,7 @@ static int __init fsl_i2c_of_init(void)
i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
if (IS_ERR(i2c_dev)) {
ret = PTR_ERR(i2c_dev);
- goto i2c_err;
+ goto err;
}
i2c_data.device_flags = 0;
@@ -240,18 +271,22 @@ static int __init fsl_i2c_of_init(void)
if (flags)
i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
- ret = platform_device_add_data(i2c_dev, &i2c_data, sizeof(struct fsl_i2c_platform_data));
+ ret =
+ platform_device_add_data(i2c_dev, &i2c_data,
+ sizeof(struct
+ fsl_i2c_platform_data));
if (ret)
- goto i2c_unreg;
+ goto unreg;
}
return 0;
-i2c_unreg:
+unreg:
platform_device_unregister(i2c_dev);
-i2c_err:
+err:
return ret;
}
+
arch_initcall(fsl_i2c_of_init);
#ifdef CONFIG_PPC_83xx
@@ -267,51 +302,192 @@ static int __init mpc83xx_wdt_init(void)
if (!np) {
ret = -ENODEV;
- goto mpc83xx_wdt_nodev;
+ goto nodev;
}
soc = of_find_node_by_type(NULL, "soc");
if (!soc) {
ret = -ENODEV;
- goto mpc83xx_wdt_nosoc;
+ goto nosoc;
}
freq = (unsigned int *)get_property(soc, "bus-frequency", NULL);
if (!freq) {
ret = -ENODEV;
- goto mpc83xx_wdt_err;
+ goto err;
}
memset(&r, 0, sizeof(r));
ret = of_address_to_resource(np, 0, &r);
if (ret)
- goto mpc83xx_wdt_err;
+ goto err;
dev = platform_device_register_simple("mpc83xx_wdt", 0, &r, 1);
if (IS_ERR(dev)) {
ret = PTR_ERR(dev);
- goto mpc83xx_wdt_err;
+ goto err;
}
ret = platform_device_add_data(dev, freq, sizeof(int));
if (ret)
- goto mpc83xx_wdt_unreg;
+ goto unreg;
of_node_put(soc);
of_node_put(np);
return 0;
-mpc83xx_wdt_unreg:
+unreg:
platform_device_unregister(dev);
-mpc83xx_wdt_err:
+err:
of_node_put(soc);
-mpc83xx_wdt_nosoc:
+nosoc:
of_node_put(np);
-mpc83xx_wdt_nodev:
+nodev:
return ret;
}
+
arch_initcall(mpc83xx_wdt_init);
#endif
+
+static enum fsl_usb2_phy_modes determine_usb_phy(char * phy_type)
+{
+ if (!phy_type)
+ return FSL_USB2_PHY_NONE;
+ if (!strcasecmp(phy_type, "ulpi"))
+ return FSL_USB2_PHY_ULPI;
+ if (!strcasecmp(phy_type, "utmi"))
+ return FSL_USB2_PHY_UTMI;
+ if (!strcasecmp(phy_type, "utmi_wide"))
+ return FSL_USB2_PHY_UTMI_WIDE;
+ if (!strcasecmp(phy_type, "serial"))
+ return FSL_USB2_PHY_SERIAL;
+
+ return FSL_USB2_PHY_NONE;
+}
+
+static int __init fsl_usb_of_init(void)
+{
+ struct device_node *np;
+ unsigned int i;
+ struct platform_device *usb_dev;
+ int ret;
+
+ for (np = NULL, i = 0;
+ (np = of_find_compatible_node(np, "usb", "fsl-usb2-mph")) != NULL;
+ i++) {
+ struct resource r[2];
+ struct fsl_usb2_platform_data usb_data;
+ unsigned char *prop = NULL;
+
+ memset(&r, 0, sizeof(r));
+ memset(&usb_data, 0, sizeof(usb_data));
+
+ ret = of_address_to_resource(np, 0, &r[0]);
+ if (ret)
+ goto err;
+
+ r[1].start = np->intrs[0].line;
+ r[1].end = np->intrs[0].line;
+ r[1].flags = IORESOURCE_IRQ;
+
+ usb_dev =
+ platform_device_register_simple("fsl-usb2-mph", i, r, 2);
+ if (IS_ERR(usb_dev)) {
+ ret = PTR_ERR(usb_dev);
+ goto err;
+ }
+
+ usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
+ usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
+
+ usb_data.operating_mode = FSL_USB2_MPH_HOST;
+
+ prop = get_property(np, "port0", NULL);
+ if (prop)
+ usb_data.port_enables |= FSL_USB2_PORT0_ENABLED;
+
+ prop = get_property(np, "port1", NULL);
+ if (prop)
+ usb_data.port_enables |= FSL_USB2_PORT1_ENABLED;
+
+ prop = get_property(np, "phy_type", NULL);
+ usb_data.phy_mode = determine_usb_phy(prop);
+
+ ret =
+ platform_device_add_data(usb_dev, &usb_data,
+ sizeof(struct
+ fsl_usb2_platform_data));
+ if (ret)
+ goto unreg;
+ }
+
+ return 0;
+
+unreg:
+ platform_device_unregister(usb_dev);
+err:
+ return ret;
+}
+
+arch_initcall(fsl_usb_of_init);
+
+static int __init fsl_usb_dr_of_init(void)
+{
+ struct device_node *np;
+ unsigned int i;
+ struct platform_device *usb_dev;
+ int ret;
+
+ for (np = NULL, i = 0;
+ (np = of_find_compatible_node(np, "usb", "fsl-usb2-dr")) != NULL;
+ i++) {
+ struct resource r[2];
+ struct fsl_usb2_platform_data usb_data;
+ unsigned char *prop = NULL;
+
+ memset(&r, 0, sizeof(r));
+ memset(&usb_data, 0, sizeof(usb_data));
+
+ ret = of_address_to_resource(np, 0, &r[0]);
+ if (ret)
+ goto err;
+
+ r[1].start = np->intrs[0].line;
+ r[1].end = np->intrs[0].line;
+ r[1].flags = IORESOURCE_IRQ;
+
+ usb_dev =
+ platform_device_register_simple("fsl-usb2-dr", i, r, 2);
+ if (IS_ERR(usb_dev)) {
+ ret = PTR_ERR(usb_dev);
+ goto err;
+ }
+
+ usb_dev->dev.coherent_dma_mask = 0xffffffffUL;
+ usb_dev->dev.dma_mask = &usb_dev->dev.coherent_dma_mask;
+
+ usb_data.operating_mode = FSL_USB2_DR_HOST;
+
+ prop = get_property(np, "phy_type", NULL);
+ usb_data.phy_mode = determine_usb_phy(prop);
+
+ ret =
+ platform_device_add_data(usb_dev, &usb_data,
+ sizeof(struct
+ fsl_usb2_platform_data));
+ if (ret)
+ goto unreg;
+ }
+
+ return 0;
+
+unreg:
+ platform_device_unregister(usb_dev);
+err:
+ return ret;
+}
+
+arch_initcall(fsl_usb_dr_of_init);
diff --git a/arch/powerpc/sysdev/ipic.h b/arch/powerpc/sysdev/ipic.h
index a7ce7da8785..a60c9d18bb7 100644
--- a/arch/powerpc/sysdev/ipic.h
+++ b/arch/powerpc/sysdev/ipic.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ipic.h
- *
* IPIC private definitions and structure.
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 7d02fa2a899..4735b41c113 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -191,6 +191,7 @@ Commands:\n\
di dump instructions\n\
df dump float values\n\
dd dump double values\n\
+ dr dump stream of raw bytes\n\
e print exception information\n\
f flush cache\n\
la lookup symbol+offset of specified address\n\
@@ -1938,6 +1939,28 @@ bsesc(void)
return c;
}
+static void xmon_rawdump (unsigned long adrs, long ndump)
+{
+ long n, m, r, nr;
+ unsigned char temp[16];
+
+ for (n = ndump; n > 0;) {
+ r = n < 16? n: 16;
+ nr = mread(adrs, temp, r);
+ adrs += nr;
+ for (m = 0; m < r; ++m) {
+ if (m < nr)
+ printf("%.2x", temp[m]);
+ else
+ printf("%s", fault_chars[fault_type]);
+ }
+ n -= r;
+ if (nr < r)
+ break;
+ }
+ printf("\n");
+}
+
#define isxdigit(c) (('0' <= (c) && (c) <= '9') \
|| ('a' <= (c) && (c) <= 'f') \
|| ('A' <= (c) && (c) <= 'F'))
@@ -1960,6 +1983,13 @@ dump(void)
nidump = MAX_DUMP;
adrs += ppc_inst_dump(adrs, nidump, 1);
last_cmd = "di\n";
+ } else if (c == 'r') {
+ scanhex(&ndump);
+ if (ndump == 0)
+ ndump = 64;
+ xmon_rawdump(adrs, ndump);
+ adrs += ndump;
+ last_cmd = "dr\n";
} else {
scanhex(&ndump);
if (ndump == 0)
diff --git a/arch/ppc/4xx_io/serial_sicc.c b/arch/ppc/4xx_io/serial_sicc.c
index 8ace2a1f3b4..98b25fa0049 100644
--- a/arch/ppc/4xx_io/serial_sicc.c
+++ b/arch/ppc/4xx_io/serial_sicc.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/4xx_io/serial_sicc.c
- *
* Driver for IBM STB3xxx SICC serial port
*
* Based on drivers/char/serial_amba.c, by ARM Ltd.
@@ -1639,9 +1637,8 @@ static struct SICC_info *siccuart_get(int line)
state->count++;
if (state->info)
return state->info;
- info = kmalloc(sizeof(struct SICC_info), GFP_KERNEL);
+ info = kzalloc(sizeof(struct SICC_info), GFP_KERNEL);
if (info) {
- memset(info, 0, sizeof(struct SICC_info));
init_waitqueue_head(&info->open_wait);
init_waitqueue_head(&info->close_wait);
init_waitqueue_head(&info->delta_msr_wait);
diff --git a/arch/ppc/8xx_io/commproc.c b/arch/ppc/8xx_io/commproc.c
index 579cd40258b..12b84ca5132 100644
--- a/arch/ppc/8xx_io/commproc.c
+++ b/arch/ppc/8xx_io/commproc.c
@@ -73,7 +73,7 @@ cpm_mask_irq(unsigned int irq)
{
int cpm_vec = irq - CPM_IRQ_OFFSET;
- out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr) & ~(1 << cpm_vec));
+ clrbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, (1 << cpm_vec));
}
static void
@@ -81,7 +81,7 @@ cpm_unmask_irq(unsigned int irq)
{
int cpm_vec = irq - CPM_IRQ_OFFSET;
- out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr) | (1 << cpm_vec));
+ setbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cimr, (1 << cpm_vec));
}
static void
@@ -198,7 +198,7 @@ cpm_interrupt_init(void)
if (setup_irq(CPM_IRQ_OFFSET + CPMVEC_ERROR, &cpm_error_irqaction))
panic("Could not allocate CPM error IRQ!");
- out_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr, in_be32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr) | CICR_IEN);
+ setbits32(&((immap_t *)IMAP_ADDR)->im_cpic.cpic_cicr, CICR_IEN);
}
/*
diff --git a/arch/ppc/8xx_io/cs4218_tdm.c b/arch/ppc/8xx_io/cs4218_tdm.c
index 49eb2a7e65c..a892356d5c3 100644
--- a/arch/ppc/8xx_io/cs4218_tdm.c
+++ b/arch/ppc/8xx_io/cs4218_tdm.c
@@ -126,11 +126,11 @@ static int numReadBufs = 4, readbufSize = 32;
*/
static volatile cbd_t *rx_base, *rx_cur, *tx_base, *tx_cur;
-MODULE_PARM(catchRadius, "i");
-MODULE_PARM(numBufs, "i");
-MODULE_PARM(bufSize, "i");
-MODULE_PARM(numreadBufs, "i");
-MODULE_PARM(readbufSize, "i");
+module_param(catchRadius, int, 0);
+module_param(numBufs, int, 0);
+module_param(bufSize, int, 0);
+module_param(numreadBufs, int, 0);
+module_param(readbufSize, int, 0);
#define arraysize(x) (sizeof(x)/sizeof(*(x)))
#define le2be16(x) (((x)<<8 & 0xff00) | ((x)>>8 & 0x00ff))
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index 11899f06bf0..54a0a9bb12d 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -481,6 +481,53 @@ config WINCEPT
endchoice
+menu "Freescale Ethernet driver platform-specific options"
+ depends on FS_ENET
+
+ config MPC8xx_SECOND_ETH
+ bool "Second Ethernet channel"
+ depends on (MPC885ADS || MPC86XADS)
+ default y
+ help
+ This enables support for second Ethernet on MPC885ADS and MPC86xADS boards.
+ The latter will use SCC1, for 885ADS you can select it below.
+
+ choice
+ prompt "Second Ethernet channel"
+ depends on MPC8xx_SECOND_ETH
+ default MPC8xx_SECOND_ETH_FEC2
+
+ config MPC8xx_SECOND_ETH_FEC2
+ bool "FEC2"
+ depends on MPC885ADS
+ help
+ Enable FEC2 to serve as 2-nd Ethernet channel. Note that SMC2
+ (often 2-nd UART) will not work if this is enabled.
+
+ config MPC8xx_SECOND_ETH_SCC1
+ bool "SCC1"
+ depends on MPC86XADS
+ select MPC8xx_SCC_ENET_FIXED
+ help
+ Enable SCC1 to serve as 2-nd Ethernet channel. Note that SMC1
+ (often 1-nd UART) will not work if this is enabled.
+
+ config MPC8xx_SECOND_ETH_SCC3
+ bool "SCC3"
+ depends on MPC885ADS
+ help
+ Enable SCC3 to serve as 2-nd Ethernet channel. Note that SMC1
+ (often 1-nd UART) will not work if this is enabled.
+
+ endchoice
+
+ config MPC8xx_SCC_ENET_FIXED
+ depends on MPC8xx_SECOND_ETH_SCC
+ default n
+ bool "Use fixed MII-less mode for SCC Ethernet"
+
+endmenu
+
choice
prompt "Machine Type"
depends on 6xx || POWER3
diff --git a/arch/ppc/Kconfig.debug b/arch/ppc/Kconfig.debug
index 61653cb60c4..8cc75abf3d8 100644
--- a/arch/ppc/Kconfig.debug
+++ b/arch/ppc/Kconfig.debug
@@ -67,7 +67,7 @@ config SERIAL_TEXT_DEBUG
config PPC_OCP
bool
- depends on IBM_OCP || XILINX_OCP
+ depends on IBM_OCP
default y
endmenu
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 98e940beeb3..9fbdf54ba2b 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -82,7 +82,7 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
-.PHONY: $(BOOT_TARGETS)
+PHONY += $(BOOT_TARGETS)
all: uImage zImage
diff --git a/arch/ppc/amiga/amiints.c b/arch/ppc/amiga/amiints.c
index 5f35cf3986f..b2bba052ab9 100644
--- a/arch/ppc/amiga/amiints.c
+++ b/arch/ppc/amiga/amiints.c
@@ -1,5 +1,5 @@
/*
- * arch/ppc/amiga/amiints.c -- Amiga Linux interrupt handling code
+ * Amiga Linux interrupt handling code
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of this archive
diff --git a/arch/ppc/amiga/bootinfo.c b/arch/ppc/amiga/bootinfo.c
index e2e965661d0..efd869a3ed9 100644
--- a/arch/ppc/amiga/bootinfo.c
+++ b/arch/ppc/amiga/bootinfo.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/amiga/bootinfo.c
- *
* Extracted from arch/m68k/kernel/setup.c.
* Should be properly generalized and put somewhere else.
* Jesper
diff --git a/arch/ppc/amiga/cia.c b/arch/ppc/amiga/cia.c
index 4431c58f611..9558f2f40e6 100644
--- a/arch/ppc/amiga/cia.c
+++ b/arch/ppc/amiga/cia.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/amiga/cia.c - CIA support
- *
* Copyright (C) 1996 Roman Zippel
*
* The concept of some functions bases on the original Amiga OS function
diff --git a/arch/ppc/amiga/config.c b/arch/ppc/amiga/config.c
index 60e2da1c92c..bbe47c9bd70 100644
--- a/arch/ppc/amiga/config.c
+++ b/arch/ppc/amiga/config.c
@@ -1,8 +1,6 @@
#define m68k_debug_device debug_device
/*
- * arch/ppc/amiga/config.c
- *
* Copyright (C) 1993 Hamish Macdonald
*
* This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/amiga/ints.c b/arch/ppc/amiga/ints.c
index 5d318e498f0..083a1746219 100644
--- a/arch/ppc/amiga/ints.c
+++ b/arch/ppc/amiga/ints.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/amiga/ints.c
- *
* Linux/m68k general interrupt handling code from arch/m68k/kernel/ints.c
* Needed to drive the m68k emulating IRQ hardware on the PowerUp boards.
*/
diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile
index efd8ce515d5..84eec0bef93 100644
--- a/arch/ppc/boot/Makefile
+++ b/arch/ppc/boot/Makefile
@@ -1,6 +1,9 @@
#
# arch/ppc/boot/Makefile
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
@@ -25,7 +28,7 @@ subdir- += simple openfirmware
hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
-.PHONY: $(BOOT_TARGETS) $(bootdir-y)
+PHONY += $(BOOT_TARGETS) $(bootdir-y)
$(BOOT_TARGETS): $(bootdir-y)
diff --git a/arch/ppc/boot/common/Makefile b/arch/ppc/boot/common/Makefile
index f88d647d5dd..a2e85e3beb8 100644
--- a/arch/ppc/boot/common/Makefile
+++ b/arch/ppc/boot/common/Makefile
@@ -1,6 +1,3 @@
-#
-# arch/ppc/boot/common/Makefile
-#
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
diff --git a/arch/ppc/boot/common/bootinfo.c b/arch/ppc/boot/common/bootinfo.c
index 9c6e528940e..f4dc9b9fab9 100644
--- a/arch/ppc/boot/common/bootinfo.c
+++ b/arch/ppc/boot/common/bootinfo.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/common/bootinfo.c
- *
* General bootinfo record utilities
* Author: Randy Vinson <rvinson@mvista.com>
*
diff --git a/arch/ppc/boot/common/misc-common.c b/arch/ppc/boot/common/misc-common.c
index e79e6b3f276..073830a8559 100644
--- a/arch/ppc/boot/common/misc-common.c
+++ b/arch/ppc/boot/common/misc-common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/common/misc-common.c
- *
* Misc. bootloader code (almost) all platforms can use
*
* Author: Johnnie Peters <jpeters@mvista.com>
diff --git a/arch/ppc/boot/common/ns16550.c b/arch/ppc/boot/common/ns16550.c
index 26818bbb6cf..4f00c93ac87 100644
--- a/arch/ppc/boot/common/ns16550.c
+++ b/arch/ppc/boot/common/ns16550.c
@@ -8,6 +8,9 @@
#include <linux/serial_reg.h>
#include <asm/serial.h>
+#if defined(CONFIG_XILINX_VIRTEX)
+#include <platforms/4xx/xparameters/xparameters.h>
+#endif
#include "nonstdio.h"
#include "serial.h"
diff --git a/arch/ppc/boot/common/serial_stub.c b/arch/ppc/boot/common/serial_stub.c
index 03dfaa01fa6..5cc9ae66a8b 100644
--- a/arch/ppc/boot/common/serial_stub.c
+++ b/arch/ppc/boot/common/serial_stub.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/common/serial_stub.c
- *
* This is a few stub routines to make the boot code cleaner looking when
* there is no serial port support doesn't need to be closed, for example.
*
diff --git a/arch/ppc/boot/common/util.S b/arch/ppc/boot/common/util.S
index 368ec035e6c..0c5e43c4ae0 100644
--- a/arch/ppc/boot/common/util.S
+++ b/arch/ppc/boot/common/util.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/common/util.S
- *
* Useful bootup functions, which are more easily done in asm than C.
*
* NOTE: Be very very careful about the registers you use here.
diff --git a/arch/ppc/boot/include/mpc10x.h b/arch/ppc/boot/include/mpc10x.h
index 6cd40ecabc7..6e5d540d8d3 100644
--- a/arch/ppc/boot/include/mpc10x.h
+++ b/arch/ppc/boot/include/mpc10x.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/include/mpc10.h
- *
* Common defines for the Motorola SPS MPC106/8240/107 Host bridge/Mem
* ctrl/EPIC/etc.
*
diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
index 2a411ec2e65..66b73974375 100644
--- a/arch/ppc/boot/openfirmware/Makefile
+++ b/arch/ppc/boot/openfirmware/Makefile
@@ -1,5 +1,8 @@
# Makefile for making bootable images on various OpenFirmware machines.
#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# Paul Mackerras January 1997
# XCOFF bootable images for PowerMacs
# Geert Uytterhoeven September 1997
@@ -86,7 +89,7 @@ $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
# The targets used on the make command-line
-.PHONY: zImage zImage.initrd
+PHONY += zImage zImage.initrd
zImage: $(images)/zImage.chrp \
$(images)/zImage.chrp-rs6k
@echo ' kernel: $@ is ready ($<)'
@@ -96,7 +99,7 @@ zImage.initrd: $(images)/zImage.initrd.chrp \
TFTPIMAGE := /tftpboot/zImage
-.PHONY: znetboot znetboot.initrd
+PHONY += znetboot znetboot.initrd
znetboot: $(images)/zImage.chrp
cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
@echo ' kernel: $@ is ready ($<)'
diff --git a/arch/ppc/boot/simple/Makefile b/arch/ppc/boot/simple/Makefile
index 9533f8de238..28be01b99c4 100644
--- a/arch/ppc/boot/simple/Makefile
+++ b/arch/ppc/boot/simple/Makefile
@@ -192,6 +192,7 @@ boot-$(CONFIG_8xx) += embed_config.o
boot-$(CONFIG_8260) += embed_config.o
boot-$(CONFIG_EP405) += embed_config.o
boot-$(CONFIG_XILINX_ML300) += embed_config.o
+boot-$(CONFIG_XILINX_ML403) += embed_config.o
boot-$(CONFIG_BSEIP) += iic.o
boot-$(CONFIG_MBX) += iic.o pci.o qspan_pci.o
boot-$(CONFIG_MV64X60) += misc-mv64x60.o
diff --git a/arch/ppc/boot/simple/cpc700_memory.c b/arch/ppc/boot/simple/cpc700_memory.c
index 8c75cf6c238..d75420a45a5 100644
--- a/arch/ppc/boot/simple/cpc700_memory.c
+++ b/arch/ppc/boot/simple/cpc700_memory.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/common/cpc700_memory.c
- *
* Find memory based upon settings in the CPC700 bridge
*
* Author: Dan Cox
diff --git a/arch/ppc/boot/simple/embed_config.c b/arch/ppc/boot/simple/embed_config.c
index 491a691d10c..3a51b106294 100644
--- a/arch/ppc/boot/simple/embed_config.c
+++ b/arch/ppc/boot/simple/embed_config.c
@@ -21,6 +21,9 @@
#ifdef CONFIG_40x
#include <asm/io.h>
#endif
+#ifdef CONFIG_XILINX_VIRTEX
+#include <platforms/4xx/xparameters/xparameters.h>
+#endif
extern unsigned long timebase_period_ns;
/* For those boards that don't provide one.
@@ -742,7 +745,7 @@ embed_config(bd_t **bdp)
}
#endif /* WILLOW */
-#ifdef CONFIG_XILINX_ML300
+#if defined(CONFIG_XILINX_ML300) || defined(CONFIG_XILINX_ML403)
void
embed_config(bd_t ** bdp)
{
@@ -779,7 +782,7 @@ embed_config(bd_t ** bdp)
timebase_period_ns = 1000000000 / bd->bi_tbfreq;
/* see bi_tbfreq definition in arch/ppc/platforms/4xx/xilinx_ml300.h */
}
-#endif /* CONFIG_XILINX_ML300 */
+#endif /* CONFIG_XILINX_ML300 || CONFIG_XILINX_ML403 */
#ifdef CONFIG_IBM_OPENBIOS
/* This could possibly work for all treeboot roms.
diff --git a/arch/ppc/boot/simple/head.S b/arch/ppc/boot/simple/head.S
index 5e4adc298bf..160da1006ff 100644
--- a/arch/ppc/boot/simple/head.S
+++ b/arch/ppc/boot/simple/head.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/head.S
- *
* Initial board bringup code for many different boards.
*
* Author: Tom Rini
@@ -65,6 +63,13 @@ start_:
*/
#endif
+#if defined(CONFIG_XILINX_VIRTEX_4_FX)
+ /* PPC errata 213: only for Virtex-4 FX */
+ mfccr0 0
+ oris 0,0,0x50000000@h
+ mtccr0 0
+#endif
+
mflr r3 /* Save our actual starting address. */
/* The following functions we call must not modify r3 or r4.....
diff --git a/arch/ppc/boot/simple/misc-chestnut.c b/arch/ppc/boot/simple/misc-chestnut.c
index 0dce7f3557e..b94e142ad89 100644
--- a/arch/ppc/boot/simple/misc-chestnut.c
+++ b/arch/ppc/boot/simple/misc-chestnut.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-chestnut.c
- *
* Setup for the IBM Chestnut (ibm-750fxgx_eval)
*
* Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-cpci690.c b/arch/ppc/boot/simple/misc-cpci690.c
index 26860300fa0..8a8614d11a3 100644
--- a/arch/ppc/boot/simple/misc-cpci690.c
+++ b/arch/ppc/boot/simple/misc-cpci690.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-cpci690.c
- *
* Add birec data for Force CPCI690 board.
*
* Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-ev64260.c b/arch/ppc/boot/simple/misc-ev64260.c
index 52ece6937a7..2678c224af2 100644
--- a/arch/ppc/boot/simple/misc-ev64260.c
+++ b/arch/ppc/boot/simple/misc-ev64260.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-ev64260.c
- *
* Host bridge init code for the Marvell/Galileo EV-64260-BP evaluation board
* with a GT64260 onboard.
*
diff --git a/arch/ppc/boot/simple/misc-ev64360.c b/arch/ppc/boot/simple/misc-ev64360.c
index cd1ccf2a158..a212b5b988c 100644
--- a/arch/ppc/boot/simple/misc-ev64360.c
+++ b/arch/ppc/boot/simple/misc-ev64360.c
@@ -1,5 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-ev64360.c
* Copyright (C) 2005 Lee Nicks <allinux@gmail.com>
*
* Based on arch/ppc/boot/simple/misc-katana.c from:
diff --git a/arch/ppc/boot/simple/misc-katana.c b/arch/ppc/boot/simple/misc-katana.c
index ec94a11baca..d97f2ee6f04 100644
--- a/arch/ppc/boot/simple/misc-katana.c
+++ b/arch/ppc/boot/simple/misc-katana.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-katana.c
- *
* Set up MPSC values to bootwrapper can prompt user.
*
* Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-mv64x60.c b/arch/ppc/boot/simple/misc-mv64x60.c
index 258d4599fad..71ff20fd494 100644
--- a/arch/ppc/boot/simple/misc-mv64x60.c
+++ b/arch/ppc/boot/simple/misc-mv64x60.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-mv64x60.c
- *
* Relocate bridge's register base and call board specific routine.
*
* Author: Mark A. Greer <source@mvista.com>
diff --git a/arch/ppc/boot/simple/misc-prep.c b/arch/ppc/boot/simple/misc-prep.c
index 75380ac4166..63def9d13d7 100644
--- a/arch/ppc/boot/simple/misc-prep.c
+++ b/arch/ppc/boot/simple/misc-prep.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-prep.c
- *
* Maintainer: Tom Rini <trini@kernel.crashing.org>
*
* In the past: Gary Thomas, Cort Dougan <cort@cs.nmt.edu>
diff --git a/arch/ppc/boot/simple/misc-radstone_ppc7d.c b/arch/ppc/boot/simple/misc-radstone_ppc7d.c
index 569e0d4feea..0f302ea9c3d 100644
--- a/arch/ppc/boot/simple/misc-radstone_ppc7d.c
+++ b/arch/ppc/boot/simple/misc-radstone_ppc7d.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/misc-radstone_ppc7d.c
- *
* Misc data for Radstone PPC7D board.
*
* Author: James Chapman <jchapman@katalix.com>
diff --git a/arch/ppc/boot/simple/misc-spruce.c b/arch/ppc/boot/simple/misc-spruce.c
index d012c39278f..0cad2f557a1 100644
--- a/arch/ppc/boot/simple/misc-spruce.c
+++ b/arch/ppc/boot/simple/misc-spruce.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/spruce/misc.c
- *
* Misc. bootloader code for IBM Spruce reference platform
*
* Authors: Johnnie Peters <jpeters@mvista.com>
diff --git a/arch/ppc/boot/simple/misc.c b/arch/ppc/boot/simple/misc.c
index f415d6c6236..3d78571ad94 100644
--- a/arch/ppc/boot/simple/misc.c
+++ b/arch/ppc/boot/simple/misc.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/simple/misc.c
- *
* Misc. bootloader code for many machines. This assumes you have are using
* a 6xx/7xx/74xx CPU in your machine. This assumes the chunk of memory
* below 8MB is free. Finally, it assumes you have a NS16550-style uart for
diff --git a/arch/ppc/boot/simple/mpc10x_memory.c b/arch/ppc/boot/simple/mpc10x_memory.c
index 20d92a34ceb..c24290823f7 100644
--- a/arch/ppc/boot/simple/mpc10x_memory.c
+++ b/arch/ppc/boot/simple/mpc10x_memory.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/common/mpc10x_common.c
- *
* A routine to find out how much memory the machine has.
*
* Based on:
diff --git a/arch/ppc/boot/simple/mpc52xx_tty.c b/arch/ppc/boot/simple/mpc52xx_tty.c
index 3acc6b7c072..1964493cf3b 100644
--- a/arch/ppc/boot/simple/mpc52xx_tty.c
+++ b/arch/ppc/boot/simple/mpc52xx_tty.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/mpc52xx_tty.c
- *
* Minimal serial functions needed to send messages out a MPC52xx
* Programmable Serial Controller (PSC).
*
diff --git a/arch/ppc/boot/simple/mv64x60_tty.c b/arch/ppc/boot/simple/mv64x60_tty.c
index b9c24d4c738..0c52f5c784a 100644
--- a/arch/ppc/boot/simple/mv64x60_tty.c
+++ b/arch/ppc/boot/simple/mv64x60_tty.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/mv64x60_tty.c
- *
* Bootloader version of the embedded MPSC/UART driver for the Marvell 64x60.
* Note: Due to a GT64260A erratum, DMA will be used for UART input (via SDMA).
*
diff --git a/arch/ppc/boot/simple/openbios.c b/arch/ppc/boot/simple/openbios.c
index 81f11d8b30a..3f2ed53f793 100644
--- a/arch/ppc/boot/simple/openbios.c
+++ b/arch/ppc/boot/simple/openbios.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/openbios.c
- *
* Copyright (c) 2005 DENX Software Engineering
* Stefan Roese <sr@denx.de>
*
diff --git a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S
index 555a216ccc4..7efddc50756 100644
--- a/arch/ppc/boot/simple/relocate.S
+++ b/arch/ppc/boot/simple/relocate.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/simple/relocate.S
- *
* This is the common part of the loader relocation and initialization
* process. All of the board/processor specific initialization is
* done before we get here.
diff --git a/arch/ppc/boot/utils/mkbugboot.c b/arch/ppc/boot/utils/mkbugboot.c
index 886122283f3..29115e01f60 100644
--- a/arch/ppc/boot/utils/mkbugboot.c
+++ b/arch/ppc/boot/utils/mkbugboot.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/boot/utils/mkbugboot.c
- *
* Makes a Motorola PPCBUG ROM bootable image which can be flashed
* into one of the FLASH banks on a Motorola PowerPlus board.
*
diff --git a/arch/ppc/configs/ml300_defconfig b/arch/ppc/configs/ml300_defconfig
new file mode 100644
index 00000000000..4a33aca948c
--- /dev/null
+++ b/arch/ppc/configs/ml300_defconfig
@@ -0,0 +1,739 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.16-rc1
+# Wed Jan 18 00:49:20 2006
+#
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_PPC=y
+CONFIG_PPC32=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+
+#
+# Processor
+#
+# CONFIG_6xx is not set
+CONFIG_40x=y
+# CONFIG_44x is not set
+# CONFIG_POWER3 is not set
+# CONFIG_8xx is not set
+# CONFIG_E200 is not set
+# CONFIG_E500 is not set
+# CONFIG_MATH_EMULATION is not set
+# CONFIG_KEXEC is not set
+# CONFIG_CPU_FREQ is not set
+CONFIG_4xx=y
+# CONFIG_WANT_EARLY_SERIAL is not set
+
+#
+# IBM 4xx options
+#
+# CONFIG_BUBINGA is not set
+# CONFIG_CPCI405 is not set
+# CONFIG_EP405 is not set
+# CONFIG_REDWOOD_5 is not set
+# CONFIG_REDWOOD_6 is not set
+# CONFIG_SYCAMORE is not set
+# CONFIG_WALNUT is not set
+CONFIG_XILINX_ML300=y
+CONFIG_IBM405_ERR77=y
+CONFIG_IBM405_ERR51=y
+CONFIG_XILINX_VIRTEX=y
+CONFIG_EMBEDDEDBOOT=y
+# CONFIG_PPC4xx_DMA is not set
+CONFIG_PPC_GEN550=y
+CONFIG_UART0_TTYS0=y
+# CONFIG_UART0_TTYS1 is not set
+CONFIG_NOT_COHERENT_CACHE=y
+
+#
+# Platform options
+#
+# CONFIG_PC_KEYBOARD is not set
+# CONFIG_HIGHMEM is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttyS0,9600"
+# CONFIG_PM is not set
+# CONFIG_SOFTWARE_SUSPEND is not set
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+# CONFIG_PPC_I8259 is not set
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# Advanced setup
+#
+# CONFIG_ADVANCED_OPTIONS is not set
+
+#
+# Default settings for advanced configuration options are used
+#
+CONFIG_HIGHMEM_START=0xfe000000
+CONFIG_LOWMEM_SIZE=0x30000000
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_TASK_SIZE=0x80000000
+CONFIG_CONSISTENT_START=0xff100000
+CONFIG_CONSISTENT_SIZE=0x00200000
+CONFIG_BOOT_LOAD=0x00400000
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=65536
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Macintosh device drivers
+#
+# CONFIG_WINDFARM is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=y
+
+#
+# PHY device support
+#
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+# CONFIG_IBM_EMAC is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+# CONFIG_TELCLOCK is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+# CONFIG_HWMON is not set
+# CONFIG_HWMON_VID is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia Capabilities Port drivers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+
+#
+# SN Devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+
+#
+# IBM 40x options
+#
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+CONFIG_FORCED_INLINING=y
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_KGDB is not set
+CONFIG_XMON=y
+# CONFIG_BDI_SWITCH is not set
+# CONFIG_SERIAL_TEXT_DEBUG is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Hardware crypto devices
+#
diff --git a/arch/ppc/configs/ml403_defconfig b/arch/ppc/configs/ml403_defconfig
new file mode 100644
index 00000000000..fafd2516fa5
--- /dev/null
+++ b/arch/ppc/configs/ml403_defconfig
@@ -0,0 +1,740 @@
+#
+# Automatically generated make config: don't edit
+# Linux kernel version: 2.6.16-rc1
+# Wed Jan 18 01:11:41 2006
+#
+CONFIG_MMU=y
+CONFIG_GENERIC_HARDIRQS=y
+CONFIG_RWSEM_XCHGADD_ALGORITHM=y
+CONFIG_GENERIC_CALIBRATE_DELAY=y
+CONFIG_PPC=y
+CONFIG_PPC32=y
+CONFIG_GENERIC_NVRAM=y
+CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
+CONFIG_ARCH_MAY_HAVE_PC_FDC=y
+
+#
+# Code maturity level options
+#
+CONFIG_EXPERIMENTAL=y
+CONFIG_CLEAN_COMPILE=y
+CONFIG_BROKEN_ON_SMP=y
+CONFIG_INIT_ENV_ARG_LIMIT=32
+
+#
+# General setup
+#
+CONFIG_LOCALVERSION=""
+CONFIG_LOCALVERSION_AUTO=y
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+# CONFIG_POSIX_MQUEUE is not set
+CONFIG_BSD_PROCESS_ACCT=y
+CONFIG_BSD_PROCESS_ACCT_V3=y
+CONFIG_SYSCTL=y
+# CONFIG_AUDIT is not set
+# CONFIG_IKCONFIG is not set
+CONFIG_INITRAMFS_SOURCE=""
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+# CONFIG_EMBEDDED is not set
+CONFIG_KALLSYMS=y
+# CONFIG_KALLSYMS_ALL is not set
+# CONFIG_KALLSYMS_EXTRA_PASS is not set
+CONFIG_HOTPLUG=y
+CONFIG_PRINTK=y
+CONFIG_BUG=y
+CONFIG_ELF_CORE=y
+CONFIG_BASE_FULL=y
+CONFIG_FUTEX=y
+CONFIG_EPOLL=y
+CONFIG_SHMEM=y
+CONFIG_CC_ALIGN_FUNCTIONS=0
+CONFIG_CC_ALIGN_LABELS=0
+CONFIG_CC_ALIGN_LOOPS=0
+CONFIG_CC_ALIGN_JUMPS=0
+CONFIG_SLAB=y
+# CONFIG_TINY_SHMEM is not set
+CONFIG_BASE_SMALL=0
+# CONFIG_SLOB is not set
+
+#
+# Loadable module support
+#
+CONFIG_MODULES=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_OBSOLETE_MODPARM=y
+CONFIG_MODVERSIONS=y
+CONFIG_MODULE_SRCVERSION_ALL=y
+CONFIG_KMOD=y
+
+#
+# Block layer
+#
+CONFIG_LBD=y
+
+#
+# IO Schedulers
+#
+CONFIG_IOSCHED_NOOP=y
+CONFIG_IOSCHED_AS=y
+CONFIG_IOSCHED_DEADLINE=y
+CONFIG_IOSCHED_CFQ=y
+CONFIG_DEFAULT_AS=y
+# CONFIG_DEFAULT_DEADLINE is not set
+# CONFIG_DEFAULT_CFQ is not set
+# CONFIG_DEFAULT_NOOP is not set
+CONFIG_DEFAULT_IOSCHED="anticipatory"
+
+#
+# Processor
+#
+# CONFIG_6xx is not set
+CONFIG_40x=y
+# CONFIG_44x is not set
+# CONFIG_POWER3 is not set
+# CONFIG_8xx is not set
+# CONFIG_E200 is not set
+# CONFIG_E500 is not set
+# CONFIG_MATH_EMULATION is not set
+# CONFIG_KEXEC is not set
+# CONFIG_CPU_FREQ is not set
+CONFIG_4xx=y
+# CONFIG_WANT_EARLY_SERIAL is not set
+
+#
+# IBM 4xx options
+#
+# CONFIG_BUBINGA is not set
+# CONFIG_CPCI405 is not set
+# CONFIG_EP405 is not set
+# CONFIG_REDWOOD_5 is not set
+# CONFIG_REDWOOD_6 is not set
+# CONFIG_SYCAMORE is not set
+# CONFIG_WALNUT is not set
+# CONFIG_XILINX_ML300 is not set
+CONFIG_XILINX_ML403=y
+CONFIG_IBM405_ERR77=y
+CONFIG_IBM405_ERR51=y
+CONFIG_XILINX_VIRTEX=y
+CONFIG_EMBEDDEDBOOT=y
+# CONFIG_PPC4xx_DMA is not set
+CONFIG_PPC_GEN550=y
+CONFIG_UART0_TTYS0=y
+# CONFIG_UART0_TTYS1 is not set
+CONFIG_NOT_COHERENT_CACHE=y
+
+#
+# Platform options
+#
+# CONFIG_PC_KEYBOARD is not set
+# CONFIG_HIGHMEM is not set
+# CONFIG_HZ_100 is not set
+CONFIG_HZ_250=y
+# CONFIG_HZ_1000 is not set
+CONFIG_HZ=250
+CONFIG_PREEMPT_NONE=y
+# CONFIG_PREEMPT_VOLUNTARY is not set
+# CONFIG_PREEMPT is not set
+CONFIG_SELECT_MEMORY_MODEL=y
+CONFIG_FLATMEM_MANUAL=y
+# CONFIG_DISCONTIGMEM_MANUAL is not set
+# CONFIG_SPARSEMEM_MANUAL is not set
+CONFIG_FLATMEM=y
+CONFIG_FLAT_NODE_MEM_MAP=y
+# CONFIG_SPARSEMEM_STATIC is not set
+CONFIG_SPLIT_PTLOCK_CPUS=4
+CONFIG_BINFMT_ELF=y
+# CONFIG_BINFMT_MISC is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="console=ttyS0,9600"
+# CONFIG_PM is not set
+# CONFIG_SOFTWARE_SUSPEND is not set
+CONFIG_SECCOMP=y
+CONFIG_ISA_DMA_API=y
+
+#
+# Bus options
+#
+# CONFIG_PPC_I8259 is not set
+# CONFIG_PCI is not set
+# CONFIG_PCI_DOMAINS is not set
+
+#
+# PCCARD (PCMCIA/CardBus) support
+#
+# CONFIG_PCCARD is not set
+
+#
+# Advanced setup
+#
+# CONFIG_ADVANCED_OPTIONS is not set
+
+#
+# Default settings for advanced configuration options are used
+#
+CONFIG_HIGHMEM_START=0xfe000000
+CONFIG_LOWMEM_SIZE=0x30000000
+CONFIG_KERNEL_START=0xc0000000
+CONFIG_TASK_SIZE=0x80000000
+CONFIG_CONSISTENT_START=0xff100000
+CONFIG_CONSISTENT_SIZE=0x00200000
+CONFIG_BOOT_LOAD=0x00400000
+
+#
+# Networking
+#
+CONFIG_NET=y
+
+#
+# Networking options
+#
+CONFIG_PACKET=y
+CONFIG_PACKET_MMAP=y
+CONFIG_UNIX=y
+# CONFIG_NET_KEY is not set
+CONFIG_INET=y
+# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+CONFIG_IP_FIB_HASH=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+# CONFIG_IP_PNP_BOOTP is not set
+# CONFIG_IP_PNP_RARP is not set
+# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_ARPD is not set
+# CONFIG_SYN_COOKIES is not set
+# CONFIG_INET_AH is not set
+# CONFIG_INET_ESP is not set
+# CONFIG_INET_IPCOMP is not set
+# CONFIG_INET_TUNNEL is not set
+CONFIG_INET_DIAG=y
+CONFIG_INET_TCP_DIAG=y
+# CONFIG_TCP_CONG_ADVANCED is not set
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_IPV6 is not set
+# CONFIG_NETFILTER is not set
+
+#
+# DCCP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_DCCP is not set
+
+#
+# SCTP Configuration (EXPERIMENTAL)
+#
+# CONFIG_IP_SCTP is not set
+# CONFIG_ATM is not set
+# CONFIG_BRIDGE is not set
+# CONFIG_VLAN_8021Q is not set
+# CONFIG_DECNET is not set
+# CONFIG_LLC2 is not set
+# CONFIG_IPX is not set
+# CONFIG_ATALK is not set
+# CONFIG_X25 is not set
+# CONFIG_LAPB is not set
+
+#
+# TIPC Configuration (EXPERIMENTAL)
+#
+# CONFIG_TIPC is not set
+# CONFIG_NET_DIVERT is not set
+# CONFIG_ECONET is not set
+# CONFIG_WAN_ROUTER is not set
+
+#
+# QoS and/or fair queueing
+#
+# CONFIG_NET_SCHED is not set
+
+#
+# Network testing
+#
+# CONFIG_NET_PKTGEN is not set
+# CONFIG_HAMRADIO is not set
+# CONFIG_IRDA is not set
+# CONFIG_BT is not set
+# CONFIG_IEEE80211 is not set
+
+#
+# Device Drivers
+#
+
+#
+# Generic Driver Options
+#
+CONFIG_STANDALONE=y
+CONFIG_PREVENT_FIRMWARE_BUILD=y
+# CONFIG_FW_LOADER is not set
+# CONFIG_DEBUG_DRIVER is not set
+
+#
+# Connector - unified userspace <-> kernelspace linker
+#
+# CONFIG_CONNECTOR is not set
+
+#
+# Memory Technology Devices (MTD)
+#
+# CONFIG_MTD is not set
+
+#
+# Parallel port support
+#
+# CONFIG_PARPORT is not set
+
+#
+# Plug and Play support
+#
+
+#
+# Block devices
+#
+# CONFIG_BLK_DEV_FD is not set
+# CONFIG_BLK_DEV_COW_COMMON is not set
+# CONFIG_BLK_DEV_LOOP is not set
+# CONFIG_BLK_DEV_NBD is not set
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=16
+CONFIG_BLK_DEV_RAM_SIZE=65536
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_CDROM_PKTCDVD is not set
+# CONFIG_ATA_OVER_ETH is not set
+
+#
+# ATA/ATAPI/MFM/RLL support
+#
+# CONFIG_IDE is not set
+
+#
+# SCSI device support
+#
+# CONFIG_RAID_ATTRS is not set
+# CONFIG_SCSI is not set
+
+#
+# Multi-device support (RAID and LVM)
+#
+# CONFIG_MD is not set
+
+#
+# Fusion MPT device support
+#
+# CONFIG_FUSION is not set
+
+#
+# IEEE 1394 (FireWire) support
+#
+
+#
+# I2O device support
+#
+
+#
+# Macintosh device drivers
+#
+# CONFIG_WINDFARM is not set
+
+#
+# Network device support
+#
+CONFIG_NETDEVICES=y
+# CONFIG_DUMMY is not set
+# CONFIG_BONDING is not set
+# CONFIG_EQUALIZER is not set
+CONFIG_TUN=y
+
+#
+# PHY device support
+#
+
+#
+# Ethernet (10 or 100Mbit)
+#
+# CONFIG_NET_ETHERNET is not set
+# CONFIG_IBM_EMAC is not set
+
+#
+# Ethernet (1000 Mbit)
+#
+
+#
+# Ethernet (10000 Mbit)
+#
+
+#
+# Token Ring devices
+#
+
+#
+# Wireless LAN (non-hamradio)
+#
+# CONFIG_NET_RADIO is not set
+
+#
+# Wan interfaces
+#
+# CONFIG_WAN is not set
+# CONFIG_PPP is not set
+# CONFIG_SLIP is not set
+# CONFIG_SHAPER is not set
+# CONFIG_NETCONSOLE is not set
+# CONFIG_NETPOLL is not set
+# CONFIG_NET_POLL_CONTROLLER is not set
+
+#
+# ISDN subsystem
+#
+# CONFIG_ISDN is not set
+
+#
+# Telephony Support
+#
+# CONFIG_PHONE is not set
+
+#
+# Input device support
+#
+CONFIG_INPUT=y
+
+#
+# Userland interfaces
+#
+CONFIG_INPUT_MOUSEDEV=y
+# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
+CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
+CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
+# CONFIG_INPUT_JOYDEV is not set
+# CONFIG_INPUT_TSDEV is not set
+# CONFIG_INPUT_EVDEV is not set
+# CONFIG_INPUT_EVBUG is not set
+
+#
+# Input Device Drivers
+#
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_INPUT_JOYSTICK is not set
+# CONFIG_INPUT_TOUCHSCREEN is not set
+# CONFIG_INPUT_MISC is not set
+
+#
+# Hardware I/O ports
+#
+# CONFIG_SERIO is not set
+# CONFIG_GAMEPORT is not set
+
+#
+# Character devices
+#
+CONFIG_VT=y
+CONFIG_VT_CONSOLE=y
+CONFIG_HW_CONSOLE=y
+# CONFIG_SERIAL_NONSTANDARD is not set
+
+#
+# Serial drivers
+#
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_NR_UARTS=4
+CONFIG_SERIAL_8250_RUNTIME_UARTS=4
+# CONFIG_SERIAL_8250_EXTENDED is not set
+
+#
+# Non-8250 serial port support
+#
+CONFIG_SERIAL_CORE=y
+CONFIG_SERIAL_CORE_CONSOLE=y
+CONFIG_UNIX98_PTYS=y
+# CONFIG_LEGACY_PTYS is not set
+
+#
+# IPMI
+#
+# CONFIG_IPMI_HANDLER is not set
+
+#
+# Watchdog Cards
+#
+# CONFIG_WATCHDOG is not set
+# CONFIG_NVRAM is not set
+# CONFIG_GEN_RTC is not set
+# CONFIG_DTLK is not set
+# CONFIG_R3964 is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_AGP is not set
+# CONFIG_RAW_DRIVER is not set
+
+#
+# TPM devices
+#
+# CONFIG_TCG_TPM is not set
+# CONFIG_TELCLOCK is not set
+
+#
+# I2C support
+#
+# CONFIG_I2C is not set
+
+#
+# SPI support
+#
+# CONFIG_SPI is not set
+# CONFIG_SPI_MASTER is not set
+
+#
+# Dallas's 1-wire bus
+#
+# CONFIG_W1 is not set
+
+#
+# Hardware Monitoring support
+#
+# CONFIG_HWMON is not set
+# CONFIG_HWMON_VID is not set
+
+#
+# Misc devices
+#
+
+#
+# Multimedia Capabilities Port drivers
+#
+
+#
+# Multimedia devices
+#
+# CONFIG_VIDEO_DEV is not set
+
+#
+# Digital Video Broadcasting Devices
+#
+# CONFIG_DVB is not set
+
+#
+# Graphics support
+#
+# CONFIG_FB is not set
+
+#
+# Console display driver support
+#
+CONFIG_DUMMY_CONSOLE=y
+
+#
+# Sound
+#
+# CONFIG_SOUND is not set
+
+#
+# USB support
+#
+# CONFIG_USB_ARCH_HAS_HCD is not set
+# CONFIG_USB_ARCH_HAS_OHCI is not set
+
+#
+# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
+#
+
+#
+# USB Gadget Support
+#
+# CONFIG_USB_GADGET is not set
+
+#
+# MMC/SD Card support
+#
+# CONFIG_MMC is not set
+
+#
+# InfiniBand support
+#
+
+#
+# SN Devices
+#
+
+#
+# File systems
+#
+CONFIG_EXT2_FS=y
+# CONFIG_EXT2_FS_XATTR is not set
+# CONFIG_EXT2_FS_XIP is not set
+# CONFIG_EXT3_FS is not set
+# CONFIG_REISERFS_FS is not set
+# CONFIG_JFS_FS is not set
+# CONFIG_FS_POSIX_ACL is not set
+# CONFIG_XFS_FS is not set
+# CONFIG_OCFS2_FS is not set
+# CONFIG_MINIX_FS is not set
+# CONFIG_ROMFS_FS is not set
+CONFIG_INOTIFY=y
+# CONFIG_QUOTA is not set
+CONFIG_DNOTIFY=y
+# CONFIG_AUTOFS_FS is not set
+# CONFIG_AUTOFS4_FS is not set
+# CONFIG_FUSE_FS is not set
+
+#
+# CD-ROM/DVD Filesystems
+#
+# CONFIG_ISO9660_FS is not set
+# CONFIG_UDF_FS is not set
+
+#
+# DOS/FAT/NT Filesystems
+#
+CONFIG_FAT_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_FAT_DEFAULT_CODEPAGE=437
+CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
+# CONFIG_NTFS_FS is not set
+
+#
+# Pseudo filesystems
+#
+CONFIG_PROC_FS=y
+CONFIG_PROC_KCORE=y
+CONFIG_SYSFS=y
+CONFIG_TMPFS=y
+# CONFIG_HUGETLB_PAGE is not set
+CONFIG_RAMFS=y
+# CONFIG_RELAYFS_FS is not set
+# CONFIG_CONFIGFS_FS is not set
+
+#
+# Miscellaneous filesystems
+#
+# CONFIG_ADFS_FS is not set
+# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
+# CONFIG_HFSPLUS_FS is not set
+# CONFIG_BEFS_FS is not set
+# CONFIG_BFS_FS is not set
+# CONFIG_EFS_FS is not set
+# CONFIG_CRAMFS is not set
+# CONFIG_VXFS_FS is not set
+# CONFIG_HPFS_FS is not set
+# CONFIG_QNX4FS_FS is not set
+# CONFIG_SYSV_FS is not set
+# CONFIG_UFS_FS is not set
+
+#
+# Network File Systems
+#
+# CONFIG_NFS_FS is not set
+# CONFIG_NFSD is not set
+# CONFIG_SMB_FS is not set
+# CONFIG_CIFS is not set
+# CONFIG_NCP_FS is not set
+# CONFIG_CODA_FS is not set
+# CONFIG_AFS_FS is not set
+# CONFIG_9P_FS is not set
+
+#
+# Partition Types
+#
+# CONFIG_PARTITION_ADVANCED is not set
+CONFIG_MSDOS_PARTITION=y
+
+#
+# Native Language Support
+#
+CONFIG_NLS=y
+CONFIG_NLS_DEFAULT="iso8859-1"
+CONFIG_NLS_CODEPAGE_437=y
+# CONFIG_NLS_CODEPAGE_737 is not set
+# CONFIG_NLS_CODEPAGE_775 is not set
+# CONFIG_NLS_CODEPAGE_850 is not set
+# CONFIG_NLS_CODEPAGE_852 is not set
+# CONFIG_NLS_CODEPAGE_855 is not set
+# CONFIG_NLS_CODEPAGE_857 is not set
+# CONFIG_NLS_CODEPAGE_860 is not set
+# CONFIG_NLS_CODEPAGE_861 is not set
+# CONFIG_NLS_CODEPAGE_862 is not set
+# CONFIG_NLS_CODEPAGE_863 is not set
+# CONFIG_NLS_CODEPAGE_864 is not set
+# CONFIG_NLS_CODEPAGE_865 is not set
+# CONFIG_NLS_CODEPAGE_866 is not set
+# CONFIG_NLS_CODEPAGE_869 is not set
+# CONFIG_NLS_CODEPAGE_936 is not set
+# CONFIG_NLS_CODEPAGE_950 is not set
+# CONFIG_NLS_CODEPAGE_932 is not set
+# CONFIG_NLS_CODEPAGE_949 is not set
+# CONFIG_NLS_CODEPAGE_874 is not set
+# CONFIG_NLS_ISO8859_8 is not set
+# CONFIG_NLS_CODEPAGE_1250 is not set
+# CONFIG_NLS_CODEPAGE_1251 is not set
+CONFIG_NLS_ASCII=y
+CONFIG_NLS_ISO8859_1=y
+# CONFIG_NLS_ISO8859_2 is not set
+# CONFIG_NLS_ISO8859_3 is not set
+# CONFIG_NLS_ISO8859_4 is not set
+# CONFIG_NLS_ISO8859_5 is not set
+# CONFIG_NLS_ISO8859_6 is not set
+# CONFIG_NLS_ISO8859_7 is not set
+# CONFIG_NLS_ISO8859_9 is not set
+# CONFIG_NLS_ISO8859_13 is not set
+# CONFIG_NLS_ISO8859_14 is not set
+# CONFIG_NLS_ISO8859_15 is not set
+# CONFIG_NLS_KOI8_R is not set
+# CONFIG_NLS_KOI8_U is not set
+CONFIG_NLS_UTF8=y
+
+#
+# IBM 40x options
+#
+
+#
+# Library routines
+#
+# CONFIG_CRC_CCITT is not set
+# CONFIG_CRC16 is not set
+CONFIG_CRC32=y
+# CONFIG_LIBCRC32C is not set
+# CONFIG_PROFILING is not set
+
+#
+# Kernel hacking
+#
+CONFIG_PRINTK_TIME=y
+CONFIG_MAGIC_SYSRQ=y
+CONFIG_DEBUG_KERNEL=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_DETECT_SOFTLOCKUP=y
+# CONFIG_SCHEDSTATS is not set
+# CONFIG_DEBUG_SLAB is not set
+CONFIG_DEBUG_MUTEXES=y
+# CONFIG_DEBUG_SPINLOCK is not set
+# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
+# CONFIG_DEBUG_KOBJECT is not set
+CONFIG_DEBUG_INFO=y
+# CONFIG_DEBUG_FS is not set
+# CONFIG_DEBUG_VM is not set
+CONFIG_FORCED_INLINING=y
+# CONFIG_RCU_TORTURE_TEST is not set
+# CONFIG_KGDB is not set
+CONFIG_XMON=y
+# CONFIG_BDI_SWITCH is not set
+# CONFIG_SERIAL_TEXT_DEBUG is not set
+
+#
+# Security options
+#
+# CONFIG_KEYS is not set
+# CONFIG_SECURITY is not set
+
+#
+# Cryptographic options
+#
+# CONFIG_CRYPTO is not set
+
+#
+# Hardware crypto devices
+#
diff --git a/arch/ppc/kernel/head_44x.S b/arch/ppc/kernel/head_44x.S
index 677c571aa27..0d8b88219d3 100644
--- a/arch/ppc/kernel/head_44x.S
+++ b/arch/ppc/kernel/head_44x.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/head_44x.S
- *
* Kernel execution entry point code.
*
* Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
diff --git a/arch/ppc/kernel/head_8xx.S b/arch/ppc/kernel/head_8xx.S
index c1e89ad0684..ec53c7d65f2 100644
--- a/arch/ppc/kernel/head_8xx.S
+++ b/arch/ppc/kernel/head_8xx.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/except_8xx.S
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
* Rewritten by Cort Dougan (cort@cs.nmt.edu) for PReP
diff --git a/arch/ppc/kernel/head_fsl_booke.S b/arch/ppc/kernel/head_fsl_booke.S
index 8d60fa99fc4..dd86bbed762 100644
--- a/arch/ppc/kernel/head_fsl_booke.S
+++ b/arch/ppc/kernel/head_fsl_booke.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/head_fsl_booke.S
- *
* Kernel execution entry point code.
*
* Copyright (c) 1995-1996 Gary Thomas <gdt@linuxppc.org>
@@ -316,6 +314,7 @@ skpinv: addi r6,r6,1 /* Increment */
*/
lis r2,DBCR0_IDM@h
mtspr SPRN_DBCR0,r2
+ isync
/* clear any residual debug events */
li r2,-1
mtspr SPRN_DBSR,r2
@@ -1002,12 +1001,15 @@ _GLOBAL(giveup_fpu)
_GLOBAL(abort)
li r13,0
mtspr SPRN_DBCR0,r13 /* disable all debug events */
+ isync
mfmsr r13
ori r13,r13,MSR_DE@l /* Enable Debug Events */
mtmsr r13
+ isync
mfspr r13,SPRN_DBCR0
lis r13,(DBCR0_IDM|DBCR0_RST_CHIP)@h
mtspr SPRN_DBCR0,r13
+ isync
_GLOBAL(set_context)
diff --git a/arch/ppc/kernel/setup.c b/arch/ppc/kernel/setup.c
index c08ab432e95..53e9deacee8 100644
--- a/arch/ppc/kernel/setup.c
+++ b/arch/ppc/kernel/setup.c
@@ -168,9 +168,8 @@ int show_cpuinfo(struct seq_file *m, void *v)
/* Show summary information */
#ifdef CONFIG_SMP
unsigned long bogosum = 0;
- for (i = 0; i < NR_CPUS; ++i)
- if (cpu_online(i))
- bogosum += cpu_data[i].loops_per_jiffy;
+ for_each_online_cpu(i)
+ bogosum += cpu_data[i].loops_per_jiffy;
seq_printf(m, "total bogomips\t: %lu.%02lu\n",
bogosum/(500000/HZ), bogosum/(5000/HZ) % 100);
#endif /* CONFIG_SMP */
@@ -712,9 +711,8 @@ int __init ppc_init(void)
if ( ppc_md.progress ) ppc_md.progress(" ", 0xffff);
/* register CPU devices */
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_possible(i))
- register_cpu(&cpu_devices[i], i, NULL);
+ for_each_cpu(i)
+ register_cpu(&cpu_devices[i], i, NULL);
/* call platform init */
if (ppc_md.init != NULL) {
diff --git a/arch/ppc/kernel/smp-tbsync.c b/arch/ppc/kernel/smp-tbsync.c
index 2c9cd95bcea..6a5694fcc71 100644
--- a/arch/ppc/kernel/smp-tbsync.c
+++ b/arch/ppc/kernel/smp-tbsync.c
@@ -126,8 +126,7 @@ smp_generic_give_timebase( void )
printk("Synchronizing timebase\n");
/* if this fails then this kernel won't work anyway... */
- tbsync = kmalloc( sizeof(*tbsync), GFP_KERNEL );
- memset( tbsync, 0, sizeof(*tbsync) );
+ tbsync = kzalloc( sizeof(*tbsync), GFP_KERNEL );
mb();
running = 1;
diff --git a/arch/ppc/kernel/traps.c b/arch/ppc/kernel/traps.c
index 6d0a1838d94..1c0d68026ab 100644
--- a/arch/ppc/kernel/traps.c
+++ b/arch/ppc/kernel/traps.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/traps.c
- *
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
*
* This program is free software; you can redistribute it and/or
diff --git a/arch/ppc/lib/rheap.c b/arch/ppc/lib/rheap.c
index 42c5de2c898..31e511856dc 100644
--- a/arch/ppc/lib/rheap.c
+++ b/arch/ppc/lib/rheap.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/rheap.c
- *
* A Remote Heap. Remote means that we don't touch the memory that the
* heap points to. Normal heap implementations use the memory they manage
* to place their list. We cannot do that because the memory we manage may
diff --git a/arch/ppc/math-emu/math.c b/arch/ppc/math-emu/math.c
index b7dff53a710..58915347276 100644
--- a/arch/ppc/math-emu/math.c
+++ b/arch/ppc/math-emu/math.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/math-emu/math.c
- *
* Copyright (C) 1999 Eddie C. Dost (ecd@atecom.com)
*/
diff --git a/arch/ppc/mm/44x_mmu.c b/arch/ppc/mm/44x_mmu.c
index 3d79ce281b6..e0152a9b26e 100644
--- a/arch/ppc/mm/44x_mmu.c
+++ b/arch/ppc/mm/44x_mmu.c
@@ -104,7 +104,7 @@ unsigned long __init mmu_mapin_ram(void)
/* Determine number of entries necessary to cover lowmem */
pinned_tlbs = (unsigned int)
- (_ALIGN(total_lowmem, PPC44x_PIN_SIZE) >> PPC44x_PIN_SHIFT);
+ (_ALIGN(total_lowmem, PPC_PIN_SIZE) >> PPC44x_PIN_SHIFT);
/* Write upper watermark to save location */
tlb_44x_hwater = PPC44x_LOW_SLOT - pinned_tlbs;
@@ -112,7 +112,7 @@ unsigned long __init mmu_mapin_ram(void)
/* If necessary, set additional pinned TLBs */
if (pinned_tlbs > 1)
for (i = (PPC44x_LOW_SLOT-(pinned_tlbs-1)); i < PPC44x_LOW_SLOT; i++) {
- unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC44x_PIN_SIZE;
+ unsigned int phys_addr = (PPC44x_LOW_SLOT-i) * PPC_PIN_SIZE;
ppc44x_pin_tlb(i, phys_addr+PAGE_OFFSET, phys_addr);
}
diff --git a/arch/ppc/mm/fault.c b/arch/ppc/mm/fault.c
index ee5e9f25baf..0217188ef46 100644
--- a/arch/ppc/mm/fault.c
+++ b/arch/ppc/mm/fault.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/mm/fault.c
- *
* PowerPC version
* Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
*
diff --git a/arch/ppc/mm/hashtable.S b/arch/ppc/mm/hashtable.S
index 3ec87c91343..f09fa88db35 100644
--- a/arch/ppc/mm/hashtable.S
+++ b/arch/ppc/mm/hashtable.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/hashtable.S
- *
* $Id: hashtable.S,v 1.6 1999/10/08 01:56:15 paulus Exp $
*
* PowerPC version
diff --git a/arch/ppc/platforms/4xx/Kconfig b/arch/ppc/platforms/4xx/Kconfig
index d8837911bbc..174ddbc9758 100644
--- a/arch/ppc/platforms/4xx/Kconfig
+++ b/arch/ppc/platforms/4xx/Kconfig
@@ -57,6 +57,10 @@ config XILINX_ML300
help
This option enables support for the Xilinx ML300 evaluation board.
+config XILINX_ML403
+ bool "Xilinx-ML403"
+ help
+ This option enables support for the Xilinx ML403 evaluation board.
endchoice
choice
@@ -172,11 +176,6 @@ config IBM_OCP
depends on ASH || BAMBOO || BUBINGA || CPCI405 || EBONY || EP405 || LUAN || YUCCA || OCOTEA || REDWOOD_5 || REDWOOD_6 || SYCAMORE || WALNUT
default y
-config XILINX_OCP
- bool
- depends on XILINX_ML300
- default y
-
config IBM_EMAC4
bool
depends on 440GX || 440SP || 440SPE
@@ -208,11 +207,21 @@ config 405GPR
depends on SYCAMORE
default y
-config VIRTEX_II_PRO
+config XILINX_VIRTEX_II_PRO
bool
depends on XILINX_ML300
default y
+config XILINX_VIRTEX_4_FX
+ bool
+ depends on XILINX_ML403
+ default y
+
+config XILINX_VIRTEX
+ bool
+ depends on XILINX_VIRTEX_II_PRO || XILINX_VIRTEX_4_FX
+ default y
+
config STB03xxx
bool
depends on REDWOOD_5 || REDWOOD_6
@@ -220,7 +229,7 @@ config STB03xxx
config EMBEDDEDBOOT
bool
- depends on EP405 || XILINX_ML300
+ depends on EP405 || XILINX_ML300 || XILINX_ML403
default y
config IBM_OPENBIOS
diff --git a/arch/ppc/platforms/4xx/Makefile b/arch/ppc/platforms/4xx/Makefile
index c9bb6117095..a04a0d0a0f5 100644
--- a/arch/ppc/platforms/4xx/Makefile
+++ b/arch/ppc/platforms/4xx/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_REDWOOD_6) += redwood6.o
obj-$(CONFIG_SYCAMORE) += sycamore.o
obj-$(CONFIG_WALNUT) += walnut.o
obj-$(CONFIG_XILINX_ML300) += xilinx_ml300.o
+obj-$(CONFIG_XILINX_ML403) += xilinx_ml403.o
obj-$(CONFIG_405GP) += ibm405gp.o
obj-$(CONFIG_REDWOOD_5) += ibmstb4.o
@@ -26,4 +27,5 @@ obj-$(CONFIG_440SP) += ibm440sp.o
obj-$(CONFIG_440SPE) += ppc440spe.o
obj-$(CONFIG_405EP) += ibm405ep.o
obj-$(CONFIG_405GPR) += ibm405gpr.o
-obj-$(CONFIG_VIRTEX_II_PRO) += virtex-ii_pro.o
+obj-$(CONFIG_XILINX_VIRTEX) += virtex.o
+
diff --git a/arch/ppc/platforms/4xx/bamboo.c b/arch/ppc/platforms/4xx/bamboo.c
index 0ec53f04933..b940cfd646c 100644
--- a/arch/ppc/platforms/4xx/bamboo.c
+++ b/arch/ppc/platforms/4xx/bamboo.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/bamboo.c
- *
* Bamboo board specific routines
*
* Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/bamboo.h b/arch/ppc/platforms/4xx/bamboo.h
index 5c019282649..31c0dd6a26c 100644
--- a/arch/ppc/platforms/4xx/bamboo.h
+++ b/arch/ppc/platforms/4xx/bamboo.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/bamboo.h
- *
* Bamboo board definitions
*
* Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/bubinga.h b/arch/ppc/platforms/4xx/bubinga.h
index b5380cfaf5c..606aa9fa5ca 100644
--- a/arch/ppc/platforms/4xx/bubinga.h
+++ b/arch/ppc/platforms/4xx/bubinga.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/bubinga.h
- *
* Bubinga board definitions
*
* Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/cpci405.c b/arch/ppc/platforms/4xx/cpci405.c
index ff966773a0b..6571e39fbe4 100644
--- a/arch/ppc/platforms/4xx/cpci405.c
+++ b/arch/ppc/platforms/4xx/cpci405.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/cpci405.c
- *
* Board setup routines for the esd CPCI-405 cPCI Board.
*
* Author: Stefan Roese
diff --git a/arch/ppc/platforms/4xx/ebony.c b/arch/ppc/platforms/4xx/ebony.c
index 9a828b62341..b4ecb9c7985 100644
--- a/arch/ppc/platforms/4xx/ebony.c
+++ b/arch/ppc/platforms/4xx/ebony.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ebony.c
- *
* Ebony board specific routines
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ebony.h b/arch/ppc/platforms/4xx/ebony.h
index b91ad4272df..27b2e77c7c8 100644
--- a/arch/ppc/platforms/4xx/ebony.h
+++ b/arch/ppc/platforms/4xx/ebony.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ebony.h
- *
* Ebony board definitions
*
* Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ep405.c b/arch/ppc/platforms/4xx/ep405.c
index 26a07cdb30e..6efa91ff9c0 100644
--- a/arch/ppc/platforms/4xx/ep405.c
+++ b/arch/ppc/platforms/4xx/ep405.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ep405.c
- *
* Embedded Planet 405GP board
* http://www.embeddedplanet.com
*
diff --git a/arch/ppc/platforms/4xx/ep405.h b/arch/ppc/platforms/4xx/ep405.h
index ea3eb21338f..9814fc43172 100644
--- a/arch/ppc/platforms/4xx/ep405.h
+++ b/arch/ppc/platforms/4xx/ep405.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ep405.h
- *
* Embedded Planet 405GP board
* http://www.embeddedplanet.com
*
diff --git a/arch/ppc/platforms/4xx/ibm405ep.c b/arch/ppc/platforms/4xx/ibm405ep.c
index 093b28d27a4..55af769a6e7 100644
--- a/arch/ppc/platforms/4xx/ibm405ep.c
+++ b/arch/ppc/platforms/4xx/ibm405ep.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ibm405ep.c
- *
* Support for IBM PPC 405EP processors.
*
* Author: SAW (IBM), derived from ibmnp405l.c.
diff --git a/arch/ppc/platforms/4xx/ibm405ep.h b/arch/ppc/platforms/4xx/ibm405ep.h
index e051e3fe8c6..fe46640de15 100644
--- a/arch/ppc/platforms/4xx/ibm405ep.h
+++ b/arch/ppc/platforms/4xx/ibm405ep.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm405ep.h
- *
* IBM PPC 405EP processor defines.
*
* Author: SAW (IBM), derived from ibm405gp.h.
diff --git a/arch/ppc/platforms/4xx/ibm405gp.h b/arch/ppc/platforms/4xx/ibm405gp.h
index b2b642e81af..eaf0ef57028 100644
--- a/arch/ppc/platforms/4xx/ibm405gp.h
+++ b/arch/ppc/platforms/4xx/ibm405gp.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm405gp.h
- *
* Author: Armin Kuster akuster@mvista.com
*
* 2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm405gpr.c b/arch/ppc/platforms/4xx/ibm405gpr.c
index cd0d00d8e8e..49da61f6854 100644
--- a/arch/ppc/platforms/4xx/ibm405gpr.c
+++ b/arch/ppc/platforms/4xx/ibm405gpr.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm405gpr.c
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm405gpr.h b/arch/ppc/platforms/4xx/ibm405gpr.h
index 45412fb4368..e90c5dde01d 100644
--- a/arch/ppc/platforms/4xx/ibm405gpr.h
+++ b/arch/ppc/platforms/4xx/ibm405gpr.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm405gpr.h
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibm440ep.c b/arch/ppc/platforms/4xx/ibm440ep.c
index 65ac0b9c2d0..1fed6638c81 100644
--- a/arch/ppc/platforms/4xx/ibm440ep.c
+++ b/arch/ppc/platforms/4xx/ibm440ep.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440ep.c
- *
* PPC440EP I/O descriptions
*
* Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440ep.h b/arch/ppc/platforms/4xx/ibm440ep.h
index 97c80b8e3e1..61717e8a799 100644
--- a/arch/ppc/platforms/4xx/ibm440ep.h
+++ b/arch/ppc/platforms/4xx/ibm440ep.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440ep.h
- *
* PPC440EP definitions
*
* Wade Farnsworth <wfarnsworth@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gp.c b/arch/ppc/platforms/4xx/ibm440gp.c
index d926245e8b3..b67a72e5c6f 100644
--- a/arch/ppc/platforms/4xx/ibm440gp.c
+++ b/arch/ppc/platforms/4xx/ibm440gp.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440gp.c
- *
* PPC440GP I/O descriptions
*
* Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gp.h b/arch/ppc/platforms/4xx/ibm440gp.h
index ae1efc03b29..7b2763b6024 100644
--- a/arch/ppc/platforms/4xx/ibm440gp.h
+++ b/arch/ppc/platforms/4xx/ibm440gp.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440gp.h
- *
* PPC440GP definitions
*
* Roland Dreier <roland@digitalvampire.org>
diff --git a/arch/ppc/platforms/4xx/ibm440gx.c b/arch/ppc/platforms/4xx/ibm440gx.c
index d24c09ee7b1..685abffcb6c 100644
--- a/arch/ppc/platforms/4xx/ibm440gx.c
+++ b/arch/ppc/platforms/4xx/ibm440gx.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440gx.c
- *
* PPC440GX I/O descriptions
*
* Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440gx.h b/arch/ppc/platforms/4xx/ibm440gx.h
index 0b59d8dcd03..070a34efe1c 100644
--- a/arch/ppc/platforms/4xx/ibm440gx.h
+++ b/arch/ppc/platforms/4xx/ibm440gx.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ibm440gx.h
- *
* PPC440GX definitions
*
* Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/4xx/ibm440sp.c b/arch/ppc/platforms/4xx/ibm440sp.c
index 71a0117d359..de8f7ac5623 100644
--- a/arch/ppc/platforms/4xx/ibm440sp.c
+++ b/arch/ppc/platforms/4xx/ibm440sp.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440sp.c
- *
* PPC440SP I/O descriptions
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ibm440sp.h b/arch/ppc/platforms/4xx/ibm440sp.h
index c71e46a18b9..77e8bb22c52 100644
--- a/arch/ppc/platforms/4xx/ibm440sp.h
+++ b/arch/ppc/platforms/4xx/ibm440sp.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440sp.h
- *
* PPC440SP definitions
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ibmnp405h.c b/arch/ppc/platforms/4xx/ibmnp405h.c
index a477a78f490..f1dcb0ac15b 100644
--- a/arch/ppc/platforms/4xx/ibmnp405h.c
+++ b/arch/ppc/platforms/4xx/ibmnp405h.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmnp405h.c
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmnp405h.h b/arch/ppc/platforms/4xx/ibmnp405h.h
index e2c2b06128c..2c683f6aaa6 100644
--- a/arch/ppc/platforms/4xx/ibmnp405h.h
+++ b/arch/ppc/platforms/4xx/ibmnp405h.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmnp405h.h
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstb4.c b/arch/ppc/platforms/4xx/ibmstb4.c
index 7e33bb63544..799a2eccccc 100644
--- a/arch/ppc/platforms/4xx/ibmstb4.c
+++ b/arch/ppc/platforms/4xx/ibmstb4.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmstb4.c
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2000-2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstb4.h b/arch/ppc/platforms/4xx/ibmstb4.h
index 9f21d4c88a3..9de42659735 100644
--- a/arch/ppc/platforms/4xx/ibmstb4.h
+++ b/arch/ppc/platforms/4xx/ibmstb4.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmstb4.h
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2001 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstbx25.c b/arch/ppc/platforms/4xx/ibmstbx25.c
index b895b9cca57..090ddcbecc5 100644
--- a/arch/ppc/platforms/4xx/ibmstbx25.c
+++ b/arch/ppc/platforms/4xx/ibmstbx25.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmstbx25.c
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2000-2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/ibmstbx25.h b/arch/ppc/platforms/4xx/ibmstbx25.h
index 9a2efc366e9..6884a49d348 100644
--- a/arch/ppc/platforms/4xx/ibmstbx25.h
+++ b/arch/ppc/platforms/4xx/ibmstbx25.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibmstbx25.h
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/luan.c b/arch/ppc/platforms/4xx/luan.c
index 21d29132aeb..5c37de28e13 100644
--- a/arch/ppc/platforms/4xx/luan.c
+++ b/arch/ppc/platforms/4xx/luan.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/luan.c
- *
* Luan board specific routines
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/luan.h b/arch/ppc/platforms/4xx/luan.h
index bbe7d0766db..e0db6a810fe 100644
--- a/arch/ppc/platforms/4xx/luan.h
+++ b/arch/ppc/platforms/4xx/luan.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/luan.h
- *
* Luan board definitions
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ocotea.c b/arch/ppc/platforms/4xx/ocotea.c
index 4f355b6acab..f841972f1fa 100644
--- a/arch/ppc/platforms/4xx/ocotea.c
+++ b/arch/ppc/platforms/4xx/ocotea.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ocotea.c
- *
* Ocotea board specific routines
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ocotea.h b/arch/ppc/platforms/4xx/ocotea.h
index 33251153ac5..7c799a9ff82 100644
--- a/arch/ppc/platforms/4xx/ocotea.h
+++ b/arch/ppc/platforms/4xx/ocotea.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ocotea.h
- *
* Ocotea board definitions
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/platforms/4xx/ppc440spe.c b/arch/ppc/platforms/4xx/ppc440spe.c
index 6139a0b3393..1be5d1c8e26 100644
--- a/arch/ppc/platforms/4xx/ppc440spe.c
+++ b/arch/ppc/platforms/4xx/ppc440spe.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ppc440spe.c
- *
* PPC440SPe I/O descriptions
*
* Roland Dreier <rolandd@cisco.com>
diff --git a/arch/ppc/platforms/4xx/ppc440spe.h b/arch/ppc/platforms/4xx/ppc440spe.h
index 2216846973b..d3a620ddcde 100644
--- a/arch/ppc/platforms/4xx/ppc440spe.h
+++ b/arch/ppc/platforms/4xx/ppc440spe.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/ibm440spe.h
- *
* PPC440SPe definitions
*
* Roland Dreier <rolandd@cisco.com>
diff --git a/arch/ppc/platforms/4xx/redwood5.c b/arch/ppc/platforms/4xx/redwood5.c
index 611ac861804..53da2b4f7c2 100644
--- a/arch/ppc/platforms/4xx/redwood5.c
+++ b/arch/ppc/platforms/4xx/redwood5.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/redwood5.c
- *
* Support for the IBM redwood5 eval board file
*
* Author: Armin Kuster <akuster@mvista.com>
diff --git a/arch/ppc/platforms/4xx/redwood5.h b/arch/ppc/platforms/4xx/redwood5.h
index 264e34fb3fb..49edd481897 100644
--- a/arch/ppc/platforms/4xx/redwood5.h
+++ b/arch/ppc/platforms/4xx/redwood5.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/redwood5.h
- *
* Macros, definitions, and data structures specific to the IBM PowerPC
* STB03xxx "Redwood" evaluation board.
*
diff --git a/arch/ppc/platforms/4xx/redwood6.c b/arch/ppc/platforms/4xx/redwood6.c
index b1311669128..41b27d106fa 100644
--- a/arch/ppc/platforms/4xx/redwood6.c
+++ b/arch/ppc/platforms/4xx/redwood6.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/redwood6.c
- *
* Author: Armin Kuster <akuster@mvista.com>
*
* 2002 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/4xx/redwood6.h b/arch/ppc/platforms/4xx/redwood6.h
index 1814b9f5fc3..1edcbe5c51c 100644
--- a/arch/ppc/platforms/4xx/redwood6.h
+++ b/arch/ppc/platforms/4xx/redwood6.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/redwood6.h
- *
* Macros, definitions, and data structures specific to the IBM PowerPC
* STBx25xx "Redwood6" evaluation board.
*
diff --git a/arch/ppc/platforms/4xx/sycamore.c b/arch/ppc/platforms/4xx/sycamore.c
index 281b4a2ffb9..bab31eb3068 100644
--- a/arch/ppc/platforms/4xx/sycamore.c
+++ b/arch/ppc/platforms/4xx/sycamore.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/sycamore.c
- *
* Architecture- / platform-specific boot-time initialization code for
* IBM PowerPC 4xx based boards.
*
diff --git a/arch/ppc/platforms/4xx/sycamore.h b/arch/ppc/platforms/4xx/sycamore.h
index 1cd6c824fd6..dae01620227 100644
--- a/arch/ppc/platforms/4xx/sycamore.h
+++ b/arch/ppc/platforms/4xx/sycamore.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/sycamore.h
- *
* Sycamore board definitions
*
* Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/virtex-ii_pro.c b/arch/ppc/platforms/4xx/virtex-ii_pro.c
deleted file mode 100644
index 097cc9d5aca..00000000000
--- a/arch/ppc/platforms/4xx/virtex-ii_pro.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * arch/ppc/platforms/4xx/virtex-ii_pro.c
- *
- * Author: MontaVista Software, Inc.
- * source@mvista.com
- *
- * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
- * terms of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-#include <asm/ocp.h>
-#include "virtex-ii_pro.h"
-
-/* Have OCP take care of the serial ports. */
-struct ocp_def core_ocp[] = {
-#ifdef XPAR_UARTNS550_0_BASEADDR
- { .vendor = OCP_VENDOR_XILINX,
- .function = OCP_FUNC_16550,
- .index = 0,
- .paddr = XPAR_UARTNS550_0_BASEADDR,
- .irq = XPAR_INTC_0_UARTNS550_0_VEC_ID,
- .pm = OCP_CPM_NA
- },
-#ifdef XPAR_UARTNS550_1_BASEADDR
- { .vendor = OCP_VENDOR_XILINX,
- .function = OCP_FUNC_16550,
- .index = 1,
- .paddr = XPAR_UARTNS550_1_BASEADDR,
- .irq = XPAR_INTC_0_UARTNS550_1_VEC_ID,
- .pm = OCP_CPM_NA
- },
-#ifdef XPAR_UARTNS550_2_BASEADDR
- { .vendor = OCP_VENDOR_XILINX,
- .function = OCP_FUNC_16550,
- .index = 2,
- .paddr = XPAR_UARTNS550_2_BASEADDR,
- .irq = XPAR_INTC_0_UARTNS550_2_VEC_ID,
- .pm = OCP_CPM_NA
- },
-#ifdef XPAR_UARTNS550_3_BASEADDR
- { .vendor = OCP_VENDOR_XILINX,
- .function = OCP_FUNC_16550,
- .index = 3,
- .paddr = XPAR_UARTNS550_3_BASEADDR,
- .irq = XPAR_INTC_0_UARTNS550_3_VEC_ID,
- .pm = OCP_CPM_NA
- },
-#ifdef XPAR_UARTNS550_4_BASEADDR
-#error Edit this file to add more devices.
-#endif /* 4 */
-#endif /* 3 */
-#endif /* 2 */
-#endif /* 1 */
-#endif /* 0 */
- { .vendor = OCP_VENDOR_INVALID
- }
-};
diff --git a/arch/ppc/platforms/4xx/virtex-ii_pro.h b/arch/ppc/platforms/4xx/virtex-ii_pro.h
deleted file mode 100644
index 9014c488733..00000000000
--- a/arch/ppc/platforms/4xx/virtex-ii_pro.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * arch/ppc/platforms/4xx/virtex-ii_pro.h
- *
- * Include file that defines the Xilinx Virtex-II Pro processor
- *
- * Author: MontaVista Software, Inc.
- * source@mvista.com
- *
- * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
- * terms of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#ifdef __KERNEL__
-#ifndef __ASM_VIRTEXIIPRO_H__
-#define __ASM_VIRTEXIIPRO_H__
-
-#include <linux/config.h>
-#include <asm/xparameters.h>
-
-/* serial defines */
-
-#define RS_TABLE_SIZE 4 /* change this and add more devices below
- if you have more then 4 16x50 UARTs */
-
-#define BASE_BAUD (XPAR_UARTNS550_0_CLOCK_FREQ_HZ/16)
-
-/* The serial ports in the Virtex-II Pro have each I/O byte in the
- * LSByte of a word. This means that iomem_reg_shift needs to be 2 to
- * change the byte offsets into word offsets. In addition the base
- * addresses need to have 3 added to them to get to the LSByte.
- */
-#define STD_UART_OP(num) \
- { 0, BASE_BAUD, 0, XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
- ASYNC_BOOT_AUTOCONF, \
- .iomem_base = (u8 *)XPAR_UARTNS550_##num##_BASEADDR + 3, \
- .iomem_reg_shift = 2, \
- .io_type = SERIAL_IO_MEM},
-
-#if defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
-#define ML300_UART0 STD_UART_OP(0)
-#else
-#define ML300_UART0
-#endif
-
-#if defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
-#define ML300_UART1 STD_UART_OP(1)
-#else
-#define ML300_UART1
-#endif
-
-#if defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
-#define ML300_UART2 STD_UART_OP(2)
-#else
-#define ML300_UART2
-#endif
-
-#if defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
-#define ML300_UART3 STD_UART_OP(3)
-#else
-#define ML300_UART3
-#endif
-
-#if defined(XPAR_INTC_0_UARTNS550_4_VEC_ID)
-#error Edit this file to add more devices.
-#elif defined(XPAR_INTC_0_UARTNS550_3_VEC_ID)
-#define NR_SER_PORTS 4
-#elif defined(XPAR_INTC_0_UARTNS550_2_VEC_ID)
-#define NR_SER_PORTS 3
-#elif defined(XPAR_INTC_0_UARTNS550_1_VEC_ID)
-#define NR_SER_PORTS 2
-#elif defined(XPAR_INTC_0_UARTNS550_0_VEC_ID)
-#define NR_SER_PORTS 1
-#else
-#define NR_SER_PORTS 0
-#endif
-
-#if defined(CONFIG_UART0_TTYS0)
-#define SERIAL_PORT_DFNS \
- ML300_UART0 \
- ML300_UART1 \
- ML300_UART2 \
- ML300_UART3
-#endif
-
-#if defined(CONFIG_UART0_TTYS1)
-#define SERIAL_PORT_DFNS \
- ML300_UART1 \
- ML300_UART0 \
- ML300_UART2 \
- ML300_UART3
-#endif
-
-#define DCRN_CPMFR_BASE 0
-
-#include <asm/ibm405.h>
-
-#endif /* __ASM_VIRTEXIIPRO_H__ */
-#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/virtex.c b/arch/ppc/platforms/4xx/virtex.c
new file mode 100644
index 00000000000..133a8314719
--- /dev/null
+++ b/arch/ppc/platforms/4xx/virtex.c
@@ -0,0 +1,56 @@
+/*
+ * Virtex-II Pro & Virtex-4 FX common infrastructure
+ *
+ * Maintainer: Grant Likely <grant.likely@secretlab.ca>
+ *
+ * Copyright 2005 Secret Lab Technologies Ltd.
+ * Copyright 2005 General Dynamics Canada Ltd.
+ * Copyright 2005 Freescale Semiconductor Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/serial_8250.h>
+#include <asm/ppc_sys.h>
+#include <platforms/4xx/virtex.h>
+#include <platforms/4xx/xparameters/xparameters.h>
+
+#define XPAR_UART(num) { \
+ .mapbase = XPAR_UARTNS550_##num##_BASEADDR + 3, \
+ .irq = XPAR_INTC_0_UARTNS550_##num##_VEC_ID, \
+ .iotype = UPIO_MEM, \
+ .uartclk = XPAR_UARTNS550_##num##_CLOCK_FREQ_HZ, \
+ .flags = UPF_BOOT_AUTOCONF, \
+ .regshift = 2, \
+ }
+
+struct plat_serial8250_port serial_platform_data[] = {
+#ifdef XPAR_UARTNS550_0_BASEADDR
+ XPAR_UART(0),
+#endif
+#ifdef XPAR_UARTNS550_1_BASEADDR
+ XPAR_UART(1),
+#endif
+#ifdef XPAR_UARTNS550_2_BASEADDR
+ XPAR_UART(2),
+#endif
+#ifdef XPAR_UARTNS550_3_BASEADDR
+ XPAR_UART(3),
+#endif
+ { }, /* terminated by empty record */
+};
+
+struct platform_device ppc_sys_platform_devices[] = {
+ [VIRTEX_UART] = {
+ .name = "serial8250",
+ .id = 0,
+ .dev.platform_data = serial_platform_data,
+ },
+};
+
diff --git a/arch/ppc/platforms/4xx/virtex.h b/arch/ppc/platforms/4xx/virtex.h
new file mode 100644
index 00000000000..c14325dfd7b
--- /dev/null
+++ b/arch/ppc/platforms/4xx/virtex.h
@@ -0,0 +1,35 @@
+/*
+ * arch/ppc/platforms/4xx/virtex.h
+ *
+ * Include file that defines the Xilinx Virtex-II Pro processor
+ *
+ * Author: MontaVista Software, Inc.
+ * source@mvista.com
+ *
+ * 2002-2004 (c) MontaVista Software, Inc. This file is licensed under the
+ * terms of the GNU General Public License version 2. This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_VIRTEX_H__
+#define __ASM_VIRTEX_H__
+
+/* serial defines */
+
+#include <asm/ibm405.h>
+
+/* Ugly, ugly, ugly! BASE_BAUD defined here to keep 8250.c happy. */
+#if !defined(BASE_BAUD)
+ #define BASE_BAUD (0) /* dummy value; not used */
+#endif
+
+/* Device type enumeration for platform bus definitions */
+#ifndef __ASSEMBLY__
+enum ppc_sys_devices {
+ VIRTEX_UART, NUM_PPC_SYS_DEVS,
+};
+#endif
+
+#endif /* __ASM_VIRTEX_H__ */
+#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/walnut.c b/arch/ppc/platforms/4xx/walnut.c
index 74cb33182d9..6bd77902b9a 100644
--- a/arch/ppc/platforms/4xx/walnut.c
+++ b/arch/ppc/platforms/4xx/walnut.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/walnut.c
- *
* Architecture- / platform-specific boot-time initialization code for
* IBM PowerPC 4xx based boards. Adapted from original
* code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek
diff --git a/arch/ppc/platforms/4xx/walnut.h b/arch/ppc/platforms/4xx/walnut.h
index dcf2691698c..f13a577f0a4 100644
--- a/arch/ppc/platforms/4xx/walnut.h
+++ b/arch/ppc/platforms/4xx/walnut.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/walnut.h
- *
* Walnut board definitions
*
* Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.c b/arch/ppc/platforms/4xx/xilinx_ml300.c
index e90d97f64f7..d97a7f269f9 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.c
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/xilinx_ml300.c
- *
* Xilinx ML300 evaluation board initialization
*
* Author: MontaVista Software, Inc.
@@ -17,12 +15,14 @@
#include <linux/tty.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
+#include <linux/serial_8250.h>
#include <linux/serialP.h>
#include <asm/io.h>
#include <asm/machdep.h>
-#include <asm/ocp.h>
+#include <asm/ppc_sys.h>
-#include <platforms/4xx/virtex-ii_pro.h> /* for NR_SER_PORTS */
+#include <syslib/gen550.h>
+#include <platforms/4xx/xparameters/xparameters.h>
/*
* As an overview of how the following functions (platform_init,
@@ -54,6 +54,22 @@
* ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
*/
+/* Board specifications structures */
+struct ppc_sys_spec *cur_ppc_sys_spec;
+struct ppc_sys_spec ppc_sys_specs[] = {
+ {
+ /* Only one entry, always assume the same design */
+ .ppc_sys_name = "Xilinx ML300 Reference Design",
+ .mask = 0x00000000,
+ .value = 0x00000000,
+ .num_devices = 1,
+ .device_list = (enum ppc_sys_devices[])
+ {
+ VIRTEX_UART,
+ },
+ },
+};
+
#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
static volatile unsigned *powerdown_base =
@@ -80,28 +96,39 @@ ml300_map_io(void)
#endif
}
+/* Early serial support functions */
static void __init
+ml300_early_serial_init(int num, struct plat_serial8250_port *pdata)
+{
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+ struct uart_port serial_req;
+
+ memset(&serial_req, 0, sizeof(serial_req));
+ serial_req.mapbase = pdata->mapbase;
+ serial_req.membase = pdata->membase;
+ serial_req.irq = pdata->irq;
+ serial_req.uartclk = pdata->uartclk;
+ serial_req.regshift = pdata->regshift;
+ serial_req.iotype = pdata->iotype;
+ serial_req.flags = pdata->flags;
+ gen550_init(num, &serial_req);
+#endif
+}
+
+void __init
ml300_early_serial_map(void)
{
#ifdef CONFIG_SERIAL_8250
- struct serial_state old_ports[] = { SERIAL_PORT_DFNS };
- struct uart_port port;
- int i;
-
- /* Setup ioremapped serial port access */
- for (i = 0; i < ARRAY_SIZE(old_ports); i++ ) {
- memset(&port, 0, sizeof(port));
- port.membase = ioremap((phys_addr_t)(old_ports[i].iomem_base), 16);
- port.irq = old_ports[i].irq;
- port.uartclk = old_ports[i].baud_base * 16;
- port.regshift = old_ports[i].iomem_reg_shift;
- port.iotype = UPIO_MEM;
- port.flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST;
- port.line = i;
-
- if (early_serial_setup(&port) != 0) {
- printk("Early serial init of port %d failed\n", i);
- }
+ struct plat_serial8250_port *pdata;
+ int i = 0;
+
+ pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
+ while(pdata && pdata->flags)
+ {
+ pdata->membase = ioremap(pdata->mapbase, 0x100);
+ ml300_early_serial_init(i, pdata);
+ pdata++;
+ i++;
}
#endif /* CONFIG_SERIAL_8250 */
}
@@ -109,9 +136,8 @@ ml300_early_serial_map(void)
void __init
ml300_setup_arch(void)
{
- ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
-
ml300_early_serial_map();
+ ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
/* Identify the system */
printk(KERN_INFO "Xilinx Virtex-II Pro port\n");
@@ -131,6 +157,8 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
{
ppc4xx_init(r3, r4, r5, r6, r7);
+ identify_ppc_sys_by_id(mfspr(SPRN_PVR));
+
ppc_md.setup_arch = ml300_setup_arch;
ppc_md.setup_io_mappings = ml300_map_io;
ppc_md.init_IRQ = ml300_init_irq;
diff --git a/arch/ppc/platforms/4xx/xilinx_ml300.h b/arch/ppc/platforms/4xx/xilinx_ml300.h
index f8c58841233..3d57332ba82 100644
--- a/arch/ppc/platforms/4xx/xilinx_ml300.h
+++ b/arch/ppc/platforms/4xx/xilinx_ml300.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/xilinx_ml300.h
- *
* Include file that defines the Xilinx ML300 evaluation board
*
* Author: MontaVista Software, Inc.
@@ -16,7 +14,7 @@
#define __ASM_XILINX_ML300_H__
/* ML300 has a Xilinx Virtex-II Pro processor */
-#include <platforms/4xx/virtex-ii_pro.h>
+#include <platforms/4xx/virtex.h>
#ifndef __ASSEMBLY__
@@ -41,7 +39,7 @@ typedef struct board_info {
#define PPC4xx_ONB_IO_VADDR 0u
#define PPC4xx_ONB_IO_SIZE 0u
-#define PPC4xx_MACHINE_NAME "Xilinx ML300"
+#define PPC4xx_MACHINE_NAME "Xilinx ML300 Reference System"
#endif /* __ASM_XILINX_ML300_H__ */
#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.c b/arch/ppc/platforms/4xx/xilinx_ml403.c
new file mode 100644
index 00000000000..4c0c7e4c111
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.c
@@ -0,0 +1,177 @@
+/*
+ * arch/ppc/platforms/4xx/xilinx_ml403.c
+ *
+ * Xilinx ML403 evaluation board initialization
+ *
+ * Author: Grant Likely <grant.likely@secretlab.ca>
+ *
+ * 2005 (c) Secret Lab Technologies Ltd.
+ * 2002-2004 (c) MontaVista Software, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/tty.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/serial_8250.h>
+#include <linux/serialP.h>
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/ppc_sys.h>
+
+#include <syslib/gen550.h>
+#include <platforms/4xx/xparameters/xparameters.h>
+
+/*
+ * As an overview of how the following functions (platform_init,
+ * ml403_map_io, ml403_setup_arch and ml403_init_IRQ) fit into the
+ * kernel startup procedure, here's a call tree:
+ *
+ * start_here arch/ppc/kernel/head_4xx.S
+ * early_init arch/ppc/kernel/setup.c
+ * machine_init arch/ppc/kernel/setup.c
+ * platform_init this file
+ * ppc4xx_init arch/ppc/syslib/ppc4xx_setup.c
+ * parse_bootinfo
+ * find_bootinfo
+ * "setup some default ppc_md pointers"
+ * MMU_init arch/ppc/mm/init.c
+ * *ppc_md.setup_io_mappings == ml403_map_io this file
+ * ppc4xx_map_io arch/ppc/syslib/ppc4xx_setup.c
+ * start_kernel init/main.c
+ * setup_arch arch/ppc/kernel/setup.c
+ * #if defined(CONFIG_KGDB)
+ * *ppc_md.kgdb_map_scc() == gen550_kgdb_map_scc
+ * #endif
+ * *ppc_md.setup_arch == ml403_setup_arch this file
+ * ppc4xx_setup_arch arch/ppc/syslib/ppc4xx_setup.c
+ * ppc4xx_find_bridges arch/ppc/syslib/ppc405_pci.c
+ * init_IRQ arch/ppc/kernel/irq.c
+ * *ppc_md.init_IRQ == ml403_init_IRQ this file
+ * ppc4xx_init_IRQ arch/ppc/syslib/ppc4xx_setup.c
+ * ppc4xx_pic_init arch/ppc/syslib/xilinx_pic.c
+ */
+
+/* Board specifications structures */
+struct ppc_sys_spec *cur_ppc_sys_spec;
+struct ppc_sys_spec ppc_sys_specs[] = {
+ {
+ /* Only one entry, always assume the same design */
+ .ppc_sys_name = "Xilinx ML403 Reference Design",
+ .mask = 0x00000000,
+ .value = 0x00000000,
+ .num_devices = 1,
+ .device_list = (enum ppc_sys_devices[])
+ {
+ VIRTEX_UART,
+ },
+ },
+};
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+
+static volatile unsigned *powerdown_base =
+ (volatile unsigned *) XPAR_POWER_0_POWERDOWN_BASEADDR;
+
+static void
+xilinx_power_off(void)
+{
+ local_irq_disable();
+ out_be32(powerdown_base, XPAR_POWER_0_POWERDOWN_VALUE);
+ while (1) ;
+}
+#endif
+
+void __init
+ml403_map_io(void)
+{
+ ppc4xx_map_io();
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+ powerdown_base = ioremap((unsigned long) powerdown_base,
+ XPAR_POWER_0_POWERDOWN_HIGHADDR -
+ XPAR_POWER_0_POWERDOWN_BASEADDR + 1);
+#endif
+}
+
+/* Early serial support functions */
+static void __init
+ml403_early_serial_init(int num, struct plat_serial8250_port *pdata)
+{
+#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
+ struct uart_port serial_req;
+
+ memset(&serial_req, 0, sizeof(serial_req));
+ serial_req.mapbase = pdata->mapbase;
+ serial_req.membase = pdata->membase;
+ serial_req.irq = pdata->irq;
+ serial_req.uartclk = pdata->uartclk;
+ serial_req.regshift = pdata->regshift;
+ serial_req.iotype = pdata->iotype;
+ serial_req.flags = pdata->flags;
+ gen550_init(num, &serial_req);
+#endif
+}
+
+void __init
+ml403_early_serial_map(void)
+{
+#ifdef CONFIG_SERIAL_8250
+ struct plat_serial8250_port *pdata;
+ int i = 0;
+
+ pdata = (struct plat_serial8250_port *) ppc_sys_get_pdata(VIRTEX_UART);
+ while(pdata && pdata->flags)
+ {
+ pdata->membase = ioremap(pdata->mapbase, 0x100);
+ ml403_early_serial_init(i, pdata);
+ pdata++;
+ i++;
+ }
+#endif /* CONFIG_SERIAL_8250 */
+}
+
+void __init
+ml403_setup_arch(void)
+{
+ ml403_early_serial_map();
+ ppc4xx_setup_arch(); /* calls ppc4xx_find_bridges() */
+
+ /* Identify the system */
+ printk(KERN_INFO "Xilinx ML403 Reference System (Virtex-4 FX)\n");
+}
+
+/* Called after board_setup_irq from ppc4xx_init_IRQ(). */
+void __init
+ml403_init_irq(void)
+{
+ ppc4xx_init_IRQ();
+}
+
+void __init
+platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+ unsigned long r6, unsigned long r7)
+{
+ ppc4xx_init(r3, r4, r5, r6, r7);
+
+ identify_ppc_sys_by_id(mfspr(SPRN_PVR));
+
+ ppc_md.setup_arch = ml403_setup_arch;
+ ppc_md.setup_io_mappings = ml403_map_io;
+ ppc_md.init_IRQ = ml403_init_irq;
+
+#if defined(XPAR_POWER_0_POWERDOWN_BASEADDR)
+ ppc_md.power_off = xilinx_power_off;
+#endif
+
+#ifdef CONFIG_KGDB
+ ppc_md.early_serial_map = ml403_early_serial_map;
+#endif
+}
+
diff --git a/arch/ppc/platforms/4xx/xilinx_ml403.h b/arch/ppc/platforms/4xx/xilinx_ml403.h
new file mode 100644
index 00000000000..47359695990
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xilinx_ml403.h
@@ -0,0 +1,49 @@
+/*
+ * arch/ppc/platforms/4xx/xilinx_ml403.h
+ *
+ * Include file that defines the Xilinx ML403 reference design
+ *
+ * Author: Grant Likely <grant.likely@secretlab.ca>
+ *
+ * 2005 (c) Secret Lab Technologies Ltd.
+ * 2002-2004 (c) MontaVista Software, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#ifdef __KERNEL__
+#ifndef __ASM_XILINX_ML403_H__
+#define __ASM_XILINX_ML403_H__
+
+/* ML403 has a Xilinx Virtex-4 FPGA with a PPC405 hard core */
+#include <platforms/4xx/virtex.h>
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+typedef struct board_info {
+ unsigned int bi_memsize; /* DRAM installed, in bytes */
+ unsigned char bi_enetaddr[6]; /* Local Ethernet MAC address */
+ unsigned int bi_intfreq; /* Processor speed, in Hz */
+ unsigned int bi_busfreq; /* PLB Bus speed, in Hz */
+ unsigned int bi_pci_busfreq; /* PCI Bus speed, in Hz */
+} bd_t;
+
+/* Some 4xx parts use a different timebase frequency from the internal clock.
+*/
+#define bi_tbfreq bi_intfreq
+
+#endif /* !__ASSEMBLY__ */
+
+/* We don't need anything mapped. Size of zero will accomplish that. */
+#define PPC4xx_ONB_IO_PADDR 0u
+#define PPC4xx_ONB_IO_VADDR 0u
+#define PPC4xx_ONB_IO_SIZE 0u
+
+#define PPC4xx_MACHINE_NAME "Xilinx ML403 Reference Design"
+
+#endif /* __ASM_XILINX_ML403_H__ */
+#endif /* __KERNEL__ */
diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters.h b/arch/ppc/platforms/4xx/xparameters/xparameters.h
new file mode 100644
index 00000000000..4cf21f25635
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters.h
@@ -0,0 +1,37 @@
+/*
+ * include/asm-ppc/xparameters.h
+ *
+ * This file includes the correct xparameters.h for the CONFIG'ed board plus
+ * fixups to translate board specific XPAR values to a common set of names
+ *
+ * Author: MontaVista Software, Inc.
+ * source@mvista.com
+ *
+ * 2004 (c) MontaVista Software, Inc. This file is licensed under the terms
+ * of the GNU General Public License version 2. This program is licensed
+ * "as is" without any warranty of any kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+
+#if defined(CONFIG_XILINX_ML300)
+ #include "xparameters_ml300.h"
+#elif defined(CONFIG_XILINX_ML403)
+ #include "xparameters_ml403.h"
+#else
+ /* Add other board xparameter includes here before the #else */
+ #error No xparameters_*.h file included
+#endif
+
+#ifndef SERIAL_PORT_DFNS
+ /* zImage serial port definitions */
+ #define RS_TABLE_SIZE 1
+ #define SERIAL_PORT_DFNS { \
+ .baud_base = XPAR_UARTNS550_0_CLOCK_FREQ_HZ/16, \
+ .irq = XPAR_INTC_0_UARTNS550_0_VEC_ID, \
+ .flags = ASYNC_BOOT_AUTOCONF, \
+ .iomem_base = (u8 *)XPAR_UARTNS550_0_BASEADDR + 3, \
+ .iomem_reg_shift = 2, \
+ .io_type = SERIAL_IO_MEM, \
+ },
+#endif
diff --git a/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h b/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h
new file mode 100644
index 00000000000..5cacdcb3964
--- /dev/null
+++ b/arch/ppc/platforms/4xx/xparameters/xparameters_ml403.h
@@ -0,0 +1,243 @@
+
+/*******************************************************************
+*
+* CAUTION: This file is automatically generated by libgen.
+* Version: Xilinx EDK 7.1.2 EDK_H.12.5.1
+* DO NOT EDIT.
+*
+* Copyright (c) 2005 Xilinx, Inc. All rights reserved.
+*
+* Description: Driver parameters
+*
+*******************************************************************/
+
+#define XPAR_PLB_BRAM_IF_CNTLR_0_BASEADDR 0xFFFF0000
+#define XPAR_PLB_BRAM_IF_CNTLR_0_HIGHADDR 0xFFFFFFFF
+
+/******************************************************************/
+
+#define XPAR_OPB_EMC_0_MEM0_BASEADDR 0x20000000
+#define XPAR_OPB_EMC_0_MEM0_HIGHADDR 0x200FFFFF
+#define XPAR_OPB_EMC_0_MEM1_BASEADDR 0x28000000
+#define XPAR_OPB_EMC_0_MEM1_HIGHADDR 0x287FFFFF
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_BASEADDR 0xA6000000
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_HIGHADDR 0xA60000FF
+#define XPAR_OPB_EMC_USB_0_MEM0_BASEADDR 0xA5000000
+#define XPAR_OPB_EMC_USB_0_MEM0_HIGHADDR 0xA50000FF
+#define XPAR_PLB_DDR_0_MEM0_BASEADDR 0x00000000
+#define XPAR_PLB_DDR_0_MEM0_HIGHADDR 0x0FFFFFFF
+
+/******************************************************************/
+
+#define XPAR_XEMAC_NUM_INSTANCES 1
+#define XPAR_OPB_ETHERNET_0_BASEADDR 0x60000000
+#define XPAR_OPB_ETHERNET_0_HIGHADDR 0x60003FFF
+#define XPAR_OPB_ETHERNET_0_DEVICE_ID 0
+#define XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST 1
+#define XPAR_OPB_ETHERNET_0_DMA_PRESENT 1
+#define XPAR_OPB_ETHERNET_0_MII_EXIST 1
+
+/******************************************************************/
+
+#define XPAR_XUARTNS550_NUM_INSTANCES 1
+#define XPAR_XUARTNS550_CLOCK_HZ 100000000
+#define XPAR_OPB_UART16550_0_BASEADDR 0xA0000000
+#define XPAR_OPB_UART16550_0_HIGHADDR 0xA0001FFF
+#define XPAR_OPB_UART16550_0_DEVICE_ID 0
+
+/******************************************************************/
+
+#define XPAR_XGPIO_NUM_INSTANCES 3
+#define XPAR_OPB_GPIO_0_BASEADDR 0x90000000
+#define XPAR_OPB_GPIO_0_HIGHADDR 0x900001FF
+#define XPAR_OPB_GPIO_0_DEVICE_ID 0
+#define XPAR_OPB_GPIO_0_INTERRUPT_PRESENT 0
+#define XPAR_OPB_GPIO_0_IS_DUAL 1
+#define XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR 0x90001000
+#define XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR 0x900011FF
+#define XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID 1
+#define XPAR_OPB_GPIO_EXP_HDR_0_INTERRUPT_PRESENT 0
+#define XPAR_OPB_GPIO_EXP_HDR_0_IS_DUAL 1
+#define XPAR_OPB_GPIO_CHAR_LCD_0_BASEADDR 0x90002000
+#define XPAR_OPB_GPIO_CHAR_LCD_0_HIGHADDR 0x900021FF
+#define XPAR_OPB_GPIO_CHAR_LCD_0_DEVICE_ID 2
+#define XPAR_OPB_GPIO_CHAR_LCD_0_INTERRUPT_PRESENT 0
+#define XPAR_OPB_GPIO_CHAR_LCD_0_IS_DUAL 0
+
+/******************************************************************/
+
+#define XPAR_XPS2_NUM_INSTANCES 2
+#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0 0
+#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0 0xA9000000
+#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0 (0xA9000000+0x3F)
+#define XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1 1
+#define XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1 (0xA9000000+0x1000)
+#define XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1 (0xA9000000+0x103F)
+
+/******************************************************************/
+
+#define XPAR_XIIC_NUM_INSTANCES 1
+#define XPAR_OPB_IIC_0_BASEADDR 0xA8000000
+#define XPAR_OPB_IIC_0_HIGHADDR 0xA80001FF
+#define XPAR_OPB_IIC_0_DEVICE_ID 0
+#define XPAR_OPB_IIC_0_TEN_BIT_ADR 0
+#define XPAR_OPB_IIC_0_GPO_WIDTH 1
+
+/******************************************************************/
+
+#define XPAR_INTC_MAX_NUM_INTR_INPUTS 10
+#define XPAR_XINTC_HAS_IPR 1
+#define XPAR_XINTC_USE_DCR 0
+#define XPAR_XINTC_NUM_INSTANCES 1
+#define XPAR_OPB_INTC_0_BASEADDR 0xD1000FC0
+#define XPAR_OPB_INTC_0_HIGHADDR 0xD1000FDF
+#define XPAR_OPB_INTC_0_DEVICE_ID 0
+#define XPAR_OPB_INTC_0_KIND_OF_INTR 0x00000000
+
+/******************************************************************/
+
+#define XPAR_INTC_SINGLE_BASEADDR 0xD1000FC0
+#define XPAR_INTC_SINGLE_HIGHADDR 0xD1000FDF
+#define XPAR_INTC_SINGLE_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
+#define XPAR_OPB_ETHERNET_0_IP2INTC_IRPT_MASK 0X000001
+#define XPAR_OPB_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR 0
+#define XPAR_SYSTEM_USB_HPI_INT_MASK 0X000002
+#define XPAR_OPB_INTC_0_SYSTEM_USB_HPI_INT_INTR 1
+#define XPAR_MISC_LOGIC_0_PHY_MII_INT_MASK 0X000004
+#define XPAR_OPB_INTC_0_MISC_LOGIC_0_PHY_MII_INT_INTR 2
+#define XPAR_OPB_SYSACE_0_SYSACE_IRQ_MASK 0X000008
+#define XPAR_OPB_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR 3
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_RECORD_INTERRUPT_MASK 0X000010
+#define XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_0_RECORD_INTERRUPT_INTR 4
+#define XPAR_OPB_AC97_CONTROLLER_REF_0_PLAYBACK_INTERRUPT_MASK 0X000020
+#define XPAR_OPB_INTC_0_OPB_AC97_CONTROLLER_REF_0_PLAYBACK_INTERRUPT_INTR 5
+#define XPAR_OPB_IIC_0_IP2INTC_IRPT_MASK 0X000040
+#define XPAR_OPB_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR 6
+#define XPAR_OPB_PS2_DUAL_REF_0_SYS_INTR2_MASK 0X000080
+#define XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR 7
+#define XPAR_OPB_PS2_DUAL_REF_0_SYS_INTR1_MASK 0X000100
+#define XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR 8
+#define XPAR_OPB_UART16550_0_IP2INTC_IRPT_MASK 0X000200
+#define XPAR_OPB_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR 9
+
+/******************************************************************/
+
+#define XPAR_XTFT_NUM_INSTANCES 1
+#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR 0xD0000200
+#define XPAR_PLB_TFT_CNTLR_REF_0_DCR_HIGHADDR 0xD0000207
+#define XPAR_PLB_TFT_CNTLR_REF_0_DEVICE_ID 0
+
+/******************************************************************/
+
+#define XPAR_XSYSACE_MEM_WIDTH 16
+#define XPAR_XSYSACE_NUM_INSTANCES 1
+#define XPAR_OPB_SYSACE_0_BASEADDR 0xCF000000
+#define XPAR_OPB_SYSACE_0_HIGHADDR 0xCF0001FF
+#define XPAR_OPB_SYSACE_0_DEVICE_ID 0
+#define XPAR_OPB_SYSACE_0_MEM_WIDTH 16
+
+/******************************************************************/
+
+#define XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ 300000000
+
+/******************************************************************/
+
+
+/******************************************************************/
+
+/* Linux Redefines */
+
+/******************************************************************/
+
+#define XPAR_UARTNS550_0_BASEADDR (XPAR_OPB_UART16550_0_BASEADDR+0x1000)
+#define XPAR_UARTNS550_0_HIGHADDR XPAR_OPB_UART16550_0_HIGHADDR
+#define XPAR_UARTNS550_0_CLOCK_FREQ_HZ XPAR_XUARTNS550_CLOCK_HZ
+#define XPAR_UARTNS550_0_DEVICE_ID XPAR_OPB_UART16550_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_INTC_0_BASEADDR XPAR_OPB_INTC_0_BASEADDR
+#define XPAR_INTC_0_HIGHADDR XPAR_OPB_INTC_0_HIGHADDR
+#define XPAR_INTC_0_KIND_OF_INTR XPAR_OPB_INTC_0_KIND_OF_INTR
+#define XPAR_INTC_0_DEVICE_ID XPAR_OPB_INTC_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_INTC_0_EMAC_0_VEC_ID XPAR_OPB_INTC_0_OPB_ETHERNET_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_SYSACE_0_VEC_ID XPAR_OPB_INTC_0_OPB_SYSACE_0_SYSACE_IRQ_INTR
+#define XPAR_INTC_0_IIC_0_VEC_ID XPAR_OPB_INTC_0_OPB_IIC_0_IP2INTC_IRPT_INTR
+#define XPAR_INTC_0_PS2_1_VEC_ID XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR2_INTR
+#define XPAR_INTC_0_PS2_0_VEC_ID XPAR_OPB_INTC_0_OPB_PS2_DUAL_REF_0_SYS_INTR1_INTR
+#define XPAR_INTC_0_UARTNS550_0_VEC_ID XPAR_OPB_INTC_0_OPB_UART16550_0_IP2INTC_IRPT_INTR
+
+/******************************************************************/
+
+#define XPAR_TFT_0_BASEADDR XPAR_PLB_TFT_CNTLR_REF_0_DCR_BASEADDR
+
+/******************************************************************/
+
+#define XPAR_EMAC_0_BASEADDR XPAR_OPB_ETHERNET_0_BASEADDR
+#define XPAR_EMAC_0_HIGHADDR XPAR_OPB_ETHERNET_0_HIGHADDR
+#define XPAR_EMAC_0_DMA_PRESENT XPAR_OPB_ETHERNET_0_DMA_PRESENT
+#define XPAR_EMAC_0_MII_EXIST XPAR_OPB_ETHERNET_0_MII_EXIST
+#define XPAR_EMAC_0_ERR_COUNT_EXIST XPAR_OPB_ETHERNET_0_ERR_COUNT_EXIST
+#define XPAR_EMAC_0_DEVICE_ID XPAR_OPB_ETHERNET_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_GPIO_0_BASEADDR XPAR_OPB_GPIO_0_BASEADDR_0
+#define XPAR_GPIO_0_HIGHADDR XPAR_OPB_GPIO_0_HIGHADDR_0
+#define XPAR_GPIO_0_DEVICE_ID XPAR_OPB_GPIO_0_DEVICE_ID_0
+#define XPAR_GPIO_1_BASEADDR XPAR_OPB_GPIO_0_BASEADDR_1
+#define XPAR_GPIO_1_HIGHADDR XPAR_OPB_GPIO_0_HIGHADDR_1
+#define XPAR_GPIO_1_DEVICE_ID XPAR_OPB_GPIO_0_DEVICE_ID_1
+#define XPAR_GPIO_2_BASEADDR XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR_0
+#define XPAR_GPIO_2_HIGHADDR XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR_0
+#define XPAR_GPIO_2_DEVICE_ID XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID_0
+#define XPAR_GPIO_3_BASEADDR XPAR_OPB_GPIO_EXP_HDR_0_BASEADDR_1
+#define XPAR_GPIO_3_HIGHADDR XPAR_OPB_GPIO_EXP_HDR_0_HIGHADDR_1
+#define XPAR_GPIO_3_DEVICE_ID XPAR_OPB_GPIO_EXP_HDR_0_DEVICE_ID_1
+#define XPAR_GPIO_4_BASEADDR XPAR_OPB_GPIO_CHAR_LCD_0_BASEADDR
+#define XPAR_GPIO_4_HIGHADDR XPAR_OPB_GPIO_CHAR_LCD_0_HIGHADDR
+#define XPAR_GPIO_4_DEVICE_ID XPAR_OPB_GPIO_CHAR_LCD_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_PS2_0_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_0
+#define XPAR_PS2_0_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_0
+#define XPAR_PS2_0_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_0
+#define XPAR_PS2_1_BASEADDR XPAR_OPB_PS2_DUAL_REF_0_BASEADDR_1
+#define XPAR_PS2_1_HIGHADDR XPAR_OPB_PS2_DUAL_REF_0_HIGHADDR_1
+#define XPAR_PS2_1_DEVICE_ID XPAR_OPB_PS2_DUAL_REF_0_DEVICE_ID_1
+
+/******************************************************************/
+
+#define XPAR_SYSACE_0_BASEADDR XPAR_OPB_SYSACE_0_BASEADDR
+#define XPAR_SYSACE_0_HIGHADDR XPAR_OPB_SYSACE_0_HIGHADDR
+#define XPAR_SYSACE_0_DEVICE_ID XPAR_OPB_SYSACE_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_IIC_0_BASEADDR XPAR_OPB_IIC_0_BASEADDR
+#define XPAR_IIC_0_HIGHADDR XPAR_OPB_IIC_0_HIGHADDR
+#define XPAR_IIC_0_TEN_BIT_ADR XPAR_OPB_IIC_0_TEN_BIT_ADR
+#define XPAR_IIC_0_DEVICE_ID XPAR_OPB_IIC_0_DEVICE_ID
+
+/******************************************************************/
+
+#define XPAR_PLB_CLOCK_FREQ_HZ 100000000
+#define XPAR_CORE_CLOCK_FREQ_HZ XPAR_CPU_PPC405_CORE_CLOCK_FREQ_HZ
+#define XPAR_DDR_0_SIZE 0x4000000
+
+/******************************************************************/
+
+#define XPAR_PERSISTENT_0_IIC_0_BASEADDR 0x00000400
+#define XPAR_PERSISTENT_0_IIC_0_HIGHADDR 0x000007FF
+#define XPAR_PERSISTENT_0_IIC_0_EEPROMADDR 0xA0
+
+/******************************************************************/
+
+#define XPAR_PCI_0_CLOCK_FREQ_HZ 0
+
+/******************************************************************/
+
diff --git a/arch/ppc/platforms/4xx/yucca.c b/arch/ppc/platforms/4xx/yucca.c
index b065b8babcd..f287dcdbffc 100644
--- a/arch/ppc/platforms/4xx/yucca.c
+++ b/arch/ppc/platforms/4xx/yucca.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/yucca.c
- *
* Yucca board specific routines
*
* Roland Dreier <rolandd@cisco.com> (based on luan.c by Matt Porter)
diff --git a/arch/ppc/platforms/4xx/yucca.h b/arch/ppc/platforms/4xx/yucca.h
index 01a4afea151..7ae23012237 100644
--- a/arch/ppc/platforms/4xx/yucca.h
+++ b/arch/ppc/platforms/4xx/yucca.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/4xx/yucca.h
- *
* Yucca board definitions
*
* Roland Dreier <rolandd@cisco.com> (based on luan.h by Matt Porter)
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.c b/arch/ppc/platforms/83xx/mpc834x_sys.c
index 1a659bbc186..11626dd9090 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.c
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/83xx/mpc834x_sys.c
- *
* MPC834x SYS board specific routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/83xx/mpc834x_sys.h b/arch/ppc/platforms/83xx/mpc834x_sys.h
index 2e514d316fb..6727bbdc36e 100644
--- a/arch/ppc/platforms/83xx/mpc834x_sys.h
+++ b/arch/ppc/platforms/83xx/mpc834x_sys.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/83xx/mpc834x_sys.h
- *
* MPC834X SYS common board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -25,7 +23,7 @@
#define VIRT_IMMRBAR ((uint)0xfe000000)
#define BCSR_PHYS_ADDR ((uint)0xf8000000)
-#define BCSR_SIZE ((uint)(128 * 1024))
+#define BCSR_SIZE ((uint)(32 * 1024))
#define BCSR_MISC_REG2_OFF 0x07
#define BCSR_MISC_REG2_PORESET 0x01
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.c b/arch/ppc/platforms/85xx/mpc8540_ads.c
index 408d64f18e1..9b014df516b 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc8540_ads.c
- *
* MPC8540ADS board specific routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8540_ads.h b/arch/ppc/platforms/85xx/mpc8540_ads.h
index e48ca3a9739..0b5e7ff856f 100644
--- a/arch/ppc/platforms/85xx/mpc8540_ads.h
+++ b/arch/ppc/platforms/85xx/mpc8540_ads.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc8540_ads.h
- *
* MPC8540ADS board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8555_cds.h b/arch/ppc/platforms/85xx/mpc8555_cds.h
index 1a8e6c67355..9754dbd5d18 100644
--- a/arch/ppc/platforms/85xx/mpc8555_cds.h
+++ b/arch/ppc/platforms/85xx/mpc8555_cds.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/mpc8555_cds.h
- *
* MPC8555CDS board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.c b/arch/ppc/platforms/85xx/mpc8560_ads.c
index 442c7ff195d..0cb2e86470e 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.c
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc8560_ads.c
- *
* MPC8560ADS board specific routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc8560_ads.h b/arch/ppc/platforms/85xx/mpc8560_ads.h
index 143ae7eefa7..c2247c21fc5 100644
--- a/arch/ppc/platforms/85xx/mpc8560_ads.h
+++ b/arch/ppc/platforms/85xx/mpc8560_ads.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/mpc8560_ads.h
- *
* MPC8540ADS board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
index 17ce48fe350..8fd9d763f58 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc85xx_ads_common.c
- *
* MPC85xx ADS board common routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_ads_common.h b/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
index 198a6a02cde..de8d41aafe1 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
+++ b/arch/ppc/platforms/85xx/mpc85xx_ads_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc85xx_ads_common.h
- *
* MPC85XX ADS common board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
index 1801ab392e2..c9e0aeeca3d 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platform/85xx/mpc85xx_cds_common.c
- *
* MPC85xx CDS board specific routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.h b/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
index 5b588cfd0e4..62df54f61ae 100644
--- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
+++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc85xx_cds_common.h
- *
* MPC85xx CDS board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/85xx/sbc8560.c b/arch/ppc/platforms/85xx/sbc8560.c
index 8a72221f816..b73778ecf82 100644
--- a/arch/ppc/platforms/85xx/sbc8560.c
+++ b/arch/ppc/platforms/85xx/sbc8560.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/sbc8560.c
- *
* Wind River SBC8560 board specific routines
*
* Maintainer: Kumar Gala
diff --git a/arch/ppc/platforms/85xx/sbc8560.h b/arch/ppc/platforms/85xx/sbc8560.h
index 5e1b00c77da..44ffaa2d2c8 100644
--- a/arch/ppc/platforms/85xx/sbc8560.h
+++ b/arch/ppc/platforms/85xx/sbc8560.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/sbc8560.h
- *
* Wind River SBC8560 board definitions
*
* Copyright 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/sbc85xx.c b/arch/ppc/platforms/85xx/sbc85xx.c
index c02f110219f..d3ff280510f 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.c
+++ b/arch/ppc/platforms/85xx/sbc85xx.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platform/85xx/sbc85xx.c
- *
* WindRiver PowerQUICC III SBC85xx board common routines
*
* Copyright 2002, 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/sbc85xx.h b/arch/ppc/platforms/85xx/sbc85xx.h
index 7af93c691a6..5dd8b6a98c9 100644
--- a/arch/ppc/platforms/85xx/sbc85xx.h
+++ b/arch/ppc/platforms/85xx/sbc85xx.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/sbc85xx.h
- *
* WindRiver PowerQUICC III SBC85xx common board definitions
*
* Copyright 2003 Motorola Inc.
diff --git a/arch/ppc/platforms/85xx/stx_gp3.c b/arch/ppc/platforms/85xx/stx_gp3.c
index 061bb7cf2d9..8d7baa9a397 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.c
+++ b/arch/ppc/platforms/85xx/stx_gp3.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/stx_gp3.c
- *
* STx GP3 board specific routines
*
* Dan Malek <dan@embeddededge.com>
diff --git a/arch/ppc/platforms/85xx/stx_gp3.h b/arch/ppc/platforms/85xx/stx_gp3.h
index 2f25b519515..3f71f8f5937 100644
--- a/arch/ppc/platforms/85xx/stx_gp3.h
+++ b/arch/ppc/platforms/85xx/stx_gp3.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/stx8560_gp3.h
- *
* STx GP3 board definitions
*
* Dan Malek (dan@embeddededge.com)
diff --git a/arch/ppc/platforms/85xx/tqm85xx.c b/arch/ppc/platforms/85xx/tqm85xx.c
index a5e38ba6273..00af132262b 100644
--- a/arch/ppc/platforms/85xx/tqm85xx.c
+++ b/arch/ppc/platforms/85xx/tqm85xx.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/tqm85xx.c
- *
* TQM85xx (40/41/55/60) board specific routines
*
* Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/85xx/tqm85xx.h b/arch/ppc/platforms/85xx/tqm85xx.h
index 3775eb363fd..612d80504f9 100644
--- a/arch/ppc/platforms/85xx/tqm85xx.h
+++ b/arch/ppc/platforms/85xx/tqm85xx.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/tqm85xx.h
- *
* TQM85xx (40/41/55/60) board definitions
*
* Copyright (c) 2005 DENX Software Engineering
diff --git a/arch/ppc/platforms/Makefile b/arch/ppc/platforms/Makefile
index 51430e294b3..e8b91a33ce9 100644
--- a/arch/ppc/platforms/Makefile
+++ b/arch/ppc/platforms/Makefile
@@ -37,6 +37,9 @@ obj-$(CONFIG_SBC82xx) += sbc82xx.o
obj-$(CONFIG_SPRUCE) += spruce.o
obj-$(CONFIG_LITE5200) += lite5200.o
obj-$(CONFIG_EV64360) += ev64360.o
+obj-$(CONFIG_MPC86XADS) += mpc866ads_setup.o
+obj-$(CONFIG_MPC885ADS) += mpc885ads_setup.o
+obj-$(CONFIG_ADS8272) += mpc8272ads_setup.o
ifeq ($(CONFIG_SMP),y)
obj-$(CONFIG_PPC_CHRP) += chrp_smp.o
diff --git a/arch/ppc/platforms/apus_setup.c b/arch/ppc/platforms/apus_setup.c
index c42c50073da..fe0cdc04d43 100644
--- a/arch/ppc/platforms/apus_setup.c
+++ b/arch/ppc/platforms/apus_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/apus_setup.c
- *
* Copyright (C) 1998, 1999 Jesper Skov
*
* Basically what is needed to replace functionality found in
diff --git a/arch/ppc/platforms/chestnut.c b/arch/ppc/platforms/chestnut.c
index aefcc0e7be5..f324f757cae 100644
--- a/arch/ppc/platforms/chestnut.c
+++ b/arch/ppc/platforms/chestnut.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chestnut.c
- *
* Board setup routines for IBM Chestnut
*
* Author: <source@mvista.com>
diff --git a/arch/ppc/platforms/chestnut.h b/arch/ppc/platforms/chestnut.h
index 0400b2be40a..e00fd9f8bbd 100644
--- a/arch/ppc/platforms/chestnut.h
+++ b/arch/ppc/platforms/chestnut.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chestnut.h
- *
* Definitions for IBM 750FXGX Eval (Chestnut)
*
* Author: <source@mvista.com>
diff --git a/arch/ppc/platforms/chrp_pegasos_eth.c b/arch/ppc/platforms/chrp_pegasos_eth.c
index 108a6e26518..9305c8aa137 100644
--- a/arch/ppc/platforms/chrp_pegasos_eth.c
+++ b/arch/ppc/platforms/chrp_pegasos_eth.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chrp_pegasos_eth.c
- *
* Copyright (C) 2005 Sven Luther <sl@bplan-gmbh.de>
* Thanks to :
* Dale Farnsworth <dale@farnsworth.org>
diff --git a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
index 48996b78737..f9fd3f4f8e2 100644
--- a/arch/ppc/platforms/chrp_setup.c
+++ b/arch/ppc/platforms/chrp_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/chrp_time.c b/arch/ppc/platforms/chrp_time.c
index 57753a55b58..c8627770af1 100644
--- a/arch/ppc/platforms/chrp_time.c
+++ b/arch/ppc/platforms/chrp_time.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/chrp_time.c
- *
* Copyright (C) 1991, 1992, 1995 Linus Torvalds
*
* Adapted for PowerPC (PReP) by Gary Thomas
diff --git a/arch/ppc/platforms/cpci690.c b/arch/ppc/platforms/cpci690.c
index 6ca7bcac947..790475c22fd 100644
--- a/arch/ppc/platforms/cpci690.c
+++ b/arch/ppc/platforms/cpci690.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/cpci690.c
- *
* Board setup routines for the Force CPCI690 board.
*
* Author: Mark A. Greer <mgreer@mvista.com>
@@ -290,7 +288,7 @@ cpci690_fixup_mpsc_pdata(struct platform_device *pdev)
pdata->brg_clk_freq = cpci690_get_bus_freq();
}
-static int __init
+static int
cpci690_platform_notify(struct device *dev)
{
static struct {
diff --git a/arch/ppc/platforms/cpci690.h b/arch/ppc/platforms/cpci690.h
index 49584c9cedf..0fa5a4c31b6 100644
--- a/arch/ppc/platforms/cpci690.h
+++ b/arch/ppc/platforms/cpci690.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/cpci690.h
- *
* Definitions for Force CPCI690
*
* Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/platforms/ev64260.c b/arch/ppc/platforms/ev64260.c
index ffde8f6f630..31e8e21e1d5 100644
--- a/arch/ppc/platforms/ev64260.c
+++ b/arch/ppc/platforms/ev64260.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ev64260.c
- *
* Board setup routines for the Marvell/Galileo EV-64260-BP Evaluation Board.
*
* Author: Mark A. Greer <mgreer@mvista.com>
@@ -416,7 +414,7 @@ ev64260_fixup_mpsc_pdata(struct platform_device *pdev)
return;
}
-static int __init
+static int
ev64260_platform_notify(struct device *dev)
{
static struct {
diff --git a/arch/ppc/platforms/ev64260.h b/arch/ppc/platforms/ev64260.h
index bedffced3a0..44d90d56745 100644
--- a/arch/ppc/platforms/ev64260.h
+++ b/arch/ppc/platforms/ev64260.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ev64260.h
- *
* Definitions for Marvell/Galileo EV-64260-BP Evaluation Board.
*
* Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c
index b9d844f88c2..104ac9b16e8 100644
--- a/arch/ppc/platforms/ev64360.c
+++ b/arch/ppc/platforms/ev64360.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ev64360.c
- *
* Board setup routines for the Marvell EV-64360-BP Evaluation Board.
*
* Author: Lee Nicks <allinux@gmail.com>
@@ -300,7 +298,7 @@ ev64360_fixup_eth_pdata(struct platform_device *pdev)
}
#endif
-static int __init
+static int
ev64360_platform_notify(struct device *dev)
{
static struct {
diff --git a/arch/ppc/platforms/ev64360.h b/arch/ppc/platforms/ev64360.h
index 68eabe49039..b30f4722690 100644
--- a/arch/ppc/platforms/ev64360.h
+++ b/arch/ppc/platforms/ev64360.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/ev64360.h
- *
* Definitions for Marvell EV-64360-BP Evaluation Board.
*
* Author: Lee Nicks <allinux@gmail.com>
diff --git a/arch/ppc/platforms/fads.h b/arch/ppc/platforms/fads.h
index a48fb8d723e..e1c0b1b6dcb 100644
--- a/arch/ppc/platforms/fads.h
+++ b/arch/ppc/platforms/fads.h
@@ -112,7 +112,7 @@
/* CPM Ethernet through SCC1 or SCC2 */
-#ifdef CONFIG_SCC1_ENET /* Probably 860 variant */
+#if defined(CONFIG_SCC1_ENET) || defined(CONFIG_MPC8xx_SECOND_ETH_SCC1) /* Probably 860 variant */
/* Bits in parallel I/O port registers that have to be set/cleared
* to configure the pins for SCC1 use.
* TCLK - CLK1, RCLK - CLK2.
diff --git a/arch/ppc/platforms/gemini.h b/arch/ppc/platforms/gemini.h
index 06de5924891..5528fd0a121 100644
--- a/arch/ppc/platforms/gemini.h
+++ b/arch/ppc/platforms/gemini.h
@@ -1,7 +1,4 @@
/*
- * arch/ppc/platforms/gemini.h
- *
- *
* Onboard registers and descriptions for Synergy Microsystems'
* "Gemini" boards.
*
diff --git a/arch/ppc/platforms/gemini_prom.S b/arch/ppc/platforms/gemini_prom.S
index 8c5065d5650..b181f210800 100644
--- a/arch/ppc/platforms/gemini_prom.S
+++ b/arch/ppc/platforms/gemini_prom.S
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/gemini_prom.S
- *
* Not really prom support code (yet), but sort of anti-prom code. The current
* bootloader does a number of things it shouldn't and doesn't do things that it
* should. The stuff in here is mainly a hodge-podge collection of setup code
diff --git a/arch/ppc/platforms/gemini_setup.c b/arch/ppc/platforms/gemini_setup.c
index 729897c5903..0090ff15460 100644
--- a/arch/ppc/platforms/gemini_setup.c
+++ b/arch/ppc/platforms/gemini_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/gemini_setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/hdpu.c b/arch/ppc/platforms/hdpu.c
index f945416960e..75dc2ee87d2 100644
--- a/arch/ppc/platforms/hdpu.c
+++ b/arch/ppc/platforms/hdpu.c
@@ -1,7 +1,4 @@
-
/*
- * arch/ppc/platforms/hdpu_setup.c
- *
* Board setup routines for the Sky Computers HDPU Compute Blade.
*
* Written by Brian Waite <waite@skycomputers.com>
@@ -353,7 +350,7 @@ static void __init hdpu_fixup_cpustate_pdata(struct platform_device *pd)
}
#endif
-static int __init hdpu_platform_notify(struct device *dev)
+static int hdpu_platform_notify(struct device *dev)
{
static struct {
char *bus_id;
diff --git a/arch/ppc/platforms/hdpu.h b/arch/ppc/platforms/hdpu.h
index 07c3cffb5c7..f9e020b6970 100644
--- a/arch/ppc/platforms/hdpu.h
+++ b/arch/ppc/platforms/hdpu.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/hdpu.h
- *
* Definitions for Sky Computers HDPU board.
*
* Brian Waite <waite@skycomputers.com>
diff --git a/arch/ppc/platforms/katana.c b/arch/ppc/platforms/katana.c
index 6e58e30ceed..ad21280e892 100644
--- a/arch/ppc/platforms/katana.c
+++ b/arch/ppc/platforms/katana.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/katana.c
- *
* Board setup routines for the Artesyn Katana cPCI boards.
*
* Author: Tim Montgomery <timm@artesyncp.com>
@@ -598,7 +596,7 @@ katana_fixup_mv64xxx_pdata(struct platform_device *pdev)
}
#endif
-static int __init
+static int
katana_platform_notify(struct device *dev)
{
static struct {
@@ -664,12 +662,11 @@ katana_setup_mtd(void)
ptbl_entries = (size >= (64*MB)) ? 6 : 4;
- if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
+ if ((ptbl = kcalloc(ptbl_entries, sizeof(struct mtd_partition),
GFP_KERNEL)) == NULL) {
printk(KERN_WARNING "Can't alloc MTD partition table\n");
return -ENOMEM;
}
- memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
ptbl[0].name = "Monitor";
ptbl[0].size = KATANA_MTD_MONITOR_SIZE;
diff --git a/arch/ppc/platforms/katana.h b/arch/ppc/platforms/katana.h
index 597257eff2e..0a9b036526b 100644
--- a/arch/ppc/platforms/katana.h
+++ b/arch/ppc/platforms/katana.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/katana.h
- *
* Definitions for Artesyn Katana750i/3750 board.
*
* Author: Tim Montgomery <timm@artesyncp.com>
diff --git a/arch/ppc/platforms/lite5200.c b/arch/ppc/platforms/lite5200.c
index 7ed52dc340c..5171b53bccb 100644
--- a/arch/ppc/platforms/lite5200.c
+++ b/arch/ppc/platforms/lite5200.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/lite5200.c
- *
* Platform support file for the Freescale LITE5200 based on MPC52xx.
* A maximum of this file should be moved to syslib/mpc52xx_?????
* so that new platform based on MPC52xx need a minimal platform file
diff --git a/arch/ppc/platforms/lite5200.h b/arch/ppc/platforms/lite5200.h
index c1de2aa4717..852a18e24d0 100644
--- a/arch/ppc/platforms/lite5200.h
+++ b/arch/ppc/platforms/lite5200.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/lite5200.h
- *
* Definitions for Freescale LITE5200 : MPC52xx Standard Development
* Platform board support
*
diff --git a/arch/ppc/platforms/lopec.c b/arch/ppc/platforms/lopec.c
index 06d247c23b8..c6445a727ca 100644
--- a/arch/ppc/platforms/lopec.c
+++ b/arch/ppc/platforms/lopec.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/lopec.c
- *
* Setup routines for the Motorola LoPEC.
*
* Author: Dan Cox
diff --git a/arch/ppc/platforms/mpc8272ads_setup.c b/arch/ppc/platforms/mpc8272ads_setup.c
new file mode 100644
index 00000000000..bc9b94f77e3
--- /dev/null
+++ b/arch/ppc/platforms/mpc8272ads_setup.c
@@ -0,0 +1,236 @@
+/*
+ * arch/ppc/platforms/82xx/pq2ads_pd.c
+ *
+ * MPC82xx Board-specific PlatformDevice descriptions
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/ioport.h>
+#include <linux/fs_enet_pd.h>
+#include <linux/platform_device.h>
+
+#include <asm/io.h>
+#include <asm/mpc8260.h>
+#include <asm/cpm2.h>
+#include <asm/immap_cpm2.h>
+#include <asm/irq.h>
+#include <asm/ppc_sys.h>
+#include <asm/ppcboot.h>
+
+#include "pq2ads_pd.h"
+
+static void init_fcc1_ioports(void);
+static void init_fcc2_ioports(void);
+
+static struct fs_mii_bus_info mii_bus_info = {
+ .method = fsmii_bitbang,
+ .id = 0,
+ .i.bitbang = {
+ .mdio_port = fsiop_portc,
+ .mdio_bit = 18,
+ .mdc_port = fsiop_portc,
+ .mdc_bit = 19,
+ .delay = 1,
+ },
+};
+
+static struct fs_platform_info mpc82xx_fcc1_pdata = {
+ .fs_no = fsid_fcc1,
+ .cp_page = CPM_CR_FCC1_PAGE,
+ .cp_block = CPM_CR_FCC1_SBLOCK,
+ .clk_trx = (PC_F1RXCLK | PC_F1TXCLK),
+ .clk_route = CMX1_CLK_ROUTE,
+ .clk_mask = CMX1_CLK_MASK,
+ .init_ioports = init_fcc1_ioports,
+
+ .phy_addr = 0,
+#ifdef PHY_INTERRUPT
+ .phy_irq = PHY_INTERRUPT,
+#else
+ .phy_irq = -1;
+#endif
+ .mem_offset = FCC1_MEM_OFFSET,
+ .bus_info = &mii_bus_info,
+ .rx_ring = 32,
+ .tx_ring = 32,
+ .rx_copybreak = 240,
+ .use_napi = 0,
+ .napi_weight = 17,
+};
+
+static struct fs_platform_info mpc82xx_fcc2_pdata = {
+ .fs_no = fsid_fcc2,
+ .cp_page = CPM_CR_FCC2_PAGE,
+ .cp_block = CPM_CR_FCC2_SBLOCK,
+ .clk_trx = (PC_F2RXCLK | PC_F2TXCLK),
+ .clk_route = CMX2_CLK_ROUTE,
+ .clk_mask = CMX2_CLK_MASK,
+ .init_ioports = init_fcc2_ioports,
+
+ .phy_addr = 3,
+#ifdef PHY_INTERRUPT
+ .phy_irq = PHY_INTERRUPT,
+#else
+ .phy_irq = -1;
+#endif
+ .mem_offset = FCC2_MEM_OFFSET,
+ .bus_info = &mii_bus_info,
+ .rx_ring = 32,
+ .tx_ring = 32,
+ .rx_copybreak = 240,
+ .use_napi = 0,
+ .napi_weight = 17,
+};
+
+static void init_fcc1_ioports(void)
+{
+ struct io_port *io;
+ u32 tempval;
+ cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
+ u32 *bcsr = ioremap(BCSR_ADDR+4, sizeof(u32));
+
+ io = &immap->im_ioport;
+
+ /* Enable the PHY */
+ clrbits32(bcsr, BCSR1_FETHIEN);
+ setbits32(bcsr, BCSR1_FETH_RST);
+
+ /* FCC1 pins are on port A/C. */
+ /* Configure port A and C pins for FCC1 Ethernet. */
+
+ tempval = in_be32(&io->iop_pdira);
+ tempval &= ~PA1_DIRA0;
+ tempval |= PA1_DIRA1;
+ out_be32(&io->iop_pdira, tempval);
+
+ tempval = in_be32(&io->iop_psora);
+ tempval &= ~PA1_PSORA0;
+ tempval |= PA1_PSORA1;
+ out_be32(&io->iop_psora, tempval);
+
+ setbits32(&io->iop_ppara,PA1_DIRA0 | PA1_DIRA1);
+
+ /* Alter clocks */
+ tempval = PC_F1TXCLK|PC_F1RXCLK;
+
+ clrbits32(&io->iop_psorc, tempval);
+ clrbits32(&io->iop_pdirc, tempval);
+ setbits32(&io->iop_pparc, tempval);
+
+ clrbits32(&immap->im_cpmux.cmx_fcr, CMX1_CLK_MASK);
+ setbits32(&immap->im_cpmux.cmx_fcr, CMX1_CLK_ROUTE);
+ iounmap(bcsr);
+ iounmap(immap);
+}
+
+static void init_fcc2_ioports(void)
+{
+ cpm2_map_t* immap = ioremap(CPM_MAP_ADDR, sizeof(cpm2_map_t));
+ u32 *bcsr = ioremap(BCSR_ADDR+12, sizeof(u32));
+
+ struct io_port *io;
+ u32 tempval;
+
+ immap = cpm2_immr;
+
+ io = &immap->im_ioport;
+
+ /* Enable the PHY */
+ clrbits32(bcsr, BCSR3_FETHIEN2);
+ setbits32(bcsr, BCSR3_FETH2_RST);
+
+ /* FCC2 are port B/C. */
+ /* Configure port A and C pins for FCC2 Ethernet. */
+
+ tempval = in_be32(&io->iop_pdirb);
+ tempval &= ~PB2_DIRB0;
+ tempval |= PB2_DIRB1;
+ out_be32(&io->iop_pdirb, tempval);
+
+ tempval = in_be32(&io->iop_psorb);
+ tempval &= ~PB2_PSORB0;
+ tempval |= PB2_PSORB1;
+ out_be32(&io->iop_psorb, tempval);
+
+ setbits32(&io->iop_pparb,PB2_DIRB0 | PB2_DIRB1);
+
+ tempval = PC_F2RXCLK|PC_F2TXCLK;
+
+ /* Alter clocks */
+ clrbits32(&io->iop_psorc,tempval);
+ clrbits32(&io->iop_pdirc,tempval);
+ setbits32(&io->iop_pparc,tempval);
+
+ clrbits32(&immap->im_cpmux.cmx_fcr, CMX2_CLK_MASK);
+ setbits32(&immap->im_cpmux.cmx_fcr, CMX2_CLK_ROUTE);
+
+ iounmap(bcsr);
+ iounmap(immap);
+}
+
+
+static void __init mpc8272ads_fixup_enet_pdata(struct platform_device *pdev,
+ int idx)
+{
+ bd_t* bi = (void*)__res;
+ int fs_no = fsid_fcc1+pdev->id-1;
+
+ mpc82xx_fcc1_pdata.dpram_offset = mpc82xx_fcc2_pdata.dpram_offset = (u32)cpm2_immr->im_dprambase;
+ mpc82xx_fcc1_pdata.fcc_regs_c = mpc82xx_fcc2_pdata.fcc_regs_c = (u32)cpm2_immr->im_fcc_c;
+
+ switch(fs_no) {
+ case fsid_fcc1:
+ memcpy(&mpc82xx_fcc1_pdata.macaddr,bi->bi_enetaddr,6);
+ pdev->dev.platform_data = &mpc82xx_fcc1_pdata;
+ break;
+ case fsid_fcc2:
+ memcpy(&mpc82xx_fcc2_pdata.macaddr,bi->bi_enetaddr,6);
+ mpc82xx_fcc2_pdata.macaddr[5] ^= 1;
+ pdev->dev.platform_data = &mpc82xx_fcc2_pdata;
+ break;
+ }
+}
+
+static int mpc8272ads_platform_notify(struct device *dev)
+{
+ static const struct platform_notify_dev_map dev_map[] = {
+ {
+ .bus_id = "fsl-cpm-fcc",
+ .rtn = mpc8272ads_fixup_enet_pdata
+ },
+ {
+ .bus_id = NULL
+ }
+ };
+ platform_notify_map(dev_map,dev);
+
+ return 0;
+
+}
+
+int __init mpc8272ads_init(void)
+{
+ printk(KERN_NOTICE "mpc8272ads: Init\n");
+
+ platform_notify = mpc8272ads_platform_notify;
+
+ ppc_sys_device_initfunc();
+
+ ppc_sys_device_disable_all();
+ ppc_sys_device_enable(MPC82xx_CPM_FCC1);
+ ppc_sys_device_enable(MPC82xx_CPM_FCC2);
+
+ return 0;
+}
+
+arch_initcall(mpc8272ads_init);
diff --git a/arch/ppc/platforms/mpc866ads_setup.c b/arch/ppc/platforms/mpc866ads_setup.c
new file mode 100644
index 00000000000..ac8fcc68afe
--- /dev/null
+++ b/arch/ppc/platforms/mpc866ads_setup.c
@@ -0,0 +1,273 @@
+/*arch/ppc/platforms/mpc885ads-setup.c
+ *
+ * Platform setup for the Freescale mpc885ads board
+ *
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * Copyright 2005 MontaVista Software Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+
+#include <linux/fs_enet_pd.h>
+#include <linux/mii.h>
+
+#include <asm/delay.h>
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/page.h>
+#include <asm/processor.h>
+#include <asm/system.h>
+#include <asm/time.h>
+#include <asm/ppcboot.h>
+#include <asm/8xx_immap.h>
+#include <asm/commproc.h>
+#include <asm/ppc_sys.h>
+#include <asm/mpc8xx.h>
+
+extern unsigned char __res[];
+
+static struct fs_mii_bus_info fec_mii_bus_info = {
+ .method = fsmii_fec,
+ .id = 0,
+};
+
+static struct fs_mii_bus_info scc_mii_bus_info = {
+ .method = fsmii_fixed,
+ .id = 0,
+ .i.fixed.speed = 10,
+ .i.fixed.duplex = 0,
+};
+
+static struct fs_platform_info mpc8xx_fec_pdata[] = {
+ {
+ .rx_ring = 128,
+ .tx_ring = 16,
+ .rx_copybreak = 240,
+
+ .use_napi = 1,
+ .napi_weight = 17,
+
+ .phy_addr = 15,
+ .phy_irq = -1,
+
+ .use_rmii = 0,
+
+ .bus_info = &fec_mii_bus_info,
+ }
+};
+
+static struct fs_platform_info mpc8xx_scc_pdata = {
+ .rx_ring = 64,
+ .tx_ring = 8,
+ .rx_copybreak = 240,
+
+ .use_napi = 1,
+ .napi_weight = 17,
+
+ .phy_addr = -1,
+ .phy_irq = -1,
+
+ .bus_info = &scc_mii_bus_info,
+};
+
+void __init board_init(void)
+{
+ volatile cpm8xx_t *cp = cpmp;
+ unsigned *bcsr_io;
+
+ bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
+
+ if (bcsr_io == NULL) {
+ printk(KERN_CRIT "Could not remap BCSR1\n");
+ return;
+ }
+#ifdef CONFIG_SERIAL_CPM_SMC1
+ cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */
+ clrbits32(bcsr_io,(0x80000000 >> 7));
+#else
+ setbits32(bcsr_io,(0x80000000 >> 7));
+
+ cp->cp_pbpar &= ~(0x000000c0);
+ cp->cp_pbdir |= 0x000000c0;
+ cp->cp_smc[0].smc_smcmr = 0;
+ cp->cp_smc[0].smc_smce = 0;
+#endif
+
+#ifdef CONFIG_SERIAL_CPM_SMC2
+ cp->cp_simode &= ~(0xe0000000 >> 1);
+ cp->cp_simode |= (0x20000000 >> 1); /* brg2 */
+ clrbits32(bcsr_io,(0x80000000 >> 13));
+#else
+ clrbits32(bcsr_io,(0x80000000 >> 13));
+ cp->cp_pbpar &= ~(0x00000c00);
+ cp->cp_pbdir |= 0x00000c00;
+ cp->cp_smc[1].smc_smcmr = 0;
+ cp->cp_smc[1].smc_smce = 0;
+#endif
+ iounmap(bcsr_io);
+}
+
+static void setup_fec1_ioports(void)
+{
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+
+ setbits16(&immap->im_ioport.iop_pdpar, 0x1fff);
+ setbits16(&immap->im_ioport.iop_pddir, 0x1fff);
+}
+
+static void setup_scc1_ioports(void)
+{
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+ unsigned *bcsr_io;
+
+ bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
+
+ if (bcsr_io == NULL) {
+ printk(KERN_CRIT "Could not remap BCSR1\n");
+ return;
+ }
+
+ /* Enable the PHY.
+ */
+ clrbits32(bcsr_io,BCSR1_ETHEN);
+
+ /* Configure port A pins for Txd and Rxd.
+ */
+ /* Disable receive and transmit in case EPPC-Bug started it.
+ */
+ setbits16(&immap->im_ioport.iop_papar, PA_ENET_RXD | PA_ENET_TXD);
+ clrbits16(&immap->im_ioport.iop_padir, PA_ENET_RXD | PA_ENET_TXD);
+ clrbits16(&immap->im_ioport.iop_paodr, PA_ENET_TXD);
+
+ /* Configure port C pins to enable CLSN and RENA.
+ */
+ clrbits16(&immap->im_ioport.iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA);
+ clrbits16(&immap->im_ioport.iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA);
+ setbits16(&immap->im_ioport.iop_pcso, PC_ENET_CLSN | PC_ENET_RENA);
+ /* Configure port A for TCLK and RCLK.
+ */
+ setbits16(&immap->im_ioport.iop_papar, PA_ENET_TCLK | PA_ENET_RCLK);
+ clrbits16(&immap->im_ioport.iop_padir, PA_ENET_TCLK | PA_ENET_RCLK);
+ clrbits32(&immap->im_cpm.cp_pbpar, PB_ENET_TENA);
+ clrbits32(&immap->im_cpm.cp_pbdir, PB_ENET_TENA);
+
+ /* Configure Serial Interface clock routing.
+ * First, clear all SCC bits to zero, then set the ones we want.
+ */
+ clrbits32(&immap->im_cpm.cp_sicr, SICR_ENET_MASK);
+ setbits32(&immap->im_cpm.cp_sicr, SICR_ENET_CLKRT);
+
+ /* In the original SCC enet driver the following code is placed at
+ the end of the initialization */
+ setbits32(&immap->im_cpm.cp_pbpar, PB_ENET_TENA);
+ setbits32(&immap->im_cpm.cp_pbdir, PB_ENET_TENA);
+
+}
+
+static void mpc866ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
+{
+ struct fs_platform_info *fpi = pdev->dev.platform_data;
+
+ volatile cpm8xx_t *cp;
+ bd_t *bd = (bd_t *) __res;
+ char *e;
+ int i;
+
+ /* Get pointer to Communication Processor */
+ cp = cpmp;
+ switch (fs_no) {
+ case fsid_fec1:
+ fpi = &mpc8xx_fec_pdata[0];
+ fpi->init_ioports = &setup_fec1_ioports;
+
+ break;
+ case fsid_scc1:
+ fpi = &mpc8xx_scc_pdata;
+ fpi->init_ioports = &setup_scc1_ioports;
+
+ break;
+ default:
+ printk(KERN_WARNING"Device %s is not supported!\n", pdev->name);
+ return;
+ }
+
+ pdev->dev.platform_data = fpi;
+ fpi->fs_no = fs_no;
+
+ e = (unsigned char *)&bd->bi_enetaddr;
+ for (i = 0; i < 6; i++)
+ fpi->macaddr[i] = *e++;
+
+ fpi->macaddr[5 - pdev->id]++;
+
+}
+
+static void mpc866ads_fixup_fec_enet_pdata(struct platform_device *pdev,
+ int idx)
+{
+ /* This is for FEC devices only */
+ if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-fec")))
+ return;
+ mpc866ads_fixup_enet_pdata(pdev, fsid_fec1 + pdev->id - 1);
+}
+
+static void mpc866ads_fixup_scc_enet_pdata(struct platform_device *pdev,
+ int idx)
+{
+ /* This is for SCC devices only */
+ if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-scc")))
+ return;
+
+ mpc866ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1);
+}
+
+static int mpc866ads_platform_notify(struct device *dev)
+{
+ static const struct platform_notify_dev_map dev_map[] = {
+ {
+ .bus_id = "fsl-cpm-fec",
+ .rtn = mpc866ads_fixup_fec_enet_pdata,
+ },
+ {
+ .bus_id = "fsl-cpm-scc",
+ .rtn = mpc866ads_fixup_scc_enet_pdata,
+ },
+ {
+ .bus_id = NULL
+ }
+ };
+
+ platform_notify_map(dev_map,dev);
+
+ return 0;
+}
+
+int __init mpc866ads_init(void)
+{
+ printk(KERN_NOTICE "mpc866ads: Init\n");
+
+ platform_notify = mpc866ads_platform_notify;
+
+ ppc_sys_device_initfunc();
+ ppc_sys_device_disable_all();
+
+#ifdef MPC8xx_SECOND_ETH_SCC1
+ ppc_sys_device_enable(MPC8xx_CPM_SCC1);
+#endif
+ ppc_sys_device_enable(MPC8xx_CPM_FEC1);
+
+ return 0;
+}
+
+arch_initcall(mpc866ads_init);
diff --git a/arch/ppc/platforms/mpc885ads_setup.c b/arch/ppc/platforms/mpc885ads_setup.c
new file mode 100644
index 00000000000..50a99e5f7c6
--- /dev/null
+++ b/arch/ppc/platforms/mpc885ads_setup.c
@@ -0,0 +1,389 @@
+/*arch/ppc/platforms/mpc885ads-setup.c
+ *
+ * Platform setup for the Freescale mpc885ads board
+ *
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * Copyright 2005 MontaVista Software Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/config.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/param.h>
+#include <linux/string.h>
+#include <linux/ioport.h>
+#include <linux/device.h>
+
+#include <linux/fs_enet_pd.h>
+#include <linux/mii.h>
+
+#include <asm/delay.h>
+#include <asm/io.h>
+#include <asm/machdep.h>
+#include <asm/page.h>
+#include <asm/processor.h>
+#include <asm/system.h>
+#include <asm/time.h>
+#include <asm/ppcboot.h>
+#include <asm/8xx_immap.h>
+#include <asm/commproc.h>
+#include <asm/ppc_sys.h>
+
+extern unsigned char __res[];
+
+static void __init mpc885ads_scc_phy_init(char);
+
+static struct fs_mii_bus_info fec_mii_bus_info = {
+ .method = fsmii_fec,
+ .id = 0,
+};
+
+static struct fs_mii_bus_info scc_mii_bus_info = {
+#ifdef CONFIG_SCC_ENET_8xx_FIXED
+ .method = fsmii_fixed,
+#else
+ .method = fsmii_fec,
+#endif
+
+ .id = 0,
+};
+
+static struct fs_platform_info mpc8xx_fec_pdata[] = {
+ {
+ .rx_ring = 128,
+ .tx_ring = 16,
+ .rx_copybreak = 240,
+
+ .use_napi = 1,
+ .napi_weight = 17,
+
+ .phy_addr = 0,
+ .phy_irq = SIU_IRQ7,
+
+ .bus_info = &fec_mii_bus_info,
+ }, {
+ .rx_ring = 128,
+ .tx_ring = 16,
+ .rx_copybreak = 240,
+
+ .use_napi = 1,
+ .napi_weight = 17,
+
+ .phy_addr = 1,
+ .phy_irq = SIU_IRQ7,
+
+ .bus_info = &fec_mii_bus_info,
+ }
+};
+
+static struct fs_platform_info mpc8xx_scc_pdata = {
+ .rx_ring = 64,
+ .tx_ring = 8,
+ .rx_copybreak = 240,
+
+ .use_napi = 1,
+ .napi_weight = 17,
+
+ .phy_addr = 2,
+#ifdef CONFIG_MPC8xx_SCC_ENET_FIXED
+ .phy_irq = -1,
+#else
+ .phy_irq = SIU_IRQ7,
+#endif
+
+ .bus_info = &scc_mii_bus_info,
+};
+
+void __init board_init(void)
+{
+ volatile cpm8xx_t *cp = cpmp;
+ unsigned int *bcsr_io;
+
+#ifdef CONFIG_FS_ENET
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+#endif
+ bcsr_io = ioremap(BCSR1, sizeof(unsigned long));
+
+ if (bcsr_io == NULL) {
+ printk(KERN_CRIT "Could not remap BCSR\n");
+ return;
+ }
+#ifdef CONFIG_SERIAL_CPM_SMC1
+ cp->cp_simode &= ~(0xe0000000 >> 17); /* brg1 */
+ clrbits32(bcsr_io, BCSR1_RS232EN_1);
+#else
+ setbits32(bcsr_io,BCSR1_RS232EN_1);
+ cp->cp_smc[0].smc_smcmr = 0;
+ cp->cp_smc[0].smc_smce = 0;
+#endif
+
+#ifdef CONFIG_SERIAL_CPM_SMC2
+ cp->cp_simode &= ~(0xe0000000 >> 1);
+ cp->cp_simode |= (0x20000000 >> 1); /* brg2 */
+ clrbits32(bcsr_io,BCSR1_RS232EN_2);
+#else
+ setbits32(bcsr_io,BCSR1_RS232EN_2);
+ cp->cp_smc[1].smc_smcmr = 0;
+ cp->cp_smc[1].smc_smce = 0;
+#endif
+ iounmap(bcsr_io);
+
+#ifdef CONFIG_FS_ENET
+ /* use MDC for MII (common) */
+ setbits16(&immap->im_ioport.iop_pdpar, 0x0080);
+ clrbits16(&immap->im_ioport.iop_pddir, 0x0080);
+#endif
+}
+
+static void setup_fec1_ioports(void)
+{
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+
+ /* configure FEC1 pins */
+ setbits16(&immap->im_ioport.iop_papar, 0xf830);
+ setbits16(&immap->im_ioport.iop_padir, 0x0830);
+ clrbits16(&immap->im_ioport.iop_padir, 0xf000);
+ setbits32(&immap->im_cpm.cp_pbpar, 0x00001001);
+
+ clrbits32(&immap->im_cpm.cp_pbdir, 0x00001001);
+ setbits16(&immap->im_ioport.iop_pcpar, 0x000c);
+ clrbits16(&immap->im_ioport.iop_pcdir, 0x000c);
+ setbits32(&immap->im_cpm.cp_pepar, 0x00000003);
+
+ setbits32(&immap->im_cpm.cp_pedir, 0x00000003);
+ clrbits32(&immap->im_cpm.cp_peso, 0x00000003);
+ clrbits32(&immap->im_cpm.cp_cptr, 0x00000100);
+}
+
+static void setup_fec2_ioports(void)
+{
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+
+ /* configure FEC2 pins */
+ setbits32(&immap->im_cpm.cp_pepar, 0x0003fffc);
+ setbits32(&immap->im_cpm.cp_pedir, 0x0003fffc);
+ setbits32(&immap->im_cpm.cp_peso, 0x00037800);
+ clrbits32(&immap->im_cpm.cp_peso, 0x000087fc);
+ clrbits32(&immap->im_cpm.cp_cptr, 0x00000080);
+}
+
+static void setup_scc3_ioports(void)
+{
+ immap_t *immap = (immap_t *) IMAP_ADDR;
+ unsigned *bcsr_io;
+
+ bcsr_io = ioremap(BCSR_ADDR, BCSR_SIZE);
+
+ if (bcsr_io == NULL) {
+ printk(KERN_CRIT "Could not remap BCSR\n");
+ return;
+ }
+
+ /* Enable the PHY.
+ */
+ setbits32(bcsr_io+4, BCSR4_ETH10_RST);
+ /* Configure port A pins for Txd and Rxd.
+ */
+ setbits16(&immap->im_ioport.iop_papar, PA_ENET_RXD | PA_ENET_TXD);
+ clrbits16(&immap->im_ioport.iop_padir, PA_ENET_RXD | PA_ENET_TXD);
+
+ /* Configure port C pins to enable CLSN and RENA.
+ */
+ clrbits16(&immap->im_ioport.iop_pcpar, PC_ENET_CLSN | PC_ENET_RENA);
+ clrbits16(&immap->im_ioport.iop_pcdir, PC_ENET_CLSN | PC_ENET_RENA);
+ setbits16(&immap->im_ioport.iop_pcso, PC_ENET_CLSN | PC_ENET_RENA);
+
+ /* Configure port E for TCLK and RCLK.
+ */
+ setbits32(&immap->im_cpm.cp_pepar, PE_ENET_TCLK | PE_ENET_RCLK);
+ clrbits32(&immap->im_cpm.cp_pepar, PE_ENET_TENA);
+ clrbits32(&immap->im_cpm.cp_pedir,
+ PE_ENET_TCLK | PE_ENET_RCLK | PE_ENET_TENA);
+ clrbits32(&immap->im_cpm.cp_peso, PE_ENET_TCLK | PE_ENET_RCLK);
+ setbits32(&immap->im_cpm.cp_peso, PE_ENET_TENA);
+
+ /* Configure Serial Interface clock routing.
+ * First, clear all SCC bits to zero, then set the ones we want.
+ */
+ clrbits32(&immap->im_cpm.cp_sicr, SICR_ENET_MASK);
+ setbits32(&immap->im_cpm.cp_sicr, SICR_ENET_CLKRT);
+
+ /* Disable Rx and Tx. SMC1 sshould be stopped if SCC3 eternet are used.
+ */
+ immap->im_cpm.cp_smc[0].smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN);
+ /* On the MPC885ADS SCC ethernet PHY is initialized in the full duplex mode
+ * by H/W setting after reset. SCC ethernet controller support only half duplex.
+ * This discrepancy of modes causes a lot of carrier lost errors.
+ */
+
+ /* In the original SCC enet driver the following code is placed at
+ the end of the initialization */
+ setbits32(&immap->im_cpm.cp_pepar, PE_ENET_TENA);
+ clrbits32(&immap->im_cpm.cp_pedir, PE_ENET_TENA);
+ setbits32(&immap->im_cpm.cp_peso, PE_ENET_TENA);
+
+ setbits32(bcsr_io+1, BCSR1_ETHEN);
+ iounmap(bcsr_io);
+}
+
+static void mpc885ads_fixup_enet_pdata(struct platform_device *pdev, int fs_no)
+{
+ struct fs_platform_info *fpi = pdev->dev.platform_data;
+
+ volatile cpm8xx_t *cp;
+ bd_t *bd = (bd_t *) __res;
+ char *e;
+ int i;
+
+ /* Get pointer to Communication Processor */
+ cp = cpmp;
+ switch (fs_no) {
+ case fsid_fec1:
+ fpi = &mpc8xx_fec_pdata[0];
+ fpi->init_ioports = &setup_fec1_ioports;
+ break;
+ case fsid_fec2:
+ fpi = &mpc8xx_fec_pdata[1];
+ fpi->init_ioports = &setup_fec2_ioports;
+ break;
+ case fsid_scc3:
+ fpi = &mpc8xx_scc_pdata;
+ fpi->init_ioports = &setup_scc3_ioports;
+ mpc885ads_scc_phy_init(fpi->phy_addr);
+ break;
+ default:
+ printk(KERN_WARNING"Device %s is not supported!\n", pdev->name);
+ return;
+ }
+
+ pdev->dev.platform_data = fpi;
+ fpi->fs_no = fs_no;
+
+ e = (unsigned char *)&bd->bi_enetaddr;
+ for (i = 0; i < 6; i++)
+ fpi->macaddr[i] = *e++;
+
+ fpi->macaddr[5 - pdev->id]++;
+
+}
+
+static void mpc885ads_fixup_fec_enet_pdata(struct platform_device *pdev,
+ int idx)
+{
+ /* This is for FEC devices only */
+ if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-fec")))
+ return;
+ mpc885ads_fixup_enet_pdata(pdev, fsid_fec1 + pdev->id - 1);
+}
+
+static void __init mpc885ads_fixup_scc_enet_pdata(struct platform_device *pdev,
+ int idx)
+{
+ /* This is for SCC devices only */
+ if (!pdev || !pdev->name || (!strstr(pdev->name, "fsl-cpm-scc")))
+ return;
+
+ mpc885ads_fixup_enet_pdata(pdev, fsid_scc1 + pdev->id - 1);
+}
+
+/* SCC ethernet controller does not have MII management channel. FEC1 MII
+ * channel is used to communicate with the 10Mbit PHY.
+ */
+
+#define MII_ECNTRL_PINMUX 0x4
+#define FEC_ECNTRL_PINMUX 0x00000004
+#define FEC_RCNTRL_MII_MODE 0x00000004
+
+/* Make MII read/write commands.
+ */
+#define mk_mii_write(REG, VAL, PHY_ADDR) (0x50020000 | (((REG) & 0x1f) << 18) | \
+ ((VAL) & 0xffff) | ((PHY_ADDR) << 23))
+
+static void mpc885ads_scc_phy_init(char phy_addr)
+{
+ volatile immap_t *immap;
+ volatile fec_t *fecp;
+ bd_t *bd;
+
+ bd = (bd_t *) __res;
+ immap = (immap_t *) IMAP_ADDR; /* pointer to internal registers */
+ fecp = &(immap->im_cpm.cp_fec);
+
+ /* Enable MII pins of the FEC1
+ */
+ setbits16(&immap->im_ioport.iop_pdpar, 0x0080);
+ clrbits16(&immap->im_ioport.iop_pddir, 0x0080);
+ /* Set MII speed to 2.5 MHz
+ */
+ out_be32(&fecp->fec_mii_speed,
+ ((((bd->bi_intfreq + 4999999) / 2500000) / 2) & 0x3F) << 1);
+
+ /* Enable FEC pin MUX
+ */
+ setbits32(&fecp->fec_ecntrl, MII_ECNTRL_PINMUX);
+ setbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE);
+
+ out_be32(&fecp->fec_mii_data,
+ mk_mii_write(MII_BMCR, BMCR_ISOLATE, phy_addr));
+ udelay(100);
+ out_be32(&fecp->fec_mii_data,
+ mk_mii_write(MII_ADVERTISE,
+ ADVERTISE_10HALF | ADVERTISE_CSMA, phy_addr));
+ udelay(100);
+
+ /* Disable FEC MII settings
+ */
+ clrbits32(&fecp->fec_ecntrl, MII_ECNTRL_PINMUX);
+ clrbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE);
+ out_be32(&fecp->fec_mii_speed, 0);
+}
+
+static int mpc885ads_platform_notify(struct device *dev)
+{
+
+ static const struct platform_notify_dev_map dev_map[] = {
+ {
+ .bus_id = "fsl-cpm-fec",
+ .rtn = mpc885ads_fixup_fec_enet_pdata,
+ },
+ {
+ .bus_id = "fsl-cpm-scc",
+ .rtn = mpc885ads_fixup_scc_enet_pdata,
+ },
+ {
+ .bus_id = NULL
+ }
+ };
+
+ platform_notify_map(dev_map,dev);
+
+}
+
+int __init mpc885ads_init(void)
+{
+ printk(KERN_NOTICE "mpc885ads: Init\n");
+
+ platform_notify = mpc885ads_platform_notify;
+
+ ppc_sys_device_initfunc();
+ ppc_sys_device_disable_all();
+
+ ppc_sys_device_enable(MPC8xx_CPM_FEC1);
+
+#ifdef CONFIG_MPC8xx_SECOND_ETH_SCC3
+ ppc_sys_device_enable(MPC8xx_CPM_SCC1);
+
+#endif
+#ifdef CONFIG_MPC8xx_SECOND_ETH_FEC2
+ ppc_sys_device_enable(MPC8xx_CPM_FEC2);
+#endif
+
+ return 0;
+}
+
+arch_initcall(mpc885ads_init);
diff --git a/arch/ppc/platforms/mvme5100.c b/arch/ppc/platforms/mvme5100.c
index 108eb182ddd..c717cd92c02 100644
--- a/arch/ppc/platforms/mvme5100.c
+++ b/arch/ppc/platforms/mvme5100.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/mvme5100.c
- *
* Board setup routines for the Motorola MVME5100.
*
* Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/pal4.h b/arch/ppc/platforms/pal4.h
index 641a11a3165..8569c423d88 100644
--- a/arch/ppc/platforms/pal4.h
+++ b/arch/ppc/platforms/pal4.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pal4.h
- *
* Definitions for SBS Palomar IV board
*
* Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_pci.c b/arch/ppc/platforms/pal4_pci.c
index c3b1b757a48..d81ae1c7e1c 100644
--- a/arch/ppc/platforms/pal4_pci.c
+++ b/arch/ppc/platforms/pal4_pci.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pal4_pci.c
- *
* PCI support for SBS Palomar IV
*
* Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_serial.h b/arch/ppc/platforms/pal4_serial.h
index a715c66e1ad..a75343224cf 100644
--- a/arch/ppc/platforms/pal4_serial.h
+++ b/arch/ppc/platforms/pal4_serial.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pal4_serial.h
- *
* Definitions for SBS PalomarIV serial support
*
* Author: Dan Cox
diff --git a/arch/ppc/platforms/pal4_setup.c b/arch/ppc/platforms/pal4_setup.c
index f93a3f87193..3c3d881df00 100644
--- a/arch/ppc/platforms/pal4_setup.c
+++ b/arch/ppc/platforms/pal4_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pal4_setup.c
- *
* Board setup routines for the SBS PalomarIV.
*
* Author: Dan Cox
diff --git a/arch/ppc/platforms/powerpmc250.c b/arch/ppc/platforms/powerpmc250.c
index e6b520e6e13..c3a86be11fb 100644
--- a/arch/ppc/platforms/powerpmc250.c
+++ b/arch/ppc/platforms/powerpmc250.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/powerpmc250.c
- *
* Board setup routines for Force PowerPMC-250 Processor PMC
*
* Author: Troy Benjegerdes <tbenjegerdes@mvista.com>
diff --git a/arch/ppc/platforms/pplus.c b/arch/ppc/platforms/pplus.c
index 22bd40cfb09..de2761ebe0d 100644
--- a/arch/ppc/platforms/pplus.c
+++ b/arch/ppc/platforms/pplus.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pplus.c
- *
* Board and PCI setup routines for MCG PowerPlus
*
* Author: Randy Vinson <rvinson@mvista.com>
diff --git a/arch/ppc/platforms/pplus.h b/arch/ppc/platforms/pplus.h
index 90f0cb2d409..a07cbbdd72c 100644
--- a/arch/ppc/platforms/pplus.h
+++ b/arch/ppc/platforms/pplus.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pplus.h
- *
* Definitions for Motorola MCG Falcon/Raven & HAWK North Bridge & Memory ctlr.
*
* Author: Mark A. Greerinclude/asm-ppc/hawk.h
diff --git a/arch/ppc/platforms/pq2ads.c b/arch/ppc/platforms/pq2ads.c
index 71c9fca1fe9..3365fd788a7 100644
--- a/arch/ppc/platforms/pq2ads.c
+++ b/arch/ppc/platforms/pq2ads.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/pq2ads.c
- *
* PQ2ADS platform support
*
* Author: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/platforms/pq2ads.h b/arch/ppc/platforms/pq2ads.h
index 067d9a5aebc..6b26dd36c64 100644
--- a/arch/ppc/platforms/pq2ads.h
+++ b/arch/ppc/platforms/pq2ads.h
@@ -13,6 +13,10 @@
#include <asm/ppcboot.h>
+#if defined(CONFIG_ADS8272)
+#define BOARD_CHIP_NAME "8272"
+#endif
+
/* Memory map is configured by the PROM startup.
* We just map a few things we need. The CSR is actually 4 byte-wide
* registers that can be accessed as 8-, 16-, or 32-bit values.
diff --git a/arch/ppc/platforms/pq2ads_pd.h b/arch/ppc/platforms/pq2ads_pd.h
new file mode 100644
index 00000000000..8f14a43eafe
--- /dev/null
+++ b/arch/ppc/platforms/pq2ads_pd.h
@@ -0,0 +1,114 @@
+#ifndef __PQ2ADS_PD_H
+#define __PQ2ADS_PD_H
+/*
+ * arch/ppc/platforms/82xx/pq2ads_pd.h
+ *
+ * Some defines for MPC82xx board-specific PlatformDevice descriptions
+ *
+ * 2005 (c) MontaVista Software, Inc.
+ * Vitaly Bordug <vbordug@ru.mvista.com>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+/* FCC1 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK9-12 */
+
+#define F1_RXCLK 11
+#define F1_TXCLK 10
+
+/* FCC2 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK13-16 */
+#define F2_RXCLK 15
+#define F2_TXCLK 16
+
+/* FCC3 Clock Source Configuration. These can be redefined in the board specific file.
+ Can only choose from CLK13-16 */
+#define F3_RXCLK 13
+#define F3_TXCLK 14
+
+/* Automatically generates register configurations */
+#define PC_CLK(x) ((uint)(1<<(x-1))) /* FCC CLK I/O ports */
+
+#define CMXFCR_RF1CS(x) ((uint)((x-5)<<27)) /* FCC1 Receive Clock Source */
+#define CMXFCR_TF1CS(x) ((uint)((x-5)<<24)) /* FCC1 Transmit Clock Source */
+#define CMXFCR_RF2CS(x) ((uint)((x-9)<<19)) /* FCC2 Receive Clock Source */
+#define CMXFCR_TF2CS(x) ((uint)((x-9)<<16)) /* FCC2 Transmit Clock Source */
+#define CMXFCR_RF3CS(x) ((uint)((x-9)<<11)) /* FCC3 Receive Clock Source */
+#define CMXFCR_TF3CS(x) ((uint)((x-9)<<8)) /* FCC3 Transmit Clock Source */
+
+#define PC_F1RXCLK PC_CLK(F1_RXCLK)
+#define PC_F1TXCLK PC_CLK(F1_TXCLK)
+#define CMX1_CLK_ROUTE (CMXFCR_RF1CS(F1_RXCLK) | CMXFCR_TF1CS(F1_TXCLK))
+#define CMX1_CLK_MASK ((uint)0xff000000)
+
+#define PC_F2RXCLK PC_CLK(F2_RXCLK)
+#define PC_F2TXCLK PC_CLK(F2_TXCLK)
+#define CMX2_CLK_ROUTE (CMXFCR_RF2CS(F2_RXCLK) | CMXFCR_TF2CS(F2_TXCLK))
+#define CMX2_CLK_MASK ((uint)0x00ff0000)
+
+#define PC_F3RXCLK PC_CLK(F3_RXCLK)
+#define PC_F3TXCLK PC_CLK(F3_TXCLK)
+#define CMX3_CLK_ROUTE (CMXFCR_RF3CS(F3_RXCLK) | CMXFCR_TF3CS(F3_TXCLK))
+#define CMX3_CLK_MASK ((uint)0x0000ff00)
+
+/* I/O Pin assignment for FCC1. I don't yet know the best way to do this,
+ * but there is little variation among the choices.
+ */
+#define PA1_COL 0x00000001U
+#define PA1_CRS 0x00000002U
+#define PA1_TXER 0x00000004U
+#define PA1_TXEN 0x00000008U
+#define PA1_RXDV 0x00000010U
+#define PA1_RXER 0x00000020U
+#define PA1_TXDAT 0x00003c00U
+#define PA1_RXDAT 0x0003c000U
+#define PA1_PSORA0 (PA1_RXDAT | PA1_TXDAT)
+#define PA1_PSORA1 (PA1_COL | PA1_CRS | PA1_TXER | PA1_TXEN | \
+ PA1_RXDV | PA1_RXER)
+#define PA1_DIRA0 (PA1_RXDAT | PA1_CRS | PA1_COL | PA1_RXER | PA1_RXDV)
+#define PA1_DIRA1 (PA1_TXDAT | PA1_TXEN | PA1_TXER)
+
+
+/* I/O Pin assignment for FCC2. I don't yet know the best way to do this,
+ * but there is little variation among the choices.
+ */
+#define PB2_TXER 0x00000001U
+#define PB2_RXDV 0x00000002U
+#define PB2_TXEN 0x00000004U
+#define PB2_RXER 0x00000008U
+#define PB2_COL 0x00000010U
+#define PB2_CRS 0x00000020U
+#define PB2_TXDAT 0x000003c0U
+#define PB2_RXDAT 0x00003c00U
+#define PB2_PSORB0 (PB2_RXDAT | PB2_TXDAT | PB2_CRS | PB2_COL | \
+ PB2_RXER | PB2_RXDV | PB2_TXER)
+#define PB2_PSORB1 (PB2_TXEN)
+#define PB2_DIRB0 (PB2_RXDAT | PB2_CRS | PB2_COL | PB2_RXER | PB2_RXDV)
+#define PB2_DIRB1 (PB2_TXDAT | PB2_TXEN | PB2_TXER)
+
+
+/* I/O Pin assignment for FCC3. I don't yet know the best way to do this,
+ * but there is little variation among the choices.
+ */
+#define PB3_RXDV 0x00004000U
+#define PB3_RXER 0x00008000U
+#define PB3_TXER 0x00010000U
+#define PB3_TXEN 0x00020000U
+#define PB3_COL 0x00040000U
+#define PB3_CRS 0x00080000U
+#define PB3_TXDAT 0x0f000000U
+#define PB3_RXDAT 0x00f00000U
+#define PB3_PSORB0 (PB3_RXDAT | PB3_TXDAT | PB3_CRS | PB3_COL | \
+ PB3_RXER | PB3_RXDV | PB3_TXER | PB3_TXEN)
+#define PB3_PSORB1 0
+#define PB3_DIRB0 (PB3_RXDAT | PB3_CRS | PB3_COL | PB3_RXER | PB3_RXDV)
+#define PB3_DIRB1 (PB3_TXDAT | PB3_TXEN | PB3_TXER)
+
+#define FCC_MEM_OFFSET(x) (CPM_FCC_SPECIAL_BASE + (x*128))
+#define FCC1_MEM_OFFSET FCC_MEM_OFFSET(0)
+#define FCC2_MEM_OFFSET FCC_MEM_OFFSET(1)
+
+#endif
diff --git a/arch/ppc/platforms/prep_setup.c b/arch/ppc/platforms/prep_setup.c
index d0653580200..a0fc628ffb1 100644
--- a/arch/ppc/platforms/prep_setup.c
+++ b/arch/ppc/platforms/prep_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/platforms/prpmc750.c b/arch/ppc/platforms/prpmc750.c
index 0bb14a5e824..cdd9cfb13ee 100644
--- a/arch/ppc/platforms/prpmc750.c
+++ b/arch/ppc/platforms/prpmc750.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/prpmc750_setup.c
- *
* Board setup routines for Motorola PrPMC750
*
* Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/platforms/prpmc800.c b/arch/ppc/platforms/prpmc800.c
index de7baefacd3..e459a199fb1 100644
--- a/arch/ppc/platforms/prpmc800.c
+++ b/arch/ppc/platforms/prpmc800.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/prpmc800.c
- *
* Author: Dale Farnsworth <dale.farnsworth@mvista.com>
*
* 2001-2004 (c) MontaVista, Software, Inc. This file is licensed under
diff --git a/arch/ppc/platforms/radstone_ppc7d.c b/arch/ppc/platforms/radstone_ppc7d.c
index 872c0a3ba3c..bc26b6d71c1 100644
--- a/arch/ppc/platforms/radstone_ppc7d.c
+++ b/arch/ppc/platforms/radstone_ppc7d.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/radstone_ppc7d.c
- *
* Board setup routines for the Radstone PPC7D boards.
*
* Author: James Chapman <jchapman@katalix.com>
@@ -685,11 +683,10 @@ ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
pdata = pdev->dev.platform_data;
if (pdata == NULL) {
- pdata = kmalloc(sizeof(*pdata), GFP_KERNEL);
+ pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (pdata == NULL)
return;
- memset(pdata, 0, sizeof(*pdata));
pdev->dev.platform_data = pdata;
}
@@ -712,7 +709,7 @@ ppc7d_fixup_i2c_pdata(struct platform_device *pdev)
}
#endif
-static int __init ppc7d_platform_notify(struct device *dev)
+static int ppc7d_platform_notify(struct device *dev)
{
static struct {
char *bus_id;
diff --git a/arch/ppc/platforms/radstone_ppc7d.h b/arch/ppc/platforms/radstone_ppc7d.h
index 938375510be..2bb093a0c03 100644
--- a/arch/ppc/platforms/radstone_ppc7d.h
+++ b/arch/ppc/platforms/radstone_ppc7d.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/radstone_ppc7d.h
- *
* Board definitions for the Radstone PPC7D boards.
*
* Author: James Chapman <jchapman@katalix.com>
diff --git a/arch/ppc/platforms/sandpoint.c b/arch/ppc/platforms/sandpoint.c
index 9eeed357230..6dc459decb2 100644
--- a/arch/ppc/platforms/sandpoint.c
+++ b/arch/ppc/platforms/sandpoint.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/sandpoint_setup.c
- *
* Board setup routines for the Motorola SPS Sandpoint Test Platform.
*
* Author: Mark A. Greer
diff --git a/arch/ppc/platforms/sandpoint.h b/arch/ppc/platforms/sandpoint.h
index f4e982cb69d..3b64e641848 100644
--- a/arch/ppc/platforms/sandpoint.h
+++ b/arch/ppc/platforms/sandpoint.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/sandpoint.h
- *
* Definitions for Motorola SPS Sandpoint Test Platform
*
* Author: Mark A. Greer
diff --git a/arch/ppc/platforms/sbc82xx.c b/arch/ppc/platforms/sbc82xx.c
index 74c9ff72c3d..866807b4ad0 100644
--- a/arch/ppc/platforms/sbc82xx.c
+++ b/arch/ppc/platforms/sbc82xx.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/sbc82xx.c
- *
* SBC82XX platform support
*
* Author: Guy Streeter <streeter@redhat.com>
diff --git a/arch/ppc/platforms/spruce.c b/arch/ppc/platforms/spruce.c
index 69e1de7971f..3783deccd9b 100644
--- a/arch/ppc/platforms/spruce.c
+++ b/arch/ppc/platforms/spruce.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/spruce.c
- *
* Board and PCI setup routines for IBM Spruce
*
* Author: MontaVista Software <source@mvista.com>
diff --git a/arch/ppc/platforms/tqm8260_setup.c b/arch/ppc/platforms/tqm8260_setup.c
index 3409139330b..b766339f44a 100644
--- a/arch/ppc/platforms/tqm8260_setup.c
+++ b/arch/ppc/platforms/tqm8260_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/tqm8260_setup.c
- *
* TQM8260 platform support
*
* Author: Allen Curtis <acurtis@onz.com>
diff --git a/arch/ppc/syslib/Makefile b/arch/ppc/syslib/Makefile
index 159dcd92a6d..5cb62c6a51c 100644
--- a/arch/ppc/syslib/Makefile
+++ b/arch/ppc/syslib/Makefile
@@ -17,8 +17,8 @@ obj-$(CONFIG_440GX) += ibm440gx_common.o
obj-$(CONFIG_440SP) += ibm440gx_common.o ibm440sp_common.o
obj-$(CONFIG_440SPE) += ibm440gx_common.o ibm440sp_common.o ppc440spe_pcie.o
ifeq ($(CONFIG_4xx),y)
-ifeq ($(CONFIG_VIRTEX_II_PRO),y)
-obj-$(CONFIG_40x) += xilinx_pic.o
+ifeq ($(CONFIG_XILINX_VIRTEX),y)
+obj-$(CONFIG_40x) += xilinx_pic.o ppc_sys.o
else
ifeq ($(CONFIG_403),y)
obj-$(CONFIG_40x) += ppc403_pic.o
diff --git a/arch/ppc/syslib/cpc700.h b/arch/ppc/syslib/cpc700.h
index f2c00253101..0a8a5d84390 100644
--- a/arch/ppc/syslib/cpc700.h
+++ b/arch/ppc/syslib/cpc700.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/cpc700.h
- *
* Header file for IBM CPC700 Host Bridge, et. al.
*
* Author: Mark A. Greer
diff --git a/arch/ppc/syslib/cpc700_pic.c b/arch/ppc/syslib/cpc700_pic.c
index 75fe8eb1069..5add0a919ef 100644
--- a/arch/ppc/syslib/cpc700_pic.c
+++ b/arch/ppc/syslib/cpc700_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/cpc700_pic.c
- *
* Interrupt controller support for IBM Spruce
*
* Authors: Mark Greer, Matt Porter, and Johnnie Peters
diff --git a/arch/ppc/syslib/cpc710.h b/arch/ppc/syslib/cpc710.h
index cc0afd80402..5299bf8b5d0 100644
--- a/arch/ppc/syslib/cpc710.h
+++ b/arch/ppc/syslib/cpc710.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/cpc710.h
- *
* Definitions for the IBM CPC710 PCI Host Bridge
*
* Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/gen550.h b/arch/ppc/syslib/gen550.h
index 039d249e19a..5254d3cdbca 100644
--- a/arch/ppc/syslib/gen550.h
+++ b/arch/ppc/syslib/gen550.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/gen550.h
- *
* gen550 prototypes
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/gen550_dbg.c b/arch/ppc/syslib/gen550_dbg.c
index 9ef0113c83d..9fcff74bfdd 100644
--- a/arch/ppc/syslib/gen550_dbg.c
+++ b/arch/ppc/syslib/gen550_dbg.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/gen550_dbg.c
- *
* A library of polled 16550 serial routines. These are intended to
* be used to support progress messages, xmon, kgdb, etc. on a
* variety of platforms.
diff --git a/arch/ppc/syslib/gen550_kgdb.c b/arch/ppc/syslib/gen550_kgdb.c
index 7239d5d7ddc..874078a7664 100644
--- a/arch/ppc/syslib/gen550_kgdb.c
+++ b/arch/ppc/syslib/gen550_kgdb.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/gen550_kgdb.c
- *
* Generic 16550 kgdb support intended to be useful on a variety
* of platforms. To enable this support, it is necessary to set
* the CONFIG_GEN550 option. Any virtual mapping of the serial
diff --git a/arch/ppc/syslib/gt64260_pic.c b/arch/ppc/syslib/gt64260_pic.c
index f97b3a9abd1..dc3bd9ecbbf 100644
--- a/arch/ppc/syslib/gt64260_pic.c
+++ b/arch/ppc/syslib/gt64260_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/gt64260_pic.c
- *
* Interrupt controller support for Galileo's GT64260.
*
* Author: Chris Zankel <source@mvista.com>
diff --git a/arch/ppc/syslib/harrier.c b/arch/ppc/syslib/harrier.c
index a6b3f864579..c1583f48832 100644
--- a/arch/ppc/syslib/harrier.c
+++ b/arch/ppc/syslib/harrier.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/harrier.c
- *
* Motorola MCG Harrier northbridge/memory controller support
*
* Author: Dale Farnsworth
diff --git a/arch/ppc/syslib/hawk_common.c b/arch/ppc/syslib/hawk_common.c
index a9911dc3a82..c5bf16b0d6a 100644
--- a/arch/ppc/syslib/hawk_common.c
+++ b/arch/ppc/syslib/hawk_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/hawk_common.c
- *
* Common Motorola PowerPlus Platform--really Falcon/Raven or HAWK.
*
* Author: Mark A. Greer
diff --git a/arch/ppc/syslib/ibm440gp_common.c b/arch/ppc/syslib/ibm440gp_common.c
index 0d6be2d6dd6..fbaae5f6d83 100644
--- a/arch/ppc/syslib/ibm440gp_common.c
+++ b/arch/ppc/syslib/ibm440gp_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ibm440gp_common.c
- *
* PPC440GP system library
*
* Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/ibm440gp_common.h b/arch/ppc/syslib/ibm440gp_common.h
index a054d83cb1a..f48529f3c23 100644
--- a/arch/ppc/syslib/ibm440gp_common.h
+++ b/arch/ppc/syslib/ibm440gp_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ibm440gp_common.h
- *
* PPC440GP system library
*
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440gx_common.c b/arch/ppc/syslib/ibm440gx_common.c
index c36db279b43..a7dd55f1c63 100644
--- a/arch/ppc/syslib/ibm440gx_common.c
+++ b/arch/ppc/syslib/ibm440gx_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ibm440gx_common.c
- *
* PPC440GX system library
*
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440gx_common.h b/arch/ppc/syslib/ibm440gx_common.h
index e73aa0411d3..a2ab9fab8e3 100644
--- a/arch/ppc/syslib/ibm440gx_common.h
+++ b/arch/ppc/syslib/ibm440gx_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ibm440gx_common.h
- *
* PPC440GX system library
*
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ibm440sp_common.c b/arch/ppc/syslib/ibm440sp_common.c
index cdafda127d8..293e4138d17 100644
--- a/arch/ppc/syslib/ibm440sp_common.c
+++ b/arch/ppc/syslib/ibm440sp_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ibm440sp_common.c
- *
* PPC440SP/PPC440SPe system library
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm440sp_common.h b/arch/ppc/syslib/ibm440sp_common.h
index a21a9906dcc..8077bf8ed11 100644
--- a/arch/ppc/syslib/ibm440sp_common.h
+++ b/arch/ppc/syslib/ibm440sp_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ibm440sp_common.h
- *
* PPC440SP system library
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm44x_common.c b/arch/ppc/syslib/ibm44x_common.c
index 71db11d2215..14a981a5cea 100644
--- a/arch/ppc/syslib/ibm44x_common.c
+++ b/arch/ppc/syslib/ibm44x_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ibm44x_common.c
- *
* PPC44x system library
*
* Matt Porter <mporter@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ibm44x_common.h b/arch/ppc/syslib/ibm44x_common.h
index b25a8995e4e..f179db8634e 100644
--- a/arch/ppc/syslib/ibm44x_common.h
+++ b/arch/ppc/syslib/ibm44x_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ibm44x_common.h
- *
* PPC44x system library
*
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/m8260_pci_erratum9.c b/arch/ppc/syslib/m8260_pci_erratum9.c
index 1dc7e4e1d49..99e4bc0e42a 100644
--- a/arch/ppc/syslib/m8260_pci_erratum9.c
+++ b/arch/ppc/syslib/m8260_pci_erratum9.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/mpc8260_pci9.c
- *
* Workaround for device erratum PCI 9.
* See Motorola's "XPC826xA Family Device Errata Reference."
* The erratum applies to all 8260 family Hip4 processors. It is scheduled
diff --git a/arch/ppc/syslib/m8260_setup.c b/arch/ppc/syslib/m8260_setup.c
index 76a2aa4ce65..b7a6cb2d8d5 100644
--- a/arch/ppc/syslib/m8260_setup.c
+++ b/arch/ppc/syslib/m8260_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/m8260_setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
diff --git a/arch/ppc/syslib/m8xx_setup.c b/arch/ppc/syslib/m8xx_setup.c
index 688616de3cd..dae9af78bde 100644
--- a/arch/ppc/syslib/m8xx_setup.c
+++ b/arch/ppc/syslib/m8xx_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/setup.c
- *
* Copyright (C) 1995 Linus Torvalds
* Adapted from 'alpha' version by Gary Thomas
* Modified by Cort Dougan (cort@cs.nmt.edu)
@@ -34,6 +32,13 @@
#include <linux/seq_file.h>
#include <linux/root_dev.h>
+#if defined(CONFIG_MTD) && defined(CONFIG_MTD_PHYSMAP)
+#include <linux/mtd/partitions.h>
+#include <linux/mtd/physmap.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/map.h>
+#endif
+
#include <asm/mmu.h>
#include <asm/reg.h>
#include <asm/residual.h>
@@ -49,6 +54,34 @@
#include "ppc8xx_pic.h"
+#ifdef CONFIG_MTD_PHYSMAP
+#define MPC8xxADS_BANK_WIDTH 4
+#endif
+
+#define MPC8xxADS_U_BOOT_SIZE 0x80000
+#define MPC8xxADS_FREE_AREA_OFFSET MPC8xxADS_U_BOOT_SIZE
+
+#if defined(CONFIG_MTD_PARTITIONS)
+ /*
+ NOTE: bank width and interleave relative to the installed flash
+ should have been chosen within MTD_CFI_GEOMETRY options.
+ */
+static struct mtd_partition mpc8xxads_partitions[] = {
+ {
+ .name = "bootloader",
+ .size = MPC8xxADS_U_BOOT_SIZE,
+ .offset = 0,
+ .mask_flags = MTD_WRITEABLE, /* force read-only */
+ }, {
+ .name = "User FS",
+ .offset = MPC8xxADS_FREE_AREA_OFFSET
+ }
+};
+
+#define mpc8xxads_part_num (sizeof (mpc8xxads_partitions) / sizeof (mpc8xxads_partitions[0]))
+
+#endif
+
static int m8xx_set_rtc_time(unsigned long time);
static unsigned long m8xx_get_rtc_time(void);
void m8xx_calibrate_decr(void);
@@ -71,6 +104,10 @@ board_init(void)
void __init
m8xx_setup_arch(void)
{
+#if defined(CONFIG_MTD) && defined(CONFIG_MTD_PHYSMAP)
+ bd_t *binfo = (bd_t *)__res;
+#endif
+
/* Reset the Communication Processor Module.
*/
m8xx_cpm_reset();
@@ -106,6 +143,17 @@ m8xx_setup_arch(void)
}
#endif
#endif
+
+#if defined (CONFIG_MPC86XADS) || defined (CONFIG_MPC885ADS)
+#if defined(CONFIG_MTD_PHYSMAP)
+ physmap_configure(binfo->bi_flashstart, binfo->bi_flashsize,
+ MPC8xxADS_BANK_WIDTH, NULL);
+#ifdef CONFIG_MTD_PARTITIONS
+ physmap_set_partitions(mpc8xxads_partitions, mpc8xxads_part_num);
+#endif /* CONFIG_MTD_PARTITIONS */
+#endif /* CONFIG_MTD_PHYSMAP */
+#endif
+
board_init();
}
@@ -140,9 +188,11 @@ void __init __attribute__ ((weak))
init_internal_rtc(void)
{
/* Disable the RTC one second and alarm interrupts. */
- out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) & ~(RTCSC_SIE | RTCSC_ALE));
+ clrbits16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, (RTCSC_SIE | RTCSC_ALE));
+
/* Enable the RTC */
- out_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, in_be16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc) | (RTCSC_RTF | RTCSC_RTE));
+ setbits16(&((immap_t *)IMAP_ADDR)->im_sit.sit_rtcsc, (RTCSC_RTF | RTCSC_RTE));
+
}
/* The decrementer counts at the system (internal) clock frequency divided by
@@ -159,8 +209,7 @@ void __init m8xx_calibrate_decr(void)
out_be32(&((immap_t *)IMAP_ADDR)->im_clkrstk.cark_sccrk, KAPWR_KEY);
/* Force all 8xx processors to use divide by 16 processor clock. */
- out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr,
- in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr)|0x02000000);
+ setbits32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_sccr, 0x02000000);
/* Processor frequency is MHz.
* The value 'fp' is the number of decrementer ticks per second.
*/
@@ -239,8 +288,8 @@ m8xx_restart(char *cmd)
__volatile__ unsigned char dummy;
local_irq_disable();
- out_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr, in_be32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr) | 0x00000080);
+ setbits32(&((immap_t *)IMAP_ADDR)->im_clkrst.car_plprcr, 0x00000080);
/* Clear the ME bit in MSR to cause checkstop on machine check
*/
mtmsr(mfmsr() & ~0x1000);
@@ -310,8 +359,8 @@ m8xx_init_IRQ(void)
i8259_init(0);
/* The i8259 cascade interrupt must be level sensitive. */
- out_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel, in_be32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel & ~(0x80000000 >> ISA_BRIDGE_INT)));
+ clrbits32(&((immap_t *)IMAP_ADDR)->im_siu_conf.sc_siel, (0x80000000 >> ISA_BRIDGE_INT));
if (setup_irq(ISA_BRIDGE_INT, &mbx_i8259_irqaction))
enable_irq(ISA_BRIDGE_INT);
#endif /* CONFIG_PCI */
diff --git a/arch/ppc/syslib/m8xx_wdt.c b/arch/ppc/syslib/m8xx_wdt.c
index df6c9557b86..ac11d7bab44 100644
--- a/arch/ppc/syslib/m8xx_wdt.c
+++ b/arch/ppc/syslib/m8xx_wdt.c
@@ -41,8 +41,7 @@ static irqreturn_t m8xx_wdt_interrupt(int irq, void *dev, struct pt_regs *regs)
m8xx_wdt_reset();
- out_be16(&imap->im_sit.sit_piscr, in_be16(&imap->im_sit.sit_piscr) | PISCR_PS); /* clear irq */
-
+ setbits16(&imap->im_sit.sit_piscr, PISCR_PS);
return IRQ_HANDLED;
}
diff --git a/arch/ppc/syslib/mpc10x_common.c b/arch/ppc/syslib/mpc10x_common.c
index 3e039706bdb..2fc7c4150a1 100644
--- a/arch/ppc/syslib/mpc10x_common.c
+++ b/arch/ppc/syslib/mpc10x_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc10x_common.c
- *
* Common routines for the Motorola SPS MPC106, MPC107 and MPC8240 Host bridge,
* Mem ctlr, EPIC, etc.
*
diff --git a/arch/ppc/syslib/mpc52xx_devices.c b/arch/ppc/syslib/mpc52xx_devices.c
index da3c74bfdc9..7487539a4e9 100644
--- a/arch/ppc/syslib/mpc52xx_devices.c
+++ b/arch/ppc/syslib/mpc52xx_devices.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_devices.c
- *
* Freescale MPC52xx device descriptions
*
*
diff --git a/arch/ppc/syslib/mpc52xx_pci.c b/arch/ppc/syslib/mpc52xx_pci.c
index 313c96ec7eb..9ec525f9fe9 100644
--- a/arch/ppc/syslib/mpc52xx_pci.c
+++ b/arch/ppc/syslib/mpc52xx_pci.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_pci.c
- *
* PCI code for the Freescale MPC52xx embedded CPU.
*
*
diff --git a/arch/ppc/syslib/mpc52xx_pci.h b/arch/ppc/syslib/mpc52xx_pci.h
index 04b509a0253..77d47dbba85 100644
--- a/arch/ppc/syslib/mpc52xx_pci.h
+++ b/arch/ppc/syslib/mpc52xx_pci.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_pci.h
- *
* PCI Include file the Freescale MPC52xx embedded cpu chips
*
*
diff --git a/arch/ppc/syslib/mpc52xx_pic.c b/arch/ppc/syslib/mpc52xx_pic.c
index 4c4497e6251..c4406f9dc6a 100644
--- a/arch/ppc/syslib/mpc52xx_pic.c
+++ b/arch/ppc/syslib/mpc52xx_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_pic.c
- *
* Programmable Interrupt Controller functions for the Freescale MPC52xx
* embedded CPU.
*
diff --git a/arch/ppc/syslib/mpc52xx_setup.c b/arch/ppc/syslib/mpc52xx_setup.c
index a4a4b02227d..2ee48ce0a51 100644
--- a/arch/ppc/syslib/mpc52xx_setup.c
+++ b/arch/ppc/syslib/mpc52xx_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_setup.c
- *
* Common code for the boards based on Freescale MPC52xx embedded CPU.
*
*
diff --git a/arch/ppc/syslib/mpc52xx_sys.c b/arch/ppc/syslib/mpc52xx_sys.c
index 9a0f90aa8aa..b4e6f978f05 100644
--- a/arch/ppc/syslib/mpc52xx_sys.c
+++ b/arch/ppc/syslib/mpc52xx_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc52xx_sys.c
- *
* Freescale MPC52xx system descriptions
*
*
diff --git a/arch/ppc/syslib/mpc83xx_devices.c b/arch/ppc/syslib/mpc83xx_devices.c
index f9b95de70e2..1af2c000fcf 100644
--- a/arch/ppc/syslib/mpc83xx_devices.c
+++ b/arch/ppc/syslib/mpc83xx_devices.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/83xx/mpc83xx_devices.c
- *
* MPC83xx Device descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc83xx_sys.c b/arch/ppc/syslib/mpc83xx_sys.c
index 82cf3ab77f4..0498ae7e01e 100644
--- a/arch/ppc/syslib/mpc83xx_sys.c
+++ b/arch/ppc/syslib/mpc83xx_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/83xx/mpc83xx_sys.c
- *
* MPC83xx System descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc85xx_devices.c b/arch/ppc/syslib/mpc85xx_devices.c
index 00e9b6ff2f6..7735336f5b8 100644
--- a/arch/ppc/syslib/mpc85xx_devices.c
+++ b/arch/ppc/syslib/mpc85xx_devices.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc85xx_devices.c
- *
* MPC85xx Device descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc85xx_sys.c b/arch/ppc/syslib/mpc85xx_sys.c
index 397cfbcce5e..d96a93dbcb5 100644
--- a/arch/ppc/syslib/mpc85xx_sys.c
+++ b/arch/ppc/syslib/mpc85xx_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/85xx/mpc85xx_sys.c
- *
* MPC85xx System descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc8xx_devices.c b/arch/ppc/syslib/mpc8xx_devices.c
index 92dc98b36bd..bd41ed83beb 100644
--- a/arch/ppc/syslib/mpc8xx_devices.c
+++ b/arch/ppc/syslib/mpc8xx_devices.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mpc8xx_devices.c
- *
* MPC8xx Device descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mpc8xx_sys.c b/arch/ppc/syslib/mpc8xx_sys.c
index d3c61752160..eee21328485 100644
--- a/arch/ppc/syslib/mpc8xx_sys.c
+++ b/arch/ppc/syslib/mpc8xx_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/platforms/mpc8xx_sys.c
- *
* MPC8xx System descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/mv64360_pic.c b/arch/ppc/syslib/mv64360_pic.c
index 58b0aa813e8..5a19697060f 100644
--- a/arch/ppc/syslib/mv64360_pic.c
+++ b/arch/ppc/syslib/mv64360_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/mv64360_pic.c
- *
* Interrupt controller support for Marvell's MV64360.
*
* Author: Rabeeh Khoury <rabeeh@galileo.co.il>
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index 1f01b7e2376..3b039c30a43 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mv64x60.c
- *
* Common routines for the Marvell/Galileo Discovery line of host bridges
* (gt64260, mv64360, mv64460, ...).
*
diff --git a/arch/ppc/syslib/mv64x60_dbg.c b/arch/ppc/syslib/mv64x60_dbg.c
index fa5b2e45e0c..9cf18764a1a 100644
--- a/arch/ppc/syslib/mv64x60_dbg.c
+++ b/arch/ppc/syslib/mv64x60_dbg.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mv64x60_dbg.c
- *
* KGDB and progress routines for the Marvell/Galileo MV64x60 (Discovery).
*
* Author: Mark A. Greer <mgreer@mvista.com>
diff --git a/arch/ppc/syslib/mv64x60_win.c b/arch/ppc/syslib/mv64x60_win.c
index 5b827e2bbe2..4bf1ad17bf1 100644
--- a/arch/ppc/syslib/mv64x60_win.c
+++ b/arch/ppc/syslib/mv64x60_win.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/mv64x60_win.c
- *
* Tables with info on how to manipulate the 32 & 64 bit windows on the
* various types of Marvell bridge chips.
*
diff --git a/arch/ppc/syslib/ocp.c b/arch/ppc/syslib/ocp.c
index 2fe28ded2c6..a4ecc2ee579 100644
--- a/arch/ppc/syslib/ocp.c
+++ b/arch/ppc/syslib/ocp.c
@@ -451,10 +451,9 @@ ocp_driver_init(void)
DBG(("ocp: ocp_driver_init()...\n"));
/* Allocate/register primary OCP bus */
- ocp_bus = kmalloc(sizeof(struct device), GFP_KERNEL);
+ ocp_bus = kzalloc(sizeof(struct device), GFP_KERNEL);
if (ocp_bus == NULL)
return 1;
- memset(ocp_bus, 0, sizeof(struct device));
strcpy(ocp_bus->bus_id, "ocp");
bus_register(&ocp_bus_type);
diff --git a/arch/ppc/syslib/open_pic.c b/arch/ppc/syslib/open_pic.c
index 894779712b4..38e5b93fbe4 100644
--- a/arch/ppc/syslib/open_pic.c
+++ b/arch/ppc/syslib/open_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
- *
* Copyright (C) 1997 Geert Uytterhoeven
*
* This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/syslib/open_pic2.c b/arch/ppc/syslib/open_pic2.c
index 1c40049b9a4..bcbe40de26f 100644
--- a/arch/ppc/syslib/open_pic2.c
+++ b/arch/ppc/syslib/open_pic2.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/open_pic.c -- OpenPIC Interrupt Handling
- *
* Copyright (C) 1997 Geert Uytterhoeven
*
* This file is subject to the terms and conditions of the GNU General Public
diff --git a/arch/ppc/syslib/open_pic_defs.h b/arch/ppc/syslib/open_pic_defs.h
index 6c94e713146..3a25de7cb57 100644
--- a/arch/ppc/syslib/open_pic_defs.h
+++ b/arch/ppc/syslib/open_pic_defs.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/open_pic_defs.h -- OpenPIC definitions
- *
* Copyright (C) 1997 Geert Uytterhoeven
*
* This file is based on the following documentation:
diff --git a/arch/ppc/syslib/pci_auto.c b/arch/ppc/syslib/pci_auto.c
index d64207c2a97..ee20a86fcc4 100644
--- a/arch/ppc/syslib/pci_auto.c
+++ b/arch/ppc/syslib/pci_auto.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/pci_auto.c
- *
* PCI autoconfiguration library
*
* Author: Matt Porter <mporter@mvista.com>
diff --git a/arch/ppc/syslib/ppc4xx_dma.c b/arch/ppc/syslib/ppc4xx_dma.c
index 05ccd598dd4..b40b96a8c60 100644
--- a/arch/ppc/syslib/ppc4xx_dma.c
+++ b/arch/ppc/syslib/ppc4xx_dma.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ppc4xx_dma.c
- *
* IBM PPC4xx DMA engine core library
*
* Copyright 2000-2004 MontaVista Software Inc.
diff --git a/arch/ppc/syslib/ppc4xx_pic.c b/arch/ppc/syslib/ppc4xx_pic.c
index aa4165144ec..fd9af0fc0e9 100644
--- a/arch/ppc/syslib/ppc4xx_pic.c
+++ b/arch/ppc/syslib/ppc4xx_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc4xx_pic.c
- *
* Interrupt controller driver for PowerPC 4xx-based processors.
*
* Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
diff --git a/arch/ppc/syslib/ppc4xx_pm.c b/arch/ppc/syslib/ppc4xx_pm.c
deleted file mode 100644
index 60a47920488..00000000000
--- a/arch/ppc/syslib/ppc4xx_pm.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Author: Armin Kuster <akuster@mvista.com>
- *
- * 2002 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- *
- * This an attempt to get Power Management going for the IBM 4xx processor.
- * This was derived from the ppc4xx._setup.c file
- */
-
-#include <linux/config.h>
-#include <linux/init.h>
-
-#include <asm/ibm4xx.h>
-
-void __init
-ppc4xx_pm_init(void)
-{
-
- unsigned int value = 0;
-
- /* turn off unused hardware to save power */
-#ifdef CONFIG_405GP
- value |= CPM_DCP; /* CodePack */
-#endif
-
-#if !defined(CONFIG_IBM_OCP_GPIO)
- value |= CPM_GPIO0;
-#endif
-
-#if !defined(CONFIG_PPC405_I2C_ADAP)
- value |= CPM_IIC0;
-#ifdef CONFIG_STB03xxx
- value |= CPM_IIC1;
-#endif
-#endif
-
-
-#if !defined(CONFIG_405_DMA)
- value |= CPM_DMA;
-#endif
-
- mtdcr(DCRN_CPMFR, value);
-
-}
diff --git a/arch/ppc/syslib/ppc4xx_sgdma.c b/arch/ppc/syslib/ppc4xx_sgdma.c
index 9f76e8ee39e..280ea010a9c 100644
--- a/arch/ppc/syslib/ppc4xx_sgdma.c
+++ b/arch/ppc/syslib/ppc4xx_sgdma.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/ppc4xx_sgdma.c
- *
* IBM PPC4xx DMA engine scatter/gather library
*
* Copyright 2002-2003 MontaVista Software Inc.
diff --git a/arch/ppc/syslib/ppc83xx_setup.c b/arch/ppc/syslib/ppc83xx_setup.c
index 7bada82527a..26afd637dc8 100644
--- a/arch/ppc/syslib/ppc83xx_setup.c
+++ b/arch/ppc/syslib/ppc83xx_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc83xx_setup.c
- *
* MPC83XX common board code
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc83xx_setup.h b/arch/ppc/syslib/ppc83xx_setup.h
index a122a7322e5..478b011cd96 100644
--- a/arch/ppc/syslib/ppc83xx_setup.h
+++ b/arch/ppc/syslib/ppc83xx_setup.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc83xx_setup.h
- *
* MPC83XX common board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_common.c b/arch/ppc/syslib/ppc85xx_common.c
index 19ad537225e..0145c968f9a 100644
--- a/arch/ppc/syslib/ppc85xx_common.c
+++ b/arch/ppc/syslib/ppc85xx_common.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc85xx_common.c
- *
* MPC85xx support routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_common.h b/arch/ppc/syslib/ppc85xx_common.h
index 94edf32151d..182744a1321 100644
--- a/arch/ppc/syslib/ppc85xx_common.h
+++ b/arch/ppc/syslib/ppc85xx_common.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc85xx_common.h
- *
* MPC85xx support routines
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc85xx_setup.c b/arch/ppc/syslib/ppc85xx_setup.c
index e4dda43fdaa..79b7089d750 100644
--- a/arch/ppc/syslib/ppc85xx_setup.c
+++ b/arch/ppc/syslib/ppc85xx_setup.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc85xx_setup.c
- *
* MPC85XX common board code
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -237,7 +235,7 @@ mpc85xx_setup_pci2(struct pci_controller *hose)
(__ilog2(MPC85XX_PCI2_UPPER_MEM - MPC85XX_PCI2_LOWER_MEM + 1) - 1);
/* Setup outbound IO windows @ MPC85XX_PCI2_IO_BASE */
- pci->potar2 = (MPC85XX_PCI2_LOWER_IO >> 12) & 0x000fffff;;
+ pci->potar2 = (MPC85XX_PCI2_LOWER_IO >> 12) & 0x000fffff;
pci->potear2 = 0x00000000;
pci->powbar2 = (MPC85XX_PCI2_IO_BASE >> 12) & 0x000fffff;
/* Enable, IO R/W */
diff --git a/arch/ppc/syslib/ppc85xx_setup.h b/arch/ppc/syslib/ppc85xx_setup.h
index e340b0545fb..f55b8032d3d 100644
--- a/arch/ppc/syslib/ppc85xx_setup.h
+++ b/arch/ppc/syslib/ppc85xx_setup.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc85xx_setup.h
- *
* MPC85XX common board definitions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/ppc_sys.c b/arch/ppc/syslib/ppc_sys.c
index c0b93c4191e..60c724e1158 100644
--- a/arch/ppc/syslib/ppc_sys.c
+++ b/arch/ppc/syslib/ppc_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/ppc_sys.c
- *
* PPC System library functions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
@@ -15,11 +13,22 @@
*/
#include <linux/string.h>
+#include <linux/bootmem.h>
#include <asm/ppc_sys.h>
int (*ppc_sys_device_fixup) (struct platform_device * pdev);
static int ppc_sys_inited;
+static int ppc_sys_func_inited;
+
+static const char *ppc_sys_func_names[] = {
+ [PPC_SYS_FUNC_DUMMY] = "dummy",
+ [PPC_SYS_FUNC_ETH] = "eth",
+ [PPC_SYS_FUNC_UART] = "uart",
+ [PPC_SYS_FUNC_HLDC] = "hldc",
+ [PPC_SYS_FUNC_USB] = "usb",
+ [PPC_SYS_FUNC_IRDA] = "irda",
+};
void __init identify_ppc_sys_by_id(u32 id)
{
@@ -38,13 +47,13 @@ void __init identify_ppc_sys_by_id(u32 id)
void __init identify_ppc_sys_by_name(char *name)
{
unsigned int i = 0;
- while (ppc_sys_specs[i].ppc_sys_name[0])
- {
+ while (ppc_sys_specs[i].ppc_sys_name[0]) {
if (!strcmp(ppc_sys_specs[i].ppc_sys_name, name))
break;
i++;
}
cur_ppc_sys_spec = &ppc_sys_specs[i];
+
return;
}
@@ -128,6 +137,165 @@ void ppc_sys_device_remove(enum ppc_sys_devices dev)
}
}
+/* Platform-notify mapping
+ * Helper function for BSP code to assign board-specific platfom-divice bits
+ */
+
+void platform_notify_map(const struct platform_notify_dev_map *map,
+ struct device *dev)
+{
+ struct platform_device *pdev;
+ int len, idx;
+ const char *s;
+
+ /* do nothing if no device or no bus_id */
+ if (!dev || !dev->bus_id)
+ return;
+
+ /* call per device map */
+ while (map->bus_id != NULL) {
+ idx = -1;
+ s = strrchr(dev->bus_id, '.');
+ if (s != NULL)
+ idx = (int)simple_strtol(s + 1, NULL, 10);
+ else
+ s = dev->bus_id;
+
+ len = s - dev->bus_id;
+
+ if (!strncmp(dev->bus_id, map->bus_id, len)) {
+ pdev = container_of(dev, struct platform_device, dev);
+ map->rtn(pdev, idx);
+ }
+ map++;
+ }
+}
+
+/*
+ Function assignment stuff.
+ Intended to work as follows:
+ the device name defined in foo_devices.c will be concatenated with :"func",
+ where func is string map of respective function from platfom_device_func enum
+
+ The PPC_SYS_FUNC_DUMMY function is intended to remove all assignments, making the device to appear
+ in platform bus with unmodified name.
+ */
+
+/*
+ Here we'll replace .name pointers with fixed-lenght strings
+ Hereby, this should be called *before* any func stuff triggeded.
+ */
+void ppc_sys_device_initfunc(void)
+{
+ int i;
+ const char *name;
+ static char new_names[NUM_PPC_SYS_DEVS][BUS_ID_SIZE];
+ enum ppc_sys_devices cur_dev;
+
+ /* If inited yet, do nothing */
+ if (ppc_sys_func_inited)
+ return;
+
+ for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
+ if ((cur_dev = cur_ppc_sys_spec->device_list[i]) < 0)
+ continue;
+
+ if (ppc_sys_platform_devices[cur_dev].name) {
+ /*backup name */
+ name = ppc_sys_platform_devices[cur_dev].name;
+ strlcpy(new_names[i], name, BUS_ID_SIZE);
+ ppc_sys_platform_devices[cur_dev].name = new_names[i];
+ }
+ }
+
+ ppc_sys_func_inited = 1;
+}
+
+/*The "engine" of the func stuff. Here we either concat specified function string description
+ to the name, or remove it if PPC_SYS_FUNC_DUMMY parameter is passed here*/
+void ppc_sys_device_setfunc(enum ppc_sys_devices dev,
+ enum platform_device_func func)
+{
+ char *s;
+ char *name = (char *)ppc_sys_platform_devices[dev].name;
+ char tmp[BUS_ID_SIZE];
+
+ if (!ppc_sys_func_inited) {
+ printk(KERN_ERR "Unable to alter function - not inited!\n");
+ return;
+ }
+
+ if (ppc_sys_inited) {
+ platform_device_unregister(&ppc_sys_platform_devices[dev]);
+ }
+
+ if ((s = (char *)strchr(name, ':')) != NULL) { /* reassign */
+ /* Either change the name after ':' or remove func modifications */
+ if (func != PPC_SYS_FUNC_DUMMY)
+ strlcpy(s + 1, ppc_sys_func_names[func], BUS_ID_SIZE);
+ else
+ *s = 0;
+ } else if (func != PPC_SYS_FUNC_DUMMY) {
+ /* do assignment if it is not just "clear" request */
+ sprintf(tmp, "%s:%s", name, ppc_sys_func_names[func]);
+ strlcpy(name, tmp, BUS_ID_SIZE);
+ }
+
+ if (ppc_sys_inited) {
+ platform_device_register(&ppc_sys_platform_devices[dev]);
+ }
+}
+
+void ppc_sys_device_disable(enum ppc_sys_devices dev)
+{
+ BUG_ON(cur_ppc_sys_spec == NULL);
+
+ /*Check if it is enabled*/
+ if(!(cur_ppc_sys_spec->config[dev] & PPC_SYS_CONFIG_DISABLED)) {
+ if (ppc_sys_inited) {
+ platform_device_unregister(&ppc_sys_platform_devices[dev]);
+ }
+ cur_ppc_sys_spec->config[dev] |= PPC_SYS_CONFIG_DISABLED;
+ }
+}
+
+void ppc_sys_device_enable(enum ppc_sys_devices dev)
+{
+ BUG_ON(cur_ppc_sys_spec == NULL);
+
+ /*Check if it is disabled*/
+ if(cur_ppc_sys_spec->config[dev] & PPC_SYS_CONFIG_DISABLED) {
+ if (ppc_sys_inited) {
+ platform_device_register(&ppc_sys_platform_devices[dev]);
+ }
+ cur_ppc_sys_spec->config[dev] &= ~PPC_SYS_CONFIG_DISABLED;
+ }
+
+}
+
+void ppc_sys_device_enable_all(void)
+{
+ enum ppc_sys_devices cur_dev;
+ int i;
+
+ for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
+ cur_dev = cur_ppc_sys_spec->device_list[i];
+ ppc_sys_device_enable(cur_dev);
+ }
+}
+
+void ppc_sys_device_disable_all(void)
+{
+ enum ppc_sys_devices cur_dev;
+ int i;
+
+ for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
+ cur_dev = cur_ppc_sys_spec->device_list[i];
+ ppc_sys_device_disable(cur_dev);
+ }
+}
+
+
static int __init ppc_sys_init(void)
{
unsigned int i, dev_id, ret = 0;
@@ -136,7 +304,8 @@ static int __init ppc_sys_init(void)
for (i = 0; i < cur_ppc_sys_spec->num_devices; i++) {
dev_id = cur_ppc_sys_spec->device_list[i];
- if (dev_id != -1) {
+ if ((dev_id != -1) &&
+ !(cur_ppc_sys_spec->config[dev_id] & PPC_SYS_CONFIG_DISABLED)) {
if (ppc_sys_device_fixup != NULL)
ppc_sys_device_fixup(&ppc_sys_platform_devices
[dev_id]);
diff --git a/arch/ppc/syslib/pq2_devices.c b/arch/ppc/syslib/pq2_devices.c
index 6ff3aab82fc..0636aed7b82 100644
--- a/arch/ppc/syslib/pq2_devices.c
+++ b/arch/ppc/syslib/pq2_devices.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/pq2_devices.c
- *
* PQ2 Device descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/pq2_sys.c b/arch/ppc/syslib/pq2_sys.c
index 36d6e217994..75e64f1c144 100644
--- a/arch/ppc/syslib/pq2_sys.c
+++ b/arch/ppc/syslib/pq2_sys.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/pq2_devices.c
- *
* PQ2 System descriptions
*
* Maintainer: Kumar Gala <galak@kernel.crashing.org>
diff --git a/arch/ppc/syslib/prep_nvram.c b/arch/ppc/syslib/prep_nvram.c
index 2c6364d9641..474dccbc4a8 100644
--- a/arch/ppc/syslib/prep_nvram.c
+++ b/arch/ppc/syslib/prep_nvram.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/prep_nvram.c
- *
* Copyright (C) 1998 Corey Minyard
*
* This reads the NvRAM on PReP compliant machines (generally from IBM or
diff --git a/arch/ppc/syslib/todc_time.c b/arch/ppc/syslib/todc_time.c
index 1323c641c19..a8168b8e568 100644
--- a/arch/ppc/syslib/todc_time.c
+++ b/arch/ppc/syslib/todc_time.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/todc_time.c
- *
* Time of Day Clock support for the M48T35, M48T37, M48T59, and MC146818
* Real Time Clocks/Timekeepers.
*
diff --git a/arch/ppc/syslib/xilinx_pic.c b/arch/ppc/syslib/xilinx_pic.c
index 47f04c71fe9..e672b600f31 100644
--- a/arch/ppc/syslib/xilinx_pic.c
+++ b/arch/ppc/syslib/xilinx_pic.c
@@ -1,6 +1,4 @@
/*
- * arch/ppc/syslib/xilinx_pic.c
- *
* Interrupt controller driver for Xilinx Virtex-II Pro.
*
* Author: MontaVista Software, Inc.
@@ -15,7 +13,7 @@
#include <linux/init.h>
#include <linux/irq.h>
#include <asm/io.h>
-#include <asm/xparameters.h>
+#include <platforms/4xx/xparameters/xparameters.h>
#include <asm/ibm4xx.h>
#include <asm/machdep.h>
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index b7ca5bf9acf..2b7364ed23b 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -460,6 +460,8 @@ config PCMCIA
source "drivers/base/Kconfig"
+source "drivers/connector/Kconfig"
+
source "drivers/scsi/Kconfig"
source "drivers/s390/Kconfig"
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index d06a8d71c71..54d35c13090 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -531,12 +531,11 @@ int appldata_register_ops(struct appldata_ops *ops)
P_ERROR("ctl_nr %i already in use!\n", ops->ctl_nr);
return -EBUSY;
}
- ops->ctl_table = kmalloc(4*sizeof(struct ctl_table), GFP_KERNEL);
+ ops->ctl_table = kzalloc(4*sizeof(struct ctl_table), GFP_KERNEL);
if (ops->ctl_table == NULL) {
P_ERROR("Not enough memory for %s ctl_table!\n", ops->name);
return -ENOMEM;
}
- memset(ops->ctl_table, 0, 4*sizeof(struct ctl_table));
spin_lock(&appldata_ops_lock);
list_for_each(lh, &appldata_ops_list) {
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 896d39d0e4c..06a3fbc1253 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -204,16 +204,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
goto fail_malloc_areas2;
}
for(j = 0; j < pages_per_area; j++) {
- areas[i][j] = (debug_entry_t*)kmalloc(PAGE_SIZE,
- GFP_KERNEL);
+ areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
if(!areas[i][j]) {
for(j--; j >=0 ; j--) {
kfree(areas[i][j]);
}
kfree(areas[i]);
goto fail_malloc_areas2;
- } else {
- memset(areas[i][j],0,PAGE_SIZE);
}
}
}
@@ -249,14 +246,12 @@ debug_info_alloc(char *name, int pages_per_area, int nr_areas, int buf_size,
rc = (debug_info_t*) kmalloc(sizeof(debug_info_t), GFP_KERNEL);
if(!rc)
goto fail_malloc_rc;
- rc->active_entries = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL);
+ rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
if(!rc->active_entries)
goto fail_malloc_active_entries;
- memset(rc->active_entries, 0, nr_areas * sizeof(int));
- rc->active_pages = (int*)kmalloc(nr_areas * sizeof(int), GFP_KERNEL);
+ rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
if(!rc->active_pages)
goto fail_malloc_active_pages;
- memset(rc->active_pages, 0, nr_areas * sizeof(int));
if((mode == ALL_AREAS) && (pages_per_area != 0)){
rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
if(!rc->areas)
diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
index da6fbae8df9..99182a415fe 100644
--- a/arch/s390/kernel/process.c
+++ b/arch/s390/kernel/process.c
@@ -103,7 +103,7 @@ extern void s390_handle_mcck(void);
/*
* The idle loop on a S390...
*/
-void default_idle(void)
+static void default_idle(void)
{
int cpu, rc;
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 24f62f16c0e..0a04e4a564b 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -78,8 +78,6 @@ extern int _text,_etext, _edata, _end;
#include <asm/setup.h>
-static char command_line[COMMAND_LINE_SIZE] = { 0, };
-
static struct resource code_resource = {
.name = "Kernel code",
.start = (unsigned long) &_text,
@@ -335,63 +333,38 @@ add_memory_hole(unsigned long start, unsigned long end)
}
}
-static void __init
-parse_cmdline_early(char **cmdline_p)
+static int __init early_parse_mem(char *p)
+{
+ memory_end = memparse(p, &p);
+ return 0;
+}
+early_param("mem", early_parse_mem);
+
+/*
+ * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
+ */
+static int __init early_parse_ipldelay(char *p)
{
- char c = ' ', cn, *to = command_line, *from = COMMAND_LINE;
unsigned long delay = 0;
- /* Save unparsed command line copy for /proc/cmdline */
- memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
- saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
+ delay = simple_strtoul(p, &p, 0);
- for (;;) {
- /*
- * "mem=XXX[kKmM]" sets memsize
- */
- if (c == ' ' && strncmp(from, "mem=", 4) == 0) {
- memory_end = simple_strtoul(from+4, &from, 0);
- if ( *from == 'K' || *from == 'k' ) {
- memory_end = memory_end << 10;
- from++;
- } else if ( *from == 'M' || *from == 'm' ) {
- memory_end = memory_end << 20;
- from++;
- }
- }
- /*
- * "ipldelay=XXX[sm]" sets ipl delay in seconds or minutes
- */
- if (c == ' ' && strncmp(from, "ipldelay=", 9) == 0) {
- delay = simple_strtoul(from+9, &from, 0);
- if (*from == 's' || *from == 'S') {
- delay = delay*1000000;
- from++;
- } else if (*from == 'm' || *from == 'M') {
- delay = delay*60*1000000;
- from++;
- }
- /* now wait for the requested amount of time */
- udelay(delay);
- }
- cn = *(from++);
- if (!cn)
- break;
- if (cn == '\n')
- cn = ' '; /* replace newlines with space */
- if (cn == 0x0d)
- cn = ' '; /* replace 0x0d with space */
- if (cn == ' ' && c == ' ')
- continue; /* remove additional spaces */
- c = cn;
- if (to - command_line >= COMMAND_LINE_SIZE)
- break;
- *(to++) = c;
+ switch (*p) {
+ case 's':
+ case 'S':
+ delay *= 1000000;
+ break;
+ case 'm':
+ case 'M':
+ delay *= 60 * 1000000;
}
- if (c == ' ' && to > command_line) to--;
- *to = '\0';
- *cmdline_p = command_line;
+
+ /* now wait for the requested amount of time */
+ udelay(delay);
+
+ return 0;
}
+early_param("ipldelay", early_parse_ipldelay);
static void __init
setup_lowcore(void)
@@ -580,9 +553,26 @@ setup_arch(char **cmdline_p)
"We are running native (64 bit mode)\n");
#endif /* CONFIG_64BIT */
+ /* Save unparsed command line copy for /proc/cmdline */
+ strlcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
+
+ *cmdline_p = COMMAND_LINE;
+ *(*cmdline_p + COMMAND_LINE_SIZE - 1) = '\0';
+
ROOT_DEV = Root_RAM0;
+
+ init_mm.start_code = PAGE_OFFSET;
+ init_mm.end_code = (unsigned long) &_etext;
+ init_mm.end_data = (unsigned long) &_edata;
+ init_mm.brk = (unsigned long) &_end;
+
+ memory_end = memory_size;
+
+ parse_early_param();
+
#ifndef CONFIG_64BIT
- memory_end = memory_size & ~0x400000UL; /* align memory end to 4MB */
+ memory_end &= ~0x400000UL;
+
/*
* We need some free virtual space to be able to do vmalloc.
* On a machine with 2GB memory we make sure that we have at
@@ -591,17 +581,9 @@ setup_arch(char **cmdline_p)
if (memory_end > 1920*1024*1024)
memory_end = 1920*1024*1024;
#else /* CONFIG_64BIT */
- memory_end = memory_size & ~0x200000UL; /* detected in head.s */
+ memory_end &= ~0x200000UL;
#endif /* CONFIG_64BIT */
- init_mm.start_code = PAGE_OFFSET;
- init_mm.end_code = (unsigned long) &_etext;
- init_mm.end_data = (unsigned long) &_edata;
- init_mm.brk = (unsigned long) &_end;
-
- parse_cmdline_early(cmdline_p);
- parse_early_param();
-
setup_memory();
setup_resources();
setup_lowcore();
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 7dbe00c76c6..2b8841f8553 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -665,7 +665,9 @@ __cpu_up(unsigned int cpu)
cpu_lowcore->current_task = (unsigned long) idle;
cpu_lowcore->cpu_data.cpu_nr = cpu;
eieio();
- signal_processor(cpu,sigp_restart);
+
+ while (signal_processor(cpu,sigp_restart) == sigp_busy)
+ udelay(10);
while (!cpu_online(cpu))
cpu_relax();
@@ -799,9 +801,7 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
*/
print_cpu_info(&S390_lowcore.cpu_data);
- for(i = 0; i < NR_CPUS; i++) {
- if (!cpu_possible(i))
- continue;
+ for_each_cpu(i) {
lowcore_ptr[i] = (struct _lowcore *)
__get_free_pages(GFP_KERNEL|GFP_DMA,
sizeof(void*) == 8 ? 1 : 0);
diff --git a/arch/s390/mm/cmm.c b/arch/s390/mm/cmm.c
index b075ab499d0..51596f42923 100644
--- a/arch/s390/mm/cmm.c
+++ b/arch/s390/mm/cmm.c
@@ -339,19 +339,19 @@ static struct ctl_table cmm_table[] = {
{
.ctl_name = VM_CMM_PAGES,
.procname = "cmm_pages",
- .mode = 0600,
+ .mode = 0644,
.proc_handler = &cmm_pages_handler,
},
{
.ctl_name = VM_CMM_TIMED_PAGES,
.procname = "cmm_timed_pages",
- .mode = 0600,
+ .mode = 0644,
.proc_handler = &cmm_pages_handler,
},
{
.ctl_name = VM_CMM_TIMEOUT,
.procname = "cmm_timeout",
- .mode = 0600,
+ .mode = 0644,
.proc_handler = &cmm_timeout_handler,
},
{ .ctl_name = 0 }
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 08c9515c480..c72e17a96ee 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -172,7 +172,7 @@ include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER
archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
-.PHONY: maketools FORCE
+PHONY += maketools FORCE
maketools: include/linux/version.h FORCE
$(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 6883c00728c..b56e79632f2 100644
--- a/arch/sh/kernel/irq.c
+++ b/arch/sh/kernel/irq.c
@@ -35,9 +35,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_puts(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
diff --git a/arch/sh/kernel/process.c b/arch/sh/kernel/process.c
index 9fd1723e621..22dc9c21201 100644
--- a/arch/sh/kernel/process.c
+++ b/arch/sh/kernel/process.c
@@ -19,7 +19,6 @@
#include <linux/slab.h>
#include <linux/pm.h>
#include <linux/ptrace.h>
-#include <linux/platform.h>
#include <linux/kallsyms.h>
#include <linux/kexec.h>
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c
index a067a34e0b6..c0e79843f58 100644
--- a/arch/sh/kernel/setup.c
+++ b/arch/sh/kernel/setup.c
@@ -404,9 +404,8 @@ static int __init topology_init(void)
{
int cpu_id;
- for (cpu_id = 0; cpu_id < NR_CPUS; cpu_id++)
- if (cpu_possible(cpu_id))
- register_cpu(&cpu[cpu_id], cpu_id, NULL);
+ for_each_cpu(cpu_id)
+ register_cpu(&cpu[cpu_id], cpu_id, NULL);
return 0;
}
diff --git a/arch/sh64/kernel/irq.c b/arch/sh64/kernel/irq.c
index 9fc2b71dbd8..d69879c0e06 100644
--- a/arch/sh64/kernel/irq.c
+++ b/arch/sh64/kernel/irq.c
@@ -53,9 +53,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_puts(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index f944b58cdfe..7c58fc1a39c 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -23,7 +23,6 @@ menu "General machine setup"
config SMP
bool "Symmetric multi-processing support (does not work on sun4/sun4c)"
- depends on BROKEN
---help---
This enables support for systems with more than one CPU. If you have
a system with only one CPU, say N. If you have a system with more
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index 410b9a72aba..aac8af5aae5 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -154,9 +154,11 @@ void (*sparc_init_timers)(irqreturn_t (*)(int, void *,struct pt_regs *)) =
struct irqaction static_irqaction[MAX_STATIC_ALLOC];
int static_irq_count;
-struct irqaction *irq_action[NR_IRQS] = {
- [0 ... (NR_IRQS-1)] = NULL
-};
+struct {
+ struct irqaction *action;
+ int flags;
+} sparc_irq[NR_IRQS];
+#define SPARC_IRQ_INPROGRESS 1
/* Used to protect the IRQ action lists */
DEFINE_SPINLOCK(irq_action_lock);
@@ -177,17 +179,16 @@ int show_interrupts(struct seq_file *p, void *v)
}
spin_lock_irqsave(&irq_action_lock, flags);
if (i < NR_IRQS) {
- action = *(i + irq_action);
+ action = sparc_irq[i].action;
if (!action)
goto out_unlock;
seq_printf(p, "%3d: ", i);
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++) {
- if (cpu_online(j))
- seq_printf(p, "%10u ",
- kstat_cpu(cpu_logical_map(j)).irqs[i]);
+ for_each_online_cpu(j) {
+ seq_printf(p, "%10u ",
+ kstat_cpu(j).irqs[i]);
}
#endif
seq_printf(p, " %c %s",
@@ -208,7 +209,7 @@ out_unlock:
void free_irq(unsigned int irq, void *dev_id)
{
struct irqaction * action;
- struct irqaction * tmp = NULL;
+ struct irqaction **actionp;
unsigned long flags;
unsigned int cpu_irq;
@@ -226,7 +227,8 @@ void free_irq(unsigned int irq, void *dev_id)
spin_lock_irqsave(&irq_action_lock, flags);
- action = *(cpu_irq + irq_action);
+ actionp = &sparc_irq[cpu_irq].action;
+ action = *actionp;
if (!action->handler) {
printk("Trying to free free IRQ%d\n",irq);
@@ -236,7 +238,7 @@ void free_irq(unsigned int irq, void *dev_id)
for (; action; action = action->next) {
if (action->dev_id == dev_id)
break;
- tmp = action;
+ actionp = &action->next;
}
if (!action) {
printk("Trying to free free shared IRQ%d\n",irq);
@@ -255,11 +257,8 @@ void free_irq(unsigned int irq, void *dev_id)
irq, action->name);
goto out_unlock;
}
-
- if (action && tmp)
- tmp->next = action->next;
- else
- *(cpu_irq + irq_action) = action->next;
+
+ *actionp = action->next;
spin_unlock_irqrestore(&irq_action_lock, flags);
@@ -269,7 +268,7 @@ void free_irq(unsigned int irq, void *dev_id)
kfree(action);
- if (!(*(cpu_irq + irq_action)))
+ if (!sparc_irq[cpu_irq].action)
disable_irq(irq);
out_unlock:
@@ -288,8 +287,11 @@ EXPORT_SYMBOL(free_irq);
#ifdef CONFIG_SMP
void synchronize_irq(unsigned int irq)
{
- printk("synchronize_irq says: implement me!\n");
- BUG();
+ unsigned int cpu_irq;
+
+ cpu_irq = irq & (NR_IRQS - 1);
+ while (sparc_irq[cpu_irq].flags & SPARC_IRQ_INPROGRESS)
+ cpu_relax();
}
#endif /* SMP */
@@ -300,7 +302,7 @@ void unexpected_irq(int irq, void *dev_id, struct pt_regs * regs)
unsigned int cpu_irq;
cpu_irq = irq & (NR_IRQS - 1);
- action = *(cpu_irq + irq_action);
+ action = sparc_irq[cpu_irq].action;
printk("IO device interrupt, irq = %d\n", irq);
printk("PC = %08lx NPC = %08lx FP=%08lx\n", regs->pc,
@@ -331,7 +333,8 @@ void handler_irq(int irq, struct pt_regs * regs)
if(irq < 10)
smp4m_irq_rotate(cpu);
#endif
- action = *(irq + irq_action);
+ action = sparc_irq[irq].action;
+ sparc_irq[irq].flags |= SPARC_IRQ_INPROGRESS;
kstat_cpu(cpu).irqs[irq]++;
do {
if (!action || !action->handler)
@@ -339,6 +342,7 @@ void handler_irq(int irq, struct pt_regs * regs)
action->handler(irq, action->dev_id, regs);
action = action->next;
} while (action);
+ sparc_irq[irq].flags &= ~SPARC_IRQ_INPROGRESS;
enable_pil_irq(irq);
irq_exit();
}
@@ -390,7 +394,7 @@ int request_fast_irq(unsigned int irq,
spin_lock_irqsave(&irq_action_lock, flags);
- action = *(cpu_irq + irq_action);
+ action = sparc_irq[cpu_irq].action;
if(action) {
if(action->flags & SA_SHIRQ)
panic("Trying to register fast irq when already shared.\n");
@@ -453,7 +457,7 @@ int request_fast_irq(unsigned int irq,
action->dev_id = NULL;
action->next = NULL;
- *(cpu_irq + irq_action) = action;
+ sparc_irq[cpu_irq].action = action;
enable_irq(irq);
@@ -468,7 +472,7 @@ int request_irq(unsigned int irq,
irqreturn_t (*handler)(int, void *, struct pt_regs *),
unsigned long irqflags, const char * devname, void *dev_id)
{
- struct irqaction * action, *tmp = NULL;
+ struct irqaction * action, **actionp;
unsigned long flags;
unsigned int cpu_irq;
int ret;
@@ -491,20 +495,20 @@ int request_irq(unsigned int irq,
spin_lock_irqsave(&irq_action_lock, flags);
- action = *(cpu_irq + irq_action);
+ actionp = &sparc_irq[cpu_irq].action;
+ action = *actionp;
if (action) {
- if ((action->flags & SA_SHIRQ) && (irqflags & SA_SHIRQ)) {
- for (tmp = action; tmp->next; tmp = tmp->next);
- } else {
+ if (!(action->flags & SA_SHIRQ) || !(irqflags & SA_SHIRQ)) {
ret = -EBUSY;
goto out_unlock;
}
- if ((action->flags & SA_INTERRUPT) ^ (irqflags & SA_INTERRUPT)) {
+ if ((action->flags & SA_INTERRUPT) != (irqflags & SA_INTERRUPT)) {
printk("Attempt to mix fast and slow interrupts on IRQ%d denied\n", irq);
ret = -EBUSY;
goto out_unlock;
- }
- action = NULL; /* Or else! */
+ }
+ for ( ; action; action = *actionp)
+ actionp = &action->next;
}
/* If this is flagged as statically allocated then we use our
@@ -533,10 +537,7 @@ int request_irq(unsigned int irq,
action->next = NULL;
action->dev_id = dev_id;
- if (tmp)
- tmp->next = action;
- else
- *(cpu_irq + irq_action) = action;
+ *actionp = action;
enable_irq(irq);
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index c6e721d8f47..2be81211519 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -45,6 +45,7 @@ volatile int __cpu_logical_map[NR_CPUS];
cpumask_t cpu_online_map = CPU_MASK_NONE;
cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
+cpumask_t smp_commenced_mask = CPU_MASK_NONE;
/* The only guaranteed locking primitive available on all Sparc
* processors is 'ldstub [%reg + immediate], %dest_reg' which atomically
@@ -57,11 +58,6 @@ cpumask_t phys_cpu_present_map = CPU_MASK_NONE;
/* Used to make bitops atomic */
unsigned char bitops_spinlock = 0;
-volatile unsigned long ipi_count;
-
-volatile int smp_process_available=0;
-volatile int smp_commenced = 0;
-
void __init smp_store_cpu_info(int id)
{
int cpu_node;
@@ -79,6 +75,22 @@ void __init smp_store_cpu_info(int id)
void __init smp_cpus_done(unsigned int max_cpus)
{
+ extern void smp4m_smp_done(void);
+ unsigned long bogosum = 0;
+ int cpu, num;
+
+ for (cpu = 0, num = 0; cpu < NR_CPUS; cpu++)
+ if (cpu_online(cpu)) {
+ num++;
+ bogosum += cpu_data(cpu).udelay_val;
+ }
+
+ printk("Total of %d processors activated (%lu.%02lu BogoMIPS).\n",
+ num, bogosum/(500000/HZ),
+ (bogosum/(5000/HZ))%100);
+
+ BUG_ON(sparc_cpu_model != sun4m);
+ smp4m_smp_done();
}
void cpu_panic(void)
@@ -89,17 +101,6 @@ void cpu_panic(void)
struct linux_prom_registers smp_penguin_ctable __initdata = { 0 };
-void __init smp_boot_cpus(void)
-{
- extern void smp4m_boot_cpus(void);
- extern void smp4d_boot_cpus(void);
-
- if (sparc_cpu_model == sun4m)
- smp4m_boot_cpus();
- else
- smp4d_boot_cpus();
-}
-
void smp_send_reschedule(int cpu)
{
/* See sparc64 */
@@ -243,9 +244,8 @@ int setup_profiling_timer(unsigned int multiplier)
return -EINVAL;
spin_lock_irqsave(&prof_setup_lock, flags);
- for(i = 0; i < NR_CPUS; i++) {
- if (cpu_possible(i))
- load_profile_irq(i, lvl14_resolution / multiplier);
+ for_each_cpu(i) {
+ load_profile_irq(i, lvl14_resolution / multiplier);
prof_multiplier(i) = multiplier;
}
spin_unlock_irqrestore(&prof_setup_lock, flags);
@@ -253,33 +253,73 @@ int setup_profiling_timer(unsigned int multiplier)
return 0;
}
-void __init smp_prepare_cpus(unsigned int maxcpus)
+void __init smp_prepare_cpus(unsigned int max_cpus)
{
+ extern void smp4m_boot_cpus(void);
+ int i, cpuid, ncpus, extra;
+
+ BUG_ON(sparc_cpu_model != sun4m);
+ printk("Entering SMP Mode...\n");
+
+ ncpus = 1;
+ extra = 0;
+ for (i = 0; !cpu_find_by_instance(i, NULL, &cpuid); i++) {
+ if (cpuid == boot_cpu_id)
+ continue;
+ if (cpuid < NR_CPUS && ncpus++ < max_cpus)
+ cpu_set(cpuid, phys_cpu_present_map);
+ else
+ extra++;
+ }
+ if (max_cpus >= NR_CPUS && extra)
+ printk("Warning: NR_CPUS is too low to start all cpus\n");
+
+ smp_store_cpu_info(boot_cpu_id);
+
+ smp4m_boot_cpus();
}
void __devinit smp_prepare_boot_cpu(void)
{
- current_thread_info()->cpu = hard_smp_processor_id();
- cpu_set(smp_processor_id(), cpu_online_map);
- cpu_set(smp_processor_id(), phys_cpu_present_map);
+ int cpuid = hard_smp_processor_id();
+
+ if (cpuid >= NR_CPUS) {
+ prom_printf("Serious problem, boot cpu id >= NR_CPUS\n");
+ prom_halt();
+ }
+ if (cpuid != 0)
+ printk("boot cpu id != 0, this could work but is untested\n");
+
+ current_thread_info()->cpu = cpuid;
+ cpu_set(cpuid, cpu_online_map);
+ cpu_set(cpuid, phys_cpu_present_map);
}
int __devinit __cpu_up(unsigned int cpu)
{
- panic("smp doesn't work\n");
+ extern int smp4m_boot_one_cpu(int);
+ int ret;
+
+ ret = smp4m_boot_one_cpu(cpu);
+
+ if (!ret) {
+ cpu_set(cpu, smp_commenced_mask);
+ while (!cpu_online(cpu))
+ mb();
+ }
+ return ret;
}
void smp_bogo(struct seq_file *m)
{
int i;
- for (i = 0; i < NR_CPUS; i++) {
- if (cpu_online(i))
- seq_printf(m,
- "Cpu%dBogo\t: %lu.%02lu\n",
- i,
- cpu_data(i).udelay_val/(500000/HZ),
- (cpu_data(i).udelay_val/(5000/HZ))%100);
+ for_each_online_cpu(i) {
+ seq_printf(m,
+ "Cpu%dBogo\t: %lu.%02lu\n",
+ i,
+ cpu_data(i).udelay_val/(500000/HZ),
+ (cpu_data(i).udelay_val/(5000/HZ))%100);
}
}
@@ -288,8 +328,6 @@ void smp_info(struct seq_file *m)
int i;
seq_printf(m, "State:\n");
- for (i = 0; i < NR_CPUS; i++) {
- if (cpu_online(i))
- seq_printf(m, "CPU%d\t\t: online\n", i);
- }
+ for_each_online_cpu(i)
+ seq_printf(m, "CPU%d\t\t: online\n", i);
}
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index 19b25399d7e..2c21d790763 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -136,10 +136,6 @@ EXPORT_PER_CPU_SYMBOL(__cpu_data);
/* IRQ implementation. */
EXPORT_SYMBOL(synchronize_irq);
-/* Misc SMP information */
-EXPORT_SYMBOL(__cpu_number_map);
-EXPORT_SYMBOL(__cpu_logical_map);
-
/* CPU online map and active count. */
EXPORT_SYMBOL(cpu_online_map);
EXPORT_SYMBOL(phys_cpu_present_map);
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 52621348a56..ca656d9bd6f 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -54,7 +54,7 @@ unsigned char cpu_leds[32];
unsigned char sbus_tid[32];
#endif
-extern struct irqaction *irq_action[];
+static struct irqaction *irq_action[NR_IRQS];
extern spinlock_t irq_action_lock;
struct sbus_action {
@@ -103,11 +103,9 @@ found_it: seq_printf(p, "%3d: ", i);
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (x = 0; x < NR_CPUS; x++) {
- if (cpu_online(x))
- seq_printf(p, "%10u ",
- kstat_cpu(cpu_logical_map(x)).irqs[i]);
- }
+ for_each_online_cpu(x)
+ seq_printf(p, "%10u ",
+ kstat_cpu(cpu_logical_map(x)).irqs[i]);
#endif
seq_printf(p, "%c %s",
(action->flags & SA_INTERRUPT) ? '+' : ' ',
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 4219dd2ce3a..b141b7ee671 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -46,14 +46,16 @@ extern volatile int smp_processors_ready;
extern int smp_num_cpus;
static int smp_highest_cpu;
extern volatile unsigned long cpu_callin_map[NR_CPUS];
-extern struct cpuinfo_sparc cpu_data[NR_CPUS];
+extern cpuinfo_sparc cpu_data[NR_CPUS];
extern unsigned char boot_cpu_id;
extern int smp_activated;
extern volatile int __cpu_number_map[NR_CPUS];
extern volatile int __cpu_logical_map[NR_CPUS];
extern volatile unsigned long ipi_count;
extern volatile int smp_process_available;
-extern volatile int smp_commenced;
+
+extern cpumask_t smp_commenced_mask;
+
extern int __smp4d_processor_id(void);
/* #define SMP_DEBUG */
@@ -136,7 +138,7 @@ void __init smp4d_callin(void)
local_irq_enable(); /* We don't allow PIL 14 yet */
- while(!smp_commenced)
+ while (!cpu_isset(cpuid, smp_commenced_mask))
barrier();
spin_lock_irqsave(&sun4d_imsk_lock, flags);
@@ -249,11 +251,9 @@ void __init smp4d_boot_cpus(void)
} else {
unsigned long bogosum = 0;
- for(i = 0; i < NR_CPUS; i++) {
- if (cpu_isset(i, cpu_present_map)) {
- bogosum += cpu_data(i).udelay_val;
- smp_highest_cpu = i;
- }
+ for_each_present_cpu(i) {
+ bogosum += cpu_data(i).udelay_val;
+ smp_highest_cpu = i;
}
SMP_PRINTK(("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n", cpucount + 1, bogosum/(500000/HZ), (bogosum/(5000/HZ))%100));
printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n",
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index fbbd8a474c4..70b375a4c2c 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -40,15 +40,11 @@ extern ctxd_t *srmmu_ctx_table_phys;
extern void calibrate_delay(void);
extern volatile int smp_processors_ready;
-extern int smp_num_cpus;
extern volatile unsigned long cpu_callin_map[NR_CPUS];
extern unsigned char boot_cpu_id;
-extern int smp_activated;
-extern volatile int __cpu_number_map[NR_CPUS];
-extern volatile int __cpu_logical_map[NR_CPUS];
-extern volatile unsigned long ipi_count;
-extern volatile int smp_process_available;
-extern volatile int smp_commenced;
+
+extern cpumask_t smp_commenced_mask;
+
extern int __smp4m_processor_id(void);
/*#define SMP_DEBUG*/
@@ -77,8 +73,6 @@ void __init smp4m_callin(void)
local_flush_cache_all();
local_flush_tlb_all();
- set_irq_udt(boot_cpu_id);
-
/* Get our local ticker going. */
smp_setup_percpu_timer();
@@ -95,8 +89,9 @@ void __init smp4m_callin(void)
* to call the scheduler code.
*/
/* Allow master to continue. */
- swap((unsigned long *)&cpu_callin_map[cpuid], 1);
+ swap(&cpu_callin_map[cpuid], 1);
+ /* XXX: What's up with all the flushes? */
local_flush_cache_all();
local_flush_tlb_all();
@@ -111,13 +106,14 @@ void __init smp4m_callin(void)
atomic_inc(&init_mm.mm_count);
current->active_mm = &init_mm;
- while(!smp_commenced)
- barrier();
-
- local_flush_cache_all();
- local_flush_tlb_all();
+ while (!cpu_isset(cpuid, smp_commenced_mask))
+ mb();
local_irq_enable();
+
+ cpu_set(cpuid, cpu_online_map);
+ /* last one in gets all the interrupts (for testing) */
+ set_irq_udt(boot_cpu_id);
}
extern void init_IRQ(void);
@@ -134,104 +130,76 @@ extern unsigned long trapbase_cpu3[];
void __init smp4m_boot_cpus(void)
{
- int cpucount = 0;
- int i, mid;
+ smp_setup_percpu_timer();
+ local_flush_cache_all();
+}
- printk("Entering SMP Mode...\n");
+int smp4m_boot_one_cpu(int i)
+{
+ extern unsigned long sun4m_cpu_startup;
+ unsigned long *entry = &sun4m_cpu_startup;
+ struct task_struct *p;
+ int timeout;
+ int cpu_node;
- local_irq_enable();
- cpus_clear(cpu_present_map);
+ cpu_find_by_mid(i, &cpu_node);
- for (i = 0; !cpu_find_by_instance(i, NULL, &mid); i++)
- cpu_set(mid, cpu_present_map);
+ /* Cook up an idler for this guy. */
+ p = fork_idle(i);
+ current_set[i] = task_thread_info(p);
+ /* See trampoline.S for details... */
+ entry += ((i-1) * 3);
- for(i=0; i < NR_CPUS; i++) {
- __cpu_number_map[i] = -1;
- __cpu_logical_map[i] = -1;
+ /*
+ * Initialize the contexts table
+ * Since the call to prom_startcpu() trashes the structure,
+ * we need to re-initialize it for each cpu
+ */
+ smp_penguin_ctable.which_io = 0;
+ smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
+ smp_penguin_ctable.reg_size = 0;
+
+ /* whirrr, whirrr, whirrrrrrrrr... */
+ printk("Starting CPU %d at %p\n", i, entry);
+ local_flush_cache_all();
+ prom_startcpu(cpu_node,
+ &smp_penguin_ctable, 0, (char *)entry);
+
+ /* wheee... it's going... */
+ for(timeout = 0; timeout < 10000; timeout++) {
+ if(cpu_callin_map[i])
+ break;
+ udelay(200);
}
- __cpu_number_map[boot_cpu_id] = 0;
- __cpu_logical_map[0] = boot_cpu_id;
- current_thread_info()->cpu = boot_cpu_id;
+ if (!(cpu_callin_map[i])) {
+ printk("Processor %d is stuck.\n", i);
+ return -ENODEV;
+ }
- smp_store_cpu_info(boot_cpu_id);
- set_irq_udt(boot_cpu_id);
- smp_setup_percpu_timer();
local_flush_cache_all();
- if(cpu_find_by_instance(1, NULL, NULL))
- return; /* Not an MP box. */
- for(i = 0; i < NR_CPUS; i++) {
- if(i == boot_cpu_id)
- continue;
-
- if (cpu_isset(i, cpu_present_map)) {
- extern unsigned long sun4m_cpu_startup;
- unsigned long *entry = &sun4m_cpu_startup;
- struct task_struct *p;
- int timeout;
-
- /* Cook up an idler for this guy. */
- p = fork_idle(i);
- cpucount++;
- current_set[i] = task_thread_info(p);
- /* See trampoline.S for details... */
- entry += ((i-1) * 3);
-
- /*
- * Initialize the contexts table
- * Since the call to prom_startcpu() trashes the structure,
- * we need to re-initialize it for each cpu
- */
- smp_penguin_ctable.which_io = 0;
- smp_penguin_ctable.phys_addr = (unsigned int) srmmu_ctx_table_phys;
- smp_penguin_ctable.reg_size = 0;
-
- /* whirrr, whirrr, whirrrrrrrrr... */
- printk("Starting CPU %d at %p\n", i, entry);
- local_flush_cache_all();
- prom_startcpu(cpu_data(i).prom_node,
- &smp_penguin_ctable, 0, (char *)entry);
-
- /* wheee... it's going... */
- for(timeout = 0; timeout < 10000; timeout++) {
- if(cpu_callin_map[i])
- break;
- udelay(200);
- }
- if(cpu_callin_map[i]) {
- /* Another "Red Snapper". */
- __cpu_number_map[i] = i;
- __cpu_logical_map[i] = i;
- } else {
- cpucount--;
- printk("Processor %d is stuck.\n", i);
- }
- }
- if(!(cpu_callin_map[i])) {
- cpu_clear(i, cpu_present_map);
- __cpu_number_map[i] = -1;
+ return 0;
+}
+
+void __init smp4m_smp_done(void)
+{
+ int i, first;
+ int *prev;
+
+ /* setup cpu list for irq rotation */
+ first = 0;
+ prev = &first;
+ for (i = 0; i < NR_CPUS; i++) {
+ if (cpu_online(i)) {
+ *prev = i;
+ prev = &cpu_data(i).next;
}
}
+ *prev = first;
local_flush_cache_all();
- if(cpucount == 0) {
- printk("Error: only one Processor found.\n");
- cpu_present_map = cpumask_of_cpu(smp_processor_id());
- } else {
- unsigned long bogosum = 0;
- for(i = 0; i < NR_CPUS; i++) {
- if (cpu_isset(i, cpu_present_map))
- bogosum += cpu_data(i).udelay_val;
- }
- printk("Total of %d Processors activated (%lu.%02lu BogoMIPS).\n",
- cpucount + 1,
- bogosum/(500000/HZ),
- (bogosum/(5000/HZ))%100);
- smp_activated = 1;
- smp_num_cpus = cpucount + 1;
- }
/* Free unneeded trap tables */
- if (!cpu_isset(i, cpu_present_map)) {
+ if (!cpu_isset(1, cpu_present_map)) {
ClearPageReserved(virt_to_page(trapbase_cpu1));
init_page_count(virt_to_page(trapbase_cpu1));
free_page((unsigned long)trapbase_cpu1);
@@ -265,6 +233,9 @@ void __init smp4m_boot_cpus(void)
*/
void smp4m_irq_rotate(int cpu)
{
+ int next = cpu_data(cpu).next;
+ if (next != cpu)
+ set_irq_udt(next);
}
/* Cross calls, in order to work efficiently and atomically do all
@@ -291,7 +262,7 @@ void smp4m_message_pass(int target, int msg, unsigned long data, int wait)
smp_cpu_in_msg[me]++;
if(target == MSG_ALL_BUT_SELF || target == MSG_ALL) {
- mask = cpu_present_map;
+ mask = cpu_online_map;
if(target == MSG_ALL_BUT_SELF)
cpu_clear(me, mask);
for(i = 0; i < 4; i++) {
@@ -316,8 +287,8 @@ static struct smp_funcall {
unsigned long arg3;
unsigned long arg4;
unsigned long arg5;
- unsigned long processors_in[NR_CPUS]; /* Set when ipi entered. */
- unsigned long processors_out[NR_CPUS]; /* Set when ipi exited. */
+ unsigned long processors_in[SUN4M_NCPUS]; /* Set when ipi entered. */
+ unsigned long processors_out[SUN4M_NCPUS]; /* Set when ipi exited. */
} ccall_info;
static DEFINE_SPINLOCK(cross_call_lock);
@@ -326,8 +297,7 @@ static DEFINE_SPINLOCK(cross_call_lock);
void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
unsigned long arg3, unsigned long arg4, unsigned long arg5)
{
- if(smp_processors_ready) {
- register int ncpus = smp_num_cpus;
+ register int ncpus = SUN4M_NCPUS;
unsigned long flags;
spin_lock_irqsave(&cross_call_lock, flags);
@@ -342,7 +312,7 @@ void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
/* Init receive/complete mapping, plus fire the IPI's off. */
{
- cpumask_t mask = cpu_present_map;
+ cpumask_t mask = cpu_online_map;
register int i;
cpu_clear(smp_processor_id(), mask);
@@ -375,7 +345,6 @@ void smp4m_cross_call(smpfunc_t func, unsigned long arg1, unsigned long arg2,
}
spin_unlock_irqrestore(&cross_call_lock, flags);
- }
}
/* Running cross calls. */
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 27b0e0ba858..58c65cc8d0d 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -1302,7 +1302,12 @@ void __init srmmu_paging_init(void)
flush_cache_all();
srmmu_set_ctable_ptr((unsigned long)srmmu_ctx_table_phys);
+#ifdef CONFIG_SMP
+ /* Stop from hanging here... */
+ local_flush_tlb_all();
+#else
flush_tlb_all();
+#endif
poke_srmmu();
#ifdef CONFIG_SUN_IO
@@ -1419,6 +1424,7 @@ static void __init init_vac_layout(void)
max_size = vac_cache_size;
if(vac_line_size < min_line_size)
min_line_size = vac_line_size;
+ //FIXME: cpus not contiguous!!
cpu++;
if (cpu >= NR_CPUS || !cpu_online(cpu))
break;
diff --git a/arch/sparc64/Kconfig.debug b/arch/sparc64/Kconfig.debug
index 3e31be494e5..afe0a7720a2 100644
--- a/arch/sparc64/Kconfig.debug
+++ b/arch/sparc64/Kconfig.debug
@@ -24,7 +24,7 @@ config DEBUG_BOOTMEM
bool "Debug BOOTMEM initialization"
config DEBUG_PAGEALLOC
- bool "Page alloc debugging"
+ bool "Debug page memory allocations"
depends on DEBUG_KERNEL && !SOFTWARE_SUSPEND
help
Unmap pages from the kernel linear mapping after free_pages().
diff --git a/arch/sparc64/kernel/irq.c b/arch/sparc64/kernel/irq.c
index 8c93ba655b3..11e645c9ec5 100644
--- a/arch/sparc64/kernel/irq.c
+++ b/arch/sparc64/kernel/irq.c
@@ -117,9 +117,7 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++) {
- if (!cpu_online(j))
- continue;
+ for_each_online_cpu(j) {
seq_printf(p, "%10u ",
kstat_cpu(j).irqs[i]);
}
@@ -729,7 +727,7 @@ void handler_irq(int irq, struct pt_regs *regs)
}
#ifdef CONFIG_BLK_DEV_FD
-extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *);;
+extern irqreturn_t floppy_interrupt(int, void *, struct pt_regs *);
/* XXX No easy way to include asm/floppy.h XXX */
extern unsigned char *pdma_vaddr;
diff --git a/arch/sparc64/kernel/smp.c b/arch/sparc64/kernel/smp.c
index 373a701c90a..1b6e2ade100 100644
--- a/arch/sparc64/kernel/smp.c
+++ b/arch/sparc64/kernel/smp.c
@@ -57,25 +57,21 @@ void smp_info(struct seq_file *m)
int i;
seq_printf(m, "State:\n");
- for (i = 0; i < NR_CPUS; i++) {
- if (cpu_online(i))
- seq_printf(m,
- "CPU%d:\t\tonline\n", i);
- }
+ for_each_online_cpu(i)
+ seq_printf(m, "CPU%d:\t\tonline\n", i);
}
void smp_bogo(struct seq_file *m)
{
int i;
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_online(i))
- seq_printf(m,
- "Cpu%dBogo\t: %lu.%02lu\n"
- "Cpu%dClkTck\t: %016lx\n",
- i, cpu_data(i).udelay_val / (500000/HZ),
- (cpu_data(i).udelay_val / (5000/HZ)) % 100,
- i, cpu_data(i).clock_tick);
+ for_each_online_cpu(i)
+ seq_printf(m,
+ "Cpu%dBogo\t: %lu.%02lu\n"
+ "Cpu%dClkTck\t: %016lx\n",
+ i, cpu_data(i).udelay_val / (500000/HZ),
+ (cpu_data(i).udelay_val / (5000/HZ)) % 100,
+ i, cpu_data(i).clock_tick);
}
void __init smp_store_cpu_info(int id)
@@ -1282,7 +1278,7 @@ int setup_profiling_timer(unsigned int multiplier)
return -EINVAL;
spin_lock_irqsave(&prof_setup_lock, flags);
- for (i = 0; i < NR_CPUS; i++)
+ for_each_cpu(i)
prof_multiplier(i) = multiplier;
current_tick_offset = (timer_tick_offset / multiplier);
spin_unlock_irqrestore(&prof_setup_lock, flags);
@@ -1384,10 +1380,8 @@ void __init smp_cpus_done(unsigned int max_cpus)
unsigned long bogosum = 0;
int i;
- for (i = 0; i < NR_CPUS; i++) {
- if (cpu_online(i))
- bogosum += cpu_data(i).udelay_val;
- }
+ for_each_online_cpu(i)
+ bogosum += cpu_data(i).udelay_val;
printk("Total of %ld processors activated "
"(%lu.%02lu BogoMIPS).\n",
(long) num_online_cpus(),
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c
index ded63ee9c4f..1539a8362b6 100644
--- a/arch/sparc64/mm/init.c
+++ b/arch/sparc64/mm/init.c
@@ -1828,8 +1828,8 @@ void __flush_tlb_all(void)
void online_page(struct page *page)
{
ClearPageReserved(page);
- set_page_count(page, 0);
- free_cold_page(page);
+ init_page_count(page);
+ __free_page(page);
totalram_pages++;
num_physpages++;
}
diff --git a/arch/um/Makefile b/arch/um/Makefile
index c58b657f009..8d14c7a831b 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -1,4 +1,7 @@
-#
+#
+# This file is included by the global makefile so that you can add your own
+# architecture-specific flags and dependencies.
+#
# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
# Licensed under the GPL
#
@@ -88,7 +91,7 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
-.PHONY: linux
+PHONY += linux
all: linux
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c
index 27cdf916442..80c9c18aae9 100644
--- a/arch/um/kernel/um_arch.c
+++ b/arch/um/kernel/um_arch.c
@@ -491,6 +491,16 @@ void __init check_bugs(void)
check_devanon();
}
-void apply_alternatives(void *start, void *end)
+void apply_alternatives(struct alt_instr *start, struct alt_instr *end)
+{
+}
+
+void alternatives_smp_module_add(struct module *mod, char *name,
+ void *locks, void *locks_end,
+ void *text, void *text_end)
+{
+}
+
+void alternatives_smp_module_del(struct module *mod)
{
}
diff --git a/arch/v850/kernel/process.c b/arch/v850/kernel/process.c
index 621111ddf90..57218c76925 100644
--- a/arch/v850/kernel/process.c
+++ b/arch/v850/kernel/process.c
@@ -37,7 +37,7 @@ extern void ret_from_fork (void);
/* The idle loop. */
-void default_idle (void)
+static void default_idle (void)
{
while (! need_resched ())
asm ("halt; nop; nop; nop; nop; nop" ::: "cc");
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index d7fd46479c5..7405dfd6522 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -67,8 +67,8 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
boot := arch/x86_64/boot
-.PHONY: bzImage bzlilo install archmrproper \
- fdimage fdimage144 fdimage288 archclean
+PHONY += bzImage bzlilo install archmrproper \
+ fdimage fdimage144 fdimage288 archclean
#Default target when executing "make"
all: bzImage
diff --git a/arch/x86_64/ia32/sys_ia32.c b/arch/x86_64/ia32/sys_ia32.c
index 2bc55af9541..2b2d029f477 100644
--- a/arch/x86_64/ia32/sys_ia32.c
+++ b/arch/x86_64/ia32/sys_ia32.c
@@ -430,24 +430,12 @@ put_tv32(struct compat_timeval __user *o, struct timeval *i)
return err;
}
-extern int do_setitimer(int which, struct itimerval *, struct itimerval *);
+extern unsigned int alarm_setitimer(unsigned int seconds);
asmlinkage long
sys32_alarm(unsigned int seconds)
{
- struct itimerval it_new, it_old;
- unsigned int oldalarm;
-
- it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
- it_new.it_value.tv_sec = seconds;
- it_new.it_value.tv_usec = 0;
- do_setitimer(ITIMER_REAL, &it_new, &it_old);
- oldalarm = it_old.it_value.tv_sec;
- /* ehhh.. We can't return 0 if we have an alarm pending.. */
- /* And we'd better return too much than too little anyway */
- if (it_old.it_value.tv_usec)
- oldalarm++;
- return oldalarm;
+ return alarm_setitimer(seconds);
}
/* Translations due to time_t size differences. Which affects all
diff --git a/arch/x86_64/kernel/early_printk.c b/arch/x86_64/kernel/early_printk.c
index 6dffb498ccd..13af920b659 100644
--- a/arch/x86_64/kernel/early_printk.c
+++ b/arch/x86_64/kernel/early_printk.c
@@ -17,11 +17,8 @@
#define VGABASE ((void __iomem *)0xffffffff800b8000UL)
#endif
-#define MAX_YPOS max_ypos
-#define MAX_XPOS max_xpos
-
static int max_ypos = 25, max_xpos = 80;
-static int current_ypos = 1, current_xpos = 0;
+static int current_ypos = 25, current_xpos = 0;
static void early_vga_write(struct console *con, const char *str, unsigned n)
{
@@ -29,26 +26,26 @@ static void early_vga_write(struct console *con, const char *str, unsigned n)
int i, k, j;
while ((c = *str++) != '\0' && n-- > 0) {
- if (current_ypos >= MAX_YPOS) {
+ if (current_ypos >= max_ypos) {
/* scroll 1 line up */
- for (k = 1, j = 0; k < MAX_YPOS; k++, j++) {
- for (i = 0; i < MAX_XPOS; i++) {
- writew(readw(VGABASE + 2*(MAX_XPOS*k + i)),
- VGABASE + 2*(MAX_XPOS*j + i));
+ for (k = 1, j = 0; k < max_ypos; k++, j++) {
+ for (i = 0; i < max_xpos; i++) {
+ writew(readw(VGABASE+2*(max_xpos*k+i)),
+ VGABASE + 2*(max_xpos*j + i));
}
}
- for (i = 0; i < MAX_XPOS; i++)
- writew(0x720, VGABASE + 2*(MAX_XPOS*j + i));
- current_ypos = MAX_YPOS-1;
+ for (i = 0; i < max_xpos; i++)
+ writew(0x720, VGABASE + 2*(max_xpos*j + i));
+ current_ypos = max_ypos-1;
}
if (c == '\n') {
current_xpos = 0;
current_ypos++;
} else if (c != '\r') {
writew(((0x7 << 8) | (unsigned short) c),
- VGABASE + 2*(MAX_XPOS*current_ypos +
+ VGABASE + 2*(max_xpos*current_ypos +
current_xpos++));
- if (current_xpos >= MAX_XPOS) {
+ if (current_xpos >= max_xpos) {
current_xpos = 0;
current_ypos++;
}
@@ -63,7 +60,7 @@ static struct console early_vga_console = {
.index = -1,
};
-/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
+/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
static int early_serial_base = 0x3f8; /* ttyS0 */
@@ -83,30 +80,30 @@ static int early_serial_base = 0x3f8; /* ttyS0 */
#define DLL 0 /* Divisor Latch Low */
#define DLH 1 /* Divisor latch High */
-static int early_serial_putc(unsigned char ch)
-{
- unsigned timeout = 0xffff;
- while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
+static int early_serial_putc(unsigned char ch)
+{
+ unsigned timeout = 0xffff;
+ while ((inb(early_serial_base + LSR) & XMTRDY) == 0 && --timeout)
cpu_relax();
outb(ch, early_serial_base + TXR);
return timeout ? 0 : -1;
-}
+}
static void early_serial_write(struct console *con, const char *s, unsigned n)
{
- while (*s && n-- > 0) {
- early_serial_putc(*s);
- if (*s == '\n')
- early_serial_putc('\r');
- s++;
- }
-}
+ while (*s && n-- > 0) {
+ early_serial_putc(*s);
+ if (*s == '\n')
+ early_serial_putc('\r');
+ s++;
+ }
+}
#define DEFAULT_BAUD 9600
static __init void early_serial_init(char *s)
{
- unsigned char c;
+ unsigned char c;
unsigned divisor;
unsigned baud = DEFAULT_BAUD;
char *e;
@@ -115,7 +112,7 @@ static __init void early_serial_init(char *s)
++s;
if (*s) {
- unsigned port;
+ unsigned port;
if (!strncmp(s,"0x",2)) {
early_serial_base = simple_strtoul(s, &e, 16);
} else {
@@ -139,16 +136,16 @@ static __init void early_serial_init(char *s)
outb(0x3, early_serial_base + MCR); /* DTR + RTS */
if (*s) {
- baud = simple_strtoul(s, &e, 0);
- if (baud == 0 || s == e)
+ baud = simple_strtoul(s, &e, 0);
+ if (baud == 0 || s == e)
baud = DEFAULT_BAUD;
- }
-
- divisor = 115200 / baud;
- c = inb(early_serial_base + LCR);
- outb(c | DLAB, early_serial_base + LCR);
- outb(divisor & 0xff, early_serial_base + DLL);
- outb((divisor >> 8) & 0xff, early_serial_base + DLH);
+ }
+
+ divisor = 115200 / baud;
+ c = inb(early_serial_base + LCR);
+ outb(c | DLAB, early_serial_base + LCR);
+ outb(divisor & 0xff, early_serial_base + DLL);
+ outb((divisor >> 8) & 0xff, early_serial_base + DLH);
outb(c & ~DLAB, early_serial_base + LCR);
}
@@ -205,67 +202,68 @@ struct console *early_console = &early_vga_console;
static int early_console_initialized = 0;
void early_printk(const char *fmt, ...)
-{
- char buf[512];
- int n;
+{
+ char buf[512];
+ int n;
va_list ap;
- va_start(ap,fmt);
+ va_start(ap,fmt);
n = vscnprintf(buf,512,fmt,ap);
early_console->write(early_console,buf,n);
- va_end(ap);
-}
+ va_end(ap);
+}
static int __initdata keep_early;
-int __init setup_early_printk(char *opt)
-{
+int __init setup_early_printk(char *opt)
+{
char *space;
- char buf[256];
+ char buf[256];
if (early_console_initialized)
return -1;
- strlcpy(buf,opt,sizeof(buf));
- space = strchr(buf, ' ');
+ strlcpy(buf,opt,sizeof(buf));
+ space = strchr(buf, ' ');
if (space)
- *space = 0;
+ *space = 0;
if (strstr(buf,"keep"))
- keep_early = 1;
+ keep_early = 1;
- if (!strncmp(buf, "serial", 6)) {
+ if (!strncmp(buf, "serial", 6)) {
early_serial_init(buf + 6);
early_console = &early_serial_console;
- } else if (!strncmp(buf, "ttyS", 4)) {
+ } else if (!strncmp(buf, "ttyS", 4)) {
early_serial_init(buf);
- early_console = &early_serial_console;
+ early_console = &early_serial_console;
} else if (!strncmp(buf, "vga", 3)
&& SCREEN_INFO.orig_video_isVGA == 1) {
max_xpos = SCREEN_INFO.orig_video_cols;
max_ypos = SCREEN_INFO.orig_video_lines;
- early_console = &early_vga_console;
+ current_ypos = SCREEN_INFO.orig_y;
+ early_console = &early_vga_console;
} else if (!strncmp(buf, "simnow", 6)) {
simnow_init(buf + 6);
early_console = &simnow_console;
keep_early = 1;
}
early_console_initialized = 1;
- register_console(early_console);
+ register_console(early_console);
return 0;
}
void __init disable_early_printk(void)
-{
+{
if (!early_console_initialized || !early_console)
return;
if (!keep_early) {
printk("disabling early console\n");
unregister_console(early_console);
early_console_initialized = 0;
- } else {
+ } else {
printk("keeping early console\n");
}
-}
+}
__setup("earlyprintk=", setup_early_printk);
diff --git a/arch/x86_64/kernel/irq.c b/arch/x86_64/kernel/irq.c
index 30d2a1e545f..d8bd0b345b1 100644
--- a/arch/x86_64/kernel/irq.c
+++ b/arch/x86_64/kernel/irq.c
@@ -38,9 +38,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_printf(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
@@ -53,10 +52,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ",
- kstat_cpu(j).irqs[i]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
#endif
seq_printf(p, " %14s", irq_desc[i].handler->typename);
@@ -68,15 +65,13 @@ skip:
spin_unlock_irqrestore(&irq_desc[i].lock, flags);
} else if (i == NR_IRQS) {
seq_printf(p, "NMI: ");
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", cpu_pda(j)->__nmi_count);
seq_putc(p, '\n');
#ifdef CONFIG_X86_LOCAL_APIC
seq_printf(p, "LOC: ");
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", cpu_pda(j)->apic_timer_irqs);
seq_putc(p, '\n');
#endif
seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index 8b866a8572c..14f0ced613b 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -222,9 +222,9 @@ void __kprobes arch_disarm_kprobe(struct kprobe *p)
void __kprobes arch_remove_kprobe(struct kprobe *p)
{
- down(&kprobe_mutex);
+ mutex_lock(&kprobe_mutex);
free_insn_slot(p->ainsn.insn);
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
}
static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index b8b9529fa89..04282ef9fbd 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -139,8 +139,7 @@ static void mce_panic(char *msg, struct mce *backup, unsigned long start)
static int mce_available(struct cpuinfo_x86 *c)
{
- return test_bit(X86_FEATURE_MCE, &c->x86_capability) &&
- test_bit(X86_FEATURE_MCA, &c->x86_capability);
+ return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
}
static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index 5bf17e41cd2..66c009e10ba 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -162,9 +162,7 @@ int __init check_nmi_watchdog (void)
local_irq_enable();
mdelay((10*1000)/nmi_hz); // wait 10 ticks
- for (cpu = 0; cpu < NR_CPUS; cpu++) {
- if (!cpu_online(cpu))
- continue;
+ for_each_online_cpu(cpu) {
if (cpu_pda(cpu)->__nmi_count - counts[cpu] <= 5) {
endflag = 1;
printk("CPU#%d: NMI appears to be stuck (%d->%d)!\n",
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 22a05dec81a..80a8f307917 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -114,7 +114,7 @@ void exit_idle(void)
* We use this if we don't have any better
* idle routine..
*/
-void default_idle(void)
+static void default_idle(void)
{
local_irq_enable();
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index aa55e3cec66..f227d0c23dc 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -1344,8 +1344,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
{
int i;
for ( i = 0 ; i < 32*NCAPINTS ; i++ )
- if ( test_bit(i, &c->x86_capability) &&
- x86_cap_flags[i] != NULL )
+ if (cpu_has(c, i) && x86_cap_flags[i] != NULL)
seq_printf(m, " %s", x86_cap_flags[i]);
}
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 5876df116c9..e5f5ce7909a 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -443,9 +443,6 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
if (!user_mode(regs))
return 1;
- if (try_to_freeze())
- goto no_signal;
-
if (!oldset)
oldset = &current->blocked;
@@ -463,7 +460,6 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
return handle_signal(signr, &info, &ka, oldset, regs);
}
- no_signal:
/* Did we come from a system call? */
if ((long)regs->orig_rax >= 0) {
/* Restart the system call - no handlers present */
diff --git a/arch/x86_64/pci/Makefile b/arch/x86_64/pci/Makefile
index a8f75a2a0f6..a3f6ad57017 100644
--- a/arch/x86_64/pci/Makefile
+++ b/arch/x86_64/pci/Makefile
@@ -7,7 +7,7 @@ CFLAGS += -Iarch/i386/pci
obj-y := i386.o
obj-$(CONFIG_PCI_DIRECT)+= direct.o
-obj-y += fixup.o
+obj-y += fixup.o init.o
obj-$(CONFIG_ACPI) += acpi.o
obj-y += legacy.o irq.o common.o
# mmconfig has a 64bit special
@@ -22,3 +22,4 @@ irq-y += ../../i386/pci/irq.o
common-y += ../../i386/pci/common.o
fixup-y += ../../i386/pci/fixup.o
i386-y += ../../i386/pci/i386.o
+init-y += ../../i386/pci/init.o
diff --git a/arch/x86_64/pci/mmconfig.c b/arch/x86_64/pci/mmconfig.c
index 18f371fe37f..e616500207e 100644
--- a/arch/x86_64/pci/mmconfig.c
+++ b/arch/x86_64/pci/mmconfig.c
@@ -55,7 +55,7 @@ static char __iomem *get_virt(unsigned int seg, unsigned bus)
static char __iomem *pci_dev_base(unsigned int seg, unsigned int bus, unsigned int devfn)
{
char __iomem *addr;
- if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), &fallback_slots))
+ if (seg == 0 && bus == 0 && test_bit(PCI_SLOT(devfn), fallback_slots))
return NULL;
addr = get_virt(seg, bus);
if (!addr)
@@ -143,29 +143,29 @@ static __init void unreachable_devices(void)
continue;
addr = pci_dev_base(0, 0, PCI_DEVFN(i, 0));
if (addr == NULL|| readl(addr) != val1) {
- set_bit(i, &fallback_slots);
+ set_bit(i, fallback_slots);
}
}
}
-static int __init pci_mmcfg_init(void)
+void __init pci_mmcfg_init(void)
{
int i;
if ((pci_probe & PCI_PROBE_MMCONF) == 0)
- return 0;
+ return;
acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
if ((pci_mmcfg_config_num == 0) ||
(pci_mmcfg_config == NULL) ||
(pci_mmcfg_config[0].base_address == 0))
- return 0;
+ return;
/* RED-PEN i386 doesn't do _nocache right now */
pci_mmcfg_virt = kmalloc(sizeof(*pci_mmcfg_virt) * pci_mmcfg_config_num, GFP_KERNEL);
if (pci_mmcfg_virt == NULL) {
printk("PCI: Can not allocate memory for mmconfig structures\n");
- return 0;
+ return;
}
for (i = 0; i < pci_mmcfg_config_num; ++i) {
pci_mmcfg_virt[i].cfg = &pci_mmcfg_config[i];
@@ -173,7 +173,7 @@ static int __init pci_mmcfg_init(void)
if (!pci_mmcfg_virt[i].virt) {
printk("PCI: Cannot map mmconfig aperture for segment %d\n",
pci_mmcfg_config[i].pci_segment_group_number);
- return 0;
+ return;
}
printk(KERN_INFO "PCI: Using MMCONFIG at %x\n", pci_mmcfg_config[i].base_address);
}
@@ -182,8 +182,4 @@ static int __init pci_mmcfg_init(void)
raw_pci_ops = &pci_mmcfg;
pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
-
- return 0;
}
-
-arch_initcall(pci_mmcfg_init);
diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index 4cbf6d91571..51f9bed455f 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -83,9 +83,8 @@ int show_interrupts(struct seq_file *p, void *v)
if (i == 0) {
seq_printf(p, " ");
- for (j=0; j<NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "CPU%d ",j);
+ for_each_online_cpu(j)
+ seq_printf(p, "CPU%d ",j);
seq_putc(p, '\n');
}
@@ -98,9 +97,8 @@ int show_interrupts(struct seq_file *p, void *v)
#ifndef CONFIG_SMP
seq_printf(p, "%10u ", kstat_irqs(i));
#else
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
#endif
seq_printf(p, " %14s", irq_desc[i].handler->typename);
seq_printf(p, " %s", action->name);
@@ -113,9 +111,8 @@ skip:
spin_unlock_irqrestore(&irq_desc[i].lock, flags);
} else if (i == NR_IRQS) {
seq_printf(p, "NMI: ");
- for (j = 0; j < NR_CPUS; j++)
- if (cpu_online(j))
- seq_printf(p, "%10u ", nmi_count(j));
+ for_each_online_cpu(j)
+ seq_printf(p, "%10u ", nmi_count(j));
seq_putc(p, '\n');
seq_printf(p, "ERR: %10u\n", atomic_read(&irq_err_count));
}
diff --git a/arch/xtensa/platform-iss/console.c b/arch/xtensa/platform-iss/console.c
index 94fdfe474ac..2a580efb58e 100644
--- a/arch/xtensa/platform-iss/console.c
+++ b/arch/xtensa/platform-iss/console.c
@@ -31,10 +31,6 @@
#include <linux/tty.h>
#include <linux/tty_flip.h>
-#ifdef SERIAL_INLINE
-#define _INLINE_ inline
-#endif
-
#define SERIAL_MAX_NUM_LINES 1
#define SERIAL_TIMER_VALUE (20 * HZ)
diff --git a/block/Kconfig b/block/Kconfig
index 377f6dd20e1..96783645092 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -11,4 +11,16 @@ config LBD
your machine, or if you want to have a raid or loopback device
bigger than 2TB. Otherwise say N.
+config BLK_DEV_IO_TRACE
+ bool "Support for tracing block io actions"
+ select RELAY
+ select DEBUG_FS
+ help
+ Say Y here, if you want to be able to trace the block layer actions
+ on a given queue. Tracing allows you to see any traffic happening
+ on a block device queue. For more information (and the user space
+ support tools needed), fetch the blktrace app from:
+
+ git://brick.kernel.dk/data/git/blktrace.git
+
source block/Kconfig.iosched
diff --git a/block/Makefile b/block/Makefile
index 7e4f93e2b44..c05de0e0037 100644
--- a/block/Makefile
+++ b/block/Makefile
@@ -8,3 +8,5 @@ obj-$(CONFIG_IOSCHED_NOOP) += noop-iosched.o
obj-$(CONFIG_IOSCHED_AS) += as-iosched.o
obj-$(CONFIG_IOSCHED_DEADLINE) += deadline-iosched.o
obj-$(CONFIG_IOSCHED_CFQ) += cfq-iosched.o
+
+obj-$(CONFIG_BLK_DEV_IO_TRACE) += blktrace.o
diff --git a/block/blktrace.c b/block/blktrace.c
new file mode 100644
index 00000000000..36f3a172275
--- /dev/null
+++ b/block/blktrace.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright (C) 2006 Jens Axboe <axboe@suse.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+#include <linux/config.h>
+#include <linux/kernel.h>
+#include <linux/blkdev.h>
+#include <linux/blktrace_api.h>
+#include <linux/percpu.h>
+#include <linux/init.h>
+#include <linux/mutex.h>
+#include <linux/debugfs.h>
+#include <asm/uaccess.h>
+
+static DEFINE_PER_CPU(unsigned long long, blk_trace_cpu_offset) = { 0, };
+static unsigned int blktrace_seq __read_mostly = 1;
+
+/*
+ * Send out a notify for this process, if we haven't done so since a trace
+ * started
+ */
+static void trace_note_tsk(struct blk_trace *bt, struct task_struct *tsk)
+{
+ struct blk_io_trace *t;
+
+ t = relay_reserve(bt->rchan, sizeof(*t) + sizeof(tsk->comm));
+ if (t) {
+ t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
+ t->device = bt->dev;
+ t->action = BLK_TC_ACT(BLK_TC_NOTIFY);
+ t->pid = tsk->pid;
+ t->cpu = smp_processor_id();
+ t->pdu_len = sizeof(tsk->comm);
+ memcpy((void *) t + sizeof(*t), tsk->comm, t->pdu_len);
+ tsk->btrace_seq = blktrace_seq;
+ }
+}
+
+static int act_log_check(struct blk_trace *bt, u32 what, sector_t sector,
+ pid_t pid)
+{
+ if (((bt->act_mask << BLK_TC_SHIFT) & what) == 0)
+ return 1;
+ if (sector < bt->start_lba || sector > bt->end_lba)
+ return 1;
+ if (bt->pid && pid != bt->pid)
+ return 1;
+
+ return 0;
+}
+
+/*
+ * Data direction bit lookup
+ */
+static u32 ddir_act[2] __read_mostly = { BLK_TC_ACT(BLK_TC_READ), BLK_TC_ACT(BLK_TC_WRITE) };
+
+/*
+ * Bio action bits of interest
+ */
+static u32 bio_act[3] __read_mostly = { 0, BLK_TC_ACT(BLK_TC_BARRIER), BLK_TC_ACT(BLK_TC_SYNC) };
+
+/*
+ * More could be added as needed, taking care to increment the decrementer
+ * to get correct indexing
+ */
+#define trace_barrier_bit(rw) \
+ (((rw) & (1 << BIO_RW_BARRIER)) >> (BIO_RW_BARRIER - 0))
+#define trace_sync_bit(rw) \
+ (((rw) & (1 << BIO_RW_SYNC)) >> (BIO_RW_SYNC - 1))
+
+/*
+ * The worker for the various blk_add_trace*() types. Fills out a
+ * blk_io_trace structure and places it in a per-cpu subbuffer.
+ */
+void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
+ int rw, u32 what, int error, int pdu_len, void *pdu_data)
+{
+ struct task_struct *tsk = current;
+ struct blk_io_trace *t;
+ unsigned long flags;
+ unsigned long *sequence;
+ pid_t pid;
+ int cpu;
+
+ if (unlikely(bt->trace_state != Blktrace_running))
+ return;
+
+ what |= ddir_act[rw & WRITE];
+ what |= bio_act[trace_barrier_bit(rw)];
+ what |= bio_act[trace_sync_bit(rw)];
+
+ pid = tsk->pid;
+ if (unlikely(act_log_check(bt, what, sector, pid)))
+ return;
+
+ /*
+ * A word about the locking here - we disable interrupts to reserve
+ * some space in the relay per-cpu buffer, to prevent an irq
+ * from coming in and stepping on our toes. Once reserved, it's
+ * enough to get preemption disabled to prevent read of this data
+ * before we are through filling it. get_cpu()/put_cpu() does this
+ * for us
+ */
+ local_irq_save(flags);
+
+ if (unlikely(tsk->btrace_seq != blktrace_seq))
+ trace_note_tsk(bt, tsk);
+
+ t = relay_reserve(bt->rchan, sizeof(*t) + pdu_len);
+ if (t) {
+ cpu = smp_processor_id();
+ sequence = per_cpu_ptr(bt->sequence, cpu);
+
+ t->magic = BLK_IO_TRACE_MAGIC | BLK_IO_TRACE_VERSION;
+ t->sequence = ++(*sequence);
+ t->time = sched_clock() - per_cpu(blk_trace_cpu_offset, cpu);
+ t->sector = sector;
+ t->bytes = bytes;
+ t->action = what;
+ t->pid = pid;
+ t->device = bt->dev;
+ t->cpu = cpu;
+ t->error = error;
+ t->pdu_len = pdu_len;
+
+ if (pdu_len)
+ memcpy((void *) t + sizeof(*t), pdu_data, pdu_len);
+ }
+
+ local_irq_restore(flags);
+}
+
+EXPORT_SYMBOL_GPL(__blk_add_trace);
+
+static struct dentry *blk_tree_root;
+static struct mutex blk_tree_mutex;
+static unsigned int root_users;
+
+static inline void blk_remove_root(void)
+{
+ if (blk_tree_root) {
+ debugfs_remove(blk_tree_root);
+ blk_tree_root = NULL;
+ }
+}
+
+static void blk_remove_tree(struct dentry *dir)
+{
+ mutex_lock(&blk_tree_mutex);
+ debugfs_remove(dir);
+ if (--root_users == 0)
+ blk_remove_root();
+ mutex_unlock(&blk_tree_mutex);
+}
+
+static struct dentry *blk_create_tree(const char *blk_name)
+{
+ struct dentry *dir = NULL;
+
+ mutex_lock(&blk_tree_mutex);
+
+ if (!blk_tree_root) {
+ blk_tree_root = debugfs_create_dir("block", NULL);
+ if (!blk_tree_root)
+ goto err;
+ }
+
+ dir = debugfs_create_dir(blk_name, blk_tree_root);
+ if (dir)
+ root_users++;
+ else
+ blk_remove_root();
+
+err:
+ mutex_unlock(&blk_tree_mutex);
+ return dir;
+}
+
+static void blk_trace_cleanup(struct blk_trace *bt)
+{
+ relay_close(bt->rchan);
+ debugfs_remove(bt->dropped_file);
+ blk_remove_tree(bt->dir);
+ free_percpu(bt->sequence);
+ kfree(bt);
+}
+
+static int blk_trace_remove(request_queue_t *q)
+{
+ struct blk_trace *bt;
+
+ bt = xchg(&q->blk_trace, NULL);
+ if (!bt)
+ return -EINVAL;
+
+ if (bt->trace_state == Blktrace_setup ||
+ bt->trace_state == Blktrace_stopped)
+ blk_trace_cleanup(bt);
+
+ return 0;
+}
+
+static int blk_dropped_open(struct inode *inode, struct file *filp)
+{
+ filp->private_data = inode->u.generic_ip;
+
+ return 0;
+}
+
+static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
+ size_t count, loff_t *ppos)
+{
+ struct blk_trace *bt = filp->private_data;
+ char buf[16];
+
+ snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
+
+ return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+}
+
+static struct file_operations blk_dropped_fops = {
+ .owner = THIS_MODULE,
+ .open = blk_dropped_open,
+ .read = blk_dropped_read,
+};
+
+/*
+ * Keep track of how many times we encountered a full subbuffer, to aid
+ * the user space app in telling how many lost events there were.
+ */
+static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
+ void *prev_subbuf, size_t prev_padding)
+{
+ struct blk_trace *bt;
+
+ if (!relay_buf_full(buf))
+ return 1;
+
+ bt = buf->chan->private_data;
+ atomic_inc(&bt->dropped);
+ return 0;
+}
+
+static int blk_remove_buf_file_callback(struct dentry *dentry)
+{
+ debugfs_remove(dentry);
+ return 0;
+}
+
+static struct dentry *blk_create_buf_file_callback(const char *filename,
+ struct dentry *parent,
+ int mode,
+ struct rchan_buf *buf,
+ int *is_global)
+{
+ return debugfs_create_file(filename, mode, parent, buf,
+ &relay_file_operations);
+}
+
+static struct rchan_callbacks blk_relay_callbacks = {
+ .subbuf_start = blk_subbuf_start_callback,
+ .create_buf_file = blk_create_buf_file_callback,
+ .remove_buf_file = blk_remove_buf_file_callback,
+};
+
+/*
+ * Setup everything required to start tracing
+ */
+static int blk_trace_setup(request_queue_t *q, struct block_device *bdev,
+ char __user *arg)
+{
+ struct blk_user_trace_setup buts;
+ struct blk_trace *old_bt, *bt = NULL;
+ struct dentry *dir = NULL;
+ char b[BDEVNAME_SIZE];
+ int ret, i;
+
+ if (copy_from_user(&buts, arg, sizeof(buts)))
+ return -EFAULT;
+
+ if (!buts.buf_size || !buts.buf_nr)
+ return -EINVAL;
+
+ strcpy(buts.name, bdevname(bdev, b));
+
+ /*
+ * some device names have larger paths - convert the slashes
+ * to underscores for this to work as expected
+ */
+ for (i = 0; i < strlen(buts.name); i++)
+ if (buts.name[i] == '/')
+ buts.name[i] = '_';
+
+ if (copy_to_user(arg, &buts, sizeof(buts)))
+ return -EFAULT;
+
+ ret = -ENOMEM;
+ bt = kzalloc(sizeof(*bt), GFP_KERNEL);
+ if (!bt)
+ goto err;
+
+ bt->sequence = alloc_percpu(unsigned long);
+ if (!bt->sequence)
+ goto err;
+
+ ret = -ENOENT;
+ dir = blk_create_tree(buts.name);
+ if (!dir)
+ goto err;
+
+ bt->dir = dir;
+ bt->dev = bdev->bd_dev;
+ atomic_set(&bt->dropped, 0);
+
+ ret = -EIO;
+ bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt, &blk_dropped_fops);
+ if (!bt->dropped_file)
+ goto err;
+
+ bt->rchan = relay_open("trace", dir, buts.buf_size, buts.buf_nr, &blk_relay_callbacks);
+ if (!bt->rchan)
+ goto err;
+ bt->rchan->private_data = bt;
+
+ bt->act_mask = buts.act_mask;
+ if (!bt->act_mask)
+ bt->act_mask = (u16) -1;
+
+ bt->start_lba = buts.start_lba;
+ bt->end_lba = buts.end_lba;
+ if (!bt->end_lba)
+ bt->end_lba = -1ULL;
+
+ bt->pid = buts.pid;
+ bt->trace_state = Blktrace_setup;
+
+ ret = -EBUSY;
+ old_bt = xchg(&q->blk_trace, bt);
+ if (old_bt) {
+ (void) xchg(&q->blk_trace, old_bt);
+ goto err;
+ }
+
+ return 0;
+err:
+ if (dir)
+ blk_remove_tree(dir);
+ if (bt) {
+ if (bt->dropped_file)
+ debugfs_remove(bt->dropped_file);
+ if (bt->sequence)
+ free_percpu(bt->sequence);
+ if (bt->rchan)
+ relay_close(bt->rchan);
+ kfree(bt);
+ }
+ return ret;
+}
+
+static int blk_trace_startstop(request_queue_t *q, int start)
+{
+ struct blk_trace *bt;
+ int ret;
+
+ if ((bt = q->blk_trace) == NULL)
+ return -EINVAL;
+
+ /*
+ * For starting a trace, we can transition from a setup or stopped
+ * trace. For stopping a trace, the state must be running
+ */
+ ret = -EINVAL;
+ if (start) {
+ if (bt->trace_state == Blktrace_setup ||
+ bt->trace_state == Blktrace_stopped) {
+ blktrace_seq++;
+ smp_mb();
+ bt->trace_state = Blktrace_running;
+ ret = 0;
+ }
+ } else {
+ if (bt->trace_state == Blktrace_running) {
+ bt->trace_state = Blktrace_stopped;
+ relay_flush(bt->rchan);
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * blk_trace_ioctl: - handle the ioctls associated with tracing
+ * @bdev: the block device
+ * @cmd: the ioctl cmd
+ * @arg: the argument data, if any
+ *
+ **/
+int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
+{
+ request_queue_t *q;
+ int ret, start = 0;
+
+ q = bdev_get_queue(bdev);
+ if (!q)
+ return -ENXIO;
+
+ mutex_lock(&bdev->bd_mutex);
+
+ switch (cmd) {
+ case BLKTRACESETUP:
+ ret = blk_trace_setup(q, bdev, arg);
+ break;
+ case BLKTRACESTART:
+ start = 1;
+ case BLKTRACESTOP:
+ ret = blk_trace_startstop(q, start);
+ break;
+ case BLKTRACETEARDOWN:
+ ret = blk_trace_remove(q);
+ break;
+ default:
+ ret = -ENOTTY;
+ break;
+ }
+
+ mutex_unlock(&bdev->bd_mutex);
+ return ret;
+}
+
+/**
+ * blk_trace_shutdown: - stop and cleanup trace structures
+ * @q: the request queue associated with the device
+ *
+ **/
+void blk_trace_shutdown(request_queue_t *q)
+{
+ blk_trace_startstop(q, 0);
+ blk_trace_remove(q);
+}
+
+/*
+ * Average offset over two calls to sched_clock() with a gettimeofday()
+ * in the middle
+ */
+static void blk_check_time(unsigned long long *t)
+{
+ unsigned long long a, b;
+ struct timeval tv;
+
+ a = sched_clock();
+ do_gettimeofday(&tv);
+ b = sched_clock();
+
+ *t = tv.tv_sec * 1000000000 + tv.tv_usec * 1000;
+ *t -= (a + b) / 2;
+}
+
+static void blk_trace_check_cpu_time(void *data)
+{
+ unsigned long long *t;
+ int cpu = get_cpu();
+
+ t = &per_cpu(blk_trace_cpu_offset, cpu);
+
+ /*
+ * Just call it twice, hopefully the second call will be cache hot
+ * and a little more precise
+ */
+ blk_check_time(t);
+ blk_check_time(t);
+
+ put_cpu();
+}
+
+/*
+ * Call blk_trace_check_cpu_time() on each CPU to calibrate our inter-CPU
+ * timings
+ */
+static void blk_trace_calibrate_offsets(void)
+{
+ unsigned long flags;
+
+ smp_call_function(blk_trace_check_cpu_time, NULL, 1, 1);
+ local_irq_save(flags);
+ blk_trace_check_cpu_time(NULL);
+ local_irq_restore(flags);
+}
+
+static void blk_trace_set_ht_offsets(void)
+{
+#if defined(CONFIG_SCHED_SMT)
+ int cpu, i;
+
+ /*
+ * now make sure HT siblings have the same time offset
+ */
+ preempt_disable();
+ for_each_online_cpu(cpu) {
+ unsigned long long *cpu_off, *sibling_off;
+
+ for_each_cpu_mask(i, cpu_sibling_map[cpu]) {
+ if (i == cpu)
+ continue;
+
+ cpu_off = &per_cpu(blk_trace_cpu_offset, cpu);
+ sibling_off = &per_cpu(blk_trace_cpu_offset, i);
+ *sibling_off = *cpu_off;
+ }
+ }
+ preempt_enable();
+#endif
+}
+
+static __init int blk_trace_init(void)
+{
+ mutex_init(&blk_tree_mutex);
+ blk_trace_calibrate_offsets();
+ blk_trace_set_ht_offsets();
+
+ return 0;
+}
+
+module_init(blk_trace_init);
+
diff --git a/block/elevator.c b/block/elevator.c
index db3d0d8296a..56c2ed06a9e 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -33,6 +33,7 @@
#include <linux/init.h>
#include <linux/compiler.h>
#include <linux/delay.h>
+#include <linux/blktrace_api.h>
#include <asm/uaccess.h>
@@ -333,6 +334,8 @@ void elv_insert(request_queue_t *q, struct request *rq, int where)
struct list_head *pos;
unsigned ordseq;
+ blk_add_trace_rq(q, rq, BLK_TA_INSERT);
+
rq->q = q;
switch (where) {
@@ -499,6 +502,7 @@ struct request *elv_next_request(request_queue_t *q)
* not be passed by new incoming requests
*/
rq->flags |= REQ_STARTED;
+ blk_add_trace_rq(q, rq, BLK_TA_ISSUE);
}
if (!q->boundary_rq || q->boundary_rq == rq) {
@@ -724,8 +728,7 @@ void elv_unregister_queue(struct request_queue *q)
int elv_register(struct elevator_type *e)
{
spin_lock_irq(&elv_list_lock);
- if (elevator_find(e->elevator_name))
- BUG();
+ BUG_ON(elevator_find(e->elevator_name));
list_add_tail(&e->list, &elv_list);
spin_unlock_irq(&elv_list_lock);
diff --git a/block/ioctl.c b/block/ioctl.c
index e1109491c23..9cfa2e1ecb2 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -5,6 +5,7 @@
#include <linux/backing-dev.h>
#include <linux/buffer_head.h>
#include <linux/smp_lock.h>
+#include <linux/blktrace_api.h>
#include <asm/uaccess.h>
static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user *arg)
@@ -42,9 +43,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
return -EINVAL;
}
/* partition number in use? */
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
if (disk->part[part - 1]) {
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return -EBUSY;
}
/* overlap? */
@@ -55,13 +56,13 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
continue;
if (!(start+length <= s->start_sect ||
start >= s->start_sect + s->nr_sects)) {
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return -EBUSY;
}
}
/* all seems OK */
add_partition(disk, part, start, length);
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return 0;
case BLKPG_DEL_PARTITION:
if (!disk->part[part-1])
@@ -71,9 +72,9 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
bdevp = bdget_disk(disk, part);
if (!bdevp)
return -ENOMEM;
- down(&bdevp->bd_sem);
+ mutex_lock(&bdevp->bd_mutex);
if (bdevp->bd_openers) {
- up(&bdevp->bd_sem);
+ mutex_unlock(&bdevp->bd_mutex);
bdput(bdevp);
return -EBUSY;
}
@@ -81,10 +82,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
fsync_bdev(bdevp);
invalidate_bdev(bdevp, 0);
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
delete_partition(disk, part);
- up(&bdev->bd_sem);
- up(&bdevp->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
+ mutex_unlock(&bdevp->bd_mutex);
bdput(bdevp);
return 0;
@@ -102,10 +103,10 @@ static int blkdev_reread_part(struct block_device *bdev)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (down_trylock(&bdev->bd_sem))
+ if (!mutex_trylock(&bdev->bd_mutex))
return -EBUSY;
res = rescan_partitions(disk, bdev);
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return res;
}
@@ -189,6 +190,11 @@ static int blkdev_locked_ioctl(struct file *file, struct block_device *bdev,
return put_ulong(arg, bdev->bd_inode->i_size >> 9);
case BLKGETSIZE64:
return put_u64(arg, bdev->bd_inode->i_size);
+ case BLKTRACESTART:
+ case BLKTRACESTOP:
+ case BLKTRACESETUP:
+ case BLKTRACETEARDOWN:
+ return blk_trace_ioctl(bdev, cmd, (char __user *) arg);
}
return -ENOIOCTLCMD;
}
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 6c793b196aa..062067fa7ea 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -28,6 +28,7 @@
#include <linux/writeback.h>
#include <linux/interrupt.h>
#include <linux/cpu.h>
+#include <linux/blktrace_api.h>
/*
* for max sense size
@@ -1556,8 +1557,10 @@ void blk_plug_device(request_queue_t *q)
if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags))
return;
- if (!test_and_set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags))
+ if (!test_and_set_bit(QUEUE_FLAG_PLUGGED, &q->queue_flags)) {
mod_timer(&q->unplug_timer, jiffies + q->unplug_delay);
+ blk_add_trace_generic(q, NULL, 0, BLK_TA_PLUG);
+ }
}
EXPORT_SYMBOL(blk_plug_device);
@@ -1621,14 +1624,21 @@ static void blk_backing_dev_unplug(struct backing_dev_info *bdi,
/*
* devices don't necessarily have an ->unplug_fn defined
*/
- if (q->unplug_fn)
+ if (q->unplug_fn) {
+ blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL,
+ q->rq.count[READ] + q->rq.count[WRITE]);
+
q->unplug_fn(q);
+ }
}
static void blk_unplug_work(void *data)
{
request_queue_t *q = data;
+ blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_IO, NULL,
+ q->rq.count[READ] + q->rq.count[WRITE]);
+
q->unplug_fn(q);
}
@@ -1636,6 +1646,9 @@ static void blk_unplug_timeout(unsigned long data)
{
request_queue_t *q = (request_queue_t *)data;
+ blk_add_trace_pdu_int(q, BLK_TA_UNPLUG_TIMER, NULL,
+ q->rq.count[READ] + q->rq.count[WRITE]);
+
kblockd_schedule_work(&q->unplug_work);
}
@@ -1753,6 +1766,9 @@ static void blk_release_queue(struct kobject *kobj)
if (q->queue_tags)
__blk_queue_free_tags(q);
+ if (q->blk_trace)
+ blk_trace_shutdown(q);
+
kmem_cache_free(requestq_cachep, q);
}
@@ -2129,6 +2145,8 @@ rq_starved:
rq_init(q, rq);
rq->rl = rl;
+
+ blk_add_trace_generic(q, bio, rw, BLK_TA_GETRQ);
out:
return rq;
}
@@ -2157,6 +2175,8 @@ static struct request *get_request_wait(request_queue_t *q, int rw,
if (!rq) {
struct io_context *ioc;
+ blk_add_trace_generic(q, bio, rw, BLK_TA_SLEEPRQ);
+
__generic_unplug_device(q);
spin_unlock_irq(q->queue_lock);
io_schedule();
@@ -2210,6 +2230,8 @@ EXPORT_SYMBOL(blk_get_request);
*/
void blk_requeue_request(request_queue_t *q, struct request *rq)
{
+ blk_add_trace_rq(q, rq, BLK_TA_REQUEUE);
+
if (blk_rq_tagged(rq))
blk_queue_end_tag(q, rq);
@@ -2844,6 +2866,8 @@ static int __make_request(request_queue_t *q, struct bio *bio)
if (!q->back_merge_fn(q, req, bio))
break;
+ blk_add_trace_bio(q, bio, BLK_TA_BACKMERGE);
+
req->biotail->bi_next = bio;
req->biotail = bio;
req->nr_sectors = req->hard_nr_sectors += nr_sectors;
@@ -2859,6 +2883,8 @@ static int __make_request(request_queue_t *q, struct bio *bio)
if (!q->front_merge_fn(q, req, bio))
break;
+ blk_add_trace_bio(q, bio, BLK_TA_FRONTMERGE);
+
bio->bi_next = req->bio;
req->bio = bio;
@@ -2976,6 +3002,7 @@ void generic_make_request(struct bio *bio)
request_queue_t *q;
sector_t maxsector;
int ret, nr_sectors = bio_sectors(bio);
+ dev_t old_dev;
might_sleep();
/* Test device or partition size, when known. */
@@ -3002,6 +3029,8 @@ void generic_make_request(struct bio *bio)
* NOTE: we don't repeat the blk_size check for each new device.
* Stacking drivers are expected to know what they are doing.
*/
+ maxsector = -1;
+ old_dev = 0;
do {
char b[BDEVNAME_SIZE];
@@ -3034,6 +3063,15 @@ end_io:
*/
blk_partition_remap(bio);
+ if (maxsector != -1)
+ blk_add_trace_remap(q, bio, old_dev, bio->bi_sector,
+ maxsector);
+
+ blk_add_trace_bio(q, bio, BLK_TA_QUEUE);
+
+ maxsector = bio->bi_sector;
+ old_dev = bio->bi_bdev->bd_dev;
+
ret = q->make_request_fn(q, bio);
} while (ret);
}
@@ -3153,6 +3191,8 @@ static int __end_that_request_first(struct request *req, int uptodate,
int total_bytes, bio_nbytes, error, next_idx = 0;
struct bio *bio;
+ blk_add_trace_rq(req->q, req, BLK_TA_COMPLETE);
+
/*
* extend uptodate bool to allow < 0 value to be direct io error
*/
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 33e2ca847a2..5cb96300eb0 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -205,6 +205,18 @@ config ACPI_IBM
If you have an IBM ThinkPad laptop, say Y or M here.
+config ACPI_IBM_DOCK
+ bool "Legacy Docking Station Support"
+ depends on ACPI_IBM
+ default n
+ ---help---
+ Allows the ibm_acpi driver to handle docking station events.
+ This support is obsoleted by CONFIG_HOTPLUG_PCI_ACPI. It will
+ allow locking and removing the laptop from the docking station,
+ but will not properly connect PCI devices.
+
+ If you are not sure, say N here.
+
config ACPI_TOSHIBA
tristate "Toshiba Laptop Extras"
depends on X86
@@ -244,7 +256,8 @@ config ACPI_CUSTOM_DSDT_FILE
depends on ACPI_CUSTOM_DSDT
default ""
help
- Enter the full path name to the file wich includes the AmlCode declaration.
+ Enter the full path name to the file which includes the AmlCode
+ declaration.
config ACPI_BLACKLIST_YEAR
int "Disable ACPI for systems before Jan 1st this year" if X86_32
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index 5cc090326dd..262b1f41335 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -160,13 +160,13 @@ IBM_HANDLE(cmos, root, "\\UCMS", /* R50, R50e, R50p, R51, T4x, X31, X40 */
"\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
"\\CMS", /* R40, R40e */
); /* all others */
-
+#ifdef CONFIG_ACPI_IBM_DOCK
IBM_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
"\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
"\\_SB.PCI0.PCI1.DOCK", /* all others */
"\\_SB.PCI.ISA.SLCE", /* 570 */
); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
-
+#endif
IBM_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
"\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
"\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
@@ -844,7 +844,7 @@ static int _sta(acpi_handle handle)
return status;
}
-
+#ifdef CONFIG_ACPI_IBM_DOCK
#define dock_docked() (_sta(dock_handle) & 1)
static int dock_read(char *p)
@@ -907,6 +907,7 @@ static void dock_notify(struct ibm_struct *ibm, u32 event)
acpi_bus_generate_event(ibm->device, event, 0); /* unknown */
}
}
+#endif
static int bay_status_supported;
static int bay_status2_supported;
@@ -1574,6 +1575,7 @@ static struct ibm_struct ibms[] = {
.read = light_read,
.write = light_write,
},
+#ifdef CONFIG_ACPI_IBM_DOCK
{
.name = "dock",
.read = dock_read,
@@ -1589,6 +1591,7 @@ static struct ibm_struct ibms[] = {
.handle = &pci_handle,
.type = ACPI_SYSTEM_NOTIFY,
},
+#endif
{
.name = "bay",
.init = bay_init,
@@ -1880,7 +1883,9 @@ IBM_PARAM(hotkey);
IBM_PARAM(bluetooth);
IBM_PARAM(video);
IBM_PARAM(light);
+#ifdef CONFIG_ACPI_IBM_DOCK
IBM_PARAM(dock);
+#endif
IBM_PARAM(bay);
IBM_PARAM(cmos);
IBM_PARAM(led);
@@ -1927,7 +1932,9 @@ static int __init acpi_ibm_init(void)
IBM_HANDLE_INIT(hkey);
IBM_HANDLE_INIT(lght);
IBM_HANDLE_INIT(cmos);
+#ifdef CONFIG_ACPI_IBM_DOCK
IBM_HANDLE_INIT(dock);
+#endif
IBM_HANDLE_INIT(pci);
IBM_HANDLE_INIT(bay);
if (bay_handle)
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 9271e5209ac..a0ab828b2cc 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -23,7 +23,6 @@ static LIST_HEAD(acpi_device_list);
DEFINE_SPINLOCK(acpi_device_lock);
LIST_HEAD(acpi_wakeup_device_list);
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice);
static void acpi_device_release(struct kobject *kobj)
{
@@ -1284,7 +1283,7 @@ int acpi_bus_start(struct acpi_device *device)
EXPORT_SYMBOL(acpi_bus_start);
-static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
+int acpi_bus_trim(struct acpi_device *start, int rmdevice)
{
acpi_status status;
struct acpi_device *parent, *child;
@@ -1337,6 +1336,8 @@ static int acpi_bus_trim(struct acpi_device *start, int rmdevice)
}
return err;
}
+EXPORT_SYMBOL_GPL(acpi_bus_trim);
+
static int acpi_bus_scan_fixed(struct acpi_device *root)
{
diff --git a/drivers/atm/.gitignore b/drivers/atm/.gitignore
new file mode 100644
index 00000000000..a165b716771
--- /dev/null
+++ b/drivers/atm/.gitignore
@@ -0,0 +1,5 @@
+# Ignore generated files
+fore200e_mkfirm
+fore200e_pca_fw.c
+pca200e.bin
+
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 29f3d7504da..dd712b24ec9 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -19,11 +19,6 @@ EXPORT_SYMBOL(cpu_sysdev_class);
static struct sys_device *cpu_sys_devices[NR_CPUS];
#ifdef CONFIG_HOTPLUG_CPU
-int __attribute__((weak)) smp_prepare_cpu (int cpu)
-{
- return 0;
-}
-
static ssize_t show_online(struct sys_device *dev, char *buf)
{
struct cpu *cpu = container_of(dev, struct cpu, sysdev);
@@ -44,9 +39,7 @@ static ssize_t store_online(struct sys_device *dev, const char *buf,
kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
break;
case '1':
- ret = smp_prepare_cpu(cpu->sysdev.id);
- if (!ret)
- ret = cpu_up(cpu->sysdev.id);
+ ret = cpu_up(cpu->sysdev.id);
if (!ret)
kobject_uevent(&dev->kobj, KOBJ_ONLINE);
break;
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
index 8660779fb28..bdb60663f2e 100644
--- a/drivers/base/power/suspend.c
+++ b/drivers/base/power/suspend.c
@@ -8,6 +8,7 @@
*
*/
+#include <linux/vt_kern.h>
#include <linux/device.h>
#include "../base.h"
#include "power.h"
@@ -62,7 +63,6 @@ int suspend_device(struct device * dev, pm_message_t state)
return error;
}
-
/**
* device_suspend - Save state and stop all devices in system.
* @state: Power state to put each device in.
@@ -82,6 +82,9 @@ int device_suspend(pm_message_t state)
{
int error = 0;
+ if (!is_console_suspend_safe())
+ return -EINVAL;
+
down(&dpm_sem);
down(&dpm_list_sem);
while (!list_empty(&dpm_active) && error == 0) {
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c
index 37b8cda3e8b..9bdea2a5cf0 100644
--- a/drivers/block/DAC960.c
+++ b/drivers/block/DAC960.c
@@ -228,8 +228,7 @@ static void *slice_dma_loaf(struct dma_loaf *loaf, size_t len,
void *cpu_end = loaf->cpu_free + len;
void *cpu_addr = loaf->cpu_free;
- if (cpu_end > loaf->cpu_base + loaf->length)
- BUG();
+ BUG_ON(cpu_end > loaf->cpu_base + loaf->length);
*dma_handle = loaf->dma_free;
loaf->cpu_free = cpu_end;
loaf->dma_free += len;
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 8b133167740..e57ac5a4324 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -401,7 +401,6 @@ config BLK_DEV_RAM_SIZE
config BLK_DEV_INITRD
bool "Initial RAM disk (initrd) support"
- depends on BLK_DEV_RAM=y
help
The initial RAM disk is a RAM disk that is loaded by the boot loader
(loadlin or lilo) and that is mounted as root before the normal boot
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 3ec1f8df87b..410f259a803 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -7,7 +7,6 @@
obj-$(CONFIG_MAC_FLOPPY) += swim3.o
obj-$(CONFIG_BLK_DEV_FD) += floppy.o
-obj-$(CONFIG_BLK_DEV_FD98) += floppy98.o
obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
obj-$(CONFIG_BLK_DEV_SWIM_IOP) += swim_iop.o
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index f8ce235ccfc..c39650920bd 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -271,7 +271,7 @@ unsigned char *DMABuffer; /* buffer for writes */
static unsigned long PhysDMABuffer; /* physical address */
static int UseTrackbuffer = -1; /* Do track buffering? */
-MODULE_PARM(UseTrackbuffer, "i");
+module_param(UseTrackbuffer, int, 0);
unsigned char *TrackBuffer; /* buffer for reads */
static unsigned long PhysTrackBuffer; /* physical address */
@@ -296,7 +296,7 @@ static int MotorOn = 0, MotorOffTrys;
static int IsFormatting = 0, FormatError;
static int UserSteprate[FD_MAX_UNITS] = { -1, -1 };
-MODULE_PARM(UserSteprate, "1-" __MODULE_STRING(FD_MAX_UNITS) "i");
+module_param_array(UserSteprate, int, NULL, 0);
/* Synchronization of FDC access. */
static volatile int fdc_busy = 0;
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index cf39cf9aac2..71ec9e66438 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -38,6 +38,7 @@
#include <linux/hdreg.h>
#include <linux/spinlock.h>
#include <linux/compat.h>
+#include <linux/blktrace_api.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -2331,6 +2332,7 @@ static inline void complete_command( ctlr_info_t *h, CommandList_struct *cmd,
cmd->rq->completion_data = cmd;
cmd->rq->errors = status;
+ blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE);
blk_complete_request(cmd->rq);
}
@@ -2359,8 +2361,7 @@ queue:
if (!creq)
goto startio;
- if (creq->nr_phys_segments > MAXSGENTRIES)
- BUG();
+ BUG_ON(creq->nr_phys_segments > MAXSGENTRIES);
if (( c = cmd_alloc(h, 1)) == NULL)
goto full;
@@ -3268,8 +3269,8 @@ clean2:
unregister_blkdev(hba[i]->major, hba[i]->devname);
clean1:
release_io_mem(hba[i]);
- free_hba(i);
hba[i]->busy_initializing = 0;
+ free_hba(i);
return(-1);
}
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index 9e35de05d5c..0e66e904bd8 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -1316,7 +1316,7 @@ cciss_scsi_queue_command (struct scsi_cmnd *cmd, void (* done)(struct scsi_cmnd
cp->Request.Timeout = 0;
memset(cp->Request.CDB, 0, sizeof(cp->Request.CDB));
- if (cmd->cmd_len > sizeof(cp->Request.CDB)) BUG();
+ BUG_ON(cmd->cmd_len > sizeof(cp->Request.CDB));
cp->Request.CDBLen = cmd->cmd_len;
memcpy(cp->Request.CDB, cmd->cmnd, cmd->cmd_len);
cp->Request.Type.Type = TYPE_CMD;
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 862b9abac0a..b6ea2f0c727 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -906,8 +906,7 @@ queue_next:
if (!creq)
goto startio;
- if (creq->nr_phys_segments > SG_MAX)
- BUG();
+ BUG_ON(creq->nr_phys_segments > SG_MAX);
if ((c = cmd_alloc(h,1)) == NULL)
goto startio;
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index d23b54332d7..840919bba76 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -179,6 +179,7 @@ static int print_unex = 1;
#include <linux/devfs_fs_kernel.h>
#include <linux/platform_device.h>
#include <linux/buffer_head.h> /* for invalidate_buffers() */
+#include <linux/mutex.h>
/*
* PS/2 floppies have much slower step rates than regular floppies.
@@ -413,7 +414,7 @@ static struct floppy_write_errors write_errors[N_DRIVE];
static struct timer_list motor_off_timer[N_DRIVE];
static struct gendisk *disks[N_DRIVE];
static struct block_device *opened_bdev[N_DRIVE];
-static DECLARE_MUTEX(open_lock);
+static DEFINE_MUTEX(open_lock);
static struct floppy_raw_cmd *raw_cmd, default_raw_cmd;
/*
@@ -3333,7 +3334,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
if (type) {
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- down(&open_lock);
+ mutex_lock(&open_lock);
LOCK_FDC(drive, 1);
floppy_type[type] = *g;
floppy_type[type].name = "user format";
@@ -3347,7 +3348,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g,
continue;
__invalidate_device(bdev);
}
- up(&open_lock);
+ mutex_unlock(&open_lock);
} else {
int oldStretch;
LOCK_FDC(drive, 1);
@@ -3674,7 +3675,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
{
int drive = (long)inode->i_bdev->bd_disk->private_data;
- down(&open_lock);
+ mutex_lock(&open_lock);
if (UDRS->fd_ref < 0)
UDRS->fd_ref = 0;
else if (!UDRS->fd_ref--) {
@@ -3684,7 +3685,7 @@ static int floppy_release(struct inode *inode, struct file *filp)
if (!UDRS->fd_ref)
opened_bdev[drive] = NULL;
floppy_release_irq_and_dma();
- up(&open_lock);
+ mutex_unlock(&open_lock);
return 0;
}
@@ -3702,7 +3703,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
char *tmp;
filp->private_data = (void *)0;
- down(&open_lock);
+ mutex_lock(&open_lock);
old_dev = UDRS->fd_device;
if (opened_bdev[drive] && opened_bdev[drive] != inode->i_bdev)
goto out2;
@@ -3785,7 +3786,7 @@ static int floppy_open(struct inode *inode, struct file *filp)
if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
goto out;
}
- up(&open_lock);
+ mutex_unlock(&open_lock);
return 0;
out:
if (UDRS->fd_ref < 0)
@@ -3796,7 +3797,7 @@ out:
opened_bdev[drive] = NULL;
floppy_release_irq_and_dma();
out2:
- up(&open_lock);
+ mutex_unlock(&open_lock);
return res;
}
@@ -4593,7 +4594,7 @@ static void __init parse_floppy_cfg_string(char *cfg)
}
}
-int init_module(void)
+int __init init_module(void)
{
if (floppy)
parse_floppy_cfg_string(floppy);
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 0010704739e..74bf0255e98 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1144,7 +1144,7 @@ static int lo_ioctl(struct inode * inode, struct file * file,
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
int err;
- down(&lo->lo_ctl_mutex);
+ mutex_lock(&lo->lo_ctl_mutex);
switch (cmd) {
case LOOP_SET_FD:
err = loop_set_fd(lo, file, inode->i_bdev, arg);
@@ -1170,7 +1170,7 @@ static int lo_ioctl(struct inode * inode, struct file * file,
default:
err = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;
}
- up(&lo->lo_ctl_mutex);
+ mutex_unlock(&lo->lo_ctl_mutex);
return err;
}
@@ -1178,9 +1178,9 @@ static int lo_open(struct inode *inode, struct file *file)
{
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
- down(&lo->lo_ctl_mutex);
+ mutex_lock(&lo->lo_ctl_mutex);
lo->lo_refcnt++;
- up(&lo->lo_ctl_mutex);
+ mutex_unlock(&lo->lo_ctl_mutex);
return 0;
}
@@ -1189,9 +1189,9 @@ static int lo_release(struct inode *inode, struct file *file)
{
struct loop_device *lo = inode->i_bdev->bd_disk->private_data;
- down(&lo->lo_ctl_mutex);
+ mutex_lock(&lo->lo_ctl_mutex);
--lo->lo_refcnt;
- up(&lo->lo_ctl_mutex);
+ mutex_unlock(&lo->lo_ctl_mutex);
return 0;
}
@@ -1233,12 +1233,12 @@ int loop_unregister_transfer(int number)
xfer_funcs[n] = NULL;
for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) {
- down(&lo->lo_ctl_mutex);
+ mutex_lock(&lo->lo_ctl_mutex);
if (lo->lo_encryption == xfer)
loop_release_xfer(lo);
- up(&lo->lo_ctl_mutex);
+ mutex_unlock(&lo->lo_ctl_mutex);
}
return 0;
@@ -1285,7 +1285,7 @@ static int __init loop_init(void)
lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
if (!lo->lo_queue)
goto out_mem4;
- init_MUTEX(&lo->lo_ctl_mutex);
+ mutex_init(&lo->lo_ctl_mutex);
init_completion(&lo->lo_done);
init_completion(&lo->lo_bh_done);
lo->lo_number = i;
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 6997d8e6bfb..8bca4905d7f 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -459,9 +459,9 @@ static void do_nbd_request(request_queue_t * q)
req->errors = 0;
spin_unlock_irq(q->queue_lock);
- down(&lo->tx_lock);
+ mutex_lock(&lo->tx_lock);
if (unlikely(!lo->sock)) {
- up(&lo->tx_lock);
+ mutex_unlock(&lo->tx_lock);
printk(KERN_ERR "%s: Attempted send on closed socket\n",
lo->disk->disk_name);
req->errors++;
@@ -484,7 +484,7 @@ static void do_nbd_request(request_queue_t * q)
}
lo->active_req = NULL;
- up(&lo->tx_lock);
+ mutex_unlock(&lo->tx_lock);
wake_up_all(&lo->active_wq);
spin_lock_irq(q->queue_lock);
@@ -534,9 +534,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
case NBD_CLEAR_SOCK:
error = 0;
- down(&lo->tx_lock);
+ mutex_lock(&lo->tx_lock);
lo->sock = NULL;
- up(&lo->tx_lock);
+ mutex_unlock(&lo->tx_lock);
file = lo->file;
lo->file = NULL;
nbd_clear_que(lo);
@@ -590,7 +590,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
* FIXME: This code is duplicated from sys_shutdown, but
* there should be a more generic interface rather than
* calling socket ops directly here */
- down(&lo->tx_lock);
+ mutex_lock(&lo->tx_lock);
if (lo->sock) {
printk(KERN_WARNING "%s: shutting down socket\n",
lo->disk->disk_name);
@@ -598,7 +598,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
SEND_SHUTDOWN|RCV_SHUTDOWN);
lo->sock = NULL;
}
- up(&lo->tx_lock);
+ mutex_unlock(&lo->tx_lock);
file = lo->file;
lo->file = NULL;
nbd_clear_que(lo);
@@ -639,10 +639,7 @@ static int __init nbd_init(void)
int err = -ENOMEM;
int i;
- if (sizeof(struct nbd_request) != 28) {
- printk(KERN_CRIT "nbd: sizeof nbd_request needs to be 28 in order to work!\n" );
- return -EIO;
- }
+ BUILD_BUG_ON(sizeof(struct nbd_request) != 28);
if (nbds_max > MAX_NBD) {
printk(KERN_CRIT "nbd: cannot allocate more than %u nbds; %u requested.\n", MAX_NBD,
@@ -683,7 +680,7 @@ static int __init nbd_init(void)
nbd_dev[i].flags = 0;
spin_lock_init(&nbd_dev[i].queue_lock);
INIT_LIST_HEAD(&nbd_dev[i].queue_head);
- init_MUTEX(&nbd_dev[i].tx_lock);
+ mutex_init(&nbd_dev[i].tx_lock);
init_waitqueue_head(&nbd_dev[i].active_wq);
nbd_dev[i].blksize = 1024;
nbd_dev[i].bytesize = 0x7ffffc00ULL << 10; /* 2TB */
diff --git a/drivers/block/paride/comm.c b/drivers/block/paride/comm.c
index d842956edf7..43d61359d8e 100644
--- a/drivers/block/paride/comm.c
+++ b/drivers/block/paride/comm.c
@@ -60,7 +60,7 @@ static int comm_read_regr( PIA *pi, int cont, int regr )
case 2:
case 3:
- case 4: w3(r+0x20); r1();
+ case 4: w3(r+0x20); (void)r1();
w2(0x24); h = r4(); w2(4);
return h;
@@ -82,7 +82,7 @@ static void comm_write_regr( PIA *pi, int cont, int regr, int val )
case 2:
case 3:
- case 4: w3(r); r1(); w4(val);
+ case 4: w3(r); (void)r1(); w4(val);
break;
}
}
@@ -126,17 +126,17 @@ static void comm_read_block( PIA *pi, char * buf, int count )
w2(4);
break;
- case 2: w3(0x68); r1(); w2(0x24);
+ case 2: w3(0x68); (void)r1(); w2(0x24);
for (i=0;i<count;i++) buf[i] = r4();
w2(4);
break;
- case 3: w3(0x68); r1(); w2(0x24);
+ case 3: w3(0x68); (void)r1(); w2(0x24);
for (i=0;i<count/2;i++) ((u16 *)buf)[i] = r4w();
w2(4);
break;
- case 4: w3(0x68); r1(); w2(0x24);
+ case 4: w3(0x68); (void)r1(); w2(0x24);
for (i=0;i<count/4;i++) ((u32 *)buf)[i] = r4l();
w2(4);
break;
@@ -160,15 +160,15 @@ static void comm_write_block( PIA *pi, char * buf, int count )
w2(5); w2(4);
break;
- case 2: w3(0x48); r1();
+ case 2: w3(0x48); (void)r1();
for (k=0;k<count;k++) w4(buf[k^1]);
break;
- case 3: w3(0x48); r1();
+ case 3: w3(0x48); (void)r1();
for (k=0;k<count/2;k++) w4w(pi_swab16(buf,k));
break;
- case 4: w3(0x48); r1();
+ case 4: w3(0x48); (void)r1();
for (k=0;k<count/4;k++) w4l(pi_swab32(buf,k));
break;
diff --git a/drivers/block/paride/on26.c b/drivers/block/paride/on26.c
index 9f837d9a363..0f833caa210 100644
--- a/drivers/block/paride/on26.c
+++ b/drivers/block/paride/on26.c
@@ -66,7 +66,7 @@ static int on26_read_regr( PIA *pi, int cont, int regr )
case 3:
case 4: w3(1); w3(1); w2(5); w4(r); w2(4);
w3(0); w3(0); w2(0x24); a = r4(); w2(4);
- w2(0x24); r4(); w2(4);
+ w2(0x24); (void)r4(); w2(4);
return a;
}
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 476a5b553f3..1d261f985f3 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -56,6 +56,7 @@
#include <linux/seq_file.h>
#include <linux/miscdevice.h>
#include <linux/suspend.h>
+#include <linux/mutex.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_ioctl.h>
#include <scsi/scsi.h>
@@ -81,7 +82,7 @@
static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
static struct proc_dir_entry *pkt_proc;
static int pkt_major;
-static struct semaphore ctl_mutex; /* Serialize open/close/setup/teardown */
+static struct mutex ctl_mutex; /* Serialize open/close/setup/teardown */
static mempool_t *psd_pool;
@@ -2018,7 +2019,7 @@ static int pkt_open(struct inode *inode, struct file *file)
VPRINTK("pktcdvd: entering open\n");
- down(&ctl_mutex);
+ mutex_lock(&ctl_mutex);
pd = pkt_find_dev_from_minor(iminor(inode));
if (!pd) {
ret = -ENODEV;
@@ -2044,14 +2045,14 @@ static int pkt_open(struct inode *inode, struct file *file)
set_blocksize(inode->i_bdev, CD_FRAMESIZE);
}
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
return 0;
out_dec:
pd->refcnt--;
out:
VPRINTK("pktcdvd: failed open (%d)\n", ret);
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
return ret;
}
@@ -2060,14 +2061,14 @@ static int pkt_close(struct inode *inode, struct file *file)
struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data;
int ret = 0;
- down(&ctl_mutex);
+ mutex_lock(&ctl_mutex);
pd->refcnt--;
BUG_ON(pd->refcnt < 0);
if (pd->refcnt == 0) {
int flush = test_bit(PACKET_WRITABLE, &pd->flags);
pkt_release_dev(pd, flush);
}
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
return ret;
}
@@ -2596,21 +2597,21 @@ static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cm
case PKT_CTRL_CMD_SETUP:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- down(&ctl_mutex);
+ mutex_lock(&ctl_mutex);
ret = pkt_setup_dev(&ctrl_cmd);
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
break;
case PKT_CTRL_CMD_TEARDOWN:
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
- down(&ctl_mutex);
+ mutex_lock(&ctl_mutex);
ret = pkt_remove_dev(&ctrl_cmd);
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
break;
case PKT_CTRL_CMD_STATUS:
- down(&ctl_mutex);
+ mutex_lock(&ctl_mutex);
pkt_get_status(&ctrl_cmd);
- up(&ctl_mutex);
+ mutex_unlock(&ctl_mutex);
break;
default:
return -ENOTTY;
@@ -2656,7 +2657,7 @@ static int __init pkt_init(void)
goto out;
}
- init_MUTEX(&ctl_mutex);
+ mutex_init(&ctl_mutex);
pkt_proc = proc_mkdir("pktcdvd", proc_root_driver);
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index ffd6abd6d5a..940bfd7951e 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -186,7 +186,8 @@ static int ramdisk_writepages(struct address_space *mapping,
*/
static int ramdisk_set_page_dirty(struct page *page)
{
- SetPageDirty(page);
+ if (!TestSetPageDirty(page))
+ return 1;
return 0;
}
@@ -310,12 +311,12 @@ static int rd_ioctl(struct inode *inode, struct file *file,
* cache
*/
error = -EBUSY;
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
if (bdev->bd_openers <= 2) {
truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
error = 0;
}
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return error;
}
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index 879bbc26ce9..a59876a0bfa 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -407,7 +407,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
ENSURE(get_mcn, CDC_MCN);
ENSURE(reset, CDC_RESET);
ENSURE(audio_ioctl, CDC_PLAY_AUDIO);
- ENSURE(dev_ioctl, CDC_IOCTLS);
ENSURE(generic_packet, CDC_GENERIC_PACKET);
cdi->mc_flags = 0;
cdo->n_minors = 0;
@@ -2196,395 +2195,586 @@ retry:
return cdrom_read_cdda_old(cdi, ubuf, lba, nframes);
}
-/* Just about every imaginable ioctl is supported in the Uniform layer
- * these days. ATAPI / SCSI specific code now mainly resides in
- * mmc_ioct().
- */
-int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
- struct inode *ip, unsigned int cmd, unsigned long arg)
+static int cdrom_ioctl_multisession(struct cdrom_device_info *cdi,
+ void __user *argp)
{
- struct cdrom_device_ops *cdo = cdi->ops;
+ struct cdrom_multisession ms_info;
+ u8 requested_format;
int ret;
- /* Try the generic SCSI command ioctl's first.. */
- ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, (void __user *)arg);
- if (ret != -ENOTTY)
+ cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n");
+
+ if (!(cdi->ops->capability & CDC_MULTI_SESSION))
+ return -ENOSYS;
+
+ if (copy_from_user(&ms_info, argp, sizeof(ms_info)))
+ return -EFAULT;
+
+ requested_format = ms_info.addr_format;
+ if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
+ return -EINVAL;
+ ms_info.addr_format = CDROM_LBA;
+
+ ret = cdi->ops->get_last_session(cdi, &ms_info);
+ if (ret)
return ret;
- /* the first few commands do not deal with audio drive_info, but
- only with routines in cdrom device operations. */
- switch (cmd) {
- case CDROMMULTISESSION: {
- struct cdrom_multisession ms_info;
- u_char requested_format;
- cdinfo(CD_DO_IOCTL, "entering CDROMMULTISESSION\n");
- if (!(cdo->capability & CDC_MULTI_SESSION))
- return -ENOSYS;
- IOCTL_IN(arg, struct cdrom_multisession, ms_info);
- requested_format = ms_info.addr_format;
- if (!((requested_format == CDROM_MSF) ||
- (requested_format == CDROM_LBA)))
- return -EINVAL;
- ms_info.addr_format = CDROM_LBA;
- if ((ret=cdo->get_last_session(cdi, &ms_info)))
+ sanitize_format(&ms_info.addr, &ms_info.addr_format, requested_format);
+
+ if (copy_to_user(argp, &ms_info, sizeof(ms_info)))
+ return -EFAULT;
+
+ cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n");
+ return 0;
+}
+
+static int cdrom_ioctl_eject(struct cdrom_device_info *cdi)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n");
+
+ if (!CDROM_CAN(CDC_OPEN_TRAY))
+ return -ENOSYS;
+ if (cdi->use_count != 1 || keeplocked)
+ return -EBUSY;
+ if (CDROM_CAN(CDC_LOCK)) {
+ int ret = cdi->ops->lock_door(cdi, 0);
+ if (ret)
return ret;
- sanitize_format(&ms_info.addr, &ms_info.addr_format,
- requested_format);
- IOCTL_OUT(arg, struct cdrom_multisession, ms_info);
- cdinfo(CD_DO_IOCTL, "CDROMMULTISESSION successful\n");
- return 0;
- }
+ }
- case CDROMEJECT: {
- cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n");
- if (!CDROM_CAN(CDC_OPEN_TRAY))
- return -ENOSYS;
- if (cdi->use_count != 1 || keeplocked)
- return -EBUSY;
- if (CDROM_CAN(CDC_LOCK))
- if ((ret=cdo->lock_door(cdi, 0)))
- return ret;
+ return cdi->ops->tray_move(cdi, 1);
+}
- return cdo->tray_move(cdi, 1);
- }
+static int cdrom_ioctl_closetray(struct cdrom_device_info *cdi)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n");
- case CDROMCLOSETRAY: {
- cdinfo(CD_DO_IOCTL, "entering CDROMCLOSETRAY\n");
- if (!CDROM_CAN(CDC_CLOSE_TRAY))
- return -ENOSYS;
- return cdo->tray_move(cdi, 0);
- }
+ if (!CDROM_CAN(CDC_CLOSE_TRAY))
+ return -ENOSYS;
+ return cdi->ops->tray_move(cdi, 0);
+}
- case CDROMEJECT_SW: {
- cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n");
- if (!CDROM_CAN(CDC_OPEN_TRAY))
- return -ENOSYS;
- if (keeplocked)
- return -EBUSY;
- cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT);
- if (arg)
- cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT;
- return 0;
- }
+static int cdrom_ioctl_eject_sw(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROMEJECT_SW\n");
- case CDROM_MEDIA_CHANGED: {
- struct cdrom_changer_info *info;
- int changed;
+ if (!CDROM_CAN(CDC_OPEN_TRAY))
+ return -ENOSYS;
+ if (keeplocked)
+ return -EBUSY;
- cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n");
- if (!CDROM_CAN(CDC_MEDIA_CHANGED))
- return -ENOSYS;
+ cdi->options &= ~(CDO_AUTO_CLOSE | CDO_AUTO_EJECT);
+ if (arg)
+ cdi->options |= CDO_AUTO_CLOSE | CDO_AUTO_EJECT;
+ return 0;
+}
- /* cannot select disc or select current disc */
- if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT)
- return media_changed(cdi, 1);
+static int cdrom_ioctl_media_changed(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ struct cdrom_changer_info *info;
+ int ret;
- if ((unsigned int)arg >= cdi->capacity)
- return -EINVAL;
+ cdinfo(CD_DO_IOCTL, "entering CDROM_MEDIA_CHANGED\n");
- info = kmalloc(sizeof(*info), GFP_KERNEL);
- if (!info)
- return -ENOMEM;
+ if (!CDROM_CAN(CDC_MEDIA_CHANGED))
+ return -ENOSYS;
- if ((ret = cdrom_read_mech_status(cdi, info))) {
- kfree(info);
- return ret;
- }
+ /* cannot select disc or select current disc */
+ if (!CDROM_CAN(CDC_SELECT_DISC) || arg == CDSL_CURRENT)
+ return media_changed(cdi, 1);
- changed = info->slots[arg].change;
- kfree(info);
- return changed;
- }
+ if ((unsigned int)arg >= cdi->capacity)
+ return -EINVAL;
- case CDROM_SET_OPTIONS: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n");
- /* options need to be in sync with capability. too late for
- that, so we have to check each one separately... */
- switch (arg) {
- case CDO_USE_FFLAGS:
- case CDO_CHECK_TYPE:
- break;
- case CDO_LOCK:
- if (!CDROM_CAN(CDC_LOCK))
- return -ENOSYS;
- break;
- case 0:
- return cdi->options;
- /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */
- default:
- if (!CDROM_CAN(arg))
- return -ENOSYS;
- }
- cdi->options |= (int) arg;
- return cdi->options;
- }
+ info = kmalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
- case CDROM_CLEAR_OPTIONS: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n");
- cdi->options &= ~(int) arg;
- return cdi->options;
- }
+ ret = cdrom_read_mech_status(cdi, info);
+ if (!ret)
+ ret = info->slots[arg].change;
+ kfree(info);
+ return ret;
+}
- case CDROM_SELECT_SPEED: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n");
- if (!CDROM_CAN(CDC_SELECT_SPEED))
- return -ENOSYS;
- return cdo->select_speed(cdi, arg);
- }
+static int cdrom_ioctl_set_options(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_SET_OPTIONS\n");
- case CDROM_SELECT_DISC: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n");
- if (!CDROM_CAN(CDC_SELECT_DISC))
+ /*
+ * Options need to be in sync with capability.
+ * Too late for that, so we have to check each one separately.
+ */
+ switch (arg) {
+ case CDO_USE_FFLAGS:
+ case CDO_CHECK_TYPE:
+ break;
+ case CDO_LOCK:
+ if (!CDROM_CAN(CDC_LOCK))
+ return -ENOSYS;
+ break;
+ case 0:
+ return cdi->options;
+ /* default is basically CDO_[AUTO_CLOSE|AUTO_EJECT] */
+ default:
+ if (!CDROM_CAN(arg))
return -ENOSYS;
+ }
+ cdi->options |= (int) arg;
+ return cdi->options;
+}
- if ((arg != CDSL_CURRENT) && (arg != CDSL_NONE))
- if ((int)arg >= cdi->capacity)
- return -EINVAL;
-
- /* cdo->select_disc is a hook to allow a driver-specific
- * way of seleting disc. However, since there is no
- * equiv hook for cdrom_slot_status this may not
- * actually be useful...
- */
- if (cdo->select_disc != NULL)
- return cdo->select_disc(cdi, arg);
-
- /* no driver specific select_disc(), call our own */
- cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n");
- return cdrom_select_disc(cdi, arg);
- }
+static int cdrom_ioctl_clear_options(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_CLEAR_OPTIONS\n");
- case CDROMRESET: {
- if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
- cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
- if (!CDROM_CAN(CDC_RESET))
- return -ENOSYS;
- invalidate_bdev(ip->i_bdev, 0);
- return cdo->reset(cdi);
- }
+ cdi->options &= ~(int) arg;
+ return cdi->options;
+}
- case CDROM_LOCKDOOR: {
- cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl");
- if (!CDROM_CAN(CDC_LOCK))
- return -EDRIVE_CANT_DO_THIS;
- keeplocked = arg ? 1 : 0;
- /* don't unlock the door on multiple opens,but allow root
- * to do so */
- if ((cdi->use_count != 1) && !arg && !capable(CAP_SYS_ADMIN))
- return -EBUSY;
- return cdo->lock_door(cdi, arg);
- }
+static int cdrom_ioctl_select_speed(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_SPEED\n");
- case CDROM_DEBUG: {
- if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
- cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis");
- debug = arg ? 1 : 0;
- return debug;
- }
+ if (!CDROM_CAN(CDC_SELECT_SPEED))
+ return -ENOSYS;
+ return cdi->ops->select_speed(cdi, arg);
+}
- case CDROM_GET_CAPABILITY: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n");
- return (cdo->capability & ~cdi->mask);
- }
+static int cdrom_ioctl_select_disc(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_SELECT_DISC\n");
+
+ if (!CDROM_CAN(CDC_SELECT_DISC))
+ return -ENOSYS;
+
+ if (arg != CDSL_CURRENT && arg != CDSL_NONE) {
+ if ((int)arg >= cdi->capacity)
+ return -EINVAL;
+ }
+
+ /*
+ * ->select_disc is a hook to allow a driver-specific way of
+ * seleting disc. However, since there is no equivalent hook for
+ * cdrom_slot_status this may not actually be useful...
+ */
+ if (cdi->ops->select_disc)
+ return cdi->ops->select_disc(cdi, arg);
+
+ cdinfo(CD_CHANGER, "Using generic cdrom_select_disc()\n");
+ return cdrom_select_disc(cdi, arg);
+}
+
+static int cdrom_ioctl_reset(struct cdrom_device_info *cdi,
+ struct block_device *bdev)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_RESET\n");
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
+ if (!CDROM_CAN(CDC_RESET))
+ return -ENOSYS;
+ invalidate_bdev(bdev, 0);
+ return cdi->ops->reset(cdi);
+}
+
+static int cdrom_ioctl_lock_door(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "%socking door.\n", arg ? "L" : "Unl");
+
+ if (!CDROM_CAN(CDC_LOCK))
+ return -EDRIVE_CANT_DO_THIS;
+
+ keeplocked = arg ? 1 : 0;
+
+ /*
+ * Don't unlock the door on multiple opens by default, but allow
+ * root to do so.
+ */
+ if (cdi->use_count != 1 && !arg && !capable(CAP_SYS_ADMIN))
+ return -EBUSY;
+ return cdi->ops->lock_door(cdi, arg);
+}
+
+static int cdrom_ioctl_debug(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "%sabling debug.\n", arg ? "En" : "Dis");
+
+ if (!capable(CAP_SYS_ADMIN))
+ return -EACCES;
+ debug = arg ? 1 : 0;
+ return debug;
+}
-/* The following function is implemented, although very few audio
+static int cdrom_ioctl_get_capability(struct cdrom_device_info *cdi)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_GET_CAPABILITY\n");
+ return (cdi->ops->capability & ~cdi->mask);
+}
+
+/*
+ * The following function is implemented, although very few audio
* discs give Universal Product Code information, which should just be
* the Medium Catalog Number on the box. Note, that the way the code
* is written on the CD is /not/ uniform across all discs!
*/
- case CDROM_GET_MCN: {
- struct cdrom_mcn mcn;
- cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n");
- if (!(cdo->capability & CDC_MCN))
- return -ENOSYS;
- if ((ret=cdo->get_mcn(cdi, &mcn)))
- return ret;
- IOCTL_OUT(arg, struct cdrom_mcn, mcn);
- cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n");
- return 0;
- }
+static int cdrom_ioctl_get_mcn(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_mcn mcn;
+ int ret;
- case CDROM_DRIVE_STATUS: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n");
- if (!(cdo->capability & CDC_DRIVE_STATUS))
- return -ENOSYS;
- if (!CDROM_CAN(CDC_SELECT_DISC))
- return cdo->drive_status(cdi, CDSL_CURRENT);
- if ((arg == CDSL_CURRENT) || (arg == CDSL_NONE))
- return cdo->drive_status(cdi, CDSL_CURRENT);
- if (((int)arg >= cdi->capacity))
- return -EINVAL;
- return cdrom_slot_status(cdi, arg);
- }
+ cdinfo(CD_DO_IOCTL, "entering CDROM_GET_MCN\n");
- /* Ok, this is where problems start. The current interface for the
- CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption
- that CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly,
- while this is often the case, it is also very common for CDs to
- have some tracks with data, and some tracks with audio. Just
- because I feel like it, I declare the following to be the best
- way to cope. If the CD has ANY data tracks on it, it will be
- returned as a data CD. If it has any XA tracks, I will return
- it as that. Now I could simplify this interface by combining these
- returns with the above, but this more clearly demonstrates
- the problem with the current interface. Too bad this wasn't
- designed to use bitmasks... -Erik
-
- Well, now we have the option CDS_MIXED: a mixed-type CD.
- User level programmers might feel the ioctl is not very useful.
- ---david
- */
- case CDROM_DISC_STATUS: {
- tracktype tracks;
- cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n");
- cdrom_count_tracks(cdi, &tracks);
- if (tracks.error)
- return(tracks.error);
-
- /* Policy mode on */
- if (tracks.audio > 0) {
- if (tracks.data==0 && tracks.cdi==0 && tracks.xa==0)
- return CDS_AUDIO;
- else
- return CDS_MIXED;
- }
- if (tracks.cdi > 0) return CDS_XA_2_2;
- if (tracks.xa > 0) return CDS_XA_2_1;
- if (tracks.data > 0) return CDS_DATA_1;
- /* Policy mode off */
+ if (!(cdi->ops->capability & CDC_MCN))
+ return -ENOSYS;
+ ret = cdi->ops->get_mcn(cdi, &mcn);
+ if (ret)
+ return ret;
- cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n");
- return CDS_NO_INFO;
- }
+ if (copy_to_user(argp, &mcn, sizeof(mcn)))
+ return -EFAULT;
+ cdinfo(CD_DO_IOCTL, "CDROM_GET_MCN successful\n");
+ return 0;
+}
- case CDROM_CHANGER_NSLOTS: {
- cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n");
- return cdi->capacity;
- }
+static int cdrom_ioctl_drive_status(struct cdrom_device_info *cdi,
+ unsigned long arg)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_DRIVE_STATUS\n");
+
+ if (!(cdi->ops->capability & CDC_DRIVE_STATUS))
+ return -ENOSYS;
+ if (!CDROM_CAN(CDC_SELECT_DISC) ||
+ (arg == CDSL_CURRENT || arg == CDSL_NONE))
+ return cdi->ops->drive_status(cdi, CDSL_CURRENT);
+ if (((int)arg >= cdi->capacity))
+ return -EINVAL;
+ return cdrom_slot_status(cdi, arg);
+}
+
+/*
+ * Ok, this is where problems start. The current interface for the
+ * CDROM_DISC_STATUS ioctl is flawed. It makes the false assumption that
+ * CDs are all CDS_DATA_1 or all CDS_AUDIO, etc. Unfortunatly, while this
+ * is often the case, it is also very common for CDs to have some tracks
+ * with data, and some tracks with audio. Just because I feel like it,
+ * I declare the following to be the best way to cope. If the CD has ANY
+ * data tracks on it, it will be returned as a data CD. If it has any XA
+ * tracks, I will return it as that. Now I could simplify this interface
+ * by combining these returns with the above, but this more clearly
+ * demonstrates the problem with the current interface. Too bad this
+ * wasn't designed to use bitmasks... -Erik
+ *
+ * Well, now we have the option CDS_MIXED: a mixed-type CD.
+ * User level programmers might feel the ioctl is not very useful.
+ * ---david
+ */
+static int cdrom_ioctl_disc_status(struct cdrom_device_info *cdi)
+{
+ tracktype tracks;
+
+ cdinfo(CD_DO_IOCTL, "entering CDROM_DISC_STATUS\n");
+
+ cdrom_count_tracks(cdi, &tracks);
+ if (tracks.error)
+ return tracks.error;
+
+ /* Policy mode on */
+ if (tracks.audio > 0) {
+ if (!tracks.data && !tracks.cdi && !tracks.xa)
+ return CDS_AUDIO;
+ else
+ return CDS_MIXED;
}
- /* use the ioctls that are implemented through the generic_packet()
- interface. this may look at bit funny, but if -ENOTTY is
- returned that particular ioctl is not implemented and we
- let it go through the device specific ones. */
+ if (tracks.cdi > 0)
+ return CDS_XA_2_2;
+ if (tracks.xa > 0)
+ return CDS_XA_2_1;
+ if (tracks.data > 0)
+ return CDS_DATA_1;
+ /* Policy mode off */
+
+ cdinfo(CD_WARNING,"This disc doesn't have any tracks I recognize!\n");
+ return CDS_NO_INFO;
+}
+
+static int cdrom_ioctl_changer_nslots(struct cdrom_device_info *cdi)
+{
+ cdinfo(CD_DO_IOCTL, "entering CDROM_CHANGER_NSLOTS\n");
+ return cdi->capacity;
+}
+
+static int cdrom_ioctl_get_subchnl(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_subchnl q;
+ u8 requested, back;
+ int ret;
+
+ /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&q, argp, sizeof(q)))
+ return -EFAULT;
+
+ requested = q.cdsc_format;
+ if (requested != CDROM_MSF && requested != CDROM_LBA)
+ return -EINVAL;
+ q.cdsc_format = CDROM_MSF;
+
+ ret = cdi->ops->audio_ioctl(cdi, CDROMSUBCHNL, &q);
+ if (ret)
+ return ret;
+
+ back = q.cdsc_format; /* local copy */
+ sanitize_format(&q.cdsc_absaddr, &back, requested);
+ sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested);
+
+ if (copy_to_user(argp, &q, sizeof(q)))
+ return -EFAULT;
+ /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */
+ return 0;
+}
+
+static int cdrom_ioctl_read_tochdr(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_tochdr header;
+ int ret;
+
+ /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&header, argp, sizeof(header)))
+ return -EFAULT;
+
+ ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCHDR, &header);
+ if (ret)
+ return ret;
+
+ if (copy_to_user(argp, &header, sizeof(header)))
+ return -EFAULT;
+ /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */
+ return 0;
+}
+
+static int cdrom_ioctl_read_tocentry(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_tocentry entry;
+ u8 requested_format;
+ int ret;
+
+ /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&entry, argp, sizeof(entry)))
+ return -EFAULT;
+
+ requested_format = entry.cdte_format;
+ if (requested_format != CDROM_MSF && requested_format != CDROM_LBA)
+ return -EINVAL;
+ /* make interface to low-level uniform */
+ entry.cdte_format = CDROM_MSF;
+ ret = cdi->ops->audio_ioctl(cdi, CDROMREADTOCENTRY, &entry);
+ if (ret)
+ return ret;
+ sanitize_format(&entry.cdte_addr, &entry.cdte_format, requested_format);
+
+ if (copy_to_user(argp, &entry, sizeof(entry)))
+ return -EFAULT;
+ /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */
+ return 0;
+}
+
+static int cdrom_ioctl_play_msf(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_msf msf;
+
+ cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n");
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&msf, argp, sizeof(msf)))
+ return -EFAULT;
+ return cdi->ops->audio_ioctl(cdi, CDROMPLAYMSF, &msf);
+}
+
+static int cdrom_ioctl_play_trkind(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_ti ti;
+ int ret;
+
+ cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n");
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&ti, argp, sizeof(ti)))
+ return -EFAULT;
+
+ ret = check_for_audio_disc(cdi, cdi->ops);
+ if (ret)
+ return ret;
+ return cdi->ops->audio_ioctl(cdi, CDROMPLAYTRKIND, &ti);
+}
+static int cdrom_ioctl_volctrl(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_volctrl volume;
+
+ cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n");
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ if (copy_from_user(&volume, argp, sizeof(volume)))
+ return -EFAULT;
+ return cdi->ops->audio_ioctl(cdi, CDROMVOLCTRL, &volume);
+}
+
+static int cdrom_ioctl_volread(struct cdrom_device_info *cdi,
+ void __user *argp)
+{
+ struct cdrom_volctrl volume;
+ int ret;
+
+ cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n");
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+
+ ret = cdi->ops->audio_ioctl(cdi, CDROMVOLREAD, &volume);
+ if (ret)
+ return ret;
+
+ if (copy_to_user(argp, &volume, sizeof(volume)))
+ return -EFAULT;
+ return 0;
+}
+
+static int cdrom_ioctl_audioctl(struct cdrom_device_info *cdi,
+ unsigned int cmd)
+{
+ int ret;
+
+ cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n");
+
+ if (!CDROM_CAN(CDC_PLAY_AUDIO))
+ return -ENOSYS;
+ ret = check_for_audio_disc(cdi, cdi->ops);
+ if (ret)
+ return ret;
+ return cdi->ops->audio_ioctl(cdi, cmd, NULL);
+}
+
+/*
+ * Just about every imaginable ioctl is supported in the Uniform layer
+ * these days.
+ * ATAPI / SCSI specific code now mainly resides in mmc_ioctl().
+ */
+int cdrom_ioctl(struct file * file, struct cdrom_device_info *cdi,
+ struct inode *ip, unsigned int cmd, unsigned long arg)
+{
+ void __user *argp = (void __user *)arg;
+ int ret;
+
+ /*
+ * Try the generic SCSI command ioctl's first.
+ */
+ ret = scsi_cmd_ioctl(file, ip->i_bdev->bd_disk, cmd, argp);
+ if (ret != -ENOTTY)
+ return ret;
+
+ switch (cmd) {
+ case CDROMMULTISESSION:
+ return cdrom_ioctl_multisession(cdi, argp);
+ case CDROMEJECT:
+ return cdrom_ioctl_eject(cdi);
+ case CDROMCLOSETRAY:
+ return cdrom_ioctl_closetray(cdi);
+ case CDROMEJECT_SW:
+ return cdrom_ioctl_eject_sw(cdi, arg);
+ case CDROM_MEDIA_CHANGED:
+ return cdrom_ioctl_media_changed(cdi, arg);
+ case CDROM_SET_OPTIONS:
+ return cdrom_ioctl_set_options(cdi, arg);
+ case CDROM_CLEAR_OPTIONS:
+ return cdrom_ioctl_clear_options(cdi, arg);
+ case CDROM_SELECT_SPEED:
+ return cdrom_ioctl_select_speed(cdi, arg);
+ case CDROM_SELECT_DISC:
+ return cdrom_ioctl_select_disc(cdi, arg);
+ case CDROMRESET:
+ return cdrom_ioctl_reset(cdi, ip->i_bdev);
+ case CDROM_LOCKDOOR:
+ return cdrom_ioctl_lock_door(cdi, arg);
+ case CDROM_DEBUG:
+ return cdrom_ioctl_debug(cdi, arg);
+ case CDROM_GET_CAPABILITY:
+ return cdrom_ioctl_get_capability(cdi);
+ case CDROM_GET_MCN:
+ return cdrom_ioctl_get_mcn(cdi, argp);
+ case CDROM_DRIVE_STATUS:
+ return cdrom_ioctl_drive_status(cdi, arg);
+ case CDROM_DISC_STATUS:
+ return cdrom_ioctl_disc_status(cdi);
+ case CDROM_CHANGER_NSLOTS:
+ return cdrom_ioctl_changer_nslots(cdi);
+ }
+
+ /*
+ * Use the ioctls that are implemented through the generic_packet()
+ * interface. this may look at bit funny, but if -ENOTTY is
+ * returned that particular ioctl is not implemented and we
+ * let it go through the device specific ones.
+ */
if (CDROM_CAN(CDC_GENERIC_PACKET)) {
ret = mmc_ioctl(cdi, cmd, arg);
- if (ret != -ENOTTY) {
+ if (ret != -ENOTTY)
return ret;
- }
}
- /* note: most of the cdinfo() calls are commented out here,
- because they fill up the sys log when CD players poll
- the drive. */
+ /*
+ * Note: most of the cdinfo() calls are commented out here,
+ * because they fill up the sys log when CD players poll
+ * the drive.
+ */
switch (cmd) {
- case CDROMSUBCHNL: {
- struct cdrom_subchnl q;
- u_char requested, back;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- /* cdinfo(CD_DO_IOCTL,"entering CDROMSUBCHNL\n");*/
- IOCTL_IN(arg, struct cdrom_subchnl, q);
- requested = q.cdsc_format;
- if (!((requested == CDROM_MSF) ||
- (requested == CDROM_LBA)))
- return -EINVAL;
- q.cdsc_format = CDROM_MSF;
- if ((ret=cdo->audio_ioctl(cdi, cmd, &q)))
- return ret;
- back = q.cdsc_format; /* local copy */
- sanitize_format(&q.cdsc_absaddr, &back, requested);
- sanitize_format(&q.cdsc_reladdr, &q.cdsc_format, requested);
- IOCTL_OUT(arg, struct cdrom_subchnl, q);
- /* cdinfo(CD_DO_IOCTL, "CDROMSUBCHNL successful\n"); */
- return 0;
- }
- case CDROMREADTOCHDR: {
- struct cdrom_tochdr header;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCHDR\n"); */
- IOCTL_IN(arg, struct cdrom_tochdr, header);
- if ((ret=cdo->audio_ioctl(cdi, cmd, &header)))
- return ret;
- IOCTL_OUT(arg, struct cdrom_tochdr, header);
- /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCHDR successful\n"); */
- return 0;
- }
- case CDROMREADTOCENTRY: {
- struct cdrom_tocentry entry;
- u_char requested_format;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- /* cdinfo(CD_DO_IOCTL, "entering CDROMREADTOCENTRY\n"); */
- IOCTL_IN(arg, struct cdrom_tocentry, entry);
- requested_format = entry.cdte_format;
- if (!((requested_format == CDROM_MSF) ||
- (requested_format == CDROM_LBA)))
- return -EINVAL;
- /* make interface to low-level uniform */
- entry.cdte_format = CDROM_MSF;
- if ((ret=cdo->audio_ioctl(cdi, cmd, &entry)))
- return ret;
- sanitize_format(&entry.cdte_addr,
- &entry.cdte_format, requested_format);
- IOCTL_OUT(arg, struct cdrom_tocentry, entry);
- /* cdinfo(CD_DO_IOCTL, "CDROMREADTOCENTRY successful\n"); */
- return 0;
- }
- case CDROMPLAYMSF: {
- struct cdrom_msf msf;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- cdinfo(CD_DO_IOCTL, "entering CDROMPLAYMSF\n");
- IOCTL_IN(arg, struct cdrom_msf, msf);
- return cdo->audio_ioctl(cdi, cmd, &msf);
- }
- case CDROMPLAYTRKIND: {
- struct cdrom_ti ti;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- cdinfo(CD_DO_IOCTL, "entering CDROMPLAYTRKIND\n");
- IOCTL_IN(arg, struct cdrom_ti, ti);
- CHECKAUDIO;
- return cdo->audio_ioctl(cdi, cmd, &ti);
- }
- case CDROMVOLCTRL: {
- struct cdrom_volctrl volume;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- cdinfo(CD_DO_IOCTL, "entering CDROMVOLCTRL\n");
- IOCTL_IN(arg, struct cdrom_volctrl, volume);
- return cdo->audio_ioctl(cdi, cmd, &volume);
- }
- case CDROMVOLREAD: {
- struct cdrom_volctrl volume;
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- cdinfo(CD_DO_IOCTL, "entering CDROMVOLREAD\n");
- if ((ret=cdo->audio_ioctl(cdi, cmd, &volume)))
- return ret;
- IOCTL_OUT(arg, struct cdrom_volctrl, volume);
- return 0;
- }
+ case CDROMSUBCHNL:
+ return cdrom_ioctl_get_subchnl(cdi, argp);
+ case CDROMREADTOCHDR:
+ return cdrom_ioctl_read_tochdr(cdi, argp);
+ case CDROMREADTOCENTRY:
+ return cdrom_ioctl_read_tocentry(cdi, argp);
+ case CDROMPLAYMSF:
+ return cdrom_ioctl_play_msf(cdi, argp);
+ case CDROMPLAYTRKIND:
+ return cdrom_ioctl_play_trkind(cdi, argp);
+ case CDROMVOLCTRL:
+ return cdrom_ioctl_volctrl(cdi, argp);
+ case CDROMVOLREAD:
+ return cdrom_ioctl_volread(cdi, argp);
case CDROMSTART:
case CDROMSTOP:
case CDROMPAUSE:
- case CDROMRESUME: {
- if (!CDROM_CAN(CDC_PLAY_AUDIO))
- return -ENOSYS;
- cdinfo(CD_DO_IOCTL, "doing audio ioctl (start/stop/pause/resume)\n");
- CHECKAUDIO;
- return cdo->audio_ioctl(cdi, cmd, NULL);
- }
- } /* switch */
+ case CDROMRESUME:
+ return cdrom_ioctl_audioctl(cdi, cmd);
+ }
- /* do the device specific ioctls */
- if (CDROM_CAN(CDC_IOCTLS))
- return cdo->dev_ioctl(cdi, cmd, arg);
-
return -ENOSYS;
}
diff --git a/drivers/cdrom/cdu31a.c b/drivers/cdrom/cdu31a.c
index 378e88d2075..72ffd64e8b1 100644
--- a/drivers/cdrom/cdu31a.c
+++ b/drivers/cdrom/cdu31a.c
@@ -2668,7 +2668,7 @@ static int scd_audio_ioctl(struct cdrom_device_info *cdi,
return retval;
}
-static int scd_dev_ioctl(struct cdrom_device_info *cdi,
+static int scd_read_audio(struct cdrom_device_info *cdi,
unsigned int cmd, unsigned long arg)
{
void __user *argp = (void __user *)arg;
@@ -2894,11 +2894,10 @@ static struct cdrom_device_ops scd_dops = {
.get_mcn = scd_get_mcn,
.reset = scd_reset,
.audio_ioctl = scd_audio_ioctl,
- .dev_ioctl = scd_dev_ioctl,
.capability = CDC_OPEN_TRAY | CDC_CLOSE_TRAY | CDC_LOCK |
CDC_SELECT_SPEED | CDC_MULTI_SESSION |
CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO |
- CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS,
+ CDC_RESET | CDC_DRIVE_STATUS,
.n_minors = 1,
};
@@ -2936,6 +2935,9 @@ static int scd_block_ioctl(struct inode *inode, struct file *file,
case CDROMCLOSETRAY:
retval = scd_tray_move(&scd_info, 0);
break;
+ case CDROMREADAUDIO:
+ retval = scd_read_audio(&scd_info, CDROMREADAUDIO, arg);
+ break;
default:
retval = cdrom_ioctl(file, &scd_info, inode, cmd, arg);
}
diff --git a/drivers/cdrom/cm206.c b/drivers/cdrom/cm206.c
index ce127f7ec0f..f43a988dd41 100644
--- a/drivers/cdrom/cm206.c
+++ b/drivers/cdrom/cm206.c
@@ -218,12 +218,12 @@ static int cm206_base = CM206_BASE;
static int cm206_irq = CM206_IRQ;
#ifdef MODULE
static int cm206[2] = { 0, 0 }; /* for compatible `insmod' parameter passing */
+module_param_array(cm206, int, NULL, 0); /* base,irq or irq,base */
#endif
-MODULE_PARM(cm206_base, "i"); /* base */
-MODULE_PARM(cm206_irq, "i"); /* irq */
-MODULE_PARM(cm206, "1-2i"); /* base,irq or irq,base */
-MODULE_PARM(auto_probe, "i"); /* auto probe base and irq */
+module_param(cm206_base, int, 0); /* base */
+module_param(cm206_irq, int, 0); /* irq */
+module_param(auto_probe, bool, 0); /* auto probe base and irq */
MODULE_LICENSE("GPL");
#define POLLOOP 100 /* milliseconds */
@@ -1157,32 +1157,6 @@ static int cm206_audio_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
}
}
-/* Ioctl. These ioctls are specific to the cm206 driver. I have made
- some driver statistics accessible through ioctl calls.
- */
-
-static int cm206_ioctl(struct cdrom_device_info *cdi, unsigned int cmd,
- unsigned long arg)
-{
- switch (cmd) {
-#ifdef STATISTICS
- case CM206CTL_GET_STAT:
- if (arg >= NR_STATS)
- return -EINVAL;
- else
- return cd->stats[arg];
- case CM206CTL_GET_LAST_STAT:
- if (arg >= NR_STATS)
- return -EINVAL;
- else
- return cd->last_stat[arg];
-#endif
- default:
- debug(("Unknown ioctl call 0x%x\n", cmd));
- return -EINVAL;
- }
-}
-
static int cm206_media_changed(struct cdrom_device_info *cdi, int disc_nr)
{
if (cd != NULL) {
@@ -1321,11 +1295,10 @@ static struct cdrom_device_ops cm206_dops = {
.get_mcn = cm206_get_upc,
.reset = cm206_reset,
.audio_ioctl = cm206_audio_ioctl,
- .dev_ioctl = cm206_ioctl,
.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
CDC_MCN | CDC_PLAY_AUDIO | CDC_SELECT_SPEED |
- CDC_IOCTLS | CDC_DRIVE_STATUS,
+ CDC_DRIVE_STATUS,
.n_minors = 1,
};
@@ -1350,6 +1323,21 @@ static int cm206_block_release(struct inode *inode, struct file *file)
static int cm206_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
+ switch (cmd) {
+#ifdef STATISTICS
+ case CM206CTL_GET_STAT:
+ if (arg >= NR_STATS)
+ return -EINVAL;
+ return cd->stats[arg];
+ case CM206CTL_GET_LAST_STAT:
+ if (arg >= NR_STATS)
+ return -EINVAL;
+ return cd->last_stat[arg];
+#endif
+ default:
+ break;
+ }
+
return cdrom_ioctl(file, &cm206_info, inode, cmd, arg);
}
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index 466e9c2974b..05c9e865eca 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -464,8 +464,13 @@ static int sbpcd[] =
static __cacheline_aligned DEFINE_SPINLOCK(sbpcd_lock);
static struct request_queue *sbpcd_queue;
-MODULE_PARM(sbpcd, "2i");
-MODULE_PARM(max_drives, "i");
+/* You can only set the first pair, from old MODULE_PARM code. */
+static int sbpcd_set(const char *val, struct kernel_param *kp)
+{
+ get_options((char *)val, 2, (int *)sbpcd);
+ return 0;
+}
+module_param_call(sbpcd, sbpcd_set, NULL, NULL, 0);
#define NUM_PROBE (sizeof(sbpcd) / sizeof(int))
@@ -553,6 +558,7 @@ static unsigned char msgnum;
static char msgbuf[80];
static int max_drives = MAX_DRIVES;
+module_param(max_drives, int, 0);
#ifndef MODULE
static unsigned char setup_done;
static const char *str_sb_l = "soundblaster";
@@ -4160,332 +4166,6 @@ static int sbpcd_get_last_session(struct cdrom_device_info *cdi, struct cdrom_mu
return 0;
}
-/*==========================================================================*/
-/*==========================================================================*/
-/*
- * ioctl support
- */
-static int sbpcd_dev_ioctl(struct cdrom_device_info *cdi, u_int cmd,
- u_long arg)
-{
- struct sbpcd_drive *p = cdi->handle;
- int i;
-
- msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg);
- if (p->drv_id==-1) {
- msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name);
- return (-ENXIO); /* no such drive */
- }
- down(&ioctl_read_sem);
- if (p != current_drive)
- switch_drive(p);
-
- msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd);
- switch (cmd) /* Sun-compatible */
- {
- case DDIOCSDBG: /* DDI Debug */
- if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM);
- i=sbpcd_dbg_ioctl(arg,1);
- RETURN_UP(i);
- case CDROMRESET: /* hard reset the drive */
- msg(DBG_IOC,"ioctl: CDROMRESET entered.\n");
- i=DriveReset();
- current_drive->audio_state=0;
- RETURN_UP(i);
-
- case CDROMREADMODE1:
- msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
-#ifdef SAFE_MIXED
- if (current_drive->has_data>1) RETURN_UP(-EBUSY);
-#endif /* SAFE_MIXED */
- cc_ModeSelect(CD_FRAMESIZE);
- cc_ModeSense();
- current_drive->mode=READ_M1;
- RETURN_UP(0);
-
- case CDROMREADMODE2: /* not usable at the moment */
- msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
-#ifdef SAFE_MIXED
- if (current_drive->has_data>1) RETURN_UP(-EBUSY);
-#endif /* SAFE_MIXED */
- cc_ModeSelect(CD_FRAMESIZE_RAW1);
- cc_ModeSense();
- current_drive->mode=READ_M2;
- RETURN_UP(0);
-
- case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
- msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
- if (current_drive->sbp_audsiz>0)
- vfree(current_drive->aud_buf);
- current_drive->aud_buf=NULL;
- current_drive->sbp_audsiz=arg;
-
- if (current_drive->sbp_audsiz>16)
- {
- current_drive->sbp_audsiz = 0;
- RETURN_UP(current_drive->sbp_audsiz);
- }
-
- if (current_drive->sbp_audsiz>0)
- {
- current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW);
- if (current_drive->aud_buf==NULL)
- {
- msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz);
- current_drive->sbp_audsiz=0;
- }
- else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz);
- }
- RETURN_UP(current_drive->sbp_audsiz);
-
- case CDROMREADAUDIO:
- { /* start of CDROMREADAUDIO */
- int i=0, j=0, frame, block=0;
- u_int try=0;
- u_long timeout;
- u_char *p;
- u_int data_tries = 0;
- u_int data_waits = 0;
- u_int data_retrying = 0;
- int status_tries;
- int error_flag;
-
- msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n");
- if (fam0_drive) RETURN_UP(-EINVAL);
- if (famL_drive) RETURN_UP(-EINVAL);
- if (famV_drive) RETURN_UP(-EINVAL);
- if (famT_drive) RETURN_UP(-EINVAL);
-#ifdef SAFE_MIXED
- if (current_drive->has_data>1) RETURN_UP(-EBUSY);
-#endif /* SAFE_MIXED */
- if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL);
- if (copy_from_user(&read_audio, (void __user *)arg,
- sizeof(struct cdrom_read_audio)))
- RETURN_UP(-EFAULT);
- if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL);
- if (!access_ok(VERIFY_WRITE, read_audio.buf,
- read_audio.nframes*CD_FRAMESIZE_RAW))
- RETURN_UP(-EFAULT);
-
- if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */
- block=msf2lba(&read_audio.addr.msf.minute);
- else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */
- block=read_audio.addr.lba;
- else RETURN_UP(-EINVAL);
-#if 000
- i=cc_SetSpeed(speed_150,0,0);
- if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i);
-#endif
- msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n",
- block, blk2msf(block));
- msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n");
-#if OLD_BUSY
- while (busy_data) sbp_sleep(HZ/10); /* wait a bit */
- busy_audio=1;
-#endif /* OLD_BUSY */
- error_flag=0;
- for (data_tries=5; data_tries>0; data_tries--)
- {
- msg(DBG_AUD,"data_tries=%d ...\n", data_tries);
- current_drive->mode=READ_AU;
- cc_ModeSelect(CD_FRAMESIZE_RAW);
- cc_ModeSense();
- for (status_tries=3; status_tries > 0; status_tries--)
- {
- flags_cmd_out |= f_respo3;
- cc_ReadStatus();
- if (sbp_status() != 0) break;
- if (st_check) cc_ReadError();
- sbp_sleep(1); /* wait a bit, try again */
- }
- if (status_tries == 0)
- {
- msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__);
- continue;
- }
- msg(DBG_AUD,"read_audio: sbp_status: ok.\n");
-
- flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
- if (fam0L_drive)
- {
- flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
- cmd_type=READ_M2;
- drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
- drvcmd[1]=(block>>16)&0x000000ff;
- drvcmd[2]=(block>>8)&0x000000ff;
- drvcmd[3]=block&0x000000ff;
- drvcmd[4]=0;
- drvcmd[5]=read_audio.nframes; /* # of frames */
- drvcmd[6]=0;
- }
- else if (fam1_drive)
- {
- drvcmd[0]=CMD1_READ; /* "read frames", new drives */
- lba2msf(block,&drvcmd[1]); /* msf-bin format required */
- drvcmd[4]=0;
- drvcmd[5]=0;
- drvcmd[6]=read_audio.nframes; /* # of frames */
- }
- else if (fam2_drive)
- {
- drvcmd[0]=CMD2_READ_XA2;
- lba2msf(block,&drvcmd[1]); /* msf-bin format required */
- drvcmd[4]=0;
- drvcmd[5]=read_audio.nframes; /* # of frames */
- drvcmd[6]=0x11; /* raw mode */
- }
- else if (famT_drive) /* CD-55A: not tested yet */
- {
- }
- msg(DBG_AUD,"read_audio: before giving \"read\" command.\n");
- flags_cmd_out=f_putcmd;
- response_count=0;
- i=cmd_out();
- if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i);
- sbp_sleep(0);
- msg(DBG_AUD,"read_audio: after giving \"read\" command.\n");
- for (frame=1;frame<2 && !error_flag; frame++)
- {
- try=maxtim_data;
- for (timeout=jiffies+9*HZ; ; )
- {
- for ( ; try!=0;try--)
- {
- j=inb(CDi_status);
- if (!(j&s_not_data_ready)) break;
- if (!(j&s_not_result_ready)) break;
- if (fam0L_drive) if (j&s_attention) break;
- }
- if (try != 0 || time_after_eq(jiffies, timeout)) break;
- if (data_retrying == 0) data_waits++;
- data_retrying = 1;
- sbp_sleep(1);
- try = 1;
- }
- if (try==0)
- {
- msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n");
- error_flag++;
- break;
- }
- msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n");
- if (j&s_not_data_ready)
- {
- msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n");
- error_flag++;
- break;
- }
- msg(DBG_AUD,"read_audio: before reading data.\n");
- error_flag=0;
- p = current_drive->aud_buf;
- if (sbpro_type==1) OUT(CDo_sel_i_d,1);
- if (do_16bit)
- {
- u_short *p2 = (u_short *) p;
-
- for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
- {
- if ((inb_p(CDi_status)&s_not_data_ready)) continue;
-
- /* get one sample */
- *p2++ = inw_p(CDi_data);
- *p2++ = inw_p(CDi_data);
- }
- } else {
- for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
- {
- if ((inb_p(CDi_status)&s_not_data_ready)) continue;
-
- /* get one sample */
- *p++ = inb_p(CDi_data);
- *p++ = inb_p(CDi_data);
- *p++ = inb_p(CDi_data);
- *p++ = inb_p(CDi_data);
- }
- }
- if (sbpro_type==1) OUT(CDo_sel_i_d,0);
- data_retrying = 0;
- }
- msg(DBG_AUD,"read_audio: after reading data.\n");
- if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
- {
- msg(DBG_AUD,"read_audio: read aborted by drive\n");
-#if 0000
- i=cc_DriveReset(); /* ugly fix to prevent a hang */
-#else
- i=cc_ReadError();
-#endif
- continue;
- }
- if (fam0L_drive)
- {
- i=maxtim_data;
- for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--)
- {
- for ( ;i!=0;i--)
- {
- j=inb(CDi_status);
- if (!(j&s_not_data_ready)) break;
- if (!(j&s_not_result_ready)) break;
- if (j&s_attention) break;
- }
- if (i != 0 || time_after_eq(jiffies, timeout)) break;
- sbp_sleep(0);
- i = 1;
- }
- if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ");
- if (!(j&s_attention))
- {
- msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n");
- i=cc_DriveReset(); /* ugly fix to prevent a hang */
- continue;
- }
- }
- do
- {
- if (fam0L_drive) cc_ReadStatus();
- i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
- if (i<0) { msg(DBG_AUD,
- "read_audio: cc_ReadStatus error after read: %02X\n",
- current_drive->status_bits);
- continue; /* FIXME */
- }
- }
- while ((fam0L_drive)&&(!st_check)&&(!(i&p_success)));
- if (st_check)
- {
- i=cc_ReadError();
- msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i);
- continue;
- }
- if (copy_to_user(read_audio.buf,
- current_drive->aud_buf,
- read_audio.nframes * CD_FRAMESIZE_RAW))
- RETURN_UP(-EFAULT);
- msg(DBG_AUD,"read_audio: copy_to_user done.\n");
- break;
- }
- cc_ModeSelect(CD_FRAMESIZE);
- cc_ModeSense();
- current_drive->mode=READ_M1;
-#if OLD_BUSY
- busy_audio=0;
-#endif /* OLD_BUSY */
- if (data_tries == 0)
- {
- msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__);
- RETURN_UP(-EIO);
- }
- msg(DBG_AUD,"read_audio: successful return.\n");
- RETURN_UP(0);
- } /* end of CDROMREADAUDIO */
-
- default:
- msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
- RETURN_UP(-EINVAL);
- } /* end switch(cmd) */
-}
-
static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
void * arg)
{
@@ -4530,7 +4210,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
default:
RETURN_UP(-EINVAL);
}
-
+
case CDROMRESUME: /* resume paused audio play */
msg(DBG_IOC,"ioctl: CDROMRESUME entered.\n");
/* resume playing audio tracks when a previous PLAY AUDIO call has */
@@ -4544,12 +4224,12 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
if (i<0) RETURN_UP(-EIO);
current_drive->audio_state=audio_playing;
RETURN_UP(0);
-
+
case CDROMPLAYMSF:
msg(DBG_IOC,"ioctl: CDROMPLAYMSF entered.\n");
#ifdef SAFE_MIXED
if (current_drive->has_data>1) RETURN_UP(-EBUSY);
-#endif /* SAFE_MIXED */
+#endif /* SAFE_MIXED */
if (current_drive->audio_state==audio_playing)
{
i=cc_Pause_Resume(1);
@@ -4584,7 +4264,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
msg(DBG_IOC,"ioctl: CDROMPLAYTRKIND entered.\n");
#ifdef SAFE_MIXED
if (current_drive->has_data>1) RETURN_UP(-EBUSY);
-#endif /* SAFE_MIXED */
+#endif /* SAFE_MIXED */
if (current_drive->audio_state==audio_playing)
{
msg(DBG_IOX,"CDROMPLAYTRKIND: already audio_playing.\n");
@@ -4654,13 +4334,13 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
cc_DriveReset();
#endif
RETURN_UP(i);
-
+
case CDROMSTART: /* Spin up the drive */
msg(DBG_IOC,"ioctl: CDROMSTART entered.\n");
cc_SpinUp();
current_drive->audio_state=0;
RETURN_UP(0);
-
+
case CDROMVOLCTRL: /* Volume control */
msg(DBG_IOC,"ioctl: CDROMVOLCTRL entered.\n");
memcpy(&volctrl,(char *) arg,sizeof(volctrl));
@@ -4670,7 +4350,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
current_drive->vol_ctrl1=volctrl.channel1;
i=cc_SetVolume();
RETURN_UP(0);
-
+
case CDROMVOLREAD: /* read Volume settings from drive */
msg(DBG_IOC,"ioctl: CDROMVOLREAD entered.\n");
st=cc_GetVolume();
@@ -4694,7 +4374,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
if (i<0) {
j=cc_ReadError(); /* clear out error status from drive */
current_drive->audio_state=CDROM_AUDIO_NO_STATUS;
- /* get and set the disk state here,
+ /* get and set the disk state here,
probably not the right place, but who cares!
It makes it work properly! --AJK */
if (current_drive->CD_changed==0xFF) {
@@ -4715,8 +4395,8 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
}
}
memcpy(&SC, (void *) arg, sizeof(struct cdrom_subchnl));
- /*
- This virtual crap is very bogus!
+ /*
+ This virtual crap is very bogus!
It doesn't detect when the cd is done playing audio!
Lets do this right with proper hardware register reading!
*/
@@ -4775,7 +4455,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
SC.cdsc_trk,SC.cdsc_ind,
SC.cdsc_absaddr,SC.cdsc_reladdr);
RETURN_UP(0);
-
+
default:
msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
RETURN_UP(-EINVAL);
@@ -4788,7 +4468,7 @@ static int sbpcd_audio_ioctl(struct cdrom_device_info *cdi, u_int cmd,
static void sbp_transfer(struct request *req)
{
long offs;
-
+
while ( (req->nr_sectors > 0) &&
(req->sector/4 >= current_drive->sbp_first_frame) &&
(req->sector/4 <= current_drive->sbp_last_frame) )
@@ -4807,11 +4487,11 @@ static void sbp_transfer(struct request *req)
*
* This is a kludge so we don't need to modify end_request.
* We put the req we take out after INIT_REQUEST in the requests list,
- * so that end_request will discard it.
+ * so that end_request will discard it.
*
* The bug could be present in other block devices, perhaps we
* should modify INIT_REQUEST and end_request instead, and
- * change every block device..
+ * change every block device..
*
* Could be a race here?? Could e.g. a timer interrupt schedule() us?
* If so, we should copy end_request here, and do it right.. (or
@@ -4883,19 +4563,19 @@ static void do_sbpcd_request(request_queue_t * q)
while (busy_audio) sbp_sleep(HZ); /* wait a bit */
busy_data=1;
#endif /* OLD_BUSY */
-
+
if (p->audio_state==audio_playing) goto err_done;
if (p != current_drive)
switch_drive(p);
block = req->sector; /* always numbered as 512-byte-pieces */
nsect = req->nr_sectors; /* always counted as 512-byte-pieces */
-
+
msg(DBG_BSZ,"read sector %d (%d sectors)\n", block, nsect);
#if 0
msg(DBG_MUL,"read LBA %d\n", block/4);
#endif
-
+
sbp_transfer(req);
/* if we satisfied the request from the buffer, we're done. */
if (req->nr_sectors == 0)
@@ -4914,10 +4594,10 @@ static void do_sbpcd_request(request_queue_t * q)
i=prepare(0,0); /* at moment not really a hassle check, but ... */
if (i!=0)
msg(DBG_INF,"\"prepare\" tells error %d -- ignored\n", i);
-#endif /* FUTURE */
-
+#endif /* FUTURE */
+
if (!st_spinning) cc_SpinUp();
-
+
for (data_tries=n_retries; data_tries > 0; data_tries--)
{
for (status_tries=3; status_tries > 0; status_tries--)
@@ -4940,7 +4620,7 @@ static void do_sbpcd_request(request_queue_t * q)
{
#ifdef SAFE_MIXED
current_drive->has_data=2; /* is really a data disk */
-#endif /* SAFE_MIXED */
+#endif /* SAFE_MIXED */
#ifdef DEBUG_GTL
printk(" do_sbpcd_request[%do](%p:%ld+%ld) end 3, Time:%li\n",
xnr, req, req->sector, req->nr_sectors, jiffies);
@@ -4951,7 +4631,7 @@ static void do_sbpcd_request(request_queue_t * q)
goto request_loop;
}
}
-
+
err_done:
#if OLD_BUSY
busy_data=0;
@@ -4976,7 +4656,7 @@ static void sbp_read_cmd(struct request *req)
int i;
int block;
-
+
current_drive->sbp_first_frame=current_drive->sbp_last_frame=-1; /* purge buffer */
current_drive->sbp_current = 0;
block=req->sector/4;
@@ -4993,7 +4673,7 @@ static void sbp_read_cmd(struct request *req)
current_drive->sbp_read_frames=1;
}
}
-
+
flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
clr_cmdbuf();
if (famV_drive)
@@ -5092,7 +4772,7 @@ static int sbp_data(struct request *req)
int success;
int wait;
int duration;
-
+
error_flag=0;
success=0;
#if LONG_TIMING
@@ -5105,12 +4785,12 @@ static int sbp_data(struct request *req)
for (frame=0;frame<current_drive->sbp_read_frames&&!error_flag; frame++)
{
SBPCD_CLI;
-
+
del_timer(&data_timer);
data_timer.expires=jiffies+max_latency;
timed_out_data=0;
add_timer(&data_timer);
- while (!timed_out_data)
+ while (!timed_out_data)
{
if (current_drive->f_multisession) try=maxtim_data*4;
else try=maxtim_data;
@@ -5207,9 +4887,9 @@ static int sbp_data(struct request *req)
else
{
sbp_sleep(1);
- OUT(CDo_sel_i_d,0);
+ OUT(CDo_sel_i_d,0);
i=inb(CDi_status);
- }
+ }
if (!(i&s_not_data_ready))
{
OUT(CDo_sel_i_d,1);
@@ -5311,7 +4991,7 @@ static int sbp_data(struct request *req)
}
SBPCD_STI;
}
-
+
#if 0
if (!success)
#endif
@@ -5370,7 +5050,326 @@ static int sbpcd_block_ioctl(struct inode *inode, struct file *file,
unsigned cmd, unsigned long arg)
{
struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
- return cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg);
+ struct cdrom_device_info *cdi = p->sbpcd_infop;
+ int ret, i;
+
+ ret = cdrom_ioctl(file, p->sbpcd_infop, inode, cmd, arg);
+ if (ret != -ENOSYS)
+ return ret;
+
+ msg(DBG_IO2,"ioctl(%s, 0x%08lX, 0x%08lX)\n", cdi->name, cmd, arg);
+ if (p->drv_id==-1) {
+ msg(DBG_INF, "ioctl: bad device: %s\n", cdi->name);
+ return (-ENXIO); /* no such drive */
+ }
+ down(&ioctl_read_sem);
+ if (p != current_drive)
+ switch_drive(p);
+
+ msg(DBG_IO2,"ioctl: device %s, request %04X\n",cdi->name,cmd);
+ switch (cmd) /* Sun-compatible */
+ {
+ case DDIOCSDBG: /* DDI Debug */
+ if (!capable(CAP_SYS_ADMIN)) RETURN_UP(-EPERM);
+ i=sbpcd_dbg_ioctl(arg,1);
+ RETURN_UP(i);
+ case CDROMRESET: /* hard reset the drive */
+ msg(DBG_IOC,"ioctl: CDROMRESET entered.\n");
+ i=DriveReset();
+ current_drive->audio_state=0;
+ RETURN_UP(i);
+
+ case CDROMREADMODE1:
+ msg(DBG_IOC,"ioctl: CDROMREADMODE1 requested.\n");
+#ifdef SAFE_MIXED
+ if (current_drive->has_data>1) RETURN_UP(-EBUSY);
+#endif /* SAFE_MIXED */
+ cc_ModeSelect(CD_FRAMESIZE);
+ cc_ModeSense();
+ current_drive->mode=READ_M1;
+ RETURN_UP(0);
+
+ case CDROMREADMODE2: /* not usable at the moment */
+ msg(DBG_IOC,"ioctl: CDROMREADMODE2 requested.\n");
+#ifdef SAFE_MIXED
+ if (current_drive->has_data>1) RETURN_UP(-EBUSY);
+#endif /* SAFE_MIXED */
+ cc_ModeSelect(CD_FRAMESIZE_RAW1);
+ cc_ModeSense();
+ current_drive->mode=READ_M2;
+ RETURN_UP(0);
+
+ case CDROMAUDIOBUFSIZ: /* configure the audio buffer size */
+ msg(DBG_IOC,"ioctl: CDROMAUDIOBUFSIZ entered.\n");
+ if (current_drive->sbp_audsiz>0)
+ vfree(current_drive->aud_buf);
+ current_drive->aud_buf=NULL;
+ current_drive->sbp_audsiz=arg;
+
+ if (current_drive->sbp_audsiz>16)
+ {
+ current_drive->sbp_audsiz = 0;
+ RETURN_UP(current_drive->sbp_audsiz);
+ }
+
+ if (current_drive->sbp_audsiz>0)
+ {
+ current_drive->aud_buf=(u_char *) vmalloc(current_drive->sbp_audsiz*CD_FRAMESIZE_RAW);
+ if (current_drive->aud_buf==NULL)
+ {
+ msg(DBG_INF,"audio buffer (%d frames) not available.\n",current_drive->sbp_audsiz);
+ current_drive->sbp_audsiz=0;
+ }
+ else msg(DBG_INF,"audio buffer size: %d frames.\n",current_drive->sbp_audsiz);
+ }
+ RETURN_UP(current_drive->sbp_audsiz);
+
+ case CDROMREADAUDIO:
+ { /* start of CDROMREADAUDIO */
+ int i=0, j=0, frame, block=0;
+ u_int try=0;
+ u_long timeout;
+ u_char *p;
+ u_int data_tries = 0;
+ u_int data_waits = 0;
+ u_int data_retrying = 0;
+ int status_tries;
+ int error_flag;
+
+ msg(DBG_IOC,"ioctl: CDROMREADAUDIO entered.\n");
+ if (fam0_drive) RETURN_UP(-EINVAL);
+ if (famL_drive) RETURN_UP(-EINVAL);
+ if (famV_drive) RETURN_UP(-EINVAL);
+ if (famT_drive) RETURN_UP(-EINVAL);
+#ifdef SAFE_MIXED
+ if (current_drive->has_data>1) RETURN_UP(-EBUSY);
+#endif /* SAFE_MIXED */
+ if (current_drive->aud_buf==NULL) RETURN_UP(-EINVAL);
+ if (copy_from_user(&read_audio, (void __user *)arg,
+ sizeof(struct cdrom_read_audio)))
+ RETURN_UP(-EFAULT);
+ if (read_audio.nframes < 0 || read_audio.nframes>current_drive->sbp_audsiz) RETURN_UP(-EINVAL);
+ if (!access_ok(VERIFY_WRITE, read_audio.buf,
+ read_audio.nframes*CD_FRAMESIZE_RAW))
+ RETURN_UP(-EFAULT);
+
+ if (read_audio.addr_format==CDROM_MSF) /* MSF-bin specification of where to start */
+ block=msf2lba(&read_audio.addr.msf.minute);
+ else if (read_audio.addr_format==CDROM_LBA) /* lba specification of where to start */
+ block=read_audio.addr.lba;
+ else RETURN_UP(-EINVAL);
+#if 000
+ i=cc_SetSpeed(speed_150,0,0);
+ if (i) msg(DBG_AUD,"read_audio: SetSpeed error %d\n", i);
+#endif
+ msg(DBG_AUD,"read_audio: lba: %d, msf: %06X\n",
+ block, blk2msf(block));
+ msg(DBG_AUD,"read_audio: before cc_ReadStatus.\n");
+#if OLD_BUSY
+ while (busy_data) sbp_sleep(HZ/10); /* wait a bit */
+ busy_audio=1;
+#endif /* OLD_BUSY */
+ error_flag=0;
+ for (data_tries=5; data_tries>0; data_tries--)
+ {
+ msg(DBG_AUD,"data_tries=%d ...\n", data_tries);
+ current_drive->mode=READ_AU;
+ cc_ModeSelect(CD_FRAMESIZE_RAW);
+ cc_ModeSense();
+ for (status_tries=3; status_tries > 0; status_tries--)
+ {
+ flags_cmd_out |= f_respo3;
+ cc_ReadStatus();
+ if (sbp_status() != 0) break;
+ if (st_check) cc_ReadError();
+ sbp_sleep(1); /* wait a bit, try again */
+ }
+ if (status_tries == 0)
+ {
+ msg(DBG_AUD,"read_audio: sbp_status: failed after 3 tries in line %d.\n", __LINE__);
+ continue;
+ }
+ msg(DBG_AUD,"read_audio: sbp_status: ok.\n");
+
+ flags_cmd_out = f_putcmd | f_respo2 | f_ResponseStatus | f_obey_p_check;
+ if (fam0L_drive)
+ {
+ flags_cmd_out |= f_lopsta | f_getsta | f_bit1;
+ cmd_type=READ_M2;
+ drvcmd[0]=CMD0_READ_XA; /* "read XA frames", old drives */
+ drvcmd[1]=(block>>16)&0x000000ff;
+ drvcmd[2]=(block>>8)&0x000000ff;
+ drvcmd[3]=block&0x000000ff;
+ drvcmd[4]=0;
+ drvcmd[5]=read_audio.nframes; /* # of frames */
+ drvcmd[6]=0;
+ }
+ else if (fam1_drive)
+ {
+ drvcmd[0]=CMD1_READ; /* "read frames", new drives */
+ lba2msf(block,&drvcmd[1]); /* msf-bin format required */
+ drvcmd[4]=0;
+ drvcmd[5]=0;
+ drvcmd[6]=read_audio.nframes; /* # of frames */
+ }
+ else if (fam2_drive)
+ {
+ drvcmd[0]=CMD2_READ_XA2;
+ lba2msf(block,&drvcmd[1]); /* msf-bin format required */
+ drvcmd[4]=0;
+ drvcmd[5]=read_audio.nframes; /* # of frames */
+ drvcmd[6]=0x11; /* raw mode */
+ }
+ else if (famT_drive) /* CD-55A: not tested yet */
+ {
+ }
+ msg(DBG_AUD,"read_audio: before giving \"read\" command.\n");
+ flags_cmd_out=f_putcmd;
+ response_count=0;
+ i=cmd_out();
+ if (i<0) msg(DBG_INF,"error giving READ AUDIO command: %0d\n", i);
+ sbp_sleep(0);
+ msg(DBG_AUD,"read_audio: after giving \"read\" command.\n");
+ for (frame=1;frame<2 && !error_flag; frame++)
+ {
+ try=maxtim_data;
+ for (timeout=jiffies+9*HZ; ; )
+ {
+ for ( ; try!=0;try--)
+ {
+ j=inb(CDi_status);
+ if (!(j&s_not_data_ready)) break;
+ if (!(j&s_not_result_ready)) break;
+ if (fam0L_drive) if (j&s_attention) break;
+ }
+ if (try != 0 || time_after_eq(jiffies, timeout)) break;
+ if (data_retrying == 0) data_waits++;
+ data_retrying = 1;
+ sbp_sleep(1);
+ try = 1;
+ }
+ if (try==0)
+ {
+ msg(DBG_INF,"read_audio: sbp_data: CDi_status timeout.\n");
+ error_flag++;
+ break;
+ }
+ msg(DBG_AUD,"read_audio: sbp_data: CDi_status ok.\n");
+ if (j&s_not_data_ready)
+ {
+ msg(DBG_INF, "read_audio: sbp_data: DATA_READY timeout.\n");
+ error_flag++;
+ break;
+ }
+ msg(DBG_AUD,"read_audio: before reading data.\n");
+ error_flag=0;
+ p = current_drive->aud_buf;
+ if (sbpro_type==1) OUT(CDo_sel_i_d,1);
+ if (do_16bit)
+ {
+ u_short *p2 = (u_short *) p;
+
+ for (; (u_char *) p2 < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
+ {
+ if ((inb_p(CDi_status)&s_not_data_ready)) continue;
+
+ /* get one sample */
+ *p2++ = inw_p(CDi_data);
+ *p2++ = inw_p(CDi_data);
+ }
+ } else {
+ for (; p < current_drive->aud_buf + read_audio.nframes*CD_FRAMESIZE_RAW;)
+ {
+ if ((inb_p(CDi_status)&s_not_data_ready)) continue;
+
+ /* get one sample */
+ *p++ = inb_p(CDi_data);
+ *p++ = inb_p(CDi_data);
+ *p++ = inb_p(CDi_data);
+ *p++ = inb_p(CDi_data);
+ }
+ }
+ if (sbpro_type==1) OUT(CDo_sel_i_d,0);
+ data_retrying = 0;
+ }
+ msg(DBG_AUD,"read_audio: after reading data.\n");
+ if (error_flag) /* must have been spurious D_RDY or (ATTN&&!D_RDY) */
+ {
+ msg(DBG_AUD,"read_audio: read aborted by drive\n");
+#if 0000
+ i=cc_DriveReset(); /* ugly fix to prevent a hang */
+#else
+ i=cc_ReadError();
+#endif
+ continue;
+ }
+ if (fam0L_drive)
+ {
+ i=maxtim_data;
+ for (timeout=jiffies+9*HZ; time_before(jiffies, timeout); timeout--)
+ {
+ for ( ;i!=0;i--)
+ {
+ j=inb(CDi_status);
+ if (!(j&s_not_data_ready)) break;
+ if (!(j&s_not_result_ready)) break;
+ if (j&s_attention) break;
+ }
+ if (i != 0 || time_after_eq(jiffies, timeout)) break;
+ sbp_sleep(0);
+ i = 1;
+ }
+ if (i==0) msg(DBG_AUD,"read_audio: STATUS TIMEOUT AFTER READ");
+ if (!(j&s_attention))
+ {
+ msg(DBG_AUD,"read_audio: sbp_data: timeout waiting DRV_ATTN - retrying\n");
+ i=cc_DriveReset(); /* ugly fix to prevent a hang */
+ continue;
+ }
+ }
+ do
+ {
+ if (fam0L_drive) cc_ReadStatus();
+ i=ResponseStatus(); /* builds status_bits, returns orig. status (old) or faked p_success (new) */
+ if (i<0) { msg(DBG_AUD,
+ "read_audio: cc_ReadStatus error after read: %02X\n",
+ current_drive->status_bits);
+ continue; /* FIXME */
+ }
+ }
+ while ((fam0L_drive)&&(!st_check)&&(!(i&p_success)));
+ if (st_check)
+ {
+ i=cc_ReadError();
+ msg(DBG_AUD,"read_audio: cc_ReadError was necessary after read: %02X\n",i);
+ continue;
+ }
+ if (copy_to_user(read_audio.buf,
+ current_drive->aud_buf,
+ read_audio.nframes * CD_FRAMESIZE_RAW))
+ RETURN_UP(-EFAULT);
+ msg(DBG_AUD,"read_audio: copy_to_user done.\n");
+ break;
+ }
+ cc_ModeSelect(CD_FRAMESIZE);
+ cc_ModeSense();
+ current_drive->mode=READ_M1;
+#if OLD_BUSY
+ busy_audio=0;
+#endif /* OLD_BUSY */
+ if (data_tries == 0)
+ {
+ msg(DBG_AUD,"read_audio: failed after 5 tries in line %d.\n", __LINE__);
+ RETURN_UP(-EIO);
+ }
+ msg(DBG_AUD,"read_audio: successful return.\n");
+ RETURN_UP(0);
+ } /* end of CDROMREADAUDIO */
+
+ default:
+ msg(DBG_IOC,"ioctl: unknown function request %04X\n", cmd);
+ RETURN_UP(-EINVAL);
+ } /* end switch(cmd) */
}
static int sbpcd_block_media_changed(struct gendisk *disk)
@@ -5478,10 +5477,9 @@ static struct cdrom_device_ops sbpcd_dops = {
.get_mcn = sbpcd_get_mcn,
.reset = sbpcd_reset,
.audio_ioctl = sbpcd_audio_ioctl,
- .dev_ioctl = sbpcd_dev_ioctl,
.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
- CDC_MCN | CDC_PLAY_AUDIO | CDC_IOCTLS,
+ CDC_MCN | CDC_PLAY_AUDIO,
.n_minors = 1,
};
diff --git a/drivers/cdrom/viocd.c b/drivers/cdrom/viocd.c
index e2761725955..c0f817ba7ad 100644
--- a/drivers/cdrom/viocd.c
+++ b/drivers/cdrom/viocd.c
@@ -627,7 +627,7 @@ static struct cdrom_device_ops viocd_dops = {
.media_changed = viocd_media_changed,
.lock_door = viocd_lock_door,
.generic_packet = viocd_packet,
- .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
+ .capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK | CDC_SELECT_SPEED | CDC_SELECT_DISC | CDC_MULTI_SESSION | CDC_MCN | CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET | CDC_DRIVE_STATUS | CDC_GENERIC_PACKET | CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | CDC_DVD_RAM | CDC_RAM
};
static int __init find_capability(const char *type)
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index 05ba410682a..5980f3e886f 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -290,7 +290,7 @@ config SX
config RIO
tristate "Specialix RIO system support"
- depends on SERIAL_NONSTANDARD && BROKEN_ON_SMP && !64BIT
+ depends on SERIAL_NONSTANDARD && !64BIT
help
This is a driver for the Specialix RIO, a smart serial card which
drives an outboard box that can support up to 128 ports. Product
@@ -695,7 +695,7 @@ config NVRAM
config RTC
tristate "Enhanced Real Time Clock Support"
- depends on !PPC32 && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV
+ depends on !PPC && !PARISC && !IA64 && !M68K && (!SPARC || PCI) && !FRV
---help---
If you say Y here and create a character special file /dev/rtc with
major number 10 and minor number 135 using mknod ("man mknod"), you
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 090d154098b..b2a11245fa9 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -45,56 +45,57 @@ obj-$(CONFIG_HVC_CONSOLE) += hvc_console.o hvc_vio.o hvsi.o
obj-$(CONFIG_RAW_DRIVER) += raw.o
obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o
obj-$(CONFIG_MMTIMER) += mmtimer.o
-obj-$(CONFIG_VIOCONS) += viocons.o
+obj-$(CONFIG_VIOCONS) += viocons.o
obj-$(CONFIG_VIOTAPE) += viotape.o
obj-$(CONFIG_HVCS) += hvcs.o
obj-$(CONFIG_SGI_MBCS) += mbcs.o
-obj-$(CONFIG_PRINTER) += lp.o
-obj-$(CONFIG_TIPAR) += tipar.o
-
-obj-$(CONFIG_DTLK) += dtlk.o
-obj-$(CONFIG_R3964) += n_r3964.o
-obj-$(CONFIG_APPLICOM) += applicom.o
-obj-$(CONFIG_SONYPI) += sonypi.o
-obj-$(CONFIG_RTC) += rtc.o
-obj-$(CONFIG_HPET) += hpet.o
-obj-$(CONFIG_GEN_RTC) += genrtc.o
-obj-$(CONFIG_EFI_RTC) += efirtc.o
-obj-$(CONFIG_SGI_DS1286) += ds1286.o
-obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
-obj-$(CONFIG_DS1302) += ds1302.o
-obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
-obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o
+obj-$(CONFIG_PRINTER) += lp.o
+obj-$(CONFIG_TIPAR) += tipar.o
+
+obj-$(CONFIG_DTLK) += dtlk.o
+obj-$(CONFIG_R3964) += n_r3964.o
+obj-$(CONFIG_APPLICOM) += applicom.o
+obj-$(CONFIG_SONYPI) += sonypi.o
+obj-$(CONFIG_RTC) += rtc.o
+obj-$(CONFIG_HPET) += hpet.o
+obj-$(CONFIG_GEN_RTC) += genrtc.o
+obj-$(CONFIG_EFI_RTC) += efirtc.o
+obj-$(CONFIG_SGI_DS1286) += ds1286.o
+obj-$(CONFIG_SGI_IP27_RTC) += ip27-rtc.o
+obj-$(CONFIG_DS1302) += ds1302.o
+obj-$(CONFIG_S3C2410_RTC) += s3c2410-rtc.o
+obj-$(CONFIG_RTC_VR41XX) += vr41xx_rtc.o
ifeq ($(CONFIG_GENERIC_NVRAM),y)
- obj-$(CONFIG_NVRAM) += generic_nvram.o
+ obj-$(CONFIG_NVRAM) += generic_nvram.o
else
- obj-$(CONFIG_NVRAM) += nvram.o
+ obj-$(CONFIG_NVRAM) += nvram.o
endif
-obj-$(CONFIG_TOSHIBA) += toshiba.o
-obj-$(CONFIG_I8K) += i8k.o
-obj-$(CONFIG_DS1620) += ds1620.o
-obj-$(CONFIG_HW_RANDOM) += hw_random.o
-obj-$(CONFIG_FTAPE) += ftape/
-obj-$(CONFIG_COBALT_LCD) += lcd.o
-obj-$(CONFIG_PPDEV) += ppdev.o
-obj-$(CONFIG_NWBUTTON) += nwbutton.o
-obj-$(CONFIG_NWFLASH) += nwflash.o
-obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
-obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
-obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
-obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
-obj-$(CONFIG_TELCLOCK) += tlclk.o
-
-obj-$(CONFIG_WATCHDOG) += watchdog/
-obj-$(CONFIG_MWAVE) += mwave/
-obj-$(CONFIG_AGP) += agp/
-obj-$(CONFIG_DRM) += drm/
-obj-$(CONFIG_PCMCIA) += pcmcia/
-obj-$(CONFIG_IPMI_HANDLER) += ipmi/
-
-obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
-obj-$(CONFIG_TCG_TPM) += tpm/
+obj-$(CONFIG_TOSHIBA) += toshiba.o
+obj-$(CONFIG_I8K) += i8k.o
+obj-$(CONFIG_DS1620) += ds1620.o
+obj-$(CONFIG_HW_RANDOM) += hw_random.o
+obj-$(CONFIG_FTAPE) += ftape/
+obj-$(CONFIG_COBALT_LCD) += lcd.o
+obj-$(CONFIG_PPDEV) += ppdev.o
+obj-$(CONFIG_NWBUTTON) += nwbutton.o
+obj-$(CONFIG_NWFLASH) += nwflash.o
+obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o
+obj-$(CONFIG_CS5535_GPIO) += cs5535_gpio.o
+obj-$(CONFIG_GPIO_VR41XX) += vr41xx_giu.o
+obj-$(CONFIG_TANBAC_TB0219) += tb0219.o
+obj-$(CONFIG_TELCLOCK) += tlclk.o
+
+obj-$(CONFIG_WATCHDOG) += watchdog/
+obj-$(CONFIG_MWAVE) += mwave/
+obj-$(CONFIG_AGP) += agp/
+obj-$(CONFIG_DRM) += drm/
+obj-$(CONFIG_PCMCIA) += pcmcia/
+obj-$(CONFIG_IPMI_HANDLER) += ipmi/
+
+obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
+obj-$(CONFIG_TCG_TPM) += tpm/
+
# Files generated that shall be removed upon make clean
clean-files := consolemap_deftbl.c defkeymap.c qtronixmap.c
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c
index 7ac365b5d9e..6602b3156df 100644
--- a/drivers/char/amiserial.c
+++ b/drivers/char/amiserial.c
@@ -46,8 +46,6 @@
/* Sanity checks */
-#define SERIAL_INLINE
-
#if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT)
#define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \
tty->name, (info->flags), serial_driver->refcount,info->count,tty->count,s)
@@ -95,10 +93,6 @@ static char *serial_version = "4.30";
#include <asm/amigahw.h>
#include <asm/amigaints.h>
-#ifdef SERIAL_INLINE
-#define _INLINE_ inline
-#endif
-
#define custom amiga_custom
static char *serial_name = "Amiga-builtin serial driver";
@@ -253,14 +247,14 @@ static void rs_start(struct tty_struct *tty)
* This routine is used by the interrupt handler to schedule
* processing in the software interrupt portion of the driver.
*/
-static _INLINE_ void rs_sched_event(struct async_struct *info,
- int event)
+static void rs_sched_event(struct async_struct *info,
+ int event)
{
info->event |= 1 << event;
tasklet_schedule(&info->tlet);
}
-static _INLINE_ void receive_chars(struct async_struct *info)
+static void receive_chars(struct async_struct *info)
{
int status;
int serdatr;
@@ -349,7 +343,7 @@ out:
return;
}
-static _INLINE_ void transmit_chars(struct async_struct *info)
+static void transmit_chars(struct async_struct *info)
{
custom.intreq = IF_TBE;
mb();
@@ -389,7 +383,7 @@ static _INLINE_ void transmit_chars(struct async_struct *info)
}
}
-static _INLINE_ void check_modem_status(struct async_struct *info)
+static void check_modem_status(struct async_struct *info)
{
unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
unsigned char dstatus;
@@ -1959,7 +1953,7 @@ done:
* number, and identifies which options were configured into this
* driver.
*/
-static _INLINE_ void show_serial_version(void)
+static void show_serial_version(void)
{
printk(KERN_INFO "%s version %s\n", serial_name, serial_version);
}
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c
index e38a5f0e07b..5e59c0b4273 100644
--- a/drivers/char/generic_serial.c
+++ b/drivers/char/generic_serial.c
@@ -48,8 +48,8 @@ static int gs_debug;
#define NEW_WRITE_LOCKING 1
#if NEW_WRITE_LOCKING
#define DECL /* Nothing */
-#define LOCKIT down (& port->port_write_sem);
-#define RELEASEIT up (&port->port_write_sem);
+#define LOCKIT mutex_lock(& port->port_write_mutex);
+#define RELEASEIT mutex_unlock(&port->port_write_mutex);
#else
#define DECL unsigned long flags;
#define LOCKIT save_flags (flags);cli ()
@@ -124,14 +124,14 @@ int gs_write(struct tty_struct * tty,
/* get exclusive "write" access to this port (problem 3) */
/* This is not a spinlock because we can have a disk access (page
fault) in copy_from_user */
- down (& port->port_write_sem);
+ mutex_lock(& port->port_write_mutex);
while (1) {
c = count;
/* This is safe because we "OWN" the "head". Noone else can
- change the "head": we own the port_write_sem. */
+ change the "head": we own the port_write_mutex. */
/* Don't overrun the end of the buffer */
t = SERIAL_XMIT_SIZE - port->xmit_head;
if (t < c) c = t;
@@ -153,7 +153,7 @@ int gs_write(struct tty_struct * tty,
count -= c;
total += c;
}
- up (& port->port_write_sem);
+ mutex_unlock(& port->port_write_mutex);
gs_dprintk (GS_DEBUG_WRITE, "write: interrupts are %s\n",
(port->flags & GS_TX_INTEN)?"enabled": "disabled");
@@ -214,7 +214,7 @@ int gs_write(struct tty_struct * tty,
c = count;
/* This is safe because we "OWN" the "head". Noone else can
- change the "head": we own the port_write_sem. */
+ change the "head": we own the port_write_mutex. */
/* Don't overrun the end of the buffer */
t = SERIAL_XMIT_SIZE - port->xmit_head;
if (t < c) c = t;
@@ -888,7 +888,7 @@ int gs_init_port(struct gs_port *port)
spin_lock_irqsave (&port->driver_lock, flags);
if (port->tty)
clear_bit(TTY_IO_ERROR, &port->tty->flags);
- init_MUTEX(&port->port_write_sem);
+ mutex_init(&port->port_write_mutex);
port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
spin_unlock_irqrestore(&port->driver_lock, flags);
gs_set_termios(port->tty, NULL);
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 831eb4e8d9d..f7ac3185657 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -118,7 +118,7 @@
* the hvcs_final_close() function in order to get it out of the spinlock.
* Rearranged hvcs_close(). Cleaned up some printks and did some housekeeping
* on the changelog. Removed local CLC_LENGTH and used HVCS_CLC_LENGTH from
- * arch/ppc64/hvcserver.h.
+ * include/asm-powerpc/hvcserver.h
*
* 1.3.2 -> 1.3.3 Replaced yield() in hvcs_close() with tty_wait_until_sent() to
* prevent possible lockup with realtime scheduling as similarily pointed out by
@@ -168,9 +168,10 @@ MODULE_VERSION(HVCS_DRIVER_VERSION);
/*
* The hcall interface involves putting 8 chars into each of two registers.
- * We load up those 2 registers (in arch/ppc64/hvconsole.c) by casting char[16]
- * to long[2]. It would work without __ALIGNED__, but a little (tiny) bit
- * slower because an unaligned load is slower than aligned load.
+ * We load up those 2 registers (in arch/powerpc/platforms/pseries/hvconsole.c)
+ * by casting char[16] to long[2]. It would work without __ALIGNED__, but a
+ * little (tiny) bit slower because an unaligned load is slower than aligned
+ * load.
*/
#define __ALIGNED__ __attribute__((__aligned__(8)))
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index d745004281d..abd4c5118a1 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -736,7 +736,8 @@ int ipmi_create_user(unsigned int if_num,
intf = ipmi_interfaces[if_num];
if ((if_num >= MAX_IPMI_INTERFACES) || IPMI_INVALID_INTERFACE(intf)) {
spin_unlock_irqrestore(&interfaces_lock, flags);
- return -EINVAL;
+ rv = -EINVAL;
+ goto out_kfree;
}
/* Note that each existing user holds a refcount to the interface. */
@@ -751,14 +752,14 @@ int ipmi_create_user(unsigned int if_num,
if (!try_module_get(intf->handlers->owner)) {
rv = -ENODEV;
- goto out_err;
+ goto out_kref;
}
if (intf->handlers->inc_usecount) {
rv = intf->handlers->inc_usecount(intf->send_info);
if (rv) {
module_put(intf->handlers->owner);
- goto out_err;
+ goto out_kref;
}
}
@@ -769,9 +770,10 @@ int ipmi_create_user(unsigned int if_num,
*user = new_user;
return 0;
- out_err:
- kfree(new_user);
+out_kref:
kref_put(&intf->refcount, intf_free);
+out_kfree:
+ kfree(new_user);
return rv;
}
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c
index 49c09ae004b..e8ed26b77d4 100644
--- a/drivers/char/ipmi/ipmi_poweroff.c
+++ b/drivers/char/ipmi/ipmi_poweroff.c
@@ -37,15 +37,13 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/completion.h>
+#include <linux/pm.h>
#include <linux/kdev_t.h>
#include <linux/ipmi.h>
#include <linux/ipmi_smi.h>
#define PFX "IPMI poweroff: "
-/* Where to we insert our poweroff function? */
-extern void (*pm_power_off)(void);
-
/* Definitions for controlling power off (if the system supports it). It
* conveniently matches the IPMI chassis control values. */
#define IPMI_CHASSIS_POWER_DOWN 0 /* power down, the default. */
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c
index 28c5a3193b8..e5247f85a44 100644
--- a/drivers/char/istallion.c
+++ b/drivers/char/istallion.c
@@ -181,7 +181,6 @@ static struct tty_driver *stli_serial;
* is already swapping a shared buffer won't make things any worse.
*/
static char *stli_tmpwritebuf;
-static DECLARE_MUTEX(stli_tmpwritesem);
#define STLI_TXBUFSIZE 4096
@@ -379,13 +378,13 @@ MODULE_DESCRIPTION("Stallion Intelligent Multiport Serial Driver");
MODULE_LICENSE("GPL");
-MODULE_PARM(board0, "1-3s");
+module_param_array(board0, charp, NULL, 0);
MODULE_PARM_DESC(board0, "Board 0 config -> name[,ioaddr[,memaddr]");
-MODULE_PARM(board1, "1-3s");
+module_param_array(board1, charp, NULL, 0);
MODULE_PARM_DESC(board1, "Board 1 config -> name[,ioaddr[,memaddr]");
-MODULE_PARM(board2, "1-3s");
+module_param_array(board2, charp, NULL, 0);
MODULE_PARM_DESC(board2, "Board 2 config -> name[,ioaddr[,memaddr]");
-MODULE_PARM(board3, "1-3s");
+module_param_array(board3, charp, NULL, 0);
MODULE_PARM_DESC(board3, "Board 3 config -> name[,ioaddr[,memaddr]");
#endif
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 29c41f4418c..26d0116b48d 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -216,11 +216,9 @@ static ssize_t write_mem(struct file * file, const char __user * buf,
copied = copy_from_user(ptr, buf, sz);
if (copied) {
- ssize_t ret;
-
- ret = written + (sz - copied);
- if (ret)
- return ret;
+ written += sz - copied;
+ if (written)
+ break;
return -EFAULT;
}
buf += sz;
@@ -456,11 +454,9 @@ do_write_kmem(void *p, unsigned long realp, const char __user * buf,
copied = copy_from_user(ptr, buf, sz);
if (copied) {
- ssize_t ret;
-
- ret = written + (sz - copied);
- if (ret)
- return ret;
+ written += sz - copied;
+ if (written)
+ break;
return -EFAULT;
}
buf += sz;
@@ -514,11 +510,10 @@ static ssize_t write_kmem(struct file * file, const char __user * buf,
if (len) {
written = copy_from_user(kbuf, buf, len);
if (written) {
- ssize_t ret;
-
+ if (wrote + virtr)
+ break;
free_page((unsigned long)kbuf);
- ret = wrote + virtr + (len - written);
- return ret ? ret : -EFAULT;
+ return -EFAULT;
}
}
len = vwrite(kbuf, (char *)p, len);
@@ -563,8 +558,11 @@ static ssize_t write_port(struct file * file, const char __user * buf,
return -EFAULT;
while (count-- > 0 && i < 65536) {
char c;
- if (__get_user(c, tmp))
+ if (__get_user(c, tmp)) {
+ if (tmp > buf)
+ break;
return -EFAULT;
+ }
outb(c,i);
i++;
tmp++;
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c
index ea725a9964e..0fb2fb9fb02 100644
--- a/drivers/char/mxser.c
+++ b/drivers/char/mxser.c
@@ -243,10 +243,10 @@ static int verbose = 0;
MODULE_AUTHOR("Casper Yang");
MODULE_DESCRIPTION("MOXA Smartio/Industio Family Multiport Board Device Driver");
-MODULE_PARM(ioaddr, "1-4i");
-MODULE_PARM(ttymajor, "i");
-MODULE_PARM(calloutmajor, "i");
-MODULE_PARM(verbose, "i");
+module_param_array(ioaddr, int, NULL, 0);
+module_param(ttymajor, int, 0);
+module_param(calloutmajor, int, 0);
+module_param(verbose, bool, 0);
MODULE_LICENSE("GPL");
struct mxser_log {
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c
index ccad7ae9454..ede365d0538 100644
--- a/drivers/char/n_tty.c
+++ b/drivers/char/n_tty.c
@@ -132,7 +132,7 @@ static void put_tty_queue(unsigned char c, struct tty_struct *tty)
* We test the TTY_THROTTLED bit first so that it always
* indicates the current state. The decision about whether
* it is worth allowing more input has been taken by the caller.
- * Can sleep, may be called under the atomic_read semaphore but
+ * Can sleep, may be called under the atomic_read_lock mutex but
* this is not guaranteed.
*/
@@ -1132,7 +1132,7 @@ static inline int input_available_p(struct tty_struct *tty, int amt)
* buffer, and once to drain the space from the (physical) beginning of
* the buffer to head pointer.
*
- * Called under the tty->atomic_read sem and with TTY_DONT_FLIP set
+ * Called under the tty->atomic_read_lock sem and with TTY_DONT_FLIP set
*
*/
@@ -1262,11 +1262,11 @@ do_it_again:
* Internal serialization of reads.
*/
if (file->f_flags & O_NONBLOCK) {
- if (down_trylock(&tty->atomic_read))
+ if (!mutex_trylock(&tty->atomic_read_lock))
return -EAGAIN;
}
else {
- if (down_interruptible(&tty->atomic_read))
+ if (mutex_lock_interruptible(&tty->atomic_read_lock))
return -ERESTARTSYS;
}
@@ -1393,7 +1393,7 @@ do_it_again:
timeout = time;
}
clear_bit(TTY_DONT_FLIP, &tty->flags);
- up(&tty->atomic_read);
+ mutex_unlock(&tty->atomic_read_lock);
remove_wait_queue(&tty->read_wait, &wait);
if (!waitqueue_active(&tty->read_wait))
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c
index ca41d62b1d9..8865387d344 100644
--- a/drivers/char/nwflash.c
+++ b/drivers/char/nwflash.c
@@ -27,6 +27,7 @@
#include <linux/rwsem.h>
#include <linux/init.h>
#include <linux/smp_lock.h>
+#include <linux/mutex.h>
#include <asm/hardware/dec21285.h>
#include <asm/io.h>
@@ -56,7 +57,7 @@ static int gbWriteEnable;
static int gbWriteBase64Enable;
static volatile unsigned char *FLASH_BASE;
static int gbFlashSize = KFLASH_SIZE;
-static DECLARE_MUTEX(nwflash_sem);
+static DEFINE_MUTEX(nwflash_mutex);
extern spinlock_t gpio_lock;
@@ -140,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
/*
* We now lock against reads and writes. --rmk
*/
- if (down_interruptible(&nwflash_sem))
+ if (mutex_lock_interruptible(&nwflash_mutex))
return -ERESTARTSYS;
ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
@@ -149,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
*ppos += count;
} else
ret = -EFAULT;
- up(&nwflash_sem);
+ mutex_unlock(&nwflash_mutex);
}
return ret;
}
@@ -188,7 +189,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
/*
* We now lock against reads and writes. --rmk
*/
- if (down_interruptible(&nwflash_sem))
+ if (mutex_lock_interruptible(&nwflash_mutex))
return -ERESTARTSYS;
written = 0;
@@ -277,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
*/
leds_event(led_release);
- up(&nwflash_sem);
+ mutex_unlock(&nwflash_mutex);
return written;
}
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 8a8ca32822b..e6b714b6390 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -4181,7 +4181,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
}
info->params.encoding = new_encoding;
- info->params.crc_type = new_crctype;;
+ info->params.crc_type = new_crctype;
/* if network interface up, reprogram hardware */
if (info->netcount)
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c
index 306ee0f091a..bee6c47b45b 100644
--- a/drivers/char/ppdev.c
+++ b/drivers/char/ppdev.c
@@ -65,10 +65,11 @@
#include <linux/parport.h>
#include <linux/ctype.h>
#include <linux/poll.h>
-#include <asm/uaccess.h>
+#include <linux/major.h>
#include <linux/ppdev.h>
#include <linux/smp_lock.h>
#include <linux/device.h>
+#include <asm/uaccess.h>
#define PP_VERSION "ppdev: user-space parallel port driver"
#define CHRDEV "ppdev"
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 30e4cbe16bb..15a7b408652 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -19,6 +19,7 @@
#include <linux/uio.h>
#include <linux/cdev.h>
#include <linux/device.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
@@ -29,7 +30,7 @@ struct raw_device_data {
static struct class *raw_class;
static struct raw_device_data raw_devices[MAX_RAW_MINORS];
-static DECLARE_MUTEX(raw_mutex);
+static DEFINE_MUTEX(raw_mutex);
static struct file_operations raw_ctl_fops; /* forward declaration */
/*
@@ -53,7 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp)
return 0;
}
- down(&raw_mutex);
+ mutex_lock(&raw_mutex);
/*
* All we need to do on open is check that the device is bound.
@@ -78,7 +79,7 @@ static int raw_open(struct inode *inode, struct file *filp)
filp->f_dentry->d_inode->i_mapping =
bdev->bd_inode->i_mapping;
filp->private_data = bdev;
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
return 0;
out2:
@@ -86,7 +87,7 @@ out2:
out1:
blkdev_put(bdev);
out:
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
return err;
}
@@ -99,14 +100,14 @@ static int raw_release(struct inode *inode, struct file *filp)
const int minor= iminor(inode);
struct block_device *bdev;
- down(&raw_mutex);
+ mutex_lock(&raw_mutex);
bdev = raw_devices[minor].binding;
if (--raw_devices[minor].inuse == 0) {
/* Here inode->i_mapping == bdev->bd_inode->i_mapping */
inode->i_mapping = &inode->i_data;
inode->i_mapping->backing_dev_info = &default_backing_dev_info;
}
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
bd_release(bdev);
blkdev_put(bdev);
@@ -187,9 +188,9 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
goto out;
}
- down(&raw_mutex);
+ mutex_lock(&raw_mutex);
if (rawdev->inuse) {
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
err = -EBUSY;
goto out;
}
@@ -211,11 +212,11 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
bind_device(&rq);
}
}
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
} else {
struct block_device *bdev;
- down(&raw_mutex);
+ mutex_lock(&raw_mutex);
bdev = rawdev->binding;
if (bdev) {
rq.block_major = MAJOR(bdev->bd_dev);
@@ -223,7 +224,7 @@ static int raw_ctl_ioctl(struct inode *inode, struct file *filp,
} else {
rq.block_major = rq.block_minor = 0;
}
- up(&raw_mutex);
+ mutex_unlock(&raw_mutex);
if (copy_to_user((void __user *)arg, &rq, sizeof(rq))) {
err = -EFAULT;
goto out;
diff --git a/drivers/char/rio/Makefile b/drivers/char/rio/Makefile
index bce2bd1204e..2d1c5a7cba7 100644
--- a/drivers/char/rio/Makefile
+++ b/drivers/char/rio/Makefile
@@ -9,4 +9,4 @@
obj-$(CONFIG_RIO) += rio.o
rio-objs := rio_linux.o rioinit.o rioboot.o riocmd.o rioctrl.o riointr.o \
- rioparam.o riopcicopy.o rioroute.o riotable.o riotty.o
+ rioparam.o rioroute.o riotable.o riotty.o
diff --git a/drivers/char/rio/board.h b/drivers/char/rio/board.h
index 29c98020409..bdea633a907 100644
--- a/drivers/char/rio/board.h
+++ b/drivers/char/rio/board.h
@@ -33,10 +33,6 @@
#ifndef __rio_board_h__
#define __rio_board_h__
-#ifdef SCCS_LABELS
-static char *_board_h_sccs_ = "@(#)board.h 1.2";
-#endif
-
/*
** board.h contains the definitions for the *hardware* of the host cards.
** It describes the memory overlay for the dual port RAM area.
@@ -53,29 +49,29 @@ static char *_board_h_sccs_ = "@(#)board.h 1.2";
** The shape of the Host Control area, at offset 0x7C00, Write Only
*/
struct s_Ctrl {
- BYTE DpCtl; /* 7C00 */
- BYTE Dp_Unused2_[127];
- BYTE DpIntSet; /* 7C80 */
- BYTE Dp_Unused3_[127];
- BYTE DpTpuReset; /* 7D00 */
- BYTE Dp_Unused4_[127];
- BYTE DpIntReset; /* 7D80 */
- BYTE Dp_Unused5_[127];
+ u8 DpCtl; /* 7C00 */
+ u8 Dp_Unused2_[127];
+ u8 DpIntSet; /* 7C80 */
+ u8 Dp_Unused3_[127];
+ u8 DpTpuReset; /* 7D00 */
+ u8 Dp_Unused4_[127];
+ u8 DpIntReset; /* 7D80 */
+ u8 Dp_Unused5_[127];
};
/*
** The PROM data area on the host (0x7C00), Read Only
*/
struct s_Prom {
- WORD DpSlxCode[2];
- WORD DpRev;
- WORD Dp_Unused6_;
- WORD DpUniq[4];
- WORD DpJahre;
- WORD DpWoche;
- WORD DpHwFeature[5];
- WORD DpOemId;
- WORD DpSiggy[16];
+ u16 DpSlxCode[2];
+ u16 DpRev;
+ u16 Dp_Unused6_;
+ u16 DpUniq[4];
+ u16 DpJahre;
+ u16 DpWoche;
+ u16 DpHwFeature[5];
+ u16 DpOemId;
+ u16 DpSiggy[16];
};
/*
@@ -90,19 +86,19 @@ union u_CtrlProm { /* This is the control/PROM area (0x7C00) */
** The top end of memory!
*/
struct s_ParmMapS { /* Area containing Parm Map Pointer */
- BYTE Dp_Unused8_[DP_PARMMAP_ADDR];
- WORD DpParmMapAd;
+ u8 Dp_Unused8_[DP_PARMMAP_ADDR];
+ u16 DpParmMapAd;
};
struct s_StartUpS {
- BYTE Dp_Unused9_[DP_STARTUP_ADDR];
- BYTE Dp_LongJump[0x4];
- BYTE Dp_Unused10_[2];
- BYTE Dp_ShortJump[0x2];
+ u8 Dp_Unused9_[DP_STARTUP_ADDR];
+ u8 Dp_LongJump[0x4];
+ u8 Dp_Unused10_[2];
+ u8 Dp_ShortJump[0x2];
};
union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
- BYTE DpSramMem[DP_SRAM2_SIZE];
+ u8 DpSramMem[DP_SRAM2_SIZE];
struct s_ParmMapS DpParmMapS;
struct s_StartUpS DpStartUpS;
};
@@ -111,11 +107,11 @@ union u_Sram2ParmMap { /* This is the top of memory (0x7E00-0x7FFF) */
** This is the DP RAM overlay.
*/
struct DpRam {
- BYTE DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */
+ u8 DpSram1[DP_SRAM1_SIZE]; /* 0000 - 7BFF */
union u_CtrlProm DpCtrlProm; /* 7C00 - 7DFF */
union u_Sram2ParmMap DpSram2ParmMap; /* 7E00 - 7FFF */
- BYTE DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
- BYTE DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */
+ u8 DpScratch[DP_SCRATCH_SIZE]; /* 8000 - 8FFF */
+ u8 DpSram3[DP_SRAM3_SIZE]; /* 9000 - FFFF */
};
#define DpControl DpCtrlProm.DpCtrl.DpCtl
diff --git a/drivers/char/rio/bootpkt.h b/drivers/char/rio/bootpkt.h
deleted file mode 100644
index 602266e0c08..00000000000
--- a/drivers/char/rio/bootpkt.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-/****************************************************************************
- ******* *******
- ******* B O O T P A C K E T H E A D E R F I L E
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef _pkt_h
-#define _pkt_h 1
-
-#ifndef lint
-#ifdef SCCS
-static char *_rio_bootpkt_h_sccs = "@(#)bootpkt.h 1.1";
-#endif
-#endif
-
- /*************************************************
- * Overlayed onto the Data fields of a regular
- * Packet
- ************************************************/
-typedef struct BOOT_PKT BOOT_PKT;
-struct BOOT_PKT {
- short seq_num;
- char data[10];
-};
-
-
-#endif
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/cirrus.h b/drivers/char/rio/cirrus.h
index 89bd94eb45b..f4f837f8682 100644
--- a/drivers/char/rio/cirrus.h
+++ b/drivers/char/rio/cirrus.h
@@ -40,73 +40,7 @@
#endif
#define _cirrus_h 1
-
-
-/* Bit fields for particular registers */
-
-/* GCR */
-#define GCR_SERIAL 0x00 /* Configure as serial channel */
-#define GCR_PARALLEL 0x80 /* Configure as parallel channel */
-
-/* RDSR - when status read from FIFO */
-#define RDSR_BREAK 0x08 /* Break received */
-#define RDSR_TIMEOUT 0x80 /* No new data timeout */
-#define RDSR_SC1 0x10 /* Special char 1 (tx XON) matched */
-#define RDSR_SC2 0x20 /* Special char 2 (tx XOFF) matched */
-#define RDSR_SC12_MASK 0x30 /* Mask for special chars 1 and 2 */
-
-/* PPR */
-#define PPR_DEFAULT 0x31 /* Default value - for a 25Mhz clock gives
- a timeout period of 1ms */
-
-/* LIVR */
-#define LIVR_EXCEPTION 0x07 /* Receive exception interrupt */
-
-/* CCR */
-#define CCR_RESET 0x80 /* Reset channel */
-#define CCR_CHANGE 0x4e /* COR's have changed - NB always change all
- COR's */
-#define CCR_WFLUSH 0x82 /* Flush transmit FIFO and TSR / THR */
-
-#define CCR_SENDSC1 0x21 /* Send special character one */
-#define CCR_SENDSC2 0x22 /* Send special character two */
-#define CCR_SENDSC3 0x23 /* Send special character three */
-#define CCR_SENDSC4 0x24 /* Send special character four */
-
-#define CCR_TENABLE 0x18 /* Enable transmitter */
-#define CCR_TDISABLE 0x14 /* Disable transmitter */
-#define CCR_RENABLE 0x12 /* Enable receiver */
-#define CCR_RDISABLE 0x11 /* Disable receiver */
-
-#define CCR_READY 0x00 /* CCR is ready for another command */
-
-/* CCSR */
-#define CCSR_TXENABLE 0x08 /* Transmitter enable */
-#define CCSR_RXENABLE 0x80 /* Receiver enable */
-#define CCSR_TXFLOWOFF 0x04 /* Transmit flow off */
-#define CCSR_TXFLOWON 0x02 /* Transmit flow on */
-
-/* SVRR */
-#define SVRR_RECEIVE 0x01 /* Receive interrupt pending */
-#define SVRR_TRANSMIT 0x02 /* Transmit interrupt pending */
-#define SVRR_MODEM 0x04 /* Modem interrupt pending */
-
-/* CAR */
-#define CAR_PORTS 0x03 /* Bit fields for ports */
-
-/* IER */
-#define IER_MODEM 0x80 /* Change in modem status */
-#define IER_RECEIVE 0x10 /* Good data / data exception */
-#define IER_TRANSMITR 0x04 /* Transmit ready (FIFO empty) */
-#define IER_TRANSMITE 0x02 /* Transmit empty */
-#define IER_TIMEOUT 0x01 /* Timeout on no data */
-
-#define IER_DEFAULT 0x94 /* Default values */
-#define IER_PARALLEL 0x84 /* Default for Parallel */
-#define IER_EMPTY 0x92 /* Transmitter empty rather than ready */
-
-/* COR1 - Driver only */
-#define COR1_INPCK 0x10 /* Check parity of received characters */
+/* Bit fields for particular registers shared with driver */
/* COR1 - driver and RTA */
#define COR1_ODD 0x80 /* Odd parity */
@@ -222,35 +156,6 @@
#define MSVR1_HOST 0xf3 /* The bits the host wants */
-/* MSVR2 */
-#define MSVR2_DSR 0x02 /* DSR output pin (DTR on Cirrus) */
-
-/* MCOR */
-#define MCOR_CD 0x80 /* CD (DSR on Cirrus) */
-#define MCOR_RTS 0x40 /* RTS (CTS on Cirrus) */
-#define MCOR_RI 0x20 /* RI */
-#define MCOR_DTR 0x10 /* DTR (CD on Cirrus) */
-
-#define MCOR_DEFAULT (MCOR_CD | MCOR_RTS | MCOR_RI | MCOR_DTR)
-#define MCOR_FULLMODEM MCOR_DEFAULT
-#define MCOR_RJ45 (MCOR_CD | MCOR_RTS | MCOR_DTR)
-#define MCOR_RESTRICTED (MCOR_CD | MCOR_RTS)
-
-/* More MCOR - H/W Handshake (flowcontrol) stuff */
-#define MCOR_THRESH8 0x08 /* eight characters then we stop */
-#define MCOR_THRESH9 0x09 /* nine characters then we stop */
-#define MCOR_THRESH10 0x0A /* ten characters then we stop */
-#define MCOR_THRESH11 0x0B /* eleven characters then we stop */
-
-#define MCOR_THRESHBITS 0x0F /* mask for ANDing out the above */
-
-#define MCOR_THRESHOLD MCOR_THRESH9 /* MUST BE GREATER THAN COR3_THRESHOLD */
-
-
-/* RTPR */
-#define RTPR_DEFAULT 0x02 /* Default */
-
-
/* Defines for the subscripts of a CONFIG packet */
#define CONFIG_COR1 1 /* Option register 1 */
#define CONFIG_COR2 2 /* Option register 2 */
@@ -264,19 +169,6 @@
#define CONFIG_TXBAUD 10 /* Tx baud rate */
#define CONFIG_RXBAUD 11 /* Rx baud rate */
-/* Port status stuff */
-#define IDLE_CLOSED 0 /* Closed */
-#define IDLE_OPEN 1 /* Idle open */
-#define IDLE_BREAK 2 /* Idle on break */
-
-/* Subscript of MODEM STATUS packet */
-#define MODEM_VALUE 3 /* Current values of handshake pins */
-/* Subscript of SBREAK packet */
-#define BREAK_LENGTH 1 /* Length of a break in slices of 0.01 seconds
- 0 = stay on break until an EBREAK command
- is sent */
-
-
#define PRE_EMPTIVE 0x80 /* Pre-emptive bit in command field */
/* Packet types going from Host to remote - with the exception of OPEN, MOPEN,
diff --git a/drivers/char/rio/cmdblk.h b/drivers/char/rio/cmdblk.h
index a9a8c45631d..c46b2fdb662 100644
--- a/drivers/char/rio/cmdblk.h
+++ b/drivers/char/rio/cmdblk.h
@@ -48,10 +48,10 @@ struct CmdBlk {
struct CmdBlk *NextP; /* Pointer to next command block */
struct PKT Packet; /* A packet, to copy to the rup */
/* The func to call to check if OK */
- int (*PreFuncP) (int, struct CmdBlk *);
+ int (*PreFuncP) (unsigned long, struct CmdBlk *);
int PreArg; /* The arg for the func */
/* The func to call when completed */
- int (*PostFuncP) (int, struct CmdBlk *);
+ int (*PostFuncP) (unsigned long, struct CmdBlk *);
int PostArg; /* The arg for the func */
};
diff --git a/drivers/char/rio/cmdpkt.h b/drivers/char/rio/cmdpkt.h
index 77cee8df68e..357ae572243 100644
--- a/drivers/char/rio/cmdpkt.h
+++ b/drivers/char/rio/cmdpkt.h
@@ -55,24 +55,24 @@ static char *_cmdpkt_h_sccs_ = "@(#)cmdpkt.h 1.2";
** at Data[2] in the actual pkt!
*/
struct BootSequence {
- WORD NumPackets;
- WORD LoadBase;
- WORD CodeSize;
+ u16 NumPackets;
+ u16 LoadBase;
+ u16 CodeSize;
};
#define BOOT_SEQUENCE_LEN 8
struct SamTop {
- BYTE Unit;
- BYTE Link;
+ u8 Unit;
+ u8 Link;
};
struct CmdHdr {
- BYTE PcCommand;
+ u8 PcCommand;
union {
- BYTE PcPhbNum;
- BYTE PcLinkNum;
- BYTE PcIDNum;
+ u8 PcPhbNum;
+ u8 PcLinkNum;
+ u8 PcIDNum;
} U0;
};
@@ -84,28 +84,28 @@ struct PktCmd {
struct BootSequence PcBootSequence;
} S1;
struct {
- WORD PcSequence;
- BYTE PcBootData[RTA_BOOT_DATA_SIZE];
+ u16 PcSequence;
+ u8 PcBootData[RTA_BOOT_DATA_SIZE];
} S2;
struct {
- WORD __crud__;
- BYTE PcUniqNum[4]; /* this is really a uint. */
- BYTE PcModuleTypes; /* what modules are fitted */
+ u16 __crud__;
+ u8 PcUniqNum[4]; /* this is really a uint. */
+ u8 PcModuleTypes; /* what modules are fitted */
} S3;
struct {
struct CmdHdr CmdHdr;
- BYTE __undefined__;
- BYTE PcModemStatus;
- BYTE PcPortStatus;
- BYTE PcSubCommand; /* commands like mem or register dump */
- WORD PcSubAddr; /* Address for command */
- BYTE PcSubData[64]; /* Date area for command */
+ u8 __undefined__;
+ u8 PcModemStatus;
+ u8 PcPortStatus;
+ u8 PcSubCommand; /* commands like mem or register dump */
+ u16 PcSubAddr; /* Address for command */
+ u8 PcSubData[64]; /* Date area for command */
} S4;
struct {
struct CmdHdr CmdHdr;
- BYTE PcCommandText[1];
- BYTE __crud__[20];
- BYTE PcIDNum2; /* It had to go somewhere! */
+ u8 PcCommandText[1];
+ u8 __crud__[20];
+ u8 PcIDNum2; /* It had to go somewhere! */
} S5;
struct {
struct CmdHdr CmdHdr;
@@ -118,45 +118,45 @@ struct PktCmd_M {
union {
struct {
struct {
- uchar PcCommand;
+ u8 PcCommand;
union {
- uchar PcPhbNum;
- uchar PcLinkNum;
- uchar PcIDNum;
+ u8 PcPhbNum;
+ u8 PcLinkNum;
+ u8 PcIDNum;
} U0;
} CmdHdr;
struct {
- ushort NumPackets;
- ushort LoadBase;
- ushort CodeSize;
+ u16 NumPackets;
+ u16 LoadBase;
+ u16 CodeSize;
} PcBootSequence;
} S1;
struct {
- ushort PcSequence;
- uchar PcBootData[RTA_BOOT_DATA_SIZE];
+ u16 PcSequence;
+ u8 PcBootData[RTA_BOOT_DATA_SIZE];
} S2;
struct {
- ushort __crud__;
- uchar PcUniqNum[4]; /* this is really a uint. */
- uchar PcModuleTypes; /* what modules are fitted */
+ u16 __crud__;
+ u8 PcUniqNum[4]; /* this is really a uint. */
+ u8 PcModuleTypes; /* what modules are fitted */
} S3;
struct {
- ushort __cmd_hdr__;
- uchar __undefined__;
- uchar PcModemStatus;
- uchar PcPortStatus;
- uchar PcSubCommand;
- ushort PcSubAddr;
- uchar PcSubData[64];
+ u16 __cmd_hdr__;
+ u8 __undefined__;
+ u8 PcModemStatus;
+ u8 PcPortStatus;
+ u8 PcSubCommand;
+ u16 PcSubAddr;
+ u8 PcSubData[64];
} S4;
struct {
- ushort __cmd_hdr__;
- uchar PcCommandText[1];
- uchar __crud__[20];
- uchar PcIDNum2; /* Tacked on end */
+ u16 __cmd_hdr__;
+ u8 PcCommandText[1];
+ u8 __crud__[20];
+ u8 PcIDNum2; /* Tacked on end */
} S5;
struct {
- ushort __cmd_hdr__;
+ u16 __cmd_hdr__;
struct Top Topology[LINKS_PER_UNIT];
} S6;
} U1;
diff --git a/drivers/char/rio/control.h b/drivers/char/rio/control.h
deleted file mode 100644
index 6853d03304a..00000000000
--- a/drivers/char/rio/control.h
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-/****************************************************************************
- ******* *******
- ******* C O N T R O L P A C K E T H E A D E R S
- ******* *******
- ****************************************************************************
-
- Author : Jon Brawn
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-
-#ifndef _control_h
-#define _control_h
-
-#ifndef lint
-/* static char *_rio_control_h_sccs = "@(#)control.h 1.4"; */
-#endif
-
-#define CONTROL '^'
-#define IFOAD ( CONTROL + 1 )
-#define IDENTIFY ( CONTROL + 2 )
-#define ZOMBIE ( CONTROL + 3 )
-#define UFOAD ( CONTROL + 4 )
-#define IWAIT ( CONTROL + 5 )
-
-#define IFOAD_MAGIC 0xF0AD /* of course */
-#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
-#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
-#define IWAIT_MAGIC 0xB1DE /* Bide your time */
-
-#endif
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/daemon.h b/drivers/char/rio/daemon.h
index 28a991bd4fe..5818a8aa46e 100644
--- a/drivers/char/rio/daemon.h
+++ b/drivers/char/rio/daemon.h
@@ -45,15 +45,15 @@ static char *_daemon_h_sccs_ = "@(#)daemon.h 1.3";
*/
struct Error {
- uint Error;
- uint Entry;
- uint Other;
+ unsigned int Error;
+ unsigned int Entry;
+ unsigned int Other;
};
struct DownLoad {
char *DataP;
- uint Count;
- uint ProductCode;
+ unsigned int Count;
+ unsigned int ProductCode;
};
/*
@@ -68,69 +68,64 @@ struct DownLoad {
#endif
struct PortSetup {
- uint From; /* Set/Clear XP & IXANY Control from this port.... */
- uint To; /* .... to this port */
- uint XpCps; /* at this speed */
+ unsigned int From; /* Set/Clear XP & IXANY Control from this port.... */
+ unsigned int To; /* .... to this port */
+ unsigned int XpCps; /* at this speed */
char XpOn[MAX_XP_CTRL_LEN]; /* this is the start string */
char XpOff[MAX_XP_CTRL_LEN]; /* this is the stop string */
- uchar IxAny; /* enable/disable IXANY */
- uchar IxOn; /* enable/disable IXON */
- uchar Lock; /* lock port params */
- uchar Store; /* store params across closes */
- uchar Drain; /* close only when drained */
+ u8 IxAny; /* enable/disable IXANY */
+ u8 IxOn; /* enable/disable IXON */
+ u8 Lock; /* lock port params */
+ u8 Store; /* store params across closes */
+ u8 Drain; /* close only when drained */
};
struct LpbReq {
- uint Host;
- uint Link;
+ unsigned int Host;
+ unsigned int Link;
struct LPB *LpbP;
};
struct RupReq {
- uint HostNum;
- uint RupNum;
+ unsigned int HostNum;
+ unsigned int RupNum;
struct RUP *RupP;
};
struct PortReq {
- uint SysPort;
+ unsigned int SysPort;
struct Port *PortP;
};
struct StreamInfo {
- uint SysPort;
-#if 0
- queue_t RQueue;
- queue_t WQueue;
-#else
+ unsigned int SysPort;
int RQueue;
int WQueue;
-#endif
};
struct HostReq {
- uint HostNum;
+ unsigned int HostNum;
struct Host *HostP;
};
struct HostDpRam {
- uint HostNum;
+ unsigned int HostNum;
struct DpRam *DpRamP;
};
struct DebugCtrl {
- uint SysPort;
- uint Debug;
- uint Wait;
+ unsigned int SysPort;
+ unsigned int Debug;
+ unsigned int Wait;
};
struct MapInfo {
- uint FirstPort; /* 8 ports, starting from this (tty) number */
- uint RtaUnique; /* reside on this RTA (unique number) */
+ unsigned int FirstPort; /* 8 ports, starting from this (tty) number */
+ unsigned int RtaUnique; /* reside on this RTA (unique number) */
};
struct MapIn {
- uint NumEntries; /* How many port sets are we mapping? */
+ unsigned int NumEntries; /* How many port sets are we mapping? */
struct MapInfo *MapInfoP; /* Pointer to (user space) info */
};
@@ -147,13 +142,13 @@ struct SpecialRupCmd {
};
struct IdentifyRta {
- ulong RtaUnique;
- uchar ID;
+ unsigned long RtaUnique;
+ u8 ID;
};
struct KillNeighbour {
- ulong UniqueNum;
- uchar Link;
+ unsigned long UniqueNum;
+ u8 Link;
};
struct rioVersion {
diff --git a/drivers/char/rio/defaults.h b/drivers/char/rio/defaults.h
deleted file mode 100644
index d55c2f6a987..00000000000
--- a/drivers/char/rio/defaults.h
+++ /dev/null
@@ -1,51 +0,0 @@
-
-/****************************************************************************
- ******* *******
- ******* D E F A U L T S
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef lint
-#ifdef SCCS
-static char *_rio_defaults_h_sccs = "@(#)defaults.h 1.1";
-#endif
-#endif
-
-
-#define MILLISECOND (int) (1000/64) /* 15.625 low ticks */
-#define SECOND (int) 15625 /* Low priority ticks */
-
-#define LINK_TIMEOUT (int) (POLL_PERIOD / 2)
-
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/error.h b/drivers/char/rio/error.h
deleted file mode 100644
index f20f0789db8..00000000000
--- a/drivers/char/rio/error.h
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/****************************************************************************
- ******* *******
- ******* E R R O R H E A D E R F I L E
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef lint
-/* static char *_rio_error_h_sccs = "@(#)error.h 1.3"; */
-#endif
-
-#define E_NO_ERROR ((ushort) 0)
-#define E_PROCESS_NOT_INIT ((ushort) 1)
-#define E_LINK_TIMEOUT ((ushort) 2)
-#define E_NO_ROUTE ((ushort) 3)
-#define E_CONFUSED ((ushort) 4)
-#define E_HOME ((ushort) 5)
-#define E_CSUM_FAIL ((ushort) 6)
-#define E_DISCONNECTED ((ushort) 7)
-#define E_BAD_RUP ((ushort) 8)
-#define E_NO_VIRGIN ((ushort) 9)
-#define E_BOOT_RUP_BUSY ((ushort) 10)
-
-
-
- /*************************************************
- * Parsed to mem_halt()
- ************************************************/
-#define E_CHANALLOC ((ushort) 0x80)
-#define E_POLL_ALLOC ((ushort) 0x81)
-#define E_LTTWAKE ((ushort) 0x82)
-#define E_LTT_ALLOC ((ushort) 0x83)
-#define E_LRT_ALLOC ((ushort) 0x84)
-#define E_CIRRUS ((ushort) 0x85)
-#define E_MONITOR ((ushort) 0x86)
-#define E_PHB_ALLOC ((ushort) 0x87)
-#define E_ARRAY_ALLOC ((ushort) 0x88)
-#define E_QBUF_ALLOC ((ushort) 0x89)
-#define E_PKT_ALLOC ((ushort) 0x8a)
-#define E_GET_TX_Q_BUF ((ushort) 0x8b)
-#define E_GET_RX_Q_BUF ((ushort) 0x8c)
-#define E_MEM_OUT ((ushort) 0x8d)
-#define E_MMU_INIT ((ushort) 0x8e)
-#define E_LTT_INIT ((ushort) 0x8f)
-#define E_LRT_INIT ((ushort) 0x90)
-#define E_LINK_RUN ((ushort) 0x91)
-#define E_MONITOR_ALLOC ((ushort) 0x92)
-#define E_MONITOR_INIT ((ushort) 0x93)
-#define E_POLL_INIT ((ushort) 0x94)
-
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/func.h b/drivers/char/rio/func.h
index b4778410ec6..e64fe991239 100644
--- a/drivers/char/rio/func.h
+++ b/drivers/char/rio/func.h
@@ -43,35 +43,33 @@ static char *_func_h_sccs_ = "@(#)func.h 1.3";
/* rioboot.c */
int RIOBootCodeRTA(struct rio_info *, struct DownLoad *);
-int RIOBootCodeHOST(struct rio_info *, register struct DownLoad *);
+int RIOBootCodeHOST(struct rio_info *, struct DownLoad *);
int RIOBootCodeUNKNOWN(struct rio_info *, struct DownLoad *);
void msec_timeout(struct Host *);
-int RIOBootRup(struct rio_info *, uint, struct Host *, struct PKT *);
-int RIOBootOk(struct rio_info *, struct Host *, ulong);
-int RIORtaBound(struct rio_info *, uint);
-void FillSlot(int, int, uint, struct Host *);
+int RIOBootRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
+int RIOBootOk(struct rio_info *, struct Host *, unsigned long);
+int RIORtaBound(struct rio_info *, unsigned int);
+void rio_fill_host_slot(int, int, unsigned int, struct Host *);
/* riocmd.c */
int RIOFoadRta(struct Host *, struct Map *);
int RIOZombieRta(struct Host *, struct Map *);
-int RIOCommandRta(struct rio_info *, uint, int (*func) (struct Host *, struct Map *));
-int RIOIdentifyRta(struct rio_info *, caddr_t);
-int RIOKillNeighbour(struct rio_info *, caddr_t);
+int RIOCommandRta(struct rio_info *, unsigned long, int (*func) (struct Host *, struct Map *));
+int RIOIdentifyRta(struct rio_info *, void *);
+int RIOKillNeighbour(struct rio_info *, void *);
int RIOSuspendBootRta(struct Host *, int, int);
int RIOFoadWakeup(struct rio_info *);
struct CmdBlk *RIOGetCmdBlk(void);
void RIOFreeCmdBlk(struct CmdBlk *);
-int RIOQueueCmdBlk(struct Host *, uint, struct CmdBlk *);
+int RIOQueueCmdBlk(struct Host *, unsigned int, struct CmdBlk *);
void RIOPollHostCommands(struct rio_info *, struct Host *);
-int RIOWFlushMark(int, struct CmdBlk *);
-int RIORFlushEnable(int, struct CmdBlk *);
-int RIOUnUse(int, struct CmdBlk *);
-void ShowPacket(uint, struct PKT *);
+int RIOWFlushMark(unsigned long, struct CmdBlk *);
+int RIORFlushEnable(unsigned long, struct CmdBlk *);
+int RIOUnUse(unsigned long, struct CmdBlk *);
/* rioctrl.c */
-int copyin(int, caddr_t, int);
int riocontrol(struct rio_info *, dev_t, int, caddr_t, int);
-int RIOPreemptiveCmd(struct rio_info *, struct Port *, uchar);
+int RIOPreemptiveCmd(struct rio_info *, struct Port *, unsigned char);
/* rioinit.c */
void rioinit(struct rio_info *, struct RioHostInfo *);
@@ -80,19 +78,17 @@ void RIOISAinit(struct rio_info *, int);
int RIODoAT(struct rio_info *, int, int);
caddr_t RIOCheckForATCard(int);
int RIOAssignAT(struct rio_info *, int, caddr_t, int);
-int RIOBoardTest(paddr_t, caddr_t, uchar, int);
+int RIOBoardTest(unsigned long, caddr_t, unsigned char, int);
void RIOAllocDataStructs(struct rio_info *);
void RIOSetupDataStructs(struct rio_info *);
-int RIODefaultName(struct rio_info *, struct Host *, uint);
+int RIODefaultName(struct rio_info *, struct Host *, unsigned int);
struct rioVersion *RIOVersid(void);
-int RIOMapin(paddr_t, int, caddr_t *);
-void RIOMapout(paddr_t, long, caddr_t);
-void RIOHostReset(uint, volatile struct DpRam *, uint);
+void RIOHostReset(unsigned int, struct DpRam *, unsigned int);
/* riointr.c */
void RIOTxEnable(char *);
void RIOServiceHost(struct rio_info *, struct Host *, int);
-int riotproc(struct rio_info *, register struct ttystatics *, int, int);
+int riotproc(struct rio_info *, struct ttystatics *, int, int);
/* rioparam.c */
int RIOParam(struct Port *, int, int, int);
@@ -106,18 +102,18 @@ int can_remove_receive(struct PKT **, struct Port *);
void remove_receive(struct Port *);
/* rioroute.c */
-int RIORouteRup(struct rio_info *, uint, struct Host *, struct PKT *);
-void RIOFixPhbs(struct rio_info *, struct Host *, uint);
-uint GetUnitType(uint);
+int RIORouteRup(struct rio_info *, unsigned int, struct Host *, struct PKT *);
+void RIOFixPhbs(struct rio_info *, struct Host *, unsigned int);
+unsigned int GetUnitType(unsigned int);
int RIOSetChange(struct rio_info *);
-int RIOFindFreeID(struct rio_info *, struct Host *, uint *, uint *);
+int RIOFindFreeID(struct rio_info *, struct Host *, unsigned int *, unsigned int *);
/* riotty.c */
int riotopen(struct tty_struct *tty, struct file *filp);
int riotclose(void *ptr);
-int riotioctl(struct rio_info *, struct tty_struct *, register int, register caddr_t);
+int riotioctl(struct rio_info *, struct tty_struct *, int, caddr_t);
void ttyseth(struct Port *, struct ttystatics *, struct old_sgttyb *sg);
/* riotable.c */
@@ -131,7 +127,7 @@ int RIOChangeName(struct rio_info *, struct Map *);
#if 0
/* riodrvr.c */
struct rio_info *rio_install(struct RioHostInfo *);
-int rio_uninstall(register struct rio_info *);
+int rio_uninstall(struct rio_info *);
int rio_open(struct rio_info *, int, struct file *);
int rio_close(struct rio_info *, struct file *);
int rio_read(struct rio_info *, struct file *, char *, int);
@@ -143,7 +139,7 @@ int rio_isr_thread(char *);
struct rio_info *rio_info_store(int cmd, struct rio_info *p);
#endif
-extern int rio_pcicopy(char *src, char *dst, int n);
+extern void rio_copy_to_card(void *to, void *from, int len);
extern int rio_minor(struct tty_struct *tty);
extern int rio_ismodem(struct tty_struct *tty);
diff --git a/drivers/char/rio/host.h b/drivers/char/rio/host.h
index f7dfcedf7d4..3ec73d1a279 100644
--- a/drivers/char/rio/host.h
+++ b/drivers/char/rio/host.h
@@ -50,22 +50,20 @@ static char *_host_h_sccs_ = "@(#)host.h 1.2";
** the host.
*/
struct Host {
- uchar Type; /* RIO_EISA, RIO_MCA, ... */
- uchar Ivec; /* POLLED or ivec number */
- uchar Mode; /* Control stuff */
- uchar Slot; /* Slot */
- volatile caddr_t Caddr; /* KV address of DPRAM */
- volatile struct DpRam *CardP; /* KV address of DPRAM, with overlay */
- paddr_t PaddrP; /* Phys. address of DPRAM */
+ unsigned char Type; /* RIO_EISA, RIO_MCA, ... */
+ unsigned char Ivec; /* POLLED or ivec number */
+ unsigned char Mode; /* Control stuff */
+ unsigned char Slot; /* Slot */
+ caddr_t Caddr; /* KV address of DPRAM */
+ struct DpRam *CardP; /* KV address of DPRAM, with overlay */
+ unsigned long PaddrP; /* Phys. address of DPRAM */
char Name[MAX_NAME_LEN]; /* The name of the host */
- uint UniqueNum; /* host unique number */
+ unsigned int UniqueNum; /* host unique number */
spinlock_t HostLock; /* Lock structure for MPX */
- /*struct pci_devinfo PciDevInfo; *//* PCI Bus/Device/Function stuff */
- /*struct lockb HostLock; *//* Lock structure for MPX */
- uint WorkToBeDone; /* set to true each interrupt */
- uint InIntr; /* Being serviced? */
- uint IntSrvDone; /* host's interrupt has been serviced */
- int (*Copy) (caddr_t, caddr_t, int); /* copy func */
+ unsigned int WorkToBeDone; /* set to true each interrupt */
+ unsigned int InIntr; /* Being serviced? */
+ unsigned int IntSrvDone; /* host's interrupt has been serviced */
+ void (*Copy) (void *, void *, int); /* copy func */
struct timer_list timer;
/*
** I M P O R T A N T !
@@ -74,7 +72,7 @@ struct Host {
** a RIO_HOST_FOAD command.
*/
- ulong Flags; /* Whats going down */
+ unsigned long Flags; /* Whats going down */
#define RC_WAITING 0
#define RC_STARTUP 1
#define RC_RUNNING 2
@@ -88,28 +86,28 @@ struct Host {
** Boot mode applies to the way in which hosts in this system will
** boot RTAs
*/
-#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */
-#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */
-#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */
+#define RC_BOOT_ALL 0x8 /* Boot all RTAs attached */
+#define RC_BOOT_OWN 0x10 /* Only boot RTAs bound to this system */
+#define RC_BOOT_NONE 0x20 /* Don't boot any RTAs (slave mode) */
struct Top Topology[LINKS_PER_UNIT]; /* one per link */
- struct Map Mapping[MAX_RUP]; /* Mappings for host */
- struct PHB *PhbP; /* Pointer to the PHB array */
- ushort *PhbNumP; /* Ptr to Number of PHB's */
- struct LPB *LinkStrP; /* Link Structure Array */
- struct RUP *RupP; /* Sixteen real rups here */
- struct PARM_MAP *ParmMapP; /* points to the parmmap */
- uint ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
- uint NumExtraBooted; /* how many of the above */
+ struct Map Mapping[MAX_RUP]; /* Mappings for host */
+ struct PHB *PhbP; /* Pointer to the PHB array */
+ unsigned short *PhbNumP; /* Ptr to Number of PHB's */
+ struct LPB *LinkStrP; /* Link Structure Array */
+ struct RUP *RupP; /* Sixteen real rups here */
+ struct PARM_MAP *ParmMapP; /* points to the parmmap */
+ unsigned int ExtraUnits[MAX_EXTRA_UNITS]; /* unknown things */
+ unsigned int NumExtraBooted; /* how many of the above */
/*
** Twenty logical rups.
** The first sixteen are the real Rup entries (above), the last four
** are the link RUPs.
*/
struct UnixRup UnixRups[MAX_RUP + LINKS_PER_UNIT];
- int timeout_id; /* For calling 100 ms delays */
- int timeout_sem; /* For calling 100 ms delays */
- long locks; /* long req'd for set_bit --RR */
+ int timeout_id; /* For calling 100 ms delays */
+ int timeout_sem; /* For calling 100 ms delays */
+ long locks; /* long req'd for set_bit --RR */
char ____end_marker____;
};
#define Control CardP->DpControl
diff --git a/drivers/char/rio/link.h b/drivers/char/rio/link.h
index 48d68ca7f82..f3bf11a04d4 100644
--- a/drivers/char/rio/link.h
+++ b/drivers/char/rio/link.h
@@ -37,38 +37,9 @@
#ifndef _link_h
#define _link_h 1
-#ifndef lint
-#ifdef SCCS_LABELS
-/* static char *_rio_link_h_sccs = "@(#)link.h 1.15"; */
-#endif
-#endif
-
-
-
/*************************************************
* Define the Link Status stuff
************************************************/
-#define LRT_ACTIVE ((ushort) 0x01)
-#define LRT_SPARE1 ((ushort) 0x02)
-#define INTRO_RCVD ((ushort) 0x04)
-#define FORCED_DISCONNECT ((ushort) 0x08)
-#define LRT_SPARE2 ((ushort) 0x80)
-
-#define TOP_OF_RTA_RAM ((ushort) 0x7000)
-#define HOST_SERIAL_POINTER (unsigned char **) (TOP_OF_RTA_RAM - 2 * sizeof (ushort))
-
-/* Flags for ltt_status */
-#define WAITING_ACK (ushort) 0x0001
-#define DATA_SENT (ushort) 0x0002
-#define WAITING_RUP (ushort) 0x0004
-#define WAITING_RETRY (ushort) 0x0008
-#define WAITING_TOPOLOGY (ushort) 0x0010
-#define SEND_SYNC (ushort) 0x0020
-#define FOAD_THIS_LINK (ushort) 0x0040
-#define REQUEST_SYNC (ushort) 0x0080
-#define REMOTE_DYING (ushort) 0x0100
-#define DIE_NOW (ushort) 0x0200
-
/* Boot request stuff */
#define BOOT_REQUEST ((ushort) 0) /* Request for a boot */
#define BOOT_ABORT ((ushort) 1) /* Abort a boot */
@@ -76,77 +47,48 @@
and load address */
#define BOOT_COMPLETED ((ushort) 3) /* Boot completed */
-/* States that a link can be in */
-#define LINK_DISCONNECTED ((ushort) 0) /* Disconnected */
-#define LINK_BOOT1 ((ushort) 1) /* Trying to send 1st stage boot */
-#define LINK_BOOT2 ((ushort) 2) /* Trying to send 2nd stage boot */
-#define LINK_BOOT2WAIT ((ushort) 3) /* Waiting for selftest results */
-#define LINK_BOOT3 ((ushort) 4) /* Trying to send 3rd stage boots */
-#define LINK_SYNC ((ushort) 5) /* Syncing */
-
-#define LINK_INTRO ((ushort) 10) /* Introductory packet */
-#define LINK_SUPPLYID ((ushort) 11) /* Trying to supply an ID */
-#define LINK_TOPOLOGY ((ushort) 12) /* Send a topology update */
-#define LINK_REQUESTID ((ushort) 13) /* Waiting for an ID */
-#define LINK_CONNECTED ((ushort) 14) /* Connected */
-
-#define LINK_INTERCONNECT ((ushort) 20) /* Subnets interconnected */
-
-#define LINK_SPARE ((ushort) 40)
-
-/*
-** Set the default timeout for link communications.
-*/
-#define LINKTIMEOUT (400 * MILLISECOND)
-
-/*
-** LED stuff
-*/
-#define LED_SET_COLOUR(colour)
-#define LED_OR_COLOUR(colour)
-#define LED_TIMEOUT(time)
struct LPB {
- WORD link_number; /* Link Number */
- Channel_ptr in_ch; /* Link In Channel */
- Channel_ptr out_ch; /* Link Out Channel */
- BYTE attached_serial[4]; /* Attached serial number */
- BYTE attached_host_serial[4];
+ u16 link_number; /* Link Number */
+ u16 in_ch; /* Link In Channel */
+ u16 out_ch; /* Link Out Channel */
+ u8 attached_serial[4]; /* Attached serial number */
+ u8 attached_host_serial[4];
/* Serial number of Host who
booted the other end */
- WORD descheduled; /* Currently Descheduled */
- WORD state; /* Current state */
- WORD send_poll; /* Send a Poll Packet */
- Process_ptr ltt_p; /* Process Descriptor */
- Process_ptr lrt_p; /* Process Descriptor */
- WORD lrt_status; /* Current lrt status */
- WORD ltt_status; /* Current ltt status */
- WORD timeout; /* Timeout value */
- WORD topology; /* Topology bits */
- WORD mon_ltt;
- WORD mon_lrt;
- WORD WaitNoBoot; /* Secs to hold off booting */
- PKT_ptr add_packet_list; /* Add packets to here */
- PKT_ptr remove_packet_list; /* Send packets from here */
-
- Channel_ptr lrt_fail_chan; /* Lrt's failure channel */
- Channel_ptr ltt_fail_chan; /* Ltt's failure channel */
+ u16 descheduled; /* Currently Descheduled */
+ u16 state; /* Current state */
+ u16 send_poll; /* Send a Poll Packet */
+ u16 ltt_p; /* Process Descriptor */
+ u16 lrt_p; /* Process Descriptor */
+ u16 lrt_status; /* Current lrt status */
+ u16 ltt_status; /* Current ltt status */
+ u16 timeout; /* Timeout value */
+ u16 topology; /* Topology bits */
+ u16 mon_ltt;
+ u16 mon_lrt;
+ u16 WaitNoBoot; /* Secs to hold off booting */
+ u16 add_packet_list; /* Add packets to here */
+ u16 remove_packet_list; /* Send packets from here */
+
+ u16 lrt_fail_chan; /* Lrt's failure channel */
+ u16 ltt_fail_chan; /* Ltt's failure channel */
/* RUP structure for HOST to driver communications */
struct RUP rup;
struct RUP link_rup; /* RUP for the link (POLL,
topology etc.) */
- WORD attached_link; /* Number of attached link */
- WORD csum_errors; /* csum errors */
- WORD num_disconnects; /* number of disconnects */
- WORD num_sync_rcvd; /* # sync's received */
- WORD num_sync_rqst; /* # sync requests */
- WORD num_tx; /* Num pkts sent */
- WORD num_rx; /* Num pkts received */
- WORD module_attached; /* Module tpyes of attached */
- WORD led_timeout; /* LED timeout */
- WORD first_port; /* First port to service */
- WORD last_port; /* Last port to service */
+ u16 attached_link; /* Number of attached link */
+ u16 csum_errors; /* csum errors */
+ u16 num_disconnects; /* number of disconnects */
+ u16 num_sync_rcvd; /* # sync's received */
+ u16 num_sync_rqst; /* # sync requests */
+ u16 num_tx; /* Num pkts sent */
+ u16 num_rx; /* Num pkts received */
+ u16 module_attached; /* Module tpyes of attached */
+ u16 led_timeout; /* LED timeout */
+ u16 first_port; /* First port to service */
+ u16 last_port; /* Last port to service */
};
#endif
diff --git a/drivers/char/rio/linux_compat.h b/drivers/char/rio/linux_compat.h
index 17a14c4a342..34c0d2899ef 100644
--- a/drivers/char/rio/linux_compat.h
+++ b/drivers/char/rio/linux_compat.h
@@ -19,56 +19,12 @@
#include <linux/interrupt.h>
-#define disable(oldspl) save_flags (oldspl)
-#define restore(oldspl) restore_flags (oldspl)
-
-#define sysbrk(x) kmalloc ((x),in_interrupt()? GFP_ATOMIC : GFP_KERNEL)
-#define sysfree(p,size) kfree ((p))
-
-#define WBYTE(p,v) writeb(v, &p)
-#define RBYTE(p) readb (&p)
-#define WWORD(p,v) writew(v, &p)
-#define RWORD(p) readw(&p)
-#define WINDW(p,v) writew(v, p)
-#define RINDW(p) readw(p)
-
#define DEBUG_ALL
-#define cprintf printk
-
-#ifdef __KERNEL__
-#define INKERNEL
-#endif
-
struct ttystatics {
struct termios tm;
};
-#define bzero(d, n) memset((d), 0, (n))
-#define bcopy(src, dest, n) memcpy ((dest), (src), (n))
-
-#define SEM_SIGIGNORE 0x1234
-
-#ifdef DEBUG_SEM
-#define swait(a,b) printk ("waiting: " __FILE__ " line %d\n", __LINE__)
-#define ssignal(sem) printk ("signalling: " __FILE__ " line %d\n", __LINE__)
-
-#define sreset(sem) printk ("sreset: " __FILE__ "\n")
-#define sem_init(sem,v) printk ("sreset: " __FILE__ "\n")
-#endif
-
-
-#define getpid() (current->pid)
-
-#define QSIZE SERIAL_XMIT_SIZE
-
-#define pseterr(errno) return (- errno)
-
-#define V_CBAUD CBAUD
-
-/* For one reason or another rioboot.c uses delay instead of RIODelay. */
-#define delay(x,y) RIODelay(NULL, y)
-
extern int rio_debug;
#define RIO_DEBUG_INIT 0x000001
@@ -91,6 +47,7 @@ extern int rio_debug;
#define RIO_DEBUG_DELAY 0x020000
#define RIO_DEBUG_MOD_COUNT 0x040000
+
/* Copied over from riowinif.h . This is ugly. The winif file declares
also much other stuff which is incompatible with the headers from
the older driver. The older driver includes "brates.h" which shadows
diff --git a/drivers/char/rio/list.h b/drivers/char/rio/list.h
deleted file mode 100644
index 79b853140ae..00000000000
--- a/drivers/char/rio/list.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
- ******* *******
- ******* L I S T *******
- ******* *******
- ****************************************************************************
-
- Author : Jeremy Rolls.
- Date : 04-Nov-1990
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
- ***************************************************************************/
-
-#ifndef _list_h
-#define _list_h 1
-
-#ifdef SCCS_LABELS
-#ifndef lint
-static char *_rio_list_h_sccs = "@(#)list.h 1.9";
-#endif
-#endif
-
-#define PKT_IN_USE 0x1
-
-#define ZERO_PTR (ushort) 0x8000
-#define CaD PortP->Caddr
-
-/*
-** We can add another packet to a transmit queue if the packet pointer pointed
-** to by the TxAdd pointer has PKT_IN_USE clear in its address.
-*/
-
-#endif /* ifndef _list.h */
-/*********** end of file ***********/
diff --git a/drivers/char/rio/map.h b/drivers/char/rio/map.h
index 97fe287aab2..bdbcd09c8b8 100644
--- a/drivers/char/rio/map.h
+++ b/drivers/char/rio/map.h
@@ -47,17 +47,17 @@ static char *_map_h_sccs_ = "@(#)map.h 1.2";
#define MAX_NAME_LEN 32
struct Map {
- uint HostUniqueNum; /* Supporting hosts unique number */
- uint RtaUniqueNum; /* Unique number */
+ unsigned int HostUniqueNum; /* Supporting hosts unique number */
+ unsigned int RtaUniqueNum; /* Unique number */
/*
** The next two IDs must be swapped on big-endian architectures
** when using a v2.04 /etc/rio/config with a v3.00 driver (when
** upgrading for example).
*/
- ushort ID; /* ID used in the subnet */
- ushort ID2; /* ID of 2nd block of 8 for 16 port */
- ulong Flags; /* Booted, ID Given, Disconnected */
- ulong SysPort; /* First tty mapped to this port */
+ unsigned short ID; /* ID used in the subnet */
+ unsigned short ID2; /* ID of 2nd block of 8 for 16 port */
+ unsigned long Flags; /* Booted, ID Given, Disconnected */
+ unsigned long SysPort; /* First tty mapped to this port */
struct Top Topology[LINKS_PER_UNIT]; /* ID connected to each link */
char Name[MAX_NAME_LEN]; /* Cute name by which RTA is known */
};
diff --git a/drivers/char/rio/param.h b/drivers/char/rio/param.h
index de7e57180c9..675c200b245 100644
--- a/drivers/char/rio/param.h
+++ b/drivers/char/rio/param.h
@@ -43,18 +43,18 @@ static char *_param_h_sccs_ = "@(#)param.h 1.2";
*/
struct phb_param {
- BYTE Cmd; /* It is very important that these line up */
- BYTE Cor1; /* with what is expected at the other end. */
- BYTE Cor2; /* to confirm that you've got it right, */
- BYTE Cor4; /* check with cirrus/cirrus.h */
- BYTE Cor5;
- BYTE TxXon; /* Transmit X-On character */
- BYTE TxXoff; /* Transmit X-Off character */
- BYTE RxXon; /* Receive X-On character */
- BYTE RxXoff; /* Receive X-Off character */
- BYTE LNext; /* Literal-next character */
- BYTE TxBaud; /* Transmit baudrate */
- BYTE RxBaud; /* Receive baudrate */
+ u8 Cmd; /* It is very important that these line up */
+ u8 Cor1; /* with what is expected at the other end. */
+ u8 Cor2; /* to confirm that you've got it right, */
+ u8 Cor4; /* check with cirrus/cirrus.h */
+ u8 Cor5;
+ u8 TxXon; /* Transmit X-On character */
+ u8 TxXoff; /* Transmit X-Off character */
+ u8 RxXon; /* Receive X-On character */
+ u8 RxXoff; /* Receive X-Off character */
+ u8 LNext; /* Literal-next character */
+ u8 TxBaud; /* Transmit baudrate */
+ u8 RxBaud; /* Receive baudrate */
};
#endif
diff --git a/drivers/char/rio/parmmap.h b/drivers/char/rio/parmmap.h
index e24acc1d184..9764ef85c5a 100644
--- a/drivers/char/rio/parmmap.h
+++ b/drivers/char/rio/parmmap.h
@@ -47,40 +47,40 @@
typedef struct PARM_MAP PARM_MAP;
struct PARM_MAP {
- PHB_ptr phb_ptr; /* Pointer to the PHB array */
- WORD_ptr phb_num_ptr; /* Ptr to Number of PHB's */
- FREE_LIST_ptr free_list; /* Free List pointer */
- FREE_LIST_ptr free_list_end; /* Free List End pointer */
- Q_BUF_ptr_ptr q_free_list_ptr; /* Ptr to Q_BUF variable */
- BYTE_ptr unit_id_ptr; /* Unit Id */
- LPB_ptr link_str_ptr; /* Link Structure Array */
- BYTE_ptr bootloader_1; /* 1st Stage Boot Loader */
- BYTE_ptr bootloader_2; /* 2nd Stage Boot Loader */
- WORD_ptr port_route_map_ptr; /* Port Route Map */
- ROUTE_STR_ptr route_ptr; /* Unit Route Map */
- NUMBER_ptr map_present; /* Route Map present */
- NUMBER pkt_num; /* Total number of packets */
- NUMBER q_num; /* Total number of Q packets */
- WORD buffers_per_port; /* Number of buffers per port */
- WORD heap_size; /* Initial size of heap */
- WORD heap_left; /* Current Heap left */
- WORD error; /* Error code */
- WORD tx_max; /* Max number of tx pkts per phb */
- WORD rx_max; /* Max number of rx pkts per phb */
- WORD rx_limit; /* For high / low watermarks */
- NUMBER links; /* Links to use */
- NUMBER timer; /* Interrupts per second */
- RUP_ptr rups; /* Pointer to the RUPs */
- WORD max_phb; /* Mostly for debugging */
- WORD living; /* Just increments!! */
- WORD init_done; /* Initialisation over */
- WORD booting_link;
- WORD idle_count; /* Idle time counter */
- WORD busy_count; /* Busy counter */
- WORD idle_control; /* Control Idle Process */
- WORD tx_intr; /* TX interrupt pending */
- WORD rx_intr; /* RX interrupt pending */
- WORD rup_intr; /* RUP interrupt pending */
+ u16 phb_ptr; /* Pointer to the PHB array */
+ u16 phb_num_ptr; /* Ptr to Number of PHB's */
+ u16 free_list; /* Free List pointer */
+ u16 free_list_end; /* Free List End pointer */
+ u16 q_free_list_ptr; /* Ptr to Q_BUF variable */
+ u16 unit_id_ptr; /* Unit Id */
+ u16 link_str_ptr; /* Link Structure Array */
+ u16 bootloader_1; /* 1st Stage Boot Loader */
+ u16 bootloader_2; /* 2nd Stage Boot Loader */
+ u16 port_route_map_ptr; /* Port Route Map */
+ u16 route_ptr; /* Unit Route Map */
+ u16 map_present; /* Route Map present */
+ s16 pkt_num; /* Total number of packets */
+ s16 q_num; /* Total number of Q packets */
+ u16 buffers_per_port; /* Number of buffers per port */
+ u16 heap_size; /* Initial size of heap */
+ u16 heap_left; /* Current Heap left */
+ u16 error; /* Error code */
+ u16 tx_max; /* Max number of tx pkts per phb */
+ u16 rx_max; /* Max number of rx pkts per phb */
+ u16 rx_limit; /* For high / low watermarks */
+ s16 links; /* Links to use */
+ s16 timer; /* Interrupts per second */
+ u16 rups; /* Pointer to the RUPs */
+ u16 max_phb; /* Mostly for debugging */
+ u16 living; /* Just increments!! */
+ u16 init_done; /* Initialisation over */
+ u16 booting_link;
+ u16 idle_count; /* Idle time counter */
+ u16 busy_count; /* Busy counter */
+ u16 idle_control; /* Control Idle Process */
+ u16 tx_intr; /* TX interrupt pending */
+ u16 rx_intr; /* RX interrupt pending */
+ u16 rup_intr; /* RUP interrupt pending */
};
#endif
diff --git a/drivers/char/rio/phb.h b/drivers/char/rio/phb.h
index 2663ca0306e..a4c48ae4e36 100644
--- a/drivers/char/rio/phb.h
+++ b/drivers/char/rio/phb.h
@@ -37,13 +37,6 @@
#ifndef _phb_h
#define _phb_h 1
-#ifdef SCCS_LABELS
-#ifndef lint
-/* static char *_rio_phb_h_sccs = "@(#)phb.h 1.12"; */
-#endif
-#endif
-
-
/*************************************************
* Handshake asserted. Deasserted by the LTT(s)
************************************************/
@@ -124,23 +117,23 @@
* the start. The pointer tx_add points to a SPACE to put a Packet.
* The pointer tx_remove points to the next Packet to remove
*************************************************************************/
-typedef struct PHB PHB;
+
struct PHB {
- WORD source;
- WORD handshake;
- WORD status;
- NUMBER timeout; /* Maximum of 1.9 seconds */
- WORD link; /* Send down this link */
- WORD destination;
- PKT_ptr_ptr tx_start;
- PKT_ptr_ptr tx_end;
- PKT_ptr_ptr tx_add;
- PKT_ptr_ptr tx_remove;
-
- PKT_ptr_ptr rx_start;
- PKT_ptr_ptr rx_end;
- PKT_ptr_ptr rx_add;
- PKT_ptr_ptr rx_remove;
+ u8 source;
+ u8 handshake;
+ u8 status;
+ u16 timeout; /* Maximum of 1.9 seconds */
+ u8 link; /* Send down this link */
+ u8 destination;
+ u16 tx_start;
+ u16 tx_end;
+ u16 tx_add;
+ u16 tx_remove;
+
+ u16 rx_start;
+ u16 rx_end;
+ u16 rx_add;
+ u16 rx_remove;
};
diff --git a/drivers/char/rio/pkt.h b/drivers/char/rio/pkt.h
index 7011e52e82d..a9458164f02 100644
--- a/drivers/char/rio/pkt.h
+++ b/drivers/char/rio/pkt.h
@@ -37,14 +37,6 @@
#ifndef _pkt_h
#define _pkt_h 1
-
-#ifdef SCCS_LABELS
-#ifndef lint
-/* static char *_rio_pkt_h_sccs = "@(#)pkt.h 1.8"; */
-#endif
-#endif
-
-#define MAX_TTL 0xf
#define PKT_CMD_BIT ((ushort) 0x080)
#define PKT_CMD_DATA ((ushort) 0x080)
@@ -70,15 +62,15 @@
#define CONTROL_DATA_WNDW (DATA_WNDW << 8)
struct PKT {
- BYTE dest_unit; /* Destination Unit Id */
- BYTE dest_port; /* Destination POrt */
- BYTE src_unit; /* Source Unit Id */
- BYTE src_port; /* Source POrt */
- BYTE len;
- BYTE control;
- BYTE data[PKT_MAX_DATA_LEN];
+ u8 dest_unit; /* Destination Unit Id */
+ u8 dest_port; /* Destination POrt */
+ u8 src_unit; /* Source Unit Id */
+ u8 src_port; /* Source POrt */
+ u8 len;
+ u8 control;
+ u8 data[PKT_MAX_DATA_LEN];
/* Actual data :-) */
- WORD csum; /* C-SUM */
+ u16 csum; /* C-SUM */
};
#endif
diff --git a/drivers/char/rio/port.h b/drivers/char/rio/port.h
index c99b1e70fdc..9b5fa3eb040 100644
--- a/drivers/char/rio/port.h
+++ b/drivers/char/rio/port.h
@@ -33,91 +33,37 @@
#ifndef __rio_port_h__
#define __rio_port_h__
-#ifdef SCCS_LABELS
-static char *_port_h_sccs_ = "@(#)port.h 1.3";
-#endif
-
-
-#undef VPIX
-
-
-/*
-** the port data structure - one per port in the system
-*/
-
-#ifdef STATS
-struct RIOStats {
- /*
- ** interrupt statistics
- */
- uint BreakIntCnt;
- uint ModemOffCnt;
- uint ModemOnCnt;
- uint RxIntCnt;
- uint TxIntCnt;
- /*
- ** throughput statistics
- */
- uint RxCharCnt;
- uint RxPktCnt;
- uint RxSaveCnt;
- uint TxCharCnt;
- uint TxPktCnt;
- /*
- ** driver entry statistics
- */
- uint CloseCnt;
- uint IoctlCnt;
- uint OpenCnt;
- uint ReadCnt;
- uint WriteCnt;
- /*
- ** proc statistics
- */
- uint BlockCnt;
- uint OutputCnt;
- uint ResumeCnt;
- uint RflushCnt;
- uint SuspendCnt;
- uint TbreakCnt;
- uint TimeoutCnt;
- uint UnblockCnt;
- uint WflushCnt;
- uint WFBodgeCnt;
-};
-#endif
-
/*
** Port data structure
*/
struct Port {
struct gs_port gs;
- int PortNum; /* RIO port no., 0-511 */
+ int PortNum; /* RIO port no., 0-511 */
struct Host *HostP;
- volatile caddr_t Caddr;
- ushort HostPort; /* Port number on host card */
- uchar RupNum; /* Number of RUP for port */
- uchar ID2; /* Second ID of RTA for port */
- ulong State; /* FLAGS for open & xopen */
-#define RIO_LOPEN 0x00001 /* Local open */
-#define RIO_MOPEN 0x00002 /* Modem open */
-#define RIO_WOPEN 0x00004 /* Waiting for open */
-#define RIO_CLOSING 0x00008 /* The port is being close */
-#define RIO_XPBUSY 0x00010 /* Transparent printer busy */
-#define RIO_BREAKING 0x00020 /* Break in progress */
-#define RIO_DIRECT 0x00040 /* Doing Direct output */
-#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
-#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
-#define RIO_CARR_ON 0x00200 /* Stream has carrier present */
-#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
-#define RIO_RBLK 0x00800 /* Stream is read-blocked */
-#define RIO_BUSY 0x01000 /* Stream is BUSY for write */
-#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
-#define RIO_TXSTOP 0x04000 /* Stream output is stopped */
-#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
-#define RIO_DYNOROD 0x10000 /* Drain failed */
-#define RIO_DELETED 0x20000 /* RTA has been deleted */
-#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
+ caddr_t Caddr;
+ unsigned short HostPort; /* Port number on host card */
+ unsigned char RupNum; /* Number of RUP for port */
+ unsigned char ID2; /* Second ID of RTA for port */
+ unsigned long State; /* FLAGS for open & xopen */
+#define RIO_LOPEN 0x00001 /* Local open */
+#define RIO_MOPEN 0x00002 /* Modem open */
+#define RIO_WOPEN 0x00004 /* Waiting for open */
+#define RIO_CLOSING 0x00008 /* The port is being close */
+#define RIO_XPBUSY 0x00010 /* Transparent printer busy */
+#define RIO_BREAKING 0x00020 /* Break in progress */
+#define RIO_DIRECT 0x00040 /* Doing Direct output */
+#define RIO_EXCLUSIVE 0x00080 /* Stream open for exclusive use */
+#define RIO_NDELAY 0x00100 /* Stream is open FNDELAY */
+#define RIO_CARR_ON 0x00200 /* Stream has carrier present */
+#define RIO_XPWANTR 0x00400 /* Stream wanted by Xprint */
+#define RIO_RBLK 0x00800 /* Stream is read-blocked */
+#define RIO_BUSY 0x01000 /* Stream is BUSY for write */
+#define RIO_TIMEOUT 0x02000 /* Stream timeout in progress */
+#define RIO_TXSTOP 0x04000 /* Stream output is stopped */
+#define RIO_WAITFLUSH 0x08000 /* Stream waiting for flush */
+#define RIO_DYNOROD 0x10000 /* Drain failed */
+#define RIO_DELETED 0x20000 /* RTA has been deleted */
+#define RIO_ISSCANCODE 0x40000 /* This line is in scancode mode */
#define RIO_USING_EUC 0x100000 /* Using extended Unix chars */
#define RIO_CAN_COOK 0x200000 /* This line can do cooking */
#define RIO_TRIAD_MODE 0x400000 /* Enable TRIAD special ops. */
@@ -125,15 +71,15 @@ struct Port {
#define RIO_TRIAD_FUNC 0x1000000 /* Seen a function key coming in */
#define RIO_THROTTLE_RX 0x2000000 /* RX needs to be throttled. */
- ulong Config; /* FLAGS for NOREAD.... */
-#define RIO_NOREAD 0x0001 /* Are not allowed to read port */
-#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
-#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
-#define RIO_NOMASK 0x0007 /* All not allowed things */
-#define RIO_IXANY 0x0008 /* Port is allowed ixany */
-#define RIO_MODEM 0x0010 /* Stream is a modem device */
-#define RIO_IXON 0x0020 /* Port is allowed ixon */
-#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
+ unsigned long Config; /* FLAGS for NOREAD.... */
+#define RIO_NOREAD 0x0001 /* Are not allowed to read port */
+#define RIO_NOWRITE 0x0002 /* Are not allowed to write port */
+#define RIO_NOXPRINT 0x0004 /* Are not allowed to xprint port */
+#define RIO_NOMASK 0x0007 /* All not allowed things */
+#define RIO_IXANY 0x0008 /* Port is allowed ixany */
+#define RIO_MODEM 0x0010 /* Stream is a modem device */
+#define RIO_IXON 0x0020 /* Port is allowed ixon */
+#define RIO_WAITDRAIN 0x0040 /* Wait for port to completely drain */
#define RIO_MAP_50_TO_50 0x0080 /* Map 50 baud to 50 baud */
#define RIO_MAP_110_TO_110 0x0100 /* Map 110 baud to 110 baud */
@@ -142,36 +88,36 @@ struct Port {
** As LynxOS does not appear to support Hardware Flow Control .....
** Define our own flow control flags in 'Config'.
*/
-#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
-#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
+#define RIO_CTSFLOW 0x0200 /* RIO's own CTSFLOW flag */
+#define RIO_RTSFLOW 0x0400 /* RIO's own RTSFLOW flag */
- struct PHB *PhbP; /* pointer to PHB for port */
- WORD *TxAdd; /* Add packets here */
- WORD *TxStart; /* Start of add array */
- WORD *TxEnd; /* End of add array */
- WORD *RxRemove; /* Remove packets here */
- WORD *RxStart; /* Start of remove array */
- WORD *RxEnd; /* End of remove array */
- uint RtaUniqueNum; /* Unique number of RTA */
- ushort PortState; /* status of port */
- ushort ModemState; /* status of modem lines */
- ulong ModemLines; /* Modem bits sent to RTA */
- uchar CookMode; /* who expands CR/LF? */
- uchar ParamSem; /* Prevent write during param */
- uchar Mapped; /* if port mapped onto host */
- uchar SecondBlock; /* if port belongs to 2nd block
- of 16 port RTA */
- uchar InUse; /* how many pre-emptive cmds */
- uchar Lock; /* if params locked */
- uchar Store; /* if params stored across closes */
- uchar FirstOpen; /* TRUE if first time port opened */
- uchar FlushCmdBodge; /* if doing a (non)flush */
- uchar MagicFlags; /* require intr processing */
-#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
-#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
-#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
- uchar WflushFlag; /* 1 How many WFLUSHs active */
+ struct PHB *PhbP; /* pointer to PHB for port */
+ u16 *TxAdd; /* Add packets here */
+ u16 *TxStart; /* Start of add array */
+ u16 *TxEnd; /* End of add array */
+ u16 *RxRemove; /* Remove packets here */
+ u16 *RxStart; /* Start of remove array */
+ u16 *RxEnd; /* End of remove array */
+ unsigned int RtaUniqueNum; /* Unique number of RTA */
+ unsigned short PortState; /* status of port */
+ unsigned short ModemState; /* status of modem lines */
+ unsigned long ModemLines; /* Modem bits sent to RTA */
+ unsigned char CookMode; /* who expands CR/LF? */
+ unsigned char ParamSem; /* Prevent write during param */
+ unsigned char Mapped; /* if port mapped onto host */
+ unsigned char SecondBlock; /* if port belongs to 2nd block
+ of 16 port RTA */
+ unsigned char InUse; /* how many pre-emptive cmds */
+ unsigned char Lock; /* if params locked */
+ unsigned char Store; /* if params stored across closes */
+ unsigned char FirstOpen; /* TRUE if first time port opened */
+ unsigned char FlushCmdBodge; /* if doing a (non)flush */
+ unsigned char MagicFlags; /* require intr processing */
+#define MAGIC_FLUSH 0x01 /* mirror of WflushFlag */
+#define MAGIC_REBOOT 0x02 /* RTA re-booted, re-open ports */
+#define MORE_OUTPUT_EYGOR 0x04 /* riotproc failed to empty clists */
+ unsigned char WflushFlag; /* 1 How many WFLUSHs active */
/*
** Transparent print stuff
*/
@@ -179,63 +125,55 @@ struct Port {
#ifndef MAX_XP_CTRL_LEN
#define MAX_XP_CTRL_LEN 16 /* ALSO IN DAEMON.H */
#endif
- uint XpCps;
+ unsigned int XpCps;
char XpOn[MAX_XP_CTRL_LEN];
char XpOff[MAX_XP_CTRL_LEN];
- ushort XpLen; /* strlen(XpOn)+strlen(XpOff) */
- uchar XpActive;
- uchar XpLastTickOk; /* TRUE if we can process */
+ unsigned short XpLen; /* strlen(XpOn)+strlen(XpOff) */
+ unsigned char XpActive;
+ unsigned char XpLastTickOk; /* TRUE if we can process */
#define XP_OPEN 00001
#define XP_RUNABLE 00002
struct ttystatics *XttyP;
} Xprint;
-#ifdef VPIX
- v86_t *StashP;
- uint IntMask;
- struct termss VpixSs;
- uchar ModemStatusReg; /* Modem status register */
-#endif
- uchar RxDataStart;
- uchar Cor2Copy; /* copy of COR2 */
- char *Name; /* points to the Rta's name */
-#ifdef STATS
- struct RIOStats Stat; /* ports statistics */
-#endif
+ unsigned char RxDataStart;
+ unsigned char Cor2Copy; /* copy of COR2 */
+ char *Name; /* points to the Rta's name */
char *TxRingBuffer;
- ushort TxBufferIn; /* New data arrives here */
- ushort TxBufferOut; /* Intr removes data here */
- ushort OldTxBufferOut; /* Indicates if draining */
- int TimeoutId; /* Timeout ID */
- uint Debug;
- uchar WaitUntilBooted; /* True if open should block */
- uint statsGather; /* True if gathering stats */
- ulong txchars; /* Chars transmitted */
- ulong rxchars; /* Chars received */
- ulong opens; /* port open count */
- ulong closes; /* port close count */
- ulong ioctls; /* ioctl count */
- uchar LastRxTgl; /* Last state of rx toggle bit */
- spinlock_t portSem; /* Lock using this sem */
- int MonitorTstate; /* Monitoring ? */
- int timeout_id; /* For calling 100 ms delays */
- int timeout_sem; /* For calling 100 ms delays */
- int firstOpen; /* First time open ? */
- char *p; /* save the global struc here .. */
+ unsigned short TxBufferIn; /* New data arrives here */
+ unsigned short TxBufferOut; /* Intr removes data here */
+ unsigned short OldTxBufferOut; /* Indicates if draining */
+ int TimeoutId; /* Timeout ID */
+ unsigned int Debug;
+ unsigned char WaitUntilBooted; /* True if open should block */
+ unsigned int statsGather; /* True if gathering stats */
+ unsigned long txchars; /* Chars transmitted */
+ unsigned long rxchars; /* Chars received */
+ unsigned long opens; /* port open count */
+ unsigned long closes; /* port close count */
+ unsigned long ioctls; /* ioctl count */
+ unsigned char LastRxTgl; /* Last state of rx toggle bit */
+ spinlock_t portSem; /* Lock using this sem */
+ int MonitorTstate; /* Monitoring ? */
+ int timeout_id; /* For calling 100 ms delays */
+ int timeout_sem; /* For calling 100 ms delays */
+ int firstOpen; /* First time open ? */
+ char *p; /* save the global struc here .. */
};
struct ModuleInfo {
char *Name;
- uint Flags[4]; /* one per port on a module */
+ unsigned int Flags[4]; /* one per port on a module */
};
-#endif
/*
** This struct is required because trying to grab an entire Port structure
** runs into problems with differing struct sizes between driver and config.
*/
struct PortParams {
- uint Port;
- ulong Config;
- ulong State;
+ unsigned int Port;
+ unsigned long Config;
+ unsigned long State;
struct ttystatics *TtyP;
};
+
+#endif
diff --git a/drivers/char/rio/qbuf.h b/drivers/char/rio/qbuf.h
deleted file mode 100644
index 391ffc33553..00000000000
--- a/drivers/char/rio/qbuf.h
+++ /dev/null
@@ -1,62 +0,0 @@
-
-/****************************************************************************
- ******* *******
- ******* Q U E U E B U F F E R S T R U C T U R E S
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra / Jeremy Rolls
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef _qbuf_h
-#define _qbuf_h 1
-
-#ifndef lint
-#ifdef SCCS_LABELS
-static char *_rio_qbuf_h_sccs = "@(#)qbuf.h 1.1";
-#endif
-#endif
-
-
-
-#define PKTS_PER_BUFFER (220 / PKT_LENGTH)
-
-typedef struct Q_BUF Q_BUF;
-struct Q_BUF {
- Q_BUF_ptr next;
- Q_BUF_ptr prev;
- PKT_ptr buf[PKTS_PER_BUFFER];
-};
-
-
-#endif
-
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/rio.h b/drivers/char/rio/rio.h
index 7f45e1ab533..b4c91871ba2 100644
--- a/drivers/char/rio/rio.h
+++ b/drivers/char/rio/rio.h
@@ -33,38 +33,6 @@
#ifndef __rio_rio_h__
#define __rio_rio_h__
-#ifdef SCCS_LABELS
-static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
-#endif
-
-/*
-** 30.09.1998 ARG -
-** Introduced driver version and host card type strings
-*/
-#define RIO_DRV_STR "Specialix RIO Driver"
-#define RIO_AT_HOST_STR "ISA"
-#define RIO_PCI_HOST_STR "PCI"
-
-
-/*
-** rio_info_store() commands (arbitary values) :
-*/
-#define RIO_INFO_PUT 0xA4B3C2D1
-#define RIO_INFO_GET 0xF1E2D3C4
-
-
-/*
-** anything that I couldn't cram in somewhere else
-*/
-/*
-#ifndef RIODEBUG
-#define debug
-#else
-#define debug rioprint
-#endif
-*/
-
-
/*
** Maximum numbers of things
*/
@@ -101,9 +69,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
/*
** Flag values returned by functions
*/
+
#define RIO_FAIL -1
-#define RIO_SUCCESS 0
-#define COPYFAIL -1 /* copy[in|out] failed */
/*
** SysPort value for something that hasn't any ports
@@ -142,30 +109,8 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
/*
** Generally useful constants
*/
-#define HALF_A_SECOND ((HZ)>>1)
-#define A_SECOND (HZ)
-#define HUNDRED_HZ ((HZ/100)?(HZ/100):1)
-#define FIFTY_HZ ((HZ/50)?(HZ/50):1)
-#define TWENTY_HZ ((HZ/20)?(HZ/20):1)
-#define TEN_HZ ((HZ/10)?(HZ/10):1)
-#define FIVE_HZ ((HZ/5)?(HZ/5):1)
-#define HUNDRED_MS TEN_HZ
-#define FIFTY_MS TWENTY_HZ
-#define TWENTY_MS FIFTY_HZ
-#define TEN_MS HUNDRED_HZ
-#define TWO_SECONDS ((A_SECOND)*2)
-#define FIVE_SECONDS ((A_SECOND)*5)
-#define TEN_SECONDS ((A_SECOND)*10)
-#define FIFTEEN_SECONDS ((A_SECOND)*15)
-#define TWENTY_SECONDS ((A_SECOND)*20)
-#define HALF_A_MINUTE (A_MINUTE>>1)
-#define A_MINUTE (A_SECOND*60)
-#define FIVE_MINUTES (A_MINUTE*5)
-#define QUARTER_HOUR (A_MINUTE*15)
-#define HALF_HOUR (A_MINUTE*30)
-#define HOUR (A_MINUTE*60)
-
-#define SIXTEEN_MEG 0x1000000
+
+#define HUNDRED_MS ((HZ/10)?(HZ/10):1)
#define ONE_MEG 0x100000
#define SIXTY_FOUR_K 0x10000
@@ -173,8 +118,6 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
#define RIO_EISA_MEM_SIZE SIXTY_FOUR_K
#define RIO_MCA_MEM_SIZE SIXTY_FOUR_K
-#define POLL_VECTOR 0x100
-
#define COOK_WELL 0
#define COOK_MEDIUM 1
#define COOK_RAW 2
@@ -186,69 +129,26 @@ static char *_rio_h_sccs_ = "@(#)rio.h 1.3";
** RIO_OBJ takes hostp->Caddr and a UNIX pointer to an object and
** returns the offset into the DP RAM area.
*/
-#define RIO_PTR(C,O) (((caddr_t)(C))+(0xFFFF&(O)))
-#define RIO_OFF(C,O) ((int)(O)-(int)(C))
+#define RIO_PTR(C,O) (((unsigned char *)(C))+(0xFFFF&(O)))
+#define RIO_OFF(C,O) ((long)(O)-(long)(C))
/*
** How to convert from various different device number formats:
** DEV is a dev number, as passed to open, close etc - NOT a minor
** number!
-**
-** Note: LynxOS only gives us 8 bits for the device minor number,
-** so all this crap here to deal with 'modem' bits etc. is
-** just a load of irrelevant old bunkum!
-** This however does not stop us needing to define a value
-** for RIO_MODEMOFFSET which is required by the 'riomkdev'
-** utility in the New Config Utilities suite.
-*/
-/* 0-511: direct 512-1023: modem */
-#define RIO_MODEMOFFSET 0x200 /* doesn't mean anything */
+**/
+
#define RIO_MODEM_MASK 0x1FF
#define RIO_MODEM_BIT 0x200
#define RIO_UNMODEM(DEV) (MINOR(DEV) & RIO_MODEM_MASK)
#define RIO_ISMODEM(DEV) (MINOR(DEV) & RIO_MODEM_BIT)
#define RIO_PORT(DEV,FIRST_MAJ) ( (MAJOR(DEV) - FIRST_MAJ) * PORTS_PER_HOST) \
+ MINOR(DEV)
-
-#define splrio spltty
-
-#define RIO_IPL 5
-#define RIO_PRI (PZERO+10)
-#define RIO_CLOSE_PRI PZERO-1 /* uninterruptible sleeps for close */
-
-typedef struct DbInf {
- uint Flag;
- char Name[8];
-} DbInf;
-
-#ifndef TRUE
-#define TRUE (1==1)
-#endif
-#ifndef FALSE
-#define FALSE (!TRUE)
-#endif
-
-#define CSUM(pkt_ptr) (((ushort *)(pkt_ptr))[0] + ((ushort *)(pkt_ptr))[1] + \
- ((ushort *)(pkt_ptr))[2] + ((ushort *)(pkt_ptr))[3] + \
- ((ushort *)(pkt_ptr))[4] + ((ushort *)(pkt_ptr))[5] + \
- ((ushort *)(pkt_ptr))[6] + ((ushort *)(pkt_ptr))[7] + \
- ((ushort *)(pkt_ptr))[8] + ((ushort *)(pkt_ptr))[9] )
-
-/*
-** This happy little macro copies SIZE bytes of data from FROM to TO
-** quite well. SIZE must be a constant.
-*/
-#define CCOPY( FROM, TO, SIZE ) { *(struct s { char data[SIZE]; } *)(TO) = *(struct s *)(FROM); }
-
-/*
-** increment a buffer pointer modulo the size of the buffer...
-*/
-#define BUMP( P, I ) ((P) = (((P)+(I)) & RIOBufferMask))
-
-#define INIT_PACKET( PK, PP ) \
-{ \
- *((uint *)PK) = PP->PacketInfo; \
-}
+#define CSUM(pkt_ptr) (((u16 *)(pkt_ptr))[0] + ((u16 *)(pkt_ptr))[1] + \
+ ((u16 *)(pkt_ptr))[2] + ((u16 *)(pkt_ptr))[3] + \
+ ((u16 *)(pkt_ptr))[4] + ((u16 *)(pkt_ptr))[5] + \
+ ((u16 *)(pkt_ptr))[6] + ((u16 *)(pkt_ptr))[7] + \
+ ((u16 *)(pkt_ptr))[8] + ((u16 *)(pkt_ptr))[9] )
#define RIO_LINK_ENABLE 0x80FF /* FF is a hack, mainly for Mips, to */
/* prevent a really stupid race condition. */
@@ -267,27 +167,42 @@ typedef struct DbInf {
#define DISCONNECT 0
#define CONNECT 1
+/* ------ Control Codes ------ */
-/*
-** Machine types - these must NOT overlap with product codes 0-15
-*/
-#define RIO_MIPS_R3230 31
-#define RIO_MIPS_R4030 32
+#define CONTROL '^'
+#define IFOAD ( CONTROL + 1 )
+#define IDENTIFY ( CONTROL + 2 )
+#define ZOMBIE ( CONTROL + 3 )
+#define UFOAD ( CONTROL + 4 )
+#define IWAIT ( CONTROL + 5 )
+
+#define IFOAD_MAGIC 0xF0AD /* of course */
+#define ZOMBIE_MAGIC (~0xDEAD) /* not dead -> zombie */
+#define UFOAD_MAGIC 0xD1E /* kill-your-neighbour */
+#define IWAIT_MAGIC 0xB1DE /* Bide your time */
+
+/* ------ Error Codes ------ */
+
+#define E_NO_ERROR ((ushort) 0)
+
+/* ------ Free Lists ------ */
-#define RIO_IO_UNKNOWN -2
+struct rio_free_list {
+ u16 next;
+ u16 prev;
+};
-#undef MODERN
-#define ERROR( E ) do { u.u_error = E; return OPENFAIL } while ( 0 )
+/* NULL for card side linked lists */
+#define TPNULL ((ushort)(0x8000))
+/* We can add another packet to a transmit queue if the packet pointer pointed
+ * to by the TxAdd pointer has PKT_IN_USE clear in its address. */
+#define PKT_IN_USE 0x1
-/* Defines for MPX line discipline routines */
+/* ------ Topology ------ */
-#define DIST_LINESW_OPEN 0x01
-#define DIST_LINESW_CLOSE 0x02
-#define DIST_LINESW_READ 0x04
-#define DIST_LINESW_WRITE 0x08
-#define DIST_LINESW_IOCTL 0x10
-#define DIST_LINESW_INPUT 0x20
-#define DIST_LINESW_OUTPUT 0x40
-#define DIST_LINESW_MDMINT 0x80
+struct Top {
+ u8 Unit;
+ u8 Link;
+};
#endif /* __rio_h__ */
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c
index c9af283a811..78dd856534c 100644
--- a/drivers/char/rio/rio_linux.c
+++ b/drivers/char/rio/rio_linux.c
@@ -57,15 +57,12 @@
#include <asm/uaccess.h>
#include "linux_compat.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -78,17 +75,13 @@
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "param.h"
-#include "list.h"
-#include "sam.h"
#include "protsts.h"
#include "rioboard.h"
@@ -297,7 +290,7 @@ static void my_hd(void *ad, int len)
unsigned char *addr = ad;
for (i = 0; i < len; i += 16) {
- rio_dprintk(RIO_DEBUG_PARAM, "%08x ", (int) addr + i);
+ rio_dprintk(RIO_DEBUG_PARAM, "%08lx ", (unsigned long) addr + i);
for (j = 0; j < 16; j++) {
rio_dprintk(RIO_DEBUG_PARAM, "%02x %s", addr[j + i], (j == 7) ? " " : "");
}
@@ -340,34 +333,19 @@ int RIODelay_ni(struct Port *PortP, int njiffies)
return !RIO_FAIL;
}
-
-int rio_minor(struct tty_struct *tty)
+void rio_copy_to_card(void *to, void *from, int len)
{
- return tty->index + (tty->driver == rio_driver) ? 0 : 256;
+ rio_memcpy_toio(NULL, to, from, len);
}
-
-int rio_ismodem(struct tty_struct *tty)
+int rio_minor(struct tty_struct *tty)
{
- return 1;
+ return tty->index + (tty->driver == rio_driver) ? 0 : 256;
}
-
static int rio_set_real_termios(void *ptr)
{
- int rv, modem;
- struct tty_struct *tty;
- func_enter();
-
- tty = ((struct Port *) ptr)->gs.tty;
-
- modem = rio_ismodem(tty);
-
- rv = RIOParam((struct Port *) ptr, CONFIG, modem, 1);
-
- func_exit();
-
- return rv;
+ return RIOParam((struct Port *) ptr, CONFIG, 1, 1);
}
@@ -379,7 +357,7 @@ static void rio_reset_interrupt(struct Host *HostP)
case RIO_AT:
case RIO_MCA:
case RIO_PCI:
- WBYTE(HostP->ResetInt, 0xff);
+ writeb(0xFF, &HostP->ResetInt);
}
func_exit();
@@ -397,9 +375,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
/* AAargh! The order in which to do these things is essential and
not trivial.
- - Rate limit goes before "recursive". Otherwise a series of
- recursive calls will hang the machine in the interrupt routine.
-
- hardware twiddling goes before "recursive". Otherwise when we
poll the card, and a recursive interrupt happens, we won't
ack the card, so it might keep on interrupting us. (especially
@@ -414,26 +389,6 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
- The initialized test goes before recursive.
*/
-
-
-#ifdef IRQ_RATE_LIMIT
- /* Aaargh! I'm ashamed. This costs more lines-of-code than the
- actual interrupt routine!. (Well, used to when I wrote that comment) */
- {
- static int lastjif;
- static int nintr = 0;
-
- if (lastjif == jiffies) {
- if (++nintr > IRQ_RATE_LIMIT) {
- free_irq(HostP->Ivec, ptr);
- printk(KERN_ERR "rio: Too many interrupts. Turning off interrupt %d.\n", HostP->Ivec);
- }
- } else {
- lastjif = jiffies;
- nintr = 0;
- }
- }
-#endif
rio_dprintk(RIO_DEBUG_IFLOW, "rio: We've have noticed the interrupt\n");
if (HostP->Ivec == irq) {
/* Tell the card we've noticed the interrupt. */
@@ -444,13 +399,13 @@ static irqreturn_t rio_interrupt(int irq, void *ptr, struct pt_regs *regs)
return IRQ_HANDLED;
if (test_and_set_bit(RIO_BOARD_INTR_LOCK, &HostP->locks)) {
- printk(KERN_ERR "Recursive interrupt! (host %d/irq%d)\n", (int) ptr, HostP->Ivec);
+ printk(KERN_ERR "Recursive interrupt! (host %p/irq%d)\n", ptr, HostP->Ivec);
return IRQ_HANDLED;
}
RIOServiceHost(p, HostP, irq);
- rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %d type %d\n", (int) ptr, HostP->Type);
+ rio_dprintk(RIO_DEBUG_IFLOW, "riointr() doing host %p type %d\n", ptr, HostP->Type);
clear_bit(RIO_BOARD_INTR_LOCK, &HostP->locks);
rio_dprintk(RIO_DEBUG_IFLOW, "rio: exit rio_interrupt (%d/%d)\n", irq, HostP->Ivec);
@@ -873,7 +828,7 @@ static int rio_init_datastructures(void)
#define HOST_SZ sizeof(struct Host)
#define PORT_SZ sizeof(struct Port *)
#define TMIO_SZ sizeof(struct termios *)
- rio_dprintk(RIO_DEBUG_INIT, "getting : %d %d %d %d %d bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
+ rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ);
if (!(p = ckmalloc(RI_SZ)))
goto free0;
@@ -963,22 +918,21 @@ static void __exit rio_release_drivers(void)
static void fix_rio_pci(struct pci_dev *pdev)
{
- unsigned int hwbase;
- unsigned long rebase;
+ unsigned long hwbase;
+ unsigned char *rebase;
unsigned int t;
#define CNTRL_REG_OFFSET 0x50
#define CNTRL_REG_GOODVALUE 0x18260000
- pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &hwbase);
- hwbase &= PCI_BASE_ADDRESS_MEM_MASK;
- rebase = (ulong) ioremap(hwbase, 0x80);
+ hwbase = pci_resource_start(pdev, 0);
+ rebase = ioremap(hwbase, 0x80);
t = readl(rebase + CNTRL_REG_OFFSET);
if (t != CNTRL_REG_GOODVALUE) {
printk(KERN_DEBUG "rio: performing cntrl reg fix: %08x -> %08x\n", t, CNTRL_REG_GOODVALUE);
writel(CNTRL_REG_GOODVALUE, rebase + CNTRL_REG_OFFSET);
}
- iounmap((char *) rebase);
+ iounmap(rebase);
}
#endif
@@ -994,7 +948,6 @@ static int __init rio_init(void)
#ifdef CONFIG_PCI
struct pci_dev *pdev = NULL;
- unsigned int tint;
unsigned short tshort;
#endif
@@ -1019,6 +972,8 @@ static int __init rio_init(void)
#ifdef CONFIG_PCI
/* First look for the JET devices: */
while ((pdev = pci_get_device(PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) {
+ u32 tint;
+
if (pci_enable_device(pdev))
continue;
@@ -1029,7 +984,6 @@ static int __init rio_init(void)
Also, reading a non-aligned dword doesn't work. So we read the
whole dword at 0x2c and extract the word at 0x2e (SUBSYSTEM_ID)
ourselves */
- /* I don't know why the define doesn't work, constant 0x2c does --REW */
pci_read_config_dword(pdev, 0x2c, &tint);
tshort = (tint >> 16) & 0xffff;
rio_dprintk(RIO_DEBUG_PROBE, "Got a specialix card: %x.\n", tint);
@@ -1039,33 +993,31 @@ static int __init rio_init(void)
}
rio_dprintk(RIO_DEBUG_PROBE, "cp1\n");
- pci_read_config_dword(pdev, PCI_BASE_ADDRESS_2, &tint);
-
hp = &p->RIOHosts[p->RIONumHosts];
- hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
+ hp->PaddrP = pci_resource_start(pdev, 2);
hp->Ivec = pdev->irq;
if (((1 << hp->Ivec) & rio_irqmask) == 0)
hp->Ivec = 0;
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->Type = RIO_PCI;
- hp->Copy = rio_pcicopy;
+ hp->Copy = rio_copy_to_card;
hp->Mode = RIO_PCI_BOOT_FROM_RAM;
spin_lock_init(&hp->HostLock);
rio_reset_interrupt(hp);
rio_start_card_running(hp);
rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
- if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
+ if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
rio_dprintk(RIO_DEBUG_INIT, "Done RIOBoardTest\n");
- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
+ writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
p->RIOHosts[p->RIONumHosts].UniqueNum =
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
fix_rio_pci(pdev);
- p->RIOLastPCISearch = RIO_SUCCESS;
+ p->RIOLastPCISearch = 0;
p->RIONumHosts++;
found++;
} else {
@@ -1088,10 +1040,8 @@ static int __init rio_init(void)
continue;
#ifdef CONFIG_RIO_OLDPCI
- pci_read_config_dword(pdev, PCI_BASE_ADDRESS_0, &tint);
-
hp = &p->RIOHosts[p->RIONumHosts];
- hp->PaddrP = tint & PCI_BASE_ADDRESS_MEM_MASK;
+ hp->PaddrP = pci_resource_start(pdev, 0);
hp->Ivec = pdev->irq;
if (((1 << hp->Ivec) & rio_irqmask) == 0)
hp->Ivec = 0;
@@ -1099,7 +1049,7 @@ static int __init rio_init(void)
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->Type = RIO_PCI;
- hp->Copy = rio_pcicopy;
+ hp->Copy = rio_copy_to_card;
hp->Mode = RIO_PCI_BOOT_FROM_RAM;
spin_lock_init(&hp->HostLock);
@@ -1109,14 +1059,14 @@ static int __init rio_init(void)
rio_reset_interrupt(hp);
rio_start_card_running(hp);
rio_dprintk(RIO_DEBUG_PROBE, "Going to test it (%p/%p).\n", (void *) p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr);
- if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == RIO_SUCCESS) {
- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt, 0xff);
+ if (RIOBoardTest(p->RIOHosts[p->RIONumHosts].PaddrP, p->RIOHosts[p->RIONumHosts].Caddr, RIO_PCI, 0) == 0) {
+ writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
p->RIOHosts[p->RIONumHosts].UniqueNum =
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0]) & 0xFF) << 0) |
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1]) & 0xFF) << 8) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2]) & 0xFF) << 16) | ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3]) & 0xFF) << 24);
rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
- p->RIOLastPCISearch = RIO_SUCCESS;
+ p->RIOLastPCISearch = 0;
p->RIONumHosts++;
found++;
} else {
@@ -1137,8 +1087,8 @@ static int __init rio_init(void)
hp->Caddr = ioremap(p->RIOHosts[p->RIONumHosts].PaddrP, RIO_WINDOW_LEN);
hp->CardP = (struct DpRam *) hp->Caddr;
hp->Type = RIO_AT;
- hp->Copy = rio_pcicopy; /* AT card PCI???? - PVDL
- * -- YES! this is now a normal copy. Only the
+ hp->Copy = rio_copy_to_card; /* AT card PCI???? - PVDL
+ * -- YES! this is now a normal copy. Only the
* old PCI card uses the special PCI copy.
* Moreover, the ISA card will work with the
* special PCI copy anyway. -- REW */
@@ -1150,7 +1100,7 @@ static int __init rio_init(void)
okboard = 0;
if ((strncmp(vpdp->identifier, RIO_ISA_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA2_IDENT, 16) == 0) || (strncmp(vpdp->identifier, RIO_ISA3_IDENT, 16) == 0)) {
/* Board is present... */
- if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == RIO_SUCCESS) {
+ if (RIOBoardTest(hp->PaddrP, hp->Caddr, RIO_AT, 0) == 0) {
/* ... and feeling fine!!!! */
rio_dprintk(RIO_DEBUG_PROBE, "Hmm Tested ok, uniqid = %x.\n", p->RIOHosts[p->RIONumHosts].UniqueNum);
if (RIOAssignAT(p, hp->PaddrP, hp->Caddr, 0)) {
@@ -1252,24 +1202,3 @@ static void __exit rio_exit(void)
module_init(rio_init);
module_exit(rio_exit);
-
-/*
- * Anybody who knows why this doesn't work for me, please tell me -- REW.
- * Snatched from scsi.c (fixed one spelling error):
- * Overrides for Emacs so that we follow Linus' tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only. This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local Variables:
- * c-indent-level: 4
- * c-brace-imaginary-offset: 0
- * c-brace-offset: -4
- * c-argdecl-indent: 4
- * c-label-offset: -4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: 0
- * indent-tabs-mode: nil
- * tab-width: 8
- * End:
- */
diff --git a/drivers/char/rio/rioboot.c b/drivers/char/rio/rioboot.c
index 92df43552f1..acda9326c2e 100644
--- a/drivers/char/rio/rioboot.c
+++ b/drivers/char/rio/rioboot.c
@@ -30,38 +30,29 @@
** -----------------------------------------------------------------------------
*/
-#ifdef SCCS_LABELS
-static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
-#endif
-
#include <linux/module.h>
#include <linux/slab.h>
+#include <linux/termios.h>
+#include <linux/serial.h>
+#include <asm/semaphore.h>
+#include <linux/generic_serial.h>
#include <linux/errno.h>
#include <linux/interrupt.h>
+#include <linux/delay.h>
#include <asm/io.h>
#include <asm/system.h>
#include <asm/string.h>
-#include <asm/semaphore.h>
-
-
-#include <linux/termios.h>
-#include <linux/serial.h>
-
-#include <linux/generic_serial.h>
-
+#include <asm/uaccess.h>
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -74,161 +65,130 @@ static char *_rioboot_c_sccs_ = "@(#)rioboot.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP );
-
-static uchar
-RIOAtVec2Ctrl[] =
-{
- /* 0 */ INTERRUPT_DISABLE,
- /* 1 */ INTERRUPT_DISABLE,
- /* 2 */ INTERRUPT_DISABLE,
- /* 3 */ INTERRUPT_DISABLE,
- /* 4 */ INTERRUPT_DISABLE,
- /* 5 */ INTERRUPT_DISABLE,
- /* 6 */ INTERRUPT_DISABLE,
- /* 7 */ INTERRUPT_DISABLE,
- /* 8 */ INTERRUPT_DISABLE,
- /* 9 */ IRQ_9|INTERRUPT_ENABLE,
+static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP);
+
+static const unsigned char RIOAtVec2Ctrl[] = {
+ /* 0 */ INTERRUPT_DISABLE,
+ /* 1 */ INTERRUPT_DISABLE,
+ /* 2 */ INTERRUPT_DISABLE,
+ /* 3 */ INTERRUPT_DISABLE,
+ /* 4 */ INTERRUPT_DISABLE,
+ /* 5 */ INTERRUPT_DISABLE,
+ /* 6 */ INTERRUPT_DISABLE,
+ /* 7 */ INTERRUPT_DISABLE,
+ /* 8 */ INTERRUPT_DISABLE,
+ /* 9 */ IRQ_9 | INTERRUPT_ENABLE,
/* 10 */ INTERRUPT_DISABLE,
- /* 11 */ IRQ_11|INTERRUPT_ENABLE,
- /* 12 */ IRQ_12|INTERRUPT_ENABLE,
+ /* 11 */ IRQ_11 | INTERRUPT_ENABLE,
+ /* 12 */ IRQ_12 | INTERRUPT_ENABLE,
/* 13 */ INTERRUPT_DISABLE,
/* 14 */ INTERRUPT_DISABLE,
- /* 15 */ IRQ_15|INTERRUPT_ENABLE
+ /* 15 */ IRQ_15 | INTERRUPT_ENABLE
};
-/*
-** Load in the RTA boot code.
-*/
-int
-RIOBootCodeRTA(p, rbp)
-struct rio_info * p;
-struct DownLoad * rbp;
+/**
+ * RIOBootCodeRTA - Load RTA boot code
+ * @p: RIO to load
+ * @rbp: Download descriptor
+ *
+ * Called when the user process initiates booting of the card firmware.
+ * Lads the firmware
+ */
+
+int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp)
{
int offset;
- func_enter ();
+ func_enter();
- /* Linux doesn't allow you to disable interrupts during a
- "copyin". (Crash when a pagefault occurs). */
- /* disable(oldspl); */
-
- rio_dprintk (RIO_DEBUG_BOOT, "Data at user address 0x%x\n",(int)rbp->DataP);
+ rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP);
/*
- ** Check that we have set asside enough memory for this
- */
- if ( rbp->Count > SIXTY_FOUR_K ) {
- rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
+ ** Check that we have set asside enough memory for this
+ */
+ if (rbp->Count > SIXTY_FOUR_K) {
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n");
p->RIOError.Error = HOST_FILE_TOO_LARGE;
- /* restore(oldspl); */
- func_exit ();
+ func_exit();
return -ENOMEM;
}
- if ( p->RIOBooting ) {
- rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
+ if (p->RIOBooting) {
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n");
p->RIOError.Error = BOOT_IN_PROGRESS;
- /* restore(oldspl); */
- func_exit ();
+ func_exit();
return -EBUSY;
}
/*
- ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
- ** so calculate how far we have to move the data up the buffer
- ** to achieve this.
- */
- offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) %
- RTA_BOOT_DATA_SIZE;
+ ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary,
+ ** so calculate how far we have to move the data up the buffer
+ ** to achieve this.
+ */
+ offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE;
/*
- ** Be clean, and clear the 'unused' portion of the boot buffer,
- ** because it will (eventually) be part of the Rta run time environment
- ** and so should be zeroed.
- */
- bzero( (caddr_t)p->RIOBootPackets, offset );
+ ** Be clean, and clear the 'unused' portion of the boot buffer,
+ ** because it will (eventually) be part of the Rta run time environment
+ ** and so should be zeroed.
+ */
+ memset(p->RIOBootPackets, 0, offset);
/*
- ** Copy the data from user space.
- */
+ ** Copy the data from user space into the array
+ */
- if ( copyin((int)rbp->DataP,((caddr_t)(p->RIOBootPackets))+offset,
- rbp->Count) ==COPYFAIL ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Bad data copy from user space\n");
+ if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n");
p->RIOError.Error = COPYIN_FAILED;
- /* restore(oldspl); */
- func_exit ();
+ func_exit();
return -EFAULT;
}
/*
- ** Make sure that our copy of the size includes that offset we discussed
- ** earlier.
- */
- p->RIONumBootPkts = (rbp->Count+offset)/RTA_BOOT_DATA_SIZE;
- p->RIOBootCount = rbp->Count;
+ ** Make sure that our copy of the size includes that offset we discussed
+ ** earlier.
+ */
+ p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE;
+ p->RIOBootCount = rbp->Count;
- /* restore(oldspl); */
func_exit();
return 0;
}
-void rio_start_card_running (struct Host * HostP)
-{
- func_enter ();
+/**
+ * rio_start_card_running - host card start
+ * @HostP: The RIO to kick off
+ *
+ * Start a RIO processor unit running. Encapsulates the knowledge
+ * of the card type.
+ */
- switch ( HostP->Type ) {
+void rio_start_card_running(struct Host *HostP)
+{
+ switch (HostP->Type) {
case RIO_AT:
- rio_dprintk (RIO_DEBUG_BOOT, "Start ISA card running\n");
- WBYTE(HostP->Control,
- BOOT_FROM_RAM | EXTERNAL_BUS_ON
- | HostP->Mode
- | RIOAtVec2Ctrl[HostP->Ivec & 0xF] );
- break;
-
-#ifdef FUTURE_RELEASE
- case RIO_MCA:
- /*
- ** MCA handles IRQ vectors differently, so we don't write
- ** them to this register.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Start MCA card running\n");
- WBYTE(HostP->Control, McaTpBootFromRam | McaTpBusEnable | HostP->Mode);
+ rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n");
+ writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control);
break;
-
- case RIO_EISA:
- /*
- ** EISA is totally different and expects OUTBZs to turn it on.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Start EISA card running\n");
- OUTBZ( HostP->Slot, EISA_CONTROL_PORT, HostP->Mode | RIOEisaVec2Ctrl[HostP->Ivec] | EISA_TP_RUN | EISA_TP_BUS_ENABLE | EISA_TP_BOOT_FROM_RAM );
- break;
-#endif
-
case RIO_PCI:
- /*
- ** PCI is much the same as MCA. Everything is once again memory
- ** mapped, so we are writing to memory registers instead of io
- ** ports.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Start PCI card running\n");
- WBYTE(HostP->Control, PCITpBootFromRam | PCITpBusEnable | HostP->Mode);
+ /*
+ ** PCI is much the same as MCA. Everything is once again memory
+ ** mapped, so we are writing to memory registers instead of io
+ ** ports.
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n");
+ writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control);
break;
default:
- rio_dprintk (RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
+ rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type);
break;
}
-/*
- printk (KERN_INFO "Done with starting the card\n");
- func_exit ();
-*/
return;
}
@@ -239,370 +199,350 @@ void rio_start_card_running (struct Host * HostP)
** Put your rubber pants on before messing with this code - even the magic
** numbers have trouble understanding what they are doing here.
*/
-int
-RIOBootCodeHOST(p, rbp)
-struct rio_info * p;
-register struct DownLoad *rbp;
+
+int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp)
{
- register struct Host *HostP;
- register caddr_t Cad;
- register PARM_MAP *ParmMapP;
- register int RupN;
+ struct Host *HostP;
+ u8 *Cad;
+ PARM_MAP *ParmMapP;
+ int RupN;
int PortN;
- uint host;
- caddr_t StartP;
- BYTE *DestP;
+ unsigned int host;
+ u8 *StartP;
+ u8 *DestP;
int wait_count;
- ushort OldParmMap;
- ushort offset; /* It is very important that this is a ushort */
- /* uint byte; */
- caddr_t DownCode = NULL;
+ u16 OldParmMap;
+ u16 offset; /* It is very important that this is a u16 */
+ u8 *DownCode = NULL;
unsigned long flags;
- HostP = NULL; /* Assure the compiler we've initialized it */
- for ( host=0; host<p->RIONumHosts; host++ ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Attempt to boot host %d\n",host);
+ HostP = NULL; /* Assure the compiler we've initialized it */
+
+
+ /* Walk the hosts */
+ for (host = 0; host < p->RIONumHosts; host++) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host);
HostP = &p->RIOHosts[host];
-
- rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n",
- HostP->Type, HostP->Mode, HostP->Ivec);
+ rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
- if ( (HostP->Flags & RUN_STATE) != RC_WAITING ) {
- rio_dprintk (RIO_DEBUG_BOOT, "%s %d already running\n","Host",host);
+ /* Don't boot hosts already running */
+ if ((HostP->Flags & RUN_STATE) != RC_WAITING) {
+ rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host);
continue;
}
/*
- ** Grab a 32 bit pointer to the card.
- */
+ ** Grab a pointer to the card (ioremapped)
+ */
Cad = HostP->Caddr;
/*
- ** We are going to (try) and load in rbp->Count bytes.
- ** The last byte will reside at p->RIOConf.HostLoadBase-1;
- ** Therefore, we need to start copying at address
- ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
- */
- StartP = (caddr_t)&Cad[p->RIOConf.HostLoadBase-rbp->Count];
-
- rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for host is 0x%x\n", (int)Cad );
- rio_dprintk (RIO_DEBUG_BOOT, "kernel virtual address for download is 0x%x\n", (int)StartP);
- rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase);
- rio_dprintk (RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
-
- if ( p->RIOConf.HostLoadBase < rbp->Count ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Bin too large\n");
+ ** We are going to (try) and load in rbp->Count bytes.
+ ** The last byte will reside at p->RIOConf.HostLoadBase-1;
+ ** Therefore, we need to start copying at address
+ ** (caddr+p->RIOConf.HostLoadBase-rbp->Count)
+ */
+ StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count];
+
+ rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad);
+ rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP);
+ rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
+ rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count);
+
+ /* Make sure it fits */
+ if (p->RIOConf.HostLoadBase < rbp->Count) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n");
p->RIOError.Error = HOST_FILE_TOO_LARGE;
- func_exit ();
+ func_exit();
return -EFBIG;
}
/*
- ** Ensure that the host really is stopped.
- ** Disable it's external bus & twang its reset line.
- */
- RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
-
- /*
- ** Copy the data directly from user space to the SRAM.
- ** This ain't going to be none too clever if the download
- ** code is bigger than this segment.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Copy in code\n");
+ ** Ensure that the host really is stopped.
+ ** Disable it's external bus & twang its reset line.
+ */
+ RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot);
/*
- ** PCI hostcard can't cope with 32 bit accesses and so need to copy
- ** data to a local buffer, and then dripfeed the card.
- */
- if ( HostP->Type == RIO_PCI ) {
- /* int offset; */
-
- DownCode = sysbrk(rbp->Count);
- if ( !DownCode ) {
- rio_dprintk (RIO_DEBUG_BOOT, "No system memory available\n");
- p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
- func_exit ();
- return -ENOMEM;
- }
- bzero(DownCode, rbp->Count);
-
- if ( copyin((int)rbp->DataP,DownCode,rbp->Count)==COPYFAIL ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
- sysfree( DownCode, rbp->Count );
- p->RIOError.Error = COPYIN_FAILED;
- func_exit ();
- return -EFAULT;
- }
-
- HostP->Copy( DownCode, StartP, rbp->Count );
-
- sysfree( DownCode, rbp->Count );
+ ** Copy the data directly from user space to the SRAM.
+ ** This ain't going to be none too clever if the download
+ ** code is bigger than this segment.
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n");
+
+ /* Buffer to local memory as we want to use I/O space and
+ some cards only do 8 or 16 bit I/O */
+
+ DownCode = vmalloc(rbp->Count);
+ if (!DownCode) {
+ p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY;
+ func_exit();
+ return -ENOMEM;
}
- else if ( copyin((int)rbp->DataP,StartP,rbp->Count)==COPYFAIL ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Bad copyin of host data\n");
+ if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) {
+ kfree(DownCode);
p->RIOError.Error = COPYIN_FAILED;
- func_exit ();
+ func_exit();
return -EFAULT;
}
+ HostP->Copy(DownCode, StartP, rbp->Count);
+ vfree(DownCode);
- rio_dprintk (RIO_DEBUG_BOOT, "Copy completed\n");
+ rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n");
/*
- ** S T O P !
- **
- ** Upto this point the code has been fairly rational, and possibly
- ** even straight forward. What follows is a pile of crud that will
- ** magically turn into six bytes of transputer assembler. Normally
- ** you would expect an array or something, but, being me, I have
- ** chosen [been told] to use a technique whereby the startup code
- ** will be correct if we change the loadbase for the code. Which
- ** brings us onto another issue - the loadbase is the *end* of the
- ** code, not the start.
- **
- ** If I were you I wouldn't start from here.
- */
+ ** S T O P !
+ **
+ ** Upto this point the code has been fairly rational, and possibly
+ ** even straight forward. What follows is a pile of crud that will
+ ** magically turn into six bytes of transputer assembler. Normally
+ ** you would expect an array or something, but, being me, I have
+ ** chosen [been told] to use a technique whereby the startup code
+ ** will be correct if we change the loadbase for the code. Which
+ ** brings us onto another issue - the loadbase is the *end* of the
+ ** code, not the start.
+ **
+ ** If I were you I wouldn't start from here.
+ */
/*
- ** We now need to insert a short boot section into
- ** the memory at the end of Sram2. This is normally (de)composed
- ** of the last eight bytes of the download code. The
- ** download has been assembled/compiled to expect to be
- ** loaded from 0x7FFF downwards. We have loaded it
- ** at some other address. The startup code goes into the small
- ** ram window at Sram2, in the last 8 bytes, which are really
- ** at addresses 0x7FF8-0x7FFF.
- **
- ** If the loadbase is, say, 0x7C00, then we need to branch to
- ** address 0x7BFE to run the host.bin startup code. We assemble
- ** this jump manually.
- **
- ** The two byte sequence 60 08 is loaded into memory at address
- ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
- ** which adds '0' to the .O register, complements .O, and then shifts
- ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
- ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
- ** location. Now, the branch starts from the value of .PC (or .IP or
- ** whatever the bloody register is called on this chip), and the .PC
- ** will be pointing to the location AFTER the branch, in this case
- ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
- **
- ** A long branch is coded at 0x7FF8. This consists of loading a four
- ** byte offset into .O using nfix (as above) and pfix operators. The
- ** pfix operates in exactly the same way as the nfix operator, but
- ** without the complement operation. The offset, of course, must be
- ** relative to the address of the byte AFTER the branch instruction,
- ** which will be (urm) 0x7FFC, so, our final destination of the branch
- ** (loadbase-2), has to be reached from here. Imagine that the loadbase
- ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
- ** is the first byte of the initial two byte short local branch of the
- ** download code).
- **
- ** To code a jump from 0x7FFC (which is where the branch will start
- ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
- ** 0x7BFE.
- ** This will be coded as four bytes:
- ** 60 2C 20 02
- ** being nfix .O+0
- ** pfix .O+C
- ** pfix .O+0
- ** jump .O+2
- **
- ** The nfix operator is used, so that the startup code will be
- ** compatible with the whole Tp family. (lies, damn lies, it'll never
- ** work in a month of Sundays).
- **
- ** The nfix nyble is the 1s complement of the nyble value you
- ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
- */
+ ** We now need to insert a short boot section into
+ ** the memory at the end of Sram2. This is normally (de)composed
+ ** of the last eight bytes of the download code. The
+ ** download has been assembled/compiled to expect to be
+ ** loaded from 0x7FFF downwards. We have loaded it
+ ** at some other address. The startup code goes into the small
+ ** ram window at Sram2, in the last 8 bytes, which are really
+ ** at addresses 0x7FF8-0x7FFF.
+ **
+ ** If the loadbase is, say, 0x7C00, then we need to branch to
+ ** address 0x7BFE to run the host.bin startup code. We assemble
+ ** this jump manually.
+ **
+ ** The two byte sequence 60 08 is loaded into memory at address
+ ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0,
+ ** which adds '0' to the .O register, complements .O, and then shifts
+ ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will
+ ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new
+ ** location. Now, the branch starts from the value of .PC (or .IP or
+ ** whatever the bloody register is called on this chip), and the .PC
+ ** will be pointing to the location AFTER the branch, in this case
+ ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8.
+ **
+ ** A long branch is coded at 0x7FF8. This consists of loading a four
+ ** byte offset into .O using nfix (as above) and pfix operators. The
+ ** pfix operates in exactly the same way as the nfix operator, but
+ ** without the complement operation. The offset, of course, must be
+ ** relative to the address of the byte AFTER the branch instruction,
+ ** which will be (urm) 0x7FFC, so, our final destination of the branch
+ ** (loadbase-2), has to be reached from here. Imagine that the loadbase
+ ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which
+ ** is the first byte of the initial two byte short local branch of the
+ ** download code).
+ **
+ ** To code a jump from 0x7FFC (which is where the branch will start
+ ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)=
+ ** 0x7BFE.
+ ** This will be coded as four bytes:
+ ** 60 2C 20 02
+ ** being nfix .O+0
+ ** pfix .O+C
+ ** pfix .O+0
+ ** jump .O+2
+ **
+ ** The nfix operator is used, so that the startup code will be
+ ** compatible with the whole Tp family. (lies, damn lies, it'll never
+ ** work in a month of Sundays).
+ **
+ ** The nfix nyble is the 1s complement of the nyble value you
+ ** want to load - in this case we wanted 'F' so we nfix loaded '0'.
+ */
/*
- ** Dest points to the top 8 bytes of Sram2. The Tp jumps
- ** to 0x7FFE at reset time, and starts executing. This is
- ** a short branch to 0x7FF8, where a long branch is coded.
- */
+ ** Dest points to the top 8 bytes of Sram2. The Tp jumps
+ ** to 0x7FFE at reset time, and starts executing. This is
+ ** a short branch to 0x7FF8, where a long branch is coded.
+ */
- DestP = (BYTE *)&Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
+ DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */
#define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */
#define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */
-#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
+#define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */
/*
- ** 0x7FFC is the address of the location following the last byte of
- ** the four byte jump instruction.
- ** READ THE ABOVE COMMENTS
- **
- ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
- ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
- ** cos I don't understand 2's complement).
- */
- offset = (p->RIOConf.HostLoadBase-2)-0x7FFC;
- WBYTE( DestP[0] , NFIX(((ushort)(~offset) >> (ushort)12) & 0xF) );
- WBYTE( DestP[1] , PFIX(( offset >> 8) & 0xF) );
- WBYTE( DestP[2] , PFIX(( offset >> 4) & 0xF) );
- WBYTE( DestP[3] , JUMP( offset & 0xF) );
-
- WBYTE( DestP[6] , NFIX(0) );
- WBYTE( DestP[7] , JUMP(8) );
-
- rio_dprintk (RIO_DEBUG_BOOT, "host loadbase is 0x%x\n",p->RIOConf.HostLoadBase);
- rio_dprintk (RIO_DEBUG_BOOT, "startup offset is 0x%x\n",offset);
+ ** 0x7FFC is the address of the location following the last byte of
+ ** the four byte jump instruction.
+ ** READ THE ABOVE COMMENTS
+ **
+ ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about.
+ ** Memsize is 64K for this range of Tp, so offset is a short (unsigned,
+ ** cos I don't understand 2's complement).
+ */
+ offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC;
+
+ writeb(NFIX(((unsigned short) (~offset) >> (unsigned short) 12) & 0xF), DestP);
+ writeb(PFIX((offset >> 8) & 0xF), DestP + 1);
+ writeb(PFIX((offset >> 4) & 0xF), DestP + 2);
+ writeb(JUMP(offset & 0xF), DestP + 3);
+
+ writeb(NFIX(0), DestP + 6);
+ writeb(JUMP(8), DestP + 7);
+
+ rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase);
+ rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset);
/*
- ** Flag what is going on
- */
+ ** Flag what is going on
+ */
HostP->Flags &= ~RUN_STATE;
HostP->Flags |= RC_STARTUP;
/*
- ** Grab a copy of the current ParmMap pointer, so we
- ** can tell when it has changed.
- */
- OldParmMap = RWORD(HostP->__ParmMapR);
+ ** Grab a copy of the current ParmMap pointer, so we
+ ** can tell when it has changed.
+ */
+ OldParmMap = readw(&HostP->__ParmMapR);
- rio_dprintk (RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n",OldParmMap);
+ rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap);
/*
- ** And start it running (I hope).
- ** As there is nothing dodgy or obscure about the
- ** above code, this is guaranteed to work every time.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n",
- HostP->Type, HostP->Mode, HostP->Ivec);
+ ** And start it running (I hope).
+ ** As there is nothing dodgy or obscure about the
+ ** above code, this is guaranteed to work every time.
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec);
rio_start_card_running(HostP);
- rio_dprintk (RIO_DEBUG_BOOT, "Set control port\n");
+ rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n");
/*
- ** Now, wait for upto five seconds for the Tp to setup the parmmap
- ** pointer:
- */
- for ( wait_count=0; (wait_count<p->RIOConf.StartupTime)&&
- (RWORD(HostP->__ParmMapR)==OldParmMap); wait_count++ ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n",wait_count,RWORD(HostP->__ParmMapR));
- delay(HostP, HUNDRED_MS);
+ ** Now, wait for upto five seconds for the Tp to setup the parmmap
+ ** pointer:
+ */
+ for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR));
+ mdelay(100);
}
/*
- ** If the parmmap pointer is unchanged, then the host code
- ** has crashed & burned in a really spectacular way
- */
- if ( RWORD(HostP->__ParmMapR) == OldParmMap ) {
- rio_dprintk (RIO_DEBUG_BOOT, "parmmap 0x%x\n", RWORD(HostP->__ParmMapR));
- rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
-
-#define HOST_DISABLE \
- HostP->Flags &= ~RUN_STATE; \
- HostP->Flags |= RC_STUFFED; \
- RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );\
- continue
-
- HOST_DISABLE;
+ ** If the parmmap pointer is unchanged, then the host code
+ ** has crashed & burned in a really spectacular way
+ */
+ if (readw(&HostP->__ParmMapR) == OldParmMap) {
+ rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR));
+ rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n");
+ HostP->Flags &= ~RUN_STATE;
+ HostP->Flags |= RC_STUFFED;
+ RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
+ continue;
}
- rio_dprintk (RIO_DEBUG_BOOT, "Running 0x%x\n", RWORD(HostP->__ParmMapR));
+ rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR));
/*
- ** Well, the board thought it was OK, and setup its parmmap
- ** pointer. For the time being, we will pretend that this
- ** board is running, and check out what the error flag says.
- */
+ ** Well, the board thought it was OK, and setup its parmmap
+ ** pointer. For the time being, we will pretend that this
+ ** board is running, and check out what the error flag says.
+ */
/*
- ** Grab a 32 bit pointer to the parmmap structure
- */
- ParmMapP = (PARM_MAP *)RIO_PTR(Cad,RWORD(HostP->__ParmMapR));
- rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP);
- ParmMapP = (PARM_MAP *)((unsigned long)Cad +
- (unsigned long)((RWORD((HostP->__ParmMapR))) & 0xFFFF));
- rio_dprintk (RIO_DEBUG_BOOT, "ParmMapP : %x\n", (int)ParmMapP);
+ ** Grab a 32 bit pointer to the parmmap structure
+ */
+ ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR));
+ rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
+ ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR));
+ rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP);
/*
- ** The links entry should be 0xFFFF; we set it up
- ** with a mask to say how many PHBs to use, and
- ** which links to use.
- */
- if ( (RWORD(ParmMapP->links) & 0xFFFF) != 0xFFFF ) {
- rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
- rio_dprintk (RIO_DEBUG_BOOT, "Links = 0x%x\n",RWORD(ParmMapP->links));
- HOST_DISABLE;
+ ** The links entry should be 0xFFFF; we set it up
+ ** with a mask to say how many PHBs to use, and
+ ** which links to use.
+ */
+ if (readw(&ParmMapP->links) != 0xFFFF) {
+ rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
+ rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links));
+ HostP->Flags &= ~RUN_STATE;
+ HostP->Flags |= RC_STUFFED;
+ RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
+ continue;
}
- WWORD(ParmMapP->links , RIO_LINK_ENABLE);
+ writew(RIO_LINK_ENABLE, &ParmMapP->links);
/*
- ** now wait for the card to set all the parmmap->XXX stuff
- ** this is a wait of upto two seconds....
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n",p->RIOConf.StartupTime);
+ ** now wait for the card to set all the parmmap->XXX stuff
+ ** this is a wait of upto two seconds....
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime);
HostP->timeout_id = 0;
- for ( wait_count=0; (wait_count<p->RIOConf.StartupTime) &&
- !RWORD(ParmMapP->init_done); wait_count++ ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Waiting for init_done\n");
- delay(HostP, HUNDRED_MS);
+ for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n");
+ mdelay(100);
}
- rio_dprintk (RIO_DEBUG_BOOT, "OK! init_done!\n");
-
- if (RWORD(ParmMapP->error) != E_NO_ERROR ||
- !RWORD(ParmMapP->init_done) ) {
- rio_dprintk (RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
- rio_dprintk (RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
- HOST_DISABLE;
+ rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n");
+
+ if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) {
+ rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name);
+ rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n");
+ HostP->Flags &= ~RUN_STATE;
+ HostP->Flags |= RC_STUFFED;
+ RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot );
+ continue;
}
- rio_dprintk (RIO_DEBUG_BOOT, "Got init_done\n");
+ rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n");
/*
- ** It runs! It runs!
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Host ID %x Running\n",HostP->UniqueNum);
+ ** It runs! It runs!
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum);
/*
- ** set the time period between interrupts.
- */
- WWORD(ParmMapP->timer, (short)p->RIOConf.Timer );
+ ** set the time period between interrupts.
+ */
+ writew(p->RIOConf.Timer, &ParmMapP->timer);
/*
- ** Translate all the 16 bit pointers in the __ParmMapR into
- ** 32 bit pointers for the driver.
- */
- HostP->ParmMapP = ParmMapP;
- HostP->PhbP = (PHB*)RIO_PTR(Cad,RWORD(ParmMapP->phb_ptr));
- HostP->RupP = (RUP*)RIO_PTR(Cad,RWORD(ParmMapP->rups));
- HostP->PhbNumP = (ushort*)RIO_PTR(Cad,RWORD(ParmMapP->phb_num_ptr));
- HostP->LinkStrP = (LPB*)RIO_PTR(Cad,RWORD(ParmMapP->link_str_ptr));
+ ** Translate all the 16 bit pointers in the __ParmMapR into
+ ** 32 bit pointers for the driver in ioremap space.
+ */
+ HostP->ParmMapP = ParmMapP;
+ HostP->PhbP = (struct PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr));
+ HostP->RupP = (struct RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups));
+ HostP->PhbNumP = (unsigned short *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr));
+ HostP->LinkStrP = (struct LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr));
/*
- ** point the UnixRups at the real Rups
- */
- for ( RupN = 0; RupN<MAX_RUP; RupN++ ) {
- HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
- HostP->UnixRups[RupN].Id = RupN+1;
+ ** point the UnixRups at the real Rups
+ */
+ for (RupN = 0; RupN < MAX_RUP; RupN++) {
+ HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN];
+ HostP->UnixRups[RupN].Id = RupN + 1;
HostP->UnixRups[RupN].BaseSysPort = NO_PORT;
spin_lock_init(&HostP->UnixRups[RupN].RupLock);
}
- for ( RupN = 0; RupN<LINKS_PER_UNIT; RupN++ ) {
- HostP->UnixRups[RupN+MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
- HostP->UnixRups[RupN+MAX_RUP].Id = 0;
- HostP->UnixRups[RupN+MAX_RUP].BaseSysPort = NO_PORT;
- spin_lock_init(&HostP->UnixRups[RupN+MAX_RUP].RupLock);
+ for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) {
+ HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup;
+ HostP->UnixRups[RupN + MAX_RUP].Id = 0;
+ HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT;
+ spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock);
}
/*
- ** point the PortP->Phbs at the real Phbs
- */
- for ( PortN=p->RIOFirstPortsMapped;
- PortN<p->RIOLastPortsMapped+PORTS_PER_RTA; PortN++ ) {
- if ( p->RIOPortp[PortN]->HostP == HostP ) {
+ ** point the PortP->Phbs at the real Phbs
+ */
+ for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) {
+ if (p->RIOPortp[PortN]->HostP == HostP) {
struct Port *PortP = p->RIOPortp[PortN];
struct PHB *PhbP;
/* int oldspl; */
- if ( !PortP->Mapped )
+ if (!PortP->Mapped)
continue;
PhbP = &HostP->PhbP[PortP->HostPort];
@@ -610,641 +550,522 @@ register struct DownLoad *rbp;
PortP->PhbP = PhbP;
- PortP->TxAdd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_add));
- PortP->TxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_start));
- PortP->TxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->tx_end));
- PortP->RxRemove = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_remove));
- PortP->RxStart = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_start));
- PortP->RxEnd = (WORD *)RIO_PTR(Cad,RWORD(PhbP->rx_end));
+ PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add));
+ PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start));
+ PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end));
+ PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove));
+ PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start));
+ PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end));
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
/*
- ** point the UnixRup at the base SysPort
- */
- if ( !(PortN % PORTS_PER_RTA) )
+ ** point the UnixRup at the base SysPort
+ */
+ if (!(PortN % PORTS_PER_RTA))
HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN;
}
}
- rio_dprintk (RIO_DEBUG_BOOT, "Set the card running... \n");
+ rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n");
/*
- ** last thing - show the world that everything is in place
- */
+ ** last thing - show the world that everything is in place
+ */
HostP->Flags &= ~RUN_STATE;
HostP->Flags |= RC_RUNNING;
}
/*
- ** MPX always uses a poller. This is actually patched into the system
- ** configuration and called directly from each clock tick.
- **
- */
+ ** MPX always uses a poller. This is actually patched into the system
+ ** configuration and called directly from each clock tick.
+ **
+ */
p->RIOPolling = 1;
p->RIOSystemUp++;
-
- rio_dprintk (RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
- func_exit ();
+
+ rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec);
+ func_exit();
return 0;
}
-/*
-** Boot an RTA. If we have successfully processed this boot, then
-** return 1. If we havent, then return 0.
-*/
-int
-RIOBootRup( p, Rup, HostP, PacketP)
-struct rio_info * p;
-uint Rup;
-struct Host *HostP;
-struct PKT *PacketP;
+/**
+ * RIOBootRup - Boot an RTA
+ * @p: rio we are working with
+ * @Rup: Rup number
+ * @HostP: host object
+ * @PacketP: packet to use
+ *
+ * If we have successfully processed this boot, then
+ * return 1. If we havent, then return 0.
+ */
+
+int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP)
{
- struct PktCmd *PktCmdP = (struct PktCmd *)PacketP->data;
+ struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
struct PktCmd_M *PktReplyP;
struct CmdBlk *CmdBlkP;
- uint sequence;
+ unsigned int sequence;
/*
- ** If we haven't been told what to boot, we can't boot it.
- */
- if ( p->RIONumBootPkts == 0 ) {
- rio_dprintk (RIO_DEBUG_BOOT, "No RTA code to download yet\n");
+ ** If we haven't been told what to boot, we can't boot it.
+ */
+ if (p->RIONumBootPkts == 0) {
+ rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n");
return 0;
}
- /* rio_dprint(RIO_DEBUG_BOOT, NULL,DBG_BOOT,"Incoming command packet\n"); */
- /* ShowPacket( DBG_BOOT, PacketP ); */
-
/*
- ** Special case of boot completed - if we get one of these then we
- ** don't need a command block. For all other cases we do, so handle
- ** this first and then get a command block, then handle every other
- ** case, relinquishing the command block if disaster strikes!
- */
- if ( (RBYTE(PacketP->len) & PKT_CMD_BIT) &&
- (RBYTE(PktCmdP->Command)==BOOT_COMPLETED) )
- return RIOBootComplete(p, HostP, Rup, PktCmdP );
+ ** Special case of boot completed - if we get one of these then we
+ ** don't need a command block. For all other cases we do, so handle
+ ** this first and then get a command block, then handle every other
+ ** case, relinquishing the command block if disaster strikes!
+ */
+ if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED))
+ return RIOBootComplete(p, HostP, Rup, PktCmdP);
/*
- ** try to unhook a command block from the command free list.
- */
- if ( !(CmdBlkP = RIOGetCmdBlk()) ) {
- rio_dprintk (RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
+ ** Try to allocate a command block. This is in kernel space
+ */
+ if (!(CmdBlkP = RIOGetCmdBlk())) {
+ rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n");
return 0;
}
/*
- ** Fill in the default info on the command block
- */
- CmdBlkP->Packet.dest_unit = Rup < (ushort)MAX_RUP ? Rup : 0;
+ ** Fill in the default info on the command block
+ */
+ CmdBlkP->Packet.dest_unit = Rup < (unsigned short) MAX_RUP ? Rup : 0;
CmdBlkP->Packet.dest_port = BOOT_RUP;
- CmdBlkP->Packet.src_unit = 0;
- CmdBlkP->Packet.src_port = BOOT_RUP;
+ CmdBlkP->Packet.src_unit = 0;
+ CmdBlkP->Packet.src_port = BOOT_RUP;
CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL;
- PktReplyP = (struct PktCmd_M *)CmdBlkP->Packet.data;
+ PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data;
/*
- ** process COMMANDS on the boot rup!
- */
- if ( RBYTE(PacketP->len) & PKT_CMD_BIT ) {
+ ** process COMMANDS on the boot rup!
+ */
+ if (readb(&PacketP->len) & PKT_CMD_BIT) {
/*
- ** We only expect one type of command - a BOOT_REQUEST!
- */
- if ( RBYTE(PktCmdP->Command) != BOOT_REQUEST ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %d\n",
- PktCmdP->Command,Rup,HostP-p->RIOHosts);
- ShowPacket( DBG_BOOT, PacketP );
- RIOFreeCmdBlk( CmdBlkP );
+ ** We only expect one type of command - a BOOT_REQUEST!
+ */
+ if (readb(&PktCmdP->Command) != BOOT_REQUEST) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts);
+ RIOFreeCmdBlk(CmdBlkP);
return 1;
}
/*
- ** Build a Boot Sequence command block
- **
- ** 02.03.1999 ARG - ESIL 0820 fix
- ** We no longer need to use "Boot Mode", we'll always allow
- ** boot requests - the boot will not complete if the device
- ** appears in the bindings table.
- ** So, this conditional is not required ...
- **
- if (p->RIOBootMode == RC_BOOT_NONE)
- **
- ** If the system is in slave mode, and a boot request is
- ** received, set command to BOOT_ABORT so that the boot
- ** will not complete.
- **
- PktReplyP->Command = BOOT_ABORT;
- else
- **
- ** We'll just (always) set the command field in packet reply
- ** to allow an attempted boot sequence :
- */
+ ** Build a Boot Sequence command block
+ **
+ ** We no longer need to use "Boot Mode", we'll always allow
+ ** boot requests - the boot will not complete if the device
+ ** appears in the bindings table.
+ **
+ ** We'll just (always) set the command field in packet reply
+ ** to allow an attempted boot sequence :
+ */
PktReplyP->Command = BOOT_SEQUENCE;
PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts;
- PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
- PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
+ PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase;
+ PktReplyP->BootSequence.CodeSize = p->RIOBootCount;
- CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
+ CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT;
- bcopy("BOOT",(void *)&CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN],4);
+ memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4);
- rio_dprintk (RIO_DEBUG_BOOT, "Boot RTA on Host %d Rup %d - %d (0x%x) packets to 0x%x\n",
- HostP-p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts,
- p->RIOConf.RtaLoadBase);
+ rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase);
/*
- ** If this host is in slave mode, send the RTA an invalid boot
- ** sequence command block to force it to kill the boot. We wait
- ** for half a second before sending this packet to prevent the RTA
- ** attempting to boot too often. The master host should then grab
- ** the RTA and make it its own.
- */
+ ** If this host is in slave mode, send the RTA an invalid boot
+ ** sequence command block to force it to kill the boot. We wait
+ ** for half a second before sending this packet to prevent the RTA
+ ** attempting to boot too often. The master host should then grab
+ ** the RTA and make it its own.
+ */
p->RIOBooting++;
- RIOQueueCmdBlk( HostP, Rup, CmdBlkP );
+ RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
return 1;
}
/*
- ** It is a request for boot data.
- */
- sequence = RWORD(PktCmdP->Sequence);
+ ** It is a request for boot data.
+ */
+ sequence = readw(&PktCmdP->Sequence);
- rio_dprintk (RIO_DEBUG_BOOT, "Boot block %d on Host %d Rup%d\n",sequence,HostP-p->RIOHosts,Rup);
+ rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup);
- if ( sequence >= p->RIONumBootPkts ) {
- rio_dprintk (RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence,
- p->RIONumBootPkts);
- ShowPacket( DBG_BOOT, PacketP );
+ if (sequence >= p->RIONumBootPkts) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts);
}
PktReplyP->Sequence = sequence;
-
- bcopy( p->RIOBootPackets[ p->RIONumBootPkts - sequence - 1 ],
- PktReplyP->BootData, RTA_BOOT_DATA_SIZE );
-
+ memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE);
CmdBlkP->Packet.len = PKT_MAX_DATA_LEN;
- ShowPacket( DBG_BOOT, &CmdBlkP->Packet );
- RIOQueueCmdBlk( HostP, Rup, CmdBlkP );
+ RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
return 1;
}
-/*
-** This function is called when an RTA been booted.
-** If booted by a host, HostP->HostUniqueNum is the booting host.
-** If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
-** RtaUniq is the booted RTA.
-*/
-static int RIOBootComplete( struct rio_info *p, struct Host *HostP, uint Rup, struct PktCmd *PktCmdP )
+/**
+ * RIOBootComplete - RTA boot is done
+ * @p: RIO we are working with
+ * @HostP: Host structure
+ * @Rup: RUP being used
+ * @PktCmdP: Packet command that was used
+ *
+ * This function is called when an RTA been booted.
+ * If booted by a host, HostP->HostUniqueNum is the booting host.
+ * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA.
+ * RtaUniq is the booted RTA.
+ */
+
+static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP)
{
- struct Map *MapP = NULL;
- struct Map *MapP2 = NULL;
- int Flag;
- int found;
- int host, rta;
- int EmptySlot = -1;
- int entry, entry2;
- char *MyType, *MyName;
- uint MyLink;
- ushort RtaType;
- uint RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) +
- (RBYTE(PktCmdP->UniqNum[1]) << 8) +
- (RBYTE(PktCmdP->UniqNum[2]) << 16) +
- (RBYTE(PktCmdP->UniqNum[3]) << 24);
-
- /* Was RIOBooting-- . That's bad. If an RTA sends two of them, the
- driver will never think that the RTA has booted... -- REW */
+ struct Map *MapP = NULL;
+ struct Map *MapP2 = NULL;
+ int Flag;
+ int found;
+ int host, rta;
+ int EmptySlot = -1;
+ int entry, entry2;
+ char *MyType, *MyName;
+ unsigned int MyLink;
+ unsigned short RtaType;
+ u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
+
p->RIOBooting = 0;
- rio_dprintk (RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting);
/*
- ** Determine type of unit (16/8 port RTA).
- */
+ ** Determine type of unit (16/8 port RTA).
+ */
+
RtaType = GetUnitType(RtaUniq);
- if ( Rup >= (ushort)MAX_RUP ) {
- rio_dprintk (RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n",
- HostP->Name, 8 * RtaType, RBYTE(PktCmdP->LinkNum)+'A');
- } else {
- rio_dprintk (RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n",
- HostP->Mapping[Rup].Name, 8 * RtaType,
- RBYTE(PktCmdP->LinkNum)+'A');
- }
+ if (Rup >= (unsigned short) MAX_RUP)
+ rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
+ else
+ rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A');
- rio_dprintk (RIO_DEBUG_BOOT, "UniqNum is 0x%x\n",RtaUniq);
+ rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq);
- if ( ( RtaUniq == 0x00000000 ) || ( RtaUniq == 0xffffffff ) )
- {
- rio_dprintk (RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
- return TRUE;
+ if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n");
+ return 1;
}
/*
- ** If this RTA has just booted an RTA which doesn't belong to this
- ** system, or the system is in slave mode, do not attempt to create
- ** a new table entry for it.
- */
- if (!RIOBootOk(p, HostP, RtaUniq))
- {
- MyLink = RBYTE(PktCmdP->LinkNum);
- if (Rup < (ushort) MAX_RUP)
- {
- /*
- ** RtaUniq was clone booted (by this RTA). Instruct this RTA
- ** to hold off further attempts to boot on this link for 30
- ** seconds.
- */
- if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink))
- {
- rio_dprintk (RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n",
- 'A' + MyLink);
- }
- }
- else
- {
- /*
- ** RtaUniq was booted by this host. Set the booting link
- ** to hold off for 30 seconds to give another unit a
- ** chance to boot it.
- */
- WWORD(HostP->LinkStrP[MyLink].WaitNoBoot, 30);
- }
- rio_dprintk (RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n",
- RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
- return TRUE;
+ ** If this RTA has just booted an RTA which doesn't belong to this
+ ** system, or the system is in slave mode, do not attempt to create
+ ** a new table entry for it.
+ */
+
+ if (!RIOBootOk(p, HostP, RtaUniq)) {
+ MyLink = readb(&PktCmdP->LinkNum);
+ if (Rup < (unsigned short) MAX_RUP) {
+ /*
+ ** RtaUniq was clone booted (by this RTA). Instruct this RTA
+ ** to hold off further attempts to boot on this link for 30
+ ** seconds.
+ */
+ if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) {
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink);
+ }
+ } else
+ /*
+ ** RtaUniq was booted by this host. Set the booting link
+ ** to hold off for 30 seconds to give another unit a
+ ** chance to boot it.
+ */
+ writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot);
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum);
+ return 1;
}
/*
- ** Check for a SLOT_IN_USE entry for this RTA attached to the
- ** current host card in the driver table.
- **
- ** If it exists, make a note that we have booted it. Other parts of
- ** the driver are interested in this information at a later date,
- ** in particular when the booting RTA asks for an ID for this unit,
- ** we must have set the BOOTED flag, and the NEWBOOT flag is used
- ** to force an open on any ports that where previously open on this
- ** unit.
- */
- for ( entry=0; entry<MAX_RUP; entry++ )
- {
- uint sysport;
-
- if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) &&
- (HostP->Mapping[entry].RtaUniqueNum==RtaUniq))
- {
- HostP->Mapping[entry].Flags |= RTA_BOOTED|RTA_NEWBOOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry]);
-#endif
- if ( (sysport=HostP->Mapping[entry].SysPort) != NO_PORT )
- {
- if ( sysport < p->RIOFirstPortsBooted )
- p->RIOFirstPortsBooted = sysport;
- if ( sysport > p->RIOLastPortsBooted )
- p->RIOLastPortsBooted = sysport;
- /*
- ** For a 16 port RTA, check the second bank of 8 ports
- */
- if (RtaType == TYPE_RTA16)
- {
- entry2 = HostP->Mapping[entry].ID2 - 1;
- HostP->Mapping[entry2].Flags |= RTA_BOOTED|RTA_NEWBOOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry2]);
-#endif
- sysport = HostP->Mapping[entry2].SysPort;
- if ( sysport < p->RIOFirstPortsBooted )
- p->RIOFirstPortsBooted = sysport;
- if ( sysport > p->RIOLastPortsBooted )
- p->RIOLastPortsBooted = sysport;
- }
- }
- if (RtaType == TYPE_RTA16) {
- rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n",
- entry+1, entry2+1);
- } else {
- rio_dprintk (RIO_DEBUG_BOOT, "RTA will be given ID %d\n",entry+1);
+ ** Check for a SLOT_IN_USE entry for this RTA attached to the
+ ** current host card in the driver table.
+ **
+ ** If it exists, make a note that we have booted it. Other parts of
+ ** the driver are interested in this information at a later date,
+ ** in particular when the booting RTA asks for an ID for this unit,
+ ** we must have set the BOOTED flag, and the NEWBOOT flag is used
+ ** to force an open on any ports that where previously open on this
+ ** unit.
+ */
+ for (entry = 0; entry < MAX_RUP; entry++) {
+ unsigned int sysport;
+
+ if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
+ HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT;
+ if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) {
+ if (sysport < p->RIOFirstPortsBooted)
+ p->RIOFirstPortsBooted = sysport;
+ if (sysport > p->RIOLastPortsBooted)
+ p->RIOLastPortsBooted = sysport;
+ /*
+ ** For a 16 port RTA, check the second bank of 8 ports
+ */
+ if (RtaType == TYPE_RTA16) {
+ entry2 = HostP->Mapping[entry].ID2 - 1;
+ HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT;
+ sysport = HostP->Mapping[entry2].SysPort;
+ if (sysport < p->RIOFirstPortsBooted)
+ p->RIOFirstPortsBooted = sysport;
+ if (sysport > p->RIOLastPortsBooted)
+ p->RIOLastPortsBooted = sysport;
+ }
+ }
+ if (RtaType == TYPE_RTA16)
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1);
+ else
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1);
+ return 1;
}
- return TRUE;
- }
}
- rio_dprintk (RIO_DEBUG_BOOT, "RTA not configured for this host\n");
+ rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n");
- if ( Rup >= (ushort)MAX_RUP )
- {
- /*
- ** It was a host that did the booting
- */
- MyType = "Host";
- MyName = HostP->Name;
- }
- else
- {
- /*
- ** It was an RTA that did the booting
- */
- MyType = "RTA";
- MyName = HostP->Mapping[Rup].Name;
+ if (Rup >= (unsigned short) MAX_RUP) {
+ /*
+ ** It was a host that did the booting
+ */
+ MyType = "Host";
+ MyName = HostP->Name;
+ } else {
+ /*
+ ** It was an RTA that did the booting
+ */
+ MyType = "RTA";
+ MyName = HostP->Mapping[Rup].Name;
}
- MyLink = RBYTE(PktCmdP->LinkNum);
+ MyLink = readb(&PktCmdP->LinkNum);
/*
- ** There is no SLOT_IN_USE entry for this RTA attached to the current
- ** host card in the driver table.
- **
- ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
- ** current host card in the driver table.
- **
- ** If we find one, then we re-use that slot.
- */
- for ( entry=0; entry<MAX_RUP; entry++ )
- {
- if ( (HostP->Mapping[entry].Flags & SLOT_TENTATIVE) &&
- (HostP->Mapping[entry].RtaUniqueNum == RtaUniq) )
- {
- if (RtaType == TYPE_RTA16)
- {
- entry2 = HostP->Mapping[entry].ID2 - 1;
- if ( (HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) &&
- (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq) )
- rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n",
- entry, entry2);
- else
- continue;
+ ** There is no SLOT_IN_USE entry for this RTA attached to the current
+ ** host card in the driver table.
+ **
+ ** Check for a SLOT_TENTATIVE entry for this RTA attached to the
+ ** current host card in the driver table.
+ **
+ ** If we find one, then we re-use that slot.
+ */
+ for (entry = 0; entry < MAX_RUP; entry++) {
+ if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) {
+ if (RtaType == TYPE_RTA16) {
+ entry2 = HostP->Mapping[entry].ID2 - 1;
+ if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq))
+ rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2);
+ else
+ continue;
+ } else
+ rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry);
+ if (!p->RIONoMessage)
+ printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
+ return 1;
}
- else
- rio_dprintk (RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n",entry);
- if (! p->RIONoMessage)
- cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
- return TRUE;
- }
}
/*
- ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
- ** attached to the current host card in the driver table.
- **
- ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
- ** host for this RTA in the driver table.
- **
- ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
- ** entry from the other host and add it to this host (using some of
- ** the functions from table.c which do this).
- ** For a SLOT_TENTATIVE entry on another host, we must cope with the
- ** following scenario:
- **
- ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
- ** in table)
- ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
- ** entries)
- ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
- ** + Unplug RTA and plug back into host A.
- ** + Configure RTA on host A. We now have the same RTA configured
- ** with different ports on two different hosts.
- */
- rio_dprintk (RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq );
+ ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
+ ** attached to the current host card in the driver table.
+ **
+ ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another
+ ** host for this RTA in the driver table.
+ **
+ ** For a SLOT_IN_USE entry on another host, we need to delete the RTA
+ ** entry from the other host and add it to this host (using some of
+ ** the functions from table.c which do this).
+ ** For a SLOT_TENTATIVE entry on another host, we must cope with the
+ ** following scenario:
+ **
+ ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry
+ ** in table)
+ ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE
+ ** entries)
+ ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE)
+ ** + Unplug RTA and plug back into host A.
+ ** + Configure RTA on host A. We now have the same RTA configured
+ ** with different ports on two different hosts.
+ */
+ rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq);
found = 0;
- Flag = 0; /* Convince the compiler this variable is initialized */
- for ( host = 0; !found && (host < p->RIONumHosts); host++ )
- {
- for ( rta=0; rta<MAX_RUP; rta++ )
- {
- if ((p->RIOHosts[host].Mapping[rta].Flags &
- (SLOT_IN_USE | SLOT_TENTATIVE)) &&
- (p->RIOHosts[host].Mapping[rta].RtaUniqueNum==RtaUniq))
- {
- Flag = p->RIOHosts[host].Mapping[rta].Flags;
- MapP = &p->RIOHosts[host].Mapping[rta];
- if (RtaType == TYPE_RTA16)
- {
- MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
- rio_dprintk (RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n",
- rta+1, MapP->ID2, p->RIOHosts[host].Name);
- }
- else
- rio_dprintk (RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n",
- rta+1, p->RIOHosts[host].Name);
- found = 1;
- break;
+ Flag = 0; /* Convince the compiler this variable is initialized */
+ for (host = 0; !found && (host < p->RIONumHosts); host++) {
+ for (rta = 0; rta < MAX_RUP; rta++) {
+ if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) {
+ Flag = p->RIOHosts[host].Mapping[rta].Flags;
+ MapP = &p->RIOHosts[host].Mapping[rta];
+ if (RtaType == TYPE_RTA16) {
+ MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1];
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name);
+ } else
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name);
+ found = 1;
+ break;
+ }
}
- }
}
/*
- ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
- ** attached to the current host card in the driver table.
- **
- ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
- ** another host for this RTA in the driver table...
- **
- ** Check for a SLOT_IN_USE entry for this RTA in the config table.
- */
- if ( !MapP )
- {
- rio_dprintk (RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n",RtaUniq);
- for ( rta=0; rta < TOTAL_MAP_ENTRIES; rta++ )
- {
- rio_dprintk (RIO_DEBUG_BOOT, "Check table entry %d (%x)",
- rta,
- p->RIOSavedTable[rta].RtaUniqueNum);
-
- if ( (p->RIOSavedTable[rta].Flags & SLOT_IN_USE) &&
- (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq) )
- {
- MapP = &p->RIOSavedTable[rta];
- Flag = p->RIOSavedTable[rta].Flags;
- if (RtaType == TYPE_RTA16)
- {
- for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES;
- entry2++)
- {
- if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
- break;
- }
- MapP2 = &p->RIOSavedTable[entry2];
- rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n",
- rta, entry2);
- }
- else
- rio_dprintk (RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
- break;
+ ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
+ ** attached to the current host card in the driver table.
+ **
+ ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on
+ ** another host for this RTA in the driver table...
+ **
+ ** Check for a SLOT_IN_USE entry for this RTA in the config table.
+ */
+ if (!MapP) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq);
+ for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) {
+ rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum);
+
+ if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) {
+ MapP = &p->RIOSavedTable[rta];
+ Flag = p->RIOSavedTable[rta].Flags;
+ if (RtaType == TYPE_RTA16) {
+ for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) {
+ if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq)
+ break;
+ }
+ MapP2 = &p->RIOSavedTable[entry2];
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2);
+ } else
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta);
+ break;
+ }
}
- }
}
/*
- ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
- ** attached to the current host card in the driver table.
- **
- ** We may have found a SLOT_IN_USE entry on another host for this
- ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
- ** on another host for this RTA in the driver table.
- **
- ** Check the driver table for room to fit this newly discovered RTA.
- ** RIOFindFreeID() first looks for free slots and if it does not
- ** find any free slots it will then attempt to oust any
- ** tentative entry in the table.
- */
+ ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
+ ** attached to the current host card in the driver table.
+ **
+ ** We may have found a SLOT_IN_USE entry on another host for this
+ ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry
+ ** on another host for this RTA in the driver table.
+ **
+ ** Check the driver table for room to fit this newly discovered RTA.
+ ** RIOFindFreeID() first looks for free slots and if it does not
+ ** find any free slots it will then attempt to oust any
+ ** tentative entry in the table.
+ */
EmptySlot = 1;
- if (RtaType == TYPE_RTA16)
- {
- if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0)
- {
- RIODefaultName(p, HostP, entry);
- FillSlot(entry, entry2, RtaUniq, HostP);
- EmptySlot = 0;
- }
- }
- else
- {
- if (RIOFindFreeID(p, HostP, &entry, NULL) == 0)
- {
- RIODefaultName(p, HostP, entry);
- FillSlot(entry, 0, RtaUniq, HostP);
- EmptySlot = 0;
- }
+ if (RtaType == TYPE_RTA16) {
+ if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) {
+ RIODefaultName(p, HostP, entry);
+ rio_fill_host_slot(entry, entry2, RtaUniq, HostP);
+ EmptySlot = 0;
+ }
+ } else {
+ if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) {
+ RIODefaultName(p, HostP, entry);
+ rio_fill_host_slot(entry, 0, RtaUniq, HostP);
+ EmptySlot = 0;
+ }
}
/*
- ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
- ** attached to the current host card in the driver table.
- **
- ** If we found a SLOT_IN_USE entry on another host for this
- ** RTA in the config or driver table, and there are enough free
- ** slots in the driver table, then we need to move it over and
- ** delete it from the other host.
- ** If we found a SLOT_TENTATIVE entry on another host for this
- ** RTA in the driver table, just delete the other host entry.
- */
- if (EmptySlot == 0)
- {
- if ( MapP )
- {
- if (Flag & SLOT_IN_USE)
- {
- rio_dprintk (RIO_DEBUG_BOOT,
- "This RTA configured on another host - move entry to current host (1)\n");
- HostP->Mapping[entry].SysPort = MapP->SysPort;
- CCOPY( MapP->Name, HostP->Mapping[entry].Name, MAX_NAME_LEN );
- HostP->Mapping[entry].Flags =
- SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry]);
-#endif
- RIOReMapPorts( p, HostP, &HostP->Mapping[entry] );
- if ( HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted )
- p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
- if ( HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted )
- p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
- rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",(int)MapP->SysPort,MapP->Name);
- }
- else
- {
- rio_dprintk (RIO_DEBUG_BOOT,
- "This RTA has a tentative entry on another host - delete that entry (1)\n");
- HostP->Mapping[entry].Flags =
- SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry]);
-#endif
- }
- if (RtaType == TYPE_RTA16)
- {
- if (Flag & SLOT_IN_USE)
- {
- HostP->Mapping[entry2].Flags = SLOT_IN_USE |
- RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry2]);
-#endif
- HostP->Mapping[entry2].SysPort = MapP2->SysPort;
- /*
- ** Map second block of ttys for 16 port RTA
- */
- RIOReMapPorts( p, HostP, &HostP->Mapping[entry2] );
- if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
- p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
- if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
- p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
- rio_dprintk (RIO_DEBUG_BOOT, "SysPort %d, Name %s\n",
- (int)HostP->Mapping[entry2].SysPort,
- HostP->Mapping[entry].Name);
- }
- else
- HostP->Mapping[entry2].Flags = SLOT_TENTATIVE |
- RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
-#ifdef NEED_TO_FIX
- RIO_SV_BROADCAST(HostP->svFlags[entry2]);
-#endif
- bzero( (caddr_t)MapP2, sizeof(struct Map) );
- }
- bzero( (caddr_t)MapP, sizeof(struct Map) );
- if (! p->RIONoMessage)
- cprintf("An orphaned RTA has been adopted by %s '%s' (%c).\n",MyType,MyName,MyLink+'A');
- }
- else if (! p->RIONoMessage)
- cprintf("RTA connected to %s '%s' (%c) not configured.\n",MyType,MyName,MyLink+'A');
- RIOSetChange(p);
- return TRUE;
+ ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA
+ ** attached to the current host card in the driver table.
+ **
+ ** If we found a SLOT_IN_USE entry on another host for this
+ ** RTA in the config or driver table, and there are enough free
+ ** slots in the driver table, then we need to move it over and
+ ** delete it from the other host.
+ ** If we found a SLOT_TENTATIVE entry on another host for this
+ ** RTA in the driver table, just delete the other host entry.
+ */
+ if (EmptySlot == 0) {
+ if (MapP) {
+ if (Flag & SLOT_IN_USE) {
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n");
+ HostP->Mapping[entry].SysPort = MapP->SysPort;
+ memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN);
+ HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT;
+ RIOReMapPorts(p, HostP, &HostP->Mapping[entry]);
+ if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted)
+ p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort;
+ if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted)
+ p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort;
+ rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name);
+ } else {
+ rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n");
+ HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT;
+ }
+ if (RtaType == TYPE_RTA16) {
+ if (Flag & SLOT_IN_USE) {
+ HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
+ HostP->Mapping[entry2].SysPort = MapP2->SysPort;
+ /*
+ ** Map second block of ttys for 16 port RTA
+ */
+ RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]);
+ if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted)
+ p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort;
+ if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted)
+ p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort;
+ rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name);
+ } else
+ HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT;
+ memset(MapP2, 0, sizeof(struct Map));
+ }
+ memset(MapP, 0, sizeof(struct Map));
+ if (!p->RIONoMessage)
+ printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A');
+ } else if (!p->RIONoMessage)
+ printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A');
+ RIOSetChange(p);
+ return 1;
}
/*
- ** There is no room in the driver table to make an entry for the
- ** booted RTA. Keep a note of its Uniq Num in the overflow table,
- ** so we can ignore it's ID requests.
- */
- if (! p->RIONoMessage)
- cprintf("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n",MyType,MyName,MyLink+'A');
- for ( entry=0; entry<HostP->NumExtraBooted; entry++ )
- {
- if ( HostP->ExtraUnits[entry] == RtaUniq )
- {
- /*
- ** already got it!
- */
- return TRUE;
- }
+ ** There is no room in the driver table to make an entry for the
+ ** booted RTA. Keep a note of its Uniq Num in the overflow table,
+ ** so we can ignore it's ID requests.
+ */
+ if (!p->RIONoMessage)
+ printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A');
+ for (entry = 0; entry < HostP->NumExtraBooted; entry++) {
+ if (HostP->ExtraUnits[entry] == RtaUniq) {
+ /*
+ ** already got it!
+ */
+ return 1;
+ }
}
/*
- ** If there is room, add the unit to the list of extras
- */
- if ( HostP->NumExtraBooted < MAX_EXTRA_UNITS )
- HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
- return TRUE;
+ ** If there is room, add the unit to the list of extras
+ */
+ if (HostP->NumExtraBooted < MAX_EXTRA_UNITS)
+ HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq;
+ return 1;
}
/*
** If the RTA or its host appears in the RIOBindTab[] structure then
-** we mustn't boot the RTA and should return FALSE.
+** we mustn't boot the RTA and should return 0.
** This operation is slightly different from the other drivers for RIO
** in that this is designed to work with the new utilities
** not config.rio and is FAR SIMPLER.
** We no longer support the RIOBootMode variable. It is all done from the
** "boot/noboot" field in the rio.cf file.
*/
-int
-RIOBootOk(p, HostP, RtaUniq)
-struct rio_info * p;
-struct Host * HostP;
-ulong RtaUniq;
+int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq)
{
- int Entry;
- uint HostUniq = HostP->UniqueNum;
+ int Entry;
+ unsigned int HostUniq = HostP->UniqueNum;
/*
- ** Search bindings table for RTA or its parent.
- ** If it exists, return 0, else 1.
- */
- for (Entry = 0;
- ( Entry < MAX_RTA_BINDINGS ) && ( p->RIOBindTab[Entry] != 0 );
- Entry++)
- {
- if ( (p->RIOBindTab[Entry] == HostUniq) ||
- (p->RIOBindTab[Entry] == RtaUniq) )
+ ** Search bindings table for RTA or its parent.
+ ** If it exists, return 0, else 1.
+ */
+ for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) {
+ if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq))
return 0;
}
return 1;
@@ -1255,45 +1076,38 @@ ulong RtaUniq;
** slots tentative, and the second one RTA_SECOND_SLOT as well.
*/
-void
-FillSlot(entry, entry2, RtaUniq, HostP)
-int entry;
-int entry2;
-uint RtaUniq;
-struct Host *HostP;
+void rio_fill_host_slot(int entry, int entry2, unsigned int rta_uniq, struct Host *host)
{
- int link;
+ int link;
- rio_dprintk (RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq);
+ rio_dprintk(RIO_DEBUG_BOOT, "rio_fill_host_slot(%d, %d, 0x%x...)\n", entry, entry2, rta_uniq);
- HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
- HostP->Mapping[entry].SysPort = NO_PORT;
- HostP->Mapping[entry].RtaUniqueNum = RtaUniq;
- HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum;
- HostP->Mapping[entry].ID = entry + 1;
- HostP->Mapping[entry].ID2 = 0;
+ host->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE);
+ host->Mapping[entry].SysPort = NO_PORT;
+ host->Mapping[entry].RtaUniqueNum = rta_uniq;
+ host->Mapping[entry].HostUniqueNum = host->UniqueNum;
+ host->Mapping[entry].ID = entry + 1;
+ host->Mapping[entry].ID2 = 0;
if (entry2) {
- HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT |
- SLOT_TENTATIVE | RTA16_SECOND_SLOT);
- HostP->Mapping[entry2].SysPort = NO_PORT;
- HostP->Mapping[entry2].RtaUniqueNum = RtaUniq;
- HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum;
- HostP->Mapping[entry2].Name[0] = '\0';
- HostP->Mapping[entry2].ID = entry2 + 1;
- HostP->Mapping[entry2].ID2 = entry + 1;
- HostP->Mapping[entry].ID2 = entry2 + 1;
+ host->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT);
+ host->Mapping[entry2].SysPort = NO_PORT;
+ host->Mapping[entry2].RtaUniqueNum = rta_uniq;
+ host->Mapping[entry2].HostUniqueNum = host->UniqueNum;
+ host->Mapping[entry2].Name[0] = '\0';
+ host->Mapping[entry2].ID = entry2 + 1;
+ host->Mapping[entry2].ID2 = entry + 1;
+ host->Mapping[entry].ID2 = entry2 + 1;
}
/*
- ** Must set these up, so that utilities show
- ** topology of 16 port RTAs correctly
- */
- for ( link=0; link<LINKS_PER_UNIT; link++ ) {
- HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
- HostP->Mapping[entry].Topology[link].Link = NO_LINK;
+ ** Must set these up, so that utilities show
+ ** topology of 16 port RTAs correctly
+ */
+ for (link = 0; link < LINKS_PER_UNIT; link++) {
+ host->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT;
+ host->Mapping[entry].Topology[link].Link = NO_LINK;
if (entry2) {
- HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
- HostP->Mapping[entry2].Topology[link].Link = NO_LINK;
+ host->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT;
+ host->Mapping[entry2].Topology[link].Link = NO_LINK;
}
}
}
-
diff --git a/drivers/char/rio/riocmd.c b/drivers/char/rio/riocmd.c
index 694bfb9d937..e6d2b14b5e6 100644
--- a/drivers/char/rio/riocmd.c
+++ b/drivers/char/rio/riocmd.c
@@ -42,6 +42,7 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
#include <asm/system.h>
#include <asm/string.h>
#include <asm/semaphore.h>
+#include <asm/uaccess.h>
#include <linux/termios.h>
#include <linux/serial.h>
@@ -50,15 +51,12 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -71,12 +69,10 @@ static char *_riocmd_c_sccs_ = "@(#)riocmd.c 1.2";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
@@ -143,17 +139,17 @@ int RIOZombieRta(struct Host *HostP, struct Map *MapP)
return 0;
}
-int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
+int RIOCommandRta(struct rio_info *p, unsigned long RtaUnique, int (*func) (struct Host * HostP, struct Map * MapP))
{
- uint Host;
+ unsigned int Host;
- rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%x func 0x%x\n", RtaUnique, (int) func);
+ rio_dprintk(RIO_DEBUG_CMD, "Command RTA 0x%lx func %p\n", RtaUnique, func);
if (!RtaUnique)
return (0);
for (Host = 0; Host < p->RIONumHosts; Host++) {
- uint Rta;
+ unsigned int Rta;
struct Host *HostP = &p->RIOHosts[Host];
for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -170,7 +166,7 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
** any connections, we can get to it.
*/
for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
- if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) {
+ if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
/*
** Its worth trying the operation...
*/
@@ -184,18 +180,18 @@ int RIOCommandRta(struct rio_info *p, uint RtaUnique, int (*func) (struct Host *
}
-int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
+int RIOIdentifyRta(struct rio_info *p, void * arg)
{
- uint Host;
+ unsigned int Host;
- if (copyin((int) arg, (caddr_t) & IdRta, sizeof(IdRta)) == COPYFAIL) {
+ if (copy_from_user(&IdRta, arg, sizeof(IdRta))) {
rio_dprintk(RIO_DEBUG_CMD, "RIO_IDENTIFY_RTA copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
for (Host = 0; Host < p->RIONumHosts; Host++) {
- uint Rta;
+ unsigned int Rta;
struct Host *HostP = &p->RIOHosts[Host];
for (Rta = 0; Rta < RTAS_PER_HOST; Rta++) {
@@ -211,7 +207,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
** any connections, we can get to it.
*/
for (Link = 0; Link < LINKS_PER_UNIT; Link++) {
- if (MapP->Topology[Link].Unit <= (uchar) MAX_RUP) {
+ if (MapP->Topology[Link].Unit <= (u8) MAX_RUP) {
/*
** Its worth trying the operation...
*/
@@ -249,7 +245,7 @@ int RIOIdentifyRta(struct rio_info *p, caddr_t arg)
}
-int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
+int RIOKillNeighbour(struct rio_info *p, void * arg)
{
uint Host;
uint ID;
@@ -258,7 +254,7 @@ int RIOKillNeighbour(struct rio_info *p, caddr_t arg)
rio_dprintk(RIO_DEBUG_CMD, "KILL HOST NEIGHBOUR\n");
- if (copyin((int) arg, (caddr_t) & KillUnit, sizeof(KillUnit)) == COPYFAIL) {
+ if (copy_from_user(&KillUnit, arg, sizeof(KillUnit))) {
rio_dprintk(RIO_DEBUG_CMD, "RIO_KILL_NEIGHBOUR copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -344,7 +340,7 @@ int RIOSuspendBootRta(struct Host *HostP, int ID, int Link)
int RIOFoadWakeup(struct rio_info *p)
{
int port;
- register struct Port *PortP;
+ struct Port *PortP;
unsigned long flags;
for (port = 0; port < RIO_PORTS; port++) {
@@ -374,15 +370,15 @@ int RIOFoadWakeup(struct rio_info *p)
/*
** Incoming command on the COMMAND_RUP to be processed.
*/
-static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
+static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, struct PKT * PacketP)
{
struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
struct Port *PortP;
struct UnixRup *UnixRupP;
- ushort SysPort;
- ushort ReportedModemStatus;
- ushort rup;
- ushort subCommand;
+ unsigned short SysPort;
+ unsigned short ReportedModemStatus;
+ unsigned short rup;
+ unsigned short subCommand;
unsigned long flags;
func_enter();
@@ -395,18 +391,18 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
** we can use PhbNum to get the rup number for the appropriate 8 port
** block (for the first block, this should be equal to 'Rup').
*/
- rup = RBYTE(PktCmdP->PhbNum) / (ushort) PORTS_PER_RTA;
+ rup = readb(&PktCmdP->PhbNum) / (unsigned short) PORTS_PER_RTA;
UnixRupP = &HostP->UnixRups[rup];
- SysPort = UnixRupP->BaseSysPort + (RBYTE(PktCmdP->PhbNum) % (ushort) PORTS_PER_RTA);
+ SysPort = UnixRupP->BaseSysPort + (readb(&PktCmdP->PhbNum) % (unsigned short) PORTS_PER_RTA);
rio_dprintk(RIO_DEBUG_CMD, "Command on rup %d, port %d\n", rup, SysPort);
if (UnixRupP->BaseSysPort == NO_PORT) {
rio_dprintk(RIO_DEBUG_CMD, "OBSCURE ERROR!\n");
rio_dprintk(RIO_DEBUG_CMD, "Diagnostics follow. Please WRITE THESE DOWN and report them to Specialix Technical Support\n");
- rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %d, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
+ rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Host number %Zd, name ``%s''\n", HostP - p->RIOHosts, HostP->Name);
rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: Rup number 0x%x\n", rup);
- if (Rup >= (ushort) MAX_RUP) {
+ if (Rup >= (unsigned short) MAX_RUP) {
rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for RTA ``%s''\n", HostP->Mapping[Rup].Name);
} else
rio_dprintk(RIO_DEBUG_CMD, "CONTROL information: This is the RUP for link ``%c'' of host ``%s''\n", ('A' + Rup - MAX_RUP), HostP->Name);
@@ -417,16 +413,16 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Control 0x%x (%d)\n", PacketP->control, PacketP->control);
rio_dprintk(RIO_DEBUG_CMD, "PACKET information: Check 0x%x (%d)\n", PacketP->csum, PacketP->csum);
rio_dprintk(RIO_DEBUG_CMD, "COMMAND information: Host Port Number 0x%x, " "Command Code 0x%x\n", PktCmdP->PhbNum, PktCmdP->Command);
- return TRUE;
+ return 1;
}
PortP = p->RIOPortp[SysPort];
rio_spin_lock_irqsave(&PortP->portSem, flags);
- switch (RBYTE(PktCmdP->Command)) {
+ switch (readb(&PktCmdP->Command)) {
case BREAK_RECEIVED:
rio_dprintk(RIO_DEBUG_CMD, "Received a break!\n");
/* If the current line disc. is not multi-threading and
the current processor is not the default, reset rup_intr
- and return FALSE to ensure that the command packet is
+ and return 0 to ensure that the command packet is
not freed. */
/* Call tmgr HANGUP HERE */
/* Fix this later when every thing works !!!! RAMRAJ */
@@ -434,15 +430,15 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
break;
case COMPLETE:
- rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %d\n", RBYTE(PktCmdP->PhbNum), HostP - p->RIOHosts);
+ rio_dprintk(RIO_DEBUG_CMD, "Command complete on phb %d host %Zd\n", readb(&PktCmdP->PhbNum), HostP - p->RIOHosts);
subCommand = 1;
- switch (RBYTE(PktCmdP->SubCommand)) {
+ switch (readb(&PktCmdP->SubCommand)) {
case MEMDUMP:
- rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", RBYTE(PktCmdP->SubCommand), RWORD(PktCmdP->SubAddr));
+ rio_dprintk(RIO_DEBUG_CMD, "Memory dump cmd (0x%x) from addr 0x%x\n", readb(&PktCmdP->SubCommand), readw(&PktCmdP->SubAddr));
break;
case READ_REGISTER:
- rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", RWORD(PktCmdP->SubAddr));
- p->CdRegister = (RBYTE(PktCmdP->ModemStatus) & MSVR1_HOST);
+ rio_dprintk(RIO_DEBUG_CMD, "Read register (0x%x)\n", readw(&PktCmdP->SubAddr));
+ p->CdRegister = (readb(&PktCmdP->ModemStatus) & MSVR1_HOST);
break;
default:
subCommand = 0;
@@ -450,10 +446,10 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
}
if (subCommand)
break;
- rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", RBYTE(PktCmdP->PortStatus), PortP->PortState);
- if (PortP->PortState != RBYTE(PktCmdP->PortStatus)) {
+ rio_dprintk(RIO_DEBUG_CMD, "New status is 0x%x was 0x%x\n", readb(&PktCmdP->PortStatus), PortP->PortState);
+ if (PortP->PortState != readb(&PktCmdP->PortStatus)) {
rio_dprintk(RIO_DEBUG_CMD, "Mark status & wakeup\n");
- PortP->PortState = RBYTE(PktCmdP->PortStatus);
+ PortP->PortState = readb(&PktCmdP->PortStatus);
/* What should we do here ...
wakeup( &PortP->PortState );
*/
@@ -467,7 +463,7 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
** to the check for modem status change (they're just there because
** it's a convenient place to put them!).
*/
- ReportedModemStatus = RBYTE(PktCmdP->ModemStatus);
+ ReportedModemStatus = readb(&PktCmdP->ModemStatus);
if ((PortP->ModemState & MSVR1_HOST) == (ReportedModemStatus & MSVR1_HOST)) {
rio_dprintk(RIO_DEBUG_CMD, "Modem status unchanged 0x%x\n", PortP->ModemState);
/*
@@ -514,9 +510,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
*/
if (PortP->State & (PORT_ISOPEN | RIO_WOPEN))
wake_up_interruptible(&PortP->gs.open_wait);
-#ifdef STATS
- PortP->Stat.ModemOnCnt++;
-#endif
}
} else {
/*
@@ -527,9 +520,6 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
tty_hangup(PortP->gs.tty);
PortP->State &= ~RIO_CARR_ON;
rio_dprintk(RIO_DEBUG_CMD, "Carrirer just went down\n");
-#ifdef STATS
- PortP->Stat.ModemOffCnt++;
-#endif
}
}
}
@@ -539,14 +529,14 @@ static int RIOCommandRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT *
break;
default:
- rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %d\n", RBYTE(PktCmdP->Command), HostP - p->RIOHosts);
+ rio_dprintk(RIO_DEBUG_CMD, "Unknown command %d on CMD_RUP of host %Zd\n", readb(&PktCmdP->Command), HostP - p->RIOHosts);
break;
}
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
func_exit();
- return TRUE;
+ return 1;
}
/*
@@ -566,10 +556,9 @@ struct CmdBlk *RIOGetCmdBlk(void)
{
struct CmdBlk *CmdBlkP;
- CmdBlkP = (struct CmdBlk *) sysbrk(sizeof(struct CmdBlk));
+ CmdBlkP = (struct CmdBlk *)kmalloc(sizeof(struct CmdBlk), GFP_ATOMIC);
if (CmdBlkP)
- bzero(CmdBlkP, sizeof(struct CmdBlk));
-
+ memset(CmdBlkP, 0, sizeof(struct CmdBlk));
return CmdBlkP;
}
@@ -578,7 +567,7 @@ struct CmdBlk *RIOGetCmdBlk(void)
*/
void RIOFreeCmdBlk(struct CmdBlk *CmdBlkP)
{
- sysfree((void *) CmdBlkP, sizeof(struct CmdBlk));
+ kfree(CmdBlkP);
}
/*
@@ -591,7 +580,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
struct UnixRup *UnixRupP;
unsigned long flags;
- if (Rup >= (ushort) (MAX_RUP + LINKS_PER_UNIT)) {
+ if (Rup >= (unsigned short) (MAX_RUP + LINKS_PER_UNIT)) {
rio_dprintk(RIO_DEBUG_CMD, "Illegal rup number %d in RIOQueueCmdBlk\n", Rup);
RIOFreeCmdBlk(CmdBlkP);
return RIO_FAIL;
@@ -605,14 +594,14 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
** If the RUP is currently inactive, then put the request
** straight on the RUP....
*/
- if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
- : TRUE)) {
+ if ((UnixRupP->CmdsWaitingP == NULL) && (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE) && (CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP)
+ : 1)) {
rio_dprintk(RIO_DEBUG_CMD, "RUP inactive-placing command straight on. Cmd byte is 0x%x\n", CmdBlkP->Packet.data[0]);
/*
** Whammy! blat that pack!
*/
- HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT));
+ HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
/*
** place command packet on the pending position.
@@ -622,11 +611,11 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
/*
** set the command register
*/
- WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY);
+ writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
- return RIO_SUCCESS;
+ return 0;
}
rio_dprintk(RIO_DEBUG_CMD, "RUP active - en-queing\n");
@@ -634,20 +623,20 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command waiting\n");
if (UnixRupP->CmdPendingP != NULL)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command pending\n");
- if (RWORD(UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
+ if (readw(&UnixRupP->RupP->txcontrol) != TX_RUP_INACTIVE)
rio_dprintk(RIO_DEBUG_CMD, "Rup active - command rup not ready\n");
Base = &UnixRupP->CmdsWaitingP;
- rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
+ rio_dprintk(RIO_DEBUG_CMD, "First try to queue cmdblk %p at %p\n", CmdBlkP, Base);
while (*Base) {
- rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk 0x%x here\n", (int) (*Base));
+ rio_dprintk(RIO_DEBUG_CMD, "Command cmdblk %p here\n", *Base);
Base = &((*Base)->NextP);
- rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
+ rio_dprintk(RIO_DEBUG_CMD, "Now try to queue cmd cmdblk %p at %p\n", CmdBlkP, Base);
}
- rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk 0x%x at 0x%x\n", (int) CmdBlkP, (int) Base);
+ rio_dprintk(RIO_DEBUG_CMD, "Will queue cmdblk %p at %p\n", CmdBlkP, Base);
*Base = CmdBlkP;
@@ -655,7 +644,7 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
- return RIO_SUCCESS;
+ return 0;
}
/*
@@ -664,10 +653,10 @@ int RIOQueueCmdBlk(struct Host *HostP, uint Rup, struct CmdBlk *CmdBlkP)
*/
void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
{
- register struct CmdBlk *CmdBlkP;
- register struct UnixRup *UnixRupP;
+ struct CmdBlk *CmdBlkP;
+ struct UnixRup *UnixRupP;
struct PKT *PacketP;
- ushort Rup;
+ unsigned short Rup;
unsigned long flags;
@@ -684,16 +673,14 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
/*
** First check for incoming commands:
*/
- if (RWORD(UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
+ if (readw(&UnixRupP->RupP->rxcontrol) != RX_RUP_INACTIVE) {
int FreeMe;
- PacketP = (PKT *) RIO_PTR(HostP->Caddr, RWORD(UnixRupP->RupP->rxpkt));
+ PacketP = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&UnixRupP->RupP->rxpkt));
- ShowPacket(DBG_CMD, PacketP);
-
- switch (RBYTE(PacketP->dest_port)) {
+ switch (readb(&PacketP->dest_port)) {
case BOOT_RUP:
- rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", RBYTE(PacketP->len) & 0x80 ? "Command" : "Data", RBYTE(PacketP->data[0]));
+ rio_dprintk(RIO_DEBUG_CMD, "Incoming Boot %s packet '%x'\n", readb(&PacketP->len) & 0x80 ? "Command" : "Data", readb(&PacketP->data[0]));
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
FreeMe = RIOBootRup(p, Rup, HostP, PacketP);
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -708,7 +695,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
rio_spin_unlock_irqrestore(&UnixRupP->RupLock, flags);
FreeMe = RIOCommandRup(p, Rup, HostP, PacketP);
if (PacketP->data[5] == MEMDUMP) {
- rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(ushort *) & (PacketP->data[6]));
+ rio_dprintk(RIO_DEBUG_CMD, "Memdump from 0x%x complete\n", *(unsigned short *) & (PacketP->data[6]));
HostP->Copy((caddr_t) & (PacketP->data[8]), (caddr_t) p->RIOMemDump, 32);
}
rio_spin_lock_irqsave(&UnixRupP->RupLock, flags);
@@ -721,7 +708,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
break;
default:
- rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", RBYTE(PacketP->dest_port));
+ rio_dprintk(RIO_DEBUG_CMD, "Unknown RUP %d\n", readb(&PacketP->dest_port));
FreeMe = 1;
break;
}
@@ -730,11 +717,11 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
rio_dprintk(RIO_DEBUG_CMD, "Free processed incoming command packet\n");
put_free_end(HostP, PacketP);
- WWORD(UnixRupP->RupP->rxcontrol, RX_RUP_INACTIVE);
+ writew(RX_RUP_INACTIVE, &UnixRupP->RupP->rxcontrol);
- if (RWORD(UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
+ if (readw(&UnixRupP->RupP->handshake) == PHB_HANDSHAKE_SET) {
rio_dprintk(RIO_DEBUG_CMD, "Handshake rup %d\n", Rup);
- WWORD(UnixRupP->RupP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
+ writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &UnixRupP->RupP->handshake);
}
}
}
@@ -744,7 +731,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
** and it has completed, then tidy it up.
*/
if ((CmdBlkP = UnixRupP->CmdPendingP) && /* ASSIGN! */
- (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
+ (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
/*
** we are idle.
** there is a command in pending.
@@ -755,7 +742,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
if (CmdBlkP->Packet.dest_port == BOOT_RUP)
rio_dprintk(RIO_DEBUG_CMD, "Free Boot %s Command Block '%x'\n", CmdBlkP->Packet.len & 0x80 ? "Command" : "Data", CmdBlkP->Packet.data[0]);
- rio_dprintk(RIO_DEBUG_CMD, "Command 0x%x completed\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CMD, "Command %p completed\n", CmdBlkP);
/*
** Clear the Rup lock to prevent mutual exclusion.
@@ -782,20 +769,20 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
** is idle, then process the command
*/
if ((CmdBlkP = UnixRupP->CmdsWaitingP) && /* ASSIGN! */
- (UnixRupP->CmdPendingP == NULL) && (RWORD(UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
+ (UnixRupP->CmdPendingP == NULL) && (readw(&UnixRupP->RupP->txcontrol) == TX_RUP_INACTIVE)) {
/*
** if the pre-function is non-zero, call it.
** If it returns RIO_FAIL then don't
** send this command yet!
*/
- if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : TRUE)) {
- rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command 0x%x\n", (int) CmdBlkP);
+ if (!(CmdBlkP->PreFuncP ? (*CmdBlkP->PreFuncP) (CmdBlkP->PreArg, CmdBlkP) : 1)) {
+ rio_dprintk(RIO_DEBUG_CMD, "Not ready to start command %p\n", CmdBlkP);
} else {
- rio_dprintk(RIO_DEBUG_CMD, "Start new command 0x%x Cmd byte is 0x%x\n", (int) CmdBlkP, CmdBlkP->Packet.data[0]);
+ rio_dprintk(RIO_DEBUG_CMD, "Start new command %p Cmd byte is 0x%x\n", CmdBlkP, CmdBlkP->Packet.data[0]);
/*
** Whammy! blat that pack!
*/
- HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(PKT));
+ HostP->Copy((caddr_t) & CmdBlkP->Packet, RIO_PTR(HostP->Caddr, UnixRupP->RupP->txpkt), sizeof(struct PKT));
/*
** remove the command from the rup command queue...
@@ -810,7 +797,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
/*
** set the command register
*/
- WWORD(UnixRupP->RupP->txcontrol, TX_PACKET_READY);
+ writew(TX_PACKET_READY, &UnixRupP->RupP->txcontrol);
/*
** the command block will be freed
@@ -822,7 +809,7 @@ void RIOPollHostCommands(struct rio_info *p, struct Host *HostP)
} while (Rup);
}
-int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
+int RIOWFlushMark(unsigned long iPortP, struct CmdBlk *CmdBlkP)
{
struct Port *PortP = (struct Port *) iPortP;
unsigned long flags;
@@ -834,33 +821,32 @@ int RIOWFlushMark(int iPortP, struct CmdBlk *CmdBlkP)
return RIOUnUse(iPortP, CmdBlkP);
}
-int RIORFlushEnable(int iPortP, struct CmdBlk *CmdBlkP)
+int RIORFlushEnable(unsigned long iPortP, struct CmdBlk *CmdBlkP)
{
struct Port *PortP = (struct Port *) iPortP;
- PKT *PacketP;
+ struct PKT *PacketP;
unsigned long flags;
rio_spin_lock_irqsave(&PortP->portSem, flags);
while (can_remove_receive(&PacketP, PortP)) {
remove_receive(PortP);
- ShowPacket(DBG_PROC, PacketP);
put_free_end(PortP->HostP, PacketP);
}
- if (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
+ if (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET) {
/*
** MAGIC! (Basically, handshake the RX buffer, so that
** the RTAs upstream can be re-enabled.)
*/
rio_dprintk(RIO_DEBUG_CMD, "Util: Set RX handshake bit\n");
- WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
+ writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
}
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
return RIOUnUse(iPortP, CmdBlkP);
}
-int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
+int RIOUnUse(unsigned long iPortP, struct CmdBlk *CmdBlkP)
{
struct Port *PortP = (struct Port *) iPortP;
unsigned long flags;
@@ -890,7 +876,7 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
** When PortP->InUse becomes NOT_INUSE, we must ensure that any data
** hanging around in the transmit buffer is sent immediately.
*/
- WWORD(PortP->HostP->ParmMapP->tx_intr, 1);
+ writew(1, &PortP->HostP->ParmMapP->tx_intr);
/* What to do here ..
wakeup( (caddr_t)&(PortP->InUse) );
*/
@@ -898,10 +884,6 @@ int RIOUnUse(int iPortP, struct CmdBlk *CmdBlkP)
return 0;
}
-void ShowPacket(uint Flags, struct PKT *PacketP)
-{
-}
-
/*
**
** How to use this file:
diff --git a/drivers/char/rio/rioctrl.c b/drivers/char/rio/rioctrl.c
index fcf18a06122..d31aba62bb7 100644
--- a/drivers/char/rio/rioctrl.c
+++ b/drivers/char/rio/rioctrl.c
@@ -51,15 +51,12 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -72,12 +69,10 @@ static char *_rioctrl_c_sccs_ = "@(#)rioctrl.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
@@ -131,30 +126,6 @@ static int
#define drv_makedev(maj, min) ((((uint) maj & 0xff) << 8) | ((uint) min & 0xff))
-int copyin(int arg, caddr_t dp, int siz)
-{
- int rv;
-
- rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes from user %p to %p.\n", siz, (void *) arg, dp);
- rv = copy_from_user(dp, (void *) arg, siz);
- if (rv)
- return COPYFAIL;
- else
- return rv;
-}
-
-static int copyout(caddr_t dp, int arg, int siz)
-{
- int rv;
-
- rio_dprintk(RIO_DEBUG_CTRL, "Copying %d bytes to user %p from %p.\n", siz, (void *) arg, dp);
- rv = copy_to_user((void *) arg, dp, siz);
- if (rv)
- return COPYFAIL;
- else
- return rv;
-}
-
int riocontrol(p, dev, cmd, arg, su)
struct rio_info *p;
dev_t dev;
@@ -168,7 +139,7 @@ int su;
ushort loop;
int Entry;
struct Port *PortP;
- PKT *PacketP;
+ struct PKT *PacketP;
int retval = 0;
unsigned long flags;
@@ -178,7 +149,7 @@ int su;
Host = 0;
PortP = NULL;
- rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: 0x%x\n", cmd, (int) arg);
+ rio_dprintk(RIO_DEBUG_CTRL, "control ioctl cmd: 0x%x arg: %p\n", cmd, arg);
switch (cmd) {
/*
@@ -189,90 +160,34 @@ int su;
** otherwise just the specified host card will be changed.
*/
case RIO_SET_TIMER:
- rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %dms\n", (uint) arg);
+ rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_TIMER to %ldms\n", (unsigned long)arg);
{
int host, value;
- host = (uint) arg >> 16;
- value = (uint) arg & 0x0000ffff;
+ host = ((unsigned long) arg >> 16) & 0x0000FFFF;
+ value = (unsigned long) arg & 0x0000ffff;
if (host == -1) {
for (host = 0; host < p->RIONumHosts; host++) {
if (p->RIOHosts[host].Flags == RC_RUNNING) {
- WWORD(p->RIOHosts[host].ParmMapP->timer, value);
+ writew(value, &p->RIOHosts[host].ParmMapP->timer);
}
}
} else if (host >= p->RIONumHosts) {
return -EINVAL;
} else {
if (p->RIOHosts[host].Flags == RC_RUNNING) {
- WWORD(p->RIOHosts[host].ParmMapP->timer, value);
+ writew(value, &p->RIOHosts[host].ParmMapP->timer);
}
}
}
return 0;
- case RIO_IDENTIFY_DRIVER:
- /*
- ** 15.10.1998 ARG - ESIL 0760 part fix
- ** Added driver ident string output.
- **
- #ifndef __THIS_RELEASE__
- #warning Driver Version string not defined !
- #endif
- cprintf("%s %s %s %s\n",
- RIO_DRV_STR,
- __THIS_RELEASE__,
- __DATE__, __TIME__ );
-
- return 0;
-
- case RIO_DISPLAY_HOST_CFG:
- **
- ** 15.10.1998 ARG - ESIL 0760 part fix
- ** Added driver host card ident string output.
- **
- ** Note that the only types currently supported
- ** are ISA and PCI. Also this driver does not
- ** (yet) distinguish between the Old PCI card
- ** and the Jet PCI card. In fact I think this
- ** driver only supports JET PCI !
- **
-
- for (Host = 0; Host < p->RIONumHosts; Host++)
- {
- HostP = &(p->RIOHosts[Host]);
-
- switch ( HostP->Type )
- {
- case RIO_AT :
- strcpy( host_type, RIO_AT_HOST_STR );
- break;
-
- case RIO_PCI :
- strcpy( host_type, RIO_PCI_HOST_STR );
- break;
-
- default :
- strcpy( host_type, "Unknown" );
- break;
- }
-
- cprintf(
- "RIO Host %d - Type:%s Addr:%X IRQ:%d\n",
- Host, host_type,
- (uint)HostP->PaddrP,
- (int)HostP->Ivec - 32 );
- }
- return 0;
- **
- */
-
case RIO_FOAD_RTA:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_FOAD_RTA\n");
- return RIOCommandRta(p, (uint) arg, RIOFoadRta);
+ return RIOCommandRta(p, (unsigned long)arg, RIOFoadRta);
case RIO_ZOMBIE_RTA:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_ZOMBIE_RTA\n");
- return RIOCommandRta(p, (uint) arg, RIOZombieRta);
+ return RIOCommandRta(p, (unsigned long)arg, RIOZombieRta);
case RIO_IDENTIFY_RTA:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_IDENTIFY_RTA\n");
@@ -287,7 +202,7 @@ int su;
struct CmdBlk *CmdBlkP;
rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD\n");
- if (copyin((int) arg, (caddr_t) & SpecialRupCmd, sizeof(SpecialRupCmd)) == COPYFAIL) {
+ if (copy_from_user(&SpecialRupCmd, arg, sizeof(SpecialRupCmd))) {
rio_dprintk(RIO_DEBUG_CTRL, "SPECIAL_RUP_CMD copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -302,7 +217,7 @@ int su;
SpecialRupCmd.Host = 0;
rio_dprintk(RIO_DEBUG_CTRL, "Queue special rup command for host %d rup %d\n", SpecialRupCmd.Host, SpecialRupCmd.RupNum);
if (RIOQueueCmdBlk(&p->RIOHosts[SpecialRupCmd.Host], SpecialRupCmd.RupNum, CmdBlkP) == RIO_FAIL) {
- cprintf("FAILED TO QUEUE SPECIAL RUP COMMAND\n");
+ printk(KERN_WARNING "rio: FAILED TO QUEUE SPECIAL RUP COMMAND\n");
}
return 0;
}
@@ -324,7 +239,7 @@ int su;
if ((retval = RIOApel(p)) != 0)
return retval;
- if (copyout((caddr_t) p->RIOConnectTable, (int) arg, TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) {
+ if (copy_to_user(arg, p->RIOConnectTable, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_TABLE copy failed\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -369,7 +284,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & p->RIOConnectTable[0], TOTAL_MAP_ENTRIES * sizeof(struct Map)) == COPYFAIL) {
+ if (copy_from_user(&p->RIOConnectTable[0], arg, TOTAL_MAP_ENTRIES * sizeof(struct Map))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_TABLE copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -415,7 +330,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyout((caddr_t) p->RIOBindTab, (int) arg, (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) {
+ if (copy_to_user(arg, p->RIOBindTab, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_BINDINGS copy failed\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -434,7 +349,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & p->RIOBindTab[0], (sizeof(ulong) * MAX_RTA_BINDINGS)) == COPYFAIL) {
+ if (copy_from_user(&p->RIOBindTab[0], arg, (sizeof(ulong) * MAX_RTA_BINDINGS))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_PUT_BINDINGS copy failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -458,12 +373,12 @@ int su;
for (Entry = 0; Entry < MAX_RTA_BINDINGS; Entry++) {
if ((EmptySlot == -1) && (p->RIOBindTab[Entry] == 0L))
EmptySlot = Entry;
- else if (p->RIOBindTab[Entry] == (int) arg) {
+ else if (p->RIOBindTab[Entry] == (long)arg) {
/*
** Already exists - delete
*/
p->RIOBindTab[Entry] = 0L;
- rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %x from p->RIOBindTab\n", (int) arg);
+ rio_dprintk(RIO_DEBUG_CTRL, "Removing Rta %ld from p->RIOBindTab\n", (unsigned long)arg);
return 0;
}
}
@@ -471,10 +386,10 @@ int su;
** Dosen't exist - add
*/
if (EmptySlot != -1) {
- p->RIOBindTab[EmptySlot] = (int) arg;
- rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %x to p->RIOBindTab\n", (int) arg);
+ p->RIOBindTab[EmptySlot] = (unsigned long)arg;
+ rio_dprintk(RIO_DEBUG_CTRL, "Adding Rta %lx to p->RIOBindTab\n", (unsigned long) arg);
} else {
- rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %x not added\n", (int) arg);
+ rio_dprintk(RIO_DEBUG_CTRL, "p->RIOBindTab full! - Rta %lx not added\n", (unsigned long) arg);
return -ENOMEM;
}
return 0;
@@ -482,7 +397,7 @@ int su;
case RIO_RESUME:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME\n");
- port = (uint) arg;
+ port = (unsigned long) arg;
if ((port < 0) || (port > 511)) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESUME: Bad port number %d\n", port);
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -518,8 +433,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
- == COPYFAIL) {
+ if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -533,8 +447,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
- == COPYFAIL) {
+ if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
rio_dprintk(RIO_DEBUG_CTRL, "Copy from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -548,8 +461,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & MapEnt, sizeof(MapEnt))
- == COPYFAIL) {
+ if (copy_from_user(&MapEnt, arg, sizeof(MapEnt))) {
rio_dprintk(RIO_DEBUG_CTRL, "Copy from data space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -557,30 +469,14 @@ int su;
return RIODeleteRta(p, &MapEnt);
case RIO_QUICK_CHECK:
- /*
- ** 09.12.1998 ARG - ESIL 0776 part fix
- ** A customer was using this to get the RTAs
- ** connect/disconnect status.
- ** RIOConCon() had been botched use RIOHalted
- ** to keep track of RTA connections and
- ** disconnections. That has been changed and
- ** RIORtaDisCons in the rio_info struct now
- ** does the job. So we need to return the value
- ** of RIORtaCons instead of RIOHalted.
- **
- if (copyout((caddr_t)&p->RIOHalted,(int)arg,
- sizeof(uint))==COPYFAIL) {
- **
- */
-
- if (copyout((caddr_t) & p->RIORtaDisCons, (int) arg, sizeof(uint)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->RIORtaDisCons, sizeof(unsigned int))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return 0;
case RIO_LAST_ERROR:
- if (copyout((caddr_t) & p->RIOError, (int) arg, sizeof(struct Error)) == COPYFAIL)
+ if (copy_to_user(arg, &p->RIOError, sizeof(struct Error)))
return -EFAULT;
return 0;
@@ -589,7 +485,7 @@ int su;
return -EINVAL;
case RIO_GET_MODTYPE:
- if (copyin((int) arg, (caddr_t) & port, sizeof(uint)) == COPYFAIL) {
+ if (copy_from_user(&port, arg, sizeof(unsigned int))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -609,36 +505,11 @@ int su;
** Return module type of port
*/
port = PortP->HostP->UnixRups[PortP->RupNum].ModTypes;
- if (copyout((caddr_t) & port, (int) arg, sizeof(uint)) == COPYFAIL) {
+ if (copy_to_user(arg, &port, sizeof(unsigned int))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return (0);
- /*
- ** 02.03.1999 ARG - ESIL 0820 fix
- ** We are no longer using "Boot Mode", so these ioctls
- ** are not required :
- **
- case RIO_GET_BOOT_MODE :
- rio_dprint(RIO_DEBUG_CTRL, ("Get boot mode - %x\n", p->RIOBootMode));
- **
- ** Return boot state of system - BOOT_ALL, BOOT_OWN or BOOT_NONE
- **
- if (copyout((caddr_t)&p->RIOBootMode, (int)arg,
- sizeof(p->RIOBootMode)) == COPYFAIL) {
- p->RIOError.Error = COPYOUT_FAILED;
- return -EFAULT;
- }
- return(0);
-
- case RIO_SET_BOOT_MODE :
- p->RIOBootMode = (uint) arg;
- rio_dprint(RIO_DEBUG_CTRL, ("Set boot mode to 0x%x\n", p->RIOBootMode));
- return(0);
- **
- ** End ESIL 0820 fix
- */
-
case RIO_BLOCK_OPENS:
rio_dprintk(RIO_DEBUG_CTRL, "Opens block until booted\n");
for (Entry = 0; Entry < RIO_PORTS; Entry++) {
@@ -650,8 +521,7 @@ int su;
case RIO_SETUP_PORTS:
rio_dprintk(RIO_DEBUG_CTRL, "Setup ports\n");
- if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup))
- == COPYFAIL) {
+ if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
p->RIOError.Error = COPYIN_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "EFAULT");
return -EFAULT;
@@ -667,7 +537,7 @@ int su;
return -EINVAL;
}
if (!p->RIOPortp) {
- cprintf("No p->RIOPortp array!\n");
+ printk(KERN_ERR "rio: No p->RIOPortp array!\n");
rio_dprintk(RIO_DEBUG_CTRL, "No p->RIOPortp array!\n");
return -EIO;
}
@@ -681,8 +551,7 @@ int su;
case RIO_GET_PORT_SETUP:
rio_dprintk(RIO_DEBUG_CTRL, "Get port setup\n");
- if (copyin((int) arg, (caddr_t) & PortSetup, sizeof(PortSetup))
- == COPYFAIL) {
+ if (copy_from_user(&PortSetup, arg, sizeof(PortSetup))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -698,13 +567,12 @@ int su;
PortSetup.Store = p->RIOPortp[port]->Store;
PortSetup.Lock = p->RIOPortp[port]->Lock;
PortSetup.XpCps = p->RIOPortp[port]->Xprint.XpCps;
- bcopy(p->RIOPortp[port]->Xprint.XpOn, PortSetup.XpOn, MAX_XP_CTRL_LEN);
- bcopy(p->RIOPortp[port]->Xprint.XpOff, PortSetup.XpOff, MAX_XP_CTRL_LEN);
+ memcpy(PortSetup.XpOn, p->RIOPortp[port]->Xprint.XpOn, MAX_XP_CTRL_LEN);
+ memcpy(PortSetup.XpOff, p->RIOPortp[port]->Xprint.XpOff, MAX_XP_CTRL_LEN);
PortSetup.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';
PortSetup.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';
- if (copyout((caddr_t) & PortSetup, (int) arg, sizeof(PortSetup))
- == COPYFAIL) {
+ if (copy_to_user(arg, &PortSetup, sizeof(PortSetup))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
@@ -712,7 +580,7 @@ int su;
case RIO_GET_PORT_PARAMS:
rio_dprintk(RIO_DEBUG_CTRL, "Get port params\n");
- if (copyin((int) arg, (caddr_t) & PortParams, sizeof(struct PortParams)) == COPYFAIL) {
+ if (copy_from_user(&PortParams, arg, sizeof(struct PortParams))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -725,7 +593,7 @@ int su;
PortParams.State = PortP->State;
rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortParams.Port);
- if (copyout((caddr_t) & PortParams, (int) arg, sizeof(struct PortParams)) == COPYFAIL) {
+ if (copy_to_user(arg, &PortParams, sizeof(struct PortParams))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
@@ -733,8 +601,7 @@ int su;
case RIO_GET_PORT_TTY:
rio_dprintk(RIO_DEBUG_CTRL, "Get port tty\n");
- if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty))
- == COPYFAIL) {
+ if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -745,14 +612,14 @@ int su;
rio_dprintk(RIO_DEBUG_CTRL, "Port %d\n", PortTty.port);
PortP = (p->RIOPortp[PortTty.port]);
- if (copyout((caddr_t) & PortTty, (int) arg, sizeof(struct PortTty)) == COPYFAIL) {
+ if (copy_to_user(arg, &PortTty, sizeof(struct PortTty))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return retval;
case RIO_SET_PORT_TTY:
- if (copyin((int) arg, (caddr_t) & PortTty, sizeof(struct PortTty)) == COPYFAIL) {
+ if (copy_from_user(&PortTty, arg, sizeof(struct PortTty))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -767,8 +634,7 @@ int su;
case RIO_SET_PORT_PARAMS:
rio_dprintk(RIO_DEBUG_CTRL, "Set port params\n");
- if (copyin((int) arg, (caddr_t) & PortParams, sizeof(PortParams))
- == COPYFAIL) {
+ if (copy_from_user(&PortParams, arg, sizeof(PortParams))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -784,7 +650,7 @@ int su;
case RIO_GET_PORT_STATS:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GET_PORT_STATS\n");
- if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) {
+ if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -799,14 +665,14 @@ int su;
portStats.opens = PortP->opens;
portStats.closes = PortP->closes;
portStats.ioctls = PortP->ioctls;
- if (copyout((caddr_t) & portStats, (int) arg, sizeof(struct portStats)) == COPYFAIL) {
+ if (copy_to_user(arg, &portStats, sizeof(struct portStats))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return retval;
case RIO_RESET_PORT_STATS:
- port = (uint) arg;
+ port = (unsigned long) arg;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_RESET_PORT_STATS\n");
if (port >= RIO_PORTS) {
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -824,7 +690,7 @@ int su;
case RIO_GATHER_PORT_STATS:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GATHER_PORT_STATS\n");
- if (copyin((int) arg, (caddr_t) & portStats, sizeof(struct portStats)) == COPYFAIL) {
+ if (copy_from_user(&portStats, arg, sizeof(struct portStats))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -840,7 +706,7 @@ int su;
case RIO_READ_CONFIG:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_CONFIG\n");
- if (copyout((caddr_t) & p->RIOConf, (int) arg, sizeof(struct Conf)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->RIOConf, sizeof(struct Conf))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
@@ -852,8 +718,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & p->RIOConf, sizeof(struct Conf))
- == COPYFAIL) {
+ if (copy_from_user(&p->RIOConf, arg, sizeof(struct Conf))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -862,7 +727,7 @@ int su;
*/
for (Host = 0; Host < p->RIONumHosts; Host++)
if ((p->RIOHosts[Host].Flags & RUN_STATE) == RC_RUNNING)
- WWORD(p->RIOHosts[Host].ParmMapP->timer, p->RIOConf.Timer);
+ writew(p->RIOConf.Timer, &p->RIOHosts[Host].ParmMapP->timer);
return retval;
case RIO_START_POLLER:
@@ -881,8 +746,7 @@ int su;
case RIO_SETDEBUG:
case RIO_GETDEBUG:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_SETDEBUG/RIO_GETDEBUG\n");
- if (copyin((int) arg, (caddr_t) & DebugCtrl, sizeof(DebugCtrl))
- == COPYFAIL) {
+ if (copy_from_user(&DebugCtrl, arg, sizeof(DebugCtrl))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -899,7 +763,7 @@ int su;
rio_dprintk(RIO_DEBUG_CTRL, "Get global debug 0x%x wait 0x%x\n", p->rio_debug, p->RIODebugWait);
DebugCtrl.Debug = p->rio_debug;
DebugCtrl.Wait = p->RIODebugWait;
- if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) {
+ if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET/GET DEBUG: bad port number %d\n", DebugCtrl.SysPort);
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -921,7 +785,7 @@ int su;
} else {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG 0x%x\n", p->RIOPortp[DebugCtrl.SysPort]->Debug);
DebugCtrl.Debug = p->RIOPortp[DebugCtrl.SysPort]->Debug;
- if (copyout((caddr_t) & DebugCtrl, (int) arg, sizeof(DebugCtrl)) == COPYFAIL) {
+ if (copy_to_user(arg, &DebugCtrl, sizeof(DebugCtrl))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_GETDEBUG: Bad copy to user space\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -936,43 +800,20 @@ int su;
** textual null terminated string.
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID\n");
- if (copyout((caddr_t) RIOVersid(), (int) arg, sizeof(struct rioVersion)) == COPYFAIL) {
+ if (copy_to_user(arg, RIOVersid(), sizeof(struct rioVersion))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_VERSID: Bad copy to user space (host=%d)\n", Host);
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return retval;
- /*
- ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ** !! commented out previous 'RIO_VERSID' functionality !!
- ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- **
- case RIO_VERSID:
- **
- ** Enquire about the release and version.
- ** We return MAX_VERSION_LEN bytes, being a textual null
- ** terminated string.
- **
- rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID\n"));
- if (copyout((caddr_t)RIOVersid(),
- (int)arg, MAX_VERSION_LEN ) == COPYFAIL ) {
- rio_dprint(RIO_DEBUG_CTRL, ("RIO_VERSID: Bad copy to user space\n",Host));
- p->RIOError.Error = COPYOUT_FAILED;
- return -EFAULT;
- }
- return retval;
- **
- ** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- */
-
case RIO_NUM_HOSTS:
/*
** Enquire as to the number of hosts located
** at init time.
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS\n");
- if (copyout((caddr_t) & p->RIONumHosts, (int) arg, sizeof(p->RIONumHosts)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->RIONumHosts, sizeof(p->RIONumHosts))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_NUM_HOSTS: Bad copy to user space\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -983,7 +824,7 @@ int su;
/*
** Kill host. This may not be in the final version...
*/
- rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %d\n", (int) arg);
+ rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD %ld\n", (unsigned long) arg);
if (!su) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_FOAD: Not super user\n");
p->RIOError.Error = NOT_SUPER_USER;
@@ -994,7 +835,7 @@ int su;
for (Host = 0; Host < p->RIONumHosts; Host++) {
(void) RIOBoardTest(p->RIOHosts[Host].PaddrP, p->RIOHosts[Host].Caddr, p->RIOHosts[Host].Type, p->RIOHosts[Host].Slot);
- bzero((caddr_t) & p->RIOHosts[Host].Flags, ((int) &p->RIOHosts[Host].____end_marker____) - ((int) &p->RIOHosts[Host].Flags));
+ memset(&p->RIOHosts[Host].Flags, 0, ((char *) &p->RIOHosts[Host].____end_marker____) - ((char *) &p->RIOHosts[Host].Flags));
p->RIOHosts[Host].Flags = RC_WAITING;
}
RIOFoadWakeup(p);
@@ -1017,7 +858,7 @@ int su;
p->RIOError.Error = NOT_SUPER_USER;
return -EPERM;
}
- if (copyin((int) arg, (caddr_t) & DownLoad, sizeof(DownLoad)) == COPYFAIL) {
+ if (copy_from_user(&DownLoad, arg, sizeof(DownLoad))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_DOWNLOAD: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1045,9 +886,9 @@ int su;
case RIO_PARMS:
{
- uint host;
+ unsigned int host;
- if (copyin((int) arg, (caddr_t) & host, sizeof(host)) == COPYFAIL) {
+ if (copy_from_user(&host, arg, sizeof(host))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1056,7 +897,7 @@ int su;
** Fetch the parmmap
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS\n");
- if (copyout((caddr_t) p->RIOHosts[host].ParmMapP, (int) arg, sizeof(PARM_MAP)) == COPYFAIL) {
+ if (copy_to_user(arg, p->RIOHosts[host].ParmMapP, sizeof(PARM_MAP))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_PARMS: Copy out to user space failed\n");
return -EFAULT;
@@ -1066,7 +907,7 @@ int su;
case RIO_HOST_REQ:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ\n");
- if (copyin((int) arg, (caddr_t) & HostReq, sizeof(HostReq)) == COPYFAIL) {
+ if (copy_from_user(&HostReq, arg, sizeof(HostReq))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1078,7 +919,7 @@ int su;
}
rio_dprintk(RIO_DEBUG_CTRL, "Request for host %d\n", HostReq.HostNum);
- if (copyout((caddr_t) & p->RIOHosts[HostReq.HostNum], (int) HostReq.HostP, sizeof(struct Host)) == COPYFAIL) {
+ if (copy_to_user(HostReq.HostP, &p->RIOHosts[HostReq.HostNum], sizeof(struct Host))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_REQ: Bad copy to user space\n");
return -EFAULT;
@@ -1087,7 +928,7 @@ int su;
case RIO_HOST_DPRAM:
rio_dprintk(RIO_DEBUG_CTRL, "Request for DPRAM\n");
- if (copyin((int) arg, (caddr_t) & HostDpRam, sizeof(HostDpRam)) == COPYFAIL) {
+ if (copy_from_user(&HostDpRam, arg, sizeof(HostDpRam))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1104,13 +945,13 @@ int su;
/* It's hardware like this that really gets on my tits. */
static unsigned char copy[sizeof(struct DpRam)];
for (off = 0; off < sizeof(struct DpRam); off++)
- copy[off] = p->RIOHosts[HostDpRam.HostNum].Caddr[off];
- if (copyout((caddr_t) copy, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) {
+ copy[off] = readb(&p->RIOHosts[HostDpRam.HostNum].Caddr[off]);
+ if (copy_to_user(HostDpRam.DpRamP, copy, sizeof(struct DpRam))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
return -EFAULT;
}
- } else if (copyout((caddr_t) p->RIOHosts[HostDpRam.HostNum].Caddr, (int) HostDpRam.DpRamP, sizeof(struct DpRam)) == COPYFAIL) {
+ } else if (copy_to_user(HostDpRam.DpRamP, p->RIOHosts[HostDpRam.HostNum].Caddr, sizeof(struct DpRam))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_DPRAM: Bad copy to user space\n");
return -EFAULT;
@@ -1119,13 +960,13 @@ int su;
case RIO_SET_BUSY:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY\n");
- if ((int) arg < 0 || (int) arg > 511) {
- rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %d\n", (int) arg);
+ if ((unsigned long) arg > 511) {
+ rio_dprintk(RIO_DEBUG_CTRL, "RIO_SET_BUSY: Bad port number %ld\n", (unsigned long) arg);
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
return -EINVAL;
}
rio_spin_lock_irqsave(&PortP->portSem, flags);
- p->RIOPortp[(int) arg]->State |= RIO_BUSY;
+ p->RIOPortp[(unsigned long) arg]->State |= RIO_BUSY;
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
return retval;
@@ -1135,7 +976,7 @@ int su;
** (probably for debug reasons)
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT\n");
- if (copyin((int) arg, (caddr_t) & PortReq, sizeof(PortReq)) == COPYFAIL) {
+ if (copy_from_user(&PortReq, arg, sizeof(PortReq))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1147,7 +988,7 @@ int su;
return -ENXIO;
}
rio_dprintk(RIO_DEBUG_CTRL, "Request for port %d\n", PortReq.SysPort);
- if (copyout((caddr_t) p->RIOPortp[PortReq.SysPort], (int) PortReq.PortP, sizeof(struct Port)) == COPYFAIL) {
+ if (copy_to_user(PortReq.PortP, p->RIOPortp[PortReq.SysPort], sizeof(struct Port))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_PORT: Bad copy to user space\n");
return -EFAULT;
@@ -1160,7 +1001,7 @@ int su;
** (probably for debug reasons)
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP\n");
- if (copyin((int) arg, (caddr_t) & RupReq, sizeof(RupReq)) == COPYFAIL) {
+ if (copy_from_user(&RupReq, arg, sizeof(RupReq))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Copy in from user space failed\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1184,7 +1025,7 @@ int su;
}
rio_dprintk(RIO_DEBUG_CTRL, "Request for rup %d from host %d\n", RupReq.RupNum, RupReq.HostNum);
- if (copyout((caddr_t) HostP->UnixRups[RupReq.RupNum].RupP, (int) RupReq.RupP, sizeof(struct RUP)) == COPYFAIL) {
+ if (copy_to_user(HostP->UnixRups[RupReq.RupNum].RupP, RupReq.RupP, sizeof(struct RUP))) {
p->RIOError.Error = COPYOUT_FAILED;
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_RUP: Bad copy to user space\n");
return -EFAULT;
@@ -1197,7 +1038,7 @@ int su;
** (probably for debug reasons)
*/
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB\n");
- if (copyin((int) arg, (caddr_t) & LpbReq, sizeof(LpbReq)) == COPYFAIL) {
+ if (copy_from_user(&LpbReq, arg, sizeof(LpbReq))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy from user space\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1221,7 +1062,7 @@ int su;
}
rio_dprintk(RIO_DEBUG_CTRL, "Request for lpb %d from host %d\n", LpbReq.Link, LpbReq.Host);
- if (copyout((caddr_t) & HostP->LinkStrP[LpbReq.Link], (int) LpbReq.LpbP, sizeof(struct LPB)) == COPYFAIL) {
+ if (copy_to_user(LpbReq.LpbP, &HostP->LinkStrP[LpbReq.Link], sizeof(struct LPB))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_HOST_LPB: Bad copy to user space\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -1252,12 +1093,13 @@ int su;
p->RIOError.Error = SIGNALS_ALREADY_SET;
return -EBUSY;
}
- p->RIOSignalProcess = getpid();
+ /* FIXME: PID tracking */
+ p->RIOSignalProcess = current->pid;
p->RIOPrintDisabled = DONT_PRINT;
return retval;
case RIO_SIGNALS_OFF:
- if (p->RIOSignalProcess != getpid()) {
+ if (p->RIOSignalProcess != current->pid) {
p->RIOError.Error = NOT_RECEIVING_PROCESS;
return -EPERM;
}
@@ -1294,7 +1136,7 @@ int su;
case RIO_MAP_B110_TO_110:
case RIO_MAP_B110_TO_115200:
rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping\n");
- port = (uint) arg;
+ port = (unsigned long) arg;
if (port < 0 || port > 511) {
rio_dprintk(RIO_DEBUG_CTRL, "Baud rate mapping: Bad port number %d\n", port);
p->RIOError.Error = PORT_NUMBER_OUT_OF_RANGE;
@@ -1324,7 +1166,7 @@ int su;
case RIO_SEND_PACKET:
rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET\n");
- if (copyin((int) arg, (caddr_t) & SendPack, sizeof(SendPack)) == COPYFAIL) {
+ if (copy_from_user(&SendPack, arg, sizeof(SendPack))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_SEND_PACKET: Bad copy from user space\n");
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
@@ -1344,9 +1186,9 @@ int su;
}
for (loop = 0; loop < (ushort) (SendPack.Len & 127); loop++)
- WBYTE(PacketP->data[loop], SendPack.Data[loop]);
+ writeb(SendPack.Data[loop], &PacketP->data[loop]);
- WBYTE(PacketP->len, SendPack.Len);
+ writeb(SendPack.Len, &PacketP->len);
add_transmit(PortP);
/*
@@ -1368,7 +1210,7 @@ int su;
return su ? 0 : -EPERM;
case RIO_WHAT_MESG:
- if (copyout((caddr_t) & p->RIONoMessage, (int) arg, sizeof(p->RIONoMessage)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->RIONoMessage, sizeof(p->RIONoMessage))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_WHAT_MESG: Bad copy to user space\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -1376,7 +1218,7 @@ int su;
return 0;
case RIO_MEM_DUMP:
- if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) {
+ if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -1406,7 +1248,7 @@ int su;
PortP->State |= RIO_BUSY;
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- if (copyout((caddr_t) p->RIOMemDump, (int) arg, MEMDUMP_SIZE) == COPYFAIL) {
+ if (copy_to_user(arg, p->RIOMemDump, MEMDUMP_SIZE)) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_MEM_DUMP copy failed\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -1414,30 +1256,30 @@ int su;
return 0;
case RIO_TICK:
- if ((int) arg < 0 || (int) arg >= p->RIONumHosts)
+ if ((unsigned long) arg >= p->RIONumHosts)
return -EINVAL;
- rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %d\n", (int) arg);
- WBYTE(p->RIOHosts[(int) arg].SetInt, 0xff);
+ rio_dprintk(RIO_DEBUG_CTRL, "Set interrupt for host %ld\n", (unsigned long) arg);
+ writeb(0xFF, &p->RIOHosts[(unsigned long) arg].SetInt);
return 0;
case RIO_TOCK:
- if ((int) arg < 0 || (int) arg >= p->RIONumHosts)
+ if ((unsigned long) arg >= p->RIONumHosts)
return -EINVAL;
- rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %d\n", (int) arg);
- WBYTE((p->RIOHosts[(int) arg].ResetInt), 0xff);
+ rio_dprintk(RIO_DEBUG_CTRL, "Clear interrupt for host %ld\n", (unsigned long) arg);
+ writeb(0xFF, &p->RIOHosts[(unsigned long) arg].ResetInt);
return 0;
case RIO_READ_CHECK:
/* Check reads for pkts with data[0] the same */
p->RIOReadCheck = !p->RIOReadCheck;
- if (copyout((caddr_t) & p->RIOReadCheck, (int) arg, sizeof(uint)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->RIOReadCheck, sizeof(unsigned int))) {
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
}
return 0;
case RIO_READ_REGISTER:
- if (copyin((int) arg, (caddr_t) & SubCmd, sizeof(struct SubCmdStruct)) == COPYFAIL) {
+ if (copy_from_user(&SubCmd, arg, sizeof(struct SubCmdStruct))) {
p->RIOError.Error = COPYIN_FAILED;
return -EFAULT;
}
@@ -1472,7 +1314,7 @@ int su;
PortP->State |= RIO_BUSY;
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- if (copyout((caddr_t) & p->CdRegister, (int) arg, sizeof(uint)) == COPYFAIL) {
+ if (copy_to_user(arg, &p->CdRegister, sizeof(unsigned int))) {
rio_dprintk(RIO_DEBUG_CTRL, "RIO_READ_REGISTER copy failed\n");
p->RIOError.Error = COPYOUT_FAILED;
return -EFAULT;
@@ -1485,21 +1327,22 @@ int su;
*/
case RIO_MAKE_DEV:
{
- uint port = (uint) arg & RIO_MODEM_MASK;
+ unsigned int port = (unsigned long) arg & RIO_MODEM_MASK;
+ unsigned int ret;
- switch ((uint) arg & RIO_DEV_MASK) {
+ switch ((unsigned long) arg & RIO_DEV_MASK) {
case RIO_DEV_DIRECT:
- arg = (caddr_t) drv_makedev(MAJOR(dev), port);
- rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, (int) arg);
- return (int) arg;
+ ret = drv_makedev(MAJOR(dev), port);
+ rio_dprintk(RIO_DEBUG_CTRL, "Makedev direct 0x%x is 0x%x\n", port, ret);
+ return ret;
case RIO_DEV_MODEM:
- arg = (caddr_t) drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
- rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, (int) arg);
- return (int) arg;
+ ret = drv_makedev(MAJOR(dev), (port | RIO_MODEM_BIT));
+ rio_dprintk(RIO_DEBUG_CTRL, "Makedev modem 0x%x is 0x%x\n", port, ret);
+ return ret;
case RIO_DEV_XPRINT:
- arg = (caddr_t) drv_makedev(MAJOR(dev), port);
- rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, (int) arg);
- return (int) arg;
+ ret = drv_makedev(MAJOR(dev), port);
+ rio_dprintk(RIO_DEBUG_CTRL, "Makedev printer 0x%x is 0x%x\n", port, ret);
+ return ret;
}
rio_dprintk(RIO_DEBUG_CTRL, "MAKE Device is called\n");
return -EINVAL;
@@ -1513,18 +1356,19 @@ int su;
{
dev_t dv;
int mino;
+ unsigned long ret;
- dv = (dev_t) ((int) arg);
+ dv = (dev_t) ((unsigned long) arg);
mino = RIO_UNMODEM(dv);
if (RIO_ISMODEM(dv)) {
rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: modem %d\n", dv, mino);
- arg = (caddr_t) (mino | RIO_DEV_MODEM);
+ ret = mino | RIO_DEV_MODEM;
} else {
rio_dprintk(RIO_DEBUG_CTRL, "Minor for device 0x%x: direct %d\n", dv, mino);
- arg = (caddr_t) (mino | RIO_DEV_DIRECT);
+ ret = mino | RIO_DEV_DIRECT;
}
- return (int) arg;
+ return ret;
}
}
rio_dprintk(RIO_DEBUG_CTRL, "INVALID DAEMON IOCTL 0x%x\n", cmd);
@@ -1537,10 +1381,7 @@ int su;
/*
** Pre-emptive commands go on RUPs and are only one byte long.
*/
-int RIOPreemptiveCmd(p, PortP, Cmd)
-struct rio_info *p;
-struct Port *PortP;
-uchar Cmd;
+int RIOPreemptiveCmd(struct rio_info *p, struct Port *PortP, u8 Cmd)
{
struct CmdBlk *CmdBlkP;
struct PktCmd_M *PktCmdP;
@@ -1558,7 +1399,7 @@ uchar Cmd;
return RIO_FAIL;
}
- rio_dprintk(RIO_DEBUG_CTRL, "Command blk 0x%x - InUse now %d\n", (int) CmdBlkP, PortP->InUse);
+ rio_dprintk(RIO_DEBUG_CTRL, "Command blk %p - InUse now %d\n", CmdBlkP, PortP->InUse);
PktCmdP = (struct PktCmd_M *) &CmdBlkP->Packet.data[0];
@@ -1572,7 +1413,7 @@ uchar Cmd;
CmdBlkP->Packet.dest_port = COMMAND_RUP;
CmdBlkP->Packet.len = PKT_CMD_BIT | 2;
CmdBlkP->PostFuncP = RIOUnUse;
- CmdBlkP->PostArg = (int) PortP;
+ CmdBlkP->PostArg = (unsigned long) PortP;
PktCmdP->Command = Cmd;
port = PortP->HostPort % (ushort) PORTS_PER_RTA;
/*
@@ -1584,38 +1425,38 @@ uchar Cmd;
switch (Cmd) {
case MEMDUMP:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk 0x%x (addr 0x%x)\n", (int) CmdBlkP, (int) SubCmd.Addr);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue MEMDUMP command blk %p (addr 0x%x)\n", CmdBlkP, (int) SubCmd.Addr);
PktCmdP->SubCommand = MEMDUMP;
PktCmdP->SubAddr = SubCmd.Addr;
break;
case FCLOSE:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue FCLOSE command blk %p\n", CmdBlkP);
break;
case READ_REGISTER:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk 0x%x\n", (int) SubCmd.Addr, (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue READ_REGISTER (0x%x) command blk %p\n", (int) SubCmd.Addr, CmdBlkP);
PktCmdP->SubCommand = READ_REGISTER;
PktCmdP->SubAddr = SubCmd.Addr;
break;
case RESUME:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue RESUME command blk %p\n", CmdBlkP);
break;
case RFLUSH:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue RFLUSH command blk %p\n", CmdBlkP);
CmdBlkP->PostFuncP = RIORFlushEnable;
break;
case SUSPEND:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue SUSPEND command blk %p\n", CmdBlkP);
break;
case MGET:
- rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue MGET command blk %p\n", CmdBlkP);
break;
case MSET:
case MBIC:
case MBIS:
CmdBlkP->Packet.data[4] = (char) PortP->ModemLines;
- rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue MSET/MBIC/MBIS command blk %p\n", CmdBlkP);
break;
case WFLUSH:
@@ -1629,7 +1470,7 @@ uchar Cmd;
RIOFreeCmdBlk(CmdBlkP);
return (RIO_FAIL);
} else {
- rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk 0x%x\n", (int) CmdBlkP);
+ rio_dprintk(RIO_DEBUG_CTRL, "Queue WFLUSH command blk %p\n", CmdBlkP);
CmdBlkP->PostFuncP = RIOWFlushMark;
}
break;
diff --git a/drivers/char/rio/riodrvr.h b/drivers/char/rio/riodrvr.h
index 663ee0914ed..3cffe275f21 100644
--- a/drivers/char/rio/riodrvr.h
+++ b/drivers/char/rio/riodrvr.h
@@ -72,42 +72,42 @@ struct rio_info {
*/
int RIOHalted; /* halted ? */
int RIORtaDisCons; /* RTA connections/disconnections */
- uint RIOReadCheck; /* Rio read check */
- uint RIONoMessage; /* To display message or not */
- uint RIONumBootPkts; /* how many packets for an RTA */
- uint RIOBootCount; /* size of RTA code */
- uint RIOBooting; /* count of outstanding boots */
- uint RIOSystemUp; /* Booted ?? */
- uint RIOCounting; /* for counting interrupts */
- uint RIOIntCount; /* # of intr since last check */
- uint RIOTxCount; /* number of xmit intrs */
- uint RIORxCount; /* number of rx intrs */
- uint RIORupCount; /* number of rup intrs */
+ unsigned int RIOReadCheck; /* Rio read check */
+ unsigned int RIONoMessage; /* To display message or not */
+ unsigned int RIONumBootPkts; /* how many packets for an RTA */
+ unsigned int RIOBootCount; /* size of RTA code */
+ unsigned int RIOBooting; /* count of outstanding boots */
+ unsigned int RIOSystemUp; /* Booted ?? */
+ unsigned int RIOCounting; /* for counting interrupts */
+ unsigned int RIOIntCount; /* # of intr since last check */
+ unsigned int RIOTxCount; /* number of xmit intrs */
+ unsigned int RIORxCount; /* number of rx intrs */
+ unsigned int RIORupCount; /* number of rup intrs */
int RIXTimer;
int RIOBufferSize; /* Buffersize */
int RIOBufferMask; /* Buffersize */
int RIOFirstMajor; /* First host card's major no */
- uint RIOLastPortsMapped; /* highest port number known */
- uint RIOFirstPortsMapped; /* lowest port number known */
+ unsigned int RIOLastPortsMapped; /* highest port number known */
+ unsigned int RIOFirstPortsMapped; /* lowest port number known */
- uint RIOLastPortsBooted; /* highest port number running */
- uint RIOFirstPortsBooted; /* lowest port number running */
+ unsigned int RIOLastPortsBooted; /* highest port number running */
+ unsigned int RIOFirstPortsBooted; /* lowest port number running */
- uint RIOLastPortsOpened; /* highest port number running */
- uint RIOFirstPortsOpened; /* lowest port number running */
+ unsigned int RIOLastPortsOpened; /* highest port number running */
+ unsigned int RIOFirstPortsOpened; /* lowest port number running */
/* Flag to say that the topology information has been changed. */
- uint RIOQuickCheck;
- uint CdRegister; /* ??? */
+ unsigned int RIOQuickCheck;
+ unsigned int CdRegister; /* ??? */
int RIOSignalProcess; /* Signalling process */
int rio_debug; /* To debug ... */
int RIODebugWait; /* For what ??? */
int tpri; /* Thread prio */
int tid; /* Thread id */
- uint _RIO_Polled; /* Counter for polling */
- uint _RIO_Interrupted; /* Counter for interrupt */
+ unsigned int _RIO_Polled; /* Counter for polling */
+ unsigned int _RIO_Interrupted; /* Counter for interrupt */
int intr_tid; /* iointset return value */
int TxEnSem; /* TxEnable Semaphore */
@@ -121,9 +121,9 @@ struct rio_info {
struct Map RIOSavedTable[TOTAL_MAP_ENTRIES];
/* RTA to host binding table for master/slave operation */
- ulong RIOBindTab[MAX_RTA_BINDINGS];
+ unsigned long RIOBindTab[MAX_RTA_BINDINGS];
/* RTA memory dump variable */
- uchar RIOMemDump[MEMDUMP_SIZE];
+ unsigned char RIOMemDump[MEMDUMP_SIZE];
struct ModuleInfo RIOModuleTypes[MAX_MODULE_TYPES];
};
@@ -138,7 +138,5 @@ struct rio_info {
#define RIO_RESET_INT 0x7d80
-#define WRBYTE(x,y) *(volatile unsigned char *)((x)) = \
- (unsigned char)(y)
#endif /* __riodrvr.h */
diff --git a/drivers/char/rio/rioinit.c b/drivers/char/rio/rioinit.c
index 0d44ef464e6..24d2992154c 100644
--- a/drivers/char/rio/rioinit.c
+++ b/drivers/char/rio/rioinit.c
@@ -51,15 +51,12 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
#include "linux_compat.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -72,22 +69,17 @@ static char *_rioinit_c_sccs_ = "@(#)rioinit.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "rio_linux.h"
-#undef bcopy
-#define bcopy rio_pcicopy
-
int RIOPCIinit(struct rio_info *p, int Mode);
-static int RIOScrub(int, BYTE *, int);
+static int RIOScrub(int, u8 *, int);
/**
@@ -99,12 +91,8 @@ static int RIOScrub(int, BYTE *, int);
** bits < 0 indicates 8 bit operation requested,
** bits > 0 indicates 16 bit operation.
*/
-int
-RIOAssignAT(p, Base, virtAddr, mode)
-struct rio_info * p;
-int Base;
-caddr_t virtAddr;
-int mode;
+
+int RIOAssignAT(struct rio_info *p, int Base, caddr_t virtAddr, int mode)
{
int bits;
struct DpRam *cardp = (struct DpRam *)virtAddr;
@@ -124,29 +112,25 @@ int mode;
/*
** Revision 01 AT host cards don't support WORD operations,
*/
- if ( RBYTE(cardp->DpRevision) == 01 )
+ if (readb(&cardp->DpRevision) == 01)
bits = BYTE_OPERATION;
p->RIOHosts[p->RIONumHosts].Type = RIO_AT;
- p->RIOHosts[p->RIONumHosts].Copy = bcopy;
+ p->RIOHosts[p->RIONumHosts].Copy = rio_copy_to_card;
/* set this later */
p->RIOHosts[p->RIONumHosts].Slot = -1;
p->RIOHosts[p->RIONumHosts].Mode = SLOW_LINKS | SLOW_AT_BUS | bits;
- WBYTE(p->RIOHosts[p->RIONumHosts].Control,
- BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
- p->RIOHosts[p->RIONumHosts].Mode |
- INTERRUPT_DISABLE );
- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);
- WBYTE(p->RIOHosts[p->RIONumHosts].Control,
- BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
- p->RIOHosts[p->RIONumHosts].Mode |
- INTERRUPT_DISABLE );
- WBYTE(p->RIOHosts[p->RIONumHosts].ResetInt,0xff);
+ writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE ,
+ &p->RIOHosts[p->RIONumHosts].Control);
+ writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
+ writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | p->RIOHosts[p->RIONumHosts].Mode | INTERRUPT_DISABLE,
+ &p->RIOHosts[p->RIONumHosts].Control);
+ writeb(0xFF, &p->RIOHosts[p->RIONumHosts].ResetInt);
p->RIOHosts[p->RIONumHosts].UniqueNum =
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|
- ((RBYTE(p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[0])&0xFF)<<0)|
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[1])&0xFF)<<8)|
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[2])&0xFF)<<16)|
+ ((readb(&p->RIOHosts[p->RIONumHosts].Unique[3])&0xFF)<<24);
rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Uniquenum 0x%x\n",p->RIOHosts[p->RIONumHosts].UniqueNum);
p->RIONumHosts++;
@@ -154,7 +138,7 @@ int mode;
return(1);
}
-static uchar val[] = {
+static u8 val[] = {
#ifdef VERY_LONG_TEST
0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80,
0xa5, 0xff, 0x5a, 0x00, 0xff, 0xc9, 0x36,
@@ -167,12 +151,7 @@ static uchar val[] = {
** RAM test a board.
** Nothing too complicated, just enough to check it out.
*/
-int
-RIOBoardTest(paddr, caddr, type, slot)
-paddr_t paddr;
-caddr_t caddr;
-uchar type;
-int slot;
+int RIOBoardTest(unsigned long paddr, caddr_t caddr, unsigned char type, int slot)
{
struct DpRam *DpRam = (struct DpRam *)caddr;
char *ram[4];
@@ -180,8 +159,8 @@ int slot;
int op, bank;
int nbanks;
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=0x%x, slot=%d\n",
- type,(int)DpRam, slot);
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Reset host type=%d, DpRam=%p, slot=%d\n",
+ type, DpRam, slot);
RIOHostReset(type, DpRam, slot);
@@ -209,12 +188,11 @@ int slot;
if (nbanks == 3) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n",
- (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2]);
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Memory: %p(0x%x), %p(0x%x), %p(0x%x)\n",
+ ram[0], size[0], ram[1], size[1], ram[2], size[2]);
} else {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x), 0x%x(0x%x)\n",
- (int)ram[0], size[0], (int)ram[1], size[1], (int)ram[2], size[2], (int)ram[3],
- size[3]);
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: %p(0x%x), %p(0x%x), %p(0x%x), %p(0x%x)\n",
+ ram[0], size[0], ram[1], size[1], ram[2], size[2], ram[3], size[3]);
}
/*
@@ -224,7 +202,7 @@ int slot;
*/
for (op=0; op<TEST_END; op++) {
for (bank=0; bank<nbanks; bank++) {
- if (RIOScrub(op, (BYTE *)ram[bank], size[bank]) == RIO_FAIL) {
+ if (RIOScrub(op, (u8 *)ram[bank], size[bank]) == RIO_FAIL) {
rio_dprintk (RIO_DEBUG_INIT, "RIO-init: RIOScrub band %d, op %d failed\n",
bank, op);
return RIO_FAIL;
@@ -233,7 +211,7 @@ int slot;
}
rio_dprintk (RIO_DEBUG_INIT, "Test completed\n");
- return RIO_SUCCESS;
+ return 0;
}
@@ -248,13 +226,10 @@ int slot;
** Call with op not zero, and the RAM will be read and compated with val[op-1]
** to check that the data from the previous phase was retained.
*/
-static int
-RIOScrub(op, ram, size)
-int op;
-BYTE * ram;
-int size;
+
+static int RIOScrub(int op, u8 *ram, int size)
{
- int off;
+ int off;
unsigned char oldbyte;
unsigned char newbyte;
unsigned char invbyte;
@@ -279,15 +254,15 @@ int size;
*/
if (op) {
for (off=0; off<size; off++) {
- if (RBYTE(ram[off]) != oldbyte) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off]));
+ if (readb(ram + off) != oldbyte) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 1: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
return RIO_FAIL;
}
}
for (off=0; off<size; off+=2) {
- if (*(ushort *)&ram[off] != oldword) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword,*(ushort *)&ram[off]);
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1]));
+ if (readw(ram + off) != oldword) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: WORD at offset 0x%x should have been=%x, was=%x\n",off,oldword, readw(ram + off));
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Pre Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
return RIO_FAIL;
}
}
@@ -301,13 +276,13 @@ int size;
** the BYTE read/write test.
*/
for (off=0; off<size; off++) {
- if (op && (RBYTE(ram[off]) != oldbyte)) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, RBYTE(ram[off]));
+ if (op && (readb(ram + off) != oldbyte)) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Pre Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, oldbyte, readb(ram + off));
return RIO_FAIL;
}
- WBYTE(ram[off],invbyte);
- if (RBYTE(ram[off]) != invbyte) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, RBYTE(ram[off]));
+ writeb(invbyte, ram + off);
+ if (readb(ram + off) != invbyte) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Byte Inv Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, invbyte, readb(ram + off));
return RIO_FAIL;
}
}
@@ -320,16 +295,16 @@ int size;
** This is the WORD operation test.
*/
for (off=0; off<size; off+=2) {
- if (*(ushort *)&ram[off] != invword) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, *(ushort *)&ram[off]);
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1]));
+ if (readw(ram + off) != invword) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: WORD at offset 0x%x should have been=%x, was=%x\n", off, invword, readw(ram + off));
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Word Inv Check: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram+off+1));
return RIO_FAIL;
}
- *(ushort *)&ram[off] = newword;
- if ( *(ushort *)&ram[off] != newword ) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]);
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1]));
+ writew(newword, ram + off);
+ if ( readw(ram + off) != newword ) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
return RIO_FAIL;
}
}
@@ -340,16 +315,16 @@ int size;
** required test data.
*/
for (off=0; off<size; off++) {
- if (RBYTE(ram[off]) != newbyte) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off]));
+ if (readb(ram + off) != newbyte) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Byte Check: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
return RIO_FAIL;
}
}
for (off=0; off<size; off+=2) {
- if ( *(ushort *)&ram[off] != newword ) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, *(ushort *)&ram[off]);
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1]));
+ if (readw(ram + off) != newword ) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: WORD at offset 0x%x should have been=%x, was=%x\n", off, newword, readw(ram + off));
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: Post Word Check 2: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
return RIO_FAIL;
}
}
@@ -360,41 +335,37 @@ int size;
swapword = invbyte | (newbyte << 8);
for (off=0; off<size; off+=2) {
- WBYTE(ram[off],invbyte);
- WBYTE(ram[off+1],newbyte);
+ writeb(invbyte, &ram[off]);
+ writeb(newbyte, &ram[off+1]);
}
for ( off=0; off<size; off+=2 ) {
- if (*(ushort *)&ram[off] != swapword) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, *((ushort *)&ram[off]));
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, RBYTE(ram[off]), off+1, RBYTE(ram[off+1]));
+ if (readw(ram + off) != swapword) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: WORD at offset 0x%x should have been=%x, was=%x\n", off, swapword, readw(ram + off));
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 1: BYTE at offset 0x%x is %x BYTE at offset 0x%x is %x\n", off, readb(ram + off), off+1, readb(ram + off + 1));
return RIO_FAIL;
}
- *((ushort *)&ram[off]) = ~swapword;
+ writew(~swapword, ram + off);
}
for (off=0; off<size; off+=2) {
- if (RBYTE(ram[off]) != newbyte) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, RBYTE(ram[off]));
+ if (readb(ram + off) != newbyte) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off, newbyte, readb(ram + off));
return RIO_FAIL;
}
- if (RBYTE(ram[off+1]) != invbyte) {
- rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, RBYTE(ram[off+1]));
+ if (readb(ram + off + 1) != invbyte) {
+ rio_dprintk (RIO_DEBUG_INIT, "RIO-init: SwapWord Check 2: BYTE at offset 0x%x should have been=%x, was=%x\n", off+1, invbyte, readb(ram + off + 1));
return RIO_FAIL;
}
- *((ushort *)&ram[off]) = newword;
+ writew(newword, ram + off);
}
- return RIO_SUCCESS;
+ return 0;
}
-int
-RIODefaultName(p, HostP, UnitId)
-struct rio_info * p;
-struct Host * HostP;
-uint UnitId;
+int RIODefaultName(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
{
- bcopy("UNKNOWN RTA X-XX",HostP->Mapping[UnitId].Name,17);
+ memcpy(HostP->Mapping[UnitId].Name, "UNKNOWN RTA X-XX", 17);
HostP->Mapping[UnitId].Name[12]='1'+(HostP-p->RIOHosts);
if ((UnitId+1) > 9) {
HostP->Mapping[UnitId].Name[14]='0'+((UnitId+1)/10);
@@ -412,8 +383,7 @@ uint UnitId;
static struct rioVersion stVersion;
-struct rioVersion *
-RIOVersid(void)
+struct rioVersion *RIOVersid(void)
{
strlcpy(stVersion.version, "RIO driver for linux V1.0",
sizeof(stVersion.version));
@@ -423,40 +393,31 @@ RIOVersid(void)
return &stVersion;
}
-void
-RIOHostReset(Type, DpRamP, Slot)
-uint Type;
-volatile struct DpRam *DpRamP;
-uint Slot;
+void RIOHostReset(unsigned int Type, struct DpRam *DpRamP, unsigned int Slot)
{
/*
** Reset the Tpu
*/
rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: type 0x%x", Type);
switch ( Type ) {
- case RIO_AT:
- rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n");
- WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
- INTERRUPT_DISABLE | BYTE_OPERATION |
- SLOW_LINKS | SLOW_AT_BUS);
- WBYTE(DpRamP->DpResetTpu, 0xFF);
- udelay(3);
-
+ case RIO_AT:
+ rio_dprintk (RIO_DEBUG_INIT, " (RIO_AT)\n");
+ writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE | BYTE_OPERATION |
+ SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
+ writeb(0xFF, &DpRamP->DpResetTpu);
+ udelay(3);
rio_dprintk (RIO_DEBUG_INIT, "RIOHostReset: Don't know if it worked. Try reset again\n");
- WBYTE(DpRamP->DpControl, BOOT_FROM_RAM | EXTERNAL_BUS_OFF |
- INTERRUPT_DISABLE | BYTE_OPERATION |
- SLOW_LINKS | SLOW_AT_BUS);
- WBYTE(DpRamP->DpResetTpu, 0xFF);
- udelay(3);
- break;
+ writeb(BOOT_FROM_RAM | EXTERNAL_BUS_OFF | INTERRUPT_DISABLE |
+ BYTE_OPERATION | SLOW_LINKS | SLOW_AT_BUS, &DpRamP->DpControl);
+ writeb(0xFF, &DpRamP->DpResetTpu);
+ udelay(3);
+ break;
case RIO_PCI:
rio_dprintk (RIO_DEBUG_INIT, " (RIO_PCI)\n");
- DpRamP->DpControl = RIO_PCI_BOOT_FROM_RAM;
- DpRamP->DpResetInt = 0xFF;
- DpRamP->DpResetTpu = 0xFF;
+ writeb(RIO_PCI_BOOT_FROM_RAM, &DpRamP->DpControl);
+ writeb(0xFF, &DpRamP->DpResetInt);
+ writeb(0xFF, &DpRamP->DpResetTpu);
udelay(100);
- /* for (i=0; i<6000; i++); */
- /* suspend( 3 ); */
break;
default:
rio_dprintk (RIO_DEBUG_INIT, " (UNKNOWN)\n");
diff --git a/drivers/char/rio/riointr.c b/drivers/char/rio/riointr.c
index 34d8787557a..97f0fa55065 100644
--- a/drivers/char/rio/riointr.c
+++ b/drivers/char/rio/riointr.c
@@ -54,15 +54,12 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -75,12 +72,10 @@ static char *_riointr_c_sccs_ = "@(#)riointr.c 1.2";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
@@ -101,8 +96,7 @@ static char *firstchars(char *p, int nch)
#define INCR( P, I ) ((P) = (((P)+(I)) & p->RIOBufferMask))
/* Enable and start the transmission of packets */
-void RIOTxEnable(en)
-char *en;
+void RIOTxEnable(char *en)
{
struct Port *PortP;
struct rio_info *p;
@@ -186,10 +180,8 @@ char *en;
static int RupIntr;
static int RxIntr;
static int TxIntr;
-void RIOServiceHost(p, HostP, From)
-struct rio_info *p;
-struct Host *HostP;
-int From;
+
+void RIOServiceHost(struct rio_info *p, struct Host *HostP, int From)
{
rio_spin_lock(&HostP->HostLock);
if ((HostP->Flags & RUN_STATE) != RC_RUNNING) {
@@ -201,22 +193,22 @@ int From;
}
rio_spin_unlock(&HostP->HostLock);
- if (RWORD(HostP->ParmMapP->rup_intr)) {
- WWORD(HostP->ParmMapP->rup_intr, 0);
+ if (readw(&HostP->ParmMapP->rup_intr)) {
+ writew(0, &HostP->ParmMapP->rup_intr);
p->RIORupCount++;
RupIntr++;
- rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %d\n", HostP - p->RIOHosts);
+ rio_dprintk(RIO_DEBUG_INTR, "rio: RUP interrupt on host %Zd\n", HostP - p->RIOHosts);
RIOPollHostCommands(p, HostP);
}
- if (RWORD(HostP->ParmMapP->rx_intr)) {
+ if (readw(&HostP->ParmMapP->rx_intr)) {
int port;
- WWORD(HostP->ParmMapP->rx_intr, 0);
+ writew(0, &HostP->ParmMapP->rx_intr);
p->RIORxCount++;
RxIntr++;
- rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %d\n", HostP - p->RIOHosts);
+ rio_dprintk(RIO_DEBUG_INTR, "rio: RX interrupt on host %Zd\n", HostP - p->RIOHosts);
/*
** Loop through every port. If the port is mapped into
** the system ( i.e. has /dev/ttyXXXX associated ) then it is
@@ -277,26 +269,26 @@ int From;
** it's handshake bit is set, then we must clear the handshake,
** so that that downstream RTA is re-enabled.
*/
- if (!can_remove_receive(&PacketP, PortP) && (RWORD(PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
+ if (!can_remove_receive(&PacketP, PortP) && (readw(&PortP->PhbP->handshake) == PHB_HANDSHAKE_SET)) {
/*
** MAGIC! ( Basically, handshake the RX buffer, so that
** the RTAs upstream can be re-enabled. )
*/
rio_dprintk(RIO_DEBUG_INTR, "Set RX handshake bit\n");
- WWORD(PortP->PhbP->handshake, PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET);
+ writew(PHB_HANDSHAKE_SET | PHB_HANDSHAKE_RESET, &PortP->PhbP->handshake);
}
rio_spin_unlock(&PortP->portSem);
}
}
- if (RWORD(HostP->ParmMapP->tx_intr)) {
+ if (readw(&HostP->ParmMapP->tx_intr)) {
int port;
- WWORD(HostP->ParmMapP->tx_intr, 0);
+ writew(0, &HostP->ParmMapP->tx_intr);
p->RIOTxCount++;
TxIntr++;
- rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %d\n", HostP - p->RIOHosts);
+ rio_dprintk(RIO_DEBUG_INTR, "rio: TX interrupt on host %Zd\n", HostP - p->RIOHosts);
/*
** Loop through every port.
@@ -399,7 +391,6 @@ int From;
/* For now don't handle RTA reboots. -- REW.
Reenabled. Otherwise RTA reboots didn't work. Duh. -- REW */
if (PortP->MagicFlags) {
-#if 1
if (PortP->MagicFlags & MAGIC_REBOOT) {
/*
** well, the RTA has been rebooted, and there is room
@@ -416,13 +407,12 @@ int From;
PortP->InUse = NOT_INUSE;
rio_spin_unlock(&PortP->portSem);
- if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? TRUE : FALSE, DONT_SLEEP) == RIO_FAIL) {
+ if (RIOParam(PortP, OPEN, ((PortP->Cor2Copy & (COR2_RTSFLOW | COR2_CTSFLOW)) == (COR2_RTSFLOW | COR2_CTSFLOW)) ? 1 : 0, DONT_SLEEP) == RIO_FAIL) {
continue; /* with next port */
}
rio_spin_lock(&PortP->portSem);
PortP->MagicFlags &= ~MAGIC_REBOOT;
}
-#endif
/*
** As mentioned above, this is a tacky hack to cope
@@ -445,9 +435,9 @@ int From;
*/
PktCmdP = (struct PktCmd *) &PacketP->data[0];
- WBYTE(PktCmdP->Command, WFLUSH);
+ writeb(WFLUSH, &PktCmdP->Command);
- p = PortP->HostPort % (ushort) PORTS_PER_RTA;
+ p = PortP->HostPort % (u16) PORTS_PER_RTA;
/*
** If second block of ports for 16 port RTA, add 8
@@ -456,27 +446,27 @@ int From;
if (PortP->SecondBlock)
p += PORTS_PER_RTA;
- WBYTE(PktCmdP->PhbNum, p);
+ writeb(p, &PktCmdP->PhbNum);
/*
** to make debuggery easier
*/
- WBYTE(PacketP->data[2], 'W');
- WBYTE(PacketP->data[3], 'F');
- WBYTE(PacketP->data[4], 'L');
- WBYTE(PacketP->data[5], 'U');
- WBYTE(PacketP->data[6], 'S');
- WBYTE(PacketP->data[7], 'H');
- WBYTE(PacketP->data[8], ' ');
- WBYTE(PacketP->data[9], '0' + PortP->WflushFlag);
- WBYTE(PacketP->data[10], ' ');
- WBYTE(PacketP->data[11], ' ');
- WBYTE(PacketP->data[12], '\0');
+ writeb('W', &PacketP->data[2]);
+ writeb('F', &PacketP->data[3]);
+ writeb('L', &PacketP->data[4]);
+ writeb('U', &PacketP->data[5]);
+ writeb('S', &PacketP->data[6]);
+ writeb('H', &PacketP->data[7]);
+ writeb(' ', &PacketP->data[8]);
+ writeb('0' + PortP->WflushFlag, &PacketP->data[9]);
+ writeb(' ', &PacketP->data[10]);
+ writeb(' ', &PacketP->data[11]);
+ writeb('\0', &PacketP->data[12]);
/*
** its two bytes long!
*/
- WBYTE(PacketP->len, PKT_CMD_BIT | 2);
+ writeb(PKT_CMD_BIT | 2, &PacketP->len);
/*
** queue it!
@@ -529,19 +519,15 @@ int From;
}
/*
-** Routine for handling received data for clist drivers.
-** NB: Called with the tty locked. The spl from the lockb( ) is passed.
-** we return the ttySpl level that we re-locked at.
+** Routine for handling received data for tty drivers
*/
-static void RIOReceive(p, PortP)
-struct rio_info *p;
-struct Port *PortP;
+static void RIOReceive(struct rio_info *p, struct Port *PortP)
{
struct tty_struct *TtyP;
- register ushort transCount;
+ unsigned short transCount;
struct PKT *PacketP;
- register uint DataCnt;
- uchar *ptr;
+ register unsigned int DataCnt;
+ unsigned char *ptr;
unsigned char *buf;
int copied = 0;
@@ -594,9 +580,6 @@ struct Port *PortP;
transCount = 1;
while (can_remove_receive(&PacketP, PortP)
&& transCount) {
-#ifdef STATS
- PortP->Stat.RxIntCnt++;
-#endif /* STATS */
RxIntCnt++;
/*
@@ -642,28 +625,15 @@ struct Port *PortP;
** to '#define', (this is the only place ___DEBUG_IT___ occurs in the
** driver).
*/
-#undef ___DEBUG_IT___
-#ifdef ___DEBUG_IT___
- kkprintf("I:%d R:%d P:%d Q:%d C:%d F:%x ", intCount, RxIntCnt, PortP->PortNum, TtyP->rxqueue.count, transCount, TtyP->flags);
-#endif
- ptr = (uchar *) PacketP->data + PortP->RxDataStart;
+ ptr = (unsigned char *) PacketP->data + PortP->RxDataStart;
tty_prepare_flip_string(TtyP, &buf, transCount);
rio_memcpy_fromio(buf, ptr, transCount);
-#ifdef STATS
- /*
- ** keep a count for statistical purposes
- */
- PortP->Stat.RxCharCnt += transCount;
-#endif
PortP->RxDataStart += transCount;
PacketP->len -= transCount;
copied += transCount;
-#ifdef ___DEBUG_IT___
- kkprintf("T:%d L:%d\n", DataCnt, PacketP->len);
-#endif
if (PacketP->len == 0) {
/*
@@ -674,12 +644,6 @@ struct Port *PortP;
remove_receive(PortP);
put_free_end(PortP->HostP, PacketP);
PortP->RxDataStart = 0;
-#ifdef STATS
- /*
- ** more lies ( oops, I mean statistics )
- */
- PortP->Stat.RxPktCnt++;
-#endif /* STATS */
}
}
}
@@ -691,215 +655,3 @@ struct Port *PortP;
return;
}
-#ifdef FUTURE_RELEASE
-/*
-** The proc routine called by the line discipline to do the work for it.
-** The proc routine works hand in hand with the interrupt routine.
-*/
-int riotproc(p, tp, cmd, port)
-struct rio_info *p;
-register struct ttystatics *tp;
-int cmd;
-int port;
-{
- register struct Port *PortP;
- int SysPort;
- struct PKT *PacketP;
-
- SysPort = port; /* Believe me, it works. */
-
- if (SysPort < 0 || SysPort >= RIO_PORTS) {
- rio_dprintk(RIO_DEBUG_INTR, "Illegal port %d derived from TTY in riotproc()\n", SysPort);
- return 0;
- }
- PortP = p->RIOPortp[SysPort];
-
- if ((uint) PortP->PhbP < (uint) PortP->Caddr || (uint) PortP->PhbP >= (uint) PortP->Caddr + SIXTY_FOUR_K) {
- rio_dprintk(RIO_DEBUG_INTR, "RIO: NULL or BAD PhbP on sys port %d in proc routine\n", SysPort);
- rio_dprintk(RIO_DEBUG_INTR, " PortP = 0x%x\n", PortP);
- rio_dprintk(RIO_DEBUG_INTR, " PortP->PhbP = 0x%x\n", PortP->PhbP);
- rio_dprintk(RIO_DEBUG_INTR, " PortP->Caddr = 0x%x\n", PortP->PhbP);
- rio_dprintk(RIO_DEBUG_INTR, " PortP->HostPort = 0x%x\n", PortP->HostPort);
- return 0;
- }
-
- switch (cmd) {
- case T_WFLUSH:
- rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH\n");
- /*
- ** Because of the spooky way the RIO works, we don't need
- ** to issue a flush command on any of the SET*F commands,
- ** as that causes trouble with getty and login, which issue
- ** these commands to incur a READ flush, and rely on the fact
- ** that the line discipline does a wait for drain for them.
- ** As the rio doesn't wait for drain, the write flush would
- ** destroy the Password: prompt. This isn't very friendly, so
- ** here we only issue a WFLUSH command if we are in the interrupt
- ** routine, or we aren't executing a SET*F command.
- */
- if (PortP->HostP->InIntr || !PortP->FlushCmdBodge) {
- /*
- ** form a wflush packet - 1 byte long, no data
- */
- if (PortP->State & RIO_DELETED) {
- rio_dprintk(RIO_DEBUG_INTR, "WFLUSH on deleted RTA\n");
- } else {
- if (RIOPreemptiveCmd(p, PortP, WFLUSH) == RIO_FAIL) {
- rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command failed\n");
- } else
- rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command\n");
- }
- /*
- ** WFLUSH operation - flush the data!
- */
- PortP->TxBufferIn = PortP->TxBufferOut = 0;
- } else {
- rio_dprintk(RIO_DEBUG_INTR, "T_WFLUSH Command ignored\n");
- }
- /*
- ** sort out the line discipline
- */
- if (PortP->CookMode == COOK_WELL)
- goto start;
- break;
-
- case T_RESUME:
- rio_dprintk(RIO_DEBUG_INTR, "T_RESUME\n");
- /*
- ** send pre-emptive resume packet
- */
- if (PortP->State & RIO_DELETED) {
- rio_dprintk(RIO_DEBUG_INTR, "RESUME on deleted RTA\n");
- } else {
- if (RIOPreemptiveCmd(p, PortP, RESUME) == RIO_FAIL) {
- rio_dprintk(RIO_DEBUG_INTR, "T_RESUME Command failed\n");
- }
- }
- /*
- ** and re-start the sender software!
- */
- if (PortP->CookMode == COOK_WELL)
- goto start;
- break;
-
- case T_TIME:
- rio_dprintk(RIO_DEBUG_INTR, "T_TIME\n");
- /*
- ** T_TIME is called when xDLY is set in oflags and
- ** the line discipline timeout has expired. It's
- ** function in life is to clear the TIMEOUT flag
- ** and to re-start output to the port.
- */
- /*
- ** Fall through and re-start output
- */
- case T_OUTPUT:
- start:
- if (PortP->MagicFlags & MAGIC_FLUSH) {
- PortP->MagicFlags |= MORE_OUTPUT_EYGOR;
- return 0;
- }
- RIOTxEnable((char *) PortP);
- PortP->MagicFlags &= ~MORE_OUTPUT_EYGOR;
- /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"T_OUTPUT finished\n"); */
- break;
-
- case T_SUSPEND:
- rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND\n");
- /*
- ** send a suspend pre-emptive packet.
- */
- if (PortP->State & RIO_DELETED) {
- rio_dprintk(RIO_DEBUG_INTR, "SUSPEND deleted RTA\n");
- } else {
- if (RIOPreemptiveCmd(p, PortP, SUSPEND) == RIO_FAIL) {
- rio_dprintk(RIO_DEBUG_INTR, "T_SUSPEND Command failed\n");
- }
- }
- /*
- ** done!
- */
- break;
-
- case T_BLOCK:
- rio_dprintk(RIO_DEBUG_INTR, "T_BLOCK\n");
- break;
-
- case T_RFLUSH:
- rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH\n");
- if (PortP->State & RIO_DELETED) {
- rio_dprintk(RIO_DEBUG_INTR, "RFLUSH on deleted RTA\n");
- PortP->RxDataStart = 0;
- } else {
- if (RIOPreemptiveCmd(p, PortP, RFLUSH) == RIO_FAIL) {
- rio_dprintk(RIO_DEBUG_INTR, "T_RFLUSH Command failed\n");
- return 0;
- }
- PortP->RxDataStart = 0;
- while (can_remove_receive(&PacketP, PortP)) {
- remove_receive(PortP);
- ShowPacket(DBG_PROC, PacketP);
- put_free_end(PortP->HostP, PacketP);
- }
- if (PortP->PhbP->handshake == PHB_HANDSHAKE_SET) {
- /*
- ** MAGIC!
- */
- rio_dprintk(RIO_DEBUG_INTR, "Set receive handshake bit\n");
- PortP->PhbP->handshake |= PHB_HANDSHAKE_RESET;
- }
- }
- break;
- /* FALLTHROUGH */
- case T_UNBLOCK:
- rio_dprintk(RIO_DEBUG_INTR, "T_UNBLOCK\n");
- /*
- ** If there is any data to receive set a timeout to service it.
- */
- RIOReceive(p, PortP);
- break;
-
- case T_BREAK:
- rio_dprintk(RIO_DEBUG_INTR, "T_BREAK\n");
- /*
- ** Send a break command. For Sys V
- ** this is a timed break, so we
- ** send a SBREAK[time] packet
- */
- /*
- ** Build a BREAK command
- */
- if (PortP->State & RIO_DELETED) {
- rio_dprintk(RIO_DEBUG_INTR, "BREAK on deleted RTA\n");
- } else {
- if (RIOShortCommand(PortP, SBREAK, 2, p->RIOConf.BreakInterval) == RIO_FAIL) {
- rio_dprintk(RIO_DEBUG_INTR, "SBREAK RIOShortCommand failed\n");
- }
- }
-
- /*
- ** done!
- */
- break;
-
- case T_INPUT:
- rio_dprintk(RIO_DEBUG_INTR, "Proc T_INPUT called - I don't know what to do!\n");
- break;
- case T_PARM:
- rio_dprintk(RIO_DEBUG_INTR, "Proc T_PARM called - I don't know what to do!\n");
- break;
-
- case T_SWTCH:
- rio_dprintk(RIO_DEBUG_INTR, "Proc T_SWTCH called - I don't know what to do!\n");
- break;
-
- default:
- rio_dprintk(RIO_DEBUG_INTR, "Proc UNKNOWN command %d\n", cmd);
- }
- /*
- ** T_OUTPUT returns without passing through this point!
- */
- /*rio_dprint(RIO_DEBUG_INTR, PortP,DBG_PROC,"riotproc done\n"); */
- return (0);
-}
-#endif
diff --git a/drivers/char/rio/rioparam.c b/drivers/char/rio/rioparam.c
index c622f46d6d7..d2e8092cdb2 100644
--- a/drivers/char/rio/rioparam.c
+++ b/drivers/char/rio/rioparam.c
@@ -52,15 +52,12 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -73,17 +70,13 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "param.h"
-#include "list.h"
-#include "sam.h"
@@ -157,20 +150,16 @@ static char *_rioparam_c_sccs_ = "@(#)rioparam.c 1.3";
** NB. for MPX
** tty lock must NOT have been previously acquired.
*/
-int RIOParam(PortP, cmd, Modem, SleepFlag)
-struct Port *PortP;
-int cmd;
-int Modem;
-int SleepFlag;
+int RIOParam(struct Port *PortP, int cmd, int Modem, int SleepFlag)
{
- register struct tty_struct *TtyP;
+ struct tty_struct *TtyP;
int retval;
- register struct phb_param *phb_param_ptr;
- PKT *PacketP;
+ struct phb_param *phb_param_ptr;
+ struct PKT *PacketP;
int res;
- uchar Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
- uchar TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
- uchar LNext = 0, TxBaud = 0, RxBaud = 0;
+ u8 Cor1 = 0, Cor2 = 0, Cor4 = 0, Cor5 = 0;
+ u8 TxXon = 0, TxXoff = 0, RxXon = 0, RxXoff = 0;
+ u8 LNext = 0, TxBaud = 0, RxBaud = 0;
int retries = 0xff;
unsigned long flags;
@@ -226,16 +215,13 @@ int SleepFlag;
if (retval == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_PARAM, "wait for can_add_transmit broken by signal\n");
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- pseterr(EINTR);
func_exit();
-
- return RIO_FAIL;
+ return -EINTR;
}
if (PortP->State & RIO_DELETED) {
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
func_exit();
-
- return RIO_SUCCESS;
+ return 0;
}
}
@@ -247,7 +233,7 @@ int SleepFlag;
}
rio_dprintk(RIO_DEBUG_PARAM, "can_add_transmit() returns %x\n", res);
- rio_dprintk(RIO_DEBUG_PARAM, "Packet is 0x%x\n", (int) PacketP);
+ rio_dprintk(RIO_DEBUG_PARAM, "Packet is %p\n", PacketP);
phb_param_ptr = (struct phb_param *) PacketP->data;
@@ -474,9 +460,6 @@ int SleepFlag;
e(115200); /* e(230400);e(460800); e(921600); */
}
- /* XXX MIssing conversion table. XXX */
- /* (TtyP->termios->c_cflag & V_CBAUD); */
-
rio_dprintk(RIO_DEBUG_PARAM, "tx baud 0x%x, rx baud 0x%x\n", TxBaud, RxBaud);
@@ -552,23 +535,23 @@ int SleepFlag;
/*
** Actually write the info into the packet to be sent
*/
- WBYTE(phb_param_ptr->Cmd, cmd);
- WBYTE(phb_param_ptr->Cor1, Cor1);
- WBYTE(phb_param_ptr->Cor2, Cor2);
- WBYTE(phb_param_ptr->Cor4, Cor4);
- WBYTE(phb_param_ptr->Cor5, Cor5);
- WBYTE(phb_param_ptr->TxXon, TxXon);
- WBYTE(phb_param_ptr->RxXon, RxXon);
- WBYTE(phb_param_ptr->TxXoff, TxXoff);
- WBYTE(phb_param_ptr->RxXoff, RxXoff);
- WBYTE(phb_param_ptr->LNext, LNext);
- WBYTE(phb_param_ptr->TxBaud, TxBaud);
- WBYTE(phb_param_ptr->RxBaud, RxBaud);
+ writeb(cmd, &phb_param_ptr->Cmd);
+ writeb(Cor1, &phb_param_ptr->Cor1);
+ writeb(Cor2, &phb_param_ptr->Cor2);
+ writeb(Cor4, &phb_param_ptr->Cor4);
+ writeb(Cor5, &phb_param_ptr->Cor5);
+ writeb(TxXon, &phb_param_ptr->TxXon);
+ writeb(RxXon, &phb_param_ptr->RxXon);
+ writeb(TxXoff, &phb_param_ptr->TxXoff);
+ writeb(RxXoff, &phb_param_ptr->RxXoff);
+ writeb(LNext, &phb_param_ptr->LNext);
+ writeb(TxBaud, &phb_param_ptr->TxBaud);
+ writeb(RxBaud, &phb_param_ptr->RxBaud);
/*
** Set the length/command field
*/
- WBYTE(PacketP->len, 12 | PKT_CMD_BIT);
+ writeb(12 | PKT_CMD_BIT, &PacketP->len);
/*
** The packet is formed - now, whack it off
@@ -589,7 +572,7 @@ int SleepFlag;
*/
func_exit();
- return RIO_SUCCESS;
+ return 0;
}
@@ -597,15 +580,13 @@ int SleepFlag;
** We can add another packet to a transmit queue if the packet pointer pointed
** to by the TxAdd pointer has PKT_IN_USE clear in its address.
*/
-int can_add_transmit(PktP, PortP)
-PKT **PktP;
-struct Port *PortP;
+int can_add_transmit(struct PKT **PktP, struct Port *PortP)
{
- register PKT *tp;
+ struct PKT *tp;
- *PktP = tp = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->TxAdd));
+ *PktP = tp = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->TxAdd));
- return !((uint) tp & PKT_IN_USE);
+ return !((unsigned long) tp & PKT_IN_USE);
}
/*
@@ -613,27 +594,24 @@ struct Port *PortP;
** and then move the TxAdd pointer along one position to point to the next
** packet pointer. You must wrap the pointer from the end back to the start.
*/
-void add_transmit(PortP)
-struct Port *PortP;
+void add_transmit(struct Port *PortP)
{
- if (RWORD(*PortP->TxAdd) & PKT_IN_USE) {
+ if (readw(PortP->TxAdd) & PKT_IN_USE) {
rio_dprintk(RIO_DEBUG_PARAM, "add_transmit: Packet has been stolen!");
}
- WWORD(*(ushort *) PortP->TxAdd, RWORD(*PortP->TxAdd) | PKT_IN_USE);
+ writew(readw(PortP->TxAdd) | PKT_IN_USE, PortP->TxAdd);
PortP->TxAdd = (PortP->TxAdd == PortP->TxEnd) ? PortP->TxStart : PortP->TxAdd + 1;
- WWORD(PortP->PhbP->tx_add, RIO_OFF(PortP->Caddr, PortP->TxAdd));
+ writew(RIO_OFF(PortP->Caddr, PortP->TxAdd), &PortP->PhbP->tx_add);
}
/****************************************
* Put a packet onto the end of the
* free list
****************************************/
-void put_free_end(HostP, PktP)
-struct Host *HostP;
-PKT *PktP;
+void put_free_end(struct Host *HostP, struct PKT *PktP)
{
- FREE_LIST *tmp_pointer;
- ushort old_end, new_end;
+ struct rio_free_list *tmp_pointer;
+ unsigned short old_end, new_end;
unsigned long flags;
rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -643,21 +621,21 @@ PKT *PktP;
*
************************************************/
- rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%x)\n", (int) PktP);
+ rio_dprintk(RIO_DEBUG_PFE, "put_free_end(PktP=%p)\n", PktP);
- if ((old_end = RWORD(HostP->ParmMapP->free_list_end)) != TPNULL) {
+ if ((old_end = readw(&HostP->ParmMapP->free_list_end)) != TPNULL) {
new_end = RIO_OFF(HostP->Caddr, PktP);
- tmp_pointer = (FREE_LIST *) RIO_PTR(HostP->Caddr, old_end);
- WWORD(tmp_pointer->next, new_end);
- WWORD(((FREE_LIST *) PktP)->prev, old_end);
- WWORD(((FREE_LIST *) PktP)->next, TPNULL);
- WWORD(HostP->ParmMapP->free_list_end, new_end);
+ tmp_pointer = (struct rio_free_list *) RIO_PTR(HostP->Caddr, old_end);
+ writew(new_end, &tmp_pointer->next);
+ writew(old_end, &((struct rio_free_list *) PktP)->prev);
+ writew(TPNULL, &((struct rio_free_list *) PktP)->next);
+ writew(new_end, &HostP->ParmMapP->free_list_end);
} else { /* First packet on the free list this should never happen! */
rio_dprintk(RIO_DEBUG_PFE, "put_free_end(): This should never happen\n");
- WWORD(HostP->ParmMapP->free_list_end, RIO_OFF(HostP->Caddr, PktP));
- tmp_pointer = (FREE_LIST *) PktP;
- WWORD(tmp_pointer->prev, TPNULL);
- WWORD(tmp_pointer->next, TPNULL);
+ writew(RIO_OFF(HostP->Caddr, PktP), &HostP->ParmMapP->free_list_end);
+ tmp_pointer = (struct rio_free_list *) PktP;
+ writew(TPNULL, &tmp_pointer->prev);
+ writew(TPNULL, &tmp_pointer->next);
}
rio_dprintk(RIO_DEBUG_CMD, "Before unlock: %p\n", &HostP->HostLock);
rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
@@ -669,12 +647,10 @@ PKT *PktP;
** relevant packet, [having cleared the PKT_IN_USE bit]. If PKT_IN_USE is clear,
** then can_remove_receive() returns 0.
*/
-int can_remove_receive(PktP, PortP)
-PKT **PktP;
-struct Port *PortP;
+int can_remove_receive(struct PKT **PktP, struct Port *PortP)
{
- if (RWORD(*PortP->RxRemove) & PKT_IN_USE) {
- *PktP = (PKT *) RIO_PTR(PortP->Caddr, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+ if (readw(PortP->RxRemove) & PKT_IN_USE) {
+ *PktP = (struct PKT *) RIO_PTR(PortP->Caddr, readw(PortP->RxRemove) & ~PKT_IN_USE);
return 1;
}
return 0;
@@ -685,10 +661,9 @@ struct Port *PortP;
** and then bump the pointers. Once the pointers get to the end, they must
** be wrapped back to the start.
*/
-void remove_receive(PortP)
-struct Port *PortP;
+void remove_receive(struct Port *PortP)
{
- WWORD(*PortP->RxRemove, RWORD(*PortP->RxRemove) & ~PKT_IN_USE);
+ writew(readw(PortP->RxRemove) & ~PKT_IN_USE, PortP->RxRemove);
PortP->RxRemove = (PortP->RxRemove == PortP->RxEnd) ? PortP->RxStart : PortP->RxRemove + 1;
- WWORD(PortP->PhbP->rx_remove, RIO_OFF(PortP->Caddr, PortP->RxRemove));
+ writew(RIO_OFF(PortP->Caddr, PortP->RxRemove), &PortP->PhbP->rx_remove);
}
diff --git a/drivers/char/rio/riopcicopy.c b/drivers/char/rio/riopcicopy.c
deleted file mode 100644
index 535afaa51ca..00000000000
--- a/drivers/char/rio/riopcicopy.c
+++ /dev/null
@@ -1,8 +0,0 @@
-
-/* Yeah. We have copyright on this one. Sure. */
-
-void rio_pcicopy(char *from, char *to, int amount)
-{
- while (amount--)
- *to++ = *from++;
-}
diff --git a/drivers/char/rio/rioroute.c b/drivers/char/rio/rioroute.c
index f98888f5265..35708533794 100644
--- a/drivers/char/rio/rioroute.c
+++ b/drivers/char/rio/rioroute.c
@@ -50,15 +50,12 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -71,29 +68,25 @@ static char *_rioroute_c_sccs_ = "@(#)rioroute.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "param.h"
-#include "list.h"
-#include "sam.h"
-static int RIOCheckIsolated(struct rio_info *, struct Host *, uint);
-static int RIOIsolate(struct rio_info *, struct Host *, uint);
-static int RIOCheck(struct Host *, uint);
-static void RIOConCon(struct rio_info *, struct Host *, uint, uint, uint, uint, int);
+static int RIOCheckIsolated(struct rio_info *, struct Host *, unsigned int);
+static int RIOIsolate(struct rio_info *, struct Host *, unsigned int);
+static int RIOCheck(struct Host *, unsigned int);
+static void RIOConCon(struct rio_info *, struct Host *, unsigned int, unsigned int, unsigned int, unsigned int, int);
/*
** Incoming on the ROUTE_RUP
** I wrote this while I was tired. Forgive me.
*/
-int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
+int RIORouteRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT * PacketP)
{
struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data;
struct PktCmd_M *PktReplyP;
@@ -104,10 +97,10 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
int ThisLink, ThisLinkMin, ThisLinkMax;
int port;
int Mod, Mod1, Mod2;
- ushort RtaType;
- uint RtaUniq;
- uint ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
- uint OldUnit, NewUnit, OldLink, NewLink;
+ unsigned short RtaType;
+ unsigned int RtaUniq;
+ unsigned int ThisUnit, ThisUnit2; /* 2 ids to accommodate 16 port RTA */
+ unsigned int OldUnit, NewUnit, OldLink, NewLink;
char *MyType, *MyName;
int Lies;
unsigned long flags;
@@ -115,7 +108,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
/*
** Is this unit telling us it's current link topology?
*/
- if (RBYTE(PktCmdP->Command) == ROUTE_TOPOLOGY) {
+ if (readb(&PktCmdP->Command) == ROUTE_TOPOLOGY) {
MapP = HostP->Mapping;
/*
@@ -125,7 +118,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
** from an RTA then we need to fill in the Mapping structure's
** Topology array for the unit.
*/
- if (Rup >= (ushort) MAX_RUP) {
+ if (Rup >= (unsigned short) MAX_RUP) {
ThisUnit = HOST_ID;
TopP = HostP->Topology;
MyType = "Host";
@@ -151,11 +144,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
** it won't lie about network interconnect, total disconnects
** and no-IDs. (or at least, it doesn't *matter* if it does)
*/
- if (RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) > (ushort) MAX_RUP)
+ if (readb(&PktCmdP->RouteTopology[ThisLink].Unit) > (unsigned short) MAX_RUP)
continue;
for (NewLink = ThisLinkMin; NewLink < ThisLink; NewLink++) {
- if ((RBYTE(PktCmdP->RouteTopology[ThisLink].Unit) == RBYTE(PktCmdP->RouteTopology[NewLink].Unit)) && (RBYTE(PktCmdP->RouteTopology[ThisLink].Link) == RBYTE(PktCmdP->RouteTopology[NewLink].Link))) {
+ if ((readb(&PktCmdP->RouteTopology[ThisLink].Unit) == readb(&PktCmdP->RouteTopology[NewLink].Unit)) && (readb(&PktCmdP->RouteTopology[ThisLink].Link) == readb(&PktCmdP->RouteTopology[NewLink].Link))) {
Lies++;
}
}
@@ -164,11 +157,11 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
if (Lies) {
rio_dprintk(RIO_DEBUG_ROUTE, "LIES! DAMN LIES! %d LIES!\n", Lies);
rio_dprintk(RIO_DEBUG_ROUTE, "%d:%c %d:%c %d:%c %d:%c\n",
- RBYTE(PktCmdP->RouteTopology[0].Unit),
- 'A' + RBYTE(PktCmdP->RouteTopology[0].Link),
- RBYTE(PktCmdP->RouteTopology[1].Unit),
- 'A' + RBYTE(PktCmdP->RouteTopology[1].Link), RBYTE(PktCmdP->RouteTopology[2].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[2].Link), RBYTE(PktCmdP->RouteTopology[3].Unit), 'A' + RBYTE(PktCmdP->RouteTopology[3].Link));
- return TRUE;
+ readb(&PktCmdP->RouteTopology[0].Unit),
+ 'A' + readb(&PktCmdP->RouteTopology[0].Link),
+ readb(&PktCmdP->RouteTopology[1].Unit),
+ 'A' + readb(&PktCmdP->RouteTopology[1].Link), readb(&PktCmdP->RouteTopology[2].Unit), 'A' + readb(&PktCmdP->RouteTopology[2].Link), readb(&PktCmdP->RouteTopology[3].Unit), 'A' + readb(&PktCmdP->RouteTopology[3].Link));
+ return 1;
}
/*
@@ -184,8 +177,8 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
/*
** this is what it is now connected to
*/
- NewUnit = RBYTE(PktCmdP->RouteTopology[ThisLink].Unit);
- NewLink = RBYTE(PktCmdP->RouteTopology[ThisLink].Link);
+ NewUnit = readb(&PktCmdP->RouteTopology[ThisLink].Unit);
+ NewLink = readb(&PktCmdP->RouteTopology[ThisLink].Link);
if (OldUnit != NewUnit || OldLink != NewLink) {
/*
@@ -219,7 +212,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
if (NewUnit == ROUTE_INTERCONNECT) {
if (!p->RIONoMessage)
- cprintf("%s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
+ printk(KERN_DEBUG "rio: %s '%s' (%c) is connected to another network.\n", MyType, MyName, 'A' + ThisLink);
}
/*
@@ -258,18 +251,18 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
RIOCheckIsolated(p, HostP, OldUnit);
}
}
- return TRUE;
+ return 1;
}
/*
** The only other command we recognise is a route_request command
*/
- if (RBYTE(PktCmdP->Command) != ROUTE_REQUEST) {
- rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %d ROUTE_RUP\n", RBYTE(PktCmdP->Command), Rup, (int) HostP);
- return TRUE;
+ if (readb(&PktCmdP->Command) != ROUTE_REQUEST) {
+ rio_dprintk(RIO_DEBUG_ROUTE, "Unknown command %d received on rup %d host %p ROUTE_RUP\n", readb(&PktCmdP->Command), Rup, HostP);
+ return 1;
}
- RtaUniq = (RBYTE(PktCmdP->UniqNum[0])) + (RBYTE(PktCmdP->UniqNum[1]) << 8) + (RBYTE(PktCmdP->UniqNum[2]) << 16) + (RBYTE(PktCmdP->UniqNum[3]) << 24);
+ RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24);
/*
** Determine if 8 or 16 port RTA
@@ -278,7 +271,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
rio_dprintk(RIO_DEBUG_ROUTE, "Received a request for an ID for serial number %x\n", RtaUniq);
- Mod = RBYTE(PktCmdP->ModuleTypes);
+ Mod = readb(&PktCmdP->ModuleTypes);
Mod1 = LONYBLE(Mod);
if (RtaType == TYPE_RTA16) {
/*
@@ -292,10 +285,6 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
rio_dprintk(RIO_DEBUG_ROUTE, "Module types are %s (ports 0-3) and %s (ports 4-7)\n", p->RIOModuleTypes[Mod1].Name, p->RIOModuleTypes[Mod2].Name);
}
- if (RtaUniq == 0xffffffff) {
- ShowPacket(DBG_SPECIAL, PacketP);
- }
-
/*
** try to unhook a command block from the command free list.
*/
@@ -320,7 +309,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
PktReplyP->Command = ROUTE_FOAD;
HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
- return TRUE;
+ return 1;
}
/*
@@ -348,13 +337,13 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
if ((HostP->Mapping[ThisUnit].Flags & SLOT_IN_USE) && !(HostP->Mapping[ThisUnit].Flags & RTA_BOOTED)) {
if (!(HostP->Mapping[ThisUnit].Flags & MSG_DONE)) {
if (!p->RIONoMessage)
- cprintf("RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
+ printk(KERN_DEBUG "rio: RTA '%s' is being updated.\n", HostP->Mapping[ThisUnit].Name);
HostP->Mapping[ThisUnit].Flags |= MSG_DONE;
}
PktReplyP->Command = ROUTE_FOAD;
HostP->Copy("RT_FOAD", PktReplyP->CommandText, 7);
RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
- return TRUE;
+ return 1;
}
/*
@@ -447,7 +436,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
/*
** Job done, get on with the interrupts!
*/
- return TRUE;
+ return 1;
}
}
/*
@@ -475,7 +464,7 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
if (!UnknownMesgDone) {
if (!p->RIONoMessage)
- cprintf("One or more unknown RTAs are being updated.\n");
+ printk(KERN_DEBUG "rio: One or more unknown RTAs are being updated.\n");
UnknownMesgDone = 1;
}
@@ -491,28 +480,25 @@ int RIORouteRup(struct rio_info *p, uint Rup, struct Host *HostP, PKT * PacketP)
if (RtaType == TYPE_RTA16) {
if (RIOFindFreeID(p, HostP, &ThisUnit, &ThisUnit2) == 0) {
RIODefaultName(p, HostP, ThisUnit);
- FillSlot(ThisUnit, ThisUnit2, RtaUniq, HostP);
+ rio_fill_host_slot(ThisUnit, ThisUnit2, RtaUniq, HostP);
}
} else {
if (RIOFindFreeID(p, HostP, &ThisUnit, NULL) == 0) {
RIODefaultName(p, HostP, ThisUnit);
- FillSlot(ThisUnit, 0, RtaUniq, HostP);
+ rio_fill_host_slot(ThisUnit, 0, RtaUniq, HostP);
}
}
PktReplyP->Command = ROUTE_USED;
HostP->Copy("RT_USED", PktReplyP->CommandText, 7);
}
RIOQueueCmdBlk(HostP, Rup, CmdBlkP);
- return TRUE;
+ return 1;
}
-void RIOFixPhbs(p, HostP, unit)
-struct rio_info *p;
-struct Host *HostP;
-uint unit;
+void RIOFixPhbs(struct rio_info *p, struct Host *HostP, unsigned int unit)
{
- ushort link, port;
+ unsigned short link, port;
struct Port *PortP;
unsigned long flags;
int PortN = HostP->Mapping[unit].SysPort;
@@ -520,19 +506,19 @@ uint unit;
rio_dprintk(RIO_DEBUG_ROUTE, "RIOFixPhbs unit %d sysport %d\n", unit, PortN);
if (PortN != -1) {
- ushort dest_unit = HostP->Mapping[unit].ID2;
+ unsigned short dest_unit = HostP->Mapping[unit].ID2;
/*
** Get the link number used for the 1st 8 phbs on this unit.
*/
PortP = p->RIOPortp[HostP->Mapping[dest_unit - 1].SysPort];
- link = RWORD(PortP->PhbP->link);
+ link = readw(&PortP->PhbP->link);
for (port = 0; port < PORTS_PER_RTA; port++, PortN++) {
- ushort dest_port = port + 8;
- WORD *TxPktP;
- PKT *Pkt;
+ unsigned short dest_port = port + 8;
+ u16 *TxPktP;
+ struct PKT *Pkt;
PortP = p->RIOPortp[PortN];
@@ -569,18 +555,18 @@ uint unit;
** card. This needs to be translated into a 32 bit pointer
** so it can be accessed from the driver.
*/
- Pkt = (PKT *) RIO_PTR(HostP->Caddr, RINDW(TxPktP));
+ Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(TxPktP));
/*
** If the packet is used, reset it.
*/
- Pkt = (PKT *) ((uint) Pkt & ~PKT_IN_USE);
- WBYTE(Pkt->dest_unit, dest_unit);
- WBYTE(Pkt->dest_port, dest_port);
+ Pkt = (struct PKT *) ((unsigned long) Pkt & ~PKT_IN_USE);
+ writeb(dest_unit, &Pkt->dest_unit);
+ writeb(dest_port, &Pkt->dest_port);
}
- rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", RWORD(PortP->PhbP->destination) & 0xff, (RWORD(PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
- WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8));
- WWORD(PortP->PhbP->link, link);
+ rio_dprintk(RIO_DEBUG_ROUTE, "phb dest: Old %x:%x New %x:%x\n", readw(&PortP->PhbP->destination) & 0xff, (readw(&PortP->PhbP->destination) >> 8) & 0xff, dest_unit, dest_port);
+ writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
+ writew(link, &PortP->PhbP->link);
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
}
@@ -590,9 +576,9 @@ uint unit;
*/
if (link > 3)
return;
- if (((unit * 8) + 7) > RWORD(HostP->LinkStrP[link].last_port)) {
+ if (((unit * 8) + 7) > readw(&HostP->LinkStrP[link].last_port)) {
rio_dprintk(RIO_DEBUG_ROUTE, "last port on host link %d: %d\n", link, (unit * 8) + 7);
- WWORD(HostP->LinkStrP[link].last_port, (unit * 8) + 7);
+ writew((unit * 8) + 7, &HostP->LinkStrP[link].last_port);
}
}
}
@@ -603,10 +589,7 @@ uint unit;
** the world about it. This is done to ensure that the configurator
** only gets up-to-date information about what is going on.
*/
-static int RIOCheckIsolated(p, HostP, UnitId)
-struct rio_info *p;
-struct Host *HostP;
-uint UnitId;
+static int RIOCheckIsolated(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
{
unsigned long flags;
rio_spin_lock_irqsave(&HostP->HostLock, flags);
@@ -628,12 +611,9 @@ uint UnitId;
** all the units attached to it. This will mean that the entire
** subnet will re-introduce itself.
*/
-static int RIOIsolate(p, HostP, UnitId)
-struct rio_info *p;
-struct Host *HostP;
-uint UnitId;
+static int RIOIsolate(struct rio_info *p, struct Host *HostP, unsigned int UnitId)
{
- uint link, unit;
+ unsigned int link, unit;
UnitId--; /* this trick relies on the Unit Id being UNSIGNED! */
@@ -658,9 +638,7 @@ uint UnitId;
return 1;
}
-static int RIOCheck(HostP, UnitId)
-struct Host *HostP;
-uint UnitId;
+static int RIOCheck(struct Host *HostP, unsigned int UnitId)
{
unsigned char link;
@@ -714,8 +692,7 @@ uint UnitId;
** Returns the type of unit (host, 16/8 port RTA)
*/
-uint GetUnitType(Uniq)
-uint Uniq;
+unsigned int GetUnitType(unsigned int Uniq)
{
switch ((Uniq >> 28) & 0xf) {
case RIO_AT:
@@ -736,8 +713,7 @@ uint Uniq;
}
}
-int RIOSetChange(p)
-struct rio_info *p;
+int RIOSetChange(struct rio_info *p)
{
if (p->RIOQuickCheck != NOT_CHANGED)
return (0);
@@ -751,14 +727,13 @@ struct rio_info *p;
return (0);
}
-static void RIOConCon(p, HostP, FromId, FromLink, ToId, ToLink, Change)
-struct rio_info *p;
-struct Host *HostP;
-uint FromId;
-uint FromLink;
-uint ToId;
-uint ToLink;
-int Change;
+static void RIOConCon(struct rio_info *p,
+ struct Host *HostP,
+ unsigned int FromId,
+ unsigned int FromLink,
+ unsigned int ToId,
+ unsigned int ToLink,
+ int Change)
{
char *FromName;
char *FromType;
@@ -818,7 +793,7 @@ int Change;
ToType = ToId ? "RTA" : "HOST";
rio_dprintk(RIO_DEBUG_ROUTE, "Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
- cprintf("Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
+ printk(KERN_DEBUG "rio: Link between %s '%s' (%c) and %s '%s' (%c) %s.\n", FromType, FromName, 'A' + FromLink, ToType, ToName, 'A' + ToLink, (Change == CONNECT) ? "established" : "disconnected");
}
/*
@@ -838,7 +813,7 @@ static int RIORemoveFromSavedTable(struct rio_info *p, struct Map *pMap)
*/
for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
if (p->RIOSavedTable[entry].RtaUniqueNum == pMap->RtaUniqueNum) {
- bzero((caddr_t) & p->RIOSavedTable[entry], sizeof(struct Map));
+ memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
}
}
return 0;
@@ -898,7 +873,7 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
int nOther = (HostP->Mapping[unit].ID2) - 1;
rio_dprintk(RIO_DEBUG_ROUTE, "RioFreedis second slot %d.\n", nOther);
- bzero((caddr_t) & HostP->Mapping[nOther], sizeof(struct Map));
+ memset(&HostP->Mapping[nOther], 0, sizeof(struct Map));
}
RIORemoveFromSavedTable(p, &HostP->Mapping[unit]);
@@ -912,7 +887,8 @@ static int RIOFreeDisconnected(struct rio_info *p, struct Host *HostP, int unit)
** This function scans the given host table for either one
** or two free unit ID's.
*/
-int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pID2)
+
+int RIOFindFreeID(struct rio_info *p, struct Host *HostP, unsigned int * pID1, unsigned int * pID2)
{
int unit, tempID;
@@ -997,7 +973,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
/*
** Clear out this slot now that we intend to use it.
*/
- bzero(&HostP->Mapping[unit], sizeof(struct Map));
+ memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
/*
** If the second ID is not needed then we can return
@@ -1015,7 +991,7 @@ int RIOFindFreeID(struct rio_info *p, struct Host *HostP, uint * pID1, uint * pI
/*
** Clear out this slot now that we intend to use it.
*/
- bzero(&HostP->Mapping[unit], sizeof(struct Map));
+ memset(&HostP->Mapping[unit], 0, sizeof(struct Map));
/* At this point under the right(wrong?) conditions
** we may have a first unit ID being higher than the
diff --git a/drivers/char/rio/riotable.c b/drivers/char/rio/riotable.c
index a86b216ab65..d3abe0d37d6 100644
--- a/drivers/char/rio/riotable.c
+++ b/drivers/char/rio/riotable.c
@@ -53,15 +53,12 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -74,25 +71,20 @@ static char *_riotable_c_sccs_ = "@(#)riotable.c 1.2";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "param.h"
-#include "list.h"
-#include "sam.h"
#include "protsts.h"
/*
** A configuration table has been loaded. It is now up to us
** to sort it out and use the information contained therein.
*/
-int RIONewTable(p)
-struct rio_info *p;
+int RIONewTable(struct rio_info *p)
{
int Host, Host1, Host2, NameIsUnique, Entry, SubEnt;
struct Map *MapP;
@@ -137,7 +129,7 @@ struct rio_info *p;
cptr = MapP->Name; /* (2) */
cptr[MAX_NAME_LEN - 1] = '\0';
if (cptr[0] == '\0') {
- bcopy(MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", MapP->Name, 8);
+ memcpy(MapP->Name, MapP->RtaUniqueNum ? "RTA NN" : "HOST NN", 8);
MapP->Name[5] = '0' + Entry / 10;
MapP->Name[6] = '0' + Entry % 10;
}
@@ -298,9 +290,9 @@ struct rio_info *p;
*/
for (Host = 0; Host < RIO_HOSTS; Host++) {
for (Entry = 0; Entry < MAX_RUP; Entry++) {
- bzero((caddr_t) & p->RIOHosts[Host].Mapping[Entry], sizeof(struct Map));
+ memset(&p->RIOHosts[Host].Mapping[Entry], 0, sizeof(struct Map));
}
- bzero((caddr_t) & p->RIOHosts[Host].Name[0], sizeof(p->RIOHosts[Host].Name));
+ memset(&p->RIOHosts[Host].Name[0], 0, sizeof(p->RIOHosts[Host].Name));
}
/*
@@ -326,7 +318,7 @@ struct rio_info *p;
*/
if (MapP->ID == 0) {
rio_dprintk(RIO_DEBUG_TABLE, "Host entry found. Name %s\n", MapP->Name);
- bcopy(MapP->Name, HostP->Name, MAX_NAME_LEN);
+ memcpy(HostP->Name, MapP->Name, MAX_NAME_LEN);
continue;
}
@@ -370,7 +362,7 @@ struct rio_info *p;
}
}
if (!p->RIOHosts[Host].Name[0]) {
- bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
+ memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
p->RIOHosts[Host].Name[5] += Host;
}
/*
@@ -398,7 +390,7 @@ struct rio_info *p;
*/
if (Host1 != Host) {
rio_dprintk(RIO_DEBUG_TABLE, "Default name %s already used\n", p->RIOHosts[Host].Name);
- bcopy("HOST 1", p->RIOHosts[Host].Name, 7);
+ memcpy(p->RIOHosts[Host].Name, "HOST 1", 7);
p->RIOHosts[Host].Name[5] += Host1;
}
rio_dprintk(RIO_DEBUG_TABLE, "Assigning default name %s\n", p->RIOHosts[Host].Name);
@@ -409,9 +401,10 @@ struct rio_info *p;
/*
** User process needs the config table - build it from first
** principles.
+**
+* FIXME: SMP locking
*/
-int RIOApel(p)
-struct rio_info *p;
+int RIOApel(struct rio_info *p)
{
int Host;
int link;
@@ -419,17 +412,17 @@ struct rio_info *p;
int Next = 0;
struct Map *MapP;
struct Host *HostP;
- long oldspl;
-
- disable(oldspl); /* strange but true! */
+ unsigned long flags;
rio_dprintk(RIO_DEBUG_TABLE, "Generating a table to return to config.rio\n");
- bzero((caddr_t) & p->RIOConnectTable[0], sizeof(struct Map) * TOTAL_MAP_ENTRIES);
+ memset(&p->RIOConnectTable[0], 0, sizeof(struct Map) * TOTAL_MAP_ENTRIES);
for (Host = 0; Host < RIO_HOSTS; Host++) {
rio_dprintk(RIO_DEBUG_TABLE, "Processing host %d\n", Host);
HostP = &p->RIOHosts[Host];
+ rio_spin_lock_irqsave(&HostP->HostLock, flags);
+
MapP = &p->RIOConnectTable[Next++];
MapP->HostUniqueNum = HostP->UniqueNum;
if ((HostP->Flags & RUN_STATE) != RC_RUNNING)
@@ -440,7 +433,7 @@ struct rio_info *p;
MapP->SysPort = NO_PORT;
for (link = 0; link < LINKS_PER_UNIT; link++)
MapP->Topology[link] = HostP->Topology[link];
- bcopy(HostP->Name, MapP->Name, MAX_NAME_LEN);
+ memcpy(MapP->Name, HostP->Name, MAX_NAME_LEN);
for (Rup = 0; Rup < MAX_RUP; Rup++) {
if (HostP->Mapping[Rup].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) {
p->RIOConnectTable[Next] = HostP->Mapping[Rup];
@@ -453,8 +446,8 @@ struct rio_info *p;
Next++;
}
}
+ rio_spin_unlock_irqrestore(&HostP->HostLock, flags);
}
- restore(oldspl);
return 0;
}
@@ -463,9 +456,7 @@ struct rio_info *p;
** if the entry is suitably inactive, then we can gob on it and remove
** it from the table.
*/
-int RIODeleteRta(p, MapP)
-struct rio_info *p;
-struct Map *MapP;
+int RIODeleteRta(struct rio_info *p, struct Map *MapP)
{
int host, entry, port, link;
int SysPort;
@@ -541,10 +532,10 @@ struct Map *MapP;
** the phb to port mappings in RIORouteRup.
*/
if (PortP->SecondBlock) {
- ushort dest_unit = HostMapP->ID;
- ushort dest_port = port - SysPort;
- WORD *TxPktP;
- PKT *Pkt;
+ u16 dest_unit = HostMapP->ID;
+ u16 dest_port = port - SysPort;
+ u16 *TxPktP;
+ struct PKT *Pkt;
for (TxPktP = PortP->TxStart; TxPktP <= PortP->TxEnd; TxPktP++) {
/*
@@ -554,19 +545,19 @@ struct Map *MapP;
** a 32 bit pointer so it can be
** accessed from the driver.
*/
- Pkt = (PKT *) RIO_PTR(HostP->Caddr, RWORD(*TxPktP));
+ Pkt = (struct PKT *) RIO_PTR(HostP->Caddr, readw(&*TxPktP));
rio_dprintk(RIO_DEBUG_TABLE, "Tx packet (%x) destination: Old %x:%x New %x:%x\n", *TxPktP, Pkt->dest_unit, Pkt->dest_port, dest_unit, dest_port);
- WWORD(Pkt->dest_unit, dest_unit);
- WWORD(Pkt->dest_port, dest_port);
+ writew(dest_unit, &Pkt->dest_unit);
+ writew(dest_port, &Pkt->dest_port);
}
rio_dprintk(RIO_DEBUG_TABLE, "Port %d phb destination: Old %x:%x New %x:%x\n", port, PortP->PhbP->destination & 0xff, (PortP->PhbP->destination >> 8) & 0xff, dest_unit, dest_port);
- WWORD(PortP->PhbP->destination, dest_unit + (dest_port << 8));
+ writew(dest_unit + (dest_port << 8), &PortP->PhbP->destination);
}
rio_spin_unlock_irqrestore(&PortP->portSem, sem_flags);
}
}
rio_dprintk(RIO_DEBUG_TABLE, "Entry nulled.\n");
- bzero((char *) HostMapP, sizeof(struct Map));
+ memset(HostMapP, 0, sizeof(struct Map));
work_done++;
}
}
@@ -576,11 +567,11 @@ struct Map *MapP;
/* XXXXX lock me up */
for (entry = 0; entry < TOTAL_MAP_ENTRIES; entry++) {
if (p->RIOSavedTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
- bzero((char *) &p->RIOSavedTable[entry], sizeof(struct Map));
+ memset(&p->RIOSavedTable[entry], 0, sizeof(struct Map));
work_done++;
}
if (p->RIOConnectTable[entry].RtaUniqueNum == MapP->RtaUniqueNum) {
- bzero((char *) &p->RIOConnectTable[entry], sizeof(struct Map));
+ memset(&p->RIOConnectTable[entry], 0, sizeof(struct Map));
work_done++;
}
}
@@ -602,7 +593,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
rio_dprintk(RIO_DEBUG_TABLE, "Assign entry on host %x, rta %x, ID %d, Sysport %d\n", MapP->HostUniqueNum, MapP->RtaUniqueNum, MapP->ID, (int) MapP->SysPort);
- if ((MapP->ID != (ushort) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
+ if ((MapP->ID != (u16) - 1) && ((int) MapP->ID < (int) 1 || (int) MapP->ID > MAX_RUP)) {
rio_dprintk(RIO_DEBUG_TABLE, "Bad ID in map entry!\n");
p->RIOError.Error = ID_NUMBER_OUT_OF_RANGE;
return -EINVAL;
@@ -648,7 +639,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
** Now we have a host we need to allocate an ID
** if the entry does not already have one.
*/
- if (MapP->ID == (ushort) - 1) {
+ if (MapP->ID == (u16) - 1) {
int nNewID;
rio_dprintk(RIO_DEBUG_TABLE, "Attempting to get a new ID for rta \"%s\"\n", MapP->Name);
@@ -667,7 +658,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
p->RIOError.Error = COULDNT_FIND_ENTRY;
return -EBUSY;
}
- MapP->ID = (ushort) nNewID + 1;
+ MapP->ID = (u16) nNewID + 1;
rio_dprintk(RIO_DEBUG_TABLE, "Allocated ID %d for this new RTA.\n", MapP->ID);
HostMapP = &p->RIOHosts[host].Mapping[nNewID];
HostMapP->RtaUniqueNum = MapP->RtaUniqueNum;
@@ -708,7 +699,7 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
*/
HostMapP->SysPort = MapP->SysPort;
if ((MapP->Flags & RTA16_SECOND_SLOT) == 0)
- CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
+ memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
HostMapP->Flags = SLOT_IN_USE | RTA_BOOTED;
#ifdef NEED_TO_FIX
RIO_SV_BROADCAST(p->RIOHosts[host].svFlags[MapP->ID - 1]);
@@ -742,16 +733,13 @@ int RIOAssignRta(struct rio_info *p, struct Map *MapP)
}
-int RIOReMapPorts(p, HostP, HostMapP)
-struct rio_info *p;
-struct Host *HostP;
-struct Map *HostMapP;
+int RIOReMapPorts(struct rio_info *p, struct Host *HostP, struct Map *HostMapP)
{
- register struct Port *PortP;
- uint SubEnt;
- uint HostPort;
- uint SysPort;
- ushort RtaType;
+ struct Port *PortP;
+ unsigned int SubEnt;
+ unsigned int HostPort;
+ unsigned int SysPort;
+ u16 RtaType;
unsigned long flags;
rio_dprintk(RIO_DEBUG_TABLE, "Mapping sysport %d to id %d\n", (int) HostMapP->SysPort, HostMapP->ID);
@@ -794,12 +782,12 @@ struct Map *HostMapP;
*/
if ((HostP->Flags & RUN_STATE) == RC_RUNNING) {
struct PHB *PhbP = PortP->PhbP = &HostP->PhbP[HostPort];
- PortP->TxAdd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_add));
- PortP->TxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_start));
- PortP->TxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->tx_end));
- PortP->RxRemove = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_remove));
- PortP->RxStart = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_start));
- PortP->RxEnd = (WORD *) RIO_PTR(HostP->Caddr, RWORD(PhbP->rx_end));
+ PortP->TxAdd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_add));
+ PortP->TxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_start));
+ PortP->TxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->tx_end));
+ PortP->RxRemove = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_remove));
+ PortP->RxStart = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_start));
+ PortP->RxEnd = (u16 *) RIO_PTR(HostP->Caddr, readw(&PhbP->rx_end));
} else
PortP->PhbP = NULL;
@@ -813,10 +801,10 @@ struct Map *HostMapP;
PortP->RupNum = HostMapP->ID - 1;
if (HostMapP->Flags & RTA16_SECOND_SLOT) {
PortP->ID2 = HostMapP->ID2 - 1;
- PortP->SecondBlock = TRUE;
+ PortP->SecondBlock = 1;
} else {
PortP->ID2 = 0;
- PortP->SecondBlock = FALSE;
+ PortP->SecondBlock = 0;
}
PortP->RtaUniqueNum = HostMapP->RtaUniqueNum;
@@ -866,9 +854,6 @@ struct Map *HostMapP;
PortP->RxDataStart = 0;
PortP->Cor2Copy = 0;
PortP->Name = &HostMapP->Name[0];
-#ifdef STATS
- bzero((caddr_t) & PortP->Stat, sizeof(struct RIOStats));
-#endif
PortP->statsGather = 0;
PortP->txchars = 0;
PortP->rxchars = 0;
@@ -876,10 +861,10 @@ struct Map *HostMapP;
PortP->closes = 0;
PortP->ioctls = 0;
if (PortP->TxRingBuffer)
- bzero(PortP->TxRingBuffer, p->RIOBufferSize);
+ memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
else if (p->RIOBufferSize) {
- PortP->TxRingBuffer = sysbrk(p->RIOBufferSize);
- bzero(PortP->TxRingBuffer, p->RIOBufferSize);
+ PortP->TxRingBuffer = kmalloc(p->RIOBufferSize, GFP_KERNEL);
+ memset(PortP->TxRingBuffer, 0, p->RIOBufferSize);
}
PortP->TxBufferOut = 0;
PortP->TxBufferIn = 0;
@@ -890,7 +875,7 @@ struct Map *HostMapP;
** If the same, we have received the same rx pkt from the RTA
** twice. Initialise to a value not equal to PHB_RX_TGL or 0.
*/
- PortP->LastRxTgl = ~(uchar) PHB_RX_TGL;
+ PortP->LastRxTgl = ~(u8) PHB_RX_TGL;
/*
** and mark the port as usable
@@ -906,9 +891,7 @@ struct Map *HostMapP;
return 0;
}
-int RIOChangeName(p, MapP)
-struct rio_info *p;
-struct Map *MapP;
+int RIOChangeName(struct rio_info *p, struct Map *MapP)
{
int host;
struct Map *HostMapP;
@@ -941,7 +924,7 @@ struct Map *MapP;
return -ENXIO;
}
if (MapP->ID == 0) {
- CCOPY(MapP->Name, p->RIOHosts[host].Name, MAX_NAME_LEN);
+ memcpy(p->RIOHosts[host].Name, MapP->Name, MAX_NAME_LEN);
return 0;
}
@@ -951,7 +934,7 @@ struct Map *MapP;
p->RIOError.Error = RTA_NUMBER_WRONG;
return -ENXIO;
}
- CCOPY(MapP->Name, HostMapP->Name, MAX_NAME_LEN);
+ memcpy(HostMapP->Name, MapP->Name, MAX_NAME_LEN);
return 0;
}
}
diff --git a/drivers/char/rio/riotty.c b/drivers/char/rio/riotty.c
index 6379816ed17..204267613c9 100644
--- a/drivers/char/rio/riotty.c
+++ b/drivers/char/rio/riotty.c
@@ -56,15 +56,12 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
#include "linux_compat.h"
#include "rio_linux.h"
-#include "typdef.h"
#include "pkt.h"
#include "daemon.h"
#include "rio.h"
#include "riospace.h"
-#include "top.h"
#include "cmdpkt.h"
#include "map.h"
-#include "riotypes.h"
#include "rup.h"
#include "port.h"
#include "riodrvr.h"
@@ -77,58 +74,18 @@ static char *_riotty_c_sccs_ = "@(#)riotty.c 1.3";
#include "unixrup.h"
#include "board.h"
#include "host.h"
-#include "error.h"
#include "phb.h"
#include "link.h"
#include "cmdblk.h"
#include "route.h"
-#include "control.h"
#include "cirrus.h"
#include "rioioctl.h"
#include "param.h"
-#include "list.h"
-#include "sam.h"
static void RIOClearUp(struct Port *PortP);
-int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
-
-
-extern int conv_vb[]; /* now defined in ttymgr.c */
-extern int conv_bv[]; /* now defined in ttymgr.c */
-/*
-** 16.09.1998 ARG - Fix to build riotty.k.o for Modular Kernel Support
-**
-** ep.def.h is necessary for Modular Kernel Support
-** DO NOT place any kernel 'extern's after this line
-** or this source file will not build riotty.k.o
-*/
-#ifdef uLYNX
-#include <ep.def.h>
-#endif
-
-#ifdef NEED_THIS2
-static struct old_sgttyb default_sg = {
- B19200, B19200, /* input and output speed */
- 'H' - '@', /* erase char */
- -1, /* 2nd erase char */
- 'U' - '@', /* kill char */
- ECHO | CRMOD, /* mode */
- 'C' - '@', /* interrupt character */
- '\\' - '@', /* quit char */
- 'Q' - '@', /* start char */
- 'S' - '@', /* stop char */
- 'D' - '@', /* EOF */
- -1, /* brk */
- (LCRTBS | LCRTERA | LCRTKIL | LCTLECH), /* local mode word */
- 'Z' - '@', /* process stop */
- 'Y' - '@', /* delayed stop */
- 'R' - '@', /* reprint line */
- 'O' - '@', /* flush output */
- 'W' - '@', /* word erase */
- 'V' - '@' /* literal next char */
-};
-#endif
+/* Below belongs in func.h */
+int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);
extern struct rio_info *p;
@@ -136,8 +93,7 @@ extern struct rio_info *p;
int riotopen(struct tty_struct *tty, struct file *filp)
{
- register uint SysPort;
- int Modem;
+ unsigned int SysPort;
int repeat_this = 250;
struct Port *PortP; /* pointer to the port structure */
unsigned long flags;
@@ -151,16 +107,14 @@ int riotopen(struct tty_struct *tty, struct file *filp)
tty->driver_data = NULL;
SysPort = rio_minor(tty);
- Modem = rio_ismodem(tty);
if (p->RIOFailed) {
rio_dprintk(RIO_DEBUG_TTY, "System initialisation failed\n");
- pseterr(ENXIO);
func_exit();
return -ENXIO;
}
- rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (%s) (mapped:%d)\n", SysPort, Modem ? "Modem" : "tty", p->RIOPortp[SysPort]->Mapped);
+ rio_dprintk(RIO_DEBUG_TTY, "port open SysPort %d (mapped:%d)\n", SysPort, p->RIOPortp[SysPort]->Mapped);
/*
** Validate that we have received a legitimate request.
@@ -170,7 +124,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
*/
if (SysPort >= RIO_PORTS) { /* out of range ? */
rio_dprintk(RIO_DEBUG_TTY, "Illegal port number %d\n", SysPort);
- pseterr(ENXIO);
func_exit();
return -ENXIO;
}
@@ -187,7 +140,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
*/
rio_dprintk(RIO_DEBUG_TTY, "port not mapped into system\n");
func_exit();
- pseterr(ENXIO);
return -ENXIO;
}
@@ -209,7 +161,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
*/
if ((PortP->HostP->Flags & RUN_STATE) != RC_RUNNING) {
rio_dprintk(RIO_DEBUG_TTY, "Host not running\n");
- pseterr(ENXIO);
func_exit();
return -ENXIO;
}
@@ -309,15 +260,12 @@ int riotopen(struct tty_struct *tty, struct file *filp)
/* PortP->gs.xmit_cnt = 0; */
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
-#ifdef NEED_THIS
- ttyseth(PortP, tp, (struct old_sgttyb *) &default_sg);
-#endif
/* Someone explain to me why this delay/config is
here. If I read the docs correctly the "open"
command piggybacks the parameters immediately.
-- REW */
- RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */
+ RIOParam(PortP, OPEN, 1, OK_TO_SLEEP); /* Open the port */
rio_spin_lock_irqsave(&PortP->portSem, flags);
/*
@@ -325,20 +273,6 @@ int riotopen(struct tty_struct *tty, struct file *filp)
*/
while (!(PortP->PortState & PORT_ISOPEN) && !p->RIOHalted) {
rio_dprintk(RIO_DEBUG_TTY, "Waiting for PORT_ISOPEN-currently %x\n", PortP->PortState);
-/*
-** 15.10.1998 ARG - ESIL 0759
-** (Part) fix for port being trashed when opened whilst RTA "disconnected"
-** Take out the limited wait - now wait for ever or until user
-** bangs us out.
-**
- if (repeat_this -- <= 0) {
- rio_dprint(RIO_DEBUG_TTY, ("Waiting for open to finish timed out.\n"));
- RIOPreemptiveCmd(p, PortP, FCLOSE );
- rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- return -EINTR;
- }
-**
-*/
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
rio_dprintk(RIO_DEBUG_TTY, "Waiting for open to finish broken by signal\n");
@@ -358,80 +292,61 @@ int riotopen(struct tty_struct *tty, struct file *filp)
}
rio_dprintk(RIO_DEBUG_TTY, "PORT_ISOPEN found\n");
}
-#ifdef MODEM_SUPPORT
- if (Modem) {
- rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
+ rio_dprintk(RIO_DEBUG_TTY, "Modem - test for carrier\n");
+ /*
+ ** ACTION
+ ** insert test for carrier here. -- ???
+ ** I already see that test here. What's the deal? -- REW
+ */
+ if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
+ rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
/*
- ** ACTION
- ** insert test for carrier here. -- ???
- ** I already see that test here. What's the deal? -- REW
+ tp->tm.c_state |= CARR_ON;
+ wakeup((caddr_t) &tp->tm.c_canq);
*/
- if ((PortP->gs.tty->termios->c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {
- rio_dprintk(RIO_DEBUG_TTY, "open(%d) Modem carr on\n", SysPort);
+ PortP->State |= RIO_CARR_ON;
+ wake_up_interruptible(&PortP->gs.open_wait);
+ } else { /* no carrier - wait for DCD */
/*
- tp->tm.c_state |= CARR_ON;
- wakeup((caddr_t) &tp->tm.c_canq);
- */
- PortP->State |= RIO_CARR_ON;
- wake_up_interruptible(&PortP->gs.open_wait);
- } else { /* no carrier - wait for DCD */
-
+ while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
+ !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
+ */
+ while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
+ rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
/*
- while (!(PortP->gs.tty->termios->c_state & CARR_ON) &&
- !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted )
+ PortP->gs.tty->termios->c_state |= WOPEN;
*/
- while (!(PortP->State & RIO_CARR_ON) && !(filp->f_flags & O_NONBLOCK) && !p->RIOHalted) {
-
- rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr on\n", SysPort);
+ PortP->State |= RIO_WOPEN;
+ rio_spin_unlock_irqrestore(&PortP->portSem, flags);
+ if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {
/*
- PortP->gs.tty->termios->c_state |= WOPEN;
+ ** ACTION: verify that this is a good thing
+ ** to do here. -- ???
+ ** I think it's OK. -- REW
*/
- PortP->State |= RIO_WOPEN;
+ rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
+ RIOPreemptiveCmd(p, PortP, FCLOSE);
+ /*
+ tp->tm.c_state &= ~WOPEN;
+ */
+ PortP->State &= ~RIO_WOPEN;
rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL)
- {
- /*
- ** ACTION: verify that this is a good thing
- ** to do here. -- ???
- ** I think it's OK. -- REW
- */
- rio_dprintk(RIO_DEBUG_TTY, "open(%d) sleeping for carr broken by signal\n", SysPort);
- RIOPreemptiveCmd(p, PortP, FCLOSE);
- /*
- tp->tm.c_state &= ~WOPEN;
- */
- PortP->State &= ~RIO_WOPEN;
- rio_spin_unlock_irqrestore(&PortP->portSem, flags);
- func_exit();
- return -EINTR;
- }
+ func_exit();
+ return -EINTR;
}
- PortP->State &= ~RIO_WOPEN;
}
- if (p->RIOHalted)
- goto bombout;
- rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
- PortP->State |= RIO_MOPEN;
- } else
-#endif
- {
- /*
- ** ACTION
- ** Direct line open - force carrier (will probably mean
- ** that sleeping Modem line fubar)
- */
- PortP->State |= RIO_LOPEN;
+ PortP->State &= ~RIO_WOPEN;
}
+ if (p->RIOHalted)
+ goto bombout;
+ rio_dprintk(RIO_DEBUG_TTY, "Setting RIO_MOPEN\n");
+ PortP->State |= RIO_MOPEN;
- if (p->RIOHalted) {
+ if (p->RIOHalted)
goto bombout;
- }
rio_dprintk(RIO_DEBUG_TTY, "high level open done\n");
-#ifdef STATS
- PortP->Stat.OpenCnt++;
-#endif
/*
** Count opens for port statistics reporting
*/
@@ -460,23 +375,21 @@ int riotclose(void *ptr)
unsigned long end_time;
struct tty_struct *tty;
unsigned long flags;
- int Modem;
int rv = 0;
rio_dprintk(RIO_DEBUG_TTY, "port close SysPort %d\n", PortP->PortNum);
/* PortP = p->RIOPortp[SysPort]; */
- rio_dprintk(RIO_DEBUG_TTY, "Port is at address 0x%x\n", (int) PortP);
+ rio_dprintk(RIO_DEBUG_TTY, "Port is at address %p\n", PortP);
/* tp = PortP->TtyP; *//* Get tty */
tty = PortP->gs.tty;
- rio_dprintk(RIO_DEBUG_TTY, "TTY is at address 0x%x\n", (int) tty);
+ rio_dprintk(RIO_DEBUG_TTY, "TTY is at address %p\n", tty);
if (PortP->gs.closing_wait)
end_time = jiffies + PortP->gs.closing_wait;
else
end_time = jiffies + MAX_SCHEDULE_TIMEOUT;
- Modem = rio_ismodem(tty);
rio_spin_lock_irqsave(&PortP->portSem, flags);
/*
@@ -500,7 +413,7 @@ int riotclose(void *ptr)
/*
** clear the open bits for this device
*/
- PortP->State &= (Modem ? ~RIO_MOPEN : ~RIO_LOPEN);
+ PortP->State &= ~RIO_MOPEN;
PortP->State &= ~RIO_CARR_ON;
PortP->ModemState &= ~MSVR1_CD;
/*
@@ -536,7 +449,6 @@ int riotclose(void *ptr)
if (!deleted)
while ((PortP->InUse != NOT_INUSE) && !p->RIOHalted && (PortP->TxBufferIn != PortP->TxBufferOut)) {
- cprintf("Need to flush the ttyport\n");
if (repeat_this-- <= 0) {
rv = -EINTR;
rio_dprintk(RIO_DEBUG_TTY, "Waiting for not idle closed broken by signal\n");
@@ -615,16 +527,13 @@ int riotclose(void *ptr)
*/
PortP->Config &= ~(RIO_CTSFLOW | RIO_RTSFLOW);
-#ifdef STATS
- PortP->Stat.CloseCnt++;
-#endif
/*
** Count opens for port statistics reporting
*/
if (PortP->statsGather)
PortP->closes++;
- close_end:
+close_end:
/* XXX: Why would a "DELETED" flag be reset here? I'd have
thought that a "deleted" flag means that the port was
permanently gone, but here we can make it reappear by it
@@ -640,8 +549,7 @@ int riotclose(void *ptr)
-static void RIOClearUp(PortP)
-struct Port *PortP;
+static void RIOClearUp(struct Port *PortP)
{
rio_dprintk(RIO_DEBUG_TTY, "RIOHalted set\n");
PortP->Config = 0; /* Direct semaphore */
@@ -668,7 +576,7 @@ struct Port *PortP;
*/
int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg)
{
- PKT *PacketP;
+ struct PKT *PacketP;
int retries = 20; /* at 10 per second -> 2 seconds */
unsigned long flags;
@@ -722,15 +630,15 @@ int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len
/*
** set the command byte and the argument byte
*/
- WBYTE(PacketP->data[0], command);
+ writeb(command, &PacketP->data[0]);
if (len == 2)
- WBYTE(PacketP->data[1], arg);
+ writeb(arg, &PacketP->data[1]);
/*
** set the length of the packet and set the command bit.
*/
- WBYTE(PacketP->len, PKT_CMD_BIT | len);
+ writeb(PKT_CMD_BIT | len, &PacketP->len);
add_transmit(PortP);
/*
diff --git a/drivers/char/rio/riotypes.h b/drivers/char/rio/riotypes.h
deleted file mode 100644
index 46084d5c7e9..00000000000
--- a/drivers/char/rio/riotypes.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
- ******* *******
- ******* R I O T Y P E S
- ******* *******
- ****************************************************************************
-
- Author : Jon Brawn
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef _riotypes_h
-#define _riotypes_h 1
-
-#ifdef SCCS_LABELS
-#ifndef lint
-/* static char *_rio_riotypes_h_sccs = "@(#)riotypes.h 1.10"; */
-#endif
-#endif
-
-typedef unsigned short NUMBER_ptr;
-typedef unsigned short WORD_ptr;
-typedef unsigned short BYTE_ptr;
-typedef unsigned short char_ptr;
-typedef unsigned short Channel_ptr;
-typedef unsigned short FREE_LIST_ptr_ptr;
-typedef unsigned short FREE_LIST_ptr;
-typedef unsigned short LPB_ptr;
-typedef unsigned short Process_ptr;
-typedef unsigned short PHB_ptr;
-typedef unsigned short PKT_ptr;
-typedef unsigned short PKT_ptr_ptr;
-typedef unsigned short Q_BUF_ptr;
-typedef unsigned short Q_BUF_ptr_ptr;
-typedef unsigned short ROUTE_STR_ptr;
-typedef unsigned short RUP_ptr;
-typedef unsigned short short_ptr;
-typedef unsigned short u_short_ptr;
-typedef unsigned short ushort_ptr;
-
-#endif /* __riotypes__ */
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/rom.h b/drivers/char/rio/rom.h
deleted file mode 100644
index 58a7843625f..00000000000
--- a/drivers/char/rio/rom.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
- ******* *******
- ******* R O M
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-
-#ifndef _rom_h
-#define _rom_h 1
-
-#ifndef lint
-#ifdef SCCS
-static char *_rio_rom_h_sccs = "@(#)rom.h 1.1";
-#endif
-#endif
-
-typedef struct ROM ROM;
-struct ROM {
- u_short slx;
- char pcb_letter_rev;
- char pcb_number_rev;
- char serial[4];
- char year;
- char week;
-};
-
-#endif
-
-#define HOST_ROM (ROM *) 0x7c00
-#define RTA_ROM (ROM *) 0x7801
-#define ROM_LENGTH 0x20
-
-/*********** end of file ***********/
diff --git a/drivers/char/rio/rup.h b/drivers/char/rio/rup.h
index f74f67c6f70..4ae90cb207a 100644
--- a/drivers/char/rio/rup.h
+++ b/drivers/char/rio/rup.h
@@ -37,14 +37,7 @@
#ifndef _rup_h
#define _rup_h 1
-#ifdef SCCS_LABELS
-#ifndef lint
-/* static char *_rio_rup_h_sccs = "@(#)rup.h 1.5"; */
-#endif
-#endif
-
#define MAX_RUP ((short) 16)
-
#define PKTS_PER_RUP ((short) 2) /* They are always used in pairs */
/*************************************************
@@ -60,15 +53,15 @@
#define RUP_NO_OWNER 0xff /* RUP not owned by any process */
struct RUP {
- PKT_ptr txpkt; /* Outgoing packet */
- PKT_ptr rxpkt; /* Incoming packet */
- WORD link; /* Which link to send down? */
- BYTE rup_dest_unit[2]; /* Destination unit */
- WORD handshake; /* For handshaking */
- WORD timeout; /* Timeout */
- WORD status; /* Status */
- WORD txcontrol; /* Transmit control */
- WORD rxcontrol; /* Receive control */
+ u16 txpkt; /* Outgoing packet */
+ u16 rxpkt; /* Incoming packet */
+ u16 link; /* Which link to send down? */
+ u8 rup_dest_unit[2]; /* Destination unit */
+ u16 handshake; /* For handshaking */
+ u16 timeout; /* Timeout */
+ u16 status; /* Status */
+ u16 txcontrol; /* Transmit control */
+ u16 rxcontrol; /* Receive control */
};
#endif
diff --git a/drivers/char/rio/sam.h b/drivers/char/rio/sam.h
deleted file mode 100644
index 6f754e19015..00000000000
--- a/drivers/char/rio/sam.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
- ******* *******
- ******* S A M . H
- ******* *******
- ****************************************************************************
-
- Author : Ian Nandhra
- Date :
-
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Version : 0.01
-
-
- Mods
- ----------------------------------------------------------------------------
- Date By Description
- ----------------------------------------------------------------------------
-
- ***************************************************************************/
-#ifndef _sam_h
-#define _sam_h 1
-
-#ifdef SCCS_LABELS
-#ifndef lint
-/* static char *_rio_sam_h_sccs = "@(#)sam.h 1.3"; */
-#endif
-#endif
-
-
-#define NUM_FREE_LIST_UNITS 500
-
-#ifndef FALSE
-#define FALSE (short) 0x00
-#endif
-#ifndef TRUE
-#define TRUE (short) !FALSE
-#endif
-
-#define TX TRUE
-#define RX FALSE
-
-
-typedef struct FREE_LIST FREE_LIST;
-struct FREE_LIST {
- FREE_LIST_ptr next;
- FREE_LIST_ptr prev;
-};
-
-
-#endif
-/*********** end of file ***********/
diff --git a/drivers/char/rio/space.h b/drivers/char/rio/space.h
deleted file mode 100644
index 1f12690f9d1..00000000000
--- a/drivers/char/rio/space.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-** -----------------------------------------------------------------------------
-**
-** Perle Specialix driver for Linux
-** Ported from existing RIO Driver for SCO sources.
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** Module : space.h
-** SID : 1.2
-** Last Modified : 11/6/98 11:34:19
-** Retrieved : 11/6/98 11:34:22
-**
-** ident @(#)space.h 1.2
-**
-** -----------------------------------------------------------------------------
-*/
-
-#ifndef __rio_space_h__
-#define __rio_space_h__
-
-#ifdef SCCS_LABELS
-static char *_space_h_sccs_ = "@(#)space.h 1.2";
-#endif
-
-extern int rio_cntls;
-extern int rio_bases[];
-extern int rio_limits[];
-extern int rio_vects[];
-
-#endif /* __rio_space_h__ */
diff --git a/drivers/char/rio/top.h b/drivers/char/rio/top.h
deleted file mode 100644
index d15a11dc4f7..00000000000
--- a/drivers/char/rio/top.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-** -----------------------------------------------------------------------------
-**
-** Perle Specialix driver for Linux
-** Ported from existing RIO Driver for SCO sources.
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** Module : top.h
-** SID : 1.2
-** Last Modified : 11/6/98 11:34:19
-** Retrieved : 11/6/98 11:34:22
-**
-** ident @(#)top.h 1.2
-**
-** -----------------------------------------------------------------------------
-*/
-
-#ifndef __rio_top_h__
-#define __rio_top_h__
-
-#ifdef SCCS_LABELS
-static char *_top_h_sccs_ = "@(#)top.h 1.2";
-#endif
-
-/*
-** Topology information
-*/
-struct Top {
- uchar Unit;
- uchar Link;
-};
-
-#endif /* __rio_top_h__ */
diff --git a/drivers/char/rio/typdef.h b/drivers/char/rio/typdef.h
deleted file mode 100644
index 185b889e151..00000000000
--- a/drivers/char/rio/typdef.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-** -----------------------------------------------------------------------------
-**
-** Perle Specialix driver for Linux
-** Ported from existing RIO Driver for SCO sources.
- *
- * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** Module : typdef.h
-** SID : 1.2
-** Last Modified : 11/6/98 11:34:20
-** Retrieved : 11/6/98 11:34:22
-**
-** ident @(#)typdef.h 1.2
-**
-** -----------------------------------------------------------------------------
-*/
-
-#ifndef __rio_typdef_h__
-#define __rio_typdef_h__
-
-#ifdef SCCS_LABELS
-static char *_typdef_h_sccs_ = "@(#)typdef.h 1.2";
-#endif
-
-#undef VPIX
-
-/*
-** IT IS REALLY, REALLY, IMPORTANT THAT BYTES ARE UNSIGNED!
-**
-** These types are ONLY to be used for refering to data structures
-** on the RIO Host card!
-*/
-typedef volatile unsigned char BYTE;
-typedef volatile unsigned short WORD;
-typedef volatile unsigned int DWORD;
-typedef volatile unsigned short RIOP;
-typedef volatile short NUMBER;
-
-
-/*
-** 27.01.199 ARG - mods to compile 'newutils' on LyxnOS -
-** These #defines are for the benefit of the 'libfuncs' library
-** only. They are not necessarily correct type mappings and
-** are here only to make the source compile.
-*/
-/* typedef unsigned int uint; */
-typedef unsigned long ulong_t;
-typedef unsigned short ushort_t;
-typedef unsigned char uchar_t;
-typedef unsigned char queue_t;
-typedef unsigned char mblk_t;
-typedef unsigned int paddr_t;
-typedef unsigned char uchar;
-
-#define TPNULL ((ushort)(0x8000))
-
-
-/*
-** RIO structures defined in other include files.
-*/
-typedef struct PKT PKT;
-typedef struct LPB LPB;
-typedef struct RUP RUP;
-typedef struct Port Port;
-typedef struct DpRam DpRam;
-
-#endif /* __rio_typdef_h__ */
diff --git a/drivers/char/rio/unixrup.h b/drivers/char/rio/unixrup.h
index a126c7cabac..4306e01dbf0 100644
--- a/drivers/char/rio/unixrup.h
+++ b/drivers/char/rio/unixrup.h
@@ -45,9 +45,9 @@ struct UnixRup {
struct CmdBlk *CmdsWaitingP; /* Commands waiting to be done */
struct CmdBlk *CmdPendingP; /* The command currently being sent */
struct RUP *RupP; /* the Rup to send it to */
- uint Id; /* Id number */
- uint BaseSysPort; /* SysPort of first tty on this RTA */
- uint ModTypes; /* Modules on this RTA */
+ unsigned int Id; /* Id number */
+ unsigned int BaseSysPort; /* SysPort of first tty on this RTA */
+ unsigned int ModTypes; /* Modules on this RTA */
spinlock_t RupLock; /* Lock structure for MPX */
/* struct lockb RupLock; *//* Lock structure for MPX */
};
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c
index 119e629656b..657c0d88f48 100644
--- a/drivers/char/riscom8.c
+++ b/drivers/char/riscom8.c
@@ -1743,10 +1743,10 @@ static int iobase;
static int iobase1;
static int iobase2;
static int iobase3;
-MODULE_PARM(iobase, "i");
-MODULE_PARM(iobase1, "i");
-MODULE_PARM(iobase2, "i");
-MODULE_PARM(iobase3, "i");
+module_param(iobase, int, 0);
+module_param(iobase1, int, 0);
+module_param(iobase2, int, 0);
+module_param(iobase3, int, 0);
MODULE_LICENSE("GPL");
#endif /* MODULE */
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c
index fee68cc895f..510bd3e0e88 100644
--- a/drivers/char/ser_a2232.c
+++ b/drivers/char/ser_a2232.c
@@ -97,7 +97,7 @@
#include <asm/amigahw.h>
#include <linux/zorro.h>
#include <asm/irq.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <linux/delay.h>
@@ -654,7 +654,7 @@ static void a2232_init_portstructs(void)
port->gs.closing_wait = 30 * HZ;
port->gs.rd = &a2232_real_driver;
#ifdef NEW_WRITE_LOCKING
- init_MUTEX(&(port->gs.port_write_sem));
+ init_MUTEX(&(port->gs.port_write_mutex));
#endif
init_waitqueue_head(&port->gs.open_wait);
init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c
index 0e7d216e7eb..b543821d8cb 100644
--- a/drivers/char/snsc.c
+++ b/drivers/char/snsc.c
@@ -5,7 +5,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
- * Copyright (C) 2004 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2004, 2006 Silicon Graphics, Inc. All rights reserved.
*/
/*
@@ -77,7 +77,7 @@ scdrv_open(struct inode *inode, struct file *file)
scd = container_of(inode->i_cdev, struct sysctl_data_s, scd_cdev);
/* allocate memory for subchannel data */
- sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
+ sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
if (sd == NULL) {
printk("%s: couldn't allocate subchannel data\n",
__FUNCTION__);
@@ -85,7 +85,6 @@ scdrv_open(struct inode *inode, struct file *file)
}
/* initialize subch_data_s fields */
- memset(sd, 0, sizeof (struct subch_data_s));
sd->sd_nasid = scd->scd_nasid;
sd->sd_subch = ia64_sn_irtr_open(scd->scd_nasid);
@@ -394,7 +393,7 @@ scdrv_init(void)
sprintf(devnamep, "#%d", geo_slab(geoid));
/* allocate sysctl device data */
- scd = kmalloc(sizeof (struct sysctl_data_s),
+ scd = kzalloc(sizeof (struct sysctl_data_s),
GFP_KERNEL);
if (!scd) {
printk("%s: failed to allocate device info"
@@ -402,7 +401,6 @@ scdrv_init(void)
SYSCTL_BASENAME, devname);
continue;
}
- memset(scd, 0, sizeof (struct sysctl_data_s));
/* initialize sysctl device data fields */
scd->scd_nasid = cnodeid_to_nasid(cnode);
diff --git a/drivers/char/snsc_event.c b/drivers/char/snsc_event.c
index a4fa507eed9..e234d50e142 100644
--- a/drivers/char/snsc_event.c
+++ b/drivers/char/snsc_event.c
@@ -287,7 +287,7 @@ scdrv_event_init(struct sysctl_data_s *scd)
{
int rv;
- event_sd = kmalloc(sizeof (struct subch_data_s), GFP_KERNEL);
+ event_sd = kzalloc(sizeof (struct subch_data_s), GFP_KERNEL);
if (event_sd == NULL) {
printk(KERN_WARNING "%s: couldn't allocate subchannel info"
" for event monitoring\n", __FUNCTION__);
@@ -295,7 +295,6 @@ scdrv_event_init(struct sysctl_data_s *scd)
}
/* initialize subch_data_s fields */
- memset(event_sd, 0, sizeof (struct subch_data_s));
event_sd->sd_nasid = scd->scd_nasid;
spin_lock_init(&event_sd->sd_rlock);
@@ -321,5 +320,3 @@ scdrv_event_init(struct sysctl_data_s *scd)
return;
}
}
-
-
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c
index bdaab699210..3f5d6077f39 100644
--- a/drivers/char/stallion.c
+++ b/drivers/char/stallion.c
@@ -148,7 +148,6 @@ static struct tty_driver *stl_serial;
* is already swapping a shared buffer won't make things any worse.
*/
static char *stl_tmpwritebuf;
-static DECLARE_MUTEX(stl_tmpwritesem);
/*
* Define a local default termios struct. All ports will be created
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index a6b4f02bdce..3b474723027 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -2318,7 +2318,7 @@ static int sx_init_portstructs (int nboards, int nports)
port->board = board;
port->gs.rd = &sx_real_driver;
#ifdef NEW_WRITE_LOCKING
- port->gs.port_write_sem = MUTEX;
+ port->gs.port_write_mutex = MUTEX;
#endif
port->gs.driver_lock = SPIN_LOCK_UNLOCKED;
/*
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c
index ede688a4e14..d68be61f0a4 100644
--- a/drivers/char/synclink.c
+++ b/drivers/char/synclink.c
@@ -7770,7 +7770,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
}
info->params.encoding = new_encoding;
- info->params.crc_type = new_crctype;;
+ info->params.crc_type = new_crctype;
/* if network interface up, reprogram hardware */
if (info->netcount)
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c
index b046390cd25..738ec2f4e56 100644
--- a/drivers/char/synclink_gt.c
+++ b/drivers/char/synclink_gt.c
@@ -1365,7 +1365,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
}
info->params.encoding = new_encoding;
- info->params.crc_type = new_crctype;;
+ info->params.crc_type = new_crctype;
/* if network interface up, reprogram hardware */
if (info->netcount)
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c
index 960adb256fb..85874013111 100644
--- a/drivers/char/synclinkmp.c
+++ b/drivers/char/synclinkmp.c
@@ -1650,7 +1650,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
}
info->params.encoding = new_encoding;
- info->params.crc_type = new_crctype;;
+ info->params.crc_type = new_crctype;
/* if network interface up, reprogram hardware */
if (info->netcount)
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c
index d58f8231885..35082dc12ea 100644
--- a/drivers/char/sysrq.c
+++ b/drivers/char/sysrq.c
@@ -42,16 +42,15 @@
/* Whether we react on sysrq keys or just ignore them */
int sysrq_enabled = 1;
-/* Loglevel sysrq handler */
static void sysrq_handle_loglevel(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
int i;
i = key - '0';
console_loglevel = 7;
printk("Loglevel set to %d\n", i);
console_loglevel = i;
-}
+}
static struct sysrq_key_op sysrq_loglevel_op = {
.handler = sysrq_handle_loglevel,
.help_msg = "loglevel0-8",
@@ -59,11 +58,9 @@ static struct sysrq_key_op sysrq_loglevel_op = {
.enable_mask = SYSRQ_ENABLE_LOG,
};
-
-/* SAK sysrq handler */
#ifdef CONFIG_VT
static void sysrq_handle_SAK(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
if (tty)
do_SAK(tty);
@@ -75,12 +72,13 @@ static struct sysrq_key_op sysrq_SAK_op = {
.action_msg = "SAK",
.enable_mask = SYSRQ_ENABLE_KEYBOARD,
};
+#else
+#define sysrq_SAK_op (*(struct sysrq_key_op *)0)
#endif
#ifdef CONFIG_VT
-/* unraw sysrq handler */
static void sysrq_handle_unraw(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
struct kbd_struct *kbd = &kbd_table[fg_console];
@@ -93,10 +91,11 @@ static struct sysrq_key_op sysrq_unraw_op = {
.action_msg = "Keyboard mode set to XLATE",
.enable_mask = SYSRQ_ENABLE_KEYBOARD,
};
+#else
+#define sysrq_unraw_op (*(struct sysrq_key_op *)0)
#endif /* CONFIG_VT */
#ifdef CONFIG_KEXEC
-/* crashdump sysrq handler */
static void sysrq_handle_crashdump(int key, struct pt_regs *pt_regs,
struct tty_struct *tty)
{
@@ -108,16 +107,16 @@ static struct sysrq_key_op sysrq_crashdump_op = {
.action_msg = "Trigger a crashdump",
.enable_mask = SYSRQ_ENABLE_DUMP,
};
+#else
+#define sysrq_crashdump_op (*(struct sysrq_key_op *)0)
#endif
-/* reboot sysrq handler */
static void sysrq_handle_reboot(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
local_irq_enable();
emergency_restart();
}
-
static struct sysrq_key_op sysrq_reboot_op = {
.handler = sysrq_handle_reboot,
.help_msg = "reBoot",
@@ -126,11 +125,10 @@ static struct sysrq_key_op sysrq_reboot_op = {
};
static void sysrq_handle_sync(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
emergency_sync();
}
-
static struct sysrq_key_op sysrq_sync_op = {
.handler = sysrq_handle_sync,
.help_msg = "Sync",
@@ -139,11 +137,10 @@ static struct sysrq_key_op sysrq_sync_op = {
};
static void sysrq_handle_mountro(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
emergency_remount();
}
-
static struct sysrq_key_op sysrq_mountro_op = {
.handler = sysrq_handle_mountro,
.help_msg = "Unmount",
@@ -151,28 +148,23 @@ static struct sysrq_key_op sysrq_mountro_op = {
.enable_mask = SYSRQ_ENABLE_REMOUNT,
};
-/* END SYNC SYSRQ HANDLERS BLOCK */
-
#ifdef CONFIG_DEBUG_MUTEXES
-
-static void
-sysrq_handle_showlocks(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
+static void sysrq_handle_showlocks(int key, struct pt_regs *pt_regs,
+ struct tty_struct *tty)
{
mutex_debug_show_all_locks();
}
-
static struct sysrq_key_op sysrq_showlocks_op = {
.handler = sysrq_handle_showlocks,
.help_msg = "show-all-locks(D)",
.action_msg = "Show Locks Held",
};
-
+#else
+#define sysrq_showlocks_op (*(struct sysrq_key_op *)0)
#endif
-/* SHOW SYSRQ HANDLERS BLOCK */
-
static void sysrq_handle_showregs(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
if (pt_regs)
show_regs(pt_regs);
@@ -184,9 +176,8 @@ static struct sysrq_key_op sysrq_showregs_op = {
.enable_mask = SYSRQ_ENABLE_DUMP,
};
-
static void sysrq_handle_showstate(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
show_state();
}
@@ -197,9 +188,8 @@ static struct sysrq_key_op sysrq_showstate_op = {
.enable_mask = SYSRQ_ENABLE_DUMP,
};
-
static void sysrq_handle_showmem(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
show_mem();
}
@@ -210,13 +200,9 @@ static struct sysrq_key_op sysrq_showmem_op = {
.enable_mask = SYSRQ_ENABLE_DUMP,
};
-/* SHOW SYSRQ HANDLERS BLOCK */
-
-
-/* SIGNAL SYSRQ HANDLERS BLOCK */
-
-/* signal sysrq helper function
- * Sends a signal to all user processes */
+/*
+ * Signal sysrq helper function. Sends a signal to all user processes.
+ */
static void send_sig_all(int sig)
{
struct task_struct *p;
@@ -229,7 +215,7 @@ static void send_sig_all(int sig)
}
static void sysrq_handle_term(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
send_sig_all(SIGTERM);
console_loglevel = 8;
@@ -243,7 +229,8 @@ static struct sysrq_key_op sysrq_term_op = {
static void moom_callback(void *ignored)
{
- out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL], GFP_KERNEL, 0);
+ out_of_memory(&NODE_DATA(0)->node_zonelists[ZONE_NORMAL],
+ GFP_KERNEL, 0);
}
static DECLARE_WORK(moom_work, moom_callback, NULL);
@@ -260,7 +247,7 @@ static struct sysrq_key_op sysrq_moom_op = {
};
static void sysrq_handle_kill(int key, struct pt_regs *pt_regs,
- struct tty_struct *tty)
+ struct tty_struct *tty)
{
send_sig_all(SIGKILL);
console_loglevel = 8;
@@ -272,8 +259,6 @@ static struct sysrq_key_op sysrq_kill_op = {
.enable_mask = SYSRQ_ENABLE_SIGNAL,
};
-/* END SIGNAL SYSRQ HANDLERS BLOCK */
-
static void sysrq_handle_unrt(int key, struct pt_regs *pt_regs,
struct tty_struct *tty)
{
@@ -288,110 +273,99 @@ static struct sysrq_key_op sysrq_unrt_op = {
/* Key Operations table and lock */
static DEFINE_SPINLOCK(sysrq_key_table_lock);
-#define SYSRQ_KEY_TABLE_LENGTH 36
-static struct sysrq_key_op *sysrq_key_table[SYSRQ_KEY_TABLE_LENGTH] = {
-/* 0 */ &sysrq_loglevel_op,
-/* 1 */ &sysrq_loglevel_op,
-/* 2 */ &sysrq_loglevel_op,
-/* 3 */ &sysrq_loglevel_op,
-/* 4 */ &sysrq_loglevel_op,
-/* 5 */ &sysrq_loglevel_op,
-/* 6 */ &sysrq_loglevel_op,
-/* 7 */ &sysrq_loglevel_op,
-/* 8 */ &sysrq_loglevel_op,
-/* 9 */ &sysrq_loglevel_op,
-/* a */ NULL, /* Don't use for system provided sysrqs,
- it is handled specially on the sparc
- and will never arrive */
-/* b */ &sysrq_reboot_op,
-#ifdef CONFIG_KEXEC
-/* c */ &sysrq_crashdump_op,
-#else
-/* c */ NULL,
-#endif
-#ifdef CONFIG_DEBUG_MUTEXES
-/* d */ &sysrq_showlocks_op,
-#else
-/* d */ NULL,
-#endif
-/* e */ &sysrq_term_op,
-/* f */ &sysrq_moom_op,
-/* g */ NULL,
-/* h */ NULL,
-/* i */ &sysrq_kill_op,
-/* j */ NULL,
-#ifdef CONFIG_VT
-/* k */ &sysrq_SAK_op,
-#else
-/* k */ NULL,
-#endif
-/* l */ NULL,
-/* m */ &sysrq_showmem_op,
-/* n */ &sysrq_unrt_op,
-/* o */ NULL, /* This will often be registered
- as 'Off' at init time */
-/* p */ &sysrq_showregs_op,
-/* q */ NULL,
-#ifdef CONFIG_VT
-/* r */ &sysrq_unraw_op,
-#else
-/* r */ NULL,
-#endif
-/* s */ &sysrq_sync_op,
-/* t */ &sysrq_showstate_op,
-/* u */ &sysrq_mountro_op,
-/* v */ NULL, /* May be assigned at init time by SMP VOYAGER */
-/* w */ NULL,
-/* x */ NULL,
-/* y */ NULL,
-/* z */ NULL
+
+static struct sysrq_key_op *sysrq_key_table[36] = {
+ &sysrq_loglevel_op, /* 0 */
+ &sysrq_loglevel_op, /* 1 */
+ &sysrq_loglevel_op, /* 2 */
+ &sysrq_loglevel_op, /* 3 */
+ &sysrq_loglevel_op, /* 4 */
+ &sysrq_loglevel_op, /* 5 */
+ &sysrq_loglevel_op, /* 6 */
+ &sysrq_loglevel_op, /* 7 */
+ &sysrq_loglevel_op, /* 8 */
+ &sysrq_loglevel_op, /* 9 */
+
+ /*
+ * Don't use for system provided sysrqs, it is handled specially on
+ * sparc and will never arrive
+ */
+ NULL, /* a */
+ &sysrq_reboot_op, /* b */
+ &sysrq_crashdump_op, /* c */
+ &sysrq_showlocks_op, /* d */
+ &sysrq_term_op, /* e */
+ &sysrq_moom_op, /* f */
+ NULL, /* g */
+ NULL, /* h */
+ &sysrq_kill_op, /* i */
+ NULL, /* j */
+ &sysrq_SAK_op, /* k */
+ NULL, /* l */
+ &sysrq_showmem_op, /* m */
+ &sysrq_unrt_op, /* n */
+ /* This will often be registered as 'Off' at init time */
+ NULL, /* o */
+ &sysrq_showregs_op, /* p */
+ NULL, /* q */
+ &sysrq_unraw_op, /* r */
+ &sysrq_sync_op, /* s */
+ &sysrq_showstate_op, /* t */
+ &sysrq_mountro_op, /* u */
+ /* May be assigned at init time by SMP VOYAGER */
+ NULL, /* v */
+ NULL, /* w */
+ NULL, /* x */
+ NULL, /* y */
+ NULL /* z */
};
/* key2index calculation, -1 on invalid index */
-static int sysrq_key_table_key2index(int key) {
+static int sysrq_key_table_key2index(int key)
+{
int retval;
- if ((key >= '0') && (key <= '9')) {
+
+ if ((key >= '0') && (key <= '9'))
retval = key - '0';
- } else if ((key >= 'a') && (key <= 'z')) {
+ else if ((key >= 'a') && (key <= 'z'))
retval = key + 10 - 'a';
- } else {
+ else
retval = -1;
- }
return retval;
}
/*
* get and put functions for the table, exposed to modules.
*/
-
-struct sysrq_key_op *__sysrq_get_key_op (int key) {
- struct sysrq_key_op *op_p;
+struct sysrq_key_op *__sysrq_get_key_op(int key)
+{
+ struct sysrq_key_op *op_p = NULL;
int i;
-
+
i = sysrq_key_table_key2index(key);
- op_p = (i == -1) ? NULL : sysrq_key_table[i];
+ if (i != -1)
+ op_p = sysrq_key_table[i];
return op_p;
}
-static void __sysrq_put_key_op (int key, struct sysrq_key_op *op_p) {
- int i;
+static void __sysrq_put_key_op(int key, struct sysrq_key_op *op_p)
+{
+ int i = sysrq_key_table_key2index(key);
- i = sysrq_key_table_key2index(key);
if (i != -1)
sysrq_key_table[i] = op_p;
}
/*
- * This is the non-locking version of handle_sysrq
- * It must/can only be called by sysrq key handlers,
- * as they are inside of the lock
+ * This is the non-locking version of handle_sysrq. It must/can only be called
+ * by sysrq key handlers, as they are inside of the lock
*/
-
-void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, int check_mask)
+void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty,
+ int check_mask)
{
struct sysrq_key_op *op_p;
int orig_log_level;
- int i, j;
+ int i;
unsigned long flags;
spin_lock_irqsave(&sysrq_key_table_lock, flags);
@@ -401,26 +375,34 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, in
op_p = __sysrq_get_key_op(key);
if (op_p) {
- /* Should we check for enabled operations (/proc/sysrq-trigger should not)
- * and is the invoked operation enabled? */
+ /*
+ * Should we check for enabled operations (/proc/sysrq-trigger
+ * should not) and is the invoked operation enabled?
+ */
if (!check_mask || sysrq_enabled == 1 ||
(sysrq_enabled & op_p->enable_mask)) {
- printk ("%s\n", op_p->action_msg);
+ printk("%s\n", op_p->action_msg);
console_loglevel = orig_log_level;
op_p->handler(key, pt_regs, tty);
- }
- else
+ } else {
printk("This sysrq operation is disabled.\n");
+ }
} else {
printk("HELP : ");
/* Only print the help msg once per handler */
- for (i=0; i<SYSRQ_KEY_TABLE_LENGTH; i++)
- if (sysrq_key_table[i]) {
- for (j=0; sysrq_key_table[i] != sysrq_key_table[j]; j++);
- if (j == i)
- printk ("%s ", sysrq_key_table[i]->help_msg);
+ for (i = 0; i < ARRAY_SIZE(sysrq_key_table); i++) {
+ if (sysrq_key_table[i]) {
+ int j;
+
+ for (j = 0; sysrq_key_table[i] !=
+ sysrq_key_table[j]; j++)
+ ;
+ if (j != i)
+ continue;
+ printk("%s ", sysrq_key_table[i]->help_msg);
+ }
}
- printk ("\n");
+ printk("\n");
console_loglevel = orig_log_level;
}
spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
@@ -430,16 +412,17 @@ void __handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty, in
* This function is called by the keyboard handler when SysRq is pressed
* and any other keycode arrives.
*/
-
void handle_sysrq(int key, struct pt_regs *pt_regs, struct tty_struct *tty)
{
if (!sysrq_enabled)
return;
__handle_sysrq(key, pt_regs, tty, 1);
}
+EXPORT_SYMBOL(handle_sysrq);
static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
- struct sysrq_key_op *remove_op_p) {
+ struct sysrq_key_op *remove_op_p)
+{
int retval;
unsigned long flags;
@@ -452,7 +435,6 @@ static int __sysrq_swap_key_ops(int key, struct sysrq_key_op *insert_op_p,
retval = -1;
}
spin_unlock_irqrestore(&sysrq_key_table_lock, flags);
-
return retval;
}
@@ -460,12 +442,10 @@ int register_sysrq_key(int key, struct sysrq_key_op *op_p)
{
return __sysrq_swap_key_ops(key, op_p, NULL);
}
+EXPORT_SYMBOL(register_sysrq_key);
int unregister_sysrq_key(int key, struct sysrq_key_op *op_p)
{
return __sysrq_swap_key_ops(key, NULL, op_p);
}
-
-EXPORT_SYMBOL(handle_sysrq);
-EXPORT_SYMBOL(register_sysrq_key);
EXPORT_SYMBOL(unregister_sysrq_key);
diff --git a/drivers/char/toshiba.c b/drivers/char/toshiba.c
index 0c6f521abd0..e2fb234dee4 100644
--- a/drivers/char/toshiba.c
+++ b/drivers/char/toshiba.c
@@ -355,14 +355,14 @@ static void tosh_set_fn_port(void)
/*
* Get the machine identification number of the current model
*/
-static int tosh_get_machine_id(void)
+static int tosh_get_machine_id(void __iomem *bios)
{
int id;
SMMRegisters regs;
unsigned short bx,cx;
unsigned long address;
- id = (0x100*(int) isa_readb(0xffffe))+((int) isa_readb(0xffffa));
+ id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
/* do we have a SCTTable machine identication number on our hands */
@@ -388,12 +388,12 @@ static int tosh_get_machine_id(void)
/* now twiddle with our pointer a bit */
- address = 0x000f0000+bx;
- cx = isa_readw(address);
- address = 0x000f0009+bx+cx;
- cx = isa_readw(address);
- address = 0x000f000a+cx;
- cx = isa_readw(address);
+ address = bx;
+ cx = readw(bios + address);
+ address = 9+bx+cx;
+ cx = readw(bios + address);
+ address = 0xa+cx;
+ cx = readw(bios + address);
/* now construct our machine identification number */
@@ -416,13 +416,18 @@ static int tosh_probe(void)
int i,major,minor,day,year,month,flag;
unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
SMMRegisters regs;
+ void __iomem *bios = ioremap(0xf0000, 0x10000);
+
+ if (!bios)
+ return -ENOMEM;
/* extra sanity check for the string "TOSHIBA" in the BIOS because
some machines that are not Toshiba's pass the next test */
for (i=0;i<7;i++) {
- if (isa_readb(0xfe010+i)!=signature[i]) {
+ if (readb(bios+0xe010+i)!=signature[i]) {
printk("toshiba: not a supported Toshiba laptop\n");
+ iounmap(bios);
return -ENODEV;
}
}
@@ -438,6 +443,7 @@ static int tosh_probe(void)
if ((flag==1) || ((regs.eax & 0xff00)==0x8600)) {
printk("toshiba: not a supported Toshiba laptop\n");
+ iounmap(bios);
return -ENODEV;
}
@@ -447,19 +453,19 @@ static int tosh_probe(void)
/* next get the machine ID of the current laptop */
- tosh_id = tosh_get_machine_id();
+ tosh_id = tosh_get_machine_id(bios);
/* get the BIOS version */
- major = isa_readb(0xfe009)-'0';
- minor = ((isa_readb(0xfe00b)-'0')*10)+(isa_readb(0xfe00c)-'0');
+ major = readb(bios+0xe009)-'0';
+ minor = ((readb(bios+0xe00b)-'0')*10)+(readb(bios+0xe00c)-'0');
tosh_bios = (major*0x100)+minor;
/* get the BIOS date */
- day = ((isa_readb(0xffff5)-'0')*10)+(isa_readb(0xffff6)-'0');
- month = ((isa_readb(0xffff8)-'0')*10)+(isa_readb(0xffff9)-'0');
- year = ((isa_readb(0xffffb)-'0')*10)+(isa_readb(0xffffc)-'0');
+ day = ((readb(bios+0xfff5)-'0')*10)+(readb(bios+0xfff6)-'0');
+ month = ((readb(bios+0xfff8)-'0')*10)+(readb(bios+0xfff9)-'0');
+ year = ((readb(bios+0xfffb)-'0')*10)+(readb(bios+0xfffc)-'0');
tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
| ((day & 0x1f)<<1);
@@ -476,6 +482,8 @@ static int tosh_probe(void)
if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
tosh_fan = 1;
+ iounmap(bios);
+
return 0;
}
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h
index fd3a4beaa53..dec0224b447 100644
--- a/drivers/char/tpm/tpm.h
+++ b/drivers/char/tpm/tpm.h
@@ -24,6 +24,7 @@
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/platform_device.h>
+#include <linux/io.h>
enum tpm_timeout {
TPM_TIMEOUT = 5, /* msecs */
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 53d3d066554..48d795bb8c4 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -130,7 +130,7 @@ LIST_HEAD(tty_drivers); /* linked list of tty drivers */
/* Semaphore to protect creating and releasing a tty. This is shared with
vt.c for deeply disgusting hack reasons */
-DECLARE_MUTEX(tty_sem);
+DEFINE_MUTEX(tty_mutex);
#ifdef CONFIG_UNIX98_PTYS
extern struct tty_driver *ptm_driver; /* Unix98 pty masters; for /dev/ptmx */
@@ -354,7 +354,7 @@ int tty_buffer_request_room(struct tty_struct *tty, size_t size)
EXPORT_SYMBOL_GPL(tty_buffer_request_room);
-int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size)
+int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
{
int copied = 0;
do {
@@ -378,7 +378,7 @@ int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t
EXPORT_SYMBOL_GPL(tty_insert_flip_string);
-int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size)
+int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size)
{
int copied = 0;
do {
@@ -1188,11 +1188,11 @@ void disassociate_ctty(int on_exit)
lock_kernel();
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
tty = current->signal->tty;
if (tty) {
tty_pgrp = tty->pgrp;
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
if (on_exit && tty->driver->type != TTY_DRIVER_TYPE_PTY)
tty_vhangup(tty);
} else {
@@ -1200,7 +1200,7 @@ void disassociate_ctty(int on_exit)
kill_pg(current->signal->tty_old_pgrp, SIGHUP, on_exit);
kill_pg(current->signal->tty_old_pgrp, SIGCONT, on_exit);
}
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
unlock_kernel();
return;
}
@@ -1211,7 +1211,7 @@ void disassociate_ctty(int on_exit)
}
/* Must lock changes to tty_old_pgrp */
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
current->signal->tty_old_pgrp = 0;
tty->session = 0;
tty->pgrp = -1;
@@ -1222,7 +1222,7 @@ void disassociate_ctty(int on_exit)
p->signal->tty = NULL;
} while_each_task_pid(current->signal->session, PIDTYPE_SID, p);
read_unlock(&tasklist_lock);
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
unlock_kernel();
}
@@ -1306,7 +1306,7 @@ static inline ssize_t do_tty_write(
ssize_t ret = 0, written = 0;
unsigned int chunk;
- if (down_interruptible(&tty->atomic_write)) {
+ if (mutex_lock_interruptible(&tty->atomic_write_lock)) {
return -ERESTARTSYS;
}
@@ -1329,7 +1329,7 @@ static inline ssize_t do_tty_write(
if (count < chunk)
chunk = count;
- /* write_buf/write_cnt is protected by the atomic_write semaphore */
+ /* write_buf/write_cnt is protected by the atomic_write_lock mutex */
if (tty->write_cnt < chunk) {
unsigned char *buf;
@@ -1338,7 +1338,7 @@ static inline ssize_t do_tty_write(
buf = kmalloc(chunk, GFP_KERNEL);
if (!buf) {
- up(&tty->atomic_write);
+ mutex_unlock(&tty->atomic_write_lock);
return -ENOMEM;
}
kfree(tty->write_buf);
@@ -1374,7 +1374,7 @@ static inline ssize_t do_tty_write(
inode->i_mtime = current_fs_time(inode->i_sb);
ret = written;
}
- up(&tty->atomic_write);
+ mutex_unlock(&tty->atomic_write_lock);
return ret;
}
@@ -1442,8 +1442,8 @@ static inline void tty_line_name(struct tty_driver *driver, int index, char *p)
/*
* WSH 06/09/97: Rewritten to remove races and properly clean up after a
- * failed open. The new code protects the open with a semaphore, so it's
- * really quite straightforward. The semaphore locking can probably be
+ * failed open. The new code protects the open with a mutex, so it's
+ * really quite straightforward. The mutex locking can probably be
* relaxed for the (most common) case of reopening a tty.
*/
static int init_dev(struct tty_driver *driver, int idx,
@@ -1640,7 +1640,7 @@ fast_track:
success:
*ret_tty = tty;
- /* All paths come through here to release the semaphore */
+ /* All paths come through here to release the mutex */
end_init:
return retval;
@@ -1837,7 +1837,7 @@ static void release_dev(struct file * filp)
/* Guard against races with tty->count changes elsewhere and
opens on /dev/tty */
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
tty_closing = tty->count <= 1;
o_tty_closing = o_tty &&
(o_tty->count <= (pty_master ? 1 : 0));
@@ -1868,7 +1868,7 @@ static void release_dev(struct file * filp)
printk(KERN_WARNING "release_dev: %s: read/write wait queue "
"active!\n", tty_name(tty, buf));
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
schedule();
}
@@ -1934,7 +1934,7 @@ static void release_dev(struct file * filp)
read_unlock(&tasklist_lock);
}
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
/* check whether both sides are closing ... */
if (!tty_closing || (o_tty && !o_tty_closing))
@@ -2040,11 +2040,11 @@ retry_open:
index = -1;
retval = 0;
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
if (device == MKDEV(TTYAUX_MAJOR,0)) {
if (!current->signal->tty) {
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
return -ENXIO;
}
driver = current->signal->tty->driver;
@@ -2070,18 +2070,18 @@ retry_open:
noctty = 1;
goto got_driver;
}
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
return -ENODEV;
}
driver = get_tty_driver(device, &index);
if (!driver) {
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
return -ENODEV;
}
got_driver:
retval = init_dev(driver, index, &tty);
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
if (retval)
return retval;
@@ -2167,9 +2167,9 @@ static int ptmx_open(struct inode * inode, struct file * filp)
}
up(&allocated_ptys_lock);
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
retval = init_dev(ptm_driver, index, &tty);
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
if (retval)
goto out;
@@ -2915,8 +2915,8 @@ static void initialize_tty_struct(struct tty_struct *tty)
init_waitqueue_head(&tty->write_wait);
init_waitqueue_head(&tty->read_wait);
INIT_WORK(&tty->hangup_work, do_tty_hangup, tty);
- sema_init(&tty->atomic_read, 1);
- sema_init(&tty->atomic_write, 1);
+ mutex_init(&tty->atomic_read_lock);
+ mutex_init(&tty->atomic_write_lock);
spin_lock_init(&tty->read_lock);
INIT_LIST_HEAD(&tty->tty_files);
INIT_WORK(&tty->SAK_work, NULL, NULL);
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c
index d9325281e48..fd00822ac14 100644
--- a/drivers/char/vme_scc.c
+++ b/drivers/char/vme_scc.c
@@ -184,7 +184,7 @@ static void scc_init_portstructs(void)
port->gs.closing_wait = 30 * HZ;
port->gs.rd = &scc_real_driver;
#ifdef NEW_WRITE_LOCKING
- port->gs.port_write_sem = MUTEX;
+ port->gs.port_write_mutex = MUTEX;
#endif
init_waitqueue_head(&port->gs.open_wait);
init_waitqueue_head(&port->gs.close_wait);
diff --git a/drivers/char/vt.c b/drivers/char/vt.c
index 0900d1dbee5..ca4844c527d 100644
--- a/drivers/char/vt.c
+++ b/drivers/char/vt.c
@@ -2489,7 +2489,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
}
/*
- * We take tty_sem in here to prevent another thread from coming in via init_dev
+ * We take tty_mutex in here to prevent another thread from coming in via init_dev
* and taking a ref against the tty while we're in the process of forgetting
* about it and cleaning things up.
*
@@ -2497,7 +2497,7 @@ static int con_open(struct tty_struct *tty, struct file *filp)
*/
static void con_close(struct tty_struct *tty, struct file *filp)
{
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
acquire_console_sem();
if (tty && tty->count == 1) {
struct vc_data *vc = tty->driver_data;
@@ -2507,15 +2507,15 @@ static void con_close(struct tty_struct *tty, struct file *filp)
tty->driver_data = NULL;
release_console_sem();
vcs_remove_devfs(tty);
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
/*
- * tty_sem is released, but we still hold BKL, so there is
+ * tty_mutex is released, but we still hold BKL, so there is
* still exclusion against init_dev()
*/
return;
}
release_console_sem();
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
}
static void vc_init(struct vc_data *vc, unsigned int rows,
@@ -2869,9 +2869,9 @@ void unblank_screen(void)
}
/*
- * We defer the timer blanking to work queue so it can take the console semaphore
+ * We defer the timer blanking to work queue so it can take the console mutex
* (console operations can still happen at irq time, but only from printk which
- * has the console semaphore. Not perfect yet, but better than no locking
+ * has the console mutex. Not perfect yet, but better than no locking
*/
static void blank_screen_t(unsigned long dummy)
{
@@ -3234,6 +3234,14 @@ void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org)
}
}
+int is_console_suspend_safe(void)
+{
+ /* It is unsafe to suspend devices while X has control of the
+ * hardware. Make sure we are running on a kernel-controlled console.
+ */
+ return vc_cons[fg_console].d->vc_mode == KD_TEXT;
+}
+
/*
* Visible symbols for modules
*/
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index c0dfcf273f0..16e99db2e12 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -148,6 +148,16 @@ config MPCORE_WATCHDOG
To compile this driver as a module, choose M here: the
module will be called mpcore_wdt.
+config EP93XX_WATCHDOG
+ tristate "EP93xx Watchdog"
+ depends on WATCHDOG && ARCH_EP93XX
+ help
+ Say Y here if to include support for the watchdog timer
+ embedded in the Cirrus Logic EP93xx family of devices.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ep93xx_wdt.
+
# X86 (i386 + ia64 + x86_64) Architecture
config ACQUIRE_WDT
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 36c0b282b8b..d6f27fde990 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o
obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o
obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
+obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
# X86 (i386 + ia64 + x86_64) Architecture
obj-$(CONFIG_ACQUIRE_WDT) += acquirewdt.o
diff --git a/drivers/char/watchdog/ep93xx_wdt.c b/drivers/char/watchdog/ep93xx_wdt.c
new file mode 100644
index 00000000000..9021dbb7829
--- /dev/null
+++ b/drivers/char/watchdog/ep93xx_wdt.c
@@ -0,0 +1,257 @@
+/*
+ * Watchdog driver for Cirrus Logic EP93xx family of devices.
+ *
+ * Copyright (c) 2004 Ray Lehtiniemi
+ * Copyright (c) 2006 Tower Technologies
+ * Based on ep93xx driver, bits from alim7101_wdt.c
+ *
+ * Authors: Ray Lehtiniemi <rayl@mail.com>,
+ * Alessandro Zummo <a.zummo@towertech.it>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ * This watchdog fires after 250msec, which is a too short interval
+ * for us to rely on the user space daemon alone. So we ping the
+ * wdt each ~200msec and eventually stop doing it if the user space
+ * daemon dies.
+ *
+ * TODO:
+ *
+ * - Test last reset from watchdog status
+ * - Add a few missing ioctls
+ */
+
+#include <linux/module.h>
+#include <linux/fs.h>
+#include <linux/miscdevice.h>
+#include <linux/watchdog.h>
+#include <linux/timer.h>
+
+#include <asm/hardware.h>
+#include <asm/uaccess.h>
+
+#define WDT_VERSION "0.3"
+#define PFX "ep93xx_wdt: "
+
+/* default timeout (secs) */
+#define WDT_TIMEOUT 30
+
+static int nowayout = WATCHDOG_NOWAYOUT;
+static int timeout = WDT_TIMEOUT;
+
+static struct timer_list timer;
+static unsigned long next_heartbeat;
+static unsigned long wdt_status;
+static unsigned long boot_status;
+
+#define WDT_IN_USE 0
+#define WDT_OK_TO_CLOSE 1
+
+#define EP93XX_WDT_REG(x) (EP93XX_WATCHDOG_BASE + (x))
+#define EP93XX_WDT_WATCHDOG EP93XX_WDT_REG(0x00)
+#define EP93XX_WDT_WDSTATUS EP93XX_WDT_REG(0x04)
+
+/* reset the wdt every ~200ms */
+#define WDT_INTERVAL (HZ/5)
+
+static void wdt_enable(void)
+{
+ __raw_writew(0xaaaa, EP93XX_WDT_WATCHDOG);
+}
+
+static void wdt_disable(void)
+{
+ __raw_writew(0xaa55, EP93XX_WDT_WATCHDOG);
+}
+
+static inline void wdt_ping(void)
+{
+ __raw_writew(0x5555, EP93XX_WDT_WATCHDOG);
+}
+
+static void wdt_startup(void)
+{
+ next_heartbeat = jiffies + (timeout * HZ);
+
+ wdt_enable();
+ mod_timer(&timer, jiffies + WDT_INTERVAL);
+}
+
+static void wdt_shutdown(void)
+{
+ del_timer_sync(&timer);
+ wdt_disable();
+}
+
+static void wdt_keepalive(void)
+{
+ /* user land ping */
+ next_heartbeat = jiffies + (timeout * HZ);
+}
+
+static int ep93xx_wdt_open(struct inode *inode, struct file *file)
+{
+ if (test_and_set_bit(WDT_IN_USE, &wdt_status))
+ return -EBUSY;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ wdt_startup();
+
+ return nonseekable_open(inode, file);
+}
+
+static ssize_t
+ep93xx_wdt_write(struct file *file, const char __user *data, size_t len,
+ loff_t *ppos)
+{
+ /* Can't seek (pwrite) on this device */
+ if (*ppos != file->f_pos)
+ return -ESPIPE;
+
+ if (len) {
+ if (!nowayout) {
+ size_t i;
+
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ for (i = 0; i != len; i++) {
+ char c;
+
+ if (get_user(c, data + i))
+ return -EFAULT;
+
+ if (c == 'V')
+ set_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ else
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+ }
+ }
+ wdt_keepalive();
+ }
+
+ return len;
+}
+
+static struct watchdog_info ident = {
+ .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE,
+ .identity = "EP93xx Watchdog",
+};
+
+static int
+ep93xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ int ret = -ENOIOCTLCMD;
+
+ switch (cmd) {
+ case WDIOC_GETSUPPORT:
+ ret = copy_to_user((struct watchdog_info __user *)arg, &ident,
+ sizeof(ident)) ? -EFAULT : 0;
+ break;
+
+ case WDIOC_GETSTATUS:
+ ret = put_user(0, (int __user *)arg);
+ break;
+
+ case WDIOC_GETBOOTSTATUS:
+ ret = put_user(boot_status, (int __user *)arg);
+ break;
+
+ case WDIOC_GETTIMEOUT:
+ /* actually, it is 0.250 seconds.... */
+ ret = put_user(1, (int __user *)arg);
+ break;
+
+ case WDIOC_KEEPALIVE:
+ wdt_keepalive();
+ ret = 0;
+ break;
+ }
+ return ret;
+}
+
+static int ep93xx_wdt_release(struct inode *inode, struct file *file)
+{
+ if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
+ wdt_shutdown();
+ else
+ printk(KERN_CRIT PFX "Device closed unexpectedly - "
+ "timer will not stop\n");
+
+ clear_bit(WDT_IN_USE, &wdt_status);
+ clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
+
+ return 0;
+}
+
+static struct file_operations ep93xx_wdt_fops = {
+ .owner = THIS_MODULE,
+ .write = ep93xx_wdt_write,
+ .ioctl = ep93xx_wdt_ioctl,
+ .open = ep93xx_wdt_open,
+ .release = ep93xx_wdt_release,
+};
+
+static struct miscdevice ep93xx_wdt_miscdev = {
+ .minor = WATCHDOG_MINOR,
+ .name = "watchdog",
+ .fops = &ep93xx_wdt_fops,
+};
+
+static void ep93xx_timer_ping(unsigned long data)
+{
+ if (time_before(jiffies, next_heartbeat))
+ wdt_ping();
+
+ /* Re-set the timer interval */
+ mod_timer(&timer, jiffies + WDT_INTERVAL);
+}
+
+static int __init ep93xx_wdt_init(void)
+{
+ int err;
+
+ err = misc_register(&ep93xx_wdt_miscdev);
+
+ boot_status = __raw_readl(EP93XX_WDT_WATCHDOG) & 0x01 ? 1 : 0;
+
+ printk(KERN_INFO PFX "EP93XX watchdog, driver version "
+ WDT_VERSION "%s\n",
+ (__raw_readl(EP93XX_WDT_WATCHDOG) & 0x08)
+ ? " (nCS1 disable detected)" : "");
+
+ if (timeout < 1 || timeout > 3600) {
+ timeout = WDT_TIMEOUT;
+ printk(KERN_INFO PFX
+ "timeout value must be 1<=x<=3600, using %d\n",
+ timeout);
+ }
+
+ setup_timer(&timer, ep93xx_timer_ping, 1);
+ return err;
+}
+
+static void __exit ep93xx_wdt_exit(void)
+{
+ wdt_shutdown();
+ misc_deregister(&ep93xx_wdt_miscdev);
+}
+
+module_init(ep93xx_wdt_init);
+module_exit(ep93xx_wdt_exit);
+
+module_param(nowayout, int, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
+
+module_param(timeout, int, 0);
+MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. (1<=timeout<=3600, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")");
+
+MODULE_AUTHOR("Ray Lehtiniemi <rayl@mail.com>,"
+ "Alessandro Zummo <a.zummo@towertech.it>");
+MODULE_DESCRIPTION("EP93xx Watchdog");
+MODULE_LICENSE("GPL");
+MODULE_VERSION(WDT_VERSION);
+MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/char/watchdog/pcwd_usb.c b/drivers/char/watchdog/pcwd_usb.c
index 1533f56baa4..2700c5c45b8 100644
--- a/drivers/char/watchdog/pcwd_usb.c
+++ b/drivers/char/watchdog/pcwd_usb.c
@@ -42,6 +42,7 @@
#include <linux/completion.h>
#include <asm/uaccess.h>
#include <linux/usb.h>
+#include <linux/mutex.h>
#ifdef CONFIG_USB_DEBUG
@@ -143,7 +144,7 @@ struct usb_pcwd_private {
static struct usb_pcwd_private *usb_pcwd_device;
/* prevent races between open() and disconnect() */
-static DECLARE_MUTEX (disconnect_sem);
+static DEFINE_MUTEX(disconnect_mutex);
/* local function prototypes */
static int usb_pcwd_probe (struct usb_interface *interface, const struct usb_device_id *id);
@@ -723,7 +724,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
struct usb_pcwd_private *usb_pcwd;
/* prevent races with open() */
- down (&disconnect_sem);
+ mutex_lock(&disconnect_mutex);
usb_pcwd = usb_get_intfdata (interface);
usb_set_intfdata (interface, NULL);
@@ -749,7 +750,7 @@ static void usb_pcwd_disconnect(struct usb_interface *interface)
cards_found--;
- up (&disconnect_sem);
+ mutex_unlock(&disconnect_mutex);
printk(KERN_INFO PFX "USB PC Watchdog disconnected\n");
}
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index d7125f4d911..35897079a78 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -26,6 +26,7 @@
#include <linux/netlink.h>
#include <linux/moduleparam.h>
#include <linux/connector.h>
+#include <linux/mutex.h>
#include <net/sock.h>
@@ -41,7 +42,7 @@ module_param(cn_val, uint, 0);
MODULE_PARM_DESC(cn_idx, "Connector's main device idx.");
MODULE_PARM_DESC(cn_val, "Connector's main device val.");
-static DECLARE_MUTEX(notify_lock);
+static DEFINE_MUTEX(notify_lock);
static LIST_HEAD(notify_list);
static struct cn_dev cdev;
@@ -260,7 +261,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
{
struct cn_ctl_entry *ent;
- down(&notify_lock);
+ mutex_lock(&notify_lock);
list_for_each_entry(ent, &notify_list, notify_entry) {
int i;
struct cn_notify_req *req;
@@ -293,7 +294,7 @@ static void cn_notify(struct cb_id *id, u32 notify_event)
cn_netlink_send(&m, ctl->group, GFP_KERNEL);
}
}
- up(&notify_lock);
+ mutex_unlock(&notify_lock);
}
/*
@@ -407,14 +408,14 @@ static void cn_callback(void *data)
if (ctl->group == 0) {
struct cn_ctl_entry *n;
- down(&notify_lock);
+ mutex_lock(&notify_lock);
list_for_each_entry_safe(ent, n, &notify_list, notify_entry) {
if (cn_ctl_msg_equals(ent->msg, ctl)) {
list_del(&ent->notify_entry);
kfree(ent);
}
}
- up(&notify_lock);
+ mutex_unlock(&notify_lock);
return;
}
@@ -429,9 +430,9 @@ static void cn_callback(void *data)
memcpy(ent->msg, ctl, size - sizeof(*ent));
- down(&notify_lock);
+ mutex_lock(&notify_lock);
list_add(&ent->notify_entry, &notify_list);
- up(&notify_lock);
+ mutex_unlock(&notify_lock);
}
static int __init cn_init(void)
diff --git a/drivers/dio/dio-driver.c b/drivers/dio/dio-driver.c
index ca8e69d2f64..e4c48e32936 100644
--- a/drivers/dio/dio-driver.c
+++ b/drivers/dio/dio-driver.c
@@ -71,22 +71,17 @@ static int dio_device_probe(struct device *dev)
* @drv: the driver structure to register
*
* Adds the driver structure to the list of registered drivers
- * Returns the number of DIO devices which were claimed by the driver
- * during registration. The driver remains registered even if the
- * return value is zero.
+ * Returns zero or a negative error value.
*/
int dio_register_driver(struct dio_driver *drv)
{
- int count = 0;
-
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &dio_bus_type;
/* register with core */
- count = driver_register(&drv->driver);
- return count ? count : 1;
+ return driver_register(&drv->driver);
}
diff --git a/drivers/eisa/.gitignore b/drivers/eisa/.gitignore
new file mode 100644
index 00000000000..4b335c0aedb
--- /dev/null
+++ b/drivers/eisa/.gitignore
@@ -0,0 +1 @@
+devlist.h
diff --git a/drivers/eisa/eisa-bus.c b/drivers/eisa/eisa-bus.c
index 4196137e66d..6078e2f5881 100644
--- a/drivers/eisa/eisa-bus.c
+++ b/drivers/eisa/eisa-bus.c
@@ -135,13 +135,8 @@ struct bus_type eisa_bus_type = {
int eisa_driver_register (struct eisa_driver *edrv)
{
- int r;
-
edrv->driver.bus = &eisa_bus_type;
- if ((r = driver_register (&edrv->driver)) < 0)
- return r;
-
- return 0;
+ return driver_register (&edrv->driver);
}
void eisa_driver_unregister (struct eisa_driver *edrv)
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 3a4e5c5b4e1..d6543fc4a92 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -33,6 +33,7 @@
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/types.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/semaphore.h>
@@ -48,7 +49,7 @@ static u8 *smi_data_buf;
static dma_addr_t smi_data_buf_handle;
static unsigned long smi_data_buf_size;
static u32 smi_data_buf_phys_addr;
-static DECLARE_MUTEX(smi_data_lock);
+static DEFINE_MUTEX(smi_data_lock);
static unsigned int host_control_action;
static unsigned int host_control_smi_type;
@@ -139,9 +140,9 @@ static ssize_t smi_data_buf_size_store(struct device *dev,
buf_size = simple_strtoul(buf, NULL, 10);
/* make sure SMI data buffer is at least buf_size */
- down(&smi_data_lock);
+ mutex_lock(&smi_data_lock);
ret = smi_data_buf_realloc(buf_size);
- up(&smi_data_lock);
+ mutex_unlock(&smi_data_lock);
if (ret)
return ret;
@@ -154,7 +155,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
size_t max_read;
ssize_t ret;
- down(&smi_data_lock);
+ mutex_lock(&smi_data_lock);
if (pos >= smi_data_buf_size) {
ret = 0;
@@ -165,7 +166,7 @@ static ssize_t smi_data_read(struct kobject *kobj, char *buf, loff_t pos,
ret = min(max_read, count);
memcpy(buf, smi_data_buf + pos, ret);
out:
- up(&smi_data_lock);
+ mutex_unlock(&smi_data_lock);
return ret;
}
@@ -174,7 +175,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
{
ssize_t ret;
- down(&smi_data_lock);
+ mutex_lock(&smi_data_lock);
ret = smi_data_buf_realloc(pos + count);
if (ret)
@@ -183,7 +184,7 @@ static ssize_t smi_data_write(struct kobject *kobj, char *buf, loff_t pos,
memcpy(smi_data_buf + pos, buf, count);
ret = count;
out:
- up(&smi_data_lock);
+ mutex_unlock(&smi_data_lock);
return ret;
}
@@ -201,9 +202,9 @@ static ssize_t host_control_action_store(struct device *dev,
ssize_t ret;
/* make sure buffer is available for host control command */
- down(&smi_data_lock);
+ mutex_lock(&smi_data_lock);
ret = smi_data_buf_realloc(sizeof(struct apm_cmd));
- up(&smi_data_lock);
+ mutex_unlock(&smi_data_lock);
if (ret)
return ret;
@@ -302,7 +303,7 @@ static ssize_t smi_request_store(struct device *dev,
unsigned long val = simple_strtoul(buf, NULL, 10);
ssize_t ret;
- down(&smi_data_lock);
+ mutex_lock(&smi_data_lock);
if (smi_data_buf_size < sizeof(struct smi_cmd)) {
ret = -ENODEV;
@@ -334,7 +335,7 @@ static ssize_t smi_request_store(struct device *dev,
}
out:
- up(&smi_data_lock);
+ mutex_unlock(&smi_data_lock);
return ret;
}
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 7230d4e0819..99cdc612d2c 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -406,13 +406,14 @@ config SENSORS_W83L785TS
will be called w83l785ts.
config SENSORS_W83627HF
- tristate "Winbond W83627HF, W83627THF, W83637HF, W83697HF"
- depends on HWMON && I2C && EXPERIMENTAL
+ tristate "Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF"
+ depends on HWMON && I2C
select I2C_ISA
select HWMON_VID
help
If you say yes here you get support for the Winbond W836X7 series
- of sensor chips: the W83627HF, W83627THF, W83637HF, and the W83697HF
+ of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and
+ W83697HF.
This driver can also be built as a module. If so, the module
will be called w83627hf.
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 665612729cb..2b6e74dd4a8 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -26,6 +26,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
@@ -92,7 +93,7 @@ struct adm1021_data {
struct class_device *class_dev;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -162,10 +163,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct adm1021_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(temp); \
adm1021_write_value(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
set(temp_max, ADM1021_REG_TOS_W);
@@ -275,7 +276,7 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -351,7 +352,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1021_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -375,7 +376,7 @@ static struct adm1021_data *adm1021_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/adm1025.c b/drivers/hwmon/adm1025.c
index 9331c56d2ba..a4c859c9fbf 100644
--- a/drivers/hwmon/adm1025.c
+++ b/drivers/hwmon/adm1025.c
@@ -53,6 +53,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver adm1025_driver = {
struct adm1025_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -207,11 +208,11 @@ static ssize_t set_in##offset##_min(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->in_min[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MIN(offset), \
data->in_min[offset]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -221,11 +222,11 @@ static ssize_t set_in##offset##_max(struct device *dev, struct device_attribute
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->in_max[offset] = IN_TO_REG(val, in_scale[offset]); \
i2c_smbus_write_byte_data(client, ADM1025_REG_IN_MAX(offset), \
data->in_max[offset]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
@@ -247,11 +248,11 @@ static ssize_t set_temp##offset##_min(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->temp_min[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_LOW(offset-1), \
data->temp_min[offset-1]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
} \
static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribute *attr, const char *buf, \
@@ -261,11 +262,11 @@ static ssize_t set_temp##offset##_max(struct device *dev, struct device_attribut
struct adm1025_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->temp_max[offset-1] = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, ADM1025_REG_TEMP_HIGH(offset-1), \
data->temp_max[offset-1]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
} \
static DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
@@ -404,7 +405,7 @@ static int adm1025_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -523,7 +524,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct adm1025_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int i;
@@ -558,7 +559,7 @@ static struct adm1025_data *adm1025_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/adm1026.c b/drivers/hwmon/adm1026.c
index fefe6e74fd0..6d4f8b8d358 100644
--- a/drivers/hwmon/adm1026.c
+++ b/drivers/hwmon/adm1026.c
@@ -32,6 +32,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -260,10 +261,10 @@ struct pwm_data {
struct adm1026_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
int valid; /* !=0 if following fields are valid */
unsigned long last_reading; /* In jiffies */
unsigned long last_config; /* In jiffies */
@@ -298,9 +299,8 @@ static int adm1026_attach_adapter(struct i2c_adapter *adapter);
static int adm1026_detect(struct i2c_adapter *adapter, int address,
int kind);
static int adm1026_detach_client(struct i2c_client *client);
-static int adm1026_read_value(struct i2c_client *client, u8 register);
-static int adm1026_write_value(struct i2c_client *client, u8 register,
- int value);
+static int adm1026_read_value(struct i2c_client *client, u8 reg);
+static int adm1026_write_value(struct i2c_client *client, u8 reg, int value);
static void adm1026_print_gpio(struct i2c_client *client);
static void adm1026_fixup_gpio(struct i2c_client *client);
static struct adm1026_data *adm1026_update_device(struct device *dev);
@@ -575,7 +575,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
int i;
long value, alarms, gpio;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (!data->valid
|| time_after(jiffies, data->last_reading + ADM1026_DATA_INTERVAL)) {
/* Things that change quickly */
@@ -710,7 +710,7 @@ static struct adm1026_data *adm1026_update_device(struct device *dev)
dev_dbg(&client->dev, "Setting VID from GPIO11-15.\n");
data->vid = (data->gpio >> 11) & 0x1f;
data->valid = 1;
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -739,10 +739,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = INS_TO_REG(nr, val);
adm1026_write_value(client, ADM1026_REG_IN_MIN[nr], data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_in_max(struct device *dev, struct device_attribute *attr,
@@ -762,10 +762,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = INS_TO_REG(nr, val);
adm1026_write_value(client, ADM1026_REG_IN_MAX[nr], data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -813,10 +813,10 @@ static ssize_t set_in16_min(struct device *dev, struct device_attribute *attr, c
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[16] = INS_TO_REG(16, val + NEG12_OFFSET);
adm1026_write_value(client, ADM1026_REG_IN_MIN[16], data->in_min[16]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_in16_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -831,10 +831,10 @@ static ssize_t set_in16_max(struct device *dev, struct device_attribute *attr, c
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[16] = INS_TO_REG(16, val+NEG12_OFFSET);
adm1026_write_value(client, ADM1026_REG_IN_MAX[16], data->in_max[16]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -874,11 +874,11 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, data->fan_div[nr]);
adm1026_write_value(client, ADM1026_REG_FAN_MIN(nr),
data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -939,7 +939,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
if (new_div == 0) {
return -EINVAL;
}
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
orig_div = data->fan_div[nr];
data->fan_div[nr] = DIV_FROM_REG(new_div);
@@ -958,7 +958,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
if (data->fan_div[nr] != orig_div) {
fixup_fan_min(dev,nr,orig_div);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1001,11 +1001,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[nr] = TEMP_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_TEMP_MIN[nr],
data->temp_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_max(struct device *dev, struct device_attribute *attr,
@@ -1025,11 +1025,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[nr] = TEMP_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_TEMP_MAX[nr],
data->temp_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1064,11 +1064,11 @@ static ssize_t set_temp_offset(struct device *dev,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_offset[nr] = TEMP_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_TEMP_OFFSET[nr],
data->temp_offset[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1115,11 +1115,11 @@ static ssize_t set_temp_auto_point1_temp(struct device *dev,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_tmin[nr] = TEMP_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_TEMP_TMIN[nr],
data->temp_tmin[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1150,11 +1150,11 @@ static ssize_t set_temp_crit_enable(struct device *dev,
int val = simple_strtol(buf, NULL, 10);
if ((val == 1) || (val==0)) {
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->config1 = (data->config1 & ~CFG1_THERM_HOT) | (val << 4);
adm1026_write_value(client, ADM1026_REG_CONFIG1,
data->config1);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
return count;
}
@@ -1184,11 +1184,11 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_crit[nr] = TEMP_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_TEMP_THERM[nr],
data->temp_crit[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1212,10 +1212,10 @@ static ssize_t set_analog_out_reg(struct device *dev, struct device_attribute *a
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->analog_out = DAC_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_DAC, data->analog_out);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1267,7 +1267,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
int val = simple_strtol(buf, NULL, 10);
unsigned long mask;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->alarm_mask = val & 0x7fffffff;
mask = data->alarm_mask
| (data->gpio_mask & 0x10000 ? 0x80000000 : 0);
@@ -1282,7 +1282,7 @@ static ssize_t set_alarm_mask(struct device *dev, struct device_attribute *attr,
mask >>= 8;
adm1026_write_value(client, ADM1026_REG_MASK4,
mask & 0xff);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1303,7 +1303,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
int val = simple_strtol(buf, NULL, 10);
long gpio;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->gpio = val & 0x1ffff;
gpio = data->gpio;
adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_0_7,gpio & 0xff);
@@ -1311,7 +1311,7 @@ static ssize_t set_gpio(struct device *dev, struct device_attribute *attr, const
adm1026_write_value(client, ADM1026_REG_GPIO_STATUS_8_15,gpio & 0xff);
gpio = ((gpio >> 1) & 0x80) | (data->alarms >> 24 & 0x7f);
adm1026_write_value(client, ADM1026_REG_STATUS4,gpio & 0xff);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1331,7 +1331,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
int val = simple_strtol(buf, NULL, 10);
long mask;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->gpio_mask = val & 0x1ffff;
mask = data->gpio_mask;
adm1026_write_value(client, ADM1026_REG_GPIO_MASK_0_7,mask & 0xff);
@@ -1339,7 +1339,7 @@ static ssize_t set_gpio_mask(struct device *dev, struct device_attribute *attr,
adm1026_write_value(client, ADM1026_REG_GPIO_MASK_8_15,mask & 0xff);
mask = ((mask >> 1) & 0x80) | (data->alarm_mask >> 24 & 0x7f);
adm1026_write_value(client, ADM1026_REG_MASK1,mask & 0xff);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1359,10 +1359,10 @@ static ssize_t set_pwm_reg(struct device *dev, struct device_attribute *attr, co
if (data->pwm1.enable == 1) {
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm1.pwm = PWM_TO_REG(val);
adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
return count;
}
@@ -1378,14 +1378,14 @@ static ssize_t set_auto_pwm_min(struct device *dev, struct device_attribute *att
struct adm1026_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm1.auto_pwm_min = SENSORS_LIMIT(val,0,255);
if (data->pwm1.enable == 2) { /* apply immediately */
data->pwm1.pwm = PWM_TO_REG((data->pwm1.pwm & 0x0f) |
PWM_MIN_TO_REG(data->pwm1.auto_pwm_min));
adm1026_write_value(client, ADM1026_REG_PWM, data->pwm1.pwm);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_auto_pwm_max(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1406,7 +1406,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
int old_enable;
if ((val >= 0) && (val < 3)) {
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
old_enable = data->pwm1.enable;
data->pwm1.enable = val;
data->config1 = (data->config1 & ~CFG1_PWM_AFC)
@@ -1424,7 +1424,7 @@ static ssize_t set_pwm_enable(struct device *dev, struct device_attribute *attr,
adm1026_write_value(client, ADM1026_REG_PWM,
data->pwm1.pwm);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
return count;
}
@@ -1541,7 +1541,7 @@ static int adm1026_detect(struct i2c_adapter *adapter, int address,
/* Fill in the remaining client fields */
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c
index d0639796608..3bf2da621ae 100644
--- a/drivers/hwmon/adm1031.c
+++ b/drivers/hwmon/adm1031.c
@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Following macros takes channel parameter starting from 0 to 2 */
#define ADM1031_REG_FAN_SPEED(nr) (0x08 + (nr))
@@ -70,7 +71,7 @@ typedef u8 auto_chan_table_t[8][2];
struct adm1031_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
int chip_type;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -262,10 +263,10 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
old_fan_mode = data->conf1;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ((ret = get_fan_auto_nearest(data, nr, val, data->conf1, &reg))) {
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return ret;
}
if (((data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1)) & ADM1031_CONF1_AUTO_MODE) ^
@@ -288,7 +289,7 @@ set_fan_auto_channel(struct device *dev, const char *buf, size_t count, int nr)
}
data->conf1 = FAN_CHAN_TO_REG(reg, data->conf1);
adm1031_write_value(client, ADM1031_REG_CONF1, data->conf1);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -329,11 +330,11 @@ set_auto_temp_min(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]);
adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
data->auto_temp[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -349,11 +350,11 @@ set_auto_temp_max(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], data->pwm[nr]);
adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr),
data->temp_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -405,11 +406,11 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
int val = simple_strtol(buf, NULL, 10);
int reg;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ((data->conf1 & ADM1031_CONF1_AUTO_MODE) &&
(((val>>4) & 0xf) != 5)) {
/* In automatic mode, the only PWM accepted is 33% */
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
data->pwm[nr] = PWM_TO_REG(val);
@@ -417,7 +418,7 @@ set_pwm(struct device *dev, const char *buf, size_t count, int nr)
adm1031_write_value(client, ADM1031_REG_PWM,
nr ? ((data->pwm[nr] << 4) & 0xf0) | (reg & 0xf)
: (data->pwm[nr] & 0xf) | (reg & 0xf0));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -511,7 +512,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
struct adm1031_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (val) {
data->fan_min[nr] =
FAN_TO_REG(val, FAN_DIV_FROM_REG(data->fan_div[nr]));
@@ -519,7 +520,7 @@ set_fan_min(struct device *dev, const char *buf, size_t count, int nr)
data->fan_min[nr] = 0xff;
}
adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
@@ -540,7 +541,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
if (tmp == 0xff)
return -EINVAL;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
old_div = FAN_DIV_FROM_REG(data->fan_div[nr]);
data->fan_div[nr] = (tmp & 0xC0) | (0x3f & data->fan_div[nr]);
new_min = data->fan_min[nr] * old_div /
@@ -553,7 +554,7 @@ set_fan_div(struct device *dev, const char *buf, size_t count, int nr)
data->fan_div[nr]);
adm1031_write_value(client, ADM1031_REG_FAN_MIN(nr),
data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -627,11 +628,11 @@ set_temp_min(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr),
data->temp_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
@@ -643,11 +644,11 @@ set_temp_max(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr),
data->temp_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t
@@ -659,11 +660,11 @@ set_temp_crit(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtol(buf, NULL, 10);
val = SENSORS_LIMIT(val, -55000, nr == 0 ? 127750 : 127875);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_crit[nr] = TEMP_TO_REG(val);
adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr),
data->temp_crit[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -778,7 +779,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -891,7 +892,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
struct adm1031_data *data = i2c_get_clientdata(client);
int chan;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -965,7 +966,7 @@ static struct adm1031_data *adm1031_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/adm9240.c b/drivers/hwmon/adm9240.c
index 5ddc22fea4a..43f6991b588 100644
--- a/drivers/hwmon/adm9240.c
+++ b/drivers/hwmon/adm9240.c
@@ -49,6 +49,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f,
@@ -150,7 +151,7 @@ struct adm9240_data {
enum chips type;
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid;
unsigned long last_updated_measure;
unsigned long last_updated_config;
@@ -195,11 +196,11 @@ static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
struct adm9240_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[attr->index] = TEMP_TO_REG(val);
i2c_smbus_write_byte_data(client, ADM9240_REG_TEMP_MAX(attr->index),
data->temp_max[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -246,11 +247,11 @@ static ssize_t set_in_min(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[attr->index] = IN_TO_REG(val, attr->index);
i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MIN(attr->index),
data->in_min[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -263,11 +264,11 @@ static ssize_t set_in_max(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[attr->index] = IN_TO_REG(val, attr->index);
i2c_smbus_write_byte_data(client, ADM9240_REG_IN_MAX(attr->index),
data->in_max[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -350,7 +351,7 @@ static ssize_t set_fan_min(struct device *dev,
int nr = attr->index;
u8 new_div;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (!val) {
data->fan_min[nr] = 255;
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct device *dev,
i2c_smbus_write_byte_data(client, ADM9240_REG_FAN_MIN(nr),
data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -439,10 +440,10 @@ static ssize_t set_aout(struct device *dev,
struct adm9240_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val);
i2c_smbus_write_byte_data(client, ADM9240_REG_ANALOG_OUT, data->aout);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -539,7 +540,7 @@ static int adm9240_detect(struct i2c_adapter *adapter, int address, int kind)
/* fill in the remaining client fields and attach */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->type = kind;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
if ((err = i2c_attach_client(new_client)))
goto exit_free;
@@ -691,7 +692,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
struct adm9240_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* minimum measurement cycle: 1.75 seconds */
if (time_after(jiffies, data->last_updated_measure + (HZ * 7 / 4))
@@ -771,7 +772,7 @@ static struct adm9240_data *adm9240_update_device(struct device *dev)
data->last_updated_config = jiffies;
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/asb100.c b/drivers/hwmon/asb100.c
index ae9de63cf2e..65b2709f750 100644
--- a/drivers/hwmon/asb100.c
+++ b/drivers/hwmon/asb100.c
@@ -44,6 +44,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/mutex.h>
#include "lm75.h"
/*
@@ -182,10 +183,10 @@ static u8 DIV_TO_REG(long val)
struct asb100_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
unsigned long last_updated; /* In jiffies */
/* array of 2 pointers to subclients */
@@ -245,11 +246,11 @@ static ssize_t set_in_##reg(struct device *dev, const char *buf, \
struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -331,10 +332,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct asb100_data *data = i2c_get_clientdata(client);
u32 val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -351,7 +352,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10);
int reg;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
@@ -381,7 +382,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
asb100_write_value(client, ASB100_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -461,7 +462,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
struct asb100_data *data = i2c_get_clientdata(client); \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
switch (nr) { \
case 1: case 2: \
data->reg[nr] = LM75_TEMP_TO_REG(val); \
@@ -472,7 +473,7 @@ static ssize_t set_##reg(struct device *dev, const char *buf, \
} \
asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
data->reg[nr]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -574,11 +575,11 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *attr, const
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm &= 0x80; /* keep the enable bit */
data->pwm |= (0x0f & ASB100_PWM_TO_REG(val));
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -595,11 +596,11 @@ static ssize_t set_pwm_enable1(struct device *dev, struct device_attribute *attr
struct asb100_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm &= 0x0f; /* keep the duty cycle bits */
data->pwm |= (val ? 0x80 : 0x00);
asb100_write_value(client, ASB100_REG_PWM1, data->pwm);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -729,7 +730,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
}
new_client = &data->client;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
@@ -789,7 +790,7 @@ static int asb100_detect(struct i2c_adapter *adapter, int address, int kind)
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -885,7 +886,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
struct i2c_client *cl;
int res, bank;
- down(&data->lock);
+ mutex_lock(&data->lock);
bank = (reg >> 8) & 0x0f;
if (bank > 2)
@@ -919,7 +920,7 @@ static int asb100_read_value(struct i2c_client *client, u16 reg)
if (bank > 2)
i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
@@ -930,7 +931,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
struct i2c_client *cl;
int bank;
- down(&data->lock);
+ mutex_lock(&data->lock);
bank = (reg >> 8) & 0x0f;
if (bank > 2)
@@ -960,7 +961,7 @@ static void asb100_write_value(struct i2c_client *client, u16 reg, u16 value)
if (bank > 2)
i2c_smbus_write_byte_data(client, ASB100_REG_BANK, 0);
- up(&data->lock);
+ mutex_unlock(&data->lock);
}
static void asb100_init_client(struct i2c_client *client)
@@ -984,7 +985,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
struct asb100_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -1042,7 +1043,7 @@ static struct asb100_data *asb100_update_device(struct device *dev)
dev_dbg(&client->dev, "... device update complete\n");
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/atxp1.c b/drivers/hwmon/atxp1.c
index b0c490073c8..728a1e8b919 100644
--- a/drivers/hwmon/atxp1.c
+++ b/drivers/hwmon/atxp1.c
@@ -26,6 +26,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("System voltages control via Attansic ATXP1");
@@ -60,7 +61,7 @@ static struct i2c_driver atxp1_driver = {
struct atxp1_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
unsigned long last_updated;
u8 valid;
struct {
@@ -80,7 +81,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
client = to_i2c_client(dev);
data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
@@ -93,7 +94,7 @@ static struct atxp1_data * atxp1_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return(data);
}
@@ -309,7 +310,7 @@ static int atxp1_detect(struct i2c_adapter *adapter, int address, int kind)
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
err = i2c_attach_client(new_client);
diff --git a/drivers/hwmon/ds1621.c b/drivers/hwmon/ds1621.c
index 203f9c7abb2..478eb4bb857 100644
--- a/drivers/hwmon/ds1621.c
+++ b/drivers/hwmon/ds1621.c
@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include "lm75.h"
/* Addresses to scan */
@@ -72,7 +73,7 @@ MODULE_PARM_DESC(polarity, "Output's polarity: 0 = active high, 1 = active low")
struct ds1621_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -156,10 +157,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
struct ds1621_data *data = ds1621_update_client(dev); \
u16 val = LM75_TEMP_TO_REG(simple_strtoul(buf, NULL, 10)); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = val; \
ds1621_write_value(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -242,7 +243,7 @@ static int ds1621_detect(struct i2c_adapter *adapter, int address,
/* Fill in remaining client fields and put it into the global list */
strlcpy(new_client->name, "ds1621", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -297,7 +298,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
struct ds1621_data *data = i2c_get_clientdata(client);
u8 new_conf;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -327,7 +328,7 @@ static struct ds1621_data *ds1621_update_client(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/f71805f.c b/drivers/hwmon/f71805f.c
index e029e0a94ec..885465df6e6 100644
--- a/drivers/hwmon/f71805f.c
+++ b/drivers/hwmon/f71805f.c
@@ -30,6 +30,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
static struct platform_device *pdev;
@@ -131,10 +132,10 @@ static struct resource f71805f_resource __initdata = {
struct f71805f_data {
unsigned short addr;
const char *name;
- struct semaphore lock;
+ struct mutex lock;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
unsigned long last_limits; /* In jiffies */
@@ -224,20 +225,20 @@ static u8 f71805f_read8(struct f71805f_data *data, u8 reg)
{
u8 val;
- down(&data->lock);
+ mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
val = inb(data->addr + DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return val;
}
static void f71805f_write8(struct f71805f_data *data, u8 reg, u8 val)
{
- down(&data->lock);
+ mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
outb(val, data->addr + DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
}
/* It is important to read the MSB first, because doing so latches the
@@ -246,24 +247,24 @@ static u16 f71805f_read16(struct f71805f_data *data, u8 reg)
{
u16 val;
- down(&data->lock);
+ mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
val = inb(data->addr + DATA_REG_OFFSET) << 8;
outb(++reg, data->addr + ADDR_REG_OFFSET);
val |= inb(data->addr + DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return val;
}
static void f71805f_write16(struct f71805f_data *data, u8 reg, u16 val)
{
- down(&data->lock);
+ mutex_lock(&data->lock);
outb(reg, data->addr + ADDR_REG_OFFSET);
outb(val >> 8, data->addr + DATA_REG_OFFSET);
outb(++reg, data->addr + ADDR_REG_OFFSET);
outb(val & 0xff, data->addr + DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
}
static struct f71805f_data *f71805f_update_device(struct device *dev)
@@ -271,7 +272,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
struct f71805f_data *data = dev_get_drvdata(dev);
int nr;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* Limit registers cache is refreshed after 60 seconds */
if (time_after(jiffies, data->last_updated + 60 * HZ)
@@ -323,7 +324,7 @@ static struct f71805f_data *f71805f_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -362,10 +363,10 @@ static ssize_t set_in0_max(struct device *dev, struct device_attribute
struct f71805f_data *data = dev_get_drvdata(dev);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_high[0] = in0_to_reg(val);
f71805f_write8(data, F71805F_REG_IN_HIGH(0), data->in_high[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -376,18 +377,14 @@ static ssize_t set_in0_min(struct device *dev, struct device_attribute
struct f71805f_data *data = dev_get_drvdata(dev);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_low[0] = in0_to_reg(val);
f71805f_write8(data, F71805F_REG_IN_LOW(0), data->in_low[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-static DEVICE_ATTR(in0_input, S_IRUGO, show_in0, NULL);
-static DEVICE_ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max);
-static DEVICE_ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min);
-
static ssize_t show_in(struct device *dev, struct device_attribute *devattr,
char *buf)
{
@@ -426,10 +423,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute
int nr = attr->index;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_high[nr] = in_to_reg(val);
f71805f_write8(data, F71805F_REG_IN_HIGH(nr), data->in_high[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -442,31 +439,14 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute
int nr = attr->index;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_low[nr] = in_to_reg(val);
f71805f_write8(data, F71805F_REG_IN_LOW(nr), data->in_low[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define sysfs_in(offset) \
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
- show_in, NULL, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in_max, set_in_max, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in_min, set_in_min, offset)
-
-sysfs_in(1);
-sysfs_in(2);
-sysfs_in(3);
-sysfs_in(4);
-sysfs_in(5);
-sysfs_in(6);
-sysfs_in(7);
-sysfs_in(8);
-
static ssize_t show_fan(struct device *dev, struct device_attribute *devattr,
char *buf)
{
@@ -495,24 +475,14 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute
int nr = attr->index;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_low[nr] = fan_to_reg(val);
f71805f_write16(data, F71805F_REG_FAN_LOW(nr), data->fan_low[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define sysfs_fan(offset) \
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
- show_fan, NULL, offset - 1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_min, set_fan_min, offset - 1)
-
-sysfs_fan(1);
-sysfs_fan(2);
-sysfs_fan(3);
-
static ssize_t show_temp(struct device *dev, struct device_attribute *devattr,
char *buf)
{
@@ -562,10 +532,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute
int nr = attr->index;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_high[nr] = temp_to_reg(val);
f71805f_write8(data, F71805F_REG_TEMP_HIGH(nr), data->temp_high[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -578,28 +548,14 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute
int nr = attr->index;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_hyst[nr] = temp_to_reg(val);
f71805f_write8(data, F71805F_REG_TEMP_HYST(nr), data->temp_hyst[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define sysfs_temp(offset) \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
- show_temp, NULL, offset - 1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
- show_temp_max, set_temp_max, offset - 1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \
- show_temp_hyst, set_temp_hyst, offset - 1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_type, S_IRUGO, \
- show_temp_type, NULL, offset - 1)
-
-sysfs_temp(1);
-sysfs_temp(2);
-sysfs_temp(3);
-
static ssize_t show_alarms_in(struct device *dev, struct device_attribute
*devattr, char *buf)
{
@@ -625,10 +581,6 @@ static ssize_t show_alarms_temp(struct device *dev, struct device_attribute
return sprintf(buf, "%d\n", (data->alarms[1] >> 3) & 0x07);
}
-static DEVICE_ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL);
-static DEVICE_ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL);
-static DEVICE_ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL);
-
static ssize_t show_name(struct device *dev, struct device_attribute
*devattr, char *buf)
{
@@ -637,7 +589,89 @@ static ssize_t show_name(struct device *dev, struct device_attribute
return sprintf(buf, "%s\n", data->name);
}
-static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
+static struct device_attribute f71805f_dev_attr[] = {
+ __ATTR(in0_input, S_IRUGO, show_in0, NULL),
+ __ATTR(in0_max, S_IRUGO| S_IWUSR, show_in0_max, set_in0_max),
+ __ATTR(in0_min, S_IRUGO| S_IWUSR, show_in0_min, set_in0_min),
+ __ATTR(alarms_in, S_IRUGO, show_alarms_in, NULL),
+ __ATTR(alarms_fan, S_IRUGO, show_alarms_fan, NULL),
+ __ATTR(alarms_temp, S_IRUGO, show_alarms_temp, NULL),
+ __ATTR(name, S_IRUGO, show_name, NULL),
+};
+
+static struct sensor_device_attribute f71805f_sensor_attr[] = {
+ SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),
+ SENSOR_ATTR(in1_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 1),
+ SENSOR_ATTR(in1_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 1),
+ SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2),
+ SENSOR_ATTR(in2_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 2),
+ SENSOR_ATTR(in2_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 2),
+ SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3),
+ SENSOR_ATTR(in3_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 3),
+ SENSOR_ATTR(in3_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 3),
+ SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4),
+ SENSOR_ATTR(in4_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 4),
+ SENSOR_ATTR(in4_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 4),
+ SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5),
+ SENSOR_ATTR(in5_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 5),
+ SENSOR_ATTR(in5_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 5),
+ SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6),
+ SENSOR_ATTR(in6_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 6),
+ SENSOR_ATTR(in6_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 6),
+ SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7),
+ SENSOR_ATTR(in7_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 7),
+ SENSOR_ATTR(in7_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 7),
+ SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8),
+ SENSOR_ATTR(in8_max, S_IRUGO | S_IWUSR,
+ show_in_max, set_in_max, 8),
+ SENSOR_ATTR(in8_min, S_IRUGO | S_IWUSR,
+ show_in_min, set_in_min, 8),
+
+ SENSOR_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0),
+ SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 0),
+ SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR,
+ show_temp_hyst, set_temp_hyst, 0),
+ SENSOR_ATTR(temp1_type, S_IRUGO, show_temp_type, NULL, 0),
+ SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1),
+ SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 1),
+ SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR,
+ show_temp_hyst, set_temp_hyst, 1),
+ SENSOR_ATTR(temp2_type, S_IRUGO, show_temp_type, NULL, 1),
+ SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2),
+ SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 2),
+ SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR,
+ show_temp_hyst, set_temp_hyst, 2),
+ SENSOR_ATTR(temp3_type, S_IRUGO, show_temp_type, NULL, 2),
+};
+
+static struct sensor_device_attribute f71805f_fan_attr[] = {
+ SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0),
+ SENSOR_ATTR(fan1_min, S_IRUGO | S_IWUSR,
+ show_fan_min, set_fan_min, 0),
+ SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1),
+ SENSOR_ATTR(fan2_min, S_IRUGO | S_IWUSR,
+ show_fan_min, set_fan_min, 1),
+ SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2),
+ SENSOR_ATTR(fan3_min, S_IRUGO | S_IWUSR,
+ show_fan_min, set_fan_min, 2),
+};
/*
* Device registration and initialization
@@ -668,7 +702,7 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
{
struct f71805f_data *data;
struct resource *res;
- int err;
+ int i, err;
if (!(data = kzalloc(sizeof(struct f71805f_data), GFP_KERNEL))) {
err = -ENOMEM;
@@ -678,9 +712,9 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
data->addr = res->start;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
data->name = "f71805f";
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
platform_set_drvdata(pdev, data);
@@ -695,76 +729,31 @@ static int __devinit f71805f_probe(struct platform_device *pdev)
f71805f_init_device(data);
/* Register sysfs interface files */
- device_create_file(&pdev->dev, &dev_attr_in0_input);
- device_create_file(&pdev->dev, &dev_attr_in0_max);
- device_create_file(&pdev->dev, &dev_attr_in0_min);
- device_create_file(&pdev->dev, &sensor_dev_attr_in1_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in2_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in3_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in4_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in5_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in6_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in7_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in8_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in1_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in2_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in3_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in4_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in5_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in6_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in7_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in8_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in1_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in2_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in3_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in4_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in5_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in6_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in7_min.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_in8_min.dev_attr);
- if (data->fan_enabled & (1 << 0)) {
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan1_input.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan1_min.dev_attr);
+ for (i = 0; i < ARRAY_SIZE(f71805f_dev_attr); i++) {
+ err = device_create_file(&pdev->dev, &f71805f_dev_attr[i]);
+ if (err)
+ goto exit_class;
}
- if (data->fan_enabled & (1 << 1)) {
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan2_input.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan2_min.dev_attr);
+ for (i = 0; i < ARRAY_SIZE(f71805f_sensor_attr); i++) {
+ err = device_create_file(&pdev->dev,
+ &f71805f_sensor_attr[i].dev_attr);
+ if (err)
+ goto exit_class;
}
- if (data->fan_enabled & (1 << 2)) {
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan3_input.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_fan3_min.dev_attr);
+ for (i = 0; i < ARRAY_SIZE(f71805f_fan_attr); i++) {
+ if (!(data->fan_enabled & (1 << (i / 2))))
+ continue;
+ err = device_create_file(&pdev->dev,
+ &f71805f_fan_attr[i].dev_attr);
+ if (err)
+ goto exit_class;
}
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp1_input.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp2_input.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp3_input.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp1_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp2_max.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp3_max.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp1_max_hyst.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp2_max_hyst.dev_attr);
- device_create_file(&pdev->dev,
- &sensor_dev_attr_temp3_max_hyst.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp1_type.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp2_type.dev_attr);
- device_create_file(&pdev->dev, &sensor_dev_attr_temp3_type.dev_attr);
- device_create_file(&pdev->dev, &dev_attr_alarms_in);
- device_create_file(&pdev->dev, &dev_attr_alarms_fan);
- device_create_file(&pdev->dev, &dev_attr_alarms_temp);
- device_create_file(&pdev->dev, &dev_attr_name);
return 0;
+exit_class:
+ dev_err(&pdev->dev, "Sysfs interface creation failed\n");
+ hwmon_device_unregister(data->class_dev);
exit_free:
kfree(data);
exit:
diff --git a/drivers/hwmon/fscher.c b/drivers/hwmon/fscher.c
index 25409181d1e..6bc76b40763 100644
--- a/drivers/hwmon/fscher.c
+++ b/drivers/hwmon/fscher.c
@@ -33,6 +33,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -133,7 +134,7 @@ static struct i2c_driver fscher_driver = {
struct fscher_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -332,7 +333,7 @@ static int fscher_detect(struct i2c_adapter *adapter, int address, int kind)
* global list */
strlcpy(new_client->name, "fscher", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -417,7 +418,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct fscher_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
@@ -457,7 +458,7 @@ static struct fscher_data *fscher_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -472,10 +473,10 @@ static ssize_t set_fan_status(struct i2c_client *client, struct fscher_data *dat
/* bits 0..1, 3..7 reserved => mask with 0x04 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x04;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_status[FAN_INDEX_FROM_NUM(nr)] &= ~v;
fscher_write_value(client, reg, v);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -490,10 +491,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscher_data *data,
{
unsigned long v = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[FAN_INDEX_FROM_NUM(nr)] = v > 0xff ? 0xff : v;
fscher_write_value(client, reg, data->fan_min[FAN_INDEX_FROM_NUM(nr)]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -518,14 +519,14 @@ static ssize_t set_fan_div(struct i2c_client *client, struct fscher_data *data,
return -EINVAL;
}
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* bits 2..7 reserved => mask with 0x03 */
data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] &= ~0x03;
data->fan_ripple[FAN_INDEX_FROM_NUM(nr)] |= v;
fscher_write_value(client, reg, data->fan_ripple[FAN_INDEX_FROM_NUM(nr)]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -552,10 +553,10 @@ static ssize_t set_temp_status(struct i2c_client *client, struct fscher_data *da
/* bits 2..7 reserved, 0 read only => mask with 0x02 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_status[TEMP_INDEX_FROM_NUM(nr)] &= ~v;
fscher_write_value(client, reg, v);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -609,10 +610,10 @@ static ssize_t set_control(struct i2c_client *client, struct fscher_data *data,
/* bits 1..7 reserved => mask with 0x01 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x01;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->global_control &= ~v;
fscher_write_value(client, reg, v);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -631,11 +632,11 @@ static ssize_t set_watchdog_control(struct i2c_client *client, struct
/* bits 0..3 reserved => mask with 0xf0 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->watchdog[2] &= ~0xf0;
data->watchdog[2] |= v;
fscher_write_value(client, reg, data->watchdog[2]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -651,10 +652,10 @@ static ssize_t set_watchdog_status(struct i2c_client *client, struct fscher_data
/* bits 0, 2..7 reserved => mask with 0x02 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0x02;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->watchdog[1] &= ~v;
fscher_write_value(client, reg, v);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -669,10 +670,10 @@ static ssize_t set_watchdog_preset(struct i2c_client *client, struct fscher_data
{
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->watchdog[0] = v;
fscher_write_value(client, reg, data->watchdog[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
diff --git a/drivers/hwmon/fscpos.c b/drivers/hwmon/fscpos.c
index 6d0146b5702..6dc4846b9ee 100644
--- a/drivers/hwmon/fscpos.c
+++ b/drivers/hwmon/fscpos.c
@@ -37,6 +37,7 @@
#include <linux/init.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -89,8 +90,8 @@ static int fscpos_attach_adapter(struct i2c_adapter *adapter);
static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind);
static int fscpos_detach_client(struct i2c_client *client);
-static int fscpos_read_value(struct i2c_client *client, u8 register);
-static int fscpos_write_value(struct i2c_client *client, u8 register, u8 value);
+static int fscpos_read_value(struct i2c_client *client, u8 reg);
+static int fscpos_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct fscpos_data *fscpos_update_device(struct device *dev);
static void fscpos_init_client(struct i2c_client *client);
@@ -114,7 +115,7 @@ static struct i2c_driver fscpos_driver = {
struct fscpos_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* 0 until following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -208,13 +209,13 @@ static ssize_t set_fan_ripple(struct i2c_client *client, struct fscpos_data
return -EINVAL;
}
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* bits 2..7 reserved => mask with 0x03 */
data->fan_ripple[nr - 1] &= ~0x03;
data->fan_ripple[nr - 1] |= v;
fscpos_write_value(client, reg, data->fan_ripple[nr - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -232,10 +233,10 @@ static ssize_t set_pwm(struct i2c_client *client, struct fscpos_data *data,
if (v < 0) v = 0;
if (v > 255) v = 255;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[nr - 1] = v;
fscpos_write_value(client, reg, data->pwm[nr - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -278,11 +279,11 @@ static ssize_t set_wdog_control(struct i2c_client *client, struct fscpos_data
/* bits 0..3 reserved => mask with 0xf0 */
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xf0;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->wdog_control &= ~0xf0;
data->wdog_control |= v;
fscpos_write_value(client, reg, data->wdog_control);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -304,10 +305,10 @@ static ssize_t set_wdog_state(struct i2c_client *client, struct fscpos_data
return -EINVAL;
}
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->wdog_state &= ~v;
fscpos_write_value(client, reg, v);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -321,10 +322,10 @@ static ssize_t set_wdog_preset(struct i2c_client *client, struct fscpos_data
{
unsigned long v = simple_strtoul(buf, NULL, 10) & 0xff;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->wdog_preset = v;
fscpos_write_value(client, reg, data->wdog_preset);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -483,7 +484,7 @@ static int fscpos_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "fscpos", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -579,7 +580,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct fscpos_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
int i;
@@ -625,7 +626,7 @@ static struct fscpos_data *fscpos_update_device(struct device *dev)
data->last_updated = jiffies;
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/gl518sm.c b/drivers/hwmon/gl518sm.c
index 9e685e3a3bc..6606aabdb49 100644
--- a/drivers/hwmon/gl518sm.c
+++ b/drivers/hwmon/gl518sm.c
@@ -43,6 +43,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, I2C_CLIENT_END };
@@ -120,7 +121,7 @@ struct gl518_data {
struct class_device *class_dev;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -212,10 +213,10 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
struct gl518_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = type##_TO_REG(val); \
gl518_write_value(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -228,12 +229,12 @@ static ssize_t set_##suffix(struct device *dev, struct device_attribute *attr, c
int regvalue; \
unsigned long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
regvalue = gl518_read_value(client, reg); \
data->value = type##_TO_REG(val); \
regvalue = (regvalue & ~mask) | (data->value << shift); \
gl518_write_value(client, reg, regvalue); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -265,7 +266,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
int regvalue;
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
data->fan_min[0] = FAN_TO_REG(val,
DIV_FROM_REG(data->fan_div[0]));
@@ -280,7 +281,7 @@ static ssize_t set_fan_min1(struct device *dev, struct device_attribute *attr, c
data->beep_mask &= data->alarm_mask;
gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -291,7 +292,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
int regvalue;
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
regvalue = gl518_read_value(client, GL518_REG_FAN_LIMIT);
data->fan_min[1] = FAN_TO_REG(val,
DIV_FROM_REG(data->fan_div[1]));
@@ -306,7 +307,7 @@ static ssize_t set_fan_min2(struct device *dev, struct device_attribute *attr, c
data->beep_mask &= data->alarm_mask;
gl518_write_value(client, GL518_REG_ALARM, data->beep_mask);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -407,7 +408,7 @@ static int gl518_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "gl518sm", I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -525,7 +526,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
struct gl518_data *data = i2c_get_clientdata(client);
int val;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -586,7 +587,7 @@ static struct gl518_data *gl518_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/gl520sm.c b/drivers/hwmon/gl520sm.c
index baee60e44b5..14e810f3c2c 100644
--- a/drivers/hwmon/gl520sm.c
+++ b/drivers/hwmon/gl520sm.c
@@ -29,6 +29,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Type of the extra sensor */
static unsigned short extra_sensor_type;
@@ -121,7 +122,7 @@ static struct i2c_driver gl520_driver = {
struct gl520_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until the following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -303,7 +304,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
long v = simple_strtol(buf, NULL, 10);
u8 r;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (n == 0)
r = VDD_TO_REG(v);
@@ -317,7 +318,7 @@ static ssize_t set_in_min(struct i2c_client *client, struct gl520_data *data, co
else
gl520_write_value(client, reg, r);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -331,7 +332,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
else
r = IN_TO_REG(v);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[n] = r;
@@ -340,7 +341,7 @@ static ssize_t set_in_max(struct i2c_client *client, struct gl520_data *data, co
else
gl520_write_value(client, reg, r);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -373,7 +374,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
unsigned long v = simple_strtoul(buf, NULL, 10);
u8 r;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
r = FAN_TO_REG(v, data->fan_div[n - 1]);
data->fan_min[n - 1] = r;
@@ -390,7 +391,7 @@ static ssize_t set_fan_min(struct i2c_client *client, struct gl520_data *data, c
data->beep_mask &= data->alarm_mask;
gl520_write_value(client, GL520_REG_BEEP_MASK, data->beep_mask);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -409,7 +410,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
return -EINVAL;
}
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_div[n - 1] = r;
if (n == 1)
@@ -417,7 +418,7 @@ static ssize_t set_fan_div(struct i2c_client *client, struct gl520_data *data, c
else
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x30) | (r << 4));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -425,10 +426,10 @@ static ssize_t set_fan_off(struct i2c_client *client, struct gl520_data *data, c
{
u8 r = simple_strtoul(buf, NULL, 10)?1:0;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_off = r;
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x0c) | (r << 2));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -454,10 +455,10 @@ static ssize_t set_temp_max(struct i2c_client *client, struct gl520_data *data,
{
long v = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
- data->temp_max[n - 1] = TEMP_TO_REG(v);;
+ mutex_lock(&data->update_lock);
+ data->temp_max[n - 1] = TEMP_TO_REG(v);
gl520_write_value(client, reg, data->temp_max[n - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -465,10 +466,10 @@ static ssize_t set_temp_max_hyst(struct i2c_client *client, struct gl520_data *d
{
long v = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max_hyst[n - 1] = TEMP_TO_REG(v);
gl520_write_value(client, reg, data->temp_max_hyst[n - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -491,10 +492,10 @@ static ssize_t set_beep_enable(struct i2c_client *client, struct gl520_data *dat
{
u8 r = simple_strtoul(buf, NULL, 10)?0:1;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->beep_enable = !r;
gl520_write_value(client, reg, (gl520_read_value(client, reg) & ~0x04) | (r << 2));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -502,11 +503,11 @@ static ssize_t set_beep_mask(struct i2c_client *client, struct gl520_data *data,
{
u8 r = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
r &= data->alarm_mask;
data->beep_mask = r;
gl520_write_value(client, reg, r);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -561,7 +562,7 @@ static int gl520_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, "gl520sm", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -685,7 +686,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
struct gl520_data *data = i2c_get_clientdata(client);
int val;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
@@ -750,7 +751,7 @@ static struct gl520_data *gl520_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/hdaps.c b/drivers/hwmon/hdaps.c
index 23a9e1ea8e3..7636c1a58f9 100644
--- a/drivers/hwmon/hdaps.c
+++ b/drivers/hwmon/hdaps.c
@@ -33,6 +33,7 @@
#include <linux/module.h>
#include <linux/timer.h>
#include <linux/dmi.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#define HDAPS_LOW_PORT 0x1600 /* first port used by hdaps */
@@ -70,10 +71,10 @@ static u8 km_activity;
static int rest_x;
static int rest_y;
-static DECLARE_MUTEX(hdaps_sem);
+static DEFINE_MUTEX(hdaps_mutex);
/*
- * __get_latch - Get the value from a given port. Callers must hold hdaps_sem.
+ * __get_latch - Get the value from a given port. Callers must hold hdaps_mutex.
*/
static inline u8 __get_latch(u16 port)
{
@@ -82,7 +83,7 @@ static inline u8 __get_latch(u16 port)
/*
* __check_latch - Check a port latch for a given value. Returns zero if the
- * port contains the given value. Callers must hold hdaps_sem.
+ * port contains the given value. Callers must hold hdaps_mutex.
*/
static inline int __check_latch(u16 port, u8 val)
{
@@ -93,7 +94,7 @@ static inline int __check_latch(u16 port, u8 val)
/*
* __wait_latch - Wait up to 100us for a port latch to get a certain value,
- * returning zero if the value is obtained. Callers must hold hdaps_sem.
+ * returning zero if the value is obtained. Callers must hold hdaps_mutex.
*/
static int __wait_latch(u16 port, u8 val)
{
@@ -110,7 +111,7 @@ static int __wait_latch(u16 port, u8 val)
/*
* __device_refresh - request a refresh from the accelerometer. Does not wait
- * for refresh to complete. Callers must hold hdaps_sem.
+ * for refresh to complete. Callers must hold hdaps_mutex.
*/
static void __device_refresh(void)
{
@@ -124,7 +125,7 @@ static void __device_refresh(void)
/*
* __device_refresh_sync - request a synchronous refresh from the
* accelerometer. We wait for the refresh to complete. Returns zero if
- * successful and nonzero on error. Callers must hold hdaps_sem.
+ * successful and nonzero on error. Callers must hold hdaps_mutex.
*/
static int __device_refresh_sync(void)
{
@@ -134,7 +135,7 @@ static int __device_refresh_sync(void)
/*
* __device_complete - indicate to the accelerometer that we are done reading
- * data, and then initiate an async refresh. Callers must hold hdaps_sem.
+ * data, and then initiate an async refresh. Callers must hold hdaps_mutex.
*/
static inline void __device_complete(void)
{
@@ -152,7 +153,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
{
int ret;
- down(&hdaps_sem);
+ mutex_lock(&hdaps_mutex);
/* do a sync refresh -- we need to be sure that we read fresh data */
ret = __device_refresh_sync();
@@ -163,7 +164,7 @@ static int hdaps_readb_one(unsigned int port, u8 *val)
__device_complete();
out:
- up(&hdaps_sem);
+ mutex_unlock(&hdaps_mutex);
return ret;
}
@@ -198,9 +199,9 @@ static int hdaps_read_pair(unsigned int port1, unsigned int port2,
{
int ret;
- down(&hdaps_sem);
+ mutex_lock(&hdaps_mutex);
ret = __hdaps_read_pair(port1, port2, val1, val2);
- up(&hdaps_sem);
+ mutex_unlock(&hdaps_mutex);
return ret;
}
@@ -213,7 +214,7 @@ static int hdaps_device_init(void)
{
int total, ret = -ENXIO;
- down(&hdaps_sem);
+ mutex_lock(&hdaps_mutex);
outb(0x13, 0x1610);
outb(0x01, 0x161f);
@@ -279,7 +280,7 @@ static int hdaps_device_init(void)
}
out:
- up(&hdaps_sem);
+ mutex_unlock(&hdaps_mutex);
return ret;
}
@@ -313,7 +314,7 @@ static struct platform_driver hdaps_driver = {
};
/*
- * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_sem.
+ * hdaps_calibrate - Set our "resting" values. Callers must hold hdaps_mutex.
*/
static void hdaps_calibrate(void)
{
@@ -325,7 +326,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
int x, y;
/* Cannot sleep. Try nonblockingly. If we fail, try again later. */
- if (down_trylock(&hdaps_sem)) {
+ if (!mutex_trylock(&hdaps_mutex)) {
mod_timer(&hdaps_timer,jiffies + HDAPS_POLL_PERIOD);
return;
}
@@ -340,7 +341,7 @@ static void hdaps_mousedev_poll(unsigned long unused)
mod_timer(&hdaps_timer, jiffies + HDAPS_POLL_PERIOD);
out:
- up(&hdaps_sem);
+ mutex_unlock(&hdaps_mutex);
}
@@ -420,9 +421,9 @@ static ssize_t hdaps_calibrate_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- down(&hdaps_sem);
+ mutex_lock(&hdaps_mutex);
hdaps_calibrate();
- up(&hdaps_sem);
+ mutex_unlock(&hdaps_mutex);
return count;
}
diff --git a/drivers/hwmon/hwmon-vid.c b/drivers/hwmon/hwmon-vid.c
index e497274916c..a74a44f16f5 100644
--- a/drivers/hwmon/hwmon-vid.c
+++ b/drivers/hwmon/hwmon-vid.c
@@ -54,6 +54,10 @@
(IMVP-II). You can find more information in the datasheet of Max1718
http://www.maxim-ic.com/quick_view2.cfm/qv_pk/2452
+ The 13 specification corresponds to the Intel Pentium M series. There
+ doesn't seem to be any named specification for these. The conversion
+ tables are detailed directly in the various Pentium M datasheets:
+ http://www.intel.com/design/intarch/pentiumm/docs_pentiumm.htm
*/
/* vrm is the VRM/VRD document version multiplied by 10.
@@ -100,6 +104,8 @@ int vid_from_reg(int val, u8 vrm)
case 17: /* Intel IMVP-II */
return(val & 0x10 ? 975 - (val & 0xF) * 25 :
1750 - val * 50);
+ case 13:
+ return(1708 - (val & 0x3f) * 16);
default: /* report 0 for unknown */
printk(KERN_INFO "hwmon-vid: requested unknown VRM version\n");
return 0;
@@ -129,8 +135,9 @@ struct vrm_model {
static struct vrm_model vrm_models[] = {
{X86_VENDOR_AMD, 0x6, ANY, ANY, 90}, /* Athlon Duron etc */
{X86_VENDOR_AMD, 0xF, ANY, ANY, 24}, /* Athlon 64, Opteron and above VRM 24 */
- {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 85}, /* 0.13um too */
+ {X86_VENDOR_INTEL, 0x6, 0x9, ANY, 13}, /* Pentium M (130 nm) */
{X86_VENDOR_INTEL, 0x6, 0xB, ANY, 85}, /* Tualatin */
+ {X86_VENDOR_INTEL, 0x6, 0xD, ANY, 13}, /* Pentium M (90 nm) */
{X86_VENDOR_INTEL, 0x6, ANY, ANY, 82}, /* any P6 */
{X86_VENDOR_INTEL, 0x7, ANY, ANY, 0}, /* Itanium */
{X86_VENDOR_INTEL, 0xF, 0x0, ANY, 90}, /* P4 */
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index dddd3eb9b38..106fa01cdb6 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -17,6 +17,7 @@
#include <linux/idr.h>
#include <linux/hwmon.h>
#include <linux/gfp.h>
+#include <linux/spinlock.h>
#define HWMON_ID_PREFIX "hwmon"
#define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
@@ -24,6 +25,7 @@
static struct class *hwmon_class;
static DEFINE_IDR(hwmon_idr);
+static DEFINE_SPINLOCK(idr_lock);
/**
* hwmon_device_register - register w/ hwmon sysfs class
@@ -37,20 +39,30 @@ static DEFINE_IDR(hwmon_idr);
struct class_device *hwmon_device_register(struct device *dev)
{
struct class_device *cdev;
- int id;
+ int id, err;
- if (idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0)
+again:
+ if (unlikely(idr_pre_get(&hwmon_idr, GFP_KERNEL) == 0))
return ERR_PTR(-ENOMEM);
- if (idr_get_new(&hwmon_idr, NULL, &id) < 0)
- return ERR_PTR(-ENOMEM);
+ spin_lock(&idr_lock);
+ err = idr_get_new(&hwmon_idr, NULL, &id);
+ spin_unlock(&idr_lock);
+
+ if (unlikely(err == -EAGAIN))
+ goto again;
+ else if (unlikely(err))
+ return ERR_PTR(err);
id = id & MAX_ID_MASK;
cdev = class_device_create(hwmon_class, NULL, MKDEV(0,0), dev,
HWMON_ID_FORMAT, id);
- if (IS_ERR(cdev))
+ if (IS_ERR(cdev)) {
+ spin_lock(&idr_lock);
idr_remove(&hwmon_idr, id);
+ spin_unlock(&idr_lock);
+ }
return cdev;
}
@@ -64,9 +76,11 @@ void hwmon_device_unregister(struct class_device *cdev)
{
int id;
- if (sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1) {
+ if (likely(sscanf(cdev->class_id, HWMON_ID_FORMAT, &id) == 1)) {
class_device_unregister(cdev);
+ spin_lock(&idr_lock);
idr_remove(&hwmon_idr, id);
+ spin_unlock(&idr_lock);
} else
dev_dbg(cdev->dev,
"hwmon_device_unregister() failed: bad class ID!\n");
diff --git a/drivers/hwmon/it87.c b/drivers/hwmon/it87.c
index d7a9401600b..06df92b3ee4 100644
--- a/drivers/hwmon/it87.c
+++ b/drivers/hwmon/it87.c
@@ -41,6 +41,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
@@ -194,10 +195,10 @@ static int DIV_TO_REG(int val)
struct it87_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -224,9 +225,8 @@ static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
static int it87_detach_client(struct i2c_client *client);
-static int it87_read_value(struct i2c_client *client, u8 register);
-static int it87_write_value(struct i2c_client *client, u8 register,
- u8 value);
+static int it87_read_value(struct i2c_client *client, u8 reg);
+static int it87_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct it87_data *it87_update_device(struct device *dev);
static int it87_check_pwm(struct i2c_client *client);
static void it87_init_client(struct i2c_client *client, struct it87_data *data);
@@ -290,11 +290,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MIN(nr),
data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
@@ -307,11 +307,11 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
it87_write_value(client, IT87_REG_VIN_MAX(nr),
data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -381,10 +381,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_HIGH(nr), data->temp_high[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -397,10 +397,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val);
it87_write_value(client, IT87_REG_TEMP_LOW(nr), data->temp_low[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_offset(offset) \
@@ -440,7 +440,7 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->sensor &= ~(1 << nr);
data->sensor &= ~(8 << nr);
@@ -450,11 +450,11 @@ static ssize_t set_sensor(struct device *dev, struct device_attribute *attr,
else if (val == 2)
data->sensor |= 8 << nr;
else if (val != 0) {
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
it87_write_value(client, IT87_REG_TEMP_ENABLE, data->sensor);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_sensor_offset(offset) \
@@ -524,7 +524,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
int val = simple_strtol(buf, NULL, 10);
u8 reg = it87_read_value(client, IT87_REG_FAN_DIV);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (nr) {
case 0: data->fan_div[nr] = reg & 0x07; break;
case 1: data->fan_div[nr] = (reg >> 3) & 0x07; break;
@@ -533,7 +533,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
it87_write_value(client, IT87_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
@@ -548,7 +548,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
int i, min[3];
u8 old;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
old = it87_read_value(client, IT87_REG_FAN_DIV);
for (i = 0; i < 3; i++)
@@ -576,7 +576,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
data->fan_min[i]=FAN_TO_REG(min[i], DIV_FROM_REG(data->fan_div[i]));
it87_write_value(client, IT87_REG_FAN_MIN(i), data->fan_min[i]);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_pwm_enable(struct device *dev,
@@ -589,7 +589,7 @@ static ssize_t set_pwm_enable(struct device *dev,
struct it87_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (val == 0) {
int tmp;
@@ -606,11 +606,11 @@ static ssize_t set_pwm_enable(struct device *dev,
/* set saved pwm value, clear FAN_CTLX PWM mode bit */
it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
} else {
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
@@ -626,11 +626,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
if (val < 0 || val > 255)
return -EINVAL;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->manual_pwm_ctl[nr] = val;
if (data->fan_main_ctrl & (1 << nr))
it87_write_value(client, IT87_REG_PWM(nr), PWM_TO_REG(data->manual_pwm_ctl[nr]));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -776,7 +776,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
new_client = &data->client;
if (is_isa)
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
@@ -823,7 +823,7 @@ static int it87_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -950,10 +950,10 @@ static int it87_read_value(struct i2c_client *client, u8 reg)
int res;
if (i2c_is_isa_client(client)) {
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
res = inb_p(client->addr + IT87_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
} else
return i2c_smbus_read_byte_data(client, reg);
@@ -969,10 +969,10 @@ static int it87_write_value(struct i2c_client *client, u8 reg, u8 value)
struct it87_data *data = i2c_get_clientdata(client);
if (i2c_is_isa_client(client)) {
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + IT87_ADDR_REG_OFFSET);
outb_p(value, client->addr + IT87_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
} else
return i2c_smbus_write_byte_data(client, reg, value);
@@ -1098,7 +1098,7 @@ static struct it87_data *it87_update_device(struct device *dev)
struct it87_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -1160,7 +1160,7 @@ static struct it87_data *it87_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm63.c b/drivers/hwmon/lm63.c
index 6b1aa7ef552..071f0fc6ade 100644
--- a/drivers/hwmon/lm63.c
+++ b/drivers/hwmon/lm63.c
@@ -45,6 +45,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -153,7 +154,7 @@ static struct i2c_driver lm63_driver = {
struct lm63_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -192,13 +193,13 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *dummy,
struct lm63_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan[1] = FAN_TO_REG(val);
i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_LSB,
data->fan[1] & 0xFF);
i2c_smbus_write_byte_data(client, LM63_REG_TACH_LIMIT_MSB,
data->fan[1] >> 8);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -222,12 +223,12 @@ static ssize_t set_pwm1(struct device *dev, struct device_attribute *dummy,
return -EPERM;
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm1_value = val <= 0 ? 0 :
val >= 255 ? 2 * data->pwm1_freq :
(val * data->pwm1_freq * 2 + 127) / 255;
i2c_smbus_write_byte_data(client, LM63_REG_PWM_VALUE, data->pwm1_value);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -253,10 +254,10 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *dummy,
struct lm63_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp8[1] = TEMP8_TO_REG(val);
i2c_smbus_write_byte_data(client, LM63_REG_LOCAL_HIGH, data->temp8[1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -284,13 +285,13 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp11[nr] = TEMP11_TO_REG(val);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2],
data->temp11[nr] >> 8);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
data->temp11[nr] & 0xff);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -314,11 +315,11 @@ static ssize_t set_temp2_crit_hyst(struct device *dev, struct device_attribute *
long val = simple_strtol(buf, NULL, 10);
long hyst;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
hyst = TEMP8_FROM_REG(data->temp8[2]) - val;
i2c_smbus_write_byte_data(client, LM63_REG_REMOTE_TCRIT_HYST,
HYST_TO_REG(hyst));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -427,7 +428,7 @@ static int lm63_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, "lm63", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -530,7 +531,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm63_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
if (data->config & 0x04) { /* tachometer enabled */
@@ -582,7 +583,7 @@ static struct lm63_data *lm63_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm75.c b/drivers/hwmon/lm75.c
index 74ca2c8c61c..fc25b90ec24 100644
--- a/drivers/hwmon/lm75.c
+++ b/drivers/hwmon/lm75.c
@@ -25,6 +25,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include "lm75.h"
@@ -47,7 +48,7 @@ I2C_CLIENT_INSMOD_1(lm75);
struct lm75_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
u16 temp_input; /* Register values */
@@ -91,10 +92,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm75_data *data = i2c_get_clientdata(client); \
int temp = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = LM75_TEMP_TO_REG(temp); \
lm75_write_value(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
set(temp_max, LM75_REG_TEMP_OS);
@@ -188,7 +189,7 @@ static int lm75_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -264,7 +265,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm75_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -277,7 +278,7 @@ static struct lm75_data *lm75_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c
index df9e02aaa70..459cc977380 100644
--- a/drivers/hwmon/lm77.c
+++ b/drivers/hwmon/lm77.c
@@ -32,6 +32,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, I2C_CLIENT_END };
@@ -51,7 +52,7 @@ I2C_CLIENT_INSMOD_1(lm77);
struct lm77_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid;
unsigned long last_updated; /* In jiffies */
int temp_input; /* Temperatures */
@@ -139,10 +140,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm77_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = val; \
lm77_write_value(client, reg, LM77_TEMP_TO_REG(data->value)); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -157,11 +158,11 @@ static ssize_t set_temp_crit_hyst(struct device *dev, struct device_attribute *a
struct lm77_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_hyst = data->temp_crit - val;
lm77_write_value(client, LM77_REG_TEMP_HYST,
LM77_TEMP_TO_REG(data->temp_hyst));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -173,7 +174,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
long val = simple_strtoul(buf, NULL, 10);
int oldcrithyst;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
oldcrithyst = data->temp_crit - data->temp_hyst;
data->temp_crit = val;
data->temp_hyst = data->temp_crit - oldcrithyst;
@@ -181,7 +182,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr,
LM77_TEMP_TO_REG(data->temp_crit));
lm77_write_value(client, LM77_REG_TEMP_HYST,
LM77_TEMP_TO_REG(data->temp_hyst));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -306,7 +307,7 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -380,7 +381,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm77_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -406,7 +407,7 @@ static struct lm77_data *lm77_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm78.c b/drivers/hwmon/lm78.c
index e404001e20d..94be3d797e6 100644
--- a/drivers/hwmon/lm78.c
+++ b/drivers/hwmon/lm78.c
@@ -27,6 +27,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
/* Addresses to scan */
@@ -131,10 +132,10 @@ static inline int TEMP_FROM_REG(s8 val)
struct lm78_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -157,8 +158,8 @@ static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
static int lm78_detach_client(struct i2c_client *client);
-static int lm78_read_value(struct i2c_client *client, u8 register);
-static int lm78_write_value(struct i2c_client *client, u8 register, u8 value);
+static int lm78_read_value(struct i2c_client *client, u8 reg);
+static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct lm78_data *lm78_update_device(struct device *dev);
static void lm78_init_client(struct i2c_client *client);
@@ -207,10 +208,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
lm78_write_value(client, LM78_REG_IN_MIN(nr), data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -221,10 +222,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
lm78_write_value(client, LM78_REG_IN_MAX(nr), data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -288,10 +289,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
struct lm78_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_over = TEMP_TO_REG(val);
lm78_write_value(client, LM78_REG_TEMP_OVER, data->temp_over);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -307,10 +308,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
struct lm78_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_hyst = TEMP_TO_REG(val);
lm78_write_value(client, LM78_REG_TEMP_HYST, data->temp_hyst);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -342,10 +343,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct lm78_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -368,7 +369,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long min;
u8 reg;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
@@ -380,7 +381,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -398,7 +399,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] =
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
lm78_write_value(client, LM78_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -548,7 +549,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
new_client = &data->client;
if (is_isa)
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
@@ -598,7 +599,7 @@ static int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -697,10 +698,10 @@ static int lm78_read_value(struct i2c_client *client, u8 reg)
int res;
if (i2c_is_isa_client(client)) {
struct lm78_data *data = i2c_get_clientdata(client);
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
res = inb_p(client->addr + LM78_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
} else
return i2c_smbus_read_byte_data(client, reg);
@@ -717,10 +718,10 @@ static int lm78_write_value(struct i2c_client *client, u8 reg, u8 value)
{
if (i2c_is_isa_client(client)) {
struct lm78_data *data = i2c_get_clientdata(client);
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + LM78_ADDR_REG_OFFSET);
outb_p(value, client->addr + LM78_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
} else
return i2c_smbus_write_byte_data(client, reg, value);
@@ -742,7 +743,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
struct lm78_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -786,7 +787,7 @@ static struct lm78_data *lm78_update_device(struct device *dev)
data->fan_div[2] = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
index c9a7cdea7bd..f72120d08c4 100644
--- a/drivers/hwmon/lm80.c
+++ b/drivers/hwmon/lm80.c
@@ -28,6 +28,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c,
@@ -108,7 +109,7 @@ static inline long TEMP_FROM_REG(u16 temp)
struct lm80_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -191,10 +192,10 @@ static ssize_t set_in_##suffix(struct device *dev, struct device_attribute *attr
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock);\
+ mutex_lock(&data->update_lock);\
data->value = IN_TO_REG(val); \
lm80_write_value(client, reg, data->value); \
- up(&data->update_lock);\
+ mutex_unlock(&data->update_lock);\
return count; \
}
set_in(min0, in_min[0], LM80_REG_IN_MIN(0));
@@ -241,10 +242,10 @@ static ssize_t set_fan_##suffix(struct device *dev, struct device_attribute *att
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock);\
+ mutex_lock(&data->update_lock);\
data->value = FAN_TO_REG(val, DIV_FROM_REG(data->div)); \
lm80_write_value(client, reg, data->value); \
- up(&data->update_lock);\
+ mutex_unlock(&data->update_lock);\
return count; \
}
set_fan(min1, fan_min[0], LM80_REG_FAN_MIN(1), fan_div[0]);
@@ -263,7 +264,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
u8 reg;
/* Save fan_min */
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
@@ -275,7 +276,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -286,7 +287,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
/* Restore fan_min */
data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
lm80_write_value(client, LM80_REG_FAN_MIN(nr + 1), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -325,10 +326,10 @@ static ssize_t set_temp_##suffix(struct device *dev, struct device_attribute *at
struct lm80_data *data = i2c_get_clientdata(client); \
long val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = TEMP_LIMIT_TO_REG(val); \
lm80_write_value(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
set_temp(hot_max, temp_hot_max, LM80_REG_TEMP_HOT_MAX);
@@ -437,7 +438,7 @@ static int lm80_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global list */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -545,7 +546,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
struct lm80_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + 2 * HZ) || !data->valid) {
dev_dbg(&client->dev, "Starting lm80 update\n");
@@ -585,7 +586,7 @@ static struct lm80_data *lm80_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm83.c b/drivers/hwmon/lm83.c
index 26dfa9e216c..aac4ec2bf69 100644
--- a/drivers/hwmon/lm83.c
+++ b/drivers/hwmon/lm83.c
@@ -35,6 +35,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -139,7 +140,7 @@ static struct i2c_driver lm83_driver = {
struct lm83_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -171,11 +172,11 @@ static ssize_t set_temp(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp[nr] = TEMP_TO_REG(val);
i2c_smbus_write_byte_data(client, LM83_REG_W_HIGH[nr - 4],
data->temp[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -300,7 +301,7 @@ static int lm83_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -373,7 +374,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm83_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
int nr;
@@ -393,7 +394,7 @@ static struct lm83_data *lm83_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c
index 7389a012754..342e9663119 100644
--- a/drivers/hwmon/lm85.c
+++ b/drivers/hwmon/lm85.c
@@ -31,6 +31,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
@@ -331,10 +332,10 @@ struct lm85_autofan {
struct lm85_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
int valid; /* !=0 if following fields are valid */
unsigned long last_reading; /* In jiffies */
unsigned long last_config; /* In jiffies */
@@ -373,8 +374,8 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
int kind);
static int lm85_detach_client(struct i2c_client *client);
-static int lm85_read_value(struct i2c_client *client, u8 register);
-static int lm85_write_value(struct i2c_client *client, u8 register, int value);
+static int lm85_read_value(struct i2c_client *client, u8 reg);
+static int lm85_write_value(struct i2c_client *client, u8 reg, int value);
static struct lm85_data *lm85_update_device(struct device *dev);
static void lm85_init_client(struct i2c_client *client);
@@ -407,10 +408,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val);
lm85_write_value(client, LM85_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -499,10 +500,10 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[nr] = PWM_TO_REG(val);
lm85_write_value(client, LM85_REG_PWM(nr), data->pwm[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_enable(struct device *dev, char *buf, int nr)
@@ -559,10 +560,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = INS_TO_REG(nr, val);
lm85_write_value(client, LM85_REG_IN_MIN(nr), data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_in_max(struct device *dev, char *buf, int nr)
@@ -577,10 +578,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = INS_TO_REG(nr, val);
lm85_write_value(client, LM85_REG_IN_MAX(nr), data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_in_reg(offset) \
@@ -640,10 +641,10 @@ static ssize_t set_temp_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[nr] = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_TEMP_MIN(nr), data->temp_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_max(struct device *dev, char *buf, int nr)
@@ -658,10 +659,10 @@ static ssize_t set_temp_max(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[nr] = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_TEMP_MAX(nr), data->temp_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_reg(offset) \
@@ -713,12 +714,12 @@ static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
| ZONE_TO_REG(val) ;
lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
data->autofan[nr].config);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
@@ -733,11 +734,11 @@ static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->autofan[nr].min_pwm = PWM_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
data->autofan[nr].min_pwm);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
@@ -752,7 +753,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->autofan[nr].min_off = val;
lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
| data->syncpwm3
@@ -760,7 +761,7 @@ static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
| (data->autofan[1].min_off ? 0x40 : 0)
| (data->autofan[2].min_off ? 0x80 : 0)
);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
@@ -775,13 +776,13 @@ static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->autofan[nr].freq = FREQ_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
(data->zone[nr].range << 4)
| data->autofan[nr].freq
);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define pwm_auto(offset) \
@@ -857,7 +858,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
int min;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = TEMP_FROM_REG(data->zone[nr].limit);
data->zone[nr].off_desired = TEMP_TO_REG(val);
data->zone[nr].hyst = HYST_TO_REG(min - val);
@@ -871,7 +872,7 @@ static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
(data->zone[2].hyst << 4)
);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
@@ -886,7 +887,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->zone[nr].limit = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
data->zone[nr].limit);
@@ -913,7 +914,7 @@ static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
(data->zone[2].hyst << 4)
);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
@@ -930,7 +931,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
int min;
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = TEMP_FROM_REG(data->zone[nr].limit);
data->zone[nr].max_desired = TEMP_TO_REG(val);
data->zone[nr].range = RANGE_TO_REG(
@@ -938,7 +939,7 @@ static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
((data->zone[nr].range & 0x0f) << 4)
| (data->autofan[nr].freq & 0x07));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
@@ -953,11 +954,11 @@ static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
struct lm85_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->zone[nr].critical = TEMP_TO_REG(val);
lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
data->zone[nr].critical);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define temp_auto(offset) \
@@ -1149,7 +1150,7 @@ static int lm85_detect(struct i2c_adapter *adapter, int address,
/* Fill in the remaining client fields */
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -1368,7 +1369,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
struct lm85_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ( !data->valid ||
time_after(jiffies, data->last_reading + LM85_DATA_INTERVAL) ) {
@@ -1571,7 +1572,7 @@ static struct lm85_data *lm85_update_device(struct device *dev)
data->valid = 1;
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c
index 6ba34c302d8..e229daf666d 100644
--- a/drivers/hwmon/lm87.c
+++ b/drivers/hwmon/lm87.c
@@ -60,6 +60,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -176,7 +177,7 @@ static struct i2c_driver lm87_driver = {
struct lm87_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -253,11 +254,11 @@ static void set_in_min(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val, data->in_scale[nr]);
lm87_write_value(client, nr<6 ? LM87_REG_IN_MIN(nr) :
LM87_REG_AIN_MIN(nr-6), data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
static void set_in_max(struct device *dev, const char *buf, int nr)
@@ -266,11 +267,11 @@ static void set_in_max(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val, data->in_scale[nr]);
lm87_write_value(client, nr<6 ? LM87_REG_IN_MAX(nr) :
LM87_REG_AIN_MAX(nr-6), data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
#define set_in(offset) \
@@ -327,10 +328,10 @@ static void set_temp_low(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_low[nr] = TEMP_TO_REG(val);
lm87_write_value(client, LM87_REG_TEMP_LOW[nr], data->temp_low[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
static void set_temp_high(struct device *dev, const char *buf, int nr)
@@ -339,10 +340,10 @@ static void set_temp_high(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_high[nr] = TEMP_TO_REG(val);
lm87_write_value(client, LM87_REG_TEMP_HIGH[nr], data->temp_high[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
#define set_temp(offset) \
@@ -411,11 +412,11 @@ static void set_fan_min(struct device *dev, const char *buf, int nr)
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val,
FAN_DIV_FROM_REG(data->fan_div[nr]));
lm87_write_value(client, LM87_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
/* Note: we save and restore the fan minimum here, because its value is
@@ -431,7 +432,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long min;
u8 reg;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
FAN_DIV_FROM_REG(data->fan_div[nr]));
@@ -441,7 +442,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
case 4: data->fan_div[nr] = 2; break;
case 8: data->fan_div[nr] = 3; break;
default:
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -459,7 +460,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] = FAN_TO_REG(min, val);
lm87_write_value(client, LM87_REG_FAN_MIN(nr),
data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -522,10 +523,10 @@ static ssize_t set_aout(struct device *dev, struct device_attribute *attr, const
struct lm87_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->aout = AOUT_TO_REG(val);
lm87_write_value(client, LM87_REG_AOUT, data->aout);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static DEVICE_ATTR(aout_output, S_IRUGO | S_IWUSR, show_aout, set_aout);
@@ -589,7 +590,7 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, "lm87", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -744,7 +745,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm87_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
int i, j;
@@ -813,7 +814,7 @@ static struct lm87_data *lm87_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c
index 5679464447c..d9eeaf7585b 100644
--- a/drivers/hwmon/lm90.c
+++ b/drivers/hwmon/lm90.c
@@ -78,6 +78,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/*
* Addresses to scan
@@ -201,7 +202,7 @@ static struct i2c_driver lm90_driver = {
struct lm90_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
int kind;
@@ -247,13 +248,13 @@ static ssize_t set_temp8(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (data->kind == adt7461)
data->temp8[nr] = TEMP1_TO_REG_ADT7461(val);
else
data->temp8[nr] = TEMP1_TO_REG(val);
i2c_smbus_write_byte_data(client, reg[nr - 1], data->temp8[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -281,7 +282,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
long val = simple_strtol(buf, NULL, 10);
int nr = attr->index;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (data->kind == adt7461)
data->temp11[nr] = TEMP2_TO_REG_ADT7461(val);
else
@@ -290,7 +291,7 @@ static ssize_t set_temp11(struct device *dev, struct device_attribute *devattr,
data->temp11[nr] >> 8);
i2c_smbus_write_byte_data(client, reg[(nr - 1) * 2 + 1],
data->temp11[nr] & 0xff);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -311,11 +312,11 @@ static ssize_t set_temphyst(struct device *dev, struct device_attribute *dummy,
long val = simple_strtol(buf, NULL, 10);
long hyst;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
hyst = TEMP1_FROM_REG(data->temp8[3]) - val;
i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST,
HYST_TO_REG(hyst));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -558,7 +559,7 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind)
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
data->kind = kind;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -646,7 +647,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm90_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
u8 oldh, newh, l;
@@ -692,7 +693,7 @@ static struct lm90_data *lm90_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/lm92.c b/drivers/hwmon/lm92.c
index b0c4cb730a7..197f77226dc 100644
--- a/drivers/hwmon/lm92.c
+++ b/drivers/hwmon/lm92.c
@@ -46,6 +46,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* The LM92 and MAX6635 have 2 two-state pins for address selection,
resulting in 4 possible addresses. */
@@ -96,7 +97,7 @@ static struct i2c_driver lm92_driver;
struct lm92_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -114,7 +115,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct lm92_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ)
|| !data->valid) {
@@ -134,7 +135,7 @@ static struct lm92_data *lm92_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -158,10 +159,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct lm92_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_word_data(client, reg, swab16(data->value)); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
set_temp(temp1_crit, LM92_REG_TEMP_CRIT);
@@ -194,11 +195,11 @@ static ssize_t set_temp1_crit_hyst(struct device *dev, struct device_attribute *
struct lm92_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp1_hyst = TEMP_FROM_REG(data->temp1_crit) - val;
i2c_smbus_write_word_data(client, LM92_REG_TEMP_HYST,
swab16(TEMP_TO_REG(data->temp1_hyst)));
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -348,7 +349,7 @@ static int lm92_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the i2c subsystem a new client has arrived */
if ((err = i2c_attach_client(new_client)))
diff --git a/drivers/hwmon/max1619.c b/drivers/hwmon/max1619.c
index 3abe330b22c..b4135b5971f 100644
--- a/drivers/hwmon/max1619.c
+++ b/drivers/hwmon/max1619.c
@@ -33,6 +33,7 @@
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/err.h>
+#include <linux/mutex.h>
static unsigned short normal_i2c[] = { 0x18, 0x19, 0x1a,
0x29, 0x2a, 0x2b,
@@ -104,7 +105,7 @@ static struct i2c_driver max1619_driver = {
struct max1619_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -141,10 +142,10 @@ static ssize_t set_##value(struct device *dev, struct device_attribute *attr, co
struct max1619_data *data = i2c_get_clientdata(client); \
long val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->value = TEMP_TO_REG(val); \
i2c_smbus_write_byte_data(client, reg, data->value); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
@@ -262,7 +263,7 @@ static int max1619_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields */
strlcpy(new_client->name, name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -330,7 +331,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct max1619_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
dev_dbg(&client->dev, "Updating max1619 data.\n");
@@ -353,7 +354,7 @@ static struct max1619_data *max1619_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index f161e88e3bb..ae05e483a77 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -43,6 +43,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
static u8 devid;
@@ -183,8 +184,8 @@ static inline u8 PWM_TO_REG(int val, int inv)
struct pc87360_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
- struct semaphore update_lock;
+ struct mutex lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -283,7 +284,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
struct pc87360_data *data = i2c_get_clientdata(client);
long fan_min = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
fan_min = FAN_TO_REG(fan_min, FAN_DIV_FROM_REG(data->fan_status[attr->index]));
/* If it wouldn't fit, change clock divisor */
@@ -300,23 +301,31 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
/* Write new divider, preserve alarm bits */
pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_FAN_STATUS(attr->index),
data->fan_status[attr->index] & 0xF9);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define show_and_set_fan(offset) \
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
- show_fan_input, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
- show_fan_min, set_fan_min, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
- show_fan_div, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
- show_fan_status, NULL, offset-1);
-show_and_set_fan(1)
-show_and_set_fan(2)
-show_and_set_fan(3)
+static struct sensor_device_attribute fan_input[] = {
+ SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0),
+ SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1),
+ SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2),
+};
+static struct sensor_device_attribute fan_status[] = {
+ SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0),
+ SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1),
+ SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2),
+};
+static struct sensor_device_attribute fan_div[] = {
+ SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0),
+ SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1),
+ SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2),
+};
+static struct sensor_device_attribute fan_min[] = {
+ SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0),
+ SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1),
+ SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
+};
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
{
@@ -335,21 +344,20 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[attr->index] = PWM_TO_REG(val,
FAN_CONFIG_INVERT(data->fan_conf, attr->index));
pc87360_write_value(data, LD_FAN, NO_BANK, PC87360_REG_PWM(attr->index),
data->pwm[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define show_and_set_pwm(offset) \
-static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
- show_pwm, set_pwm, offset-1);
-show_and_set_pwm(1)
-show_and_set_pwm(2)
-show_and_set_pwm(3)
+static struct sensor_device_attribute pwm[] = {
+ SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0),
+ SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1),
+ SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
+};
static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
{
@@ -386,11 +394,11 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *devattr,
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MIN,
data->in_min[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -401,35 +409,67 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[attr->index] = IN_TO_REG(val,
data->in_vref);
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_IN_MAX,
data->in_max[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define show_and_set_in(offset) \
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
- show_in_input, NULL, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
- show_in_min, set_in_min, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
- show_in_max, set_in_max, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \
- show_in_status, NULL, offset);
-show_and_set_in(0)
-show_and_set_in(1)
-show_and_set_in(2)
-show_and_set_in(3)
-show_and_set_in(4)
-show_and_set_in(5)
-show_and_set_in(6)
-show_and_set_in(7)
-show_and_set_in(8)
-show_and_set_in(9)
-show_and_set_in(10)
+static struct sensor_device_attribute in_input[] = {
+ SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0),
+ SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1),
+ SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2),
+ SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3),
+ SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4),
+ SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5),
+ SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6),
+ SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7),
+ SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8),
+ SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9),
+ SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10),
+};
+static struct sensor_device_attribute in_status[] = {
+ SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0),
+ SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1),
+ SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2),
+ SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3),
+ SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4),
+ SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5),
+ SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6),
+ SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7),
+ SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8),
+ SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9),
+ SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10),
+};
+static struct sensor_device_attribute in_min[] = {
+ SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0),
+ SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1),
+ SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2),
+ SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3),
+ SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4),
+ SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5),
+ SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6),
+ SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7),
+ SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8),
+ SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9),
+ SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10),
+};
+static struct sensor_device_attribute in_max[] = {
+ SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0),
+ SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1),
+ SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2),
+ SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3),
+ SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4),
+ SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5),
+ SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6),
+ SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7),
+ SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8),
+ SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9),
+ SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
+};
static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
{
@@ -473,11 +513,11 @@ static ssize_t set_therm_min(struct device *dev, struct device_attribute *devatt
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[attr->index] = IN_TO_REG(val, data->in_vref);
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MIN,
data->in_min[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_therm_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -488,11 +528,11 @@ static ssize_t set_therm_max(struct device *dev, struct device_attribute *devatt
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[attr->index] = IN_TO_REG(val, data->in_vref);
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_MAX,
data->in_max[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -503,28 +543,51 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_crit[attr->index-11] = IN_TO_REG(val, data->in_vref);
pc87360_write_value(data, LD_IN, attr->index, PC87365_REG_TEMP_CRIT,
data->in_crit[attr->index-11]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define show_and_set_therm(offset) \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
- show_therm_input, NULL, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
- show_therm_min, set_therm_min, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
- show_therm_max, set_therm_max, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
- show_therm_crit, set_therm_crit, 11+offset-4); \
-static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
- show_therm_status, NULL, 11+offset-4);
-show_and_set_therm(4)
-show_and_set_therm(5)
-show_and_set_therm(6)
+/* the +11 term below reflects the fact that VLM units 11,12,13 are
+ used in the chip to measure voltage across the thermistors
+*/
+static struct sensor_device_attribute therm_input[] = {
+ SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11),
+ SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11),
+ SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11),
+};
+static struct sensor_device_attribute therm_status[] = {
+ SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11),
+ SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11),
+ SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11),
+};
+static struct sensor_device_attribute therm_min[] = {
+ SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR,
+ show_therm_min, set_therm_min, 0+11),
+ SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR,
+ show_therm_min, set_therm_min, 1+11),
+ SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR,
+ show_therm_min, set_therm_min, 2+11),
+};
+static struct sensor_device_attribute therm_max[] = {
+ SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR,
+ show_therm_max, set_therm_max, 0+11),
+ SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR,
+ show_therm_max, set_therm_max, 1+11),
+ SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR,
+ show_therm_max, set_therm_max, 2+11),
+};
+static struct sensor_device_attribute therm_crit[] = {
+ SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
+ show_therm_crit, set_therm_crit, 0+11),
+ SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR,
+ show_therm_crit, set_therm_crit, 1+11),
+ SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR,
+ show_therm_crit, set_therm_crit, 2+11),
+};
static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -592,11 +655,11 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *devattr
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[attr->index] = TEMP_TO_REG(val);
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MIN,
data->temp_min[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -607,11 +670,11 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *devattr
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[attr->index] = TEMP_TO_REG(val);
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_MAX,
data->temp_max[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devattr, const char *buf,
@@ -622,28 +685,48 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt
struct pc87360_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_crit[attr->index] = TEMP_TO_REG(val);
pc87360_write_value(data, LD_TEMP, attr->index, PC87365_REG_TEMP_CRIT,
data->temp_crit[attr->index]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define show_and_set_temp(offset) \
-static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
- show_temp_input, NULL, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
- show_temp_min, set_temp_min, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
- show_temp_max, set_temp_max, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
- show_temp_crit, set_temp_crit, offset-1); \
-static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
- show_temp_status, NULL, offset-1);
-show_and_set_temp(1)
-show_and_set_temp(2)
-show_and_set_temp(3)
+static struct sensor_device_attribute temp_input[] = {
+ SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0),
+ SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1),
+ SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2),
+};
+static struct sensor_device_attribute temp_status[] = {
+ SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0),
+ SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1),
+ SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2),
+};
+static struct sensor_device_attribute temp_min[] = {
+ SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR,
+ show_temp_min, set_temp_min, 0),
+ SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR,
+ show_temp_min, set_temp_min, 1),
+ SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR,
+ show_temp_min, set_temp_min, 2),
+};
+static struct sensor_device_attribute temp_max[] = {
+ SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 0),
+ SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 1),
+ SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
+ show_temp_max, set_temp_max, 2),
+};
+static struct sensor_device_attribute temp_crit[] = {
+ SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
+ show_temp_crit, set_temp_crit, 0),
+ SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR,
+ show_temp_crit, set_temp_crit, 1),
+ SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR,
+ show_temp_crit, set_temp_crit, 2),
+};
static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -749,22 +832,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses
static int pc87360_detect(struct i2c_adapter *adapter)
{
int i;
- struct i2c_client *new_client;
+ struct i2c_client *client;
struct pc87360_data *data;
int err = 0;
const char *name = "pc87360";
int use_thermistors = 0;
+ struct device *dev;
if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
return -ENOMEM;
- new_client = &data->client;
- i2c_set_clientdata(new_client, data);
- new_client->addr = address;
- init_MUTEX(&data->lock);
- new_client->adapter = adapter;
- new_client->driver = &pc87360_driver;
- new_client->flags = 0;
+ client = &data->client;
+ dev = &client->dev;
+ i2c_set_clientdata(client, data);
+ client->addr = address;
+ mutex_init(&data->lock);
+ client->adapter = adapter;
+ client->driver = &pc87360_driver;
+ client->flags = 0;
data->fannr = 2;
data->innr = 0;
@@ -792,15 +877,15 @@ static int pc87360_detect(struct i2c_adapter *adapter)
break;
}
- strcpy(new_client->name, name);
+ strlcpy(client->name, name, sizeof(client->name));
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
for (i = 0; i < 3; i++) {
if (((data->address[i] = extra_isa[i]))
&& !request_region(extra_isa[i], PC87360_EXTENT,
pc87360_driver.driver.name)) {
- dev_err(&new_client->dev, "Region 0x%x-0x%x already "
+ dev_err(&client->dev, "Region 0x%x-0x%x already "
"in use!\n", extra_isa[i],
extra_isa[i]+PC87360_EXTENT-1);
for (i--; i >= 0; i--)
@@ -814,7 +899,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
if (data->fannr)
data->fan_conf = confreg[0] | (confreg[1] << 8);
- if ((err = i2c_attach_client(new_client)))
+ if ((err = i2c_attach_client(client)))
goto ERROR2;
/* Use the correct reference voltage
@@ -828,7 +913,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
PC87365_REG_TEMP_CONFIG);
}
data->in_vref = (i&0x02) ? 3025 : 2966;
- dev_dbg(&new_client->dev, "Using %s reference voltage\n",
+ dev_dbg(&client->dev, "Using %s reference voltage\n",
(i&0x02) ? "external" : "internal");
data->vid_conf = confreg[3];
@@ -847,154 +932,64 @@ static int pc87360_detect(struct i2c_adapter *adapter)
if (devid == 0xe9 && data->address[1]) /* PC87366 */
use_thermistors = confreg[2] & 0x40;
- pc87360_init_client(new_client, use_thermistors);
+ pc87360_init_client(client, use_thermistors);
}
/* Register sysfs hooks */
- data->class_dev = hwmon_device_register(&new_client->dev);
+ data->class_dev = hwmon_device_register(&client->dev);
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto ERROR3;
}
if (data->innr) {
- device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr);
-
- device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
- device_create_file(&new_client->dev, &dev_attr_vrm);
- device_create_file(&new_client->dev, &dev_attr_alarms_in);
+ for (i = 0; i < 11; i++) {
+ device_create_file(dev, &in_input[i].dev_attr);
+ device_create_file(dev, &in_min[i].dev_attr);
+ device_create_file(dev, &in_max[i].dev_attr);
+ device_create_file(dev, &in_status[i].dev_attr);
+ }
+ device_create_file(dev, &dev_attr_cpu0_vid);
+ device_create_file(dev, &dev_attr_vrm);
+ device_create_file(dev, &dev_attr_alarms_in);
}
if (data->tempnr) {
- device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr);
-
- device_create_file(&new_client->dev, &dev_attr_alarms_temp);
- }
- if (data->tempnr == 3) {
- device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr);
- }
- if (data->innr == 14) {
- device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr);
- device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr);
- }
-
- if (data->fannr) {
- if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) {
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan1_input.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan1_min.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan1_div.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan1_status.dev_attr);
+ for (i = 0; i < data->tempnr; i++) {
+ device_create_file(dev, &temp_input[i].dev_attr);
+ device_create_file(dev, &temp_min[i].dev_attr);
+ device_create_file(dev, &temp_max[i].dev_attr);
+ device_create_file(dev, &temp_crit[i].dev_attr);
+ device_create_file(dev, &temp_status[i].dev_attr);
}
+ device_create_file(dev, &dev_attr_alarms_temp);
+ }
- if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) {
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan2_input.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan2_min.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan2_div.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan2_status.dev_attr);
+ if (data->innr == 14) {
+ for (i = 0; i < 3; i++) {
+ device_create_file(dev, &therm_input[i].dev_attr);
+ device_create_file(dev, &therm_min[i].dev_attr);
+ device_create_file(dev, &therm_max[i].dev_attr);
+ device_create_file(dev, &therm_crit[i].dev_attr);
+ device_create_file(dev, &therm_status[i].dev_attr);
}
-
- if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
- device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
- if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
- device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
}
- if (data->fannr == 3) {
- if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) {
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan3_input.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan3_min.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan3_div.dev_attr);
- device_create_file(&new_client->dev,
- &sensor_dev_attr_fan3_status.dev_attr);
- }
- if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
- device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
+ for (i = 0; i < data->fannr; i++) {
+ if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
+ device_create_file(dev, &fan_input[i].dev_attr);
+ device_create_file(dev, &fan_min[i].dev_attr);
+ device_create_file(dev, &fan_div[i].dev_attr);
+ device_create_file(dev, &fan_status[i].dev_attr);
+ }
+ if (FAN_CONFIG_CONTROL(data->fan_conf, i))
+ device_create_file(dev, &pwm[i].dev_attr);
}
return 0;
ERROR3:
- i2c_detach_client(new_client);
+ i2c_detach_client(client);
ERROR2:
for (i = 0; i < 3; i++) {
if (data->address[i]) {
@@ -1033,11 +1028,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
{
int res;
- down(&(data->lock));
+ mutex_lock(&(data->lock));
if (bank != NO_BANK)
outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
res = inb_p(data->address[ldi] + reg);
- up(&(data->lock));
+ mutex_unlock(&(data->lock));
return res;
}
@@ -1045,11 +1040,11 @@ static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
static void pc87360_write_value(struct pc87360_data *data, u8 ldi, u8 bank,
u8 reg, u8 value)
{
- down(&(data->lock));
+ mutex_lock(&(data->lock));
if (bank != NO_BANK)
outb_p(bank, data->address[ldi] + PC87365_REG_BANK);
outb_p(value, data->address[ldi] + reg);
- up(&(data->lock));
+ mutex_unlock(&(data->lock));
}
static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
@@ -1071,7 +1066,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
}
nr = data->innr < 11 ? data->innr : 11;
- for (i=0; i<nr; i++) {
+ for (i = 0; i < nr; i++) {
if (init >= init_in[i]) {
/* Forcibly enable voltage channel */
reg = pc87360_read_value(data, LD_IN, i,
@@ -1088,14 +1083,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
/* We can't blindly trust the Super-I/O space configuration bit,
most BIOS won't set it properly */
- for (i=11; i<data->innr; i++) {
+ for (i = 11; i < data->innr; i++) {
reg = pc87360_read_value(data, LD_IN, i,
PC87365_REG_TEMP_STATUS);
use_thermistors = use_thermistors || (reg & 0x01);
}
i = use_thermistors ? 2 : 0;
- for (; i<data->tempnr; i++) {
+ for (; i < data->tempnr; i++) {
if (init >= init_temp[i]) {
/* Forcibly enable temperature channel */
reg = pc87360_read_value(data, LD_TEMP, i,
@@ -1111,7 +1106,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
}
if (use_thermistors) {
- for (i=11; i<data->innr; i++) {
+ for (i = 11; i < data->innr; i++) {
if (init >= init_in[i]) {
/* The pin may already be used by thermal
diodes */
@@ -1221,7 +1216,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
struct pc87360_data *data = i2c_get_clientdata(client);
u8 i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ * 2) || !data->valid) {
dev_dbg(&client->dev, "Data update\n");
@@ -1321,7 +1316,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/sis5595.c b/drivers/hwmon/sis5595.c
index 8be5189d9bd..6f3fda73f70 100644
--- a/drivers/hwmon/sis5595.c
+++ b/drivers/hwmon/sis5595.c
@@ -60,6 +60,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/jiffies.h>
+#include <linux/mutex.h>
#include <asm/io.h>
@@ -167,9 +168,9 @@ static inline u8 DIV_TO_REG(int val)
struct sis5595_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
char maxins; /* == 3 if temp enabled, otherwise == 4 */
@@ -192,8 +193,8 @@ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
static int sis5595_detect(struct i2c_adapter *adapter);
static int sis5595_detach_client(struct i2c_client *client);
-static int sis5595_read_value(struct i2c_client *client, u8 register);
-static int sis5595_write_value(struct i2c_client *client, u8 register, u8 value);
+static int sis5595_read_value(struct i2c_client *client, u8 reg);
+static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value);
static struct sis5595_data *sis5595_update_device(struct device *dev);
static void sis5595_init_client(struct i2c_client *client);
@@ -231,10 +232,10 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_IN_MIN(nr), data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -245,10 +246,10 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_IN_MAX(nr), data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -310,10 +311,10 @@ static ssize_t set_temp_over(struct device *dev, struct device_attribute *attr,
struct sis5595_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_over = TEMP_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_TEMP_OVER, data->temp_over);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -329,10 +330,10 @@ static ssize_t set_temp_hyst(struct device *dev, struct device_attribute *attr,
struct sis5595_data *data = i2c_get_clientdata(client);
long val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_hyst = TEMP_TO_REG(val);
sis5595_write_value(client, SIS5595_REG_TEMP_HYST, data->temp_hyst);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -364,10 +365,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct sis5595_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -390,7 +391,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
unsigned long val = simple_strtoul(buf, NULL, 10);
int reg;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
reg = sis5595_read_value(client, SIS5595_REG_FANDIV);
@@ -403,7 +404,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
default:
dev_err(&client->dev, "fan_div value %ld not "
"supported. Choose one of 1, 2, 4 or 8!\n", val);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -419,7 +420,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_min[nr] =
FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
sis5595_write_value(client, SIS5595_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -527,7 +528,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
new_client = &data->client;
new_client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
i2c_set_clientdata(new_client, data);
new_client->adapter = adapter;
new_client->driver = &sis5595_driver;
@@ -548,7 +549,7 @@ static int sis5595_detect(struct i2c_adapter *adapter)
strlcpy(new_client->name, "sis5595", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -635,20 +636,20 @@ static int sis5595_read_value(struct i2c_client *client, u8 reg)
int res;
struct sis5595_data *data = i2c_get_clientdata(client);
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
res = inb_p(client->addr + SIS5595_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
static int sis5595_write_value(struct i2c_client *client, u8 reg, u8 value)
{
struct sis5595_data *data = i2c_get_clientdata(client);
- down(&data->lock);
+ mutex_lock(&data->lock);
outb_p(reg, client->addr + SIS5595_ADDR_REG_OFFSET);
outb_p(value, client->addr + SIS5595_DATA_REG_OFFSET);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
}
@@ -667,7 +668,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
struct sis5595_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -707,7 +708,7 @@ static struct sis5595_data *sis5595_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c
index 8663bbbe97f..b6086186d22 100644
--- a/drivers/hwmon/smsc47b397.c
+++ b/drivers/hwmon/smsc47b397.c
@@ -35,6 +35,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
+#include <linux/mutex.h>
#include <asm/io.h>
/* Address is autodetected, there is no default value */
@@ -92,9 +93,9 @@ static u8 smsc47b397_reg_temp[] = {0x25, 0x26, 0x27, 0x80};
struct smsc47b397_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
- struct semaphore update_lock;
+ struct mutex update_lock;
unsigned long last_updated; /* in jiffies */
int valid;
@@ -108,10 +109,10 @@ static int smsc47b397_read_value(struct i2c_client *client, u8 reg)
struct smsc47b397_data *data = i2c_get_clientdata(client);
int res;
- down(&data->lock);
+ mutex_lock(&data->lock);
outb(reg, client->addr);
res = inb_p(client->addr + 1);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
@@ -121,7 +122,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
struct smsc47b397_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ) || !data->valid) {
dev_dbg(&client->dev, "starting device update...\n");
@@ -144,7 +145,7 @@ static struct smsc47b397_data *smsc47b397_update_device(struct device *dev)
dev_dbg(&client->dev, "... device update complete\n");
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -254,14 +255,14 @@ static int smsc47b397_detect(struct i2c_adapter *adapter)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = &smsc47b397_driver;
new_client->flags = 0;
strlcpy(new_client->name, "smsc47b397", I2C_NAME_SIZE);
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
if ((err = i2c_attach_client(new_client)))
goto error_free;
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index d1e3ec0fe4d..7732aec5459 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -34,6 +34,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
+#include <linux/mutex.h>
#include <asm/io.h>
/* Address is autodetected, there is no default value */
@@ -102,9 +103,9 @@ superio_exit(void)
struct smsc47m1_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
- struct semaphore update_lock;
+ struct mutex update_lock;
unsigned long last_updated; /* In jiffies */
u8 fan[2]; /* Register value */
@@ -188,18 +189,18 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct smsc47m1_data *data = i2c_get_clientdata(client);
long rpmdiv, val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
rpmdiv = val * DIV_FROM_REG(data->fan_div[nr]);
if (983040 > 192 * rpmdiv || 2 * rpmdiv > 983040) {
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
data->fan_preload[nr] = 192 - ((983040 + rpmdiv / 2) / rpmdiv);
smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
data->fan_preload[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -220,14 +221,14 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
if (new_div == old_div) /* No change */
return count;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (new_div) {
case 1: data->fan_div[nr] = 0; break;
case 2: data->fan_div[nr] = 1; break;
case 4: data->fan_div[nr] = 2; break;
case 8: data->fan_div[nr] = 3; break;
default:
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -241,7 +242,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
data->fan_preload[nr] = SENSORS_LIMIT(tmp, 0, 191);
smsc47m1_write_value(client, SMSC47M1_REG_FAN_PRELOAD(nr),
data->fan_preload[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -257,12 +258,12 @@ static ssize_t set_pwm(struct device *dev, const char *buf,
if (val < 0 || val > 255)
return -EINVAL;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[nr] &= 0x81; /* Preserve additional bits */
data->pwm[nr] |= PWM_TO_REG(val);
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
data->pwm[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -278,12 +279,12 @@ static ssize_t set_pwm_en(struct device *dev, const char *buf,
if (val != 0 && val != 1)
return -EINVAL;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[nr] &= 0xFE; /* preserve the other bits */
data->pwm[nr] |= !val;
smsc47m1_write_value(client, SMSC47M1_REG_PWM(nr),
data->pwm[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -408,13 +409,13 @@ static int smsc47m1_detect(struct i2c_adapter *adapter)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = &smsc47m1_driver;
new_client->flags = 0;
strlcpy(new_client->name, "smsc47m1", I2C_NAME_SIZE);
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* If no function is properly configured, there's no point in
actually registering the chip. */
@@ -512,17 +513,17 @@ static int smsc47m1_read_value(struct i2c_client *client, u8 reg)
{
int res;
- down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
+ mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
res = inb_p(client->addr + reg);
- up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
+ mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
return res;
}
static void smsc47m1_write_value(struct i2c_client *client, u8 reg, u8 value)
{
- down(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
+ mutex_lock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
outb_p(value, client->addr + reg);
- up(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
+ mutex_unlock(&((struct smsc47m1_data *) i2c_get_clientdata(client))->lock);
}
static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
@@ -531,7 +532,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
struct i2c_client *client = to_i2c_client(dev);
struct smsc47m1_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2) || init) {
int i;
@@ -558,7 +559,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
data->last_updated = jiffies;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index cb01848729b..166298f1f19 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -39,6 +39,7 @@
#include <linux/hwmon.h>
#include <linux/err.h>
#include <linux/init.h>
+#include <linux/mutex.h>
#include <asm/io.h>
@@ -296,7 +297,7 @@ static inline long TEMP_FROM_REG10(u16 val)
struct via686a_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -355,11 +356,11 @@ static ssize_t set_in_min(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MIN(nr),
data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_in_max(struct device *dev, const char *buf,
@@ -368,11 +369,11 @@ static ssize_t set_in_max(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = IN_TO_REG(val, nr);
via686a_write_value(client, VIA686A_REG_IN_MAX(nr),
data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_in_offset(offset) \
@@ -432,11 +433,11 @@ static ssize_t set_temp_over(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_over[nr] = TEMP_TO_REG(val);
via686a_write_value(client, VIA686A_REG_TEMP_OVER[nr],
data->temp_over[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_hyst(struct device *dev, const char *buf,
@@ -445,11 +446,11 @@ static ssize_t set_temp_hyst(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_hyst[nr] = TEMP_TO_REG(val);
via686a_write_value(client, VIA686A_REG_TEMP_HYST[nr],
data->temp_hyst[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
#define show_temp_offset(offset) \
@@ -508,10 +509,10 @@ static ssize_t set_fan_min(struct device *dev, const char *buf,
struct via686a_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
via686a_write_value(client, VIA686A_REG_FAN_MIN(nr+1), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_fan_div(struct device *dev, const char *buf,
@@ -521,12 +522,12 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
int val = simple_strtol(buf, NULL, 10);
int old;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
old = via686a_read_value(client, VIA686A_REG_FANDIV);
data->fan_div[nr] = DIV_TO_REG(val);
old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
via686a_write_value(client, VIA686A_REG_FANDIV, old);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -639,7 +640,7 @@ static int via686a_detect(struct i2c_adapter *adapter)
strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
goto exit_free;
@@ -733,7 +734,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
struct via686a_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -788,7 +789,7 @@ static struct via686a_data *via686a_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c
index 271e9cb9532..686f3deb309 100644
--- a/drivers/hwmon/vt8231.c
+++ b/drivers/hwmon/vt8231.c
@@ -35,6 +35,7 @@
#include <linux/hwmon-sysfs.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
static int force_addr;
@@ -148,7 +149,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
struct vt8231_data {
struct i2c_client client;
- struct semaphore update_lock;
+ struct mutex update_lock;
struct class_device *class_dev;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -223,10 +224,10 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
vt8231_write_value(client, regvoltmin[nr], data->in_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -239,10 +240,10 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255);
vt8231_write_value(client, regvoltmax[nr], data->in_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -281,11 +282,11 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
0, 255);
vt8231_write_value(client, regvoltmin[5], data->in_min[5]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -296,11 +297,11 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3,
0, 255);
vt8231_write_value(client, regvoltmax[5], data->in_max[5]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -351,10 +352,10 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
vt8231_write_value(client, regtempmax[0], data->temp_max[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
@@ -364,10 +365,10 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255);
vt8231_write_value(client, regtempmin[0], data->temp_min[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -407,10 +408,10 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
vt8231_write_value(client, regtempmax[nr], data->temp_max[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
@@ -422,10 +423,10 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
int val = simple_strtol(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255);
vt8231_write_value(client, regtempmin[nr], data->temp_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -520,10 +521,10 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
struct vt8231_data *data = i2c_get_clientdata(client);
int val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr]));
vt8231_write_value(client, VT8231_REG_FAN_MIN(nr), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -539,7 +540,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
long min = FAN_FROM_REG(data->fan_min[nr],
DIV_FROM_REG(data->fan_div[nr]));
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (val) {
case 1: data->fan_div[nr] = 0; break;
case 2: data->fan_div[nr] = 1; break;
@@ -548,7 +549,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
default:
dev_err(&client->dev, "fan_div value %ld not supported."
"Choose one of 1, 2, 4 or 8!\n", val);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
@@ -558,7 +559,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
old = (old & 0x0f) | (data->fan_div[1] << 6) | (data->fan_div[0] << 4);
vt8231_write_value(client, VT8231_REG_FANDIV, old);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -660,7 +661,7 @@ int vt8231_detect(struct i2c_adapter *adapter)
/* Fill in the remaining client fields and put into the global list */
strlcpy(client->name, "vt8231", I2C_NAME_SIZE);
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(client)))
@@ -745,7 +746,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
int i;
u16 low;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -804,7 +805,7 @@ static struct vt8231_data *vt8231_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c
index 12d79f5e490..b6bd5685fd3 100644
--- a/drivers/hwmon/w83627ehf.c
+++ b/drivers/hwmon/w83627ehf.c
@@ -42,7 +42,9 @@
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include "lm75.h"
@@ -177,9 +179,9 @@ temp1_to_reg(int temp)
struct w83627ehf_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -230,7 +232,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)
struct w83627ehf_data *data = i2c_get_clientdata(client);
int res, word_sized = is_word_sized(reg);
- down(&data->lock);
+ mutex_lock(&data->lock);
w83627ehf_set_bank(client, reg);
outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
@@ -242,7 +244,7 @@ static u16 w83627ehf_read_value(struct i2c_client *client, u16 reg)
}
w83627ehf_reset_bank(client, reg);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
@@ -252,7 +254,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)
struct w83627ehf_data *data = i2c_get_clientdata(client);
int word_sized = is_word_sized(reg);
- down(&data->lock);
+ mutex_lock(&data->lock);
w83627ehf_set_bank(client, reg);
outb_p(reg & 0xff, client->addr + ADDR_REG_OFFSET);
@@ -264,7 +266,7 @@ static int w83627ehf_write_value(struct i2c_client *client, u16 reg, u16 value)
outb_p(value & 0xff, client->addr + DATA_REG_OFFSET);
w83627ehf_reset_bank(client, reg);
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
}
@@ -322,7 +324,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
struct w83627ehf_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ)
|| !data->valid) {
@@ -397,7 +399,7 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
@@ -407,9 +409,12 @@ static struct w83627ehf_data *w83627ehf_update_device(struct device *dev)
#define show_fan_reg(reg) \
static ssize_t \
-show_##reg(struct device *dev, char *buf, int nr) \
+show_##reg(struct device *dev, struct device_attribute *attr, \
+ char *buf) \
{ \
struct w83627ehf_data *data = w83627ehf_update_device(dev); \
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+ int nr = sensor_attr->index; \
return sprintf(buf, "%d\n", \
fan_from_reg(data->reg[nr], \
div_from_reg(data->fan_div[nr]))); \
@@ -418,23 +423,28 @@ show_fan_reg(fan);
show_fan_reg(fan_min);
static ssize_t
-show_fan_div(struct device *dev, char *buf, int nr)
+show_fan_div(struct device *dev, struct device_attribute *attr,
+ char *buf)
{
struct w83627ehf_data *data = w83627ehf_update_device(dev);
- return sprintf(buf, "%u\n",
- div_from_reg(data->fan_div[nr]));
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+ int nr = sensor_attr->index;
+ return sprintf(buf, "%u\n", div_from_reg(data->fan_div[nr]));
}
static ssize_t
-store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
+store_fan_min(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
{
struct i2c_client *client = to_i2c_client(dev);
struct w83627ehf_data *data = i2c_get_clientdata(client);
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
+ int nr = sensor_attr->index;
unsigned int val = simple_strtoul(buf, NULL, 10);
unsigned int reg;
u8 new_div;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (!val) {
/* No min limit, alarm disabled */
data->fan_min[nr] = 255;
@@ -482,63 +492,46 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
}
w83627ehf_write_value(client, W83627EHF_REG_FAN_MIN[nr],
data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
-#define sysfs_fan_offset(offset) \
-static ssize_t \
-show_reg_fan_##offset(struct device *dev, struct device_attribute *attr, \
- char *buf) \
-{ \
- return show_fan(dev, buf, offset-1); \
-} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
- show_reg_fan_##offset, NULL);
+static struct sensor_device_attribute sda_fan_input[] = {
+ SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0),
+ SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1),
+ SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2),
+ SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3),
+ SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 4),
+};
-#define sysfs_fan_min_offset(offset) \
-static ssize_t \
-show_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \
- char *buf) \
-{ \
- return show_fan_min(dev, buf, offset-1); \
-} \
-static ssize_t \
-store_reg_fan##offset##_min(struct device *dev, struct device_attribute *attr, \
- const char *buf, size_t count) \
-{ \
- return store_fan_min(dev, buf, count, offset-1); \
-} \
-static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_reg_fan##offset##_min, \
- store_reg_fan##offset##_min);
+static struct sensor_device_attribute sda_fan_min[] = {
+ SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min,
+ store_fan_min, 0),
+ SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min,
+ store_fan_min, 1),
+ SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min,
+ store_fan_min, 2),
+ SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min,
+ store_fan_min, 3),
+ SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min,
+ store_fan_min, 4),
+};
-#define sysfs_fan_div_offset(offset) \
-static ssize_t \
-show_reg_fan##offset##_div(struct device *dev, struct device_attribute *attr, \
- char *buf) \
-{ \
- return show_fan_div(dev, buf, offset - 1); \
-} \
-static DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
- show_reg_fan##offset##_div, NULL);
-
-sysfs_fan_offset(1);
-sysfs_fan_min_offset(1);
-sysfs_fan_div_offset(1);
-sysfs_fan_offset(2);
-sysfs_fan_min_offset(2);
-sysfs_fan_div_offset(2);
-sysfs_fan_offset(3);
-sysfs_fan_min_offset(3);
-sysfs_fan_div_offset(3);
-sysfs_fan_offset(4);
-sysfs_fan_min_offset(4);
-sysfs_fan_div_offset(4);
-sysfs_fan_offset(5);
-sysfs_fan_min_offset(5);
-sysfs_fan_div_offset(5);
+static struct sensor_device_attribute sda_fan_div[] = {
+ SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0),
+ SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1),
+ SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2),
+ SENSOR_ATTR(fan4_div, S_IRUGO, show_fan_div, NULL, 3),
+ SENSOR_ATTR(fan5_div, S_IRUGO, show_fan_div, NULL, 4),
+};
+
+static void device_create_file_fan(struct device *dev, int i)
+{
+ device_create_file(dev, &sda_fan_input[i].dev_attr);
+ device_create_file(dev, &sda_fan_div[i].dev_attr);
+ device_create_file(dev, &sda_fan_min[i].dev_attr);
+}
#define show_temp1_reg(reg) \
static ssize_t \
@@ -561,27 +554,24 @@ store_temp1_##reg(struct device *dev, struct device_attribute *attr, \
struct w83627ehf_data *data = i2c_get_clientdata(client); \
u32 val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->temp1_##reg = temp1_to_reg(val); \
w83627ehf_write_value(client, W83627EHF_REG_TEMP1_##REG, \
data->temp1_##reg); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_temp1_reg(OVER, max);
store_temp1_reg(HYST, max_hyst);
-static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL);
-static DEVICE_ATTR(temp1_max, S_IRUGO| S_IWUSR,
- show_temp1_max, store_temp1_max);
-static DEVICE_ATTR(temp1_max_hyst, S_IRUGO| S_IWUSR,
- show_temp1_max_hyst, store_temp1_max_hyst);
-
#define show_temp_reg(reg) \
static ssize_t \
-show_##reg (struct device *dev, char *buf, int nr) \
+show_##reg(struct device *dev, struct device_attribute *attr, \
+ char *buf) \
{ \
struct w83627ehf_data *data = w83627ehf_update_device(dev); \
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+ int nr = sensor_attr->index; \
return sprintf(buf, "%d\n", \
LM75_TEMP_FROM_REG(data->reg[nr])); \
}
@@ -591,55 +581,42 @@ show_temp_reg(temp_max_hyst);
#define store_temp_reg(REG, reg) \
static ssize_t \
-store_##reg (struct device *dev, const char *buf, size_t count, int nr) \
+store_##reg(struct device *dev, struct device_attribute *attr, \
+ const char *buf, size_t count) \
{ \
struct i2c_client *client = to_i2c_client(dev); \
struct w83627ehf_data *data = i2c_get_clientdata(client); \
+ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \
+ int nr = sensor_attr->index; \
u32 val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->reg[nr] = LM75_TEMP_TO_REG(val); \
w83627ehf_write_value(client, W83627EHF_REG_TEMP_##REG[nr], \
data->reg[nr]); \
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_temp_reg(OVER, temp_max);
store_temp_reg(HYST, temp_max_hyst);
-#define sysfs_temp_offset(offset) \
-static ssize_t \
-show_reg_temp##offset (struct device *dev, struct device_attribute *attr, \
- char *buf) \
-{ \
- return show_temp(dev, buf, offset - 2); \
-} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
- show_reg_temp##offset, NULL);
-
-#define sysfs_temp_reg_offset(reg, offset) \
-static ssize_t \
-show_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \
- char *buf) \
-{ \
- return show_temp_##reg(dev, buf, offset - 2); \
-} \
-static ssize_t \
-store_reg_temp##offset##_##reg(struct device *dev, struct device_attribute *attr, \
- const char *buf, size_t count) \
-{ \
- return store_temp_##reg(dev, buf, count, offset - 2); \
-} \
-static DEVICE_ATTR(temp##offset##_##reg, S_IRUGO| S_IWUSR, \
- show_reg_temp##offset##_##reg, \
- store_reg_temp##offset##_##reg);
-
-sysfs_temp_offset(2);
-sysfs_temp_reg_offset(max, 2);
-sysfs_temp_reg_offset(max_hyst, 2);
-sysfs_temp_offset(3);
-sysfs_temp_reg_offset(max, 3);
-sysfs_temp_reg_offset(max_hyst, 3);
+static struct sensor_device_attribute sda_temp[] = {
+ SENSOR_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0),
+ SENSOR_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 0),
+ SENSOR_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 1),
+ SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1_max,
+ store_temp1_max, 0),
+ SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max,
+ store_temp_max, 0),
+ SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max,
+ store_temp_max, 1),
+ SENSOR_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1_max_hyst,
+ store_temp1_max_hyst, 0),
+ SENSOR_ATTR(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst,
+ store_temp_max_hyst, 0),
+ SENSOR_ATTR(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp_max_hyst,
+ store_temp_max_hyst, 1),
+};
/*
* Driver and client management
@@ -673,6 +650,7 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
{
struct i2c_client *client;
struct w83627ehf_data *data;
+ struct device *dev;
int i, err = 0;
if (!request_region(address + REGION_OFFSET, REGION_LENGTH,
@@ -689,14 +667,15 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
client = &data->client;
i2c_set_clientdata(client, data);
client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
client->adapter = adapter;
client->driver = &w83627ehf_driver;
client->flags = 0;
+ dev = &client->dev;
strlcpy(client->name, "w83627ehf", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the i2c layer a new client has arrived */
if ((err = i2c_attach_client(client)))
@@ -720,42 +699,18 @@ static int w83627ehf_detect(struct i2c_adapter *adapter)
data->has_fan |= (1 << 4);
/* Register sysfs hooks */
- data->class_dev = hwmon_device_register(&client->dev);
+ data->class_dev = hwmon_device_register(dev);
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto exit_detach;
}
- device_create_file(&client->dev, &dev_attr_fan1_input);
- device_create_file(&client->dev, &dev_attr_fan1_min);
- device_create_file(&client->dev, &dev_attr_fan1_div);
- device_create_file(&client->dev, &dev_attr_fan2_input);
- device_create_file(&client->dev, &dev_attr_fan2_min);
- device_create_file(&client->dev, &dev_attr_fan2_div);
- device_create_file(&client->dev, &dev_attr_fan3_input);
- device_create_file(&client->dev, &dev_attr_fan3_min);
- device_create_file(&client->dev, &dev_attr_fan3_div);
-
- if (data->has_fan & (1 << 3)) {
- device_create_file(&client->dev, &dev_attr_fan4_input);
- device_create_file(&client->dev, &dev_attr_fan4_min);
- device_create_file(&client->dev, &dev_attr_fan4_div);
- }
- if (data->has_fan & (1 << 4)) {
- device_create_file(&client->dev, &dev_attr_fan5_input);
- device_create_file(&client->dev, &dev_attr_fan5_min);
- device_create_file(&client->dev, &dev_attr_fan5_div);
+ for (i = 0; i < 5; i++) {
+ if (data->has_fan & (1 << i))
+ device_create_file_fan(dev, i);
}
-
- device_create_file(&client->dev, &dev_attr_temp1_input);
- device_create_file(&client->dev, &dev_attr_temp1_max);
- device_create_file(&client->dev, &dev_attr_temp1_max_hyst);
- device_create_file(&client->dev, &dev_attr_temp2_input);
- device_create_file(&client->dev, &dev_attr_temp2_max);
- device_create_file(&client->dev, &dev_attr_temp2_max_hyst);
- device_create_file(&client->dev, &dev_attr_temp3_input);
- device_create_file(&client->dev, &dev_attr_temp3_max);
- device_create_file(&client->dev, &dev_attr_temp3_max_hyst);
+ for (i = 0; i < ARRAY_SIZE(sda_temp); i++)
+ device_create_file(dev, &sda_temp[i].dev_attr);
return 0;
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 7ea441d4da6..71fb7f1af8f 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -28,6 +28,7 @@
w83627hf 9 3 2 3 0x20 0x5ca3 no yes(LPC)
w83627thf 7 3 3 3 0x90 0x5ca3 no yes(LPC)
w83637hf 7 3 3 3 0x80 0x5ca3 no yes(LPC)
+ w83687thf 7 3 3 3 0x90 0x5ca3 no yes(LPC)
w83697hf 8 2 2 2 0x60 0x5ca3 no yes(LPC)
For other winbond chips, and for i2c support in the above chips,
@@ -46,6 +47,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include "lm75.h"
@@ -62,7 +64,7 @@ MODULE_PARM_DESC(force_i2c,
static unsigned short address;
/* Insmod parameters */
-enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf };
+enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf, w83687thf };
static int reset;
module_param(reset, bool, 0);
@@ -100,6 +102,10 @@ static int VAL; /* The value to read/write */
#define W83627THF_GPIO5_IOSR 0xf3 /* w83627thf only */
#define W83627THF_GPIO5_DR 0xf4 /* w83627thf only */
+#define W83687THF_VID_EN 0x29 /* w83687thf only */
+#define W83687THF_VID_CFG 0xF0 /* w83687thf only */
+#define W83687THF_VID_DATA 0xF1 /* w83687thf only */
+
static inline void
superio_outb(int reg, int val)
{
@@ -138,6 +144,7 @@ superio_exit(void)
#define W627THF_DEVID 0x82
#define W697_DEVID 0x60
#define W637_DEVID 0x70
+#define W687THF_DEVID 0x85
#define WINB_ACT_REG 0x30
#define WINB_BASE_REG 0x60
/* Constants specified below */
@@ -201,11 +208,11 @@ superio_exit(void)
#define W83627HF_REG_PWM1 0x5A
#define W83627HF_REG_PWM2 0x5B
-#define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */
-#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */
-#define W83627THF_REG_PWM3 0x11 /* 637HF too */
+#define W83627THF_REG_PWM1 0x01 /* 697HF/637HF/687THF too */
+#define W83627THF_REG_PWM2 0x03 /* 697HF/637HF/687THF too */
+#define W83627THF_REG_PWM3 0x11 /* 637HF/687THF too */
-#define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF too */
+#define W83627THF_REG_VRM_OVT_CFG 0x18 /* 637HF/687THF too */
static const u8 regpwm_627hf[] = { W83627HF_REG_PWM1, W83627HF_REG_PWM2 };
static const u8 regpwm[] = { W83627THF_REG_PWM1, W83627THF_REG_PWM2,
@@ -285,10 +292,10 @@ static inline u8 DIV_TO_REG(long val)
struct w83627hf_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -318,16 +325,15 @@ struct w83627hf_data {
Default = 3435.
Other Betas unimplemented */
u8 vrm;
- u8 vrm_ovt; /* Register value, 627thf & 637hf only */
+ u8 vrm_ovt; /* Register value, 627THF/637HF/687THF only */
};
static int w83627hf_detect(struct i2c_adapter *adapter);
static int w83627hf_detach_client(struct i2c_client *client);
-static int w83627hf_read_value(struct i2c_client *client, u16 register);
-static int w83627hf_write_value(struct i2c_client *client, u16 register,
- u16 value);
+static int w83627hf_read_value(struct i2c_client *client, u16 reg);
+static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value);
static struct w83627hf_data *w83627hf_update_device(struct device *dev);
static void w83627hf_init_client(struct i2c_client *client);
@@ -360,12 +366,12 @@ store_in_##reg (struct device *dev, const char *buf, size_t count, int nr) \
\
val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
w83627hf_write_value(client, W83781D_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
\
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_in_reg(MIN, min)
@@ -413,7 +419,8 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
long in0;
if ((data->vrm_ovt & 0x01) &&
- (w83627thf == data->type || w83637hf == data->type))
+ (w83627thf == data->type || w83637hf == data->type
+ || w83687thf == data->type))
/* use VRM9 calculation */
in0 = (long)((reg * 488 + 70000 + 50) / 100);
@@ -451,10 +458,11 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ((data->vrm_ovt & 0x01) &&
- (w83627thf == data->type || w83637hf == data->type))
+ (w83627thf == data->type || w83637hf == data->type
+ || w83687thf == data->type))
/* use VRM9 calculation */
data->in_min[0] =
@@ -465,7 +473,7 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
data->in_min[0] = IN_TO_REG(val);
w83627hf_write_value(client, W83781D_REG_IN_MIN(0), data->in_min[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -478,10 +486,11 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ((data->vrm_ovt & 0x01) &&
- (w83627thf == data->type || w83637hf == data->type))
+ (w83627thf == data->type || w83637hf == data->type
+ || w83687thf == data->type))
/* use VRM9 calculation */
data->in_max[0] =
@@ -492,7 +501,7 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
data->in_max[0] = IN_TO_REG(val);
w83627hf_write_value(client, W83781D_REG_IN_MAX(0), data->in_max[0]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -529,13 +538,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr - 1] =
FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr),
data->fan_min[nr - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -597,7 +606,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
\
val = simple_strtoul(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
\
if (nr >= 2) { /* TEMP2 and TEMP3 */ \
data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
@@ -609,7 +618,7 @@ store_temp_##reg (struct device *dev, const char *buf, size_t count, int nr) \
data->temp_##reg); \
} \
\
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_temp_reg(OVER, max);
@@ -718,7 +727,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
data->beep_mask = BEEP_MASK_TO_REG(val);
@@ -736,7 +745,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
w83627hf_write_value(client, W83781D_REG_BEEP_INTS2,
val2 | data->beep_enable << 7);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -783,7 +792,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
u8 reg;
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* Save fan_min */
min = FAN_FROM_REG(data->fan_min[nr],
@@ -805,7 +814,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
w83627hf_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -848,7 +857,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (data->type == w83627thf) {
/* bits 0-3 are reserved in 627THF */
@@ -865,7 +874,7 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
data->pwm[nr - 1]);
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -907,7 +916,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (val) {
case 1: /* PII/Celeron diode */
@@ -941,7 +950,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
break;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -980,7 +989,8 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr)
if(val != W627_DEVID &&
val != W627THF_DEVID &&
val != W697_DEVID &&
- val != W637_DEVID) {
+ val != W637_DEVID &&
+ val != W687THF_DEVID) {
superio_exit();
return -ENODEV;
}
@@ -1034,6 +1044,8 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
kind = w83627thf;
else if(val == W637_DEVID)
kind = w83637hf;
+ else if (val == W687THF_DEVID)
+ kind = w83687thf;
else {
dev_info(&adapter->dev,
"Unsupported chip (dev_id=0x%02X).\n", val);
@@ -1057,7 +1069,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = &w83627hf_driver;
new_client->flags = 0;
@@ -1071,13 +1083,15 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
client_name = "w83697hf";
} else if (kind == w83637hf) {
client_name = "w83637hf";
+ } else if (kind == w83687thf) {
+ client_name = "w83687thf";
}
/* Fill in the remaining client fields and put into the global list */
strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -1106,7 +1120,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
device_create_file_in(new_client, 2);
device_create_file_in(new_client, 3);
device_create_file_in(new_client, 4);
- if (kind != w83627thf && kind != w83637hf) {
+ if (kind == w83627hf || kind == w83697hf) {
device_create_file_in(new_client, 5);
device_create_file_in(new_client, 6);
}
@@ -1139,7 +1153,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
device_create_file_pwm(new_client, 1);
device_create_file_pwm(new_client, 2);
- if (kind == w83627thf || kind == w83637hf)
+ if (kind == w83627thf || kind == w83637hf || kind == w83687thf)
device_create_file_pwm(new_client, 3);
device_create_file_sensor(new_client, 1);
@@ -1187,7 +1201,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
struct w83627hf_data *data = i2c_get_clientdata(client);
int res, word_sized;
- down(&data->lock);
+ mutex_lock(&data->lock);
word_sized = (((reg & 0xff00) == 0x100)
|| ((reg & 0xff00) == 0x200))
&& (((reg & 0x00ff) == 0x50)
@@ -1213,7 +1227,7 @@ static int w83627hf_read_value(struct i2c_client *client, u16 reg)
client->addr + W83781D_ADDR_REG_OFFSET);
outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
}
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
@@ -1247,12 +1261,39 @@ exit:
return res;
}
+static int w83687thf_read_vid(struct i2c_client *client)
+{
+ int res = 0xff;
+
+ superio_enter();
+ superio_select(W83627HF_LD_HWM);
+
+ /* Make sure these GPIO pins are enabled */
+ if (!(superio_inb(W83687THF_VID_EN) & (1 << 2))) {
+ dev_dbg(&client->dev, "VID disabled, no VID function\n");
+ goto exit;
+ }
+
+ /* Make sure the pins are configured for input */
+ if (!(superio_inb(W83687THF_VID_CFG) & (1 << 4))) {
+ dev_dbg(&client->dev, "VID configured as output, "
+ "no VID function\n");
+ goto exit;
+ }
+
+ res = superio_inb(W83687THF_VID_DATA) & 0x3f;
+
+exit:
+ superio_exit();
+ return res;
+}
+
static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
{
struct w83627hf_data *data = i2c_get_clientdata(client);
int word_sized;
- down(&data->lock);
+ mutex_lock(&data->lock);
word_sized = (((reg & 0xff00) == 0x100)
|| ((reg & 0xff00) == 0x200))
&& (((reg & 0x00ff) == 0x53)
@@ -1277,7 +1318,7 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
client->addr + W83781D_ADDR_REG_OFFSET);
outb_p(0, client->addr + W83781D_DATA_REG_OFFSET);
}
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
}
@@ -1324,10 +1365,13 @@ static void w83627hf_init_client(struct i2c_client *client)
data->vid = (lo & 0x0f) | ((hi & 0x01) << 4);
} else if (w83627thf == data->type) {
data->vid = w83627thf_read_gpio5(client);
+ } else if (w83687thf == data->type) {
+ data->vid = w83687thf_read_vid(client);
}
/* Read VRM & OVT Config only once */
- if (w83627thf == data->type || w83637hf == data->type) {
+ if (w83627thf == data->type || w83637hf == data->type
+ || w83687thf == data->type) {
data->vrm_ovt =
w83627hf_read_value(client, W83627THF_REG_VRM_OVT_CFG);
}
@@ -1387,14 +1431,14 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
struct w83627hf_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
for (i = 0; i <= 8; i++) {
/* skip missing sensors */
if (((data->type == w83697hf) && (i == 1)) ||
- ((data->type == w83627thf || data->type == w83637hf)
+ ((data->type != w83627hf && data->type != w83697hf)
&& (i == 5 || i == 6)))
continue;
data->in[i] =
@@ -1470,7 +1514,7 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c
index 64c1f8af5bb..e4c700356c4 100644
--- a/drivers/hwmon/w83781d.c
+++ b/drivers/hwmon/w83781d.c
@@ -42,6 +42,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/err.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include "lm75.h"
@@ -56,6 +57,10 @@ I2C_CLIENT_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
I2C_CLIENT_MODULE_PARM(force_subclients, "List of subclient addresses: "
"{bus, clientaddr, subclientaddr1, subclientaddr2}");
+static int reset;
+module_param(reset, bool, 0);
+MODULE_PARM_DESC(reset, "Set to one to reset chip on load");
+
static int init = 1;
module_param(init, bool, 0);
MODULE_PARM_DESC(init, "Set to zero to bypass chip initialization");
@@ -226,10 +231,10 @@ DIV_TO_REG(long val, enum chips type)
struct w83781d_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore lock;
+ struct mutex lock;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -267,9 +272,8 @@ static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter);
static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind);
static int w83781d_detach_client(struct i2c_client *client);
-static int w83781d_read_value(struct i2c_client *client, u16 register);
-static int w83781d_write_value(struct i2c_client *client, u16 register,
- u16 value);
+static int w83781d_read_value(struct i2c_client *client, u16 reg);
+static int w83781d_write_value(struct i2c_client *client, u16 reg, u16 value);
static struct w83781d_data *w83781d_update_device(struct device *dev);
static void w83781d_init_client(struct i2c_client *client);
@@ -311,11 +315,11 @@ static ssize_t store_in_##reg (struct device *dev, const char *buf, size_t count
\
val = simple_strtoul(buf, NULL, 10) / 10; \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
w83781d_write_value(client, W83781D_REG_IN_##REG(nr), data->in_##reg[nr]); \
\
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_in_reg(MIN, min);
@@ -381,13 +385,13 @@ store_fan_min(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->fan_min[nr - 1] =
FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1]));
w83781d_write_value(client, W83781D_REG_FAN_MIN(nr),
data->fan_min[nr - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -446,7 +450,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou
\
val = simple_strtol(buf, NULL, 10); \
\
- down(&data->update_lock); \
+ mutex_lock(&data->update_lock); \
\
if (nr >= 2) { /* TEMP2 and TEMP3 */ \
data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
@@ -458,7 +462,7 @@ static ssize_t store_temp_##reg (struct device *dev, const char *buf, size_t cou
data->temp_##reg); \
} \
\
- up(&data->update_lock); \
+ mutex_unlock(&data->update_lock); \
return count; \
}
store_temp_reg(OVER, max);
@@ -571,7 +575,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (update_mask == BEEP_MASK) { /* We are storing beep_mask */
data->beep_mask = BEEP_MASK_TO_REG(val, data->type);
@@ -592,7 +596,7 @@ store_beep_reg(struct device *dev, const char *buf, size_t count,
w83781d_write_value(client, W83781D_REG_BEEP_INTS2,
val2 | data->beep_enable << 7);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -637,7 +641,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
u8 reg;
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
/* Save fan_min */
min = FAN_FROM_REG(data->fan_min[nr],
@@ -662,7 +666,7 @@ store_fan_div_reg(struct device *dev, const char *buf, size_t count, int nr)
data->fan_min[nr] = FAN_TO_REG(min, DIV_FROM_REG(data->fan_div[nr]));
w83781d_write_value(client, W83781D_REG_FAN_MIN(nr+1), data->fan_min[nr]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -709,10 +713,10 @@ store_pwm_reg(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
data->pwm[nr - 1] = PWM_TO_REG(val);
w83781d_write_value(client, W83781D_REG_PWM(nr), data->pwm[nr - 1]);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -725,7 +729,7 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (val) {
case 0:
@@ -742,11 +746,11 @@ store_pwmenable_reg(struct device *dev, const char *buf, size_t count, int nr)
break;
default:
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return -EINVAL;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -808,7 +812,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
switch (val) {
case 1: /* PII/Celeron diode */
@@ -841,7 +845,7 @@ store_sensor_reg(struct device *dev, const char *buf, size_t count, int nr)
break;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -1073,7 +1077,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
new_client = &data->client;
i2c_set_clientdata(new_client, data);
new_client->addr = address;
- init_MUTEX(&data->lock);
+ mutex_init(&data->lock);
new_client->adapter = adapter;
new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
new_client->flags = 0;
@@ -1178,7 +1182,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -1325,7 +1329,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg)
int res, word_sized, bank;
struct i2c_client *cl;
- down(&data->lock);
+ mutex_lock(&data->lock);
if (i2c_is_isa_client(client)) {
word_sized = (((reg & 0xff00) == 0x100)
|| ((reg & 0xff00) == 0x200))
@@ -1383,7 +1387,7 @@ w83781d_read_value(struct i2c_client *client, u16 reg)
if (bank > 2)
i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0);
}
- up(&data->lock);
+ mutex_unlock(&data->lock);
return res;
}
@@ -1394,7 +1398,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
int word_sized, bank;
struct i2c_client *cl;
- down(&data->lock);
+ mutex_lock(&data->lock);
if (i2c_is_isa_client(client)) {
word_sized = (((reg & 0xff00) == 0x100)
|| ((reg & 0xff00) == 0x200))
@@ -1447,7 +1451,7 @@ w83781d_write_value(struct i2c_client *client, u16 reg, u16 value)
if (bank > 2)
i2c_smbus_write_byte_data(client, W83781D_REG_BANK, 0);
}
- up(&data->lock);
+ mutex_unlock(&data->lock);
return 0;
}
@@ -1459,8 +1463,17 @@ w83781d_init_client(struct i2c_client *client)
int type = data->type;
u8 tmp;
- if (init && type != as99127f) { /* this resets registers we don't have
+ if (reset && type != as99127f) { /* this resets registers we don't have
documentation for on the as99127f */
+ /* Resetting the chip has been the default for a long time,
+ but it causes the BIOS initializations (fan clock dividers,
+ thermal sensor types...) to be lost, so it is now optional.
+ It might even go away if nobody reports it as being useful,
+ as I see very little reason why this would be needed at
+ all. */
+ dev_info(&client->dev, "If reset=1 solved a problem you were "
+ "having, please report!\n");
+
/* save these registers */
i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG);
p = w83781d_read_value(client, W83781D_REG_PWMCLK12);
@@ -1477,6 +1490,13 @@ w83781d_init_client(struct i2c_client *client)
w83781d_write_value(client, W83781D_REG_BEEP_INTS2, 0);
}
+ /* Disable power-on abnormal beep, as advised by the datasheet.
+ Already done if reset=1. */
+ if (init && !reset && type != as99127f) {
+ i = w83781d_read_value(client, W83781D_REG_BEEP_CONFIG);
+ w83781d_write_value(client, W83781D_REG_BEEP_CONFIG, i | 0x80);
+ }
+
data->vrm = vid_which_vrm();
if ((type != w83781d) && (type != as99127f)) {
@@ -1533,7 +1553,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
struct w83781d_data *data = i2c_get_clientdata(client);
int i;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after(jiffies, data->last_updated + HZ + HZ / 2)
|| !data->valid) {
@@ -1641,7 +1661,7 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c
index a2f6bb67623..6865c64d8a5 100644
--- a/drivers/hwmon/w83792d.c
+++ b/drivers/hwmon/w83792d.c
@@ -43,6 +43,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
@@ -271,7 +272,7 @@ struct w83792d_data {
struct class_device *class_dev;
enum chips type;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* !=0 if following fields are valid */
unsigned long last_updated; /* In jiffies */
@@ -382,30 +383,40 @@ static ssize_t store_in_##reg (struct device *dev, \
store_in_reg(MIN, min);
store_in_reg(MAX, max);
-#define sysfs_in_reg(offset) \
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in, \
- NULL, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
- show_in_min, store_in_min, offset); \
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
- show_in_max, store_in_max, offset);
-
-sysfs_in_reg(0);
-sysfs_in_reg(1);
-sysfs_in_reg(2);
-sysfs_in_reg(3);
-sysfs_in_reg(4);
-sysfs_in_reg(5);
-sysfs_in_reg(6);
-sysfs_in_reg(7);
-sysfs_in_reg(8);
-
-#define device_create_file_in(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_in##offset##_input.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_in##offset##_max.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_in##offset##_min.dev_attr); \
-} while (0)
+static struct sensor_device_attribute sda_in_input[] = {
+ SENSOR_ATTR(in0_input, S_IRUGO, show_in, NULL, 0),
+ SENSOR_ATTR(in1_input, S_IRUGO, show_in, NULL, 1),
+ SENSOR_ATTR(in2_input, S_IRUGO, show_in, NULL, 2),
+ SENSOR_ATTR(in3_input, S_IRUGO, show_in, NULL, 3),
+ SENSOR_ATTR(in4_input, S_IRUGO, show_in, NULL, 4),
+ SENSOR_ATTR(in5_input, S_IRUGO, show_in, NULL, 5),
+ SENSOR_ATTR(in6_input, S_IRUGO, show_in, NULL, 6),
+ SENSOR_ATTR(in7_input, S_IRUGO, show_in, NULL, 7),
+ SENSOR_ATTR(in8_input, S_IRUGO, show_in, NULL, 8),
+};
+static struct sensor_device_attribute sda_in_min[] = {
+ SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 0),
+ SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 1),
+ SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 2),
+ SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 3),
+ SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 4),
+ SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 5),
+ SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 6),
+ SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 7),
+ SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, store_in_min, 8),
+};
+static struct sensor_device_attribute sda_in_max[] = {
+ SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 0),
+ SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 1),
+ SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 2),
+ SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 3),
+ SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 4),
+ SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 5),
+ SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 6),
+ SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 7),
+ SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, store_in_max, 8),
+};
+
#define show_fan_reg(reg) \
static ssize_t show_##reg (struct device *dev, struct device_attribute *attr, \
@@ -486,28 +497,33 @@ store_fan_div(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_fan(offset) \
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan, NULL, \
- offset); \
-static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
- show_fan_div, store_fan_div, offset); \
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
- show_fan_min, store_fan_min, offset);
-
-sysfs_fan(1);
-sysfs_fan(2);
-sysfs_fan(3);
-sysfs_fan(4);
-sysfs_fan(5);
-sysfs_fan(6);
-sysfs_fan(7);
-
-#define device_create_file_fan(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_input.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_div.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_fan##offset##_min.dev_attr); \
-} while (0)
+static struct sensor_device_attribute sda_fan_input[] = {
+ SENSOR_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 1),
+ SENSOR_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 2),
+ SENSOR_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 3),
+ SENSOR_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 4),
+ SENSOR_ATTR(fan5_input, S_IRUGO, show_fan, NULL, 5),
+ SENSOR_ATTR(fan6_input, S_IRUGO, show_fan, NULL, 6),
+ SENSOR_ATTR(fan7_input, S_IRUGO, show_fan, NULL, 7),
+};
+static struct sensor_device_attribute sda_fan_min[] = {
+ SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 1),
+ SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 2),
+ SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 3),
+ SENSOR_ATTR(fan4_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 4),
+ SENSOR_ATTR(fan5_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 5),
+ SENSOR_ATTR(fan6_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 6),
+ SENSOR_ATTR(fan7_min, S_IWUSR | S_IRUGO, show_fan_min, store_fan_min, 7),
+};
+static struct sensor_device_attribute sda_fan_div[] = {
+ SENSOR_ATTR(fan1_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 1),
+ SENSOR_ATTR(fan2_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 2),
+ SENSOR_ATTR(fan3_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 3),
+ SENSOR_ATTR(fan4_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 4),
+ SENSOR_ATTR(fan5_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 5),
+ SENSOR_ATTR(fan6_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 6),
+ SENSOR_ATTR(fan7_div, S_IWUSR | S_IRUGO, show_fan_div, store_fan_div, 7),
+};
/* read/write the temperature1, includes measured value and limits */
@@ -539,21 +555,6 @@ static ssize_t store_temp1(struct device *dev, struct device_attribute *attr,
return count;
}
-
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp1, NULL, 0);
-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp1,
- store_temp1, 1);
-static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1,
- store_temp1, 2);
-
-#define device_create_file_temp1(client) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_temp1_input.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_temp1_max.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_temp1_max_hyst.dev_attr); \
-} while (0)
-
-
/* read/write the temperature2-3, includes measured value and limits */
static ssize_t show_temp23(struct device *dev, struct device_attribute *attr,
@@ -590,25 +591,23 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_temp23(name,idx) \
-static SENSOR_DEVICE_ATTR_2(name##_input, S_IRUGO, show_temp23, NULL, \
- idx, 0); \
-static SENSOR_DEVICE_ATTR_2(name##_max, S_IRUGO | S_IWUSR, \
- show_temp23, store_temp23, idx, 2); \
-static SENSOR_DEVICE_ATTR_2(name##_max_hyst, S_IRUGO | S_IWUSR, \
- show_temp23, store_temp23, idx, 4);
-
-sysfs_temp23(temp2,0)
-sysfs_temp23(temp3,1)
+static struct sensor_device_attribute_2 sda_temp_input[] = {
+ SENSOR_ATTR_2(temp1_input, S_IRUGO, show_temp1, NULL, 0, 0),
+ SENSOR_ATTR_2(temp2_input, S_IRUGO, show_temp23, NULL, 0, 0),
+ SENSOR_ATTR_2(temp3_input, S_IRUGO, show_temp23, NULL, 1, 0),
+};
-#define device_create_file_temp_add(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_input.dev_attr); \
-device_create_file(&client->dev, &sensor_dev_attr_temp##offset##_max.dev_attr); \
-device_create_file(&client->dev, \
-&sensor_dev_attr_temp##offset##_max_hyst.dev_attr); \
-} while (0)
+static struct sensor_device_attribute_2 sda_temp_max[] = {
+ SENSOR_ATTR_2(temp1_max, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 1),
+ SENSOR_ATTR_2(temp2_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 2),
+ SENSOR_ATTR_2(temp3_max, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 2),
+};
+static struct sensor_device_attribute_2 sda_temp_max_hyst[] = {
+ SENSOR_ATTR_2(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp1, store_temp1, 0, 2),
+ SENSOR_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4),
+ SENSOR_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4),
+};
/* get reatime status of all sensors items: voltage, temp, fan */
static ssize_t
@@ -620,10 +619,6 @@ show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf)
static
DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL);
-#define device_create_file_alarms(client) \
-device_create_file(&client->dev, &dev_attr_alarms);
-
-
static ssize_t
show_pwm(struct device *dev, struct device_attribute *attr,
@@ -711,26 +706,19 @@ store_pwmenable(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_pwm(offset) \
-static SENSOR_DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
- show_pwm, store_pwm, offset); \
-static SENSOR_DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
- show_pwmenable, store_pwmenable, offset); \
-
-sysfs_pwm(1);
-sysfs_pwm(2);
-sysfs_pwm(3);
-
-
-#define device_create_file_pwm(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_pwm##offset.dev_attr); \
-} while (0)
-
-#define device_create_file_pwmenable(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_enable.dev_attr); \
-} while (0)
+static struct sensor_device_attribute sda_pwm[] = {
+ SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1),
+ SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2),
+ SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 3),
+};
+static struct sensor_device_attribute sda_pwm_enable[] = {
+ SENSOR_ATTR(pwm1_enable, S_IWUSR | S_IRUGO,
+ show_pwmenable, store_pwmenable, 1),
+ SENSOR_ATTR(pwm2_enable, S_IWUSR | S_IRUGO,
+ show_pwmenable, store_pwmenable, 2),
+ SENSOR_ATTR(pwm3_enable, S_IWUSR | S_IRUGO,
+ show_pwmenable, store_pwmenable, 3),
+};
static ssize_t
@@ -764,18 +752,14 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_pwm_mode(offset) \
-static SENSOR_DEVICE_ATTR(pwm##offset##_mode, S_IRUGO | S_IWUSR, \
- show_pwm_mode, store_pwm_mode, offset);
-
-sysfs_pwm_mode(1);
-sysfs_pwm_mode(2);
-sysfs_pwm_mode(3);
-
-#define device_create_file_pwm_mode(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_pwm##offset##_mode.dev_attr); \
-} while (0)
+static struct sensor_device_attribute sda_pwm_mode[] = {
+ SENSOR_ATTR(pwm1_mode, S_IWUSR | S_IRUGO,
+ show_pwm_mode, store_pwm_mode, 1),
+ SENSOR_ATTR(pwm2_mode, S_IWUSR | S_IRUGO,
+ show_pwm_mode, store_pwm_mode, 2),
+ SENSOR_ATTR(pwm3_mode, S_IWUSR | S_IRUGO,
+ show_pwm_mode, store_pwm_mode, 3),
+};
static ssize_t
@@ -788,12 +772,6 @@ show_regs_chassis(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(chassis, S_IRUGO, show_regs_chassis, NULL);
-#define device_create_file_chassis(client) \
-do { \
-device_create_file(&client->dev, &dev_attr_chassis); \
-} while (0)
-
-
static ssize_t
show_chassis_clear(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -824,13 +802,6 @@ store_chassis_clear(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR(chassis_clear, S_IRUGO | S_IWUSR,
show_chassis_clear, store_chassis_clear);
-#define device_create_file_chassis_clear(client) \
-do { \
-device_create_file(&client->dev, &dev_attr_chassis_clear); \
-} while (0)
-
-
-
/* For Smart Fan I / Thermal Cruise */
static ssize_t
show_thermal_cruise(struct device *dev, struct device_attribute *attr,
@@ -864,20 +835,14 @@ store_thermal_cruise(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_thermal_cruise(offset) \
-static SENSOR_DEVICE_ATTR(thermal_cruise##offset, S_IRUGO | S_IWUSR, \
- show_thermal_cruise, store_thermal_cruise, offset);
-
-sysfs_thermal_cruise(1);
-sysfs_thermal_cruise(2);
-sysfs_thermal_cruise(3);
-
-#define device_create_file_thermal_cruise(client, offset) \
-do { \
-device_create_file(&client->dev, \
-&sensor_dev_attr_thermal_cruise##offset.dev_attr); \
-} while (0)
-
+static struct sensor_device_attribute sda_thermal_cruise[] = {
+ SENSOR_ATTR(thermal_cruise1, S_IWUSR | S_IRUGO,
+ show_thermal_cruise, store_thermal_cruise, 1),
+ SENSOR_ATTR(thermal_cruise2, S_IWUSR | S_IRUGO,
+ show_thermal_cruise, store_thermal_cruise, 2),
+ SENSOR_ATTR(thermal_cruise3, S_IWUSR | S_IRUGO,
+ show_thermal_cruise, store_thermal_cruise, 3),
+};
/* For Smart Fan I/Thermal Cruise and Smart Fan II */
static ssize_t
@@ -916,19 +881,14 @@ store_tolerance(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_tolerance(offset) \
-static SENSOR_DEVICE_ATTR(tolerance##offset, S_IRUGO | S_IWUSR, \
- show_tolerance, store_tolerance, offset);
-
-sysfs_tolerance(1);
-sysfs_tolerance(2);
-sysfs_tolerance(3);
-
-#define device_create_file_tolerance(client, offset) \
-do { \
-device_create_file(&client->dev, &sensor_dev_attr_tolerance##offset.dev_attr); \
-} while (0)
-
+static struct sensor_device_attribute sda_tolerance[] = {
+ SENSOR_ATTR(tolerance1, S_IWUSR | S_IRUGO,
+ show_tolerance, store_tolerance, 1),
+ SENSOR_ATTR(tolerance2, S_IWUSR | S_IRUGO,
+ show_tolerance, store_tolerance, 2),
+ SENSOR_ATTR(tolerance3, S_IWUSR | S_IRUGO,
+ show_tolerance, store_tolerance, 3),
+};
/* For Smart Fan II */
static ssize_t
@@ -964,28 +924,34 @@ store_sf2_point(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_sf2_point(offset, index) \
-static SENSOR_DEVICE_ATTR_2(sf2_point##offset##_fan##index, S_IRUGO | S_IWUSR, \
- show_sf2_point, store_sf2_point, offset, index);
-
-sysfs_sf2_point(1, 1); /* Fan1 */
-sysfs_sf2_point(2, 1); /* Fan1 */
-sysfs_sf2_point(3, 1); /* Fan1 */
-sysfs_sf2_point(4, 1); /* Fan1 */
-sysfs_sf2_point(1, 2); /* Fan2 */
-sysfs_sf2_point(2, 2); /* Fan2 */
-sysfs_sf2_point(3, 2); /* Fan2 */
-sysfs_sf2_point(4, 2); /* Fan2 */
-sysfs_sf2_point(1, 3); /* Fan3 */
-sysfs_sf2_point(2, 3); /* Fan3 */
-sysfs_sf2_point(3, 3); /* Fan3 */
-sysfs_sf2_point(4, 3); /* Fan3 */
-
-#define device_create_file_sf2_point(client, offset, index) \
-do { \
-device_create_file(&client->dev, \
-&sensor_dev_attr_sf2_point##offset##_fan##index.dev_attr); \
-} while (0)
+static struct sensor_device_attribute_2 sda_sf2_point[] = {
+ SENSOR_ATTR_2(sf2_point1_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 1, 1),
+ SENSOR_ATTR_2(sf2_point2_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 2, 1),
+ SENSOR_ATTR_2(sf2_point3_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 3, 1),
+ SENSOR_ATTR_2(sf2_point4_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 4, 1),
+
+ SENSOR_ATTR_2(sf2_point1_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 1, 2),
+ SENSOR_ATTR_2(sf2_point2_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 2, 2),
+ SENSOR_ATTR_2(sf2_point3_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 3, 2),
+ SENSOR_ATTR_2(sf2_point4_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 4, 2),
+
+ SENSOR_ATTR_2(sf2_point1_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 1, 3),
+ SENSOR_ATTR_2(sf2_point2_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 2, 3),
+ SENSOR_ATTR_2(sf2_point3_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 3, 3),
+ SENSOR_ATTR_2(sf2_point4_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_point, store_sf2_point, 4, 3),
+};
static ssize_t
@@ -1026,26 +992,28 @@ store_sf2_level(struct device *dev, struct device_attribute *attr,
return count;
}
-#define sysfs_sf2_level(offset, index) \
-static SENSOR_DEVICE_ATTR_2(sf2_level##offset##_fan##index, S_IRUGO | S_IWUSR, \
- show_sf2_level, store_sf2_level, offset, index);
-
-sysfs_sf2_level(1, 1); /* Fan1 */
-sysfs_sf2_level(2, 1); /* Fan1 */
-sysfs_sf2_level(3, 1); /* Fan1 */
-sysfs_sf2_level(1, 2); /* Fan2 */
-sysfs_sf2_level(2, 2); /* Fan2 */
-sysfs_sf2_level(3, 2); /* Fan2 */
-sysfs_sf2_level(1, 3); /* Fan3 */
-sysfs_sf2_level(2, 3); /* Fan3 */
-sysfs_sf2_level(3, 3); /* Fan3 */
-
-#define device_create_file_sf2_level(client, offset, index) \
-do { \
-device_create_file(&client->dev, \
-&sensor_dev_attr_sf2_level##offset##_fan##index.dev_attr); \
-} while (0)
-
+static struct sensor_device_attribute_2 sda_sf2_level[] = {
+ SENSOR_ATTR_2(sf2_level1_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 1, 1),
+ SENSOR_ATTR_2(sf2_level2_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 2, 1),
+ SENSOR_ATTR_2(sf2_level3_fan1, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 3, 1),
+
+ SENSOR_ATTR_2(sf2_level1_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 1, 2),
+ SENSOR_ATTR_2(sf2_level2_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 2, 2),
+ SENSOR_ATTR_2(sf2_level3_fan2, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 3, 2),
+
+ SENSOR_ATTR_2(sf2_level1_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 1, 3),
+ SENSOR_ATTR_2(sf2_level2_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 2, 3),
+ SENSOR_ATTR_2(sf2_level3_fan3, S_IRUGO | S_IWUSR,
+ show_sf2_level, store_sf2_level, 3, 3),
+};
/* This function is called when:
* w83792d_driver is inserted (when this module is loaded), for each
@@ -1147,12 +1115,19 @@ ERROR_SC_0:
return err;
}
+static void device_create_file_fan(struct device *dev, int i)
+{
+ device_create_file(dev, &sda_fan_input[i].dev_attr);
+ device_create_file(dev, &sda_fan_div[i].dev_attr);
+ device_create_file(dev, &sda_fan_min[i].dev_attr);
+}
static int
w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
{
int i = 0, val1 = 0, val2;
- struct i2c_client *new_client;
+ struct i2c_client *client;
+ struct device *dev;
struct w83792d_data *data;
int err = 0;
const char *client_name = "";
@@ -1170,12 +1145,13 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
goto ERROR0;
}
- new_client = &data->client;
- i2c_set_clientdata(new_client, data);
- new_client->addr = address;
- new_client->adapter = adapter;
- new_client->driver = &w83792d_driver;
- new_client->flags = 0;
+ client = &data->client;
+ dev = &client->dev;
+ i2c_set_clientdata(client, data);
+ client->addr = address;
+ client->adapter = adapter;
+ client->driver = &w83792d_driver;
+ client->flags = 0;
/* Now, we do the remaining detection. */
@@ -1184,13 +1160,12 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
force_*=... parameter, and the Winbond will be reset to the right
bank. */
if (kind < 0) {
- if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) {
- dev_warn(&new_client->dev, "Detection failed at step "
- "3\n");
+ if (w83792d_read_value(client, W83792D_REG_CONFIG) & 0x80) {
+ dev_warn(dev, "Detection failed at step 3\n");
goto ERROR1;
}
- val1 = w83792d_read_value(new_client, W83792D_REG_BANK);
- val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
+ val1 = w83792d_read_value(client, W83792D_REG_BANK);
+ val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN);
/* Check for Winbond ID if in bank 0 */
if (!(val1 & 0x07)) { /* is Bank0 */
if (((!(val1 & 0x80)) && (val2 != 0xa3)) ||
@@ -1200,34 +1175,33 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
}
/* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR
should match */
- if (w83792d_read_value(new_client,
+ if (w83792d_read_value(client,
W83792D_REG_I2C_ADDR) != address) {
- dev_warn(&new_client->dev, "Detection failed "
- "at step 5\n");
+ dev_warn(dev, "Detection failed at step 5\n");
goto ERROR1;
}
}
/* We have either had a force parameter, or we have already detected the
Winbond. Put it now into bank 0 and Vendor ID High Byte */
- w83792d_write_value(new_client,
+ w83792d_write_value(client,
W83792D_REG_BANK,
- (w83792d_read_value(new_client,
+ (w83792d_read_value(client,
W83792D_REG_BANK) & 0x78) | 0x80);
/* Determine the chip type. */
if (kind <= 0) {
/* get vendor ID */
- val2 = w83792d_read_value(new_client, W83792D_REG_CHIPMAN);
+ val2 = w83792d_read_value(client, W83792D_REG_CHIPMAN);
if (val2 != 0x5c) { /* the vendor is NOT Winbond */
goto ERROR1;
}
- val1 = w83792d_read_value(new_client, W83792D_REG_WCHIPID);
+ val1 = w83792d_read_value(client, W83792D_REG_WCHIPID);
if (val1 == 0x7a) {
kind = w83792d;
} else {
if (kind == 0)
- dev_warn(&new_client->dev,
+ dev_warn(dev,
"w83792d: Ignoring 'force' parameter for"
" unknown chip at adapter %d, address"
" 0x%02x\n", i2c_adapter_id(adapter),
@@ -1239,120 +1213,86 @@ w83792d_detect(struct i2c_adapter *adapter, int address, int kind)
if (kind == w83792d) {
client_name = "w83792d";
} else {
- dev_err(&new_client->dev, "w83792d: Internal error: unknown"
+ dev_err(dev, "w83792d: Internal error: unknown"
" kind (%d)?!?", kind);
goto ERROR1;
}
/* Fill in the remaining client fields and put into the global list */
- strlcpy(new_client->name, client_name, I2C_NAME_SIZE);
+ strlcpy(client->name, client_name, I2C_NAME_SIZE);
data->type = kind;
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
- if ((err = i2c_attach_client(new_client)))
+ if ((err = i2c_attach_client(client)))
goto ERROR1;
if ((err = w83792d_detect_subclients(adapter, address,
- kind, new_client)))
+ kind, client)))
goto ERROR2;
/* Initialize the chip */
- w83792d_init_client(new_client);
+ w83792d_init_client(client);
/* A few vars need to be filled upon startup */
for (i = 0; i < 7; i++) {
- data->fan_min[i] = w83792d_read_value(new_client,
+ data->fan_min[i] = w83792d_read_value(client,
W83792D_REG_FAN_MIN[i]);
}
/* Register sysfs hooks */
- data->class_dev = hwmon_device_register(&new_client->dev);
+ data->class_dev = hwmon_device_register(dev);
if (IS_ERR(data->class_dev)) {
err = PTR_ERR(data->class_dev);
goto ERROR3;
}
- device_create_file_in(new_client, 0);
- device_create_file_in(new_client, 1);
- device_create_file_in(new_client, 2);
- device_create_file_in(new_client, 3);
- device_create_file_in(new_client, 4);
- device_create_file_in(new_client, 5);
- device_create_file_in(new_client, 6);
- device_create_file_in(new_client, 7);
- device_create_file_in(new_client, 8);
-
- device_create_file_fan(new_client, 1);
- device_create_file_fan(new_client, 2);
- device_create_file_fan(new_client, 3);
+ for (i = 0; i < 9; i++) {
+ device_create_file(dev, &sda_in_input[i].dev_attr);
+ device_create_file(dev, &sda_in_max[i].dev_attr);
+ device_create_file(dev, &sda_in_min[i].dev_attr);
+ }
+ for (i = 0; i < 3; i++)
+ device_create_file_fan(dev, i);
/* Read GPIO enable register to check if pins for fan 4,5 are used as
GPIO */
- val1 = w83792d_read_value(new_client, W83792D_REG_GPIO_EN);
+ val1 = w83792d_read_value(client, W83792D_REG_GPIO_EN);
if (!(val1 & 0x40))
- device_create_file_fan(new_client, 4);
+ device_create_file_fan(dev, 3);
if (!(val1 & 0x20))
- device_create_file_fan(new_client, 5);
+ device_create_file_fan(dev, 4);
- val1 = w83792d_read_value(new_client, W83792D_REG_PIN);
+ val1 = w83792d_read_value(client, W83792D_REG_PIN);
if (val1 & 0x40)
- device_create_file_fan(new_client, 6);
+ device_create_file_fan(dev, 5);
if (val1 & 0x04)
- device_create_file_fan(new_client, 7);
-
- device_create_file_temp1(new_client); /* Temp1 */
- device_create_file_temp_add(new_client, 2); /* Temp2 */
- device_create_file_temp_add(new_client, 3); /* Temp3 */
-
- device_create_file_alarms(new_client);
-
- device_create_file_pwm(new_client, 1);
- device_create_file_pwm(new_client, 2);
- device_create_file_pwm(new_client, 3);
-
- device_create_file_pwmenable(new_client, 1);
- device_create_file_pwmenable(new_client, 2);
- device_create_file_pwmenable(new_client, 3);
-
- device_create_file_pwm_mode(new_client, 1);
- device_create_file_pwm_mode(new_client, 2);
- device_create_file_pwm_mode(new_client, 3);
-
- device_create_file_chassis(new_client);
- device_create_file_chassis_clear(new_client);
-
- device_create_file_thermal_cruise(new_client, 1);
- device_create_file_thermal_cruise(new_client, 2);
- device_create_file_thermal_cruise(new_client, 3);
-
- device_create_file_tolerance(new_client, 1);
- device_create_file_tolerance(new_client, 2);
- device_create_file_tolerance(new_client, 3);
-
- device_create_file_sf2_point(new_client, 1, 1); /* Fan1 */
- device_create_file_sf2_point(new_client, 2, 1); /* Fan1 */
- device_create_file_sf2_point(new_client, 3, 1); /* Fan1 */
- device_create_file_sf2_point(new_client, 4, 1); /* Fan1 */
- device_create_file_sf2_point(new_client, 1, 2); /* Fan2 */
- device_create_file_sf2_point(new_client, 2, 2); /* Fan2 */
- device_create_file_sf2_point(new_client, 3, 2); /* Fan2 */
- device_create_file_sf2_point(new_client, 4, 2); /* Fan2 */
- device_create_file_sf2_point(new_client, 1, 3); /* Fan3 */
- device_create_file_sf2_point(new_client, 2, 3); /* Fan3 */
- device_create_file_sf2_point(new_client, 3, 3); /* Fan3 */
- device_create_file_sf2_point(new_client, 4, 3); /* Fan3 */
-
- device_create_file_sf2_level(new_client, 1, 1); /* Fan1 */
- device_create_file_sf2_level(new_client, 2, 1); /* Fan1 */
- device_create_file_sf2_level(new_client, 3, 1); /* Fan1 */
- device_create_file_sf2_level(new_client, 1, 2); /* Fan2 */
- device_create_file_sf2_level(new_client, 2, 2); /* Fan2 */
- device_create_file_sf2_level(new_client, 3, 2); /* Fan2 */
- device_create_file_sf2_level(new_client, 1, 3); /* Fan3 */
- device_create_file_sf2_level(new_client, 2, 3); /* Fan3 */
- device_create_file_sf2_level(new_client, 3, 3); /* Fan3 */
+ device_create_file_fan(dev, 6);
+
+ for (i = 0; i < 3; i++) {
+ device_create_file(dev, &sda_temp_input[i].dev_attr);
+ device_create_file(dev, &sda_temp_max[i].dev_attr);
+ device_create_file(dev, &sda_temp_max_hyst[i].dev_attr);
+ device_create_file(dev, &sda_thermal_cruise[i].dev_attr);
+ device_create_file(dev, &sda_tolerance[i].dev_attr);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(sda_pwm); i++) {
+ device_create_file(dev, &sda_pwm[i].dev_attr);
+ device_create_file(dev, &sda_pwm_enable[i].dev_attr);
+ device_create_file(dev, &sda_pwm_mode[i].dev_attr);
+ }
+
+ device_create_file(dev, &dev_attr_alarms);
+ device_create_file(dev, &dev_attr_chassis);
+ device_create_file(dev, &dev_attr_chassis_clear);
+
+ for (i = 0; i < ARRAY_SIZE(sda_sf2_point); i++)
+ device_create_file(dev, &sda_sf2_point[i].dev_attr);
+
+ for (i = 0; i < ARRAY_SIZE(sda_sf2_level); i++)
+ device_create_file(dev, &sda_sf2_level[i].dev_attr);
return 0;
@@ -1366,7 +1306,7 @@ ERROR3:
kfree(data->lm75[1]);
}
ERROR2:
- i2c_detach_client(new_client);
+ i2c_detach_client(client);
ERROR1:
kfree(data);
ERROR0:
@@ -1434,7 +1374,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
int i, j;
u8 reg_array_tmp[4], pwm_array_tmp[7], reg_tmp;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (time_after
(jiffies - data->last_updated, (unsigned long) (HZ * 3))
@@ -1545,7 +1485,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
#ifdef DEBUG
w83792d_print_debug(data, dev);
diff --git a/drivers/hwmon/w83l785ts.c b/drivers/hwmon/w83l785ts.c
index f66c0cfdeda..3f2bac125fb 100644
--- a/drivers/hwmon/w83l785ts.c
+++ b/drivers/hwmon/w83l785ts.c
@@ -39,6 +39,7 @@
#include <linux/hwmon.h>
#include <linux/hwmon-sysfs.h>
#include <linux/err.h>
+#include <linux/mutex.h>
/* How many retries on register read error */
#define MAX_RETRIES 5
@@ -107,7 +108,7 @@ static struct i2c_driver w83l785ts_driver = {
struct w83l785ts_data {
struct i2c_client client;
struct class_device *class_dev;
- struct semaphore update_lock;
+ struct mutex update_lock;
char valid; /* zero until following fields are valid */
unsigned long last_updated; /* in jiffies */
@@ -221,7 +222,7 @@ static int w83l785ts_detect(struct i2c_adapter *adapter, int address, int kind)
/* We can fill in the remaining client fields. */
strlcpy(new_client->name, "w83l785ts", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Default values in case the first read fails (unlikely). */
data->temp[1] = data->temp[0] = 0;
@@ -299,7 +300,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
struct i2c_client *client = to_i2c_client(dev);
struct w83l785ts_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (!data->valid || time_after(jiffies, data->last_updated + HZ * 2)) {
dev_dbg(&client->dev, "Updating w83l785ts data.\n");
@@ -312,7 +313,7 @@ static struct w83l785ts_data *w83l785ts_update_device(struct device *dev)
data->valid = 1;
}
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return data;
}
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index ff92735c7c8..089c6f5b24d 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -168,12 +168,14 @@ config I2C_PIIX4
help
If you say yes to this option, support will be included for the Intel
PIIX4 family of mainboard I2C interfaces. Specifically, the following
- versions of the chipset are supported:
+ versions of the chipset are supported (note that Serverworks is part
+ of Broadcom):
Intel PIIX4
Intel 440MX
Serverworks OSB4
Serverworks CSB5
Serverworks CSB6
+ Serverworks HT-1000
SMSC Victory66
This driver can also be built as a module. If so, the module
@@ -389,10 +391,11 @@ config SCx200_I2C_SDA
also be specified with a module parameter.
config SCx200_ACB
- tristate "NatSemi SCx200 ACCESS.bus"
- depends on I2C && PCI
+ tristate "Geode ACCESS.bus support"
+ depends on X86_32 && I2C && PCI
help
- Enable the use of the ACCESS.bus controllers of a SCx200 processor.
+ Enable the use of the ACCESS.bus controllers on the Geode SCx200 and
+ SC1100 processors and the CS5535 and CS5536 Geode companion devices.
If you don't know what to do here, say N.
diff --git a/drivers/i2c/busses/i2c-ali1535.c b/drivers/i2c/busses/i2c-ali1535.c
index 3eb47890db4..d3ef46aeeb3 100644
--- a/drivers/i2c/busses/i2c-ali1535.c
+++ b/drivers/i2c/busses/i2c-ali1535.c
@@ -63,7 +63,6 @@
#include <linux/i2c.h>
#include <linux/init.h>
#include <asm/io.h>
-#include <asm/semaphore.h>
/* ALI1535 SMBus address offsets */
@@ -136,7 +135,6 @@
static struct pci_driver ali1535_driver;
static unsigned short ali1535_smba;
-static DECLARE_MUTEX(i2c_ali1535_sem);
/* Detect whether a ALI1535 can be found, and initialize it, where necessary.
Note the differences between kernels with the old PCI BIOS interface and
@@ -345,7 +343,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
int timeout;
s32 result = 0;
- down(&i2c_ali1535_sem);
/* make sure SMBus is idle */
temp = inb_p(SMBHSTSTS);
for (timeout = 0;
@@ -460,7 +457,6 @@ static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
break;
}
EXIT:
- up(&i2c_ali1535_sem);
return result;
}
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 56c7d987590..08e915730ca 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -38,6 +38,7 @@
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/i2c.h>
+#include <linux/mutex.h>
extern struct i2c_adapter amd756_smbus;
@@ -45,7 +46,7 @@ static struct i2c_adapter *s4882_adapter;
static struct i2c_algorithm *s4882_algo;
/* Wrapper access functions for multiplexed SMBus */
-static struct semaphore amd756_lock;
+static DEFINE_MUTEX(amd756_lock);
static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
unsigned short flags, char read_write,
@@ -59,12 +60,12 @@ static s32 amd756_access_virt0(struct i2c_adapter * adap, u16 addr,
|| addr == 0x18)
return -1;
- down(&amd756_lock);
+ mutex_lock(&amd756_lock);
error = amd756_smbus.algo->smbus_xfer(adap, addr, flags, read_write,
command, size, data);
- up(&amd756_lock);
+ mutex_unlock(&amd756_lock);
return error;
}
@@ -87,7 +88,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
if (addr != 0x4c && (addr & 0xfc) != 0x50 && (addr & 0xfc) != 0x30)
return -1;
- down(&amd756_lock);
+ mutex_lock(&amd756_lock);
if (last_channels != channels) {
union i2c_smbus_data mplxdata;
@@ -105,7 +106,7 @@ static inline s32 amd756_access_channel(struct i2c_adapter * adap, u16 addr,
command, size, data);
UNLOCK:
- up(&amd756_lock);
+ mutex_unlock(&amd756_lock);
return error;
}
@@ -166,8 +167,6 @@ static int __init amd756_s4882_init(void)
}
printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
- init_MUTEX(&amd756_lock);
-
/* Define the 5 virtual adapters and algorithms structures */
if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
GFP_KERNEL))) {
diff --git a/drivers/i2c/busses/i2c-frodo.c b/drivers/i2c/busses/i2c-frodo.c
deleted file mode 100644
index b6f52f5a413..00000000000
--- a/drivers/i2c/busses/i2c-frodo.c
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * linux/drivers/i2c/i2c-frodo.c
- *
- * Author: Abraham van der Merwe <abraham@2d3d.co.za>
- *
- * An I2C adapter driver for the 2d3D, Inc. StrongARM SA-1110
- * Development board (Frodo).
- *
- * This source code is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/init.h>
-#include <linux/delay.h>
-#include <linux/i2c.h>
-#include <linux/i2c-algo-bit.h>
-#include <asm/hardware.h>
-
-
-static void frodo_setsda (void *data,int state)
-{
- if (state)
- FRODO_CPLD_I2C |= FRODO_I2C_SDA_OUT;
- else
- FRODO_CPLD_I2C &= ~FRODO_I2C_SDA_OUT;
-}
-
-static void frodo_setscl (void *data,int state)
-{
- if (state)
- FRODO_CPLD_I2C |= FRODO_I2C_SCL_OUT;
- else
- FRODO_CPLD_I2C &= ~FRODO_I2C_SCL_OUT;
-}
-
-static int frodo_getsda (void *data)
-{
- return ((FRODO_CPLD_I2C & FRODO_I2C_SDA_IN) != 0);
-}
-
-static int frodo_getscl (void *data)
-{
- return ((FRODO_CPLD_I2C & FRODO_I2C_SCL_IN) != 0);
-}
-
-static struct i2c_algo_bit_data bit_frodo_data = {
- .setsda = frodo_setsda,
- .setscl = frodo_setscl,
- .getsda = frodo_getsda,
- .getscl = frodo_getscl,
- .udelay = 80,
- .mdelay = 80,
- .timeout = HZ
-};
-
-static struct i2c_adapter frodo_ops = {
- .owner = THIS_MODULE,
- .id = I2C_HW_B_FRODO,
- .algo_data = &bit_frodo_data,
- .dev = {
- .name = "Frodo adapter driver",
- },
-};
-
-static int __init i2c_frodo_init (void)
-{
- return i2c_bit_add_bus(&frodo_ops);
-}
-
-static void __exit i2c_frodo_exit (void)
-{
- i2c_bit_del_bus(&frodo_ops);
-}
-
-MODULE_AUTHOR ("Abraham van der Merwe <abraham@2d3d.co.za>");
-MODULE_DESCRIPTION ("I2C-Bus adapter routines for Frodo");
-MODULE_LICENSE ("GPL");
-
-module_init (i2c_frodo_init);
-module_exit (i2c_frodo_exit);
-
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 4344ae6b1fc..c3e1d3e888d 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -125,7 +125,7 @@ int i2c_isa_del_driver(struct i2c_driver *driver)
static int __init i2c_isa_init(void)
{
- init_MUTEX(&isa_adapter.clist_lock);
+ mutex_init(&isa_adapter.clist_lock);
INIT_LIST_HEAD(&isa_adapter.clients);
isa_adapter.nr = ANY_I2C_ISA_BUS;
diff --git a/drivers/i2c/busses/i2c-ite.c b/drivers/i2c/busses/i2c-ite.c
index 5f5d2944808..d82e6dae840 100644
--- a/drivers/i2c/busses/i2c-ite.c
+++ b/drivers/i2c/busses/i2c-ite.c
@@ -200,9 +200,7 @@ static struct i2c_adapter iic_ite_ops = {
.owner = THIS_MODULE,
.id = I2C_HW_I_IIC,
.algo_data = &iic_ite_data,
- .dev = {
- .name = "ITE IIC adapter",
- },
+ .name = "ITE IIC adapter",
};
/* Called when the module is loaded. This function starts the
diff --git a/drivers/i2c/busses/i2c-ixp4xx.c b/drivers/i2c/busses/i2c-ixp4xx.c
index e422d8b2d4d..2ed07112d68 100644
--- a/drivers/i2c/busses/i2c-ixp4xx.c
+++ b/drivers/i2c/busses/i2c-ixp4xx.c
@@ -126,6 +126,7 @@ static int ixp4xx_i2c_probe(struct platform_device *plat_dev)
drv_data->algo_data.timeout = 100;
drv_data->adapter.id = I2C_HW_B_IXP4XX;
+ drv_data->adapter.class = I2C_CLASS_HWMON;
strlcpy(drv_data->adapter.name, plat_dev->dev.driver->name,
I2C_NAME_SIZE);
drv_data->adapter.algo_data = &drv_data->algo_data;
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index 692f4734548..d9c7c00e71f 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -22,7 +22,7 @@
/*
Supports:
Intel PIIX4, 440MX
- Serverworks OSB4, CSB5, CSB6
+ Serverworks OSB4, CSB5, CSB6, HT-1000
SMSC Victory66
Note: we assume there can only be one device, with one SMBus interface.
@@ -419,6 +419,8 @@ static struct pci_device_id piix4_ids[] = {
.driver_data = 0 },
{ PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6),
.driver_data = 0 },
+ { PCI_DEVICE(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT1000SB),
+ .driver_data = 0 },
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443MX_3),
.driver_data = 3 },
{ PCI_DEVICE(PCI_VENDOR_ID_EFAR, PCI_DEVICE_ID_EFAR_SLC90E66_3),
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 7579f4b256a..5155010b455 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -647,7 +647,7 @@ static inline void i2c_pxa_start_message(struct pxa_i2c *i2c)
}
/*
- * We are protected by the adapter bus semaphore.
+ * We are protected by the adapter bus mutex.
*/
static int i2c_pxa_do_xfer(struct pxa_i2c *i2c, struct i2c_msg *msg, int num)
{
diff --git a/drivers/i2c/busses/scx200_acb.c b/drivers/i2c/busses/scx200_acb.c
index d3478e08452..8bd305e47f0 100644
--- a/drivers/i2c/busses/scx200_acb.c
+++ b/drivers/i2c/busses/scx200_acb.c
@@ -1,27 +1,26 @@
-/* linux/drivers/i2c/scx200_acb.c
-
+/*
Copyright (c) 2001,2002 Christer Weinigel <wingel@nano-system.com>
National Semiconductor SCx200 ACCESS.bus support
-
+ Also supports the AMD CS5535 and AMD CS5536
+
Based on i2c-keywest.c which is:
Copyright (c) 2001 Benjamin Herrenschmidt <benh@kernel.crashing.org>
Copyright (c) 2000 Philip Edelbrock <phil@stimpy.netroedge.com>
-
+
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
*/
#include <linux/module.h>
@@ -32,7 +31,9 @@
#include <linux/smp_lock.h>
#include <linux/pci.h>
#include <linux/delay.h>
+#include <linux/mutex.h>
#include <asm/io.h>
+#include <asm/msr.h>
#include <linux/scx200.h>
@@ -47,16 +48,7 @@ static int base[MAX_DEVICES] = { 0x820, 0x840 };
module_param_array(base, int, NULL, 0);
MODULE_PARM_DESC(base, "Base addresses for the ACCESS.bus controllers");
-#ifdef DEBUG
-#define DBG(x...) printk(KERN_DEBUG NAME ": " x)
-#else
-#define DBG(x...)
-#endif
-
-/* The hardware supports interrupt driven mode too, but I haven't
- implemented that. */
-#define POLLED_MODE 1
-#define POLL_TIMEOUT (HZ)
+#define POLL_TIMEOUT (HZ/5)
enum scx200_acb_state {
state_idle,
@@ -79,12 +71,11 @@ static const char *scx200_acb_state_name[] = {
};
/* Physical interface */
-struct scx200_acb_iface
-{
+struct scx200_acb_iface {
struct scx200_acb_iface *next;
struct i2c_adapter adapter;
unsigned base;
- struct semaphore sem;
+ struct mutex mutex;
/* State machine data */
enum scx200_acb_state state;
@@ -100,7 +91,7 @@ struct scx200_acb_iface
#define ACBSDA (iface->base + 0)
#define ACBST (iface->base + 1)
#define ACBST_SDAST 0x40 /* SDA Status */
-#define ACBST_BER 0x20
+#define ACBST_BER 0x20
#define ACBST_NEGACK 0x10 /* Negative Acknowledge */
#define ACBST_STASTR 0x08 /* Stall After Start */
#define ACBST_MASTER 0x02
@@ -109,9 +100,9 @@ struct scx200_acb_iface
#define ACBCTL1 (iface->base + 3)
#define ACBCTL1_STASTRE 0x80
#define ACBCTL1_NMINTE 0x40
-#define ACBCTL1_ACK 0x10
-#define ACBCTL1_STOP 0x02
-#define ACBCTL1_START 0x01
+#define ACBCTL1_ACK 0x10
+#define ACBCTL1_STOP 0x02
+#define ACBCTL1_START 0x01
#define ACBADDR (iface->base + 4)
#define ACBCTL2 (iface->base + 5)
#define ACBCTL2_ENABLE 0x01
@@ -122,8 +113,8 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
{
const char *errmsg;
- DBG("state %s, status = 0x%02x\n",
- scx200_acb_state_name[iface->state], status);
+ dev_dbg(&iface->adapter.dev, "state %s, status = 0x%02x\n",
+ scx200_acb_state_name[iface->state], status);
if (status & ACBST_BER) {
errmsg = "bus error";
@@ -133,8 +124,17 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
errmsg = "not master";
goto error;
}
- if (status & ACBST_NEGACK)
- goto negack;
+ if (status & ACBST_NEGACK) {
+ dev_dbg(&iface->adapter.dev, "negative ack in state %s\n",
+ scx200_acb_state_name[iface->state]);
+
+ iface->state = state_idle;
+ iface->result = -ENXIO;
+
+ outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
+ outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
+ return;
+ }
switch (iface->state) {
case state_idle:
@@ -160,10 +160,10 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
case state_repeat_start:
outb(inb(ACBCTL1) | ACBCTL1_START, ACBCTL1);
/* fallthrough */
-
+
case state_quick:
if (iface->address_byte & 1) {
- if (iface->len == 1)
+ if (iface->len == 1)
outb(inb(ACBCTL1) | ACBCTL1_ACK, ACBCTL1);
else
outb(inb(ACBCTL1) & ~ACBCTL1_ACK, ACBCTL1);
@@ -202,26 +202,15 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
break;
}
-
+
outb(*iface->ptr++, ACBSDA);
--iface->len;
-
+
break;
}
return;
- negack:
- DBG("negative acknowledge in state %s\n",
- scx200_acb_state_name[iface->state]);
-
- iface->state = state_idle;
- iface->result = -ENXIO;
-
- outb(inb(ACBCTL1) | ACBCTL1_STOP, ACBCTL1);
- outb(ACBST_STASTR | ACBST_NEGACK, ACBST);
- return;
-
error:
dev_err(&iface->adapter.dev, "%s in state %s\n", errmsg,
scx200_acb_state_name[iface->state]);
@@ -231,20 +220,9 @@ static void scx200_acb_machine(struct scx200_acb_iface *iface, u8 status)
iface->needs_reset = 1;
}
-static void scx200_acb_timeout(struct scx200_acb_iface *iface)
-{
- dev_err(&iface->adapter.dev, "timeout in state %s\n",
- scx200_acb_state_name[iface->state]);
-
- iface->state = state_idle;
- iface->result = -EIO;
- iface->needs_reset = 1;
-}
-
-#ifdef POLLED_MODE
static void scx200_acb_poll(struct scx200_acb_iface *iface)
{
- u8 status = 0;
+ u8 status;
unsigned long timeout;
timeout = jiffies + POLL_TIMEOUT;
@@ -254,17 +232,21 @@ static void scx200_acb_poll(struct scx200_acb_iface *iface)
scx200_acb_machine(iface, status);
return;
}
- msleep(10);
+ yield();
}
- scx200_acb_timeout(iface);
+ dev_err(&iface->adapter.dev, "timeout in state %s\n",
+ scx200_acb_state_name[iface->state]);
+
+ iface->state = state_idle;
+ iface->result = -EIO;
+ iface->needs_reset = 1;
}
-#endif /* POLLED_MODE */
static void scx200_acb_reset(struct scx200_acb_iface *iface)
{
/* Disable the ACCESS.bus device and Configure the SCL
- frequency: 16 clock cycles */
+ frequency: 16 clock cycles */
outb(0x70, ACBCTL2);
/* Polling mode */
outb(0, ACBCTL1);
@@ -283,9 +265,9 @@ static void scx200_acb_reset(struct scx200_acb_iface *iface)
}
static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
- u16 address, unsigned short flags,
- char rw, u8 command, int size,
- union i2c_smbus_data *data)
+ u16 address, unsigned short flags,
+ char rw, u8 command, int size,
+ union i2c_smbus_data *data)
{
struct scx200_acb_iface *iface = i2c_get_adapdata(adapter);
int len;
@@ -295,53 +277,47 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
switch (size) {
case I2C_SMBUS_QUICK:
- len = 0;
- buffer = NULL;
- break;
+ len = 0;
+ buffer = NULL;
+ break;
+
case I2C_SMBUS_BYTE:
- if (rw == I2C_SMBUS_READ) {
- len = 1;
- buffer = &data->byte;
- } else {
- len = 1;
- buffer = &command;
- }
- break;
+ len = 1;
+ buffer = rw ? &data->byte : &command;
+ break;
+
case I2C_SMBUS_BYTE_DATA:
- len = 1;
- buffer = &data->byte;
- break;
+ len = 1;
+ buffer = &data->byte;
+ break;
+
case I2C_SMBUS_WORD_DATA:
len = 2;
- cur_word = cpu_to_le16(data->word);
- buffer = (u8 *)&cur_word;
+ cur_word = cpu_to_le16(data->word);
+ buffer = (u8 *)&cur_word;
break;
+
case I2C_SMBUS_BLOCK_DATA:
- len = data->block[0];
- buffer = &data->block[1];
+ len = data->block[0];
+ buffer = &data->block[1];
break;
+
default:
- return -EINVAL;
+ return -EINVAL;
}
- DBG("size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
- size, address, command, len, rw == I2C_SMBUS_READ);
+ dev_dbg(&adapter->dev,
+ "size=%d, address=0x%x, command=0x%x, len=%d, read=%d\n",
+ size, address, command, len, rw);
if (!len && rw == I2C_SMBUS_READ) {
- dev_warn(&adapter->dev, "zero length read\n");
+ dev_dbg(&adapter->dev, "zero length read\n");
return -EINVAL;
}
- if (len && !buffer) {
- dev_warn(&adapter->dev, "nonzero length but no buffer\n");
- return -EFAULT;
- }
-
- down(&iface->sem);
+ mutex_lock(&iface->mutex);
- iface->address_byte = address<<1;
- if (rw == I2C_SMBUS_READ)
- iface->address_byte |= 1;
+ iface->address_byte = (address << 1) | rw;
iface->command = command;
iface->ptr = buffer;
iface->len = len;
@@ -355,25 +331,21 @@ static s32 scx200_acb_smbus_xfer(struct i2c_adapter *adapter,
else
iface->state = state_address;
-#ifdef POLLED_MODE
while (iface->state != state_idle)
scx200_acb_poll(iface);
-#else /* POLLED_MODE */
-#error Interrupt driven mode not implemented
-#endif /* POLLED_MODE */
if (iface->needs_reset)
scx200_acb_reset(iface);
rc = iface->result;
- up(&iface->sem);
+ mutex_unlock(&iface->mutex);
if (rc == 0 && size == I2C_SMBUS_WORD_DATA && rw == I2C_SMBUS_READ)
- data->word = le16_to_cpu(cur_word);
+ data->word = le16_to_cpu(cur_word);
#ifdef DEBUG
- DBG(": transfer done, result: %d", rc);
+ dev_dbg(&adapter->dev, "transfer done, result: %d", rc);
if (buffer) {
int i;
printk(" data:");
@@ -400,17 +372,18 @@ static struct i2c_algorithm scx200_acb_algorithm = {
};
static struct scx200_acb_iface *scx200_acb_list;
+static DECLARE_MUTEX(scx200_acb_list_mutex);
static int scx200_acb_probe(struct scx200_acb_iface *iface)
{
u8 val;
/* Disable the ACCESS.bus device and Configure the SCL
- frequency: 16 clock cycles */
+ frequency: 16 clock cycles */
outb(0x70, ACBCTL2);
if (inb(ACBCTL2) != 0x70) {
- DBG("ACBCTL2 readback failed\n");
+ pr_debug(NAME ": ACBCTL2 readback failed\n");
return -ENXIO;
}
@@ -418,7 +391,8 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface)
val = inb(ACBCTL1);
if (val) {
- DBG("disabled, but ACBCTL1=0x%02x\n", val);
+ pr_debug(NAME ": disabled, but ACBCTL1=0x%02x\n",
+ val);
return -ENXIO;
}
@@ -428,18 +402,19 @@ static int scx200_acb_probe(struct scx200_acb_iface *iface)
val = inb(ACBCTL1);
if ((val & ACBCTL1_NMINTE) != ACBCTL1_NMINTE) {
- DBG("enabled, but NMINTE won't be set, ACBCTL1=0x%02x\n", val);
+ pr_debug(NAME ": enabled, but NMINTE won't be set, "
+ "ACBCTL1=0x%02x\n", val);
return -ENXIO;
}
return 0;
}
-static int __init scx200_acb_create(int base, int index)
+static int __init scx200_acb_create(const char *text, int base, int index)
{
struct scx200_acb_iface *iface;
struct i2c_adapter *adapter;
- int rc = 0;
+ int rc;
char description[64];
iface = kzalloc(sizeof(*iface), GFP_KERNEL);
@@ -451,50 +426,51 @@ static int __init scx200_acb_create(int base, int index)
adapter = &iface->adapter;
i2c_set_adapdata(adapter, iface);
- snprintf(adapter->name, I2C_NAME_SIZE, "SCx200 ACB%d", index);
+ snprintf(adapter->name, I2C_NAME_SIZE, "%s ACB%d", text, index);
adapter->owner = THIS_MODULE;
adapter->id = I2C_HW_SMBUS_SCX200;
adapter->algo = &scx200_acb_algorithm;
adapter->class = I2C_CLASS_HWMON;
- init_MUTEX(&iface->sem);
+ mutex_init(&iface->mutex);
+
+ snprintf(description, sizeof(description), "%s ACCESS.bus [%s]",
+ text, adapter->name);
- snprintf(description, sizeof(description), "NatSemi SCx200 ACCESS.bus [%s]", adapter->name);
if (request_region(base, 8, description) == 0) {
- dev_err(&adapter->dev, "can't allocate io 0x%x-0x%x\n",
+ printk(KERN_ERR NAME ": can't allocate io 0x%x-0x%x\n",
base, base + 8-1);
rc = -EBUSY;
- goto errout;
+ goto errout_free;
}
iface->base = base;
rc = scx200_acb_probe(iface);
if (rc) {
- dev_warn(&adapter->dev, "probe failed\n");
- goto errout;
+ printk(KERN_WARNING NAME ": probe failed\n");
+ goto errout_release;
}
scx200_acb_reset(iface);
if (i2c_add_adapter(adapter) < 0) {
- dev_err(&adapter->dev, "failed to register\n");
+ printk(KERN_ERR NAME ": failed to register\n");
rc = -ENODEV;
- goto errout;
+ goto errout_release;
}
- lock_kernel();
+ down(&scx200_acb_list_mutex);
iface->next = scx200_acb_list;
scx200_acb_list = iface;
- unlock_kernel();
+ up(&scx200_acb_list_mutex);
return 0;
+ errout_release:
+ release_region(iface->base, 8);
+ errout_free:
+ kfree(iface);
errout:
- if (iface) {
- if (iface->base)
- release_region(iface->base, 8);
- kfree(iface);
- }
return rc;
}
@@ -504,50 +480,69 @@ static struct pci_device_id scx200[] = {
{ },
};
+static struct pci_device_id divil_pci[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_CS5535_ISA) },
+ { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA) },
+ { } /* NULL entry */
+};
+
+#define MSR_LBAR_SMB 0x5140000B
+
+static int scx200_add_cs553x(void)
+{
+ u32 low, hi;
+ u32 smb_base;
+
+ /* Grab & reserve the SMB I/O range */
+ rdmsr(MSR_LBAR_SMB, low, hi);
+
+ /* Check the IO mask and whether SMB is enabled */
+ if (hi != 0x0000F001) {
+ printk(KERN_WARNING NAME ": SMBus not enabled\n");
+ return -ENODEV;
+ }
+
+ /* SMBus IO size is 8 bytes */
+ smb_base = low & 0x0000FFF8;
+
+ return scx200_acb_create("CS5535", smb_base, 0);
+}
+
static int __init scx200_acb_init(void)
{
int i;
- int rc;
+ int rc = -ENODEV;
pr_debug(NAME ": NatSemi SCx200 ACCESS.bus Driver\n");
/* Verify that this really is a SCx200 processor */
- if (pci_dev_present(scx200) == 0)
- return -ENODEV;
+ if (pci_dev_present(scx200)) {
+ for (i = 0; i < MAX_DEVICES; ++i) {
+ if (base[i] > 0)
+ rc = scx200_acb_create("SCx200", base[i], i);
+ }
+ } else if (pci_dev_present(divil_pci))
+ rc = scx200_add_cs553x();
- rc = -ENXIO;
- for (i = 0; i < MAX_DEVICES; ++i) {
- if (base[i] > 0)
- rc = scx200_acb_create(base[i], i);
- }
- if (scx200_acb_list)
- return 0;
return rc;
}
static void __exit scx200_acb_cleanup(void)
{
struct scx200_acb_iface *iface;
- lock_kernel();
+
+ down(&scx200_acb_list_mutex);
while ((iface = scx200_acb_list) != NULL) {
scx200_acb_list = iface->next;
- unlock_kernel();
+ up(&scx200_acb_list_mutex);
i2c_del_adapter(&iface->adapter);
release_region(iface->base, 8);
kfree(iface);
- lock_kernel();
+ down(&scx200_acb_list_mutex);
}
- unlock_kernel();
+ up(&scx200_acb_list_mutex);
}
module_init(scx200_acb_init);
module_exit(scx200_acb_cleanup);
-
-/*
- Local variables:
- compile-command: "make -k -C ../.. SUBDIRS=drivers/i2c modules"
- c-basic-offset: 8
- End:
-*/
-
diff --git a/drivers/i2c/chips/ds1374.c b/drivers/i2c/chips/ds1374.c
index 0710b9da9d5..03d09ed5ec2 100644
--- a/drivers/i2c/chips/ds1374.c
+++ b/drivers/i2c/chips/ds1374.c
@@ -26,6 +26,7 @@
#include <linux/i2c.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
+#include <linux/mutex.h>
#define DS1374_REG_TOD0 0x00
#define DS1374_REG_TOD1 0x01
@@ -41,7 +42,7 @@
#define DS1374_DRV_NAME "ds1374"
-static DECLARE_MUTEX(ds1374_mutex);
+static DEFINE_MUTEX(ds1374_mutex);
static struct i2c_driver ds1374_driver;
static struct i2c_client *save_client;
@@ -114,7 +115,7 @@ ulong ds1374_get_rtc_time(void)
ulong t1, t2;
int limit = 10; /* arbitrary retry limit */
- down(&ds1374_mutex);
+ mutex_lock(&ds1374_mutex);
/*
* Since the reads are being performed one byte at a time using
@@ -127,7 +128,7 @@ ulong ds1374_get_rtc_time(void)
t2 = ds1374_read_rtc();
} while (t1 != t2 && limit--);
- up(&ds1374_mutex);
+ mutex_unlock(&ds1374_mutex);
if (t1 != t2) {
dev_warn(&save_client->dev,
@@ -145,7 +146,7 @@ static void ds1374_set_tlet(ulong arg)
t1 = *(ulong *) arg;
- down(&ds1374_mutex);
+ mutex_lock(&ds1374_mutex);
/*
* Since the writes are being performed one byte at a time using
@@ -158,7 +159,7 @@ static void ds1374_set_tlet(ulong arg)
t2 = ds1374_read_rtc();
} while (t1 != t2 && limit--);
- up(&ds1374_mutex);
+ mutex_unlock(&ds1374_mutex);
if (t1 != t2)
dev_warn(&save_client->dev,
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 41116b7947f..13c108269a6 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -33,6 +33,7 @@
#include <linux/sched.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x50, 0x51, 0x52, 0x53, 0x54,
@@ -54,7 +55,7 @@ enum eeprom_nature {
/* Each client has this additional data */
struct eeprom_data {
struct i2c_client client;
- struct semaphore update_lock;
+ struct mutex update_lock;
u8 valid; /* bitfield, bit!=0 if slice is valid */
unsigned long last_updated[8]; /* In jiffies, 8 slices */
u8 data[EEPROM_SIZE]; /* Register values */
@@ -81,7 +82,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
struct eeprom_data *data = i2c_get_clientdata(client);
int i, j;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (!(data->valid & (1 << slice)) ||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
@@ -107,7 +108,7 @@ static void eeprom_update_client(struct i2c_client *client, u8 slice)
data->valid |= (1 << slice);
}
exit:
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -187,7 +188,7 @@ static int eeprom_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields */
strlcpy(new_client->name, "eeprom", I2C_NAME_SIZE);
data->valid = 0;
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
data->nature = UNKNOWN;
/* Tell the I2C layer a new client has arrived */
diff --git a/drivers/i2c/chips/isp1301_omap.c b/drivers/i2c/chips/isp1301_omap.c
index 1251c7fc18d..e6f1ab7b913 100644
--- a/drivers/i2c/chips/isp1301_omap.c
+++ b/drivers/i2c/chips/isp1301_omap.c
@@ -1635,8 +1635,6 @@ static struct i2c_driver isp1301_driver = {
.driver = {
.name = "isp1301_omap",
},
- .id = 1301, /* FIXME "official", i2c-ids.h */
- .class = I2C_CLASS_HWMON,
.attach_adapter = isp1301_scan_bus,
.detach_client = isp1301_detach_client,
};
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c
index 2dc3d48375f..b5aabe7cf79 100644
--- a/drivers/i2c/chips/m41t00.c
+++ b/drivers/i2c/chips/m41t00.c
@@ -24,13 +24,14 @@
#include <linux/i2c.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
+#include <linux/mutex.h>
#include <asm/time.h>
#include <asm/rtc.h>
#define M41T00_DRV_NAME "m41t00"
-static DECLARE_MUTEX(m41t00_mutex);
+static DEFINE_MUTEX(m41t00_mutex);
static struct i2c_driver m41t00_driver;
static struct i2c_client *save_client;
@@ -54,7 +55,7 @@ m41t00_get_rtc_time(void)
sec = min = hour = day = mon = year = 0;
sec1 = min1 = hour1 = day1 = mon1 = year1 = 0;
- down(&m41t00_mutex);
+ mutex_lock(&m41t00_mutex);
do {
if (((sec = i2c_smbus_read_byte_data(save_client, 0)) >= 0)
&& ((min = i2c_smbus_read_byte_data(save_client, 1))
@@ -80,7 +81,7 @@ m41t00_get_rtc_time(void)
mon1 = mon;
year1 = year;
} while (--limit > 0);
- up(&m41t00_mutex);
+ mutex_unlock(&m41t00_mutex);
if (limit == 0) {
dev_warn(&save_client->dev,
@@ -125,7 +126,7 @@ m41t00_set_tlet(ulong arg)
BIN_TO_BCD(tm.tm_mday);
BIN_TO_BCD(tm.tm_year);
- down(&m41t00_mutex);
+ mutex_lock(&m41t00_mutex);
if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0)
|| (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f)
< 0)
@@ -140,7 +141,7 @@ m41t00_set_tlet(ulong arg)
dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n");
- up(&m41t00_mutex);
+ mutex_unlock(&m41t00_mutex);
return;
}
diff --git a/drivers/i2c/chips/max6875.c b/drivers/i2c/chips/max6875.c
index 6d3ff584155..88d2ddee449 100644
--- a/drivers/i2c/chips/max6875.c
+++ b/drivers/i2c/chips/max6875.c
@@ -31,7 +31,7 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/i2c.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
/* Do not scan - the MAX6875 access method will write to some EEPROM chips */
static unsigned short normal_i2c[] = {I2C_CLIENT_END};
@@ -54,7 +54,7 @@ I2C_CLIENT_INSMOD_1(max6875);
/* Each client has this additional data */
struct max6875_data {
struct i2c_client client;
- struct semaphore update_lock;
+ struct mutex update_lock;
u32 valid;
u8 data[USER_EEPROM_SIZE];
@@ -83,7 +83,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
if (slice >= USER_EEPROM_SLICES)
return;
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
buf = &data->data[slice << SLICE_BITS];
@@ -122,7 +122,7 @@ static void max6875_update_slice(struct i2c_client *client, int slice)
data->valid |= (1 << slice);
}
exit_up:
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
}
static ssize_t max6875_read(struct kobject *kobj, char *buf, loff_t off,
@@ -196,7 +196,7 @@ static int max6875_detect(struct i2c_adapter *adapter, int address, int kind)
real_client->driver = &max6875_driver;
real_client->flags = 0;
strlcpy(real_client->name, "max6875", I2C_NAME_SIZE);
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Init fake client data */
/* set the client data to the i2c_client so that it will get freed */
diff --git a/drivers/i2c/chips/pcf8591.c b/drivers/i2c/chips/pcf8591.c
index 36cff09c678..925a6b371fd 100644
--- a/drivers/i2c/chips/pcf8591.c
+++ b/drivers/i2c/chips/pcf8591.c
@@ -24,6 +24,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/mutex.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4b, 0x4c,
@@ -74,7 +75,7 @@ MODULE_PARM_DESC(input_mode,
struct pcf8591_data {
struct i2c_client client;
- struct semaphore update_lock;
+ struct mutex update_lock;
u8 control;
u8 aout;
@@ -144,13 +145,13 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
struct pcf8591_data *data = i2c_get_clientdata(client);
unsigned long val = simple_strtoul(buf, NULL, 10);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if (val)
data->control |= PCF8591_CONTROL_AOEF;
else
data->control &= ~PCF8591_CONTROL_AOEF;
i2c_smbus_write_byte(client, data->control);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
return count;
}
@@ -200,7 +201,7 @@ static int pcf8591_detect(struct i2c_adapter *adapter, int address, int kind)
/* Fill in the remaining client fields and put it into the global
list */
strlcpy(new_client->name, "pcf8591", I2C_NAME_SIZE);
- init_MUTEX(&data->update_lock);
+ mutex_init(&data->update_lock);
/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
@@ -265,7 +266,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
struct i2c_client *client = to_i2c_client(dev);
struct pcf8591_data *data = i2c_get_clientdata(client);
- down(&data->update_lock);
+ mutex_lock(&data->update_lock);
if ((data->control & PCF8591_CONTROL_AICH_MASK) != channel) {
data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
@@ -278,7 +279,7 @@ static int pcf8591_read_channel(struct device *dev, int channel)
}
value = i2c_smbus_read_byte(client);
- up(&data->update_lock);
+ mutex_unlock(&data->update_lock);
if ((channel == 2 && input_mode == 2) ||
(channel != 3 && (input_mode == 1 || input_mode == 3)))
diff --git a/drivers/i2c/chips/rtc8564.c b/drivers/i2c/chips/rtc8564.c
index ceaa6b0bdfd..0d8699b3f48 100644
--- a/drivers/i2c/chips/rtc8564.c
+++ b/drivers/i2c/chips/rtc8564.c
@@ -53,7 +53,7 @@ static inline u8 _rtc8564_ctrl2(struct i2c_client *client)
#define CTRL1(c) _rtc8564_ctrl1(c)
#define CTRL2(c) _rtc8564_ctrl2(c)
-static int debug;;
+static int debug;
module_param(debug, int, S_IRUGO | S_IWUSR);
static struct i2c_driver rtc8564_driver;
diff --git a/drivers/i2c/chips/tps65010.c b/drivers/i2c/chips/tps65010.c
index 1af3dfbb808..179b1e022d8 100644
--- a/drivers/i2c/chips/tps65010.c
+++ b/drivers/i2c/chips/tps65010.c
@@ -32,6 +32,7 @@
#include <linux/suspend.h>
#include <linux/debugfs.h>
#include <linux/seq_file.h>
+#include <linux/mutex.h>
#include <asm/irq.h>
#include <asm/mach-types.h>
@@ -81,7 +82,7 @@ enum tps_model {
struct tps65010 {
struct i2c_client client;
- struct semaphore lock;
+ struct mutex lock;
int irq;
struct work_struct work;
struct dentry *file;
@@ -218,7 +219,7 @@ static int dbg_show(struct seq_file *s, void *_)
seq_printf(s, "driver %s\nversion %s\nchip %s\n\n",
DRIVER_NAME, DRIVER_VERSION, chip);
- down(&tps->lock);
+ mutex_lock(&tps->lock);
/* FIXME how can we tell whether a battery is present?
* likely involves a charge gauging chip (like BQ26501).
@@ -300,7 +301,7 @@ static int dbg_show(struct seq_file *s, void *_)
(v2 & (1 << (4 + i))) ? "rising" : "falling");
}
- up(&tps->lock);
+ mutex_unlock(&tps->lock);
return 0;
}
@@ -416,7 +417,7 @@ static void tps65010_work(void *_tps)
{
struct tps65010 *tps = _tps;
- down(&tps->lock);
+ mutex_lock(&tps->lock);
tps65010_interrupt(tps);
@@ -444,7 +445,7 @@ static void tps65010_work(void *_tps)
if (test_and_clear_bit(FLAG_IRQ_ENABLE, &tps->flags))
enable_irq(tps->irq);
- up(&tps->lock);
+ mutex_unlock(&tps->lock);
}
static irqreturn_t tps65010_irq(int irq, void *_tps, struct pt_regs *regs)
@@ -505,7 +506,7 @@ tps65010_probe(struct i2c_adapter *bus, int address, int kind)
if (!tps)
return 0;
- init_MUTEX(&tps->lock);
+ mutex_init(&tps->lock);
INIT_WORK(&tps->work, tps65010_work, tps);
tps->irq = -1;
tps->client.addr = address;
@@ -695,7 +696,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
if ((gpio < GPIO1) || (gpio > GPIO4))
return -EINVAL;
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
defgpio = i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO);
@@ -720,7 +721,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
gpio, value ? "high" : "low",
i2c_smbus_read_byte_data(&the_tps->client, TPS_DEFGPIO));
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
EXPORT_SYMBOL(tps65010_set_gpio_out_value);
@@ -745,7 +746,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
led = LED2;
}
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
pr_debug("%s: led%i_on 0x%02x\n", DRIVER_NAME, led,
i2c_smbus_read_byte_data(&the_tps->client,
@@ -771,7 +772,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
default:
printk(KERN_ERR "%s: Wrong mode parameter for set_led()\n",
DRIVER_NAME);
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return -EINVAL;
}
@@ -781,7 +782,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
if (status != 0) {
printk(KERN_ERR "%s: Failed to write led%i_on register\n",
DRIVER_NAME, led);
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -794,7 +795,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
if (status != 0) {
printk(KERN_ERR "%s: Failed to write led%i_per register\n",
DRIVER_NAME, led);
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -802,7 +803,7 @@ int tps65010_set_led(unsigned led, unsigned mode)
i2c_smbus_read_byte_data(&the_tps->client,
TPS_LED1_PER + offs));
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -820,7 +821,7 @@ int tps65010_set_vib(unsigned value)
if (!the_tps)
return -ENODEV;
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
vdcdc2 = i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC2);
vdcdc2 &= ~(1 << 1);
@@ -831,7 +832,7 @@ int tps65010_set_vib(unsigned value)
pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
EXPORT_SYMBOL(tps65010_set_vib);
@@ -848,7 +849,7 @@ int tps65010_set_low_pwr(unsigned mode)
if (!the_tps)
return -ENODEV;
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
mode ? "enable" : "disable",
@@ -876,7 +877,7 @@ int tps65010_set_low_pwr(unsigned mode)
pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -894,7 +895,7 @@ int tps65010_config_vregs1(unsigned value)
if (!the_tps)
return -ENODEV;
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
@@ -909,7 +910,7 @@ int tps65010_config_vregs1(unsigned value)
pr_debug("%s: vregs1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VREGS1));
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -931,7 +932,7 @@ int tps65013_set_low_pwr(unsigned mode)
if (!the_tps || the_tps->por)
return -ENODEV;
- down(&the_tps->lock);
+ mutex_lock(&the_tps->lock);
pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
DRIVER_NAME,
@@ -959,7 +960,7 @@ int tps65013_set_low_pwr(unsigned mode)
if (status != 0) {
printk(KERN_ERR "%s: Failed to write chconfig register\n",
DRIVER_NAME);
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
@@ -977,7 +978,7 @@ int tps65013_set_low_pwr(unsigned mode)
pr_debug("%s: vdcdc1 0x%02x\n", DRIVER_NAME,
i2c_smbus_read_byte_data(&the_tps->client, TPS_VDCDC1));
- up(&the_tps->lock);
+ mutex_unlock(&the_tps->lock);
return status;
}
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 1a2c9ab5d9e..45e2cdf5473 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -31,12 +31,13 @@
#include <linux/idr.h>
#include <linux/seq_file.h>
#include <linux/platform_device.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
static LIST_HEAD(adapters);
static LIST_HEAD(drivers);
-static DECLARE_MUTEX(core_lists);
+static DEFINE_MUTEX(core_lists);
static DEFINE_IDR(i2c_adapter_idr);
/* match always succeeds, as we want the probe() to tell if we really accept this match */
@@ -153,7 +154,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
struct list_head *item;
struct i2c_driver *driver;
- down(&core_lists);
+ mutex_lock(&core_lists);
if (idr_pre_get(&i2c_adapter_idr, GFP_KERNEL) == 0) {
res = -ENOMEM;
@@ -168,8 +169,8 @@ int i2c_add_adapter(struct i2c_adapter *adap)
}
adap->nr = id & MAX_ID_MASK;
- init_MUTEX(&adap->bus_lock);
- init_MUTEX(&adap->clist_lock);
+ mutex_init(&adap->bus_lock);
+ mutex_init(&adap->clist_lock);
list_add_tail(&adap->list,&adapters);
INIT_LIST_HEAD(&adap->clients);
@@ -203,7 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
}
out_unlock:
- up(&core_lists);
+ mutex_unlock(&core_lists);
return res;
}
@@ -216,7 +217,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
struct i2c_client *client;
int res = 0;
- down(&core_lists);
+ mutex_lock(&core_lists);
/* First make sure that this adapter was ever added */
list_for_each_entry(adap_from_list, &adapters, list) {
@@ -272,7 +273,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
dev_dbg(&adap->dev, "adapter [%s] unregistered\n", adap->name);
out_unlock:
- up(&core_lists);
+ mutex_unlock(&core_lists);
return res;
}
@@ -287,9 +288,7 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
{
struct list_head *item;
struct i2c_adapter *adapter;
- int res = 0;
-
- down(&core_lists);
+ int res;
/* add the driver to the list of i2c drivers in the driver core */
driver->driver.owner = owner;
@@ -297,8 +296,10 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
res = driver_register(&driver->driver);
if (res)
- goto out_unlock;
+ return res;
+ mutex_lock(&core_lists);
+
list_add_tail(&driver->list,&drivers);
pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);
@@ -310,9 +311,8 @@ int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
}
}
- out_unlock:
- up(&core_lists);
- return res;
+ mutex_unlock(&core_lists);
+ return 0;
}
EXPORT_SYMBOL(i2c_register_driver);
@@ -324,7 +324,7 @@ int i2c_del_driver(struct i2c_driver *driver)
int res = 0;
- down(&core_lists);
+ mutex_lock(&core_lists);
/* Have a look at each adapter, if clients of this driver are still
* attached. If so, detach them to be able to kill the driver
@@ -363,7 +363,7 @@ int i2c_del_driver(struct i2c_driver *driver)
pr_debug("i2c-core: driver [%s] unregistered\n", driver->driver.name);
out_unlock:
- up(&core_lists);
+ mutex_unlock(&core_lists);
return 0;
}
@@ -384,9 +384,9 @@ int i2c_check_addr(struct i2c_adapter *adapter, int addr)
{
int rval;
- down(&adapter->clist_lock);
+ mutex_lock(&adapter->clist_lock);
rval = __i2c_check_addr(adapter, addr);
- up(&adapter->clist_lock);
+ mutex_unlock(&adapter->clist_lock);
return rval;
}
@@ -395,13 +395,13 @@ int i2c_attach_client(struct i2c_client *client)
{
struct i2c_adapter *adapter = client->adapter;
- down(&adapter->clist_lock);
+ mutex_lock(&adapter->clist_lock);
if (__i2c_check_addr(client->adapter, client->addr)) {
- up(&adapter->clist_lock);
+ mutex_unlock(&adapter->clist_lock);
return -EBUSY;
}
list_add_tail(&client->list,&adapter->clients);
- up(&adapter->clist_lock);
+ mutex_unlock(&adapter->clist_lock);
if (adapter->client_register) {
if (adapter->client_register(client)) {
@@ -450,12 +450,12 @@ int i2c_detach_client(struct i2c_client *client)
}
}
- down(&adapter->clist_lock);
+ mutex_lock(&adapter->clist_lock);
list_del(&client->list);
init_completion(&client->released);
device_remove_file(&client->dev, &dev_attr_client_name);
device_unregister(&client->dev);
- up(&adapter->clist_lock);
+ mutex_unlock(&adapter->clist_lock);
wait_for_completion(&client->released);
out:
@@ -513,19 +513,19 @@ void i2c_clients_command(struct i2c_adapter *adap, unsigned int cmd, void *arg)
struct list_head *item;
struct i2c_client *client;
- down(&adap->clist_lock);
+ mutex_lock(&adap->clist_lock);
list_for_each(item,&adap->clients) {
client = list_entry(item, struct i2c_client, list);
if (!try_module_get(client->driver->driver.owner))
continue;
if (NULL != client->driver->command) {
- up(&adap->clist_lock);
+ mutex_unlock(&adap->clist_lock);
client->driver->command(client,cmd,arg);
- down(&adap->clist_lock);
+ mutex_lock(&adap->clist_lock);
}
module_put(client->driver->driver.owner);
}
- up(&adap->clist_lock);
+ mutex_unlock(&adap->clist_lock);
}
static int __init i2c_init(void)
@@ -569,9 +569,9 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
}
#endif
- down(&adap->bus_lock);
+ mutex_lock(&adap->bus_lock);
ret = adap->algo->master_xfer(adap,msgs,num);
- up(&adap->bus_lock);
+ mutex_unlock(&adap->bus_lock);
return ret;
} else {
@@ -779,12 +779,12 @@ struct i2c_adapter* i2c_get_adapter(int id)
{
struct i2c_adapter *adapter;
- down(&core_lists);
+ mutex_lock(&core_lists);
adapter = (struct i2c_adapter *)idr_find(&i2c_adapter_idr, id);
if (adapter && !try_module_get(adapter->owner))
adapter = NULL;
- up(&core_lists);
+ mutex_unlock(&core_lists);
return adapter;
}
@@ -919,12 +919,11 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
u8 length, u8 *values)
{
union i2c_smbus_data data;
- int i;
+
if (length > I2C_SMBUS_BLOCK_MAX)
length = I2C_SMBUS_BLOCK_MAX;
- for (i = 1; i <= length; i++)
- data.block[i] = values[i-1];
data.block[0] = length;
+ memcpy(&data.block[1], values, length);
return i2c_smbus_xfer(client->adapter,client->addr,client->flags,
I2C_SMBUS_WRITE,command,
I2C_SMBUS_BLOCK_DATA,&data);
@@ -934,16 +933,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command,
s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values)
{
union i2c_smbus_data data;
- int i;
+
if (i2c_smbus_xfer(client->adapter,client->addr,client->flags,
I2C_SMBUS_READ,command,
I2C_SMBUS_I2C_BLOCK_DATA,&data))
return -1;
- else {
- for (i = 1; i <= data.block[0]; i++)
- values[i-1] = data.block[i];
- return data.block[0];
- }
+
+ memcpy(values, &data.block[1], data.block[0]);
+ return data.block[0];
}
s32 i2c_smbus_write_i2c_block_data(struct i2c_client *client, u8 command,
@@ -1118,10 +1115,10 @@ s32 i2c_smbus_xfer(struct i2c_adapter * adapter, u16 addr, unsigned short flags,
flags &= I2C_M_TEN | I2C_CLIENT_PEC;
if (adapter->algo->smbus_xfer) {
- down(&adapter->bus_lock);
+ mutex_lock(&adapter->bus_lock);
res = adapter->algo->smbus_xfer(adapter,addr,flags,read_write,
command,size,data);
- up(&adapter->bus_lock);
+ mutex_unlock(&adapter->bus_lock);
} else
res = i2c_smbus_xfer_emulated(adapter,addr,flags,read_write,
command,size,data);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3325660f724..c7671e18801 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -313,6 +313,7 @@
#include <linux/cdrom.h>
#include <linux/ide.h>
#include <linux/completion.h>
+#include <linux/mutex.h>
#include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */
@@ -324,7 +325,7 @@
#include "ide-cd.h"
-static DECLARE_MUTEX(idecd_ref_sem);
+static DEFINE_MUTEX(idecd_ref_mutex);
#define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref)
@@ -335,11 +336,11 @@ static struct cdrom_info *ide_cd_get(struct gendisk *disk)
{
struct cdrom_info *cd = NULL;
- down(&idecd_ref_sem);
+ mutex_lock(&idecd_ref_mutex);
cd = ide_cd_g(disk);
if (cd)
kref_get(&cd->kref);
- up(&idecd_ref_sem);
+ mutex_unlock(&idecd_ref_mutex);
return cd;
}
@@ -347,9 +348,9 @@ static void ide_cd_release(struct kref *);
static void ide_cd_put(struct cdrom_info *cd)
{
- down(&idecd_ref_sem);
+ mutex_lock(&idecd_ref_mutex);
kref_put(&cd->kref, ide_cd_release);
- up(&idecd_ref_sem);
+ mutex_unlock(&idecd_ref_mutex);
}
/****************************************************************************
@@ -2471,52 +2472,6 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi,
}
static
-int ide_cdrom_dev_ioctl (struct cdrom_device_info *cdi,
- unsigned int cmd, unsigned long arg)
-{
- struct packet_command cgc;
- char buffer[16];
- int stat;
-
- init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
-
- /* These will be moved into the Uniform layer shortly... */
- switch (cmd) {
- case CDROMSETSPINDOWN: {
- char spindown;
-
- if (copy_from_user(&spindown, (void __user *) arg, sizeof(char)))
- return -EFAULT;
-
- if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0)))
- return stat;
-
- buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f);
-
- return cdrom_mode_select(cdi, &cgc);
- }
-
- case CDROMGETSPINDOWN: {
- char spindown;
-
- if ((stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0)))
- return stat;
-
- spindown = buffer[11] & 0x0f;
-
- if (copy_to_user((void __user *) arg, &spindown, sizeof (char)))
- return -EFAULT;
-
- return 0;
- }
-
- default:
- return -EINVAL;
- }
-
-}
-
-static
int ide_cdrom_audio_ioctl (struct cdrom_device_info *cdi,
unsigned int cmd, void *arg)
@@ -2852,12 +2807,11 @@ static struct cdrom_device_ops ide_cdrom_dops = {
.get_mcn = ide_cdrom_get_mcn,
.reset = ide_cdrom_reset,
.audio_ioctl = ide_cdrom_audio_ioctl,
- .dev_ioctl = ide_cdrom_dev_ioctl,
.capability = CDC_CLOSE_TRAY | CDC_OPEN_TRAY | CDC_LOCK |
CDC_SELECT_SPEED | CDC_SELECT_DISC |
CDC_MULTI_SESSION | CDC_MCN |
CDC_MEDIA_CHANGED | CDC_PLAY_AUDIO | CDC_RESET |
- CDC_IOCTLS | CDC_DRIVE_STATUS | CDC_CD_R |
+ CDC_DRIVE_STATUS | CDC_CD_R |
CDC_CD_RW | CDC_DVD | CDC_DVD_R| CDC_DVD_RAM |
CDC_GENERIC_PACKET | CDC_MO_DRIVE | CDC_MRW |
CDC_MRW_W | CDC_RAM,
@@ -3367,6 +3321,45 @@ static int idecd_release(struct inode * inode, struct file * file)
return 0;
}
+static int idecd_set_spindown(struct cdrom_device_info *cdi, unsigned long arg)
+{
+ struct packet_command cgc;
+ char buffer[16];
+ int stat;
+ char spindown;
+
+ if (copy_from_user(&spindown, (void __user *)arg, sizeof(char)))
+ return -EFAULT;
+
+ init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
+
+ stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0);
+ if (stat)
+ return stat;
+
+ buffer[11] = (buffer[11] & 0xf0) | (spindown & 0x0f);
+ return cdrom_mode_select(cdi, &cgc);
+}
+
+static int idecd_get_spindown(struct cdrom_device_info *cdi, unsigned long arg)
+{
+ struct packet_command cgc;
+ char buffer[16];
+ int stat;
+ char spindown;
+
+ init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_UNKNOWN);
+
+ stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CDROM_PAGE, 0);
+ if (stat)
+ return stat;
+
+ spindown = buffer[11] & 0x0f;
+ if (copy_to_user((void __user *)arg, &spindown, sizeof (char)))
+ return -EFAULT;
+ return 0;
+}
+
static int idecd_ioctl (struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
@@ -3374,7 +3367,16 @@ static int idecd_ioctl (struct inode *inode, struct file *file,
struct cdrom_info *info = ide_cd_g(bdev->bd_disk);
int err;
- err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg);
+ switch (cmd) {
+ case CDROMSETSPINDOWN:
+ return idecd_set_spindown(&info->devinfo, arg);
+ case CDROMGETSPINDOWN:
+ return idecd_get_spindown(&info->devinfo, arg);
+ default:
+ break;
+ }
+
+ err = generic_ide_ioctl(info->drive, file, bdev, cmd, arg);
if (err == -EINVAL)
err = cdrom_ioctl(file, &info->devinfo, inode, cmd, arg);
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 09086b8b648..ccf528d733b 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -60,6 +60,7 @@
#include <linux/genhd.h>
#include <linux/slab.h>
#include <linux/delay.h>
+#include <linux/mutex.h>
#define _IDE_DISK
@@ -78,7 +79,7 @@ struct ide_disk_obj {
struct kref kref;
};
-static DECLARE_MUTEX(idedisk_ref_sem);
+static DEFINE_MUTEX(idedisk_ref_mutex);
#define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref)
@@ -89,11 +90,11 @@ static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
{
struct ide_disk_obj *idkp = NULL;
- down(&idedisk_ref_sem);
+ mutex_lock(&idedisk_ref_mutex);
idkp = ide_disk_g(disk);
if (idkp)
kref_get(&idkp->kref);
- up(&idedisk_ref_sem);
+ mutex_unlock(&idedisk_ref_mutex);
return idkp;
}
@@ -101,9 +102,9 @@ static void ide_disk_release(struct kref *);
static void ide_disk_put(struct ide_disk_obj *idkp)
{
- down(&idedisk_ref_sem);
+ mutex_lock(&idedisk_ref_mutex);
kref_put(&idkp->kref, ide_disk_release);
- up(&idedisk_ref_sem);
+ mutex_unlock(&idedisk_ref_mutex);
}
/*
@@ -977,8 +978,6 @@ static void idedisk_setup (ide_drive_t *drive)
ide_dma_verbose(drive);
printk("\n");
- drive->no_io_32bit = id->dword_io ? 1 : 0;
-
/* write cache enabled? */
if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5)))
drive->wcache = 1;
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 0523da77425..c481be8b807 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -175,7 +175,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive)
if (rq->rq_disk) {
ide_driver_t *drv;
- drv = *(ide_driver_t **)rq->rq_disk->private_data;;
+ drv = *(ide_driver_t **)rq->rq_disk->private_data;
drv->end_request(drive, 1, rq->nr_sectors);
} else
ide_end_request(drive, 1, rq->nr_sectors);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 1f8db9ac05d..a53e3ce4a14 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -98,6 +98,7 @@
#include <linux/cdrom.h>
#include <linux/ide.h>
#include <linux/bitops.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
@@ -517,7 +518,7 @@ typedef struct {
u8 reserved[4];
} idefloppy_mode_parameter_header_t;
-static DECLARE_MUTEX(idefloppy_ref_sem);
+static DEFINE_MUTEX(idefloppy_ref_mutex);
#define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref)
@@ -528,11 +529,11 @@ static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
{
struct ide_floppy_obj *floppy = NULL;
- down(&idefloppy_ref_sem);
+ mutex_lock(&idefloppy_ref_mutex);
floppy = ide_floppy_g(disk);
if (floppy)
kref_get(&floppy->kref);
- up(&idefloppy_ref_sem);
+ mutex_unlock(&idefloppy_ref_mutex);
return floppy;
}
@@ -540,9 +541,9 @@ static void ide_floppy_release(struct kref *);
static void ide_floppy_put(struct ide_floppy_obj *floppy)
{
- down(&idefloppy_ref_sem);
+ mutex_lock(&idefloppy_ref_mutex);
kref_put(&floppy->kref, ide_floppy_release);
- up(&idefloppy_ref_sem);
+ mutex_unlock(&idefloppy_ref_mutex);
}
/*
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 427d1c20417..1b7b4c531bc 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -858,6 +858,15 @@ static void probe_hwif(ide_hwif_t *hwif)
}
}
}
+
+ for (unit = 0; unit < MAX_DRIVES; ++unit) {
+ ide_drive_t *drive = &hwif->drives[unit];
+
+ if (hwif->no_io_32bit)
+ drive->no_io_32bit = 1;
+ else
+ drive->no_io_32bit = drive->id->dword_io ? 1 : 0;
+ }
}
static int hwif_init(ide_hwif_t *hwif);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 0101d0def7c..ebc59064b47 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -443,6 +443,7 @@
#include <linux/smp_lock.h>
#include <linux/completion.h>
#include <linux/bitops.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
@@ -1011,7 +1012,7 @@ typedef struct ide_tape_obj {
int debug_level;
} idetape_tape_t;
-static DECLARE_MUTEX(idetape_ref_sem);
+static DEFINE_MUTEX(idetape_ref_mutex);
static struct class *idetape_sysfs_class;
@@ -1024,11 +1025,11 @@ static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
{
struct ide_tape_obj *tape = NULL;
- down(&idetape_ref_sem);
+ mutex_lock(&idetape_ref_mutex);
tape = ide_tape_g(disk);
if (tape)
kref_get(&tape->kref);
- up(&idetape_ref_sem);
+ mutex_unlock(&idetape_ref_mutex);
return tape;
}
@@ -1036,9 +1037,9 @@ static void ide_tape_release(struct kref *);
static void ide_tape_put(struct ide_tape_obj *tape)
{
- down(&idetape_ref_sem);
+ mutex_lock(&idetape_ref_mutex);
kref_put(&tape->kref, ide_tape_release);
- up(&idetape_ref_sem);
+ mutex_unlock(&idetape_ref_mutex);
}
/*
@@ -1290,11 +1291,11 @@ static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i)
{
struct ide_tape_obj *tape = NULL;
- down(&idetape_ref_sem);
+ mutex_lock(&idetape_ref_mutex);
tape = idetape_devs[i];
if (tape)
kref_get(&tape->kref);
- up(&idetape_ref_sem);
+ mutex_unlock(&idetape_ref_mutex);
return tape;
}
@@ -4870,11 +4871,11 @@ static int ide_tape_probe(ide_drive_t *drive)
drive->driver_data = tape;
- down(&idetape_ref_sem);
+ mutex_lock(&idetape_ref_mutex);
for (minor = 0; idetape_devs[minor]; minor++)
;
idetape_devs[minor] = tape;
- up(&idetape_ref_sem);
+ mutex_unlock(&idetape_ref_mutex);
idetape_setup(drive, tape, minor);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index b2cc43702f6..3fdab563fec 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -2058,7 +2058,7 @@ static void __init parse_options (char *line)
}
}
-int init_module (void)
+int __init init_module (void)
{
parse_options(options);
return ide_init();
diff --git a/drivers/input/serio/hil_mlc.c b/drivers/input/serio/hil_mlc.c
index 5704204964a..ea499783fb1 100644
--- a/drivers/input/serio/hil_mlc.c
+++ b/drivers/input/serio/hil_mlc.c
@@ -556,7 +556,7 @@ static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) {
do_gettimeofday(&(mlc->instart));
mlc->icount = 15;
memset(mlc->ipacket, 0, 16 * sizeof(hil_packet));
- if (down_trylock(&(mlc->isem))) BUG();
+ BUG_ON(down_trylock(&(mlc->isem)));
return;
}
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 8c12a974b41..a81f987978c 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -23,6 +23,7 @@
#include <linux/slab.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
+#include <linux/interrupt.h>
#ifdef CONFIG_ARM
#include <asm/mach-types.h>
diff --git a/drivers/isdn/capi/kcapi.c b/drivers/isdn/capi/kcapi.c
index feec40cf590..8c4fcb9027b 100644
--- a/drivers/isdn/capi/kcapi.c
+++ b/drivers/isdn/capi/kcapi.c
@@ -32,6 +32,7 @@
#ifdef CONFIG_AVMB1_COMPAT
#include <linux/b1lli.h>
#endif
+#include <linux/mutex.h>
static char *revision = "$Revision: 1.1.2.8 $";
@@ -66,7 +67,7 @@ LIST_HEAD(capi_drivers);
DEFINE_RWLOCK(capi_drivers_list_lock);
static DEFINE_RWLOCK(application_lock);
-static DECLARE_MUTEX(controller_sem);
+static DEFINE_MUTEX(controller_mutex);
struct capi20_appl *capi_applications[CAPI_MAXAPPL];
struct capi_ctr *capi_cards[CAPI_MAXCONTR];
@@ -395,20 +396,20 @@ attach_capi_ctr(struct capi_ctr *card)
{
int i;
- down(&controller_sem);
+ mutex_lock(&controller_mutex);
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (capi_cards[i] == NULL)
break;
}
if (i == CAPI_MAXCONTR) {
- up(&controller_sem);
+ mutex_unlock(&controller_mutex);
printk(KERN_ERR "kcapi: out of controller slots\n");
return -EBUSY;
}
capi_cards[i] = card;
- up(&controller_sem);
+ mutex_unlock(&controller_mutex);
card->nrecvctlpkt = 0;
card->nrecvdatapkt = 0;
@@ -531,13 +532,13 @@ u16 capi20_register(struct capi20_appl *ap)
write_unlock_irqrestore(&application_lock, flags);
- down(&controller_sem);
+ mutex_lock(&controller_mutex);
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
continue;
register_appl(capi_cards[i], applid, &ap->rparam);
}
- up(&controller_sem);
+ mutex_unlock(&controller_mutex);
if (showcapimsgs & 1) {
printk(KERN_DEBUG "kcapi: appl %d up\n", applid);
@@ -560,13 +561,13 @@ u16 capi20_release(struct capi20_appl *ap)
capi_applications[ap->applid - 1] = NULL;
write_unlock_irqrestore(&application_lock, flags);
- down(&controller_sem);
+ mutex_lock(&controller_mutex);
for (i = 0; i < CAPI_MAXCONTR; i++) {
if (!capi_cards[i] || capi_cards[i]->cardstate != CARD_RUNNING)
continue;
release_appl(capi_cards[i], ap->applid);
}
- up(&controller_sem);
+ mutex_unlock(&controller_mutex);
flush_scheduled_work();
skb_queue_purge(&ap->recv_queue);
diff --git a/drivers/isdn/hardware/avm/b1dma.c b/drivers/isdn/hardware/avm/b1dma.c
index 91dd0551fc7..4d64e5cbcdb 100644
--- a/drivers/isdn/hardware/avm/b1dma.c
+++ b/drivers/isdn/hardware/avm/b1dma.c
@@ -39,7 +39,7 @@ MODULE_AUTHOR("Carsten Paeth");
MODULE_LICENSE("GPL");
static int suppress_pollack = 0;
-MODULE_PARM(suppress_pollack, "0-1i");
+module_param(suppress_pollack, bool, 0);
/* ------------------------------------------------------------- */
diff --git a/drivers/isdn/hardware/avm/b1isa.c b/drivers/isdn/hardware/avm/b1isa.c
index 38bd4dfecbd..80fb488848b 100644
--- a/drivers/isdn/hardware/avm/b1isa.c
+++ b/drivers/isdn/hardware/avm/b1isa.c
@@ -169,8 +169,8 @@ static struct pci_dev isa_dev[MAX_CARDS];
static int io[MAX_CARDS];
static int irq[MAX_CARDS];
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CARDS) "i");
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
MODULE_PARM_DESC(io, "I/O base address(es)");
MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c
index 724aac2c1cc..f7253b2136e 100644
--- a/drivers/isdn/hardware/avm/c4.c
+++ b/drivers/isdn/hardware/avm/c4.c
@@ -50,7 +50,7 @@ MODULE_DEVICE_TABLE(pci, c4_pci_tbl);
MODULE_DESCRIPTION("CAPI4Linux: Driver for AVM C2/C4 cards");
MODULE_AUTHOR("Carsten Paeth");
MODULE_LICENSE("GPL");
-MODULE_PARM(suppress_pollack, "0-1i");
+module_param(suppress_pollack, bool, 0);
/* ------------------------------------------------------------- */
diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c
index 3b701d97bdf..5a2f854d55b 100644
--- a/drivers/isdn/hardware/avm/t1isa.c
+++ b/drivers/isdn/hardware/avm/t1isa.c
@@ -519,9 +519,9 @@ static int io[MAX_CARDS];
static int irq[MAX_CARDS];
static int cardnr[MAX_CARDS];
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_CARDS) "i");
-MODULE_PARM(cardnr, "1-" __MODULE_STRING(MAX_CARDS) "i");
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
+module_param_array(cardnr, int, NULL, 0);
MODULE_PARM_DESC(io, "I/O base address(es)");
MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)");
MODULE_PARM_DESC(cardnr, "Card number(s) (as jumpered)");
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c
index df9d6520181..27332506f9f 100644
--- a/drivers/isdn/hisax/config.c
+++ b/drivers/isdn/hisax/config.c
@@ -25,7 +25,6 @@
#include <linux/workqueue.h>
#include <linux/interrupt.h>
#define HISAX_STATUS_BUFSIZE 4096
-#define INCLUDE_INLINE_FUNCS
/*
* This structure array contains one entry per card. An entry looks
diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c
index 110e9fd669c..f8ca4b32333 100644
--- a/drivers/isdn/hisax/elsa.c
+++ b/drivers/isdn/hisax/elsa.c
@@ -108,7 +108,6 @@ static const char *ITACVer[] =
#define ELSA_ASSIGN 4
#define RS_ISR_PASS_LIMIT 256
-#define _INLINE_ inline
#define FLG_MODEM_ACTIVE 1
/* IPAC AUX */
#define ELSA_IPAC_LINE_LED 0x40 /* Bit 6 Gelbe LED */
diff --git a/drivers/isdn/hysdn/boardergo.c b/drivers/isdn/hysdn/boardergo.c
index e19a01a305a..48d134be990 100644
--- a/drivers/isdn/hysdn/boardergo.c
+++ b/drivers/isdn/hysdn/boardergo.c
@@ -38,8 +38,8 @@ ergo_interrupt(int intno, void *dev_id, struct pt_regs *regs)
{
hysdn_card *card = dev_id; /* parameter from irq */
tErgDpram *dpr;
- ulong flags;
- uchar volatile b;
+ unsigned long flags;
+ unsigned char volatile b;
if (!card)
return IRQ_NONE; /* error -> spurious interrupt */
@@ -77,7 +77,7 @@ ergo_irq_bh(hysdn_card * card)
{
tErgDpram *dpr;
int again;
- ulong flags;
+ unsigned long flags;
if (card->state != CARD_STATE_RUN)
return; /* invalid call */
@@ -131,8 +131,8 @@ ergo_irq_bh(hysdn_card * card)
static void
ergo_stopcard(hysdn_card * card)
{
- ulong flags;
- uchar val;
+ unsigned long flags;
+ unsigned char val;
hysdn_net_release(card); /* first release the net device if existing */
#ifdef CONFIG_HYSDN_CAPI
@@ -157,7 +157,7 @@ ergo_stopcard(hysdn_card * card)
static void
ergo_set_errlog_state(hysdn_card * card, int on)
{
- ulong flags;
+ unsigned long flags;
if (card->state != CARD_STATE_RUN) {
card->err_log_state = ERRLOG_STATE_OFF; /* must be off */
@@ -217,9 +217,10 @@ ergo_testram(hysdn_card * card)
/* Negative return values are interpreted as errors. */
/*****************************************************************************/
static int
-ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs)
+ergo_writebootimg(struct HYSDN_CARD *card, unsigned char *buf,
+ unsigned long offs)
{
- uchar *dst;
+ unsigned char *dst;
tErgDpram *dpram;
int cnt = (BOOT_IMG_SIZE >> 2); /* number of words to move and swap (byte order!) */
@@ -264,14 +265,14 @@ ergo_writebootimg(struct HYSDN_CARD *card, uchar * buf, ulong offs)
/* case of errors a negative error value is returned. */
/********************************************************************************/
static int
-ergo_writebootseq(struct HYSDN_CARD *card, uchar * buf, int len)
+ergo_writebootseq(struct HYSDN_CARD *card, unsigned char *buf, int len)
{
tDpramBootSpooler *sp = (tDpramBootSpooler *) card->dpram;
- uchar *dst;
- uchar buflen;
+ unsigned char *dst;
+ unsigned char buflen;
int nr_write;
- uchar tmp_rdptr;
- uchar wr_mirror;
+ unsigned char tmp_rdptr;
+ unsigned char wr_mirror;
int i;
if (card->debug_flags & LOG_POF_CARD)
@@ -330,7 +331,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
{
tErgDpram *dpr = card->dpram; /* pointer to DPRAM structure */
int timecnt = 10000 / 50; /* timeout is 10 secs max. */
- ulong flags;
+ unsigned long flags;
int msg_size;
int i;
@@ -345,7 +346,7 @@ ergo_waitpofready(struct HYSDN_CARD *card)
if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
(dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
(dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
- ((*(ulong *) dpr->ToPcBuf) != RDY_MAGIC))
+ ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
break; /* an error occurred */
/* Check for additional data delivered during SysReady */
diff --git a/drivers/isdn/hysdn/boardergo.h b/drivers/isdn/hysdn/boardergo.h
index b56ff0889ea..c59422aa8c3 100644
--- a/drivers/isdn/hysdn/boardergo.h
+++ b/drivers/isdn/hysdn/boardergo.h
@@ -23,36 +23,36 @@
/* following DPRAM layout copied from OS2-driver boarderg.h */
typedef struct ErgDpram_tag {
-/*0000 */ uchar ToHyBuf[ERG_TO_HY_BUF_SIZE];
-/*0E00 */ uchar ToPcBuf[ERG_TO_PC_BUF_SIZE];
+/*0000 */ unsigned char ToHyBuf[ERG_TO_HY_BUF_SIZE];
+/*0E00 */ unsigned char ToPcBuf[ERG_TO_PC_BUF_SIZE];
- /*1C00 */ uchar bSoftUart[SIZE_RSV_SOFT_UART];
+ /*1C00 */ unsigned char bSoftUart[SIZE_RSV_SOFT_UART];
/* size 0x1B0 */
- /*1DB0 *//* tErrLogEntry */ uchar volatile ErrLogMsg[64];
+ /*1DB0 *//* tErrLogEntry */ unsigned char volatile ErrLogMsg[64];
/* size 64 bytes */
- /*1DB0 ulong ulErrType; */
- /*1DB4 ulong ulErrSubtype; */
- /*1DB8 ulong ucTextSize; */
- /*1DB9 ulong ucText[ERRLOG_TEXT_SIZE]; *//* ASCIIZ of len ucTextSize-1 */
+ /*1DB0 unsigned long ulErrType; */
+ /*1DB4 unsigned long ulErrSubtype; */
+ /*1DB8 unsigned long ucTextSize; */
+ /*1DB9 unsigned long ucText[ERRLOG_TEXT_SIZE]; *//* ASCIIZ of len ucTextSize-1 */
/*1DF0 */
-/*1DF0 */ word volatile ToHyChannel;
-/*1DF2 */ word volatile ToHySize;
- /*1DF4 */ uchar volatile ToHyFlag;
+/*1DF0 */ unsigned short volatile ToHyChannel;
+/*1DF2 */ unsigned short volatile ToHySize;
+ /*1DF4 */ unsigned char volatile ToHyFlag;
/* !=0: msg for Hy waiting */
- /*1DF5 */ uchar volatile ToPcFlag;
+ /*1DF5 */ unsigned char volatile ToPcFlag;
/* !=0: msg for PC waiting */
-/*1DF6 */ word volatile ToPcChannel;
-/*1DF8 */ word volatile ToPcSize;
- /*1DFA */ uchar bRes1DBA[0x1E00 - 0x1DFA];
+/*1DF6 */ unsigned short volatile ToPcChannel;
+/*1DF8 */ unsigned short volatile ToPcSize;
+ /*1DFA */ unsigned char bRes1DBA[0x1E00 - 0x1DFA];
/* 6 bytes */
-/*1E00 */ uchar bRestOfEntryTbl[0x1F00 - 0x1E00];
-/*1F00 */ ulong TrapTable[62];
- /*1FF8 */ uchar bRes1FF8[0x1FFB - 0x1FF8];
+/*1E00 */ unsigned char bRestOfEntryTbl[0x1F00 - 0x1E00];
+/*1F00 */ unsigned long TrapTable[62];
+ /*1FF8 */ unsigned char bRes1FF8[0x1FFB - 0x1FF8];
/* low part of reset vetor */
-/*1FFB */ uchar ToPcIntMetro;
+/*1FFB */ unsigned char ToPcIntMetro;
/* notes:
* - metro has 32-bit boot ram - accessing
* ToPcInt and ToHyInt would be the same;
@@ -65,16 +65,16 @@ typedef struct ErgDpram_tag {
* so E1 side should NOT change this byte
* when writing!
*/
-/*1FFC */ uchar volatile ToHyNoDpramErrLog;
+/*1FFC */ unsigned char volatile ToHyNoDpramErrLog;
/* note: ToHyNoDpramErrLog is used to inform
* boot loader, not to use DPRAM based
* ErrLog; when DOS driver is rewritten
* this becomes obsolete
*/
-/*1FFD */ uchar bRes1FFD;
- /*1FFE */ uchar ToPcInt;
+/*1FFD */ unsigned char bRes1FFD;
+ /*1FFE */ unsigned char ToPcInt;
/* E1_intclear; on CHAMP2: E1_intset */
- /*1FFF */ uchar ToHyInt;
+ /*1FFF */ unsigned char ToHyInt;
/* E1_intset; on CHAMP2: E1_intclear */
} tErgDpram;
diff --git a/drivers/isdn/hysdn/hycapi.c b/drivers/isdn/hysdn/hycapi.c
index acc1d3cceeb..6bac43cc91b 100644
--- a/drivers/isdn/hysdn/hycapi.c
+++ b/drivers/isdn/hysdn/hycapi.c
@@ -31,7 +31,7 @@
static char hycapi_revision[]="$Revision: 1.8.6.4 $";
unsigned int hycapi_enable = 0xffffffff;
-MODULE_PARM(hycapi_enable, "i");
+module_param(hycapi_enable, uint, 0);
typedef struct _hycapi_appl {
unsigned int ctrl_mask;
@@ -523,7 +523,7 @@ New nccis are created if necessary.
*******************************************************************/
void
-hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len)
+hycapi_rx_capipkt(hysdn_card * card, unsigned char *buf, unsigned short len)
{
struct sk_buff *skb;
hycapictrl_info *cinfo = card->hyctrlinfo;
diff --git a/drivers/isdn/hysdn/hysdn_boot.c b/drivers/isdn/hysdn/hysdn_boot.c
index 7bfba196f31..6d0eb0f42fc 100644
--- a/drivers/isdn/hysdn/hysdn_boot.c
+++ b/drivers/isdn/hysdn/hysdn_boot.c
@@ -30,17 +30,17 @@
/* needed during boot and so allocated dynamically. */
/************************************************************/
struct boot_data {
- word Cryptor; /* for use with Decrypt function */
- word Nrecs; /* records remaining in file */
- uchar pof_state; /* actual state of read handler */
- uchar is_crypted; /* card data is crypted */
+ unsigned short Cryptor; /* for use with Decrypt function */
+ unsigned short Nrecs; /* records remaining in file */
+ unsigned char pof_state;/* actual state of read handler */
+ unsigned char is_crypted;/* card data is crypted */
int BufSize; /* actual number of bytes bufferd */
int last_error; /* last occurred error */
- word pof_recid; /* actual pof recid */
- ulong pof_reclen; /* total length of pof record data */
- ulong pof_recoffset; /* actual offset inside pof record */
+ unsigned short pof_recid;/* actual pof recid */
+ unsigned long pof_reclen;/* total length of pof record data */
+ unsigned long pof_recoffset;/* actual offset inside pof record */
union {
- uchar BootBuf[BOOT_BUF_SIZE]; /* buffer as byte count */
+ unsigned char BootBuf[BOOT_BUF_SIZE];/* buffer as byte count */
tPofRecHdr PofRecHdr; /* header for actual record/chunk */
tPofFileHdr PofFileHdr; /* header from POF file */
tPofTimeStamp PofTime; /* time information */
@@ -69,11 +69,11 @@ StartDecryption(struct boot_data *boot)
static void
DecryptBuf(struct boot_data *boot, int cnt)
{
- uchar *bufp = boot->buf.BootBuf;
+ unsigned char *bufp = boot->buf.BootBuf;
while (cnt--) {
boot->Cryptor = (boot->Cryptor >> 1) ^ ((boot->Cryptor & 1U) ? CRYPT_FEEDTERM : 0);
- *bufp++ ^= (uchar) boot->Cryptor;
+ *bufp++ ^= (unsigned char)boot->Cryptor;
}
} /* DecryptBuf */
@@ -86,7 +86,7 @@ pof_handle_data(hysdn_card * card, int datlen)
{
struct boot_data *boot = card->boot; /* pointer to boot specific data */
long l;
- uchar *imgp;
+ unsigned char *imgp;
int img_len;
/* handle the different record types */
@@ -197,7 +197,7 @@ pof_write_buffer(hysdn_card * card, int datlen)
break;
}
/* Setup the new state and vars */
- boot->Nrecs = (word) (boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */
+ boot->Nrecs = (unsigned short)(boot->buf.PofFileHdr.N_PofRecs); /* limited to 65535 */
boot->pof_state = POF_READ_TAG_HEAD; /* now start with single tags */
boot->last_error = sizeof(tPofRecHdr); /* new length */
break;
@@ -268,7 +268,7 @@ pof_write_buffer(hysdn_card * card, int datlen)
/* occurred. Additionally the pointer to the buffer data area is set on success */
/*******************************************************************************/
int
-pof_write_open(hysdn_card * card, uchar ** bufp)
+pof_write_open(hysdn_card * card, unsigned char **bufp)
{
struct boot_data *boot; /* pointer to boot specific data */
@@ -335,7 +335,7 @@ pof_write_close(hysdn_card * card)
/* when POF has been booted. A return value of 0 is used if no error occurred. */
/*********************************************************************************/
int
-EvalSysrTokData(hysdn_card * card, uchar * cp, int len)
+EvalSysrTokData(hysdn_card *card, unsigned char *cp, int len)
{
u_char *p;
u_char crc;
diff --git a/drivers/isdn/hysdn/hysdn_defs.h b/drivers/isdn/hysdn/hysdn_defs.h
index 432f6f99089..3a9b29b38bc 100644
--- a/drivers/isdn/hysdn/hysdn_defs.h
+++ b/drivers/isdn/hysdn/hysdn_defs.h
@@ -20,14 +20,6 @@
#include <linux/workqueue.h>
#include <linux/skbuff.h>
-/****************************/
-/* storage type definitions */
-/****************************/
-#define uchar unsigned char
-#define uint unsigned int
-#define ulong unsigned long
-#define word unsigned short
-
#include "ince1pc.h"
#ifdef CONFIG_HYSDN_CAPI
@@ -147,18 +139,18 @@ typedef struct HYSDN_CARD {
/* general variables for the cards */
int myid; /* own driver card id */
- uchar bus; /* pci bus the card is connected to */
- uchar devfn; /* slot+function bit encoded */
- word subsysid; /* PCI subsystem id */
- uchar brdtype; /* type of card */
- uint bchans; /* number of available B-channels */
- uint faxchans; /* number of available fax-channels */
- uchar mac_addr[6]; /* MAC Address read from card */
- uint irq; /* interrupt number */
- uint iobase; /* IO-port base address */
- ulong plxbase; /* PLX memory base */
- ulong membase; /* DPRAM memory base */
- ulong memend; /* DPRAM memory end */
+ unsigned char bus; /* pci bus the card is connected to */
+ unsigned char devfn; /* slot+function bit encoded */
+ unsigned short subsysid;/* PCI subsystem id */
+ unsigned char brdtype; /* type of card */
+ unsigned int bchans; /* number of available B-channels */
+ unsigned int faxchans; /* number of available fax-channels */
+ unsigned char mac_addr[6];/* MAC Address read from card */
+ unsigned int irq; /* interrupt number */
+ unsigned int iobase; /* IO-port base address */
+ unsigned long plxbase; /* PLX memory base */
+ unsigned long membase; /* DPRAM memory base */
+ unsigned long memend; /* DPRAM memory end */
void *dpram; /* mapped dpram */
int state; /* actual state of card -> CARD_STATE_** */
struct HYSDN_CARD *next; /* pointer to next card */
@@ -168,26 +160,26 @@ typedef struct HYSDN_CARD {
void *procconf; /* pointer to procconf filesystem specific data */
/* debugging and logging */
- uchar err_log_state; /* actual error log state of the card */
- ulong debug_flags; /* tells what should be debugged and where */
+ unsigned char err_log_state;/* actual error log state of the card */
+ unsigned long debug_flags;/* tells what should be debugged and where */
void (*set_errlog_state) (struct HYSDN_CARD *, int);
/* interrupt handler + interrupt synchronisation */
struct work_struct irq_queue; /* interrupt task queue */
- uchar volatile irq_enabled; /* interrupt enabled if != 0 */
- uchar volatile hw_lock; /* hardware is currently locked -> no access */
+ unsigned char volatile irq_enabled;/* interrupt enabled if != 0 */
+ unsigned char volatile hw_lock;/* hardware is currently locked -> no access */
/* boot process */
void *boot; /* pointer to boot private data */
- int (*writebootimg) (struct HYSDN_CARD *, uchar *, ulong);
- int (*writebootseq) (struct HYSDN_CARD *, uchar *, int);
+ int (*writebootimg) (struct HYSDN_CARD *, unsigned char *, unsigned long);
+ int (*writebootseq) (struct HYSDN_CARD *, unsigned char *, int);
int (*waitpofready) (struct HYSDN_CARD *);
int (*testram) (struct HYSDN_CARD *);
/* scheduler for data transfer (only async parts) */
- uchar async_data[256]; /* async data to be sent (normally for config) */
- word volatile async_len; /* length of data to sent */
- word volatile async_channel; /* channel number for async transfer */
+ unsigned char async_data[256];/* async data to be sent (normally for config) */
+ unsigned short volatile async_len;/* length of data to sent */
+ unsigned short volatile async_channel;/* channel number for async transfer */
int volatile async_busy; /* flag != 0 sending in progress */
int volatile net_tx_busy; /* a network packet tx is in progress */
@@ -251,15 +243,18 @@ extern int ergo_inithardware(hysdn_card * card); /* get hardware -> module init
/* hysdn_boot.c */
extern int pof_write_close(hysdn_card *); /* close proc file after writing pof */
-extern int pof_write_open(hysdn_card *, uchar **); /* open proc file for writing pof */
+extern int pof_write_open(hysdn_card *, unsigned char **); /* open proc file for writing pof */
extern int pof_write_buffer(hysdn_card *, int); /* write boot data to card */
-extern int EvalSysrTokData(hysdn_card *, uchar *, int); /* Check Sysready Token Data */
+extern int EvalSysrTokData(hysdn_card *, unsigned char *, int); /* Check Sysready Token Data */
/* hysdn_sched.c */
-extern int hysdn_sched_tx(hysdn_card *, uchar *, word volatile *, word volatile *,
- word);
-extern int hysdn_sched_rx(hysdn_card *, uchar *, word, word);
-extern int hysdn_tx_cfgline(hysdn_card *, uchar *, word); /* send one cfg line */
+extern int hysdn_sched_tx(hysdn_card *, unsigned char *,
+ unsigned short volatile *, unsigned short volatile *,
+ unsigned short);
+extern int hysdn_sched_rx(hysdn_card *, unsigned char *, unsigned short,
+ unsigned short);
+extern int hysdn_tx_cfgline(hysdn_card *, unsigned char *,
+ unsigned short); /* send one cfg line */
/* hysdn_net.c */
extern unsigned int hynet_enable;
@@ -269,14 +264,16 @@ extern int hysdn_net_release(hysdn_card *); /* delete the device */
extern char *hysdn_net_getname(hysdn_card *); /* get name of net interface */
extern void hysdn_tx_netack(hysdn_card *); /* acknowledge a packet tx */
extern struct sk_buff *hysdn_tx_netget(hysdn_card *); /* get next network packet */
-extern void hysdn_rx_netpkt(hysdn_card *, uchar *, word); /* rxed packet from network */
+extern void hysdn_rx_netpkt(hysdn_card *, unsigned char *,
+ unsigned short); /* rxed packet from network */
#ifdef CONFIG_HYSDN_CAPI
extern unsigned int hycapi_enable;
extern int hycapi_capi_create(hysdn_card *); /* create a new capi device */
extern int hycapi_capi_release(hysdn_card *); /* delete the device */
extern int hycapi_capi_stop(hysdn_card *card); /* suspend */
-extern void hycapi_rx_capipkt(hysdn_card * card, uchar * buf, word len);
+extern void hycapi_rx_capipkt(hysdn_card * card, unsigned char * buf,
+ unsigned short len);
extern void hycapi_tx_capiack(hysdn_card * card);
extern struct sk_buff *hycapi_tx_capiget(hysdn_card *card);
extern int hycapi_init(void);
diff --git a/drivers/isdn/hysdn/hysdn_init.c b/drivers/isdn/hysdn/hysdn_init.c
index cb791f8e793..b75ac5af236 100644
--- a/drivers/isdn/hysdn/hysdn_init.c
+++ b/drivers/isdn/hysdn/hysdn_init.c
@@ -41,8 +41,8 @@ hysdn_card *card_root = NULL; /* pointer to first card */
/* the last entry contains all 0 */
/**********************************************/
static struct {
- word subid; /* PCI sub id */
- uchar cardtyp; /* card type assigned */
+ unsigned short subid; /* PCI sub id */
+ unsigned char cardtyp; /* card type assigned */
} pci_subid_map[] = {
{
diff --git a/drivers/isdn/hysdn/hysdn_net.c b/drivers/isdn/hysdn/hysdn_net.c
index aa01628d74c..d205249a124 100644
--- a/drivers/isdn/hysdn/hysdn_net.c
+++ b/drivers/isdn/hysdn/hysdn_net.c
@@ -24,7 +24,7 @@
#include "hysdn_defs.h"
unsigned int hynet_enable = 0xffffffff;
-MODULE_PARM(hynet_enable, "i");
+module_param(hynet_enable, uint, 0);
/* store the actual version for log reporting */
char *hysdn_net_revision = "$Revision: 1.8.6.4 $";
@@ -83,12 +83,12 @@ net_open(struct net_device *dev)
/* Fill in the MAC-level header (if not already set) */
if (!card->mac_addr[0]) {
- for (i = 0; i < ETH_ALEN - sizeof(ulong); i++)
+ for (i = 0; i < ETH_ALEN - sizeof(unsigned long); i++)
dev->dev_addr[i] = 0xfc;
if ((in_dev = dev->ip_ptr) != NULL) {
struct in_ifaddr *ifa = in_dev->ifa_list;
if (ifa != NULL)
- memcpy(dev->dev_addr + (ETH_ALEN - sizeof(ulong)), &ifa->ifa_local, sizeof(ulong));
+ memcpy(dev->dev_addr + (ETH_ALEN - sizeof(unsigned long)), &ifa->ifa_local, sizeof(unsigned long));
}
} else
memcpy(dev->dev_addr, card->mac_addr, ETH_ALEN);
@@ -197,7 +197,7 @@ hysdn_tx_netack(hysdn_card * card)
/* we got a packet from the network, go and queue it */
/*****************************************************/
void
-hysdn_rx_netpkt(hysdn_card * card, uchar * buf, word len)
+hysdn_rx_netpkt(hysdn_card * card, unsigned char *buf, unsigned short len)
{
struct net_local *lp = card->netif;
struct sk_buff *skb;
diff --git a/drivers/isdn/hysdn/hysdn_pof.h b/drivers/isdn/hysdn/hysdn_pof.h
index 6cd81b9b08b..a368d6caca0 100644
--- a/drivers/isdn/hysdn/hysdn_pof.h
+++ b/drivers/isdn/hysdn/hysdn_pof.h
@@ -47,20 +47,20 @@
/*--------------------------------------POF file record structs------------*/
typedef struct PofFileHdr_tag { /* Pof file header */
-/*00 */ ulong Magic __attribute__((packed));
-/*04 */ ulong N_PofRecs __attribute__((packed));
+/*00 */ unsigned long Magic __attribute__((packed));
+/*04 */ unsigned long N_PofRecs __attribute__((packed));
/*08 */
} tPofFileHdr;
typedef struct PofRecHdr_tag { /* Pof record header */
-/*00 */ word PofRecId __attribute__((packed));
-/*02 */ ulong PofRecDataLen __attribute__((packed));
+/*00 */ unsigned short PofRecId __attribute__((packed));
+/*02 */ unsigned long PofRecDataLen __attribute__((packed));
/*06 */
} tPofRecHdr;
typedef struct PofTimeStamp_tag {
-/*00 */ ulong UnixTime __attribute__((packed));
- /*04 */ uchar DateTimeText[0x28] __attribute__((packed));
+/*00 */ unsigned long UnixTime __attribute__((packed));
+ /*04 */ unsigned char DateTimeText[0x28] __attribute__((packed));
/* =40 */
/*2C */
} tPofTimeStamp;
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c
index 40e56143c76..8e2b03889f3 100644
--- a/drivers/isdn/hysdn/hysdn_procconf.c
+++ b/drivers/isdn/hysdn/hysdn_procconf.c
@@ -36,9 +36,9 @@ struct conf_writedata {
int buf_size; /* actual number of bytes in the buffer */
int needed_size; /* needed size when reading pof */
int state; /* actual interface states from above constants */
- uchar conf_line[CONF_LINE_LEN]; /* buffered conf line */
- word channel; /* active channel number */
- uchar *pof_buffer; /* buffer when writing pof */
+ unsigned char conf_line[CONF_LINE_LEN]; /* buffered conf line */
+ unsigned short channel; /* active channel number */
+ unsigned char *pof_buffer; /* buffer when writing pof */
};
/***********************************************************************/
@@ -49,7 +49,7 @@ struct conf_writedata {
static int
process_line(struct conf_writedata *cnf)
{
- uchar *cp = cnf->conf_line;
+ unsigned char *cp = cnf->conf_line;
int i;
if (cnf->card->debug_flags & LOG_CNF_LINE)
@@ -92,7 +92,7 @@ hysdn_conf_write(struct file *file, const char __user *buf, size_t count, loff_t
{
struct conf_writedata *cnf;
int i;
- uchar ch, *cp;
+ unsigned char ch, *cp;
if (!count)
return (0); /* nothing to handle */
@@ -390,7 +390,7 @@ int
hysdn_procconf_init(void)
{
hysdn_card *card;
- uchar conf_name[20];
+ unsigned char conf_name[20];
hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net);
if (!hysdn_proc_entry) {
@@ -423,7 +423,7 @@ void
hysdn_procconf_release(void)
{
hysdn_card *card;
- uchar conf_name[20];
+ unsigned char conf_name[20];
card = card_root; /* start with first card */
while (card) {
diff --git a/drivers/isdn/hysdn/hysdn_proclog.c b/drivers/isdn/hysdn/hysdn_proclog.c
index 6c26f1efabd..c4301e8338e 100644
--- a/drivers/isdn/hysdn/hysdn_proclog.c
+++ b/drivers/isdn/hysdn/hysdn_proclog.c
@@ -28,7 +28,7 @@ static void put_log_buffer(hysdn_card * card, char *cp);
/*************************************************/
struct log_data {
struct log_data *next;
- ulong usage_cnt; /* number of files still to work */
+ unsigned long usage_cnt;/* number of files still to work */
void *proc_ctrl; /* pointer to own control procdata structure */
char log_start[2]; /* log string start (final len aligned by size) */
};
@@ -42,7 +42,7 @@ struct procdata {
struct log_data *log_head, *log_tail; /* head and tail for queue */
int if_used; /* open count for interface */
int volatile del_lock; /* lock for delete operations */
- uchar logtmp[LOG_MAX_LINELEN];
+ unsigned char logtmp[LOG_MAX_LINELEN];
wait_queue_head_t rd_queue;
};
@@ -153,9 +153,9 @@ put_log_buffer(hysdn_card * card, char *cp)
static ssize_t
hysdn_log_write(struct file *file, const char __user *buf, size_t count, loff_t * off)
{
- ulong u = 0;
+ unsigned long u = 0;
int found = 0;
- uchar *cp, valbuf[128];
+ unsigned char *cp, valbuf[128];
long base = 10;
hysdn_card *card = (hysdn_card *) file->private_data;
@@ -249,7 +249,7 @@ hysdn_log_open(struct inode *ino, struct file *filep)
{
hysdn_card *card;
struct procdata *pd = NULL;
- ulong flags;
+ unsigned long flags;
lock_kernel();
card = card_root;
diff --git a/drivers/isdn/hysdn/hysdn_sched.c b/drivers/isdn/hysdn/hysdn_sched.c
index 4fa3b01707c..133032920ff 100644
--- a/drivers/isdn/hysdn/hysdn_sched.c
+++ b/drivers/isdn/hysdn/hysdn_sched.c
@@ -30,7 +30,8 @@
/* to keep the data until later. */
/*****************************************************************************/
int
-hysdn_sched_rx(hysdn_card * card, uchar * buf, word len, word chan)
+hysdn_sched_rx(hysdn_card *card, unsigned char *buf, unsigned short len,
+ unsigned short chan)
{
switch (chan) {
@@ -72,7 +73,9 @@ hysdn_sched_rx(hysdn_card * card, uchar * buf, word len, word chan)
/* sending. */
/*****************************************************************************/
int
-hysdn_sched_tx(hysdn_card * card, uchar * buf, word volatile *len, word volatile *chan, word maxlen)
+hysdn_sched_tx(hysdn_card *card, unsigned char *buf,
+ unsigned short volatile *len, unsigned short volatile *chan,
+ unsigned short maxlen)
{
struct sk_buff *skb;
@@ -145,10 +148,10 @@ hysdn_sched_tx(hysdn_card * card, uchar * buf, word volatile *len, word volatile
/* are to be sent and this happens very seldom. */
/*****************************************************************************/
int
-hysdn_tx_cfgline(hysdn_card * card, uchar * line, word chan)
+hysdn_tx_cfgline(hysdn_card *card, unsigned char *line, unsigned short chan)
{
int cnt = 50; /* timeout intervalls */
- ulong flags;
+ unsigned long flags;
if (card->debug_flags & LOG_SCHED_ASYN)
hysdn_addlog(card, "async tx-cfg chan=%d len=%d", chan, strlen(line) + 1);
diff --git a/drivers/isdn/hysdn/ince1pc.h b/drivers/isdn/hysdn/ince1pc.h
index 4a115a87c78..7a36694df6d 100644
--- a/drivers/isdn/hysdn/ince1pc.h
+++ b/drivers/isdn/hysdn/ince1pc.h
@@ -62,7 +62,7 @@
* s. RotlCRC algorithm
*
* RotlCRC algorithm:
- * ucSum= 0 1 uchar
+ * ucSum= 0 1 unsigned char
* for all NonEndTokenChunk bytes:
* ROTL(ucSum,1) rotate left by 1
* ucSum += Char; add current byte with swap around
@@ -85,13 +85,13 @@
typedef struct ErrLogEntry_tag {
-/*00 */ ulong ulErrType;
+/*00 */ unsigned long ulErrType;
-/*04 */ ulong ulErrSubtype;
+/*04 */ unsigned long ulErrSubtype;
-/*08 */ uchar ucTextSize;
+/*08 */ unsigned char ucTextSize;
- /*09 */ uchar ucText[ERRLOG_TEXT_SIZE];
+ /*09 */ unsigned char ucText[ERRLOG_TEXT_SIZE];
/* ASCIIZ of len ucTextSize-1 */
/*40 */
@@ -111,13 +111,13 @@ typedef struct ErrLogEntry_tag {
#define DPRAM_SPOOLER_DATA_SIZE 0x20
typedef struct DpramBootSpooler_tag {
-/*00 */ uchar Len;
+/*00 */ unsigned char Len;
-/*01 */ volatile uchar RdPtr;
+/*01 */ volatile unsigned char RdPtr;
-/*02 */ uchar WrPtr;
+/*02 */ unsigned char WrPtr;
-/*03 */ uchar Data[DPRAM_SPOOLER_DATA_SIZE];
+/*03 */ unsigned char Data[DPRAM_SPOOLER_DATA_SIZE];
/*23 */
} tDpramBootSpooler;
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c
index 1a19a0f8942..b9fed8a3bcc 100644
--- a/drivers/isdn/i4l/isdn_ppp.c
+++ b/drivers/isdn/i4l/isdn_ppp.c
@@ -782,7 +782,8 @@ isdn_ppp_read(int min, struct file *file, char __user *buf, int count)
is->first = b;
spin_unlock_irqrestore(&is->buflock, flags);
- copy_to_user(buf, save_buf, count);
+ if (copy_to_user(buf, save_buf, count))
+ count = -EFAULT;
kfree(save_buf);
return count;
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
index aeaa1db74bd..3585fb1f334 100644
--- a/drivers/isdn/i4l/isdn_tty.c
+++ b/drivers/isdn/i4l/isdn_tty.c
@@ -2345,12 +2345,15 @@ isdn_tty_at_cout(char *msg, modem_info * info)
u_long flags;
struct sk_buff *skb = NULL;
char *sp = NULL;
- int l = strlen(msg);
+ int l;
if (!msg) {
printk(KERN_WARNING "isdn_tty: Null-Message in isdn_tty_at_cout\n");
return;
}
+
+ l = strlen(msg);
+
spin_lock_irqsave(&info->readlock, flags);
tty = info->tty;
if ((info->flags & ISDN_ASYNC_CLOSING) || (!tty)) {
diff --git a/drivers/isdn/i4l/isdn_x25iface.c b/drivers/isdn/i4l/isdn_x25iface.c
index edf14a2aa3c..743ac4077f3 100644
--- a/drivers/isdn/i4l/isdn_x25iface.c
+++ b/drivers/isdn/i4l/isdn_x25iface.c
@@ -7,7 +7,7 @@
*
* stuff needed to support the Linux X.25 PLP code on top of devices that
* can provide a lab_b service using the concap_proto mechanism.
- * This module supports a network interface wich provides lapb_sematics
+ * This module supports a network interface which provides lapb_sematics
* -- as defined in Documentation/networking/x25-iface.txt -- to
* the upper layer and assumes that the lower layer provides a reliable
* data link service by means of the concap_device_ops callbacks.
diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
index 33d33970041..a67d31af797 100644
--- a/drivers/isdn/isdnloop/isdnloop.c
+++ b/drivers/isdn/isdnloop/isdnloop.c
@@ -22,7 +22,7 @@ static char *isdnloop_id = "loop0";
MODULE_DESCRIPTION("ISDN4Linux: Pseudo Driver that simulates an ISDN card");
MODULE_AUTHOR("Fritz Elfert");
MODULE_LICENSE("GPL");
-MODULE_PARM(isdnloop_id, "s");
+module_param(isdnloop_id, charp, 0);
MODULE_PARM_DESC(isdnloop_id, "ID-String of first card");
static int isdnloop_addcard(char *);
diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index 69596f6438e..431bd37225a 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -550,15 +550,12 @@ static void macio_pci_add_devices(struct macio_chip *chip)
*/
int macio_register_driver(struct macio_driver *drv)
{
- int count = 0;
-
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &macio_bus_type;
/* register with core */
- count = driver_register(&drv->driver);
- return count ? count : 1;
+ return driver_register(&drv->driver);
}
/**
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c
index db2ae71d07e..4eb05d7143d 100644
--- a/drivers/macintosh/smu.c
+++ b/drivers/macintosh/smu.c
@@ -629,8 +629,6 @@ static struct of_platform_driver smu_of_platform_driver =
static int __init smu_init_sysfs(void)
{
- int rc;
-
/*
* Due to sysfs bogosity, a sysdev is not a real device, so
* we should in fact create both if we want sysdev semantics
@@ -639,7 +637,7 @@ static int __init smu_init_sysfs(void)
* I'm a bit too far from figuring out how that works with those
* new chipsets, but that will come back and bite us
*/
- rc = of_register_driver(&smu_of_platform_driver);
+ of_register_driver(&smu_of_platform_driver);
return 0;
}
diff --git a/drivers/macintosh/therm_pm72.c b/drivers/macintosh/therm_pm72.c
index 4f50ee5767a..231146f439d 100644
--- a/drivers/macintosh/therm_pm72.c
+++ b/drivers/macintosh/therm_pm72.c
@@ -104,7 +104,6 @@
#include <linux/kernel.h>
#include <linux/delay.h>
#include <linux/sched.h>
-#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/spinlock.h>
@@ -113,7 +112,6 @@
#include <linux/reboot.h>
#include <linux/kmod.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/io.h>
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
index 4a478eb0e27..4f5f3abc9cb 100644
--- a/drivers/macintosh/via-pmu.c
+++ b/drivers/macintosh/via-pmu.c
@@ -161,7 +161,9 @@ static int drop_interrupts;
#if defined(CONFIG_PM) && defined(CONFIG_PPC32)
static int option_lid_wakeup = 1;
#endif /* CONFIG_PM && CONFIG_PPC32 */
+#if (defined(CONFIG_PM)&&defined(CONFIG_PPC32))||defined(CONFIG_PMAC_BACKLIGHT)
static int sleep_in_progress;
+#endif
static unsigned long async_req_locks;
static unsigned int pmu_irq_stats[11];
@@ -2201,8 +2203,7 @@ pmac_wakeup_devices(void)
#define GRACKLE_NAP (1<<4)
#define GRACKLE_SLEEP (1<<3)
-int
-powerbook_sleep_grackle(void)
+static int powerbook_sleep_grackle(void)
{
unsigned long save_l2cr;
unsigned short pmcr1;
diff --git a/drivers/macintosh/windfarm_lm75_sensor.c b/drivers/macintosh/windfarm_lm75_sensor.c
index 423bfa2432c..3f7967feaf5 100644
--- a/drivers/macintosh/windfarm_lm75_sensor.c
+++ b/drivers/macintosh/windfarm_lm75_sensor.c
@@ -15,7 +15,6 @@
#include <linux/init.h>
#include <linux/wait.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/io.h>
diff --git a/drivers/macintosh/windfarm_max6690_sensor.c b/drivers/macintosh/windfarm_max6690_sensor.c
index 8e99d408fdd..eae1189d6c4 100644
--- a/drivers/macintosh/windfarm_max6690_sensor.c
+++ b/drivers/macintosh/windfarm_max6690_sensor.c
@@ -11,7 +11,6 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <asm/prom.h>
#include <asm/pmac_low_i2c.h>
diff --git a/drivers/macintosh/windfarm_smu_sat.c b/drivers/macintosh/windfarm_smu_sat.c
index 24e51d5e97f..e295a07a1eb 100644
--- a/drivers/macintosh/windfarm_smu_sat.c
+++ b/drivers/macintosh/windfarm_smu_sat.c
@@ -13,7 +13,6 @@
#include <linux/init.h>
#include <linux/wait.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <asm/semaphore.h>
#include <asm/prom.h>
#include <asm/smu.h>
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index eae4473eadd..e1c18aa1d71 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -556,7 +556,7 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
unsigned long flags;
spin_lock_irqsave(&bitmap->lock, flags);
- if (!bitmap || !bitmap->sb_page) { /* can't set the state */
+ if (!bitmap->sb_page) { /* can't set the state */
spin_unlock_irqrestore(&bitmap->lock, flags);
return;
}
@@ -1309,7 +1309,7 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect
case 1:
*bmc = 2;
}
- if ((*bmc & COUNTER_MAX) == COUNTER_MAX) BUG();
+ BUG_ON((*bmc & COUNTER_MAX) == COUNTER_MAX);
(*bmc)++;
spin_unlock_irq(&bitmap->lock);
diff --git a/drivers/md/dm-hw-handler.c b/drivers/md/dm-hw-handler.c
index 4cc0010e015..baafaaba4d4 100644
--- a/drivers/md/dm-hw-handler.c
+++ b/drivers/md/dm-hw-handler.c
@@ -83,8 +83,7 @@ void dm_put_hw_handler(struct hw_handler_type *hwht)
if (--hwhi->use == 0)
module_put(hwhi->hwht.module);
- if (hwhi->use < 0)
- BUG();
+ BUG_ON(hwhi->use < 0);
out:
up_read(&_hwh_lock);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 26b08ee425c..8c82373f7ff 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -17,6 +17,7 @@
#include <linux/mempool.h>
#include <linux/slab.h>
#include <linux/idr.h>
+#include <linux/blktrace_api.h>
static const char *_name = DM_NAME;
@@ -334,6 +335,8 @@ static void dec_pending(struct dm_io *io, int error)
/* nudge anyone waiting on suspend queue */
wake_up(&io->md->wait);
+ blk_add_trace_bio(io->md->queue, io->bio, BLK_TA_COMPLETE);
+
bio_endio(io->bio, io->bio->bi_size, io->error);
free_io(io->md, io);
}
@@ -392,6 +395,7 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
struct target_io *tio)
{
int r;
+ sector_t sector;
/*
* Sanity checks.
@@ -407,10 +411,17 @@ static void __map_bio(struct dm_target *ti, struct bio *clone,
* this io.
*/
atomic_inc(&tio->io->io_count);
+ sector = clone->bi_sector;
r = ti->type->map(ti, clone, &tio->info);
- if (r > 0)
+ if (r > 0) {
/* the bio has been remapped so dispatch it */
+
+ blk_add_trace_remap(bdev_get_queue(clone->bi_bdev), clone,
+ tio->io->bio->bi_bdev->bd_dev, sector,
+ clone->bi_sector);
+
generic_make_request(clone);
+ }
else if (r < 0) {
/* error the io and bail out */
diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig
index c2602b34049..baa9f58beff 100644
--- a/drivers/media/Kconfig
+++ b/drivers/media/Kconfig
@@ -50,5 +50,19 @@ config VIDEO_IR
config VIDEO_TVEEPROM
tristate
+config USB_DABUSB
+ tristate "DABUSB driver"
+ depends on USB
+ ---help---
+ A Digital Audio Broadcasting (DAB) Receiver for USB and Linux
+ brought to you by the DAB-Team
+ <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken
+ as an example for URB-based bulk, control, and isochronous
+ transactions. URB's are explained in
+ <Documentation/usb/URB.txt>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called dabusb.
+
endmenu
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index 3870fa948cc..523ab3851c7 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -50,14 +50,15 @@ void saa7146_res_free(struct saa7146_fh *fh, unsigned int bits)
/********************************************************************************/
/* common dma functions */
-void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf)
+void saa7146_dma_free(struct saa7146_dev *dev,struct videobuf_queue *q,
+ struct saa7146_buf *buf)
{
DEB_EE(("dev:%p, buf:%p\n",dev,buf));
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
buf->vb.state = STATE_NEEDS_INIT;
}
diff --git a/drivers/media/common/saa7146_vbi.c b/drivers/media/common/saa7146_vbi.c
index 500bd3f05e1..063608462eb 100644
--- a/drivers/media/common/saa7146_vbi.c
+++ b/drivers/media/common/saa7146_vbi.c
@@ -236,7 +236,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
}
if (buf->vb.size != size)
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
if (STATE_NEEDS_INIT == buf->vb.state) {
buf->vb.width = llength;
@@ -247,7 +247,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
saa7146_pgtable_free(dev->pci, &buf->pt[2]);
saa7146_pgtable_alloc(dev->pci, &buf->pt[2]);
- err = videobuf_iolock(dev->pci,&buf->vb, NULL);
+ err = videobuf_iolock(q,&buf->vb, NULL);
if (err)
goto oops;
err = saa7146_pgtable_build_single(dev->pci, &buf->pt[2], buf->vb.dma.sglist, buf->vb.dma.sglen);
@@ -261,7 +261,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,e
oops:
DEB_VBI(("error out.\n"));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
return err;
}
@@ -301,7 +301,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_VBI(("vb:%p\n",vb));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
static struct videobuf_queue_ops vbi_qops = {
diff --git a/drivers/media/common/saa7146_video.c b/drivers/media/common/saa7146_video.c
index 6b42713d97f..e7079d1bd53 100644
--- a/drivers/media/common/saa7146_video.c
+++ b/drivers/media/common/saa7146_video.c
@@ -1275,7 +1275,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.field != field ||
buf->vb.field != fh->video_fmt.field ||
buf->fmt != &fh->video_fmt) {
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1304,7 +1304,7 @@ static int buffer_prepare(struct videobuf_queue *q,
saa7146_pgtable_alloc(dev->pci, &buf->pt[0]);
}
- err = videobuf_iolock(dev->pci,&buf->vb, &vv->ov_fb);
+ err = videobuf_iolock(q,&buf->vb, &vv->ov_fb);
if (err)
goto oops;
err = saa7146_pgtable_build(dev,buf);
@@ -1318,7 +1318,7 @@ static int buffer_prepare(struct videobuf_queue *q,
oops:
DEB_D(("error out.\n"));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
return err;
}
@@ -1363,7 +1363,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct saa7146_buf *buf = (struct saa7146_buf *)vb;
DEB_CAP(("vbuf:%p\n",vb));
- saa7146_dma_free(dev,buf);
+ saa7146_dma_free(dev,q,buf);
}
static struct videobuf_queue_ops video_qops = {
diff --git a/drivers/media/dvb/b2c2/flexcop-usb.c b/drivers/media/dvb/b2c2/flexcop-usb.c
index a6c91db40ad..06ec9fff0ec 100644
--- a/drivers/media/dvb/b2c2/flexcop-usb.c
+++ b/drivers/media/dvb/b2c2/flexcop-usb.c
@@ -541,6 +541,7 @@ static struct usb_device_id flexcop_usb_table [] = {
{ USB_DEVICE(0x0af7, 0x0101) },
{ }
};
+MODULE_DEVICE_TABLE (usb, flexcop_usb_table);
/* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver flexcop_usb_driver = {
diff --git a/drivers/media/dvb/bt8xx/Makefile b/drivers/media/dvb/bt8xx/Makefile
index d188e4c670b..9d197efb481 100644
--- a/drivers/media/dvb/bt8xx/Makefile
+++ b/drivers/media/dvb/bt8xx/Makefile
@@ -1,3 +1,3 @@
obj-$(CONFIG_DVB_BT8XX) += bt878.o dvb-bt8xx.o dst.o dst_ca.o
-EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video -Idrivers/media/dvb/frontends
+EXTRA_CFLAGS = -Idrivers/media/dvb/dvb-core/ -Idrivers/media/video/bt8xx -Idrivers/media/dvb/frontends
diff --git a/drivers/media/dvb/dvb-usb/cxusb.c b/drivers/media/dvb/dvb-usb/cxusb.c
index e14bf43941e..a14e737ec84 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.c
+++ b/drivers/media/dvb/dvb-usb/cxusb.c
@@ -81,18 +81,19 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
return -EAGAIN;
if (num > 2)
- warn("more than 2 i2c messages at a time is not handled yet. TODO.");
+ warn("more than two i2c messages at a time is not handled yet. TODO.");
for (i = 0; i < num; i++) {
- switch (msg[i].addr) {
- case 0x63:
- cxusb_gpio_tuner(d,0);
- break;
- default:
- cxusb_gpio_tuner(d,1);
- break;
- }
+ if (d->udev->descriptor.idVendor == USB_VID_MEDION)
+ switch (msg[i].addr) {
+ case 0x63:
+ cxusb_gpio_tuner(d,0);
+ break;
+ default:
+ cxusb_gpio_tuner(d,1);
+ break;
+ }
/* read request */
if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
@@ -108,7 +109,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
break;
if (ibuf[0] != 0x08)
- deb_info("i2c read could have been failed\n");
+ deb_i2c("i2c read may have failed\n");
memcpy(msg[i+1].buf,&ibuf[1],msg[i+1].len);
@@ -122,7 +123,7 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg msg[],int num)
if (cxusb_ctrl_msg(d,CMD_I2C_WRITE, obuf, 2+msg[i].len, &ibuf,1) < 0)
break;
if (ibuf != 0x08)
- deb_info("i2c write could have been failed\n");
+ deb_i2c("i2c write may have failed\n");
}
}
@@ -410,7 +411,6 @@ static int bluebird_patch_dvico_firmware_download(struct usb_device *udev, const
if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
- /* FIXME: are we allowed to change the fw-data ? */
fw->data[BLUEBIRD_01_ID_OFFSET + 2] = udev->descriptor.idProduct + 1;
fw->data[BLUEBIRD_01_ID_OFFSET + 3] = udev->descriptor.idProduct >> 8;
diff --git a/drivers/media/dvb/dvb-usb/cxusb.h b/drivers/media/dvb/dvb-usb/cxusb.h
index 087c9942785..c8ef77554b0 100644
--- a/drivers/media/dvb/dvb-usb/cxusb.h
+++ b/drivers/media/dvb/dvb-usb/cxusb.h
@@ -6,6 +6,8 @@
extern int dvb_usb_cxusb_debug;
#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
+#define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
+ dprintk(dvb_usb_cxusb_debug,0x01,args)
/* usb commands - some of it are guesses, don't have a reference yet */
#define CMD_I2C_WRITE 0x08
diff --git a/drivers/media/dvb/ttpci/av7110_v4l.c b/drivers/media/dvb/ttpci/av7110_v4l.c
index 2f23ceab8d4..603a22e4bfe 100644
--- a/drivers/media/dvb/ttpci/av7110_v4l.c
+++ b/drivers/media/dvb/ttpci/av7110_v4l.c
@@ -369,6 +369,11 @@ static int av7110_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
fm_matrix = 0x3001; // stereo
src = 0x0020;
break;
+ case V4L2_TUNER_MODE_LANG1_LANG2:
+ dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n");
+ fm_matrix = 0x3000; // bilingual
+ src = 0x0020;
+ break;
case V4L2_TUNER_MODE_LANG1:
dprintk(2, "VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1\n");
fm_matrix = 0x3000; // mono
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index c622a4da566..f31a19890b1 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -16,31 +16,7 @@ config VIDEO_ADV_DEBUG
V4L devices.
In doubt, say N.
-config VIDEO_BT848
- tristate "BT848 Video For Linux"
- depends on VIDEO_DEV && PCI && I2C
- select I2C_ALGOBIT
- select FW_LOADER
- select VIDEO_BTCX
- select VIDEO_BUF
- select VIDEO_IR
- select VIDEO_TUNER
- select VIDEO_TVEEPROM
- select VIDEO_MSP3400
- ---help---
- Support for BT848 based frame grabber/overlay boards. This includes
- the Miro, Hauppauge and STB boards. Please read the material in
- <file:Documentation/video4linux/bttv/> for more information.
-
- To compile this driver as a module, choose M here: the
- module will be called bttv.
-
-config VIDEO_BT848_DVB
- bool "DVB/ATSC Support for bt878 based TV cards"
- depends on VIDEO_BT848 && DVB_CORE
- select DVB_BT8XX
- ---help---
- This adds support for DVB/ATSC cards based on the BT878 chip.
+source "drivers/media/video/bt8xx/Kconfig"
config VIDEO_SAA6588
tristate "SAA6588 Radio Chip RDS decoder support on BT848 cards"
@@ -315,8 +291,6 @@ config VIDEO_HEXIUM_GEMINI
source "drivers/media/video/cx88/Kconfig"
-source "drivers/media/video/em28xx/Kconfig"
-
config VIDEO_OVCAMCHIP
tristate "OmniVision Camera Chip support"
depends on VIDEO_DEV && I2C
@@ -391,4 +365,234 @@ config VIDEO_SAA7127
To compile this driver as a module, choose M here: the
module will be called saa7127
+#
+# USB Multimedia device configuration
+#
+
+menu "V4L USB devices"
+ depends on USB && VIDEO_DEV
+
+source "drivers/media/video/em28xx/Kconfig"
+
+config USB_VICAM
+ tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
+ depends on USB && VIDEO_DEV && EXPERIMENTAL
+ ---help---
+ Say Y here if you have 3com homeconnect camera (vicam).
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" (under Multimedia Devices) to use this driver.
+ Information on this API and pointers to "v4l" programs may be found
+ at <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called vicam.
+
+config USB_DSBR
+ tristate "D-Link USB FM radio support (EXPERIMENTAL)"
+ depends on USB && VIDEO_DEV && EXPERIMENTAL
+ ---help---
+ Say Y here if you want to connect this type of radio to your
+ computer's USB port. Note that the audio is not digital, and
+ you must connect the line out connector to a sound card or a
+ set of speakers.
+
+ This driver uses the Video For Linux API. You must enable
+ (Y or M in config) Video For Linux (under Character Devices)
+ to use this driver. Information on this API and pointers to
+ "v4l" programs may be found at
+ <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called dsbr100.
+
+config USB_ET61X251
+ tristate "USB ET61X[12]51 PC Camera Controller support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want support for cameras based on Etoms ET61X151
+ or ET61X251 PC Camera Controllers.
+
+ See <file:Documentation/usb/et61x251.txt> for more informations.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" to use this driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called et61x251.
+
+config USB_IBMCAM
+ tristate "USB IBM (Xirlink) C-it Camera support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want to connect a IBM "C-It" camera, also known as
+ "Xirlink PC Camera" to your computer's USB port. For more
+ information, read <file:Documentation/usb/ibmcam.txt>.
+
+ This driver uses the Video For Linux API. You must enable
+ (Y or M in config) Video For Linux (under Character Devices)
+ to use this driver. Information on this API and pointers to
+ "v4l" programs may be found at
+ <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ibmcam.
+
+ This camera has several configuration options which
+ can be specified when you load the module. Read
+ <file:Documentation/usb/ibmcam.txt> to learn more.
+
+config USB_KONICAWC
+ tristate "USB Konica Webcam support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want support for webcams based on a Konica
+ chipset. This is known to work with the Intel YC76 webcam.
+
+ This driver uses the Video For Linux API. You must enable
+ (Y or M in config) Video For Linux (under Character Devices)
+ to use this driver. Information on this API and pointers to
+ "v4l" programs may be found at
+ <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called konicawc.
+
+config USB_OV511
+ tristate "USB OV511 Camera support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want to connect this type of camera to your
+ computer's USB port. See <file:Documentation/usb/ov511.txt> for more
+ information and for a list of supported cameras.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" (under Character Devices) to use this driver.
+ Information on this API and pointers to "v4l" programs may be found
+ at <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ov511.
+
+config USB_SE401
+ tristate "USB SE401 Camera support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want to connect this type of camera to your
+ computer's USB port. See <file:Documentation/usb/se401.txt> for more
+ information and for a list of supported cameras.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" (under Multimedia Devices) to use this driver.
+ Information on this API and pointers to "v4l" programs may be found
+ at <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called se401.
+
+config USB_SN9C102
+ tristate "USB SN9C10x PC Camera Controller support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want support for cameras based on SONiX SN9C101,
+ SN9C102 or SN9C103 PC Camera Controllers.
+
+ See <file:Documentation/usb/sn9c102.txt> for more informations.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" to use this driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called sn9c102.
+
+config USB_STV680
+ tristate "USB STV680 (Pencam) Camera support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want to connect this type of camera to your
+ computer's USB port. This includes the Pencam line of cameras.
+ See <file:Documentation/usb/stv680.txt> for more information and for
+ a list of supported cameras.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" (under Multimedia Devices) to use this driver.
+ Information on this API and pointers to "v4l" programs may be found
+ at <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called stv680.
+
+config USB_W9968CF
+ tristate "USB W996[87]CF JPEG Dual Mode Camera support"
+ depends on USB && VIDEO_DEV && I2C && VIDEO_OVCAMCHIP
+ ---help---
+ Say Y here if you want support for cameras based on OV681 or
+ Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
+
+ This driver has an optional plugin, which is distributed as a
+ separate module only (released under GPL). It allows to use higher
+ resolutions and framerates, but cannot be included in the official
+ Linux kernel for performance purposes.
+
+ See <file:Documentation/usb/w9968cf.txt> for more informations.
+
+ This driver uses the Video For Linux and the I2C APIs. It needs the
+ OmniVision Camera Chip support as well. You must say Y or M to
+ "Video For Linux", "I2C Support" and "OmniVision Camera Chip
+ support" to use this driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called w9968cf.
+
+config USB_ZC0301
+ tristate "USB ZC0301 Image Processor and Control Chip support"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y here if you want support for cameras based on the ZC0301
+ Image Processor and Control Chip.
+
+ See <file:Documentation/usb/zc0301.txt> for more informations.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" to use this driver.
+
+ To compile this driver as a module, choose M here: the
+ module will be called zc0301.
+
+config USB_PWC
+ tristate "USB Philips Cameras"
+ depends on USB && VIDEO_DEV
+ ---help---
+ Say Y or M here if you want to use one of these Philips & OEM
+ webcams:
+ * Philips PCA645, PCA646
+ * Philips PCVC675, PCVC680, PCVC690
+ * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
+ * Askey VC010
+ * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
+ and 'Orbit'/'Sphere'
+ * Samsung MPC-C10, MPC-C30
+ * Creative Webcam 5, Pro Ex
+ * SOTEC Afina Eye
+ * Visionite VCS-UC300, VCS-UM100
+
+ The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
+ and never will be, but the 665 and 720/20 are supported by other
+ drivers.
+
+ See <file:Documentation/usb/philips.txt> for more information and
+ installation instructions.
+
+ The built-in microphone is enabled by selecting USB Audio support.
+
+ This driver uses the Video For Linux API. You must say Y or M to
+ "Video For Linux" (under Character Devices) to use this driver.
+ Information on this API and pointers to "v4l" programs may be found
+ at <file:Documentation/video4linux/API.html>.
+
+ To compile this driver as a module, choose M here: the
+ module will be called pwc.
+
+endmenu # V4L USB devices
+
endmenu
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile
index f2bd4c0c4f1..1c0e72e5a59 100644
--- a/drivers/media/video/Makefile
+++ b/drivers/media/video/Makefile
@@ -2,9 +2,6 @@
# Makefile for the video capture/playback device drivers.
#
-bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
- bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \
- bttv-input.o
zoran-objs := zr36120.o zr36120_i2c.o zr36120_mem.o
zr36067-objs := zoran_procfs.o zoran_device.o \
zoran_driver.o zoran_card.o
@@ -15,8 +12,8 @@ msp3400-objs := msp3400-driver.o msp3400-kthreads.o
obj-$(CONFIG_VIDEO_DEV) += videodev.o v4l2-common.o v4l1-compat.o compat_ioctl32.o
-obj-$(CONFIG_VIDEO_BT848) += bttv.o tvaudio.o \
- tda7432.o tda9875.o ir-kbd-i2c.o
+obj-$(CONFIG_VIDEO_BT848) += bt8xx/
+obj-$(CONFIG_VIDEO_BT848) += tvaudio.o tda7432.o tda9875.o ir-kbd-i2c.o
obj-$(CONFIG_SOUND_TVMIXER) += tvmixer.o
obj-$(CONFIG_VIDEO_ZR36120) += zoran.o
@@ -68,4 +65,23 @@ obj-$(CONFIG_VIDEO_CX25840) += cx25840/
obj-$(CONFIG_VIDEO_SAA711X) += saa7115.o
obj-$(CONFIG_VIDEO_SAA7127) += saa7127.o
+et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
+zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
+
+obj-$(CONFIG_USB_DABUSB) += dabusb.o
+obj-$(CONFIG_USB_DSBR) += dsbr100.o
+obj-$(CONFIG_USB_OV511) += ov511.o
+obj-$(CONFIG_USB_SE401) += se401.o
+obj-$(CONFIG_USB_STV680) += stv680.o
+obj-$(CONFIG_USB_W9968CF) += w9968cf.o
+
+obj-$(CONFIG_USB_SN9C102) += sn9c102/
+obj-$(CONFIG_USB_ET61X251) += et61x251/
+obj-$(CONFIG_USB_PWC) += pwc/
+obj-$(CONFIG_USB_ZC0301) += zc0301/
+
+obj-$(CONFIG_USB_IBMCAM) += usbvideo/
+obj-$(CONFIG_USB_KONICAWC) += usbvideo/
+obj-$(CONFIG_USB_VICAM) += usbvideo/
+
EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/drivers/media/video/adv7170.c b/drivers/media/video/adv7170.c
index 4ce07ae62da..48709582a18 100644
--- a/drivers/media/video/adv7170.c
+++ b/drivers/media/video/adv7170.c
@@ -1,9 +1,9 @@
-/*
+/*
* adv7170 - adv7170, adv7171 video encoder driver version 0.0.1
*
* Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
*
- * Based on adv7176 driver by:
+ * Based on adv7176 driver by:
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
* Copyright (C) 1999 Wolfgang Scherr <scherr@net4you.net>
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(x) (x)->name
@@ -125,24 +124,21 @@ adv7170_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct adv7170 *encoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
+ block_data[block_len++] =
encoder->reg[reg++] = data[1];
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -177,7 +173,7 @@ adv7170_write_block (struct i2c_client *client,
static const unsigned char init_NTSC[] = {
0x00, 0x10, // MR0
0x01, 0x20, // MR1
- 0x02, 0x0e, // MR2 RTC control: bits 2 and 1
+ 0x02, 0x0e, // MR2 RTC control: bits 2 and 1
0x03, 0x80, // MR3
0x04, 0x30, // MR4
0x05, 0x00, // Reserved
@@ -200,7 +196,7 @@ static const unsigned char init_NTSC[] = {
0x16, 0x00, // CGMS_WSS_0
0x17, 0x00, // CGMS_WSS_1
0x18, 0x00, // CGMS_WSS_2
- 0x19, 0x00, // Teletext Ctl
+ 0x19, 0x00, // Teletext Ctl
};
static const unsigned char init_PAL[] = {
@@ -385,7 +381,7 @@ static unsigned short normal_i2c[] =
};
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/adv7175.c b/drivers/media/video/adv7175.c
index 4e218f22b21..68e7d7aff5e 100644
--- a/drivers/media/video/adv7175.c
+++ b/drivers/media/video/adv7175.c
@@ -1,4 +1,4 @@
-/*
+/*
* adv7175 - adv7175a video encoder driver version 0.0.3
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -68,8 +67,6 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */
struct adv7175 {
- unsigned char reg[128];
-
int norm;
int input;
int enable;
@@ -95,9 +92,6 @@ adv7175_write (struct i2c_client *client,
u8 reg,
u8 value)
{
- struct adv7175 *encoder = i2c_get_clientdata(client);
-
- encoder->reg[reg] = value;
return i2c_smbus_write_byte_data(client, reg, value);
}
@@ -120,25 +114,21 @@ adv7175_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
- struct adv7175 *encoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
- encoder->reg[reg++] = data[1];
+ block_data[block_len++] = data[1];
+ reg++;
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -171,24 +161,6 @@ set_subcarrier_freq (struct i2c_client *client,
adv7175_write(client, 0x05, 0x25);
}
-#ifdef ENCODER_DUMP
-static void
-dump (struct i2c_client *client)
-{
- struct adv7175 *encoder = i2c_get_clientdata(client);
- int i, j;
-
- printk(KERN_INFO "%s: registry dump\n", I2C_NAME(client));
- for (i = 0; i < 182 / 8; i++) {
- printk("%s: 0x%02x -", I2C_NAME(client), i * 8);
- for (j = 0; j < 8; j++) {
- printk(" 0x%02x", encoder->reg[i * 8 + j]);
- }
- printk("\n");
- }
-}
-#endif
-
/* ----------------------------------------------------------------------- */
// Output filter: S-Video Composite
@@ -261,7 +233,7 @@ adv7175_command (struct i2c_client *client,
sizeof(init_common));
adv7175_write(client, 0x07, TR0MODE | TR0RST);
adv7175_write(client, 0x07, TR0MODE);
- break;
+ break;
case ENCODER_GET_CAPABILITIES:
{
@@ -407,14 +379,6 @@ adv7175_command (struct i2c_client *client,
}
break;
-#ifdef ENCODER_DUMP
- case ENCODER_DUMP:
- {
- dump(client);
- }
- break;
-#endif
-
default:
return -EINVAL;
}
@@ -435,7 +399,7 @@ static unsigned short normal_i2c[] =
};
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c
index c586f64b6b7..dbe02517059 100644
--- a/drivers/media/video/arv.c
+++ b/drivers/media/video/arv.c
@@ -161,39 +161,39 @@ void iic(int n, unsigned long addr, unsigned long data1, unsigned long data2,
{
int i;
- /* Slave Address */
- ar_outl(addr, PLDI2CDATA);
+ /* Slave Address */
+ ar_outl(addr, PLDI2CDATA);
wait_for_vsync();
- /* Start */
- ar_outl(1, PLDI2CCND);
+ /* Start */
+ ar_outl(1, PLDI2CCND);
wait_acknowledge();
/* Transfer data 1 */
- ar_outl(data1, PLDI2CDATA);
+ ar_outl(data1, PLDI2CDATA);
wait_for_vsync();
- ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+ ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
wait_acknowledge();
/* Transfer data 2 */
- ar_outl(data2, PLDI2CDATA);
+ ar_outl(data2, PLDI2CDATA);
wait_for_vsync();
- ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+ ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
wait_acknowledge();
if (n == 3) {
/* Transfer data 3 */
- ar_outl(data3, PLDI2CDATA);
+ ar_outl(data3, PLDI2CDATA);
wait_for_vsync();
- ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
+ ar_outl(PLDI2CSTEN_STEN, PLDI2CSTEN);
wait_acknowledge();
- }
+ }
- /* Stop */
+ /* Stop */
for (i = 0; i < 100; i++)
cpu_relax();
- ar_outl(2, PLDI2CCND);
- ar_outl(2, PLDI2CCND);
+ ar_outl(2, PLDI2CCND);
+ ar_outl(2, PLDI2CCND);
while (ar_inl(PLDI2CSTS) & PLDI2CSTS_BB)
cpu_relax();
@@ -204,24 +204,24 @@ void init_iic(void)
{
DEBUG(1, "init_iic:\n");
- /*
+ /*
* ICU Setting (iic)
*/
- /* I2C Setting */
- ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */
- ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */
- ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */
+ /* I2C Setting */
+ ar_outl(0x0, PLDI2CCR); /* I2CCR Disable */
+ ar_outl(0x0300, PLDI2CMOD); /* I2CMOD ACK/8b-data/7b-addr/auto */
+ ar_outl(0x1, PLDI2CACK); /* I2CACK ACK */
/* I2C CLK */
- /* 50MH-100k */
+ /* 50MH-100k */
if (freq == 75) {
- ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */
+ ar_outl(369, PLDI2CFREQ); /* BCLK = 75MHz */
} else if (freq == 50) {
ar_outl(244, PLDI2CFREQ); /* BCLK = 50MHz */
} else {
ar_outl(244, PLDI2CFREQ); /* default: BCLK = 50MHz */
}
- ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */
+ ar_outl(0x1, PLDI2CCR); /* I2CCR Enable */
}
/**************************************************************************
@@ -253,7 +253,7 @@ static inline void wait_for_vertical_sync(int exp_line)
/*
* check HCOUNT because we cannot check vertical sync.
- */
+ */
for (; tmout >= 0; tmout--) {
l = ar_inl(ARVHCOUNT);
if (l == exp_line)
@@ -562,8 +562,8 @@ static void ar_interrupt(int irq, void *dev, struct pt_regs *regs)
/* operations for interlace mode */
if ( line_count < (AR_HEIGHT_VGA/2) ) /* even line */
line_number = (line_count << 1);
- else /* odd line */
- line_number =
+ else /* odd line */
+ line_number =
(((line_count - (AR_HEIGHT_VGA/2)) << 1) + 1);
} else {
line_number = line_count;
@@ -651,7 +651,7 @@ static int ar_initialize(struct video_device *dev)
cr |= ARVCR1_NORMAL;
ar_outl(cr, ARVCR1);
- /*
+ /*
* Initialize IIC so that CPU can communicate with AR LSI,
* and send boot commands to AR LSI.
*/
@@ -846,7 +846,7 @@ static int __init ar_init(void)
* so register video device as a frame grabber type.
* device is named "video[0-64]".
* video_register_device() initializes h/w using ar_initialize().
- */
+ */
if (video_register_device(ar->vdev, VFL_TYPE_GRABBER, video_nr) != 0) {
/* return -1, -ENFILE(full) or others */
printk("arv: register video (Colour AR) failed.\n");
diff --git a/drivers/media/video/bt819.c b/drivers/media/video/bt819.c
index d6447791d0e..e7b38fdd5e3 100644
--- a/drivers/media/video/bt819.c
+++ b/drivers/media/video/bt819.c
@@ -1,4 +1,4 @@
-/*
+/*
* bt819 - BT819A VideoStream Decoder (Rockwell Part)
*
* Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -6,7 +6,7 @@
*
* Modifications for LML33/DC10plus unified driver
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
- *
+ *
* Changes by Ronald Bultje <rbultje@ronald.bitfreak.net>
* - moved over to linux>=2.4.x i2c protocol (9/9/2002)
*
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -141,24 +140,21 @@ bt819_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct bt819 *decoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
+ block_data[block_len++] =
decoder->reg[reg++] = data[1];
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -210,9 +206,9 @@ bt819_init (struct i2c_client *client)
Bug in the bt819 stepping on my board?
*/
0x14, 0x00, /* 0x14 Vertial Scaling lsb */
- 0x16, 0x07, /* 0x16 Video Timing Polarity
+ 0x16, 0x07, /* 0x16 Video Timing Polarity
ACTIVE=active low
- FIELD: high=odd,
+ FIELD: high=odd,
vreset=active high,
hreset=active high */
0x18, 0x68, /* 0x18 AGC Delay */
@@ -501,7 +497,7 @@ static unsigned short normal_i2c[] = {
};
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/bt856.c b/drivers/media/video/bt856.c
index 909b593530e..af3b61d4fa7 100644
--- a/drivers/media/video/bt856.c
+++ b/drivers/media/video/bt856.c
@@ -1,4 +1,4 @@
-/*
+/*
* bt856 - BT856A Digital Video Encoder (Rockwell Part)
*
* Copyright (C) 1999 Mike Bernson <mike@mlb.org>
@@ -53,7 +53,6 @@ MODULE_AUTHOR("Mike Bernson & Dave Perks");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -71,17 +70,14 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */
-#define REG_OFFSET 0xCE
+#define REG_OFFSET 0xDA
+#define BT856_NR_REG 6
struct bt856 {
- unsigned char reg[32];
+ unsigned char reg[BT856_NR_REG];
int norm;
int enable;
- int bright;
- int contrast;
- int hue;
- int sat;
};
#define I2C_BT856 0x88
@@ -120,8 +116,8 @@ bt856_dump (struct i2c_client *client)
struct bt856 *encoder = i2c_get_clientdata(client);
printk(KERN_INFO "%s: register dump:", I2C_NAME(client));
- for (i = 0xd6; i <= 0xde; i += 2)
- printk(" %02x", encoder->reg[i - REG_OFFSET]);
+ for (i = 0; i < BT856_NR_REG; i += 2)
+ printk(" %02x", encoder->reg[i]);
printk("\n");
}
@@ -289,7 +285,7 @@ bt856_command (struct i2c_client *client,
static unsigned short normal_i2c[] = { I2C_BT856 >> 1, I2C_CLIENT_END };
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/bt8xx/Kconfig b/drivers/media/video/bt8xx/Kconfig
new file mode 100644
index 00000000000..085477c1261
--- /dev/null
+++ b/drivers/media/video/bt8xx/Kconfig
@@ -0,0 +1,25 @@
+config VIDEO_BT848
+ tristate "BT848 Video For Linux"
+ depends on VIDEO_DEV && PCI && I2C
+ select I2C_ALGOBIT
+ select FW_LOADER
+ select VIDEO_BTCX
+ select VIDEO_BUF
+ select VIDEO_IR
+ select VIDEO_TUNER
+ select VIDEO_TVEEPROM
+ select VIDEO_MSP3400
+ ---help---
+ Support for BT848 based frame grabber/overlay boards. This includes
+ the Miro, Hauppauge and STB boards. Please read the material in
+ <file:Documentation/video4linux/bttv/> for more information.
+
+ To compile this driver as a module, choose M here: the
+ module will be called bttv.
+
+config VIDEO_BT848_DVB
+ bool "DVB/ATSC Support for bt878 based TV cards"
+ depends on VIDEO_BT848 && DVB_CORE
+ select DVB_BT8XX
+ ---help---
+ This adds support for DVB/ATSC cards based on the BT878 chip.
diff --git a/drivers/media/video/bt8xx/Makefile b/drivers/media/video/bt8xx/Makefile
new file mode 100644
index 00000000000..94350f21cdc
--- /dev/null
+++ b/drivers/media/video/bt8xx/Makefile
@@ -0,0 +1,12 @@
+#
+# Makefile for the video capture/playback device drivers.
+#
+
+bttv-objs := bttv-driver.o bttv-cards.o bttv-if.o \
+ bttv-risc.o bttv-vbi.o bttv-i2c.o bttv-gpio.o \
+ bttv-input.o
+
+obj-$(CONFIG_VIDEO_BT848) += bttv.o
+
+EXTRA_CFLAGS += -I$(src)/..
+EXTRA_CFLAGS += -I$(srctree)/drivers/media/dvb/dvb-core
diff --git a/drivers/media/video/bt832.c b/drivers/media/video/bt8xx/bt832.c
index cc54b62f460..a5187613788 100644
--- a/drivers/media/video/bt832.c
+++ b/drivers/media/video/bt8xx/bt832.c
@@ -30,7 +30,6 @@
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/slab.h>
-#include <media/audiochip.h>
#include <media/v4l2-common.h>
#include "bttv.h"
@@ -39,7 +38,7 @@
MODULE_LICENSE("GPL");
/* Addresses to scan */
-static unsigned short normal_i2c[] = { I2C_BT832_ALT1>>1, I2C_BT832_ALT2>>1,
+static unsigned short normal_i2c[] = { I2C_ADDR_BT832_ALT1>>1, I2C_ADDR_BT832_ALT2>>1,
I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/bt832.h b/drivers/media/video/bt8xx/bt832.h
index 1ce8fa71f7d..1ce8fa71f7d 100644
--- a/drivers/media/video/bt832.h
+++ b/drivers/media/video/bt8xx/bt832.h
diff --git a/drivers/media/video/bt848.h b/drivers/media/video/bt8xx/bt848.h
index 0bcd95303bb..0bcd95303bb 100644
--- a/drivers/media/video/bt848.h
+++ b/drivers/media/video/bt8xx/bt848.h
diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bt8xx/bttv-cards.c
index abfa6ad857a..f209a749205 100644
--- a/drivers/media/video/bttv-cards.c
+++ b/drivers/media/video/bt8xx/bttv-cards.c
@@ -39,6 +39,7 @@
#include "bttvp.h"
#include <media/v4l2-common.h>
+#include <media/tvaudio.h>
/* fwd decl */
static void boot_msp34xx(struct bttv *btv, int pin);
@@ -336,7 +337,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 0, 0, 0, 10 },
+ .gpiomux = { 2, 0, 0, 0 },
+ .gpiomute = 10,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -350,7 +352,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -364,7 +367,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 4, 0, 2, 3, 1 },
+ .gpiomux = { 4, 0, 2, 3 },
+ .gpiomute = 1,
.no_msp34xx = 1,
.needs_tvaudio = 1,
.tuner_type = TUNER_PHILIPS_NTSC,
@@ -383,7 +387,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.tuner_type = 4,
.tuner_addr = ADDR_UNSET,
@@ -397,7 +401,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 3,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0, 1, 0, 1, 3 },
+ .gpiomux = { 0, 1, 0, 1 },
+ .gpiomute = 3,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -411,7 +416,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.muxsel = { 2, 3, 1, 1 },
.gpiomask = 0x0f,
- .audiomux = { 0x0c, 0x04, 0x08, 0x04, 0 },
+ .gpiomux = { 0x0c, 0x04, 0x08, 0x04 },
/* 0x04 for some cards ?? */
.needs_tvaudio = 1,
.tuner_type = -1,
@@ -428,7 +433,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0, 0 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -444,7 +449,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xc00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0xc00, 0x800, 0x400, 0xc00, 0 },
+ .gpiomux = { 0, 0xc00, 0x800, 0x400 },
+ .gpiomute = 0xc00,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -459,7 +465,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 3,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 1, 2, 3, 0 },
+ .gpiomux = { 1, 1, 2, 3 },
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_TEMIC_PAL,
@@ -474,7 +480,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x0f, /* old: 7 */
.muxsel = { 2, 0, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -489,7 +496,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x3014f,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x20001,0x10001, 0, 0,10 },
+ .gpiomux = { 0x20001,0x10001, 0, 0 },
+ .gpiomute = 10,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -505,7 +513,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 13, 14, 11, 7, 0, 0 },
+ .gpiomux = { 13, 14, 11, 7 },
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -519,7 +527,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 13, 14, 11, 7, 0, 0 },
+ .gpiomux = { 13, 14, 11, 7 },
.needs_tvaudio = 1,
.msp34xx_alt = 1,
.pll = PLL_28,
@@ -537,7 +545,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 2, 1, 3, 4 }, /* old: {0, 1, 2, 3, 4} */
+ .gpiomux = { 0, 2, 1, 3 }, /* old: {0, 1, 2, 3, 4} */
+ .gpiomute = 4,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -552,7 +561,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0 , 0, 1 , 0, 10 },
+ .gpiomux = { 0, 0, 1, 0 },
+ .gpiomute = 10,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -570,10 +580,11 @@ struct tvcard bttv_tvcards[] = {
.muxsel = { 2, 3, 1, 1 },
#if 0
/* old */
- .audiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000, 0 },
+ .gpiomux = { 0x01c000, 0, 0x018000, 0x014000, 0x002000 },
#else
/* 2003-10-20 by "Anton A. Arapov" <arapov@mail.ru> */
- .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
+ .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 },
+ .gpiomute = 0x002000,
#endif
.needs_tvaudio = 1,
.pll = PLL_28,
@@ -587,7 +598,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x8300f8,
.muxsel = { 2, 3, 1, 1,0 },
- .audiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007,0xcfa007 },
+ .gpiomux = { 0x4fa007,0xcfa007,0xcfa007,0xcfa007 },
+ .gpiomute = 0xcfa007,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -603,7 +615,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 0, 0, 0, 0 },
+ .gpiomux = { 1, 0, 0, 0 },
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -617,7 +629,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 0x8dff00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.no_msp34xx = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -644,7 +656,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
+ .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL_I,
.tuner_addr = ADDR_UNSET,
@@ -658,7 +671,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xc00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 0x800, 0x400, 0xc00, 0 },
+ .gpiomux = { 0, 1, 0x800, 0x400 },
+ .gpiomute = 0xc00,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -674,7 +688,7 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 7,
.muxsel = { 2, 3, -1 },
.digital_mode = DIGITAL_MODE_CAMERA,
- .audiomux = { 0, 0, 0, 0, 0 },
+ .gpiomux = { 0, 0, 0, 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_ALPS_TSBB5_PAL_I,
@@ -691,7 +705,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xe00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = {0x400, 0x400, 0x400, 0x400, 0xc00 },
+ .gpiomux = {0x400, 0x400, 0x400, 0x400 },
+ .gpiomute = 0xc00,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -707,7 +722,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1f0fff,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000 },
+ .gpiomux = { 0x20000, 0x30000, 0x10000, 0 },
+ .gpiomute = 0x40000,
.needs_tvaudio = 0,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -722,7 +738,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 7,
.muxsel = { 2, 0, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -736,7 +753,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
+ .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_SECAM,
.tuner_addr = ADDR_UNSET,
@@ -752,7 +770,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1f0fff,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x20000, 0x30000, 0x10000, 0x00000, 0x40000 },
+ .gpiomux = { 0x20000, 0x30000, 0x10000, 0x00000 },
+ .gpiomute = 0x40000,
.needs_tvaudio = 0,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -799,7 +818,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 1, /* was: 4 */
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0, 0},
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -815,7 +834,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800, /* 0x8dfe00 */
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x0800, 0x1000, 0x1000, 0x1800, 0 },
+ .gpiomux = { 0, 0x0800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -829,7 +849,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 1,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 0, 0, 0, 0 },
+ .gpiomux = { 1, 0, 0, 0 },
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -845,7 +865,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.tuner_type = 4,
.tuner_addr = ADDR_UNSET,
@@ -859,7 +879,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xffff00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x500, 0, 0x300, 0x900, 0x900 },
+ .gpiomux = { 0x500, 0, 0x300, 0x900 },
+ .gpiomute = 0x900,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -875,11 +896,12 @@ struct tvcard bttv_tvcards[] = {
.muxsel = { 2, 3, 1, 1, 0 }, /* TV, CVid, SVid, CVid over SVid connector */
#if 0
.gpiomask = 0xc33000,
- .audiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
+ .gpiomux = { 0x422000,0x1000,0x0000,0x620000,0x800000 },
#else
/* Alexander Varakin <avarakin@hotmail.com> [stereo version] */
.gpiomask = 0xb33000,
- .audiomux = { 0x122000,0x1000,0x0000,0x620000,0x800000 },
+ .gpiomux = { 0x122000,0x1000,0x0000,0x620000 },
+ .gpiomute = 0x800000,
#endif
/* Audio Routing for "WinFast 2000 XP" (no tv stereo !)
gpio23 -- hef4052:nEnable (0x800000)
@@ -909,7 +931,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800 },
+ .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -925,7 +948,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
+ .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -940,7 +964,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xff,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
+ .gpiomux = { 0x21, 0x20, 0x24, 0x2c },
+ .gpiomute = 0x29,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -955,7 +980,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x551e00,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0x551400, 0x551200, 0, 0, 0x551c00, 0x551200 },
+ .gpiomux = { 0x551400, 0x551200, 0, 0 },
+ .gpiomute = 0x551c00,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = 1,
@@ -971,7 +997,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x03000F,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 0xd0001, 0, 0, 1 },
+ .gpiomux = { 2, 0xd0001, 0, 0 },
+ .gpiomute = 1,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = -1,
@@ -988,7 +1015,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 4, 0, 2, 3, 1 },
+ .gpiomux = { 4, 0, 2, 3 },
+ .gpiomute = 1,
.no_msp34xx = 1,
.needs_tvaudio = 1,
.tuner_type = TUNER_PHILIPS_NTSC,
@@ -1005,7 +1033,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 13, 4, 11, 7, 0, 0 },
+ .gpiomux = { 13, 4, 11, 7 },
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -1022,7 +1050,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 1},
- .audiomux = { 0, 0, 0, 0, 0},
+ .gpiomux = { 0, 0, 0, 0},
.needs_tvaudio = 1,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -1038,7 +1066,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xe00b,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0, 0xff3ffc },
+ .gpiomux = { 0xff9ff6, 0xff9ff6, 0xff1ff7, 0 },
+ .gpiomute = 0xff3ffc,
.no_msp34xx = 1,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -1054,7 +1083,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 3,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 1, 0, 2, 3 },
+ .gpiomux = { 1, 1, 0, 2 },
+ .gpiomute = 3,
.no_msp34xx = 1,
.pll = PLL_NONE,
.tuner_type = -1,
@@ -1069,7 +1099,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0, 0 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -1084,7 +1114,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xbcf03f,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0, 0xbcb03f },
+ .gpiomux = { 0xbc803f, 0xbc903f, 0xbcb03f, 0 },
+ .gpiomute = 0xbcb03f,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = 21,
@@ -1099,7 +1130,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x70000,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x20000, 0x30000, 0x10000, 0, 0x40000, 0x20000 },
+ .gpiomux = { 0x20000, 0x30000, 0x10000, 0 },
+ .gpiomute = 0x40000,
.needs_tvaudio = 1,
.no_msp34xx = 1,
.pll = PLL_35,
@@ -1118,7 +1150,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = {2,0,0,0,1 },
+ .gpiomux = {2,0,0,0 },
+ .gpiomute = 1,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -1133,7 +1166,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x010f00,
.muxsel = {2, 3, 0, 0 },
- .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 },
+ .gpiomux = {0x10000, 0, 0x10000, 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_ALPS_TSHC6_NTSC,
@@ -1150,7 +1183,8 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 0xAA0000,
.muxsel = { 2,3,1,1,-1 },
.digital_mode = DIGITAL_MODE_CAMERA,
- .audiomux = { 0x20000, 0, 0x80000, 0x80000, 0xa8000, 0x46000 },
+ .gpiomux = { 0x20000, 0, 0x80000, 0x80000 },
+ .gpiomute = 0xa8000,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL_I,
@@ -1175,7 +1209,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 0, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.pll = PLL_28,
.tuner_type = -1 /* TUNER_ALPS_TMDH2_NTSC */,
.tuner_addr = ADDR_UNSET,
@@ -1192,7 +1227,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 0x03000F,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 0xd0001, 0, 0, 10 },
+ .gpiomux = { 1, 0xd0001, 0, 0 },
+ .gpiomute = 10,
/* sound path (5 sources):
MUX1 (mask 0x03), Enable Pin 0x08 (0=enable, 1=disable)
0= ext. Audio IN
@@ -1218,7 +1254,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1c,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0, 0x10, 8, 4 },
+ .gpiomux = { 0, 0, 0x10, 8 },
+ .gpiomute = 4,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -1230,7 +1267,7 @@ struct tvcard bttv_tvcards[] = {
/* Tim Röstermundt <rosterm@uni-muenster.de>
in de.comp.os.unix.linux.hardware:
options bttv card=0 pll=1 radio=1 gpiomask=0x18e0
- audiomux=0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
+ gpiomux =0x44c71f,0x44d71f,0,0x44d71f,0x44dfff
options tuner type=5 */
.name = "Lifeview FlyVideo 2000 /FlyVideo A2/ Lifetec LT 9415 TV [LR90]",
.video_inputs = 4,
@@ -1239,7 +1276,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x18e0,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x18e0 },
+ .gpiomux = { 0x0000,0x0800,0x1000,0x1000 },
+ .gpiomute = 0x18e0,
/* For cards with tda9820/tda9821:
0x0000: Tuner normal stereo
0x0080: Tuner A2 SAP (second audio program = Zweikanalton)
@@ -1259,7 +1297,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xF,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 2, 0, 0, 0, 10 },
+ .gpiomux = { 2, 0, 0, 0 },
+ .gpiomute = 10,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_TEMIC_PAL,
@@ -1277,7 +1316,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1800,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0x800, 0x1000, 0x1000, 0x1800, 0 },
+ .gpiomux = { 0, 0x800, 0x1000, 0x1000 },
+ .gpiomute = 0x1800,
.pll = PLL_28,
.tuner_type = 5,
.tuner_addr = ADDR_UNSET,
@@ -1294,7 +1334,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 1,
.gpiomask = 0,
.muxsel = { 3, 1 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_35,
@@ -1311,7 +1351,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xe00,
.muxsel = { 2, 3, 1, 1},
- .audiomux = { 0x400, 0x400, 0x400, 0x400, 0x800, 0x400 },
+ .gpiomux = { 0x400, 0x400, 0x400, 0x400 },
+ .gpiomute = 0x800,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = TUNER_TEMIC_4036FY5_NTSC,
@@ -1327,7 +1368,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x03000F,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 2, 0, 0, 0, 1 },
+ .gpiomux = { 2, 0, 0, 0 },
+ .gpiomute = 1,
.pll = PLL_28,
.tuner_type = 0,
.tuner_addr = ADDR_UNSET,
@@ -1344,7 +1386,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 11,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 0, 0, 1, 8 },
+ .gpiomux = { 2, 0, 0, 1 },
+ .gpiomute = 8,
.pll = PLL_35,
.tuner_type = TUNER_TEMIC_PAL,
.tuner_addr = ADDR_UNSET,
@@ -1359,7 +1402,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 1,
.gpiomask = 0xF,
.muxsel = { 2, 2 },
- .audiomux = { },
+ .gpiomux = { },
.no_msp34xx = 1,
.needs_tvaudio = 0,
.pll = PLL_28,
@@ -1378,7 +1421,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xFF,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 1, 0, 4, 4, 9 },
+ .gpiomux = { 1, 0, 4, 4 },
+ .gpiomute = 9,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -1394,7 +1438,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xf03f,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0xbffe, 0, 0xbfff, 0, 0xbffe },
+ .gpiomux = { 0xbffe, 0, 0xbfff, 0 },
+ .gpiomute = 0xbffe,
.pll = PLL_28,
.tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
.tuner_addr = ADDR_UNSET,
@@ -1411,7 +1456,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 1,
.muxsel = { 2, 3, 0, 1 },
- .audiomux = { 0, 0, 1, 0, 0 },
+ .gpiomux = { 0, 0, 1, 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_TEMIC_4006FN5_MULTI_PAL,
@@ -1430,7 +1475,8 @@ struct tvcard bttv_tvcards[] = {
/* Radio changed from 1e80 to 0x800 to make
FlyVideo2000S in .hu happy (gm)*/
/* -dk-???: set mute=0x1800 for tda9874h daughterboard */
- .audiomux = { 0x0000,0x0800,0x1000,0x1000,0x1800, 0x1080 },
+ .gpiomux = { 0x0000,0x0800,0x1000,0x1000 },
+ .gpiomute = 0x1800,
.audio_hook = fv2000s_audio,
.no_msp34xx = 1,
.no_tda9875 = 1,
@@ -1448,7 +1494,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0xffff00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x500, 0x500, 0x300, 0x900, 0x900 },
+ .gpiomux = { 0x500, 0x500, 0x300, 0x900 },
+ .gpiomute = 0x900,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -1465,7 +1512,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x010f00,
.muxsel = {2, 3, 0, 0 },
- .audiomux = {0x10000, 0, 0x10000, 0, 0, 0 },
+ .gpiomux = {0x10000, 0, 0x10000, 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_SHARP_2U5JF5540_NTSC,
@@ -1486,7 +1533,8 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 0x4f8a00,
/* 0x100000: 1=MSP enabled (0=disable again)
* 0x010000: Connected to "S0" on tda9880 (0=Pal/BG, 1=NTSC) */
- .audiomux = {0x947fff, 0x987fff,0x947fff,0x947fff, 0x947fff},
+ .gpiomux = {0x947fff, 0x987fff,0x947fff,0x947fff },
+ .gpiomute = 0x947fff,
/* tvtuner, radio, external,internal, mute, stereo
* tuner, Composit, SVid, Composit-on-Svid-adapter */
.muxsel = { 2, 3 ,0 ,1 },
@@ -1518,7 +1566,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0, 11, 7, 13, 0 }, /* TV and Radio with same GPIO ! */
+ .gpiomux = { 0, 0, 11, 7 }, /* TV and Radio with same GPIO ! */
+ .gpiomute = 13,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = 25,
@@ -1557,7 +1606,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x3f,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x01, 0x00, 0x03, 0x03, 0x09, 0x02 },
+ .gpiomux = { 0x01, 0x00, 0x03, 0x03 },
+ .gpiomute = 0x09,
.needs_tvaudio = 1,
.no_msp34xx = 1,
.no_tda9875 = 1,
@@ -1586,7 +1636,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 4,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0, 0 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.tuner_type = -1,
.tuner_addr = ADDR_UNSET,
@@ -1618,7 +1668,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x1C800F, /* Bit0-2: Audio select, 8-12:remote control 14:remote valid 15:remote reset */
.muxsel = { 2, 1, 1, },
- .audiomux = { 0, 1, 2, 2, 4 },
+ .gpiomux = { 0, 1, 2, 2 },
+ .gpiomute = 4,
.needs_tvaudio = 0,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -1637,7 +1688,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x140007,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4, 0 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.tuner_type = TUNER_PHILIPS_NTSC,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
@@ -1651,7 +1703,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -1667,13 +1719,14 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 }, /* Tuner, SVid, SVHS, SVid to SVHS connector */
- .audiomux = { 0 ,0 ,4, 4,4,4},/* Yes, this tuner uses the same audio output for TV and FM radio!
+ .gpiomux = { 0, 0, 4, 4 },/* Yes, this tuner uses the same audio output for TV and FM radio!
* This card lacks external Audio In, so we mute it on Ext. & Int.
* The PCB can take a sbx1637/sbx1673, wiring unknown.
* This card lacks PCI subsystem ID, sigh.
- * audiomux=1: lower volume, 2+3: mute
+ * gpiomux =1: lower volume, 2+3: mute
* btwincap uses 0x80000/0x80003
*/
+ .gpiomute = 4,
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -1720,7 +1773,7 @@ struct tvcard bttv_tvcards[] = {
.radio_addr = ADDR_UNSET,
.gpiomask = 7,
- .audiomux = {7},
+ .gpiomux = {7},
},
[BTTV_BOARD_GVBCTV5PCI] = {
.name = "IODATA GV-BCTV5/PCI",
@@ -1730,7 +1783,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x0f0f80,
.muxsel = {2, 3, 1, 0 },
- .audiomux = {0x030000, 0x010000, 0, 0, 0x020000, 0},
+ .gpiomux = {0x030000, 0x010000, 0, 0 },
+ .gpiomute = 0x020000,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_NTSC_M,
@@ -1960,7 +2014,7 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 2,
/* TV, Comp1, Composite over SVID con, SVID */
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 2, 0, 0, 0 },
+ .gpiomux = { 2, 2, 0, 0 },
.pll = PLL_28,
.has_radio = 1,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -1984,7 +2038,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1},
- .audiomux = { 0, 1, 2, 3, 4},
+ .gpiomux = { 0, 1, 2, 3},
+ .gpiomute = 4,
.needs_tvaudio = 1,
.tuner_type = 5,
.tuner_addr = ADDR_UNSET,
@@ -2016,7 +2071,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 0,
.muxsel = { 2, 3 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -2035,7 +2090,8 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 0x001e8007,
.muxsel = { 2, 3, 1, 0 },
/* Tuner, Radio, external, internal, off, on */
- .audiomux = { 0x08, 0x0f, 0x0a, 0x08, 0x0f, 0x08 },
+ .gpiomux = { 0x08, 0x0f, 0x0a, 0x08 },
+ .gpiomute = 0x0f,
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -2152,7 +2208,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 0,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.needs_tvaudio = 0,
.no_msp34xx = 1,
.pll = PLL_28,
@@ -2169,7 +2225,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 0x00,
.muxsel = { 2, 3, 1, 0 },
- .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
+ .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2184,7 +2240,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 3,
.gpiomask = 0x00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
+ .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2204,7 +2260,7 @@ struct tvcard bttv_tvcards[] = {
via the upper nibble of muxsel. here: used for
xternal video-mux */
.muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x00 },
- .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
+ .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2222,7 +2278,7 @@ struct tvcard bttv_tvcards[] = {
via the upper nibble of muxsel. here: used for
xternal video-mux */
.muxsel = { 0x02, 0x12, 0x22, 0x32, 0x03, 0x13, 0x23, 0x33, 0x01, 0x01 },
- .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
+ .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2310,7 +2366,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 3,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 1, 1, 1, 1, 0 },
+ .gpiomux = { 1, 1, 1, 1 },
.needs_tvaudio = 1,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -2341,7 +2397,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x008007,
.muxsel = { 2, 3, 0, 0 },
- .audiomux = { 0, 0, 0, 0, 0x000003, 0 },
+ .gpiomux = { 0, 0, 0, 0 },
+ .gpiomute = 0x000003,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
.tuner_addr = ADDR_UNSET,
@@ -2377,7 +2434,7 @@ struct tvcard bttv_tvcards[] = {
.needs_tvaudio = 0,
.gpiomask = 0x68,
.muxsel = { 2, 3, 1 },
- .audiomux = { 0x68, 0x68, 0x61, 0x61, 0x00 },
+ .gpiomux = { 0x68, 0x68, 0x61, 0x61 },
.pll = PLL_28,
},
@@ -2392,7 +2449,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x008007,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 2, 2, 3 },
+ .gpiomux = { 0, 1, 2, 2 },
+ .gpiomute = 3,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -2417,7 +2475,7 @@ struct tvcard bttv_tvcards[] = {
.no_tda9875 = 1,
.no_tda7432 = 1,
.muxsel = {2,2,2,2},/*878A input is always MUX0, see above.*/
- .audiomux = { 0, 0, 0, 0, 0, 0 }, /* card has no audio */
+ .gpiomux = { 0, 0, 0, 0 }, /* card has no audio */
.pll = PLL_28,
.needs_tvaudio = 0,
.muxsel_hook = picolo_tetra_muxsel,/*Required as it doesn't follow the classic input selection policy*/
@@ -2435,7 +2493,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x0000000f,
.muxsel = { 2, 1, 1 },
- .audiomux = { 0x02, 0x00, 0x00, 0x00, 0x00 },
+ .gpiomux = { 0x02, 0x00, 0x00, 0x00 },
.tuner_type = TUNER_TEMIC_PAL,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
@@ -2491,7 +2549,7 @@ struct tvcard bttv_tvcards[] = {
.muxsel = { 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3 },
.muxsel_hook = sigmaSQ_muxsel,
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2508,7 +2566,7 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 0x0,
.muxsel = { 2, 2, 2, 2 },
.muxsel_hook = sigmaSLC_muxsel,
- .audiomux = { 0 },
+ .gpiomux = { 0 },
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = -1,
@@ -2526,7 +2584,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = -1,
.gpiomask = 0xFF,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 0, 0, 0, 10 },
+ .gpiomux = { 2, 0, 0, 0 },
+ .gpiomute = 10,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_PAL,
@@ -2560,7 +2619,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x3f,
.muxsel = {2, 3, 1, 0 },
- .audiomux = {0x31, 0x31, 0x31, 0x31, 0x31, 0x31 },
+ .gpiomux = {0x31, 0x31, 0x31, 0x31 },
+ .gpiomute = 0x31,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_PHILIPS_NTSC_M,
@@ -2583,7 +2643,7 @@ struct tvcard bttv_tvcards[] = {
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
.gpiomask = 0x008007,
- .audiomux = { 0, 0x000001,0,0, 0 },
+ .gpiomux = { 0, 0x000001,0,0 },
.needs_tvaudio = 1,
.has_radio = 1,
},
@@ -2693,7 +2753,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.muxsel = { 2, 3, 1 },
.gpiomask = 0x00e00007,
- .audiomux = { 0x00400005, 0, 0x00000001, 0, 0x00c00007, 0 },
+ .gpiomux = { 0x00400005, 0, 0x00000001, 0 },
+ .gpiomute = 0x00c00007,
.no_msp34xx = 1,
.no_tda9875 = 1,
.no_tda7432 = 1,
@@ -2709,7 +2770,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x01fe00,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x001e00, 0, 0x018000, 0x014000, 0x002000, 0 },
+ .gpiomux = { 0x001e00, 0, 0x018000, 0x014000 },
+ .gpiomute = 0x002000,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = TUNER_YMEC_TVF66T5_B_DFF,
@@ -2726,7 +2788,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x001c0007,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 2, 2, 3 },
+ .gpiomux = { 0, 1, 2, 2 },
+ .gpiomute = 3,
.needs_tvaudio = 0,
.pll = PLL_28,
.tuner_type = TUNER_TENA_9533_DI,
@@ -2745,7 +2808,8 @@ struct tvcard bttv_tvcards[] = {
.gpiomask = 0x01fe00,
.muxsel = { 2,3,1,1,-1 },
.digital_mode = DIGITAL_MODE_CAMERA,
- .audiomux = { 0x00400, 0x10400, 0x04400, 0x80000, 0x12400, 0x46000 },
+ .gpiomux = { 0x00400, 0x10400, 0x04400, 0x80000 },
+ .gpiomute = 0x12400,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_LG_PAL_FM,
@@ -2763,7 +2827,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x3f,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0x21, 0x20, 0x24, 0x2c, 0x29, 0x29 },
+ .gpiomux = { 0x21, 0x20, 0x24, 0x2c },
+ .gpiomute = 0x29,
.no_msp34xx = 1,
.pll = PLL_28,
.tuner_type = TUNER_YMEC_TVF_5533MF,
@@ -2797,7 +2862,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 15,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 2, 0, 0, 0, 1 },
+ .gpiomux = { 2, 0, 0, 0 },
+ .gpiomute = 1,
.needs_tvaudio = 1,
.pll = PLL_28,
.tuner_type = 2,
@@ -2813,7 +2879,7 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 0x108007,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 100000, 100002, 100002, 100000 },
+ .gpiomux = { 100000, 100002, 100002, 100000 },
.no_msp34xx = 1,
.no_tda9875 = 1,
.no_tda7432 = 1,
@@ -2853,7 +2919,8 @@ struct tvcard bttv_tvcards[] = {
.svhs = 2,
.gpiomask = 7,
.muxsel = { 2, 3, 1, 1 },
- .audiomux = { 0, 1, 2, 3, 4 },
+ .gpiomux = { 0, 1, 2, 3 },
+ .gpiomute = 4,
.tuner_type = TUNER_TEMIC_4009FR5_PAL,
.tuner_addr = ADDR_UNSET,
.radio_addr = ADDR_UNSET,
@@ -2925,20 +2992,20 @@ void __devinit bttv_idcard(struct bttv *btv)
if (UNSET != audiomux[0]) {
gpiobits = 0;
for (i = 0; i < 5; i++) {
- bttv_tvcards[btv->c.type].audiomux[i] = audiomux[i];
+ bttv_tvcards[btv->c.type].gpiomux[i] = audiomux[i];
gpiobits |= audiomux[i];
}
} else {
gpiobits = audioall;
for (i = 0; i < 5; i++) {
- bttv_tvcards[btv->c.type].audiomux[i] = audioall;
+ bttv_tvcards[btv->c.type].gpiomux[i] = audioall;
}
}
bttv_tvcards[btv->c.type].gpiomask = (UNSET != gpiomask) ? gpiomask : gpiobits;
printk(KERN_INFO "bttv%d: gpio config override: mask=0x%x, mux=",
btv->c.nr,bttv_tvcards[btv->c.type].gpiomask);
for (i = 0; i < 5; i++) {
- printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].audiomux[i]);
+ printk("%s0x%x", i ? "," : "", bttv_tvcards[btv->c.type].gpiomux[i]);
}
printk("\n");
}
@@ -3046,7 +3113,7 @@ static void miro_pinnacle_gpio(struct bttv *btv)
gpio_inout(0xffffff, 0);
gpio = gpio_read();
id = ((gpio>>10) & 63) -1;
- msp = bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx");
+ msp = bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx");
if (id < 32) {
btv->tuner_type = miro_tunermap[id];
if (0 == (gpio & 0x20)) {
@@ -3442,8 +3509,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
if (bttv_tvcards[btv->c.type].digital_mode == DIGITAL_MODE_CAMERA) {
/* detect Bt832 chip for quartzsight digital camera */
- if ((bttv_I2CRead(btv, I2C_BT832_ALT1, "Bt832") >=0) ||
- (bttv_I2CRead(btv, I2C_BT832_ALT2, "Bt832") >=0))
+ if ((bttv_I2CRead(btv, I2C_ADDR_BT832_ALT1, "Bt832") >=0) ||
+ (bttv_I2CRead(btv, I2C_ADDR_BT832_ALT2, "Bt832") >=0))
boot_bt832(btv);
}
@@ -3452,19 +3519,19 @@ void __devinit bttv_init_card2(struct bttv *btv)
/* try to detect audio/fader chips */
if (!bttv_tvcards[btv->c.type].no_msp34xx &&
- bttv_I2CRead(btv, I2C_MSP3400, "MSP34xx") >=0)
+ bttv_I2CRead(btv, I2C_ADDR_MSP3400, "MSP34xx") >=0)
request_module("msp3400");
if (bttv_tvcards[btv->c.type].msp34xx_alt &&
- bttv_I2CRead(btv, I2C_MSP3400_ALT, "MSP34xx (alternate address)") >=0)
+ bttv_I2CRead(btv, I2C_ADDR_MSP3400_ALT, "MSP34xx (alternate address)") >=0)
request_module("msp3400");
if (!bttv_tvcards[btv->c.type].no_tda9875 &&
- bttv_I2CRead(btv, I2C_TDA9875, "TDA9875") >=0)
+ bttv_I2CRead(btv, I2C_ADDR_TDA9875, "TDA9875") >=0)
request_module("tda9875");
if (!bttv_tvcards[btv->c.type].no_tda7432 &&
- bttv_I2CRead(btv, I2C_TDA7432, "TDA7432") >=0)
+ bttv_I2CRead(btv, I2C_ADDR_TDA7432, "TDA7432") >=0)
request_module("tda7432");
if (bttv_tvcards[btv->c.type].needs_tvaudio)
@@ -3475,7 +3542,7 @@ void __devinit bttv_init_card2(struct bttv *btv)
if (btv->tda9887_conf)
tda9887 = 1;
if (0 == tda9887 && 0 == bttv_tvcards[btv->c.type].has_dvb &&
- bttv_I2CRead(btv, I2C_TDA9887, "TDA9887") >=0)
+ bttv_I2CRead(btv, I2C_ADDR_TDA9887, "TDA9887") >=0)
tda9887 = 1;
/* Hybrid DVB card, DOES have a tda9887 */
if (btv->c.type == BTTV_BOARD_DVICO_FUSIONHDTV_5_LITE)
@@ -3796,18 +3863,18 @@ void bttv_tda9880_setnorm(struct bttv *btv, int norm)
{
/* fix up our card entry */
if(norm==VIDEO_MODE_NTSC) {
- bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[0]=0x957fff;
- bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[4]=0x957fff;
+ bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x957fff;
+ bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x957fff;
dprintk("bttv_tda9880_setnorm to NTSC\n");
}
else {
- bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[0]=0x947fff;
- bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].audiomux[4]=0x947fff;
+ bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomux[TVAUDIO_INPUT_TUNER]=0x947fff;
+ bttv_tvcards[BTTV_BOARD_VOODOOTV_FM].gpiomute=0x947fff;
dprintk("bttv_tda9880_setnorm to PAL\n");
}
/* set GPIO according */
gpio_bits(bttv_tvcards[btv->c.type].gpiomask,
- bttv_tvcards[btv->c.type].audiomux[btv->audio]);
+ bttv_tvcards[btv->c.type].gpiomux[btv->audio]);
}
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bt8xx/bttv-driver.c
index c0415d6e7fe..74def9c2395 100644
--- a/drivers/media/video/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -36,13 +36,15 @@
#include <linux/kdev_t.h>
#include "bttvp.h"
#include <media/v4l2-common.h>
+#include <media/tvaudio.h>
+#include <media/msp3400.h>
#include <linux/dma-mapping.h>
#include <asm/io.h>
#include <asm/byteorder.h>
-#include "rds.h"
+#include <media/rds.h>
unsigned int bttv_num; /* number of Bt848s in use */
@@ -926,45 +928,98 @@ video_mux(struct bttv *btv, unsigned int input)
static char *audio_modes[] = {
"audio: tuner", "audio: radio", "audio: extern",
- "audio: intern", "audio: off"
+ "audio: intern", "audio: mute"
};
static int
-audio_mux(struct bttv *btv, int mode)
+audio_mux(struct bttv *btv, int input, int mute)
{
- int val,mux,i2c_mux,signal;
+ int gpio_val, signal;
+ struct v4l2_control ctrl;
+ struct i2c_client *c;
gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
bttv_tvcards[btv->c.type].gpiomask);
signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
- switch (mode) {
- case AUDIO_MUTE:
- btv->audio |= AUDIO_MUTE;
- break;
- case AUDIO_UNMUTE:
- btv->audio &= ~AUDIO_MUTE;
- break;
- case AUDIO_TUNER:
- case AUDIO_RADIO:
- case AUDIO_EXTERN:
- case AUDIO_INTERN:
- btv->audio &= AUDIO_MUTE;
- btv->audio |= mode;
- }
- i2c_mux = mux = (btv->audio & AUDIO_MUTE) ? AUDIO_OFF : btv->audio;
- if (btv->opt_automute && !signal && !btv->radio_user)
- mux = AUDIO_OFF;
-
- val = bttv_tvcards[btv->c.type].audiomux[mux];
- gpio_bits(bttv_tvcards[btv->c.type].gpiomask,val);
+ btv->mute = mute;
+ btv->audio = input;
+
+ /* automute */
+ mute = mute || (btv->opt_automute && !signal && !btv->radio_user);
+
+ if (mute)
+ gpio_val = bttv_tvcards[btv->c.type].gpiomute;
+ else
+ gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
+
+ gpio_bits(bttv_tvcards[btv->c.type].gpiomask, gpio_val);
if (bttv_gpio)
- bttv_gpio_tracking(btv,audio_modes[mux]);
- if (!in_interrupt())
- bttv_call_i2c_clients(btv,AUDC_SET_INPUT,&(i2c_mux));
+ bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]);
+ if (in_interrupt())
+ return 0;
+
+ ctrl.id = V4L2_CID_AUDIO_MUTE;
+ ctrl.value = btv->mute;
+ bttv_call_i2c_clients(btv, VIDIOC_S_CTRL, &ctrl);
+ c = btv->i2c_msp34xx_client;
+ if (c) {
+ struct v4l2_routing route;
+
+ /* Note: the inputs tuner/radio/extern/intern are translated
+ to msp routings. This assumes common behavior for all msp3400
+ based TV cards. When this assumption fails, then the
+ specific MSP routing must be added to the card table.
+ For now this is sufficient. */
+ switch (input) {
+ case TVAUDIO_INPUT_RADIO:
+ route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1,
+ MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
+ break;
+ case TVAUDIO_INPUT_EXTERN:
+ route.input = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1,
+ MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
+ break;
+ case TVAUDIO_INPUT_INTERN:
+ /* Yes, this is the same input as for RADIO. I doubt
+ if this is ever used. The only board with an INTERN
+ input is the BTTV_BOARD_AVERMEDIA98. I wonder how
+ that was tested. My guess is that the whole INTERN
+ input does not work. */
+ route.input = MSP_INPUT(MSP_IN_SCART_2, MSP_IN_TUNER_1,
+ MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART);
+ break;
+ case TVAUDIO_INPUT_TUNER:
+ default:
+ route.input = MSP_INPUT_DEFAULT;
+ break;
+ }
+ route.output = MSP_OUTPUT_DEFAULT;
+ c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route);
+ }
+ c = btv->i2c_tvaudio_client;
+ if (c) {
+ struct v4l2_routing route;
+
+ route.input = input;
+ route.output = 0;
+ c->driver->command(c, VIDIOC_INT_S_AUDIO_ROUTING, &route);
+ }
return 0;
}
+static inline int
+audio_mute(struct bttv *btv, int mute)
+{
+ return audio_mux(btv, btv->audio, mute);
+}
+
+static inline int
+audio_input(struct bttv *btv, int input)
+{
+ return audio_mux(btv, input, btv->mute);
+}
+
static void
i2c_vidiocschan(struct bttv *btv)
{
@@ -1023,8 +1078,8 @@ set_input(struct bttv *btv, unsigned int input)
} else {
video_mux(btv,input);
}
- audio_mux(btv,(input == bttv_tvcards[btv->c.type].tuner ?
- AUDIO_TUNER : AUDIO_EXTERN));
+ audio_input(btv,(input == bttv_tvcards[btv->c.type].tuner ?
+ TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN));
set_tvnorm(btv,btv->tvnorm);
i2c_vidiocschan(btv);
}
@@ -1236,10 +1291,10 @@ static int set_control(struct bttv *btv, struct v4l2_control *c)
case V4L2_CID_AUDIO_MUTE:
if (c->value) {
va.flags |= VIDEO_AUDIO_MUTE;
- audio_mux(btv, AUDIO_MUTE);
+ audio_mute(btv, 1);
} else {
va.flags &= ~VIDEO_AUDIO_MUTE;
- audio_mux(btv, AUDIO_UNMUTE);
+ audio_mute(btv, 0);
}
break;
@@ -1397,7 +1452,7 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
free_btres(btv,fh,RESOURCE_OVERLAY);
if (NULL != old) {
dprintk("switch_overlay: old=%p state is %d\n",old,old->vb.state);
- bttv_dma_free(btv, old);
+ bttv_dma_free(&fh->cap,btv, old);
kfree(old);
}
dprintk("switch_overlay: done\n");
@@ -1407,7 +1462,8 @@ bttv_switch_overlay(struct bttv *btv, struct bttv_fh *fh,
/* ----------------------------------------------------------------------- */
/* video4linux (1) interface */
-static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
+static int bttv_prepare_buffer(struct videobuf_queue *q,struct bttv *btv,
+ struct bttv_buffer *buf,
const struct bttv_format *fmt,
unsigned int width, unsigned int height,
enum v4l2_field field)
@@ -1450,7 +1506,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
/* alloc risc memory */
if (STATE_NEEDS_INIT == buf->vb.state) {
redo_dma_risc = 1;
- if (0 != (rc = videobuf_iolock(btv->c.pci,&buf->vb,&btv->fbuf)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,&btv->fbuf)))
goto fail;
}
@@ -1462,7 +1518,7 @@ static int bttv_prepare_buffer(struct bttv *btv, struct bttv_buffer *buf,
return 0;
fail:
- bttv_dma_free(btv,buf);
+ bttv_dma_free(q,btv,buf);
return rc;
}
@@ -1486,7 +1542,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
struct bttv_fh *fh = q->priv_data;
- return bttv_prepare_buffer(fh->btv, buf, fh->fmt,
+ return bttv_prepare_buffer(q,fh->btv, buf, fh->fmt,
fh->width, fh->height, field);
}
@@ -1510,7 +1566,7 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
struct bttv_fh *fh = q->priv_data;
- bttv_dma_free(fh->btv,buf);
+ bttv_dma_free(&fh->cap,fh->btv,buf);
}
static struct videobuf_queue_ops bttv_video_qops = {
@@ -1653,7 +1709,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
return -EINVAL;
mutex_lock(&btv->lock);
- audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE);
+ audio_mute(btv, (v->flags&VIDEO_AUDIO_MUTE) ? 1 : 0);
bttv_call_i2c_clients(btv,cmd,v);
/* card specific hooks */
@@ -1822,7 +1878,8 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg)
bttv_call_i2c_clients(btv, VIDIOCGAUDIO, &va);
if (t->audmode == V4L2_TUNER_MODE_MONO)
va.mode = VIDEO_SOUND_MONO;
- else if (t->audmode == V4L2_TUNER_MODE_STEREO)
+ else if (t->audmode == V4L2_TUNER_MODE_STEREO ||
+ t->audmode == V4L2_TUNER_MODE_LANG1_LANG2)
va.mode = VIDEO_SOUND_STEREO;
else if (t->audmode == V4L2_TUNER_MODE_LANG1)
va.mode = VIDEO_SOUND_LANG1;
@@ -2496,7 +2553,7 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
field = (vm->height > bttv_tvnorms[btv->tvnorm].sheight/2)
? V4L2_FIELD_INTERLACED
: V4L2_FIELD_BOTTOM;
- retval = bttv_prepare_buffer(btv,buf,
+ retval = bttv_prepare_buffer(&fh->cap,btv,buf,
format_by_palette(vm->format),
vm->width,vm->height,field);
if (0 != retval)
@@ -2528,8 +2585,8 @@ static int bttv_do_ioctl(struct inode *inode, struct file *file,
retval = -EIO;
/* fall through */
case STATE_DONE:
- videobuf_dma_pci_sync(btv->c.pci,&buf->vb.dma);
- bttv_dma_free(btv,buf);
+ videobuf_dma_sync(&fh->cap,&buf->vb.dma);
+ bttv_dma_free(&fh->cap,btv,buf);
break;
default:
retval = -EINVAL;
@@ -3162,8 +3219,8 @@ static int radio_open(struct inode *inode, struct file *file)
file->private_data = btv;
- bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type);
- audio_mux(btv,AUDIO_RADIO);
+ bttv_call_i2c_clients(btv,AUDC_SET_RADIO,NULL);
+ audio_input(btv,TVAUDIO_INPUT_RADIO);
mutex_unlock(&btv->lock);
return 0;
@@ -3749,7 +3806,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id, struct pt_regs * regs)
bttv_irq_switch_video(btv);
if ((astat & BT848_INT_HLOCK) && btv->opt_automute)
- audio_mux(btv, -1);
+ audio_mute(btv, btv->mute); /* trigger automute */
if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
printk(KERN_INFO "bttv%d: %s%s @ %08x,",btv->c.nr,
@@ -4050,7 +4107,7 @@ static int __devinit bttv_probe(struct pci_dev *dev,
bt848_contrast(btv,32768);
bt848_hue(btv,32768);
bt848_sat(btv,32768);
- audio_mux(btv,AUDIO_MUTE);
+ audio_mute(btv, 1);
set_input(btv,0);
}
diff --git a/drivers/media/video/bttv-gpio.c b/drivers/media/video/bt8xx/bttv-gpio.c
index c4d5e2b70c2..c4d5e2b70c2 100644
--- a/drivers/media/video/bttv-gpio.c
+++ b/drivers/media/video/bt8xx/bttv-gpio.c
diff --git a/drivers/media/video/bttv-i2c.c b/drivers/media/video/bt8xx/bttv-i2c.c
index 614c1201855..4b562b386fc 100644
--- a/drivers/media/video/bttv-i2c.c
+++ b/drivers/media/video/bt8xx/bttv-i2c.c
@@ -302,6 +302,10 @@ static int attach_inform(struct i2c_client *client)
if (!client->driver->command)
return 0;
+ if (client->driver->id == I2C_DRIVERID_MSP3400)
+ btv->i2c_msp34xx_client = client;
+ if (client->driver->id == I2C_DRIVERID_TVAUDIO)
+ btv->i2c_tvaudio_client = client;
if (btv->tuner_type != UNSET) {
struct tuner_setup tun_setup;
diff --git a/drivers/media/video/bttv-if.c b/drivers/media/video/bt8xx/bttv-if.c
index 19b564ab0e9..19b564ab0e9 100644
--- a/drivers/media/video/bttv-if.c
+++ b/drivers/media/video/bt8xx/bttv-if.c
diff --git a/drivers/media/video/bttv-input.c b/drivers/media/video/bt8xx/bttv-input.c
index 69efa0e5174..69efa0e5174 100644
--- a/drivers/media/video/bttv-input.c
+++ b/drivers/media/video/bt8xx/bttv-input.c
diff --git a/drivers/media/video/bttv-risc.c b/drivers/media/video/bt8xx/bttv-risc.c
index 344f84e9af0..16323a5d68a 100644
--- a/drivers/media/video/bttv-risc.c
+++ b/drivers/media/video/bt8xx/bttv-risc.c
@@ -509,11 +509,11 @@ bttv_risc_hook(struct bttv *btv, int slot, struct btcx_riscmem *risc,
}
void
-bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf)
+bttv_dma_free(struct videobuf_queue *q,struct bttv *btv, struct bttv_buffer *buf)
{
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(btv->c.pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
btcx_riscmem_free(btv->c.pci,&buf->bottom);
btcx_riscmem_free(btv->c.pci,&buf->top);
diff --git a/drivers/media/video/bttv-vbi.c b/drivers/media/video/bt8xx/bttv-vbi.c
index 72afdd64b88..e20ff238e40 100644
--- a/drivers/media/video/bttv-vbi.c
+++ b/drivers/media/video/bt8xx/bttv-vbi.c
@@ -96,7 +96,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
return -EINVAL;
if (STATE_NEEDS_INIT == buf->vb.state) {
- if (0 != (rc = videobuf_iolock(btv->c.pci, &buf->vb, NULL)))
+ if (0 != (rc = videobuf_iolock(q, &buf->vb, NULL)))
goto fail;
if (0 != (rc = vbi_buffer_risc(btv,buf,fh->lines)))
goto fail;
@@ -109,7 +109,7 @@ static int vbi_buffer_prepare(struct videobuf_queue *q,
return 0;
fail:
- bttv_dma_free(btv,buf);
+ bttv_dma_free(q,btv,buf);
return rc;
}
@@ -136,7 +136,7 @@ static void vbi_buffer_release(struct videobuf_queue *q, struct videobuf_buffer
struct bttv_buffer *buf = container_of(vb,struct bttv_buffer,vb);
dprintk("free %p\n",vb);
- bttv_dma_free(fh->btv,buf);
+ bttv_dma_free(&fh->cap,fh->btv,buf);
}
struct videobuf_queue_ops bttv_vbi_qops = {
diff --git a/drivers/media/video/bttv.h b/drivers/media/video/bt8xx/bttv.h
index 9908c8e0c95..3a23265c153 100644
--- a/drivers/media/video/bttv.h
+++ b/drivers/media/video/bt8xx/bttv.h
@@ -18,6 +18,7 @@
#include <linux/i2c.h>
#include <media/ir-common.h>
#include <media/ir-kbd-i2c.h>
+#include <media/i2c-addr.h>
/* ---------------------------------------------------------- */
/* exported by bttv-cards.c */
@@ -168,25 +169,6 @@
#define BTTV_BOARD_HAUPPAUGE_IMPACTVCB 0x8f
#define BTTV_BOARD_MACHTV_MAGICTV 0x90
-/* i2c address list */
-#define I2C_TSA5522 0xc2
-#define I2C_TDA7432 0x8a
-#define I2C_BT832_ALT1 0x88
-#define I2C_BT832_ALT2 0x8a // alternate setting
-#define I2C_TDA8425 0x82
-#define I2C_TDA9840 0x84
-#define I2C_TDA9850 0xb6 /* also used by 9855,9873 */
-#define I2C_TDA9874 0xb0 /* also used by 9875 */
-#define I2C_TDA9875 0xb0
-#define I2C_HAUPEE 0xa0
-#define I2C_STBEE 0xae
-#define I2C_VHX 0xc0
-#define I2C_MSP3400 0x80
-#define I2C_MSP3400_ALT 0x88
-#define I2C_TEA6300 0x80 /* also used by 6320 */
-#define I2C_DPL3518 0x84
-#define I2C_TDA9887 0x86
-
/* more card-specific defines */
#define PT2254_L_CHANNEL 0x10
#define PT2254_R_CHANNEL 0x08
@@ -252,7 +234,8 @@ struct tvcard
unsigned int digital_mode; // DIGITAL_MODE_CAMERA or DIGITAL_MODE_VIDEO
u32 gpiomask;
u32 muxsel[16];
- u32 audiomux[6]; /* Tuner, Radio, external, internal, mute, stereo */
+ u32 gpiomux[4]; /* Tuner, Radio, external, internal */
+ u32 gpiomute; /* GPIO mute setting */
u32 gpiomask2; /* GPIO MUX mask */
/* i2c audio flags */
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bt8xx/bttvp.h
index 9cb72f176f7..ee989d2e15d 100644
--- a/drivers/media/video/bttvp.h
+++ b/drivers/media/video/bt8xx/bttvp.h
@@ -41,7 +41,6 @@
#include <linux/device.h>
#include <media/video-buf.h>
-#include <media/audiochip.h>
#include <media/tuner.h>
#include <media/tveeprom.h>
#include <media/ir-common.h>
@@ -190,7 +189,8 @@ int bttv_buffer_activate_video(struct bttv *btv,
struct bttv_buffer_set *set);
int bttv_buffer_activate_vbi(struct bttv *btv,
struct bttv_buffer *vbi);
-void bttv_dma_free(struct bttv *btv, struct bttv_buffer *buf);
+void bttv_dma_free(struct videobuf_queue *q, struct bttv *btv,
+ struct bttv_buffer *buf);
/* overlay handling */
int bttv_overlay_risc(struct bttv *btv, struct bttv_overlay *ov,
@@ -298,6 +298,8 @@ struct bttv {
int i2c_state, i2c_rc;
int i2c_done;
wait_queue_head_t i2c_queue;
+ struct i2c_client *i2c_msp34xx_client;
+ struct i2c_client *i2c_tvaudio_client;
/* video4linux (1) */
struct video_device *video_dev;
@@ -320,6 +322,7 @@ struct bttv {
/* video state */
unsigned int input;
unsigned int audio;
+ unsigned int mute;
unsigned long freq;
int tvnorm,hue,contrast,bright,saturation;
struct v4l2_framebuffer fbuf;
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index d97b7d8ac33..cf61c590f4a 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -150,7 +150,7 @@ static int qc_calibrate(struct qcam_device *q)
static struct qcam_device *qcam_init(struct parport *port)
{
struct qcam_device *q;
-
+
q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
if(q==NULL)
return NULL;
@@ -158,16 +158,16 @@ static struct qcam_device *qcam_init(struct parport *port)
q->pport = port;
q->pdev = parport_register_device(port, "bw-qcam", NULL, NULL,
NULL, 0, NULL);
- if (q->pdev == NULL)
+ if (q->pdev == NULL)
{
printk(KERN_ERR "bw-qcam: couldn't register for %s.\n",
port->name);
kfree(q);
return NULL;
}
-
+
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
-
+
mutex_init(&q->lock);
q->port_mode = (QC_ANY | QC_NOTSET);
@@ -236,12 +236,12 @@ static int qc_waithand(struct qcam_device *q, int val)
while (!((status = read_lpstatus(q)) & 8))
{
/* 1000 is enough spins on the I/O for all normal
- cases, at that point we start to poll slowly
+ cases, at that point we start to poll slowly
until the camera wakes up. However, we are
busy blocked until the camera responds, so
setting it lower is much better for interactive
response. */
-
+
if(runs++>maxpoll)
{
msleep_interruptible(5);
@@ -255,12 +255,12 @@ static int qc_waithand(struct qcam_device *q, int val)
while (((status = read_lpstatus(q)) & 8))
{
/* 1000 is enough spins on the I/O for all normal
- cases, at that point we start to poll slowly
+ cases, at that point we start to poll slowly
until the camera wakes up. However, we are
busy blocked until the camera responds, so
setting it lower is much better for interactive
response. */
-
+
if(runs++>maxpoll)
{
msleep_interruptible(5);
@@ -282,17 +282,17 @@ static unsigned int qc_waithand2(struct qcam_device *q, int val)
{
unsigned int status;
int runs=0;
-
- do
+
+ do
{
status = read_lpdata(q);
/* 1000 is enough spins on the I/O for all normal
- cases, at that point we start to poll slowly
+ cases, at that point we start to poll slowly
until the camera wakes up. However, we are
busy blocked until the camera responds, so
setting it lower is much better for interactive
response. */
-
+
if(runs++>maxpoll)
{
msleep_interruptible(5);
@@ -321,7 +321,7 @@ static int qc_detect(struct qcam_device *q)
lastreg = reg = read_lpstatus(q) & 0xf0;
- for (i = 0; i < 500; i++)
+ for (i = 0; i < 500; i++)
{
reg = read_lpstatus(q) & 0xf0;
if (reg != lastreg)
@@ -357,7 +357,7 @@ static int qc_detect(struct qcam_device *q)
static void qc_reset(struct qcam_device *q)
{
- switch (q->port_mode & QC_FORCE_MASK)
+ switch (q->port_mode & QC_FORCE_MASK)
{
case QC_FORCE_UNIDIR:
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_UNIDIR;
@@ -370,7 +370,7 @@ static void qc_reset(struct qcam_device *q)
case QC_ANY:
write_lpcontrol(q, 0x20);
write_lpdata(q, 0x75);
-
+
if (read_lpdata(q) != 0x75) {
q->port_mode = (q->port_mode & ~QC_MODE_MASK) | QC_BIDIR;
} else {
@@ -398,8 +398,8 @@ static void qc_reset(struct qcam_device *q)
static int qc_setscanmode(struct qcam_device *q)
{
int old_mode = q->mode;
-
- switch (q->transfer_scale)
+
+ switch (q->transfer_scale)
{
case 1:
q->mode = 0;
@@ -412,7 +412,7 @@ static int qc_setscanmode(struct qcam_device *q)
break;
}
- switch (q->bpp)
+ switch (q->bpp)
{
case 4:
break;
@@ -421,7 +421,7 @@ static int qc_setscanmode(struct qcam_device *q)
break;
}
- switch (q->port_mode & QC_MODE_MASK)
+ switch (q->port_mode & QC_MODE_MASK)
{
case QC_BIDIR:
q->mode += 1;
@@ -430,10 +430,10 @@ static int qc_setscanmode(struct qcam_device *q)
case QC_UNIDIR:
break;
}
-
+
if (q->mode != old_mode)
q->status |= QC_PARAM_CHANGE;
-
+
return 0;
}
@@ -451,7 +451,7 @@ static void qc_set(struct qcam_device *q)
/* Set the brightness. Yes, this is repetitive, but it works.
* Shorter versions seem to fail subtly. Feel free to try :-). */
/* I think the problem was in qc_command, not here -- bls */
-
+
qc_command(q, 0xb);
qc_command(q, q->brightness);
@@ -502,13 +502,13 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
unsigned int hi2, lo2;
static int state = 0;
- if (buffer == NULL)
+ if (buffer == NULL)
{
state = 0;
return 0;
}
-
- switch (q->port_mode & QC_MODE_MASK)
+
+ switch (q->port_mode & QC_MODE_MASK)
{
case QC_BIDIR: /* Bi-directional Port */
write_lpcontrol(q, 0x26);
@@ -517,7 +517,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
write_lpcontrol(q, 0x2e);
lo2 = (qc_waithand2(q, 0) >> 1);
hi2 = (read_lpstatus(q) >> 3) & 0x1f;
- switch (q->bpp)
+ switch (q->bpp)
{
case 4:
buffer[0] = lo & 0xf;
@@ -544,7 +544,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
write_lpcontrol(q, 0xe);
hi = (qc_waithand(q, 0) & 0xf0) >> 4;
- switch (q->bpp)
+ switch (q->bpp)
{
case 4:
buffer[0] = lo;
@@ -552,7 +552,7 @@ static inline int qc_readbytes(struct qcam_device *q, char buffer[])
ret = 2;
break;
case 6:
- switch (state)
+ switch (state)
{
case 0:
buffer[0] = (lo << 2) | ((hi & 0xc) >> 2);
@@ -604,13 +604,13 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
int shift=8-q->bpp;
char invert;
- if (q->mode == -1)
+ if (q->mode == -1)
return -ENXIO;
qc_command(q, 0x7);
qc_command(q, q->mode);
- if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
+ if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
{
write_lpcontrol(q, 0x2e); /* turn port around */
write_lpcontrol(q, 0x26);
@@ -618,7 +618,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
write_lpcontrol(q, 0x2e);
(void) qc_waithand(q, 0);
}
-
+
/* strange -- should be 15:63 below, but 4bpp is odd */
invert = (q->bpp == 4) ? 16 : 63;
@@ -629,15 +629,15 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
q->transfer_scale;
transperline = (transperline + divisor - 1) / divisor;
- for (i = 0, yield = yieldlines; i < linestotrans; i++)
+ for (i = 0, yield = yieldlines; i < linestotrans; i++)
{
- for (pixels_read = j = 0; j < transperline; j++)
+ for (pixels_read = j = 0; j < transperline; j++)
{
bytes = qc_readbytes(q, buffer);
- for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++)
+ for (k = 0; k < bytes && (pixels_read + k) < pixels_per_line; k++)
{
int o;
- if (buffer[k] == 0 && invert == 16)
+ if (buffer[k] == 0 && invert == 16)
{
/* 4bpp is odd (again) -- inverter is 16, not 15, but output
must be 0-15 -- bls */
@@ -653,7 +653,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
pixels_read += bytes;
}
(void) qc_readbytes(q, NULL); /* reset state machine */
-
+
/* Grabbing an entire frame from the quickcam is a lengthy
process. We don't (usually) want to busy-block the
processor for the entire frame. yieldlines is a module
@@ -666,7 +666,7 @@ static long qc_capture(struct qcam_device * q, char __user *buf, unsigned long l
}
}
- if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
+ if ((q->port_mode & QC_MODE_MASK) == QC_BIDIR)
{
write_lpcontrol(q, 2);
write_lpcontrol(q, 6);
@@ -687,7 +687,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
{
struct video_device *dev = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)dev;
-
+
switch(cmd)
{
case VIDIOCGCAP:
@@ -762,7 +762,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
if(p->depth!=4 && p->depth!=6)
return -EINVAL;
-
+
/*
* Now load the camera.
*/
@@ -790,11 +790,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
if(vw->width<80||vw->width>320)
return -EINVAL;
-
+
qcam->width = 320;
qcam->height = 240;
qcam->transfer_scale = 4;
-
+
if(vw->width>=160 && vw->height>=120)
{
qcam->transfer_scale = 2;
@@ -808,11 +808,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
mutex_lock(&qcam->lock);
qc_setscanmode(qcam);
mutex_unlock(&qcam->lock);
-
+
/* We must update the camera before we grab. We could
just have changed the grab size */
qcam->status |= QC_PARAM_CHANGE;
-
+
/* Ok we figured out what to use from our wide choice */
return 0;
}
@@ -853,9 +853,9 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
struct qcam_device *qcam=(struct qcam_device *)v;
int len;
parport_claim_or_block(qcam->pdev);
-
+
mutex_lock(&qcam->lock);
-
+
qc_reset(qcam);
/* Update the camera parameters if we need to */
@@ -863,13 +863,13 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
qc_set(qcam);
len=qc_capture(qcam, buf,count);
-
+
mutex_unlock(&qcam->lock);
-
+
parport_release(qcam->pdev);
return len;
}
-
+
static struct file_operations qcam_fops = {
.owner = THIS_MODULE,
.open = video_exclusive_open,
@@ -905,11 +905,11 @@ static int init_bwqcam(struct parport *port)
qcam=qcam_init(port);
if(qcam==NULL)
return -ENODEV;
-
+
parport_claim_or_block(qcam->pdev);
qc_reset(qcam);
-
+
if(qc_detect(qcam)==0)
{
parport_release(qcam->pdev);
@@ -920,9 +920,9 @@ static int init_bwqcam(struct parport *port)
qc_calibrate(qcam);
parport_release(qcam->pdev);
-
+
printk(KERN_INFO "Connectix Quickcam on %s\n", qcam->pport->name);
-
+
if(video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
{
parport_unregister_device(qcam->pdev);
@@ -1013,7 +1013,7 @@ static int __init init_bw_qcams(void)
printk("Connectix Quickcam max-poll was above 5000. Using 5000.\n");
maxpoll = 5000;
}
-
+
if (yieldlines < 1) {
printk("Connectix Quickcam yieldlines was less than 1. Using 1.\n");
yieldlines = 1;
diff --git a/drivers/media/video/c-qcam.c b/drivers/media/video/c-qcam.c
index 8211fd8d7cb..22a7386bbea 100644
--- a/drivers/media/video/c-qcam.c
+++ b/drivers/media/video/c-qcam.c
@@ -16,7 +16,7 @@
*
* The parport parameter controls which parports will be scanned.
* Scanning all parports causes some printers to print a garbage page.
- * -- March 14, 1999 Billy Donahue <billy@escape.com>
+ * -- March 14, 1999 Billy Donahue <billy@escape.com>
*
* Fixed data format to BGR, added force_rgb parameter. Added missing
* parport_unregister_driver() on module removal.
@@ -88,7 +88,7 @@ static inline unsigned int qcam_ready2(struct qcam_device *qcam)
return (parport_read_data(qcam->pport) & 0x1)?1:0;
}
-static unsigned int qcam_await_ready1(struct qcam_device *qcam,
+static unsigned int qcam_await_ready1(struct qcam_device *qcam,
int value)
{
unsigned long oldjiffies = jiffies;
@@ -98,7 +98,7 @@ static unsigned int qcam_await_ready1(struct qcam_device *qcam,
if (qcam_ready1(qcam) == value)
return 0;
- /* If the camera didn't respond within 1/25 second, poll slowly
+ /* If the camera didn't respond within 1/25 second, poll slowly
for a while. */
for (i = 0; i < 50; i++)
{
@@ -123,7 +123,7 @@ static unsigned int qcam_await_ready2(struct qcam_device *qcam, int value)
if (qcam_ready2(qcam) == value)
return 0;
- /* If the camera didn't respond within 1/25 second, poll slowly
+ /* If the camera didn't respond within 1/25 second, poll slowly
for a while. */
for (i = 0; i < 50; i++)
{
@@ -157,12 +157,12 @@ static int qcam_write_data(struct qcam_device *qcam, unsigned int data)
unsigned int idata;
parport_write_data(qcam->pport, data);
idata = qcam_read_data(qcam);
- if (data != idata)
+ if (data != idata)
{
- printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
+ printk(KERN_WARNING "cqcam: sent %x but received %x\n", data,
idata);
return 1;
- }
+ }
return 0;
}
@@ -193,12 +193,12 @@ static int qc_detect(struct qcam_device *qcam)
no device was found". Fix this one day. */
if (qcam->pport->probe_info[0].class == PARPORT_CLASS_MEDIA
&& qcam->pport->probe_info[0].model
- && !strcmp(qcam->pdev->port->probe_info[0].model,
+ && !strcmp(qcam->pdev->port->probe_info[0].model,
"Color QuickCam 2.0")) {
printk(KERN_DEBUG "QuickCam: Found by IEEE1284 probe.\n");
return 1;
}
-
+
if (probe < 2)
return 0;
@@ -206,11 +206,11 @@ static int qc_detect(struct qcam_device *qcam)
/* look for a heartbeat */
ostat = stat = parport_read_status(qcam->pport);
- for (i=0; i<250; i++)
+ for (i=0; i<250; i++)
{
mdelay(1);
stat = parport_read_status(qcam->pport);
- if (ostat != stat)
+ if (ostat != stat)
{
if (++count >= 3) return 1;
ostat = stat;
@@ -226,11 +226,11 @@ static int qc_detect(struct qcam_device *qcam)
count = 0;
ostat = stat = parport_read_status(qcam->pport);
- for (i=0; i<250; i++)
+ for (i=0; i<250; i++)
{
mdelay(1);
stat = parport_read_status(qcam->pport);
- if (ostat != stat)
+ if (ostat != stat)
{
if (++count >= 3) return 1;
ostat = stat;
@@ -247,7 +247,7 @@ static void qc_reset(struct qcam_device *qcam)
parport_write_control(qcam->pport, 0x8);
mdelay(1);
parport_write_control(qcam->pport, 0xc);
- mdelay(1);
+ mdelay(1);
}
/* Reset the QuickCam and program for brightness, contrast,
@@ -258,7 +258,7 @@ static void qc_setup(struct qcam_device *q)
qc_reset(q);
/* Set the brightness. */
- qcam_set(q, 11, q->brightness);
+ qcam_set(q, 11, q->brightness);
/* Set the height and width. These refer to the actual
CCD area *before* applying the selected decimation. */
@@ -272,12 +272,12 @@ static void qc_setup(struct qcam_device *q)
/* Set contrast and white balance. */
qcam_set(q, 0x19, q->contrast);
qcam_set(q, 0x1f, q->whitebal);
-
+
/* Set the speed. */
qcam_set(q, 45, 2);
}
-/* Read some bytes from the camera and put them in the buffer.
+/* Read some bytes from the camera and put them in the buffer.
nbytes should be a multiple of 3, because bidirectional mode gives
us three bytes at a time. */
@@ -383,7 +383,7 @@ static long qc_capture(struct qcam_device *q, char __user *buf, unsigned long le
if (qcam_set(q, 7, (q->mode | (is_bi_dir?1:0)) + 1))
return -EIO;
-
+
lines = q->height;
pixelsperline = q->width;
bitsperxfer = (is_bi_dir) ? 24 : 8;
@@ -499,7 +499,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
{
struct video_device *dev = video_devdata(file);
struct qcam_device *qcam=(struct qcam_device *)dev;
-
+
switch(cmd)
{
case VIDIOCGCAP:
@@ -574,7 +574,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
*/
if (p->depth != 24 || p->palette != VIDEO_PALETTE_RGB24)
return -EINVAL;
-
+
/*
* Now load the camera.
*/
@@ -584,7 +584,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
- qc_setup(qcam);
+ qc_setup(qcam);
parport_release(qcam->pdev);
mutex_unlock(&qcam->lock);
return 0;
@@ -601,11 +601,11 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
if(vw->width<80||vw->width>320)
return -EINVAL;
-
+
qcam->width = 80;
qcam->height = 60;
qcam->mode = QC_DECIMATION_4;
-
+
if(vw->width>=160 && vw->height>=120)
{
qcam->width = 160;
@@ -627,7 +627,7 @@ static int qcam_do_ioctl(struct inode *inode, struct file *file,
qcam->mode = QC_BILLIONS | QC_DECIMATION_1;
}
#endif
- /* Ok we figured out what to use from our
+ /* Ok we figured out what to use from our
wide choice */
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
@@ -676,7 +676,7 @@ static ssize_t qcam_read(struct file *file, char __user *buf,
mutex_lock(&qcam->lock);
parport_claim_or_block(qcam->pdev);
/* Probably should have a semaphore against multiple users */
- len = qc_capture(qcam, buf,count);
+ len = qc_capture(qcam, buf,count);
parport_release(qcam->pdev);
mutex_unlock(&qcam->lock);
return len;
@@ -707,7 +707,7 @@ static struct video_device qcam_template=
static struct qcam_device *qcam_init(struct parport *port)
{
struct qcam_device *q;
-
+
q = kmalloc(sizeof(struct qcam_device), GFP_KERNEL);
if(q==NULL)
return NULL;
@@ -718,14 +718,14 @@ static struct qcam_device *qcam_init(struct parport *port)
q->bidirectional = (q->pport->modes & PARPORT_MODE_TRISTATE)?1:0;
- if (q->pdev == NULL)
+ if (q->pdev == NULL)
{
printk(KERN_ERR "c-qcam: couldn't register for %s.\n",
port->name);
kfree(q);
return NULL;
}
-
+
memcpy(&q->vdev, &qcam_template, sizeof(qcam_template));
mutex_init(&q->lock);
@@ -766,11 +766,11 @@ static int init_cqcam(struct parport *port)
qcam = qcam_init(port);
if (qcam==NULL)
return -ENODEV;
-
+
parport_claim_or_block(qcam->pdev);
qc_reset(qcam);
-
+
if (probe && qc_detect(qcam)==0)
{
parport_release(qcam->pdev);
@@ -782,7 +782,7 @@ static int init_cqcam(struct parport *port)
qc_setup(qcam);
parport_release(qcam->pdev);
-
+
if (video_register_device(&qcam->vdev, VFL_TYPE_GRABBER, video_nr)==-1)
{
printk(KERN_ERR "Unable to register Colour QuickCam on %s\n",
@@ -792,9 +792,9 @@ static int init_cqcam(struct parport *port)
return -ENODEV;
}
- printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
+ printk(KERN_INFO "video%d: Colour QuickCam found on %s\n",
qcam->vdev.minor, qcam->pport->name);
-
+
qcams[num_cams++] = qcam;
return 0;
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c
index d93a561e6b8..2227c5640c1 100644
--- a/drivers/media/video/cpia.c
+++ b/drivers/media/video/cpia.c
@@ -24,7 +24,7 @@
*/
/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
-/* #define _CPIA_DEBUG_ 1 */
+/* #define _CPIA_DEBUG_ 1 */
#include <linux/config.h>
@@ -58,7 +58,7 @@ static int video_nr = -1;
#ifdef MODULE
module_param(video_nr, int, 0);
-MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfeld.com>");
+MODULE_AUTHOR("Scott J. Bertin <sbertin@securenym.net> & Peter Pregler <Peter_Pregler@email.com> & Johannes Erdfelt <johannes@erdfelt.com>");
MODULE_DESCRIPTION("V4L-driver for Vision CPiA based cameras");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("video");
@@ -67,11 +67,11 @@ MODULE_SUPPORTED_DEVICE("video");
static unsigned short colorspace_conv = 0;
module_param(colorspace_conv, ushort, 0444);
MODULE_PARM_DESC(colorspace_conv,
- "\n<n> Colorspace conversion:"
- "\n0 = disable"
- "\n1 = enable"
- "\nDefault value is 0"
- "\n");
+ "\n<n> Colorspace conversion:"
+ "\n0 = disable"
+ "\n1 = enable"
+ "\nDefault value is 0"
+ "\n");
#define ABOUT "V4L-Driver for Vision CPiA based cameras"
@@ -189,8 +189,8 @@ enum {
#define TC 94
#define EXP_ACC_DARK 50
#define EXP_ACC_LIGHT 90
-#define HIGH_COMP_102 160
-#define MAX_COMP 239
+#define HIGH_COMP_102 160
+#define MAX_COMP 239
#define DARK_TIME 3
#define LIGHT_TIME 3
@@ -208,7 +208,7 @@ static u8 flicker_jumps[2][2][4] =
static void reset_camera_struct(struct cam_data *cam);
static int find_over_exposure(int brightness);
static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
- int on);
+ int on);
/**********************************************************************
@@ -262,7 +262,7 @@ static void rvfree(void *mem, unsigned long size)
static struct proc_dir_entry *cpia_proc_root=NULL;
static int cpia_read_proc(char *page, char **start, off_t off,
- int count, int *eof, void *data)
+ int count, int *eof, void *data)
{
char *out = page;
int len, tmp;
@@ -276,58 +276,58 @@ static int cpia_read_proc(char *page, char **start, off_t off,
out += sprintf(out, "V4L Driver version: %d.%d.%d\n",
CPIA_MAJ_VER, CPIA_MIN_VER, CPIA_PATCH_VER);
out += sprintf(out, "CPIA Version: %d.%02d (%d.%d)\n",
- cam->params.version.firmwareVersion,
- cam->params.version.firmwareRevision,
- cam->params.version.vcVersion,
- cam->params.version.vcRevision);
+ cam->params.version.firmwareVersion,
+ cam->params.version.firmwareRevision,
+ cam->params.version.vcVersion,
+ cam->params.version.vcRevision);
out += sprintf(out, "CPIA PnP-ID: %04x:%04x:%04x\n",
- cam->params.pnpID.vendor, cam->params.pnpID.product,
- cam->params.pnpID.deviceRevision);
+ cam->params.pnpID.vendor, cam->params.pnpID.product,
+ cam->params.pnpID.deviceRevision);
out += sprintf(out, "VP-Version: %d.%d %04x\n",
- cam->params.vpVersion.vpVersion,
- cam->params.vpVersion.vpRevision,
- cam->params.vpVersion.cameraHeadID);
-
+ cam->params.vpVersion.vpVersion,
+ cam->params.vpVersion.vpRevision,
+ cam->params.vpVersion.cameraHeadID);
+
out += sprintf(out, "system_state: %#04x\n",
- cam->params.status.systemState);
+ cam->params.status.systemState);
out += sprintf(out, "grab_state: %#04x\n",
- cam->params.status.grabState);
+ cam->params.status.grabState);
out += sprintf(out, "stream_state: %#04x\n",
- cam->params.status.streamState);
+ cam->params.status.streamState);
out += sprintf(out, "fatal_error: %#04x\n",
- cam->params.status.fatalError);
+ cam->params.status.fatalError);
out += sprintf(out, "cmd_error: %#04x\n",
- cam->params.status.cmdError);
+ cam->params.status.cmdError);
out += sprintf(out, "debug_flags: %#04x\n",
- cam->params.status.debugFlags);
+ cam->params.status.debugFlags);
out += sprintf(out, "vp_status: %#04x\n",
- cam->params.status.vpStatus);
+ cam->params.status.vpStatus);
out += sprintf(out, "error_code: %#04x\n",
- cam->params.status.errorCode);
+ cam->params.status.errorCode);
/* QX3 specific entries */
if (cam->params.qx3.qx3_detected) {
out += sprintf(out, "button: %4d\n",
- cam->params.qx3.button);
+ cam->params.qx3.button);
out += sprintf(out, "cradled: %4d\n",
- cam->params.qx3.cradled);
+ cam->params.qx3.cradled);
}
out += sprintf(out, "video_size: %s\n",
- cam->params.format.videoSize == VIDEOSIZE_CIF ?
+ cam->params.format.videoSize == VIDEOSIZE_CIF ?
"CIF " : "QCIF");
out += sprintf(out, "roi: (%3d, %3d) to (%3d, %3d)\n",
- cam->params.roi.colStart*8,
- cam->params.roi.rowStart*4,
- cam->params.roi.colEnd*8,
- cam->params.roi.rowEnd*4);
+ cam->params.roi.colStart*8,
+ cam->params.roi.rowStart*4,
+ cam->params.roi.colEnd*8,
+ cam->params.roi.rowEnd*4);
out += sprintf(out, "actual_fps: %3d\n", cam->fps);
out += sprintf(out, "transfer_rate: %4dkB/s\n",
- cam->transfer_rate);
-
+ cam->transfer_rate);
+
out += sprintf(out, "\nread-write\n");
out += sprintf(out, "----------------------- current min"
- " max default comment\n");
+ " max default comment\n");
out += sprintf(out, "brightness: %8d %8d %8d %8d\n",
- cam->params.colourParams.brightness, 0, 100, 50);
+ cam->params.colourParams.brightness, 0, 100, 50);
if (cam->params.version.firmwareVersion == 1 &&
cam->params.version.firmwareRevision == 2)
/* 1-02 firmware limits contrast to 80 */
@@ -336,26 +336,26 @@ static int cpia_read_proc(char *page, char **start, off_t off,
tmp = 96;
out += sprintf(out, "contrast: %8d %8d %8d %8d"
- " steps of 8\n",
- cam->params.colourParams.contrast, 0, tmp, 48);
+ " steps of 8\n",
+ cam->params.colourParams.contrast, 0, tmp, 48);
out += sprintf(out, "saturation: %8d %8d %8d %8d\n",
- cam->params.colourParams.saturation, 0, 100, 50);
+ cam->params.colourParams.saturation, 0, 100, 50);
tmp = (25000+5000*cam->params.sensorFps.baserate)/
(1<<cam->params.sensorFps.divisor);
out += sprintf(out, "sensor_fps: %4d.%03d %8d %8d %8d\n",
- tmp/1000, tmp%1000, 3, 30, 15);
+ tmp/1000, tmp%1000, 3, 30, 15);
out += sprintf(out, "stream_start_line: %8d %8d %8d %8d\n",
- 2*cam->params.streamStartLine, 0,
+ 2*cam->params.streamStartLine, 0,
cam->params.format.videoSize == VIDEOSIZE_CIF ? 288:144,
cam->params.format.videoSize == VIDEOSIZE_CIF ? 240:120);
out += sprintf(out, "sub_sample: %8s %8s %8s %8s\n",
- cam->params.format.subSample == SUBSAMPLE_420 ?
+ cam->params.format.subSample == SUBSAMPLE_420 ?
"420" : "422", "420", "422", "422");
out += sprintf(out, "yuv_order: %8s %8s %8s %8s\n",
- cam->params.format.yuvOrder == YUVORDER_YUYV ?
+ cam->params.format.yuvOrder == YUVORDER_YUYV ?
"YUYV" : "UYVY", "YUYV" , "UYVY", "YUYV");
out += sprintf(out, "ecp_timing: %8s %8s %8s %8s\n",
- cam->params.ecpTiming ? "slow" : "normal", "slow",
+ cam->params.ecpTiming ? "slow" : "normal", "slow",
"normal", "normal");
if (cam->params.colourBalance.balanceMode == 2) {
@@ -366,11 +366,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
out += sprintf(out, "color_balance_mode: %8s %8s %8s"
" %8s\n", tmpstr, "manual", "auto", "auto");
out += sprintf(out, "red_gain: %8d %8d %8d %8d\n",
- cam->params.colourBalance.redGain, 0, 212, 32);
+ cam->params.colourBalance.redGain, 0, 212, 32);
out += sprintf(out, "green_gain: %8d %8d %8d %8d\n",
- cam->params.colourBalance.greenGain, 0, 212, 6);
+ cam->params.colourBalance.greenGain, 0, 212, 6);
out += sprintf(out, "blue_gain: %8d %8d %8d %8d\n",
- cam->params.colourBalance.blueGain, 0, 212, 92);
+ cam->params.colourBalance.blueGain, 0, 212, 92);
if (cam->params.version.firmwareVersion == 1 &&
cam->params.version.firmwareRevision == 2)
@@ -381,11 +381,11 @@ static int cpia_read_proc(char *page, char **start, off_t off,
if (cam->params.exposure.gainMode == 0)
out += sprintf(out, "max_gain: unknown %28s"
- " powers of 2\n", tmpstr);
+ " powers of 2\n", tmpstr);
else
out += sprintf(out, "max_gain: %8d %28s"
" 1,2,4 or 8 \n",
- 1<<(cam->params.exposure.gainMode-1), tmpstr);
+ 1<<(cam->params.exposure.gainMode-1), tmpstr);
switch(cam->params.exposure.expMode) {
case 1:
@@ -402,10 +402,10 @@ static int cpia_read_proc(char *page, char **start, off_t off,
out += sprintf(out, "exposure_mode: %8s %8s %8s"
" %8s\n", tmpstr, "manual", "auto", "auto");
out += sprintf(out, "centre_weight: %8s %8s %8s %8s\n",
- (2-cam->params.exposure.centreWeight) ? "on" : "off",
- "off", "on", "on");
+ (2-cam->params.exposure.centreWeight) ? "on" : "off",
+ "off", "on", "on");
out += sprintf(out, "gain: %8d %8d max_gain %8d 1,2,4,8 possible\n",
- 1<<cam->params.exposure.gain, 1, 1);
+ 1<<cam->params.exposure.gain, 1, 1);
if (cam->params.version.firmwareVersion == 1 &&
cam->params.version.firmwareRevision == 2)
/* 1-02 firmware limits fineExp/2 to 127 */
@@ -414,7 +414,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
tmp = 510;
out += sprintf(out, "fine_exp: %8d %8d %8d %8d\n",
- cam->params.exposure.fineExp*2, 0, tmp, 0);
+ cam->params.exposure.fineExp*2, 0, tmp, 0);
if (cam->params.version.firmwareVersion == 1 &&
cam->params.version.firmwareRevision == 2)
/* 1-02 firmware limits coarseExpHi to 0 */
@@ -426,46 +426,46 @@ static int cpia_read_proc(char *page, char **start, off_t off,
" %8d\n", cam->params.exposure.coarseExpLo+
256*cam->params.exposure.coarseExpHi, 0, tmp, 185);
out += sprintf(out, "red_comp: %8d %8d %8d %8d\n",
- cam->params.exposure.redComp, COMP_RED, 255, COMP_RED);
+ cam->params.exposure.redComp, COMP_RED, 255, COMP_RED);
out += sprintf(out, "green1_comp: %8d %8d %8d %8d\n",
- cam->params.exposure.green1Comp, COMP_GREEN1, 255,
+ cam->params.exposure.green1Comp, COMP_GREEN1, 255,
COMP_GREEN1);
out += sprintf(out, "green2_comp: %8d %8d %8d %8d\n",
- cam->params.exposure.green2Comp, COMP_GREEN2, 255,
+ cam->params.exposure.green2Comp, COMP_GREEN2, 255,
COMP_GREEN2);
out += sprintf(out, "blue_comp: %8d %8d %8d %8d\n",
- cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE);
-
+ cam->params.exposure.blueComp, COMP_BLUE, 255, COMP_BLUE);
+
out += sprintf(out, "apcor_gain1: %#8x %#8x %#8x %#8x\n",
- cam->params.apcor.gain1, 0, 0xff, 0x1c);
+ cam->params.apcor.gain1, 0, 0xff, 0x1c);
out += sprintf(out, "apcor_gain2: %#8x %#8x %#8x %#8x\n",
- cam->params.apcor.gain2, 0, 0xff, 0x1a);
+ cam->params.apcor.gain2, 0, 0xff, 0x1a);
out += sprintf(out, "apcor_gain4: %#8x %#8x %#8x %#8x\n",
- cam->params.apcor.gain4, 0, 0xff, 0x2d);
+ cam->params.apcor.gain4, 0, 0xff, 0x2d);
out += sprintf(out, "apcor_gain8: %#8x %#8x %#8x %#8x\n",
- cam->params.apcor.gain8, 0, 0xff, 0x2a);
+ cam->params.apcor.gain8, 0, 0xff, 0x2a);
out += sprintf(out, "vl_offset_gain1: %8d %8d %8d %8d\n",
- cam->params.vlOffset.gain1, 0, 255, 24);
+ cam->params.vlOffset.gain1, 0, 255, 24);
out += sprintf(out, "vl_offset_gain2: %8d %8d %8d %8d\n",
- cam->params.vlOffset.gain2, 0, 255, 28);
+ cam->params.vlOffset.gain2, 0, 255, 28);
out += sprintf(out, "vl_offset_gain4: %8d %8d %8d %8d\n",
- cam->params.vlOffset.gain4, 0, 255, 30);
+ cam->params.vlOffset.gain4, 0, 255, 30);
out += sprintf(out, "vl_offset_gain8: %8d %8d %8d %8d\n",
- cam->params.vlOffset.gain8, 0, 255, 30);
+ cam->params.vlOffset.gain8, 0, 255, 30);
out += sprintf(out, "flicker_control: %8s %8s %8s %8s\n",
- cam->params.flickerControl.flickerMode ? "on" : "off",
+ cam->params.flickerControl.flickerMode ? "on" : "off",
"off", "on", "off");
out += sprintf(out, "mains_frequency: %8d %8d %8d %8d"
- " only 50/60\n",
- cam->mainsFreq ? 60 : 50, 50, 60, 50);
+ " only 50/60\n",
+ cam->mainsFreq ? 60 : 50, 50, 60, 50);
if(cam->params.flickerControl.allowableOverExposure < 0)
out += sprintf(out, "allowable_overexposure: %4dauto auto %8d auto\n",
- -cam->params.flickerControl.allowableOverExposure,
- 255);
+ -cam->params.flickerControl.allowableOverExposure,
+ 255);
else
out += sprintf(out, "allowable_overexposure: %8d auto %8d auto\n",
- cam->params.flickerControl.allowableOverExposure,
- 255);
+ cam->params.flickerControl.allowableOverExposure,
+ 255);
out += sprintf(out, "compression_mode: ");
switch(cam->params.compression.mode) {
case CPIA_COMPRESSION_NONE:
@@ -483,52 +483,52 @@ static int cpia_read_proc(char *page, char **start, off_t off,
}
out += sprintf(out, " none,auto,manual auto\n");
out += sprintf(out, "decimation_enable: %8s %8s %8s %8s\n",
- cam->params.compression.decimation ==
- DECIMATION_ENAB ? "on":"off", "off", "on",
+ cam->params.compression.decimation ==
+ DECIMATION_ENAB ? "on":"off", "off", "on",
"off");
out += sprintf(out, "compression_target: %9s %9s %9s %9s\n",
- cam->params.compressionTarget.frTargeting ==
+ cam->params.compressionTarget.frTargeting ==
CPIA_COMPRESSION_TARGET_FRAMERATE ?
"framerate":"quality",
"framerate", "quality", "quality");
out += sprintf(out, "target_framerate: %8d %8d %8d %8d\n",
- cam->params.compressionTarget.targetFR, 1, 30, 15);
+ cam->params.compressionTarget.targetFR, 1, 30, 15);
out += sprintf(out, "target_quality: %8d %8d %8d %8d\n",
- cam->params.compressionTarget.targetQ, 1, 64, 5);
+ cam->params.compressionTarget.targetQ, 1, 64, 5);
out += sprintf(out, "y_threshold: %8d %8d %8d %8d\n",
- cam->params.yuvThreshold.yThreshold, 0, 31, 6);
+ cam->params.yuvThreshold.yThreshold, 0, 31, 6);
out += sprintf(out, "uv_threshold: %8d %8d %8d %8d\n",
- cam->params.yuvThreshold.uvThreshold, 0, 31, 6);
+ cam->params.yuvThreshold.uvThreshold, 0, 31, 6);
out += sprintf(out, "hysteresis: %8d %8d %8d %8d\n",
- cam->params.compressionParams.hysteresis, 0, 255, 3);
+ cam->params.compressionParams.hysteresis, 0, 255, 3);
out += sprintf(out, "threshold_max: %8d %8d %8d %8d\n",
- cam->params.compressionParams.threshMax, 0, 255, 11);
+ cam->params.compressionParams.threshMax, 0, 255, 11);
out += sprintf(out, "small_step: %8d %8d %8d %8d\n",
- cam->params.compressionParams.smallStep, 0, 255, 1);
+ cam->params.compressionParams.smallStep, 0, 255, 1);
out += sprintf(out, "large_step: %8d %8d %8d %8d\n",
- cam->params.compressionParams.largeStep, 0, 255, 3);
+ cam->params.compressionParams.largeStep, 0, 255, 3);
out += sprintf(out, "decimation_hysteresis: %8d %8d %8d %8d\n",
- cam->params.compressionParams.decimationHysteresis,
+ cam->params.compressionParams.decimationHysteresis,
0, 255, 2);
out += sprintf(out, "fr_diff_step_thresh: %8d %8d %8d %8d\n",
- cam->params.compressionParams.frDiffStepThresh,
+ cam->params.compressionParams.frDiffStepThresh,
0, 255, 5);
out += sprintf(out, "q_diff_step_thresh: %8d %8d %8d %8d\n",
- cam->params.compressionParams.qDiffStepThresh,
+ cam->params.compressionParams.qDiffStepThresh,
0, 255, 3);
out += sprintf(out, "decimation_thresh_mod: %8d %8d %8d %8d\n",
- cam->params.compressionParams.decimationThreshMod,
+ cam->params.compressionParams.decimationThreshMod,
0, 255, 2);
/* QX3 specific entries */
if (cam->params.qx3.qx3_detected) {
- out += sprintf(out, "toplight: %8s %8s %8s %8s\n",
- cam->params.qx3.toplight ? "on" : "off",
+ out += sprintf(out, "toplight: %8s %8s %8s %8s\n",
+ cam->params.qx3.toplight ? "on" : "off",
"off", "on", "off");
- out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n",
- cam->params.qx3.bottomlight ? "on" : "off",
+ out += sprintf(out, "bottomlight: %8s %8s %8s %8s\n",
+ cam->params.qx3.bottomlight ? "on" : "off",
"off", "on", "off");
}
-
+
len = out - page;
len -= off;
if (len < count) {
@@ -543,7 +543,7 @@ static int cpia_read_proc(char *page, char **start, off_t off,
static int match(char *checkstr, char **buffer, unsigned long *count,
- int *find_colon, int *err)
+ int *find_colon, int *err)
{
int ret, colon_found = 1;
int len = strlen(checkstr);
@@ -583,7 +583,7 @@ static unsigned long int value(char **buffer, unsigned long *count, int *err)
}
static int cpia_write_proc(struct file *file, const char __user *buf,
- unsigned long count, void *data)
+ unsigned long count, void *data)
{
struct cam_data *cam = data;
struct cam_params new_params;
@@ -619,12 +619,12 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
retval = -EINVAL;
goto out;
}
-
+
buffer = page;
-
+
if (mutex_lock_interruptible(&cam->param_lock))
return -ERESTARTSYS;
-
+
/*
* Skip over leading whitespace
*/
@@ -632,15 +632,15 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
--count;
++buffer;
}
-
+
memcpy(&new_params, &cam->params, sizeof(struct cam_params));
new_mains = cam->mainsFreq;
-
+
#define MATCH(x) (match(x, &buffer, &count, &find_colon, &retval))
#define VALUE (value(&buffer,&count, &retval))
#define FIRMWARE_VERSION(x,y) (new_params.version.firmwareVersion == (x) && \
- new_params.version.firmwareRevision == (y))
-
+ new_params.version.firmwareRevision == (y))
+
retval = 0;
while (count && !retval) {
find_colon = 1;
@@ -656,7 +656,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
}
command_flags |= COMMAND_SETCOLOURPARAMS;
if(new_params.flickerControl.allowableOverExposure < 0)
- new_params.flickerControl.allowableOverExposure =
+ new_params.flickerControl.allowableOverExposure =
-find_over_exposure(new_params.colourParams.brightness);
if(new_params.flickerControl.flickerMode != 0)
command_flags |= COMMAND_SETFLICKERCTRL;
@@ -721,7 +721,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
/* Either base rate would work here */
new_params.sensorFps.baserate = 1;
}
- new_params.flickerControl.coarseJump =
+ new_params.flickerControl.coarseJump =
flicker_jumps[new_mains]
[new_params.sensorFps.baserate]
[new_params.sensorFps.divisor];
@@ -1085,7 +1085,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
} else if (MATCH("mains_frequency")) {
if (!retval && MATCH("50")) {
new_mains = 0;
- new_params.flickerControl.coarseJump =
+ new_params.flickerControl.coarseJump =
flicker_jumps[new_mains]
[new_params.sensorFps.baserate]
[new_params.sensorFps.divisor];
@@ -1093,7 +1093,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
command_flags |= COMMAND_SETFLICKERCTRL;
} else if (!retval && MATCH("60")) {
new_mains = 1;
- new_params.flickerControl.coarseJump =
+ new_params.flickerControl.coarseJump =
flicker_jumps[new_mains]
[new_params.sensorFps.baserate]
[new_params.sensorFps.divisor];
@@ -1103,7 +1103,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
retval = -EINVAL;
} else if (MATCH("allowable_overexposure")) {
if (!retval && MATCH("auto")) {
- new_params.flickerControl.allowableOverExposure =
+ new_params.flickerControl.allowableOverExposure =
-find_over_exposure(new_params.colourParams.brightness);
if(new_params.flickerControl.flickerMode != 0)
command_flags |= COMMAND_SETFLICKERCTRL;
@@ -1146,10 +1146,10 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
command_flags |= COMMAND_SETCOMPRESSION;
} else if (MATCH("compression_target")) {
if (!retval && MATCH("quality"))
- new_params.compressionTarget.frTargeting =
+ new_params.compressionTarget.frTargeting =
CPIA_COMPRESSION_TARGET_QUALITY;
else if (!retval && MATCH("framerate"))
- new_params.compressionTarget.frTargeting =
+ new_params.compressionTarget.frTargeting =
CPIA_COMPRESSION_TARGET_FRAMERATE;
else
retval = -EINVAL;
@@ -1173,7 +1173,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
if (!retval) {
if(val > 0 && val <= 64)
new_params.compressionTarget.targetQ = val;
- else
+ else
retval = -EINVAL;
}
command_flags |= COMMAND_SETCOMPRESSIONTARGET;
@@ -1288,19 +1288,19 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
}
command_flags |= COMMAND_SETCOMPRESSIONPARAMS;
} else if (MATCH("toplight")) {
- if (!retval && MATCH("on"))
+ if (!retval && MATCH("on"))
new_params.qx3.toplight = 1;
else if (!retval && MATCH("off"))
new_params.qx3.toplight = 0;
- else
+ else
retval = -EINVAL;
command_flags |= COMMAND_SETLIGHTS;
} else if (MATCH("bottomlight")) {
- if (!retval && MATCH("on"))
+ if (!retval && MATCH("on"))
new_params.qx3.bottomlight = 1;
- else if (!retval && MATCH("off"))
+ else if (!retval && MATCH("off"))
new_params.qx3.bottomlight = 0;
- else
+ else
retval = -EINVAL;
command_flags |= COMMAND_SETLIGHTS;
} else {
@@ -1326,7 +1326,7 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
}
}
}
-#undef MATCH
+#undef MATCH
#undef VALUE
#undef FIRMWARE_VERSION
if (!retval) {
@@ -1349,24 +1349,24 @@ static int cpia_write_proc(struct file *file, const char __user *buf,
retval = size;
} else
DBG("error: %d\n", retval);
-
+
mutex_unlock(&cam->param_lock);
-
+
out:
free_page((unsigned long)page);
- return retval;
+ return retval;
}
static void create_proc_cpia_cam(struct cam_data *cam)
{
char name[7];
struct proc_dir_entry *ent;
-
+
if (!cpia_proc_root || !cam)
return;
sprintf(name, "video%d", cam->vdev.minor);
-
+
ent = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUSR, cpia_proc_root);
if (!ent)
return;
@@ -1374,9 +1374,9 @@ static void create_proc_cpia_cam(struct cam_data *cam)
ent->data = cam;
ent->read_proc = cpia_read_proc;
ent->write_proc = cpia_write_proc;
- /*
+ /*
size of the proc entry is 3736 bytes for the standard webcam;
- the extra features of the QX3 microscope add 189 bytes.
+ the extra features of the QX3 microscope add 189 bytes.
(we have not yet probed the camera to see which type it is).
*/
ent->size = 3736 + 189;
@@ -1386,10 +1386,10 @@ static void create_proc_cpia_cam(struct cam_data *cam)
static void destroy_proc_cpia_cam(struct cam_data *cam)
{
char name[7];
-
+
if (!cam || !cam->proc_entry)
return;
-
+
sprintf(name, "video%d", cam->vdev.minor);
remove_proc_entry(name, cpia_proc_root);
cam->proc_entry = NULL;
@@ -1596,13 +1596,13 @@ static void set_vw_size(struct cam_data *cam)
cam->vc.width = cam->vw.width;
if(cam->vc.height == 0)
cam->vc.height = cam->vw.height;
-
+
cam->params.roi.colStart += cam->vc.x >> 3;
cam->params.roi.colEnd = cam->params.roi.colStart +
- (cam->vc.width >> 3);
+ (cam->vc.width >> 3);
cam->params.roi.rowStart += cam->vc.y >> 2;
cam->params.roi.rowEnd = cam->params.roi.rowStart +
- (cam->vc.height >> 2);
+ (cam->vc.height >> 2);
return;
}
@@ -1624,7 +1624,7 @@ static int allocate_frame_buf(struct cam_data *cam)
static int free_frame_buf(struct cam_data *cam)
{
int i;
-
+
rvfree(cam->frame_buf, FRAME_NUM*CPIA_MAX_FRAME_SIZE);
cam->frame_buf = NULL;
for (i=0; i < FRAME_NUM; i++)
@@ -1667,7 +1667,7 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
mutex_lock(&cam->param_lock);
datasize=8;
break;
- case CPIA_COMMAND_ReadMCPorts:
+ case CPIA_COMMAND_ReadMCPorts:
case CPIA_COMMAND_ReadVCRegs:
datasize = 4;
break;
@@ -1746,10 +1746,10 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
mutex_unlock(&cam->param_lock);
break;
- case CPIA_COMMAND_ReadMCPorts:
- if (!cam->params.qx3.qx3_detected)
+ case CPIA_COMMAND_ReadMCPorts:
+ if (!cam->params.qx3.qx3_detected)
break;
- /* test button press */
+ /* test button press */
cam->params.qx3.button = ((data[1] & 0x02) == 0);
if (cam->params.qx3.button) {
/* button pressed - unlock the latch */
@@ -1770,9 +1770,9 @@ static int do_command(struct cam_data *cam, u16 command, u8 a, u8 b, u8 c, u8 d)
/* send a command to the camera with an additional data transaction */
static int do_command_extended(struct cam_data *cam, u16 command,
- u8 a, u8 b, u8 c, u8 d,
- u8 e, u8 f, u8 g, u8 h,
- u8 i, u8 j, u8 k, u8 l)
+ u8 a, u8 b, u8 c, u8 d,
+ u8 e, u8 f, u8 g, u8 h,
+ u8 i, u8 j, u8 k, u8 l)
{
int retval;
u8 cmd[8], data[8];
@@ -1809,10 +1809,10 @@ static int do_command_extended(struct cam_data *cam, u16 command,
#define LIMIT(x) ((((x)>0xffffff)?0xff0000:(((x)<=0xffff)?0:(x)&0xff0000))>>16)
static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
- int linesize, int mmap_kludge)
+ int linesize, int mmap_kludge)
{
int y, u, v, r, g, b, y1;
-
+
/* Odd lines use the same u and v as the previous line.
* Because of compression, it is necessary to get this
* information from the decoded image. */
@@ -1925,7 +1925,7 @@ static int convert420(unsigned char *yuv, unsigned char *rgb, int out_fmt,
static int yuvconvert(unsigned char *yuv, unsigned char *rgb, int out_fmt,
- int in_uyvy, int mmap_kludge)
+ int in_uyvy, int mmap_kludge)
{
int y, u, v, r, g, b, y1;
@@ -2078,21 +2078,21 @@ static int parse_picture(struct cam_data *cam, int size)
mutex_unlock(&cam->param_lock);
return -1;
}
-
+
if (ibuf[17] != SUBSAMPLE_420 && ibuf[17] != SUBSAMPLE_422) {
LOG("illegal subtype %d\n",ibuf[17]);
mutex_unlock(&cam->param_lock);
return -1;
}
subsample_422 = ibuf[17] == SUBSAMPLE_422;
-
+
if (ibuf[18] != YUVORDER_YUYV && ibuf[18] != YUVORDER_UYVY) {
LOG("illegal yuvorder %d\n",ibuf[18]);
mutex_unlock(&cam->param_lock);
return -1;
}
in_uyvy = ibuf[18] == YUVORDER_UYVY;
-
+
if ((ibuf[24] != cam->params.roi.colStart) ||
(ibuf[25] != cam->params.roi.colEnd) ||
(ibuf[26] != cam->params.roi.rowStart) ||
@@ -2104,20 +2104,20 @@ static int parse_picture(struct cam_data *cam, int size)
cols = 8*(ibuf[25] - ibuf[24]);
rows = 4*(ibuf[27] - ibuf[26]);
-
+
if ((ibuf[28] != NOT_COMPRESSED) && (ibuf[28] != COMPRESSED)) {
LOG("illegal compression %d\n",ibuf[28]);
mutex_unlock(&cam->param_lock);
return -1;
}
compressed = (ibuf[28] == COMPRESSED);
-
+
if (ibuf[29] != NO_DECIMATION && ibuf[29] != DECIMATION_ENAB) {
LOG("illegal decimation %d\n",ibuf[29]);
mutex_unlock(&cam->param_lock);
return -1;
}
- decimation = (ibuf[29] == DECIMATION_ENAB);
+ decimation = (ibuf[29] == DECIMATION_ENAB);
cam->params.yuvThreshold.yThreshold = ibuf[30];
cam->params.yuvThreshold.uvThreshold = ibuf[31];
@@ -2131,7 +2131,7 @@ static int parse_picture(struct cam_data *cam, int size)
cam->params.status.errorCode = ibuf[39];
cam->fps = ibuf[41];
mutex_unlock(&cam->param_lock);
-
+
linesize = skipcount(cols, out_fmt);
ibuf += FRAME_HEADER_SIZE;
size -= FRAME_HEADER_SIZE;
@@ -2150,14 +2150,14 @@ static int parse_picture(struct cam_data *cam, int size)
if (!compressed || (compressed && !(*ibuf & 1))) {
if(subsample_422 || even_line) {
obuf += yuvconvert(ibuf, obuf, out_fmt,
- in_uyvy, cam->mmap_kludge);
+ in_uyvy, cam->mmap_kludge);
ibuf += 4;
ll -= 4;
} else {
/* SUBSAMPLE_420 on an odd line */
obuf += convert420(ibuf, obuf,
- out_fmt, linesize,
- cam->mmap_kludge);
+ out_fmt, linesize,
+ cam->mmap_kludge);
ibuf += 2;
ll -= 2;
}
@@ -2183,7 +2183,7 @@ static int parse_picture(struct cam_data *cam, int size)
if ((size > 3) && (ibuf[0] == EOI) && (ibuf[1] == EOI) &&
(ibuf[2] == EOI) && (ibuf[3] == EOI)) {
- size -= 4;
+ size -= 4;
break;
}
@@ -2204,7 +2204,7 @@ static int parse_picture(struct cam_data *cam, int size)
return -1;
}
}
-
+
if(decimation) {
/* interpolate odd rows */
int i, j;
@@ -2233,7 +2233,7 @@ static int parse_picture(struct cam_data *cam, int size)
static inline int init_stream_cap(struct cam_data *cam)
{
return do_command(cam, CPIA_COMMAND_InitStreamCap,
- 0, cam->params.streamStartLine, 0, 0);
+ 0, cam->params.streamStartLine, 0, 0);
}
@@ -2254,7 +2254,7 @@ static int find_over_exposure(int brightness)
int MaxAllowableOverExposure, OverExposure;
MaxAllowableOverExposure = FLICKER_MAX_EXPOSURE - brightness -
- FLICKER_BRIGHTNESS_CONSTANT;
+ FLICKER_BRIGHTNESS_CONSTANT;
if (MaxAllowableOverExposure < FLICKER_ALLOWABLE_OVER_EXPOSURE) {
OverExposure = MaxAllowableOverExposure;
@@ -2280,62 +2280,62 @@ static void dispatch_commands(struct cam_data *cam)
DEB_BYTE(cam->cmd_queue>>8);
if (cam->cmd_queue & COMMAND_SETFORMAT) {
do_command(cam, CPIA_COMMAND_SetFormat,
- cam->params.format.videoSize,
- cam->params.format.subSample,
- cam->params.format.yuvOrder, 0);
+ cam->params.format.videoSize,
+ cam->params.format.subSample,
+ cam->params.format.yuvOrder, 0);
do_command(cam, CPIA_COMMAND_SetROI,
- cam->params.roi.colStart, cam->params.roi.colEnd,
- cam->params.roi.rowStart, cam->params.roi.rowEnd);
+ cam->params.roi.colStart, cam->params.roi.colEnd,
+ cam->params.roi.rowStart, cam->params.roi.rowEnd);
cam->first_frame = 1;
}
if (cam->cmd_queue & COMMAND_SETCOLOURPARAMS)
do_command(cam, CPIA_COMMAND_SetColourParams,
- cam->params.colourParams.brightness,
- cam->params.colourParams.contrast,
- cam->params.colourParams.saturation, 0);
+ cam->params.colourParams.brightness,
+ cam->params.colourParams.contrast,
+ cam->params.colourParams.saturation, 0);
if (cam->cmd_queue & COMMAND_SETAPCOR)
do_command(cam, CPIA_COMMAND_SetApcor,
- cam->params.apcor.gain1,
- cam->params.apcor.gain2,
- cam->params.apcor.gain4,
- cam->params.apcor.gain8);
+ cam->params.apcor.gain1,
+ cam->params.apcor.gain2,
+ cam->params.apcor.gain4,
+ cam->params.apcor.gain8);
if (cam->cmd_queue & COMMAND_SETVLOFFSET)
do_command(cam, CPIA_COMMAND_SetVLOffset,
- cam->params.vlOffset.gain1,
- cam->params.vlOffset.gain2,
- cam->params.vlOffset.gain4,
- cam->params.vlOffset.gain8);
+ cam->params.vlOffset.gain1,
+ cam->params.vlOffset.gain2,
+ cam->params.vlOffset.gain4,
+ cam->params.vlOffset.gain8);
if (cam->cmd_queue & COMMAND_SETEXPOSURE) {
do_command_extended(cam, CPIA_COMMAND_SetExposure,
- cam->params.exposure.gainMode,
- 1,
- cam->params.exposure.compMode,
- cam->params.exposure.centreWeight,
- cam->params.exposure.gain,
- cam->params.exposure.fineExp,
- cam->params.exposure.coarseExpLo,
- cam->params.exposure.coarseExpHi,
- cam->params.exposure.redComp,
- cam->params.exposure.green1Comp,
- cam->params.exposure.green2Comp,
- cam->params.exposure.blueComp);
+ cam->params.exposure.gainMode,
+ 1,
+ cam->params.exposure.compMode,
+ cam->params.exposure.centreWeight,
+ cam->params.exposure.gain,
+ cam->params.exposure.fineExp,
+ cam->params.exposure.coarseExpLo,
+ cam->params.exposure.coarseExpHi,
+ cam->params.exposure.redComp,
+ cam->params.exposure.green1Comp,
+ cam->params.exposure.green2Comp,
+ cam->params.exposure.blueComp);
if(cam->params.exposure.expMode != 1) {
do_command_extended(cam, CPIA_COMMAND_SetExposure,
- 0,
- cam->params.exposure.expMode,
- 0, 0,
- cam->params.exposure.gain,
- cam->params.exposure.fineExp,
- cam->params.exposure.coarseExpLo,
- cam->params.exposure.coarseExpHi,
- 0, 0, 0, 0);
+ 0,
+ cam->params.exposure.expMode,
+ 0, 0,
+ cam->params.exposure.gain,
+ cam->params.exposure.fineExp,
+ cam->params.exposure.coarseExpLo,
+ cam->params.exposure.coarseExpHi,
+ 0, 0, 0, 0);
}
}
-
+
if (cam->cmd_queue & COMMAND_SETCOLOURBALANCE) {
if (cam->params.colourBalance.balanceMode == 1) {
do_command(cam, CPIA_COMMAND_SetColourBalance,
@@ -2358,47 +2358,47 @@ static void dispatch_commands(struct cam_data *cam)
if (cam->cmd_queue & COMMAND_SETCOMPRESSIONTARGET)
do_command(cam, CPIA_COMMAND_SetCompressionTarget,
- cam->params.compressionTarget.frTargeting,
- cam->params.compressionTarget.targetFR,
- cam->params.compressionTarget.targetQ, 0);
+ cam->params.compressionTarget.frTargeting,
+ cam->params.compressionTarget.targetFR,
+ cam->params.compressionTarget.targetQ, 0);
if (cam->cmd_queue & COMMAND_SETYUVTHRESH)
do_command(cam, CPIA_COMMAND_SetYUVThresh,
- cam->params.yuvThreshold.yThreshold,
- cam->params.yuvThreshold.uvThreshold, 0, 0);
+ cam->params.yuvThreshold.yThreshold,
+ cam->params.yuvThreshold.uvThreshold, 0, 0);
if (cam->cmd_queue & COMMAND_SETCOMPRESSIONPARAMS)
do_command_extended(cam, CPIA_COMMAND_SetCompressionParams,
- 0, 0, 0, 0,
- cam->params.compressionParams.hysteresis,
- cam->params.compressionParams.threshMax,
- cam->params.compressionParams.smallStep,
- cam->params.compressionParams.largeStep,
- cam->params.compressionParams.decimationHysteresis,
- cam->params.compressionParams.frDiffStepThresh,
- cam->params.compressionParams.qDiffStepThresh,
- cam->params.compressionParams.decimationThreshMod);
+ 0, 0, 0, 0,
+ cam->params.compressionParams.hysteresis,
+ cam->params.compressionParams.threshMax,
+ cam->params.compressionParams.smallStep,
+ cam->params.compressionParams.largeStep,
+ cam->params.compressionParams.decimationHysteresis,
+ cam->params.compressionParams.frDiffStepThresh,
+ cam->params.compressionParams.qDiffStepThresh,
+ cam->params.compressionParams.decimationThreshMod);
if (cam->cmd_queue & COMMAND_SETCOMPRESSION)
do_command(cam, CPIA_COMMAND_SetCompression,
- cam->params.compression.mode,
+ cam->params.compression.mode,
cam->params.compression.decimation, 0, 0);
if (cam->cmd_queue & COMMAND_SETSENSORFPS)
do_command(cam, CPIA_COMMAND_SetSensorFPS,
- cam->params.sensorFps.divisor,
- cam->params.sensorFps.baserate, 0, 0);
+ cam->params.sensorFps.divisor,
+ cam->params.sensorFps.baserate, 0, 0);
if (cam->cmd_queue & COMMAND_SETFLICKERCTRL)
do_command(cam, CPIA_COMMAND_SetFlickerCtrl,
- cam->params.flickerControl.flickerMode,
- cam->params.flickerControl.coarseJump,
- abs(cam->params.flickerControl.allowableOverExposure),
- 0);
+ cam->params.flickerControl.flickerMode,
+ cam->params.flickerControl.coarseJump,
+ abs(cam->params.flickerControl.allowableOverExposure),
+ 0);
if (cam->cmd_queue & COMMAND_SETECPTIMING)
do_command(cam, CPIA_COMMAND_SetECPTiming,
- cam->params.ecpTiming, 0, 0, 0);
+ cam->params.ecpTiming, 0, 0, 0);
if (cam->cmd_queue & COMMAND_PAUSE)
do_command(cam, CPIA_COMMAND_EndStreamCap, 0, 0, 0, 0);
@@ -2409,9 +2409,9 @@ static void dispatch_commands(struct cam_data *cam)
if (cam->cmd_queue & COMMAND_SETLIGHTS && cam->params.qx3.qx3_detected)
{
int p1 = (cam->params.qx3.bottomlight == 0) << 1;
- int p2 = (cam->params.qx3.toplight == 0) << 3;
- do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0);
- do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0);
+ int p2 = (cam->params.qx3.toplight == 0) << 3;
+ do_command(cam, CPIA_COMMAND_WriteVCReg, 0x90, 0x8F, 0x50, 0);
+ do_command(cam, CPIA_COMMAND_WriteMCPort, 2, 0, (p1|p2|0xE0), 0);
}
cam->cmd_queue = COMMAND_NONE;
@@ -2422,11 +2422,11 @@ static void dispatch_commands(struct cam_data *cam)
static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
- int on)
+ int on)
{
/* Everything in here is from the Windows driver */
#define FIRMWARE_VERSION(x,y) (params->version.firmwareVersion == (x) && \
- params->version.firmwareRevision == (y))
+ params->version.firmwareRevision == (y))
/* define for compgain calculation */
#if 0
#define COMPGAIN(base, curexp, newexp) \
@@ -2441,7 +2441,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
(u16)(((u32)(curexp * (u8)(curcomp + 128)) / (u8)(basecomp - 128)))
#endif
-
+
int currentexp = params->exposure.coarseExpLo +
params->exposure.coarseExpHi*256;
int startexp;
@@ -2482,7 +2482,7 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
}
if(FIRMWARE_VERSION(1,2))
params->exposure.compMode = 0;
- else
+ else
params->exposure.compMode = 1;
params->apcor.gain1 = 0x18;
@@ -2533,14 +2533,14 @@ static void set_flicker(struct cam_params *params, volatile u32 *command_flags,
}
#define FIRMWARE_VERSION(x,y) (cam->params.version.firmwareVersion == (x) && \
- cam->params.version.firmwareRevision == (y))
+ cam->params.version.firmwareRevision == (y))
/* monitor the exposure and adjust the sensor frame rate if needed */
static void monitor_exposure(struct cam_data *cam)
{
u8 exp_acc, bcomp, gain, coarseL, cmd[8], data[8];
int retval, light_exp, dark_exp, very_dark_exp;
int old_exposure, new_exposure, framerate;
-
+
/* get necessary stats and register settings from camera */
/* do_command can't handle this, so do it ourselves */
cmd[0] = CPIA_COMMAND_ReadVPRegs>>8;
@@ -2564,17 +2564,17 @@ static void monitor_exposure(struct cam_data *cam)
mutex_lock(&cam->param_lock);
light_exp = cam->params.colourParams.brightness +
- TC - 50 + EXP_ACC_LIGHT;
+ TC - 50 + EXP_ACC_LIGHT;
if(light_exp > 255)
light_exp = 255;
dark_exp = cam->params.colourParams.brightness +
- TC - 50 - EXP_ACC_DARK;
+ TC - 50 - EXP_ACC_DARK;
if(dark_exp < 0)
dark_exp = 0;
very_dark_exp = dark_exp/2;
-
+
old_exposure = cam->params.exposure.coarseExpHi * 256 +
- cam->params.exposure.coarseExpLo;
+ cam->params.exposure.coarseExpLo;
if(!cam->params.flickerControl.disabled) {
/* Flicker control on */
@@ -2667,11 +2667,11 @@ static void monitor_exposure(struct cam_data *cam)
cam->exposure_status = EXPOSURE_NORMAL;
}
}
-
+
framerate = cam->fps;
if(framerate > 30 || framerate < 1)
framerate = 1;
-
+
if(!cam->params.flickerControl.disabled) {
/* Flicker control on */
if((cam->exposure_status == EXPOSURE_VERY_DARK ||
@@ -2683,10 +2683,10 @@ static void monitor_exposure(struct cam_data *cam)
++cam->params.sensorFps.divisor;
cam->cmd_queue |= COMMAND_SETSENSORFPS;
- cam->params.flickerControl.coarseJump =
+ cam->params.flickerControl.coarseJump =
flicker_jumps[cam->mainsFreq]
- [cam->params.sensorFps.baserate]
- [cam->params.sensorFps.divisor];
+ [cam->params.sensorFps.baserate]
+ [cam->params.sensorFps.divisor];
cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2704,15 +2704,15 @@ static void monitor_exposure(struct cam_data *cam)
cam->params.sensorFps.divisor > 0) {
/* light for too long */
- int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ;
+ int max_exp = FIRMWARE_VERSION(1,2) ? MAX_EXP_102 : MAX_EXP ;
--cam->params.sensorFps.divisor;
cam->cmd_queue |= COMMAND_SETSENSORFPS;
- cam->params.flickerControl.coarseJump =
+ cam->params.flickerControl.coarseJump =
flicker_jumps[cam->mainsFreq]
- [cam->params.sensorFps.baserate]
- [cam->params.sensorFps.divisor];
+ [cam->params.sensorFps.baserate]
+ [cam->params.sensorFps.divisor];
cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
new_exposure = cam->params.flickerControl.coarseJump-1;
@@ -2772,7 +2772,7 @@ static void monitor_exposure(struct cam_data *cam)
It also adjust the colour balance when an exposure step is detected - as
long as flicker is running
-*/
+*/
static void restart_flicker(struct cam_data *cam)
{
int cam_exposure, old_exp;
@@ -2786,22 +2786,22 @@ static void restart_flicker(struct cam_data *cam)
}
cam_exposure = cam->raw_image[39]*2;
old_exp = cam->params.exposure.coarseExpLo +
- cam->params.exposure.coarseExpHi*256;
- /*
- see how far away camera exposure is from a valid
- flicker exposure value
- */
- cam_exposure %= cam->params.flickerControl.coarseJump;
+ cam->params.exposure.coarseExpHi*256;
+ /*
+ see how far away camera exposure is from a valid
+ flicker exposure value
+ */
+ cam_exposure %= cam->params.flickerControl.coarseJump;
if(!cam->params.flickerControl.disabled &&
- cam_exposure <= cam->params.flickerControl.coarseJump - 3) {
+ cam_exposure <= cam->params.flickerControl.coarseJump - 3) {
/* Flicker control auto-disabled */
cam->params.flickerControl.disabled = 1;
}
-
+
if(cam->params.flickerControl.disabled &&
cam->params.flickerControl.flickerMode &&
old_exp > cam->params.flickerControl.coarseJump +
- ROUND_UP_EXP_FOR_FLICKER) {
+ ROUND_UP_EXP_FOR_FLICKER) {
/* exposure is now high enough to switch
flicker control back on */
set_flicker(&cam->params, &cam->cmd_queue, 1);
@@ -2818,7 +2818,7 @@ static int clear_stall(struct cam_data *cam)
{
/* FIXME: Does this actually work? */
LOG("Clearing stall\n");
-
+
cam->ops->streamRead(cam->lowlevel_data, cam->raw_image, 0);
do_command(cam, CPIA_COMMAND_GetCameraStatus,0,0,0,0);
return cam->params.status.streamState != STREAM_PAUSED;
@@ -2878,7 +2878,7 @@ static int fetch_frame(void *data)
return -EINTR;
do_command(cam, CPIA_COMMAND_GetCameraStatus,
- 0, 0, 0, 0);
+ 0, 0, 0, 0);
}
if(cam->params.status.streamState != STREAM_READY) {
continue;
@@ -2903,18 +2903,18 @@ static int fetch_frame(void *data)
/* Switch flicker control back on if it got turned off */
restart_flicker(cam);
-
+
/* If AEC is enabled, monitor the exposure and
adjust the sensor frame rate if needed */
if(cam->params.exposure.expMode == 2)
monitor_exposure(cam);
-
+
/* camera idle now so dispatch queued commands */
dispatch_commands(cam);
/* Update our knowledge of the camera state */
- do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0);
- do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
+ do_command(cam, CPIA_COMMAND_GetColourBalance, 0, 0, 0, 0);
+ do_command(cam, CPIA_COMMAND_GetExposure, 0, 0, 0, 0);
do_command(cam, CPIA_COMMAND_ReadMCPorts, 0, 0, 0, 0);
/* decompress and convert image to by copying it from
@@ -2933,7 +2933,7 @@ static int fetch_frame(void *data)
uncompressed. */
cam->first_frame = 1;
do_command(cam, CPIA_COMMAND_SetGrabMode,
- CPIA_GRAB_SINGLE, 0, 0, 0);
+ CPIA_GRAB_SINGLE, 0, 0, 0);
/* FIXME: Trial & error - need up to 70ms for
the grab mode change to complete ? */
msleep_interruptible(70);
@@ -2957,12 +2957,12 @@ static int fetch_frame(void *data)
if (cam->first_frame) {
cam->first_frame = 0;
do_command(cam, CPIA_COMMAND_SetCompression,
- cam->params.compression.mode,
+ cam->params.compression.mode,
cam->params.compression.decimation, 0, 0);
/* Switch from single-grab to continuous grab */
do_command(cam, CPIA_COMMAND_SetGrabMode,
- CPIA_GRAB_CONTINUOUS, 0, 0, 0);
+ CPIA_GRAB_CONTINUOUS, 0, 0, 0);
}
return 0;
}
@@ -2977,12 +2977,12 @@ static int capture_frame(struct cam_data *cam, struct video_mmap *vm)
if ((err = allocate_frame_buf(cam)))
return err;
}
-
+
cam->curframe = vm->frame;
cam->frame[cam->curframe].state = FRAME_READY;
return fetch_frame(cam);
}
-
+
static int goto_high_power(struct cam_data *cam)
{
if (do_command(cam, CPIA_COMMAND_GotoHiPower, 0, 0, 0, 0))
@@ -3039,22 +3039,22 @@ static void save_camera_state(struct cam_data *cam)
static int set_camera_state(struct cam_data *cam)
{
cam->cmd_queue = COMMAND_SETCOMPRESSION |
- COMMAND_SETCOMPRESSIONTARGET |
- COMMAND_SETCOLOURPARAMS |
- COMMAND_SETFORMAT |
- COMMAND_SETYUVTHRESH |
- COMMAND_SETECPTIMING |
- COMMAND_SETCOMPRESSIONPARAMS |
- COMMAND_SETEXPOSURE |
- COMMAND_SETCOLOURBALANCE |
- COMMAND_SETSENSORFPS |
- COMMAND_SETAPCOR |
- COMMAND_SETFLICKERCTRL |
- COMMAND_SETVLOFFSET;
+ COMMAND_SETCOMPRESSIONTARGET |
+ COMMAND_SETCOLOURPARAMS |
+ COMMAND_SETFORMAT |
+ COMMAND_SETYUVTHRESH |
+ COMMAND_SETECPTIMING |
+ COMMAND_SETCOMPRESSIONPARAMS |
+ COMMAND_SETEXPOSURE |
+ COMMAND_SETCOLOURBALANCE |
+ COMMAND_SETSENSORFPS |
+ COMMAND_SETAPCOR |
+ COMMAND_SETFLICKERCTRL |
+ COMMAND_SETVLOFFSET;
do_command(cam, CPIA_COMMAND_SetGrabMode, CPIA_GRAB_SINGLE,0,0,0);
dispatch_commands(cam);
-
+
/* Wait 6 frames for the sensor to get all settings and
AEC/ACB to settle */
msleep_interruptible(6*(cam->params.sensorFps.baserate ? 33 : 40) *
@@ -3062,7 +3062,7 @@ static int set_camera_state(struct cam_data *cam)
if(signal_pending(current))
return -EINTR;
-
+
save_camera_state(cam);
return 0;
@@ -3094,9 +3094,9 @@ static int reset_camera(struct cam_data *cam)
if (goto_low_power(cam))
return -ENODEV;
}
-
+
/* procedure described in developer's guide p3-28 */
-
+
/* Check the firmware version. */
cam->params.version.firmwareVersion = 0;
get_version_information(cam);
@@ -3113,14 +3113,14 @@ static int reset_camera(struct cam_data *cam)
cam->params.qx3.qx3_detected = (cam->params.pnpID.vendor == 0x0813 &&
cam->params.pnpID.product == 0x0001);
- /* The fatal error checking should be done after
+ /* The fatal error checking should be done after
* the camera powers up (developer's guide p 3-38) */
/* Set streamState before transition to high power to avoid bug
* in firmware 1-02 */
do_command(cam, CPIA_COMMAND_ModifyCameraStatus, STREAMSTATE, 0,
- STREAM_NOT_READY, 0);
-
+ STREAM_NOT_READY, 0);
+
/* GotoHiPower */
err = goto_high_power(cam);
if (err)
@@ -3142,16 +3142,16 @@ static int reset_camera(struct cam_data *cam)
/* Firmware 1-02 may do this for parallel port cameras,
* just clear the flags (developer's guide p 3-38) */
do_command(cam, CPIA_COMMAND_ModifyCameraStatus,
- FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0);
+ FATALERROR, ~(COM_FLAG|CPIA_FLAG), 0, 0);
}
}
-
+
/* Check the camera status again */
if (cam->params.status.fatalError) {
if (cam->params.status.fatalError)
return -EIO;
}
-
+
/* VPVersion can't be retrieved before the camera is in HiPower,
* so get it here instead of in get_version_information. */
do_command(cam, CPIA_COMMAND_GetVPVersion, 0, 0, 0, 0);
@@ -3193,24 +3193,24 @@ static int cpia_open(struct inode *inode, struct file *file)
if (!cam->raw_image)
goto oops;
}
-
+
if (!cam->decompressed_frame.data) {
cam->decompressed_frame.data = rvmalloc(CPIA_MAX_FRAME_SIZE);
if (!cam->decompressed_frame.data)
goto oops;
}
-
+
/* open cpia */
err = -ENODEV;
if (cam->ops->open(cam->lowlevel_data))
goto oops;
-
+
/* reset the camera */
if ((err = reset_camera(cam)) != 0) {
cam->ops->close(cam->lowlevel_data);
goto oops;
}
-
+
err = -EINTR;
if(signal_pending(current))
goto oops;
@@ -3224,7 +3224,7 @@ static int cpia_open(struct inode *inode, struct file *file)
/* init it to something */
cam->mmap_kludge = 0;
-
+
++cam->open_count;
file->private_data = dev;
mutex_unlock(&cam->busy_lock);
@@ -3250,10 +3250,10 @@ static int cpia_close(struct inode *inode, struct file *file)
struct cam_data *cam = dev->priv;
if (cam->ops) {
- /* Return ownership of /proc/cpia/videoX to root */
+ /* Return ownership of /proc/cpia/videoX to root */
if(cam->proc_entry)
cam->proc_entry->uid = 0;
-
+
/* save camera state for later open (developers guide ch 3.5.3) */
save_camera_state(cam);
@@ -3342,7 +3342,7 @@ static ssize_t cpia_read(struct file *file, char __user *buf,
return -EFAULT;
}
if (copy_to_user(buf, cam->decompressed_frame.data,
- cam->decompressed_frame.count)) {
+ cam->decompressed_frame.count)) {
DBG("copy_to_user failed\n");
mutex_unlock(&cam->busy_lock);
return -EFAULT;
@@ -3361,7 +3361,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
if (!cam || !cam->ops)
return -ENODEV;
-
+
/* make this _really_ smp-safe */
if (mutex_lock_interruptible(&cam->busy_lock))
return -EINTR;
@@ -3405,7 +3405,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
v->norm = 0;
break;
}
-
+
case VIDIOCSCHAN:
{
struct video_channel *v = arg;
@@ -3424,7 +3424,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
*pic = cam->vp;
break;
}
-
+
case VIDIOCSPICT:
{
struct video_picture *vp = arg;
@@ -3458,11 +3458,11 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
/* Adjust flicker control if necessary */
if(cam->params.flickerControl.allowableOverExposure < 0)
- cam->params.flickerControl.allowableOverExposure =
+ cam->params.flickerControl.allowableOverExposure =
-find_over_exposure(cam->params.colourParams.brightness);
if(cam->params.flickerControl.flickerMode != 0)
cam->cmd_queue |= COMMAND_SETFLICKERCTRL;
-
+
/* queue command to update camera */
cam->cmd_queue |= COMMAND_SETCOLOURPARAMS;
@@ -3482,7 +3482,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
*vw = cam->vw;
break;
}
-
+
case VIDIOCSWIN:
{
/* copy_from_user, check validity, copy to internal structure */
@@ -3514,7 +3514,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
/* video size is changing, reset the subcapture area */
memset(&cam->vc, 0, sizeof(cam->vc));
-
+
set_vw_size(cam);
DBG("%d / %d\n", cam->vw.width, cam->vw.height);
cam->cmd_queue |= COMMAND_SETFORMAT;
@@ -3547,7 +3547,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
vm->offsets[i] = CPIA_MAX_FRAME_SIZE * i;
break;
}
-
+
case VIDIOCMCAPTURE:
{
struct video_mmap *vm = arg;
@@ -3597,7 +3597,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
/* video size is changing, reset the subcapture area */
memset(&cam->vc, 0, sizeof(cam->vc));
-
+
set_vw_size(cam);
cam->cmd_queue |= COMMAND_SETFORMAT;
dispatch_commands(cam);
@@ -3608,7 +3608,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
break;
}
-
+
case VIDIOCSYNC:
{
int *frame = arg;
@@ -3649,7 +3649,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
*vc = cam->vc;
break;
- }
+ }
case VIDIOCSCAPTURE:
{
@@ -3665,7 +3665,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
retval = -EINVAL;
break;
}
-
+
/* Clip to the resolution we can set for the ROI
(every 8 columns and 4 rows) */
vc->x = vc->x & ~(__u32)7;
@@ -3681,14 +3681,14 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
}
DBG("%d,%d/%dx%d\n", vc->x,vc->y,vc->width, vc->height);
-
+
mutex_lock(&cam->param_lock);
-
+
cam->vc.x = vc->x;
cam->vc.y = vc->y;
cam->vc.width = vc->width;
cam->vc.height = vc->height;
-
+
set_vw_size(cam);
cam->cmd_queue |= COMMAND_SETFORMAT;
@@ -3699,7 +3699,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
dispatch_commands(cam);
break;
}
-
+
case VIDIOCGUNIT:
{
struct video_unit *vu = arg;
@@ -3715,7 +3715,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
break;
}
-
+
/* pointless to implement overlay with this camera */
case VIDIOCCAPTURE:
case VIDIOCGFBUF:
@@ -3738,7 +3738,7 @@ static int cpia_do_ioctl(struct inode *inode, struct file *file,
mutex_unlock(&cam->busy_lock);
return retval;
-}
+}
static int cpia_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
@@ -3759,7 +3759,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
if (!cam || !cam->ops)
return -ENODEV;
-
+
DBG("cpia_mmap: %ld\n", size);
if (size > FRAME_NUM*CPIA_MAX_FRAME_SIZE)
@@ -3767,7 +3767,7 @@ static int cpia_mmap(struct file *file, struct vm_area_struct *vma)
if (!cam || !cam->ops)
return -ENODEV;
-
+
/* make this _really_ smp-safe */
if (mutex_lock_interruptible(&cam->busy_lock))
return -EINTR;
@@ -3851,11 +3851,11 @@ static void reset_camera_struct(struct cam_data *cam)
cam->params.flickerControl.flickerMode = 0;
cam->params.flickerControl.disabled = 1;
- cam->params.flickerControl.coarseJump =
+ cam->params.flickerControl.coarseJump =
flicker_jumps[cam->mainsFreq]
- [cam->params.sensorFps.baserate]
- [cam->params.sensorFps.divisor];
- cam->params.flickerControl.allowableOverExposure =
+ [cam->params.sensorFps.baserate]
+ [cam->params.sensorFps.divisor];
+ cam->params.flickerControl.allowableOverExposure =
-find_over_exposure(cam->params.colourParams.brightness);
cam->params.vlOffset.gain1 = 20;
cam->params.vlOffset.gain2 = 24;
@@ -3870,21 +3870,21 @@ static void reset_camera_struct(struct cam_data *cam)
cam->params.compressionParams.qDiffStepThresh = 3;
cam->params.compressionParams.decimationThreshMod = 2;
/* End of default values from Software Developer's Guide */
-
+
cam->transfer_rate = 0;
cam->exposure_status = EXPOSURE_NORMAL;
-
+
/* Set Sensor FPS to 15fps. This seems better than 30fps
* for indoor lighting. */
cam->params.sensorFps.divisor = 1;
cam->params.sensorFps.baserate = 1;
-
+
cam->params.yuvThreshold.yThreshold = 6; /* From windows driver */
cam->params.yuvThreshold.uvThreshold = 6; /* From windows driver */
-
+
cam->params.format.subSample = SUBSAMPLE_422;
cam->params.format.yuvOrder = YUVORDER_YUYV;
-
+
cam->params.compression.mode = CPIA_COMPRESSION_AUTO;
cam->params.compressionTarget.frTargeting =
CPIA_COMPRESSION_TARGET_QUALITY;
@@ -3898,7 +3898,7 @@ static void reset_camera_struct(struct cam_data *cam)
cam->params.qx3.cradled = 0;
cam->video_size = VIDEOSIZE_CIF;
-
+
cam->vp.colour = 32768; /* 50% */
cam->vp.hue = 32768; /* 50% */
cam->vp.brightness = 32768; /* 50% */
@@ -3911,7 +3911,7 @@ static void reset_camera_struct(struct cam_data *cam)
cam->vc.y = 0;
cam->vc.width = 0;
cam->vc.height = 0;
-
+
cam->vw.x = 0;
cam->vw.y = 0;
set_vw_size(cam);
@@ -3928,7 +3928,7 @@ static void reset_camera_struct(struct cam_data *cam)
/* initialize cam_data structure */
static void init_camera_struct(struct cam_data *cam,
- struct cpia_camera_ops *ops )
+ struct cpia_camera_ops *ops )
{
int i;
@@ -3945,7 +3945,7 @@ static void init_camera_struct(struct cam_data *cam,
memcpy(&cam->vdev, &cpia_template, sizeof(cpia_template));
cam->vdev.priv = cam;
-
+
cam->curframe = 0;
for (i = 0; i < FRAME_NUM; i++) {
cam->frame[i].width = 0;
@@ -3961,15 +3961,15 @@ static void init_camera_struct(struct cam_data *cam,
struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowlevel)
{
- struct cam_data *camera;
-
+ struct cam_data *camera;
+
if ((camera = kmalloc(sizeof(struct cam_data), GFP_KERNEL)) == NULL)
return NULL;
-
+
init_camera_struct( camera, ops );
camera->lowlevel_data = lowlevel;
-
+
/* register v4l device */
if (video_register_device(&camera->vdev, VFL_TYPE_GRABBER, video_nr) == -1) {
kfree(camera);
@@ -3982,7 +3982,7 @@ struct cam_data *cpia_register_camera(struct cpia_camera_ops *ops, void *lowleve
/* open cpia */
if (camera->ops->open(camera->lowlevel_data))
return camera;
-
+
/* reset the camera */
if (reset_camera(camera) != 0) {
camera->ops->close(camera->lowlevel_data);
@@ -4022,11 +4022,11 @@ void cpia_unregister_camera(struct cam_data *cam)
DBG("camera open -- setting ops to NULL\n");
cam->ops = NULL;
}
-
+
#ifdef CONFIG_PROC_FS
DBG("destroying /proc/cpia/video%d\n", cam->vdev.minor);
destroy_proc_cpia_cam(cam);
-#endif
+#endif
if (!cam->open_count) {
DBG("freeing camera\n");
kfree(cam);
diff --git a/drivers/media/video/cpia.h b/drivers/media/video/cpia.h
index de6678200a5..dde27a6a4a0 100644
--- a/drivers/media/video/cpia.h
+++ b/drivers/media/video/cpia.h
@@ -52,10 +52,10 @@
struct cpia_camera_ops
{
/* open sets privdata to point to structure for this camera.
- * Returns negative value on error, otherwise 0.
+ * Returns negative value on error, otherwise 0.
*/
int (*open)(void *privdata);
-
+
/* Registers callback function cb to be called with cbdata
* when an image is ready. If cb is NULL, only single image grabs
* should be used. cb should immediately call streamRead to read
@@ -63,8 +63,8 @@ struct cpia_camera_ops
* otherwise 0.
*/
int (*registerCallback)(void *privdata, void (*cb)(void *cbdata),
- void *cbdata);
-
+ void *cbdata);
+
/* transferCmd sends commands to the camera. command MUST point to
* an 8 byte buffer in kernel space. data can be NULL if no extra
* data is needed. The size of the data is given by the last 2
@@ -77,30 +77,30 @@ struct cpia_camera_ops
* Returns negative value on error, otherwise 0.
*/
int (*streamStart)(void *privdata);
-
+
/* streamStop terminates stream capture mode.
* Returns negative value on error, otherwise 0.
*/
int (*streamStop)(void *privdata);
-
+
/* streamRead reads a frame from the camera. buffer points to a
- * buffer large enough to hold a complete frame in kernel space.
- * noblock indicates if this should be a non blocking read.
+ * buffer large enough to hold a complete frame in kernel space.
+ * noblock indicates if this should be a non blocking read.
* Returns the number of bytes read, or negative value on error.
- */
+ */
int (*streamRead)(void *privdata, u8 *buffer, int noblock);
-
+
/* close disables the device until open() is called again.
* Returns negative value on error, otherwise 0.
*/
int (*close)(void *privdata);
-
+
/* If wait_for_stream_ready is non-zero, wait until the streamState
* is STREAM_READY before calling streamRead.
*/
int wait_for_stream_ready;
- /*
+ /*
* Used to maintain lowlevel module usage counts
*/
struct module *owner;
@@ -215,14 +215,14 @@ struct cam_params {
u8 videoSize; /* CIF/QCIF */
u8 subSample;
u8 yuvOrder;
- } format;
- struct { /* Intel QX3 specific data */
- u8 qx3_detected; /* a QX3 is present */
- u8 toplight; /* top light lit , R/W */
- u8 bottomlight; /* bottom light lit, R/W */
- u8 button; /* snapshot button pressed (R/O) */
- u8 cradled; /* microscope is in cradle (R/O) */
- } qx3;
+ } format;
+ struct { /* Intel QX3 specific data */
+ u8 qx3_detected; /* a QX3 is present */
+ u8 toplight; /* top light lit , R/W */
+ u8 bottomlight; /* bottom light lit, R/W */
+ u8 button; /* snapshot button pressed (R/O) */
+ u8 cradled; /* microscope is in cradle (R/O) */
+ } qx3;
struct {
u8 colStart; /* skip first 8*colStart pixels */
u8 colEnd; /* finish at 8*colEnd pixels */
@@ -247,13 +247,13 @@ enum v4l_camstates {
struct cam_data {
struct list_head cam_data_list;
- struct mutex busy_lock; /* guard against SMP multithreading */
+ struct mutex busy_lock; /* guard against SMP multithreading */
struct cpia_camera_ops *ops; /* lowlevel driver operations */
void *lowlevel_data; /* private data for lowlevel driver */
u8 *raw_image; /* buffer for raw image data */
struct cpia_frame decompressed_frame;
- /* buffer to hold decompressed frame */
- int image_size; /* sizeof last decompressed image */
+ /* buffer to hold decompressed frame */
+ int image_size; /* sizeof last decompressed image */
int open_count; /* # of process that have camera open */
/* camera status */
@@ -265,7 +265,7 @@ struct cam_data {
struct mutex param_lock; /* params lock for this camera */
struct cam_params params; /* camera settings */
struct proc_dir_entry *proc_entry; /* /proc/cpia/videoX */
-
+
/* v4l */
int video_size; /* VIDEO_SIZE_ */
volatile enum v4l_camstates camstate; /* v4l layer status */
@@ -277,7 +277,7 @@ struct cam_data {
/* mmap interface */
int curframe; /* the current frame to grab into */
u8 *frame_buf; /* frame buffer data */
- struct cpia_frame frame[FRAME_NUM];
+ struct cpia_frame frame[FRAME_NUM];
/* FRAME_NUM-buffering, so we need a array */
int first_frame;
@@ -424,7 +424,7 @@ void cpia_unregister_camera(struct cam_data *cam);
#define DEB_BYTE(p)\
DBG("%1d %1d %1d %1d %1d %1d %1d %1d \n",\
(p)&0x80?1:0, (p)&0x40?1:0, (p)&0x20?1:0, (p)&0x10?1:0,\
- (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
+ (p)&0x08?1:0, (p)&0x04?1:0, (p)&0x02?1:0, (p)&0x01?1:0);
#endif /* __KERNEL__ */
diff --git a/drivers/media/video/cpia2/cpia2.h b/drivers/media/video/cpia2/cpia2.h
index 95d3afa94a3..8394283993f 100644
--- a/drivers/media/video/cpia2/cpia2.h
+++ b/drivers/media/video/cpia2/cpia2.h
@@ -381,7 +381,7 @@ struct cpia2_fh {
struct camera_data {
/* locks */
- struct semaphore busy_lock; /* guard against SMP multithreading */
+ struct mutex busy_lock; /* guard against SMP multithreading */
struct v4l2_prio_state prio;
/* camera status */
diff --git a/drivers/media/video/cpia2/cpia2_core.c b/drivers/media/video/cpia2/cpia2_core.c
index 5dfb242d5b8..fd771c7a2fe 100644
--- a/drivers/media/video/cpia2/cpia2_core.c
+++ b/drivers/media/video/cpia2/cpia2_core.c
@@ -2238,7 +2238,7 @@ struct camera_data *cpia2_init_camera_struct(void)
memset(cam, 0, sizeof(struct camera_data));
cam->present = 1;
- init_MUTEX(&cam->busy_lock);
+ mutex_init(&cam->busy_lock);
init_waitqueue_head(&cam->wq_stream);
return cam;
@@ -2371,12 +2371,12 @@ long cpia2_read(struct camera_data *cam,
}
/* make this _really_ smp and multithread-safe */
- if (down_interruptible(&cam->busy_lock))
+ if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;
if (!cam->present) {
LOG("%s: camera removed\n",__FUNCTION__);
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return 0; /* EOF */
}
@@ -2389,34 +2389,34 @@ long cpia2_read(struct camera_data *cam,
/* Copy cam->curbuff in case it changes while we're processing */
frame = cam->curbuff;
if (noblock && frame->status != FRAME_READY) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EAGAIN;
}
if(frame->status != FRAME_READY) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->present ||
(frame = cam->curbuff)->status == FRAME_READY);
if (signal_pending(current))
return -ERESTARTSYS;
/* make this _really_ smp and multithread-safe */
- if (down_interruptible(&cam->busy_lock)) {
+ if (mutex_lock_interruptible(&cam->busy_lock)) {
return -ERESTARTSYS;
}
if(!cam->present) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return 0;
}
}
/* copy data to user space */
if (frame->length > count) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EFAULT;
}
if (copy_to_user(buf, frame->data, frame->length)) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EFAULT;
}
@@ -2424,7 +2424,7 @@ long cpia2_read(struct camera_data *cam,
frame->status = FRAME_EMPTY;
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return count;
}
@@ -2443,10 +2443,10 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
return POLLERR;
}
- down(&cam->busy_lock);
+ mutex_lock(&cam->busy_lock);
if(!cam->present) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return POLLHUP;
}
@@ -2456,16 +2456,16 @@ unsigned int cpia2_poll(struct camera_data *cam, struct file *filp,
cam->params.camera_state.stream_mode);
}
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
poll_wait(filp, &cam->wq_stream, wait);
- down(&cam->busy_lock);
+ mutex_lock(&cam->busy_lock);
if(!cam->present)
status = POLLHUP;
else if(cam->curbuff->status == FRAME_READY)
status = POLLIN | POLLRDNORM;
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return status;
}
@@ -2488,18 +2488,18 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
DBG("mmap offset:%ld size:%ld\n", start_offset, size);
/* make this _really_ smp-safe */
- if (down_interruptible(&cam->busy_lock))
+ if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;
if (!cam->present) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -ENODEV;
}
if (size > cam->frame_size*cam->num_frames ||
(start_offset % cam->frame_size) != 0 ||
(start_offset+size > cam->frame_size*cam->num_frames)) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EINVAL;
}
@@ -2507,7 +2507,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
while (size > 0) {
page = kvirt_to_pa(pos);
if (remap_pfn_range(vma, start, page >> PAGE_SHIFT, PAGE_SIZE, PAGE_SHARED)) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EAGAIN;
}
start += PAGE_SIZE;
@@ -2519,7 +2519,7 @@ int cpia2_remap_buffer(struct camera_data *cam, struct vm_area_struct *vma)
}
cam->mmapped = true;
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return 0;
}
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c
index 08f8be345fa..481e178ef56 100644
--- a/drivers/media/video/cpia2/cpia2_v4l.c
+++ b/drivers/media/video/cpia2/cpia2_v4l.c
@@ -255,7 +255,7 @@ static int cpia2_open(struct inode *inode, struct file *file)
return -ENODEV;
}
- if(down_interruptible(&cam->busy_lock))
+ if(mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;
if(!cam->present) {
@@ -299,7 +299,7 @@ skip_init:
cpia2_dbg_dump_registers(cam);
err_return:
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return retval;
}
@@ -314,7 +314,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
struct camera_data *cam = video_get_drvdata(dev);
struct cpia2_fh *fh = file->private_data;
- down(&cam->busy_lock);
+ mutex_lock(&cam->busy_lock);
if (cam->present &&
(cam->open_count == 1
@@ -347,7 +347,7 @@ static int cpia2_close(struct inode *inode, struct file *file)
}
}
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return 0;
}
@@ -523,11 +523,11 @@ static int sync(struct camera_data *cam, int frame_nr)
return 0;
}
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->streaming ||
frame->status == FRAME_READY);
- down(&cam->busy_lock);
+ mutex_lock(&cam->busy_lock);
if (signal_pending(current))
return -ERESTARTSYS;
if(!cam->present)
@@ -1544,11 +1544,11 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file)
if(frame < 0) {
/* Wait for a frame to become available */
struct framebuf *cb=cam->curbuff;
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
wait_event_interruptible(cam->wq_stream,
!cam->present ||
(cb=cam->curbuff)->status == FRAME_READY);
- down(&cam->busy_lock);
+ mutex_lock(&cam->busy_lock);
if (signal_pending(current))
return -ERESTARTSYS;
if(!cam->present)
@@ -1591,11 +1591,11 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
return -ENOTTY;
/* make this _really_ smp-safe */
- if (down_interruptible(&cam->busy_lock))
+ if (mutex_lock_interruptible(&cam->busy_lock))
return -ERESTARTSYS;
if (!cam->present) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -ENODEV;
}
@@ -1608,7 +1608,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
struct cpia2_fh *fh = file->private_data;
retval = v4l2_prio_check(&cam->prio, &fh->prio);
if(retval) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return retval;
}
break;
@@ -1618,7 +1618,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
{
struct cpia2_fh *fh = file->private_data;
if(fh->prio != V4L2_PRIORITY_RECORD) {
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return -EBUSY;
}
break;
@@ -1847,7 +1847,7 @@ static int cpia2_do_ioctl(struct inode *inode, struct file *file,
break;
}
- up(&cam->busy_lock);
+ mutex_unlock(&cam->busy_lock);
return retval;
}
@@ -1924,14 +1924,15 @@ static void reset_camera_struct_v4l(struct camera_data *cam)
* The v4l video device structure initialized for this device
***/
static struct file_operations fops_template = {
- .owner= THIS_MODULE,
- .open= cpia2_open,
- .release= cpia2_close,
- .read= cpia2_v4l_read,
- .poll= cpia2_v4l_poll,
- .ioctl= cpia2_ioctl,
- .llseek= no_llseek,
- .mmap= cpia2_mmap,
+ .owner = THIS_MODULE,
+ .open = cpia2_open,
+ .release = cpia2_close,
+ .read = cpia2_v4l_read,
+ .poll = cpia2_v4l_poll,
+ .ioctl = cpia2_ioctl,
+ .llseek = no_llseek,
+ .compat_ioctl = v4l_compat_ioctl32,
+ .mmap = cpia2_mmap,
};
static struct video_device cpia2_template = {
diff --git a/drivers/media/video/cpia_pp.c b/drivers/media/video/cpia_pp.c
index 74cff626e04..3021f21aae3 100644
--- a/drivers/media/video/cpia_pp.c
+++ b/drivers/media/video/cpia_pp.c
@@ -23,7 +23,7 @@
*/
/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
-/* #define _CPIA_DEBUG_ 1 */
+/* #define _CPIA_DEBUG_ 1 */
#include <linux/config.h>
@@ -45,7 +45,7 @@
static int cpia_pp_open(void *privdata);
static int cpia_pp_registerCallback(void *privdata, void (*cb) (void *cbdata),
- void *cbdata);
+ void *cbdata);
static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data);
static int cpia_pp_streamStart(void *privdata);
static int cpia_pp_streamStop(void *privdata);
@@ -93,7 +93,7 @@ struct pp_cam_entry {
int stream_irq;
};
-static struct cpia_camera_ops cpia_pp_ops =
+static struct cpia_camera_ops cpia_pp_ops =
{
cpia_pp_open,
cpia_pp_registerCallback,
@@ -123,7 +123,7 @@ static void cpia_parport_disable_irq( struct parport *port ) {
}
/* Special CPiA PPC modes: These are invoked by using the 1284 Extensibility
- * Link Flag during negotiation */
+ * Link Flag during negotiation */
#define UPLOAD_FLAG 0x08
#define NIBBLE_TRANSFER 0x01
#define ECP_TRANSFER 0x03
@@ -139,17 +139,17 @@ static void cpia_parport_disable_irq( struct parport *port ) {
/* CPiA nonstandard "Nibble" mode (no nDataAvail signal after each byte). */
/* The standard kernel parport_ieee1284_read_nibble() fails with the CPiA... */
-static size_t cpia_read_nibble (struct parport *port,
- void *buffer, size_t len,
+static size_t cpia_read_nibble (struct parport *port,
+ void *buffer, size_t len,
int flags)
{
- /* adapted verbatim, with one change, from
+ /* adapted verbatim, with one change, from
parport_ieee1284_read_nibble() in drivers/parport/ieee1284-ops.c */
unsigned char *buf = buffer;
int i;
unsigned char byte = 0;
-
+
len *= 2; /* in nibbles */
for (i=0; i < len; i++) {
unsigned char nibble;
@@ -158,12 +158,12 @@ static size_t cpia_read_nibble (struct parport *port,
* after every second nibble to signal that more
* data is available. (the total number of Bytes that
* should be sent is known; if too few are received, an error
- * will be recorded after a timeout).
+ * will be recorded after a timeout).
* This is incompatible with parport_ieee1284_read_nibble(),
* which expects to find nFault LO after every second nibble.
*/
- /* Solution: modify cpia_read_nibble to only check for
+ /* Solution: modify cpia_read_nibble to only check for
* nDataAvail before the first nibble is sent.
*/
@@ -216,7 +216,7 @@ static size_t cpia_read_nibble (struct parport *port,
/* Second nibble */
byte |= nibble << 4;
*buf++ = byte;
- } else
+ } else
byte = nibble;
}
@@ -238,18 +238,18 @@ static size_t cpia_read_nibble (struct parport *port,
}
/* CPiA nonstandard "Nibble Stream" mode (2 nibbles per cycle, instead of 1)
- * (See CPiA Data sheet p. 31)
- *
- * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a
- * nonstandard variant of nibble mode which allows the same (mediocre)
- * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable
+ * (See CPiA Data sheet p. 31)
+ *
+ * "Nibble Stream" mode used by CPiA for uploads to non-ECP ports is a
+ * nonstandard variant of nibble mode which allows the same (mediocre)
+ * data flow of 8 bits per cycle as software-enabled ECP by TRISTATE-capable
* parallel ports, but works also for non-TRISTATE-capable ports.
* (Standard nibble mode only send 4 bits per cycle)
*
*/
-static size_t cpia_read_nibble_stream(struct parport *port,
- void *buffer, size_t len,
+static size_t cpia_read_nibble_stream(struct parport *port,
+ void *buffer, size_t len,
int flags)
{
int i;
@@ -260,7 +260,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
unsigned char nibble[2], byte = 0;
int j;
- /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */
+ /* Image Data is complete when 4 consecutive EOI bytes (0xff) are seen */
if (endseen > 3 )
break;
@@ -268,7 +268,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
parport_frob_control (port,
PARPORT_CONTROL_AUTOFD,
PARPORT_CONTROL_AUTOFD);
-
+
/* Event 9: nAck goes low. */
port->ieee1284.phase = IEEE1284_PH_REV_DATA;
if (parport_wait_peripheral (port,
@@ -282,7 +282,7 @@ static size_t cpia_read_nibble_stream(struct parport *port,
/* Read lower nibble */
nibble[0] = parport_read_status (port) >>3;
-
+
/* Event 10: Set nAutoFd high. */
parport_frob_control (port, PARPORT_CONTROL_AUTOFD, 0);
@@ -295,10 +295,10 @@ static size_t cpia_read_nibble_stream(struct parport *port,
port->name);
break;
}
-
+
/* Read upper nibble */
nibble[1] = parport_read_status (port) >>3;
-
+
/* reassemble the byte */
for (j = 0; j < 2 ; j++ ) {
nibble[j] &= ~8;
@@ -335,8 +335,8 @@ static void EndTransferMode(struct pp_cam_entry *cam)
static int ForwardSetup(struct pp_cam_entry *cam)
{
int retry;
-
- /* The CPiA uses ECP protocol for Downloads from the Host to the camera.
+
+ /* The CPiA uses ECP protocol for Downloads from the Host to the camera.
* This will be software-emulated if ECP hardware is not present
*/
@@ -375,9 +375,9 @@ static int ReverseSetup(struct pp_cam_entry *cam, int extensibility)
upload_mode = mode;
if(extensibility) mode = UPLOAD_FLAG|transfer_mode|IEEE1284_EXT_LINK;
- /* the usual camera maximum response time is 10ms, but after
+ /* the usual camera maximum response time is 10ms, but after
* receiving some commands, it needs up to 40ms. */
-
+
for(retry = 0; retry < 4; ++retry) {
if(!parport_negotiate(cam->port, mode)) {
break;
@@ -439,10 +439,10 @@ static int ReadPacket(struct pp_cam_entry *cam, u8 *packet, size_t size)
/* support for CPiA variant nibble reads */
if(cam->port->ieee1284.mode == IEEE1284_MODE_NIBBLE) {
- if(cpia_read_nibble(cam->port, packet, size, 0) != size)
- retval = -EIO;
+ if(cpia_read_nibble(cam->port, packet, size, 0) != size)
+ retval = -EIO;
} else {
- if(parport_read(cam->port, packet, size) != size)
+ if(parport_read(cam->port, packet, size) != size)
retval = -EIO;
}
EndTransferMode(cam);
@@ -542,18 +542,18 @@ static int cpia_pp_streamRead(void *privdata, u8 *buffer, int noblock)
block_size = PARPORT_CHUNK_SIZE;
while( !cam->image_complete ) {
cond_resched();
-
+
new_bytes = cpia_pp_read(cam->port, buffer, block_size );
if( new_bytes <= 0 ) {
break;
}
i=-1;
while(++i<new_bytes && endseen<4) {
- if(*buffer==EOI) {
- endseen++;
- } else {
- endseen=0;
- }
+ if(*buffer==EOI) {
+ endseen++;
+ } else {
+ endseen=0;
+ }
buffer++;
}
read_bytes += i;
@@ -601,7 +601,7 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
}
if((err = ReadPacket(cam, buffer, 8)) < 0) {
DBG("Error reading command result\n");
- return err;
+ return err;
}
memcpy(data, buffer, databytes);
} else if(command[0] == DATA_OUT) {
@@ -631,10 +631,10 @@ static int cpia_pp_transferCmd(void *privdata, u8 *command, u8 *data)
static int cpia_pp_open(void *privdata)
{
struct pp_cam_entry *cam = (struct pp_cam_entry *)privdata;
-
+
if (cam == NULL)
return -EINVAL;
-
+
if(cam->open_count == 0) {
if (parport_claim(cam->pdev)) {
DBG("failed to claim the port\n");
@@ -645,12 +645,12 @@ static int cpia_pp_open(void *privdata)
parport_write_control(cam->port, PARPORT_CONTROL_SELECT);
udelay(50);
parport_write_control(cam->port,
- PARPORT_CONTROL_SELECT
- | PARPORT_CONTROL_INIT);
+ PARPORT_CONTROL_SELECT
+ | PARPORT_CONTROL_INIT);
}
-
+
++cam->open_count;
-
+
return 0;
}
@@ -663,7 +663,7 @@ static int cpia_pp_registerCallback(void *privdata, void (*cb)(void *cbdata), vo
{
struct pp_cam_entry *cam = privdata;
int retval = 0;
-
+
if(cam->port->irq != PARPORT_IRQ_NONE) {
INIT_WORK(&cam->cb_task, cb, cbdata);
} else {
@@ -707,9 +707,9 @@ static int cpia_pp_register(struct parport *port)
LOG("failed to allocate camera structure\n");
return -ENOMEM;
}
-
+
pdev = parport_register_device(port, "cpia_pp", NULL, NULL,
- NULL, 0, cam);
+ NULL, 0, cam);
if (!pdev) {
LOG("failed to parport_register_device\n");
@@ -753,19 +753,19 @@ static void cpia_pp_detach (struct parport *port)
}
cpia = NULL;
}
- spin_unlock( &cam_list_lock_pp );
+ spin_unlock( &cam_list_lock_pp );
if (!cpia) {
DBG("cpia_pp_detach failed to find cam_data in cam_list\n");
return;
}
-
- cam = (struct pp_cam_entry *) cpia->lowlevel_data;
+
+ cam = (struct pp_cam_entry *) cpia->lowlevel_data;
cpia_unregister_camera(cpia);
- if(cam->open_count > 0)
+ if(cam->open_count > 0)
cpia_pp_close(cam);
parport_unregister_device(cam->pdev);
- cpia->lowlevel_data = NULL;
+ cpia->lowlevel_data = NULL;
kfree(cam);
}
@@ -805,14 +805,14 @@ static struct parport_driver cpia_pp_driver = {
int cpia_pp_init(void)
{
- printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
+ printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
CPIA_PP_MAJ_VER,CPIA_PP_MIN_VER,CPIA_PP_PATCH_VER);
if(parport_nr[0] == PPCPIA_PARPORT_OFF) {
printk(" disabled\n");
return 0;
}
-
+
spin_lock_init( &cam_list_lock_pp );
if (parport_register_driver (&cpia_pp_driver)) {
diff --git a/drivers/media/video/cpia_usb.c b/drivers/media/video/cpia_usb.c
index 03275c37c5d..9c49a4b0011 100644
--- a/drivers/media/video/cpia_usb.c
+++ b/drivers/media/video/cpia_usb.c
@@ -22,7 +22,7 @@
*/
/* define _CPIA_DEBUG_ for verbose debug output (see cpia.h) */
-/* #define _CPIA_DEBUG_ 1 */
+/* #define _CPIA_DEBUG_ 1 */
#include <linux/module.h>
#include <linux/kernel.h>
@@ -85,7 +85,7 @@ struct usb_cpia {
static int cpia_usb_open(void *privdata);
static int cpia_usb_registerCallback(void *privdata, void (*cb) (void *cbdata),
- void *cbdata);
+ void *cbdata);
static int cpia_usb_transferCmd(void *privdata, u8 *command, u8 *data);
static int cpia_usb_streamStart(void *privdata);
static int cpia_usb_streamStop(void *privdata);
@@ -127,7 +127,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
ucpia->workbuff->status = FRAME_READING;
ucpia->workbuff->length = 0;
}
-
+
for (i = 0; i < urb->number_of_packets; i++) {
int n = urb->iso_frame_desc[i].actual_length;
int st = urb->iso_frame_desc[i].status;
@@ -141,9 +141,9 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
printk(KERN_DEBUG "cpia: scratch buf overflow!scr_len: %d, n: %d\n", ucpia->workbuff->length, n);
return;
}
-
+
if (n) {
- if ((ucpia->workbuff->length > 0) ||
+ if ((ucpia->workbuff->length > 0) ||
(0x19 == cdata[0] && 0x68 == cdata[1])) {
memcpy(ucpia->workbuff->data + ucpia->workbuff->length, cdata, n);
ucpia->workbuff->length += n;
@@ -160,7 +160,7 @@ static void cpia_usb_complete(struct urb *urb, struct pt_regs *regs)
ucpia->workbuff = ucpia->workbuff->next;
ucpia->workbuff->status = FRAME_EMPTY;
ucpia->workbuff->length = 0;
-
+
if (waitqueue_active(&ucpia->wq_stream))
wake_up_interruptible(&ucpia->wq_stream);
}
@@ -178,7 +178,7 @@ static int cpia_usb_open(void *privdata)
struct usb_cpia *ucpia = (struct usb_cpia *) privdata;
struct urb *urb;
int ret, retval = 0, fx, err;
-
+
if (!ucpia)
return -EINVAL;
@@ -191,7 +191,7 @@ static int cpia_usb_open(void *privdata)
retval = -EINVAL;
goto error_0;
}
-
+
ret = usb_set_interface(ucpia->dev, ucpia->iface, 3);
if (ret < 0) {
printk(KERN_ERR "cpia_usb_open: usb_set_interface error (ret = %d)\n", ret);
@@ -286,7 +286,7 @@ error_1:
error_0:
kfree (ucpia->sbuf[0].data);
ucpia->sbuf[0].data = NULL;
-
+
return retval;
}
@@ -307,7 +307,7 @@ static int WritePacket(struct usb_device *udev, const u8 *packet, u8 *buf, size_
return usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
packet[1] + (packet[0] << 8),
USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- packet[2] + (packet[3] << 8),
+ packet[2] + (packet[3] << 8),
packet[4] + (packet[5] << 8), buf, size, 1000);
}
@@ -324,7 +324,7 @@ static int ReadPacket(struct usb_device *udev, u8 *packet, u8 *buf, size_t size)
return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
packet[1] + (packet[0] << 8),
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- packet[2] + (packet[3] << 8),
+ packet[2] + (packet[3] << 8),
packet[4] + (packet[5] << 8), buf, size, 1000);
}
@@ -393,7 +393,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
if (!ucpia || !ucpia->present)
return -1;
-
+
if (ucpia->curbuff->status != FRAME_READY)
interruptible_sleep_on(&ucpia->wq_stream);
else
@@ -403,7 +403,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
if (!mybuff)
return -1;
-
+
if (mybuff->status != FRAME_READY || mybuff->length < 4) {
DBG("Something went wrong!\n");
return -1;
@@ -411,7 +411,7 @@ static int cpia_usb_streamRead(void *privdata, u8 *frame, int noblock)
memcpy(frame, mybuff->data, mybuff->length);
mybuff->status = FRAME_EMPTY;
-
+
/* DBG("read done, %d bytes, Header: %x/%x, Footer: %x%x%x%x\n", */
/* mybuff->length, frame[0], frame[1], */
/* frame[mybuff->length-4], frame[mybuff->length-3], */
@@ -447,7 +447,7 @@ static void cpia_usb_free_resources(struct usb_cpia *ucpia, int try)
kfree(ucpia->sbuf[1].data);
ucpia->sbuf[1].data = NULL;
-
+
if (ucpia->sbuf[0].urb) {
usb_kill_urb(ucpia->sbuf[0].urb);
usb_free_urb(ucpia->sbuf[0].urb);
@@ -490,7 +490,7 @@ static int cpia_probe(struct usb_interface *intf,
struct usb_cpia *ucpia;
struct cam_data *cam;
int ret;
-
+
/* A multi-config CPiA camera? */
if (udev->descriptor.bNumConfigurations != 1)
return -ENODEV;
@@ -539,7 +539,7 @@ static int cpia_probe(struct usb_interface *intf,
/* Before register_camera, important */
ucpia->present = 1;
-
+
cam = cpia_register_camera(&cpia_usb_ops, ucpia);
if (!cam) {
LOG("failed to cpia_register_camera\n");
@@ -591,7 +591,7 @@ static void cpia_disconnect(struct usb_interface *intf)
struct cam_data *cam = usb_get_intfdata(intf);
struct usb_cpia *ucpia;
struct usb_device *udev;
-
+
usb_set_intfdata(intf, NULL);
if (!cam)
return;
@@ -600,7 +600,7 @@ static void cpia_disconnect(struct usb_interface *intf)
spin_lock( &cam_list_lock_usb );
list_del(&cam->cam_data_list);
spin_unlock( &cam_list_lock_usb );
-
+
ucpia->present = 0;
cpia_unregister_camera(cam);
@@ -631,7 +631,7 @@ static void cpia_disconnect(struct usb_interface *intf)
static int __init usb_cpia_init(void)
{
- printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
+ printk(KERN_INFO "%s v%d.%d.%d\n",ABOUT,
CPIA_USB_MAJ_VER,CPIA_USB_MIN_VER,CPIA_USB_PATCH_VER);
spin_lock_init(&cam_list_lock_usb);
diff --git a/drivers/media/video/cs53l32a.c b/drivers/media/video/cs53l32a.c
index 8739c64785e..de87247c74e 100644
--- a/drivers/media/video/cs53l32a.c
+++ b/drivers/media/video/cs53l32a.c
@@ -59,25 +59,25 @@ static int cs53l32a_read(struct i2c_client *client, u8 reg)
static int cs53l32a_command(struct i2c_client *client, unsigned int cmd,
void *arg)
{
- struct v4l2_audio *input = arg;
+ struct v4l2_routing *route = arg;
struct v4l2_control *ctrl = arg;
switch (cmd) {
- case VIDIOC_S_AUDIO:
+ case VIDIOC_INT_G_AUDIO_ROUTING:
+ route->input = (cs53l32a_read(client, 0x01) >> 4) & 3;
+ route->output = 0;
+ break;
+
+ case VIDIOC_INT_S_AUDIO_ROUTING:
/* There are 2 physical inputs, but the second input can be
placed in two modes, the first mode bypasses the PGA (gain),
the second goes through the PGA. Hence there are three
possible inputs to choose from. */
- if (input->index > 2) {
- v4l_err(client, "Invalid input %d.\n", input->index);
+ if (route->input > 2) {
+ v4l_err(client, "Invalid input %d.\n", route->input);
return -EINVAL;
}
- cs53l32a_write(client, 0x01, 0x01 + (input->index << 4));
- break;
-
- case VIDIOC_G_AUDIO:
- memset(input, 0, sizeof(*input));
- input->index = (cs53l32a_read(client, 0x01) >> 4) & 3;
+ cs53l32a_write(client, 0x01, 0x01 + (route->input << 4));
break;
case VIDIOC_G_CTRL:
diff --git a/drivers/media/video/cs8420.h b/drivers/media/video/cs8420.h
index 2b22f3a38de..621c0c6678e 100644
--- a/drivers/media/video/cs8420.h
+++ b/drivers/media/video/cs8420.h
@@ -20,7 +20,7 @@
#define __CS8420_H__
/* Initialization Sequence */
-
+
static __u8 init8420[] = {
1, 0x01, 2, 0x02, 3, 0x00, 4, 0x46,
5, 0x24, 6, 0x84, 18, 0x18, 19, 0x13,
diff --git a/drivers/media/video/cx25840/cx25840-audio.c b/drivers/media/video/cx25840/cx25840-audio.c
index cb9a7981e40..a4540e858f2 100644
--- a/drivers/media/video/cx25840/cx25840-audio.c
+++ b/drivers/media/video/cx25840/cx25840-audio.c
@@ -18,7 +18,6 @@
#include <linux/videodev2.h>
#include <linux/i2c.h>
-#include <media/audiochip.h>
#include <media/v4l2-common.h>
#include "cx25840.h"
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 8a257978056..a65b3cc4bf0 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -31,7 +31,6 @@
#include <linux/slab.h>
#include <linux/videodev2.h>
#include <linux/i2c.h>
-#include <media/audiochip.h>
#include <media/v4l2-common.h>
#include "cx25840.h"
@@ -176,9 +175,9 @@ static void cx25840_initialize(struct i2c_client *client, int loadfw)
cx25840_write(client, 0x4a5, 0x00);
cx25840_write(client, 0x402, 0x00);
/* 8. */
- cx25840_write(client, 0x401, 0x18);
- cx25840_write(client, 0x4a2, 0x10);
- cx25840_write(client, 0x402, 0x04);
+ cx25840_and_or(client, 0x401, ~0x18, 0);
+ cx25840_and_or(client, 0x4a2, ~0x10, 0x10);
+ /* steps 8c and 8d are done in change_input() */
/* 10. */
cx25840_write(client, 0x8d3, 0x1f);
cx25840_write(client, 0x8e3, 0x03);
@@ -209,6 +208,17 @@ static void input_change(struct i2c_client *client)
struct cx25840_state *state = i2c_get_clientdata(client);
v4l2_std_id std = cx25840_get_v4lstd(client);
+ /* Follow step 8c and 8d of section 3.16 in the cx25840 datasheet */
+ if (std & V4L2_STD_SECAM) {
+ cx25840_write(client, 0x402, 0);
+ }
+ else {
+ cx25840_write(client, 0x402, 0x04);
+ cx25840_write(client, 0x49f, (std & V4L2_STD_NTSC) ? 0x14 : 0x11);
+ }
+ cx25840_and_or(client, 0x401, ~0x60, 0);
+ cx25840_and_or(client, 0x401, ~0x60, 0x60);
+
/* Note: perhaps V4L2_STD_PAL_M should be handled as V4L2_STD_NTSC
instead of V4L2_STD_PAL. Someone needs to test this. */
if (std & V4L2_STD_PAL) {
@@ -343,6 +353,15 @@ static int set_v4lstd(struct i2c_client *client, v4l2_std_id std)
}
}
+ /* Follow step 9 of section 3.16 in the cx25840 datasheet.
+ Without this PAL may display a vertical ghosting effect.
+ This happens for example with the Yuan MPC622. */
+ if (fmt >= 4 && fmt < 8) {
+ /* Set format to NTSC-M */
+ cx25840_and_or(client, 0x400, ~0xf, 1);
+ /* Turn off LCOMB */
+ cx25840_and_or(client, 0x47b, ~6, 0);
+ }
cx25840_and_or(client, 0x400, ~0xf, fmt);
cx25840_vbi_setup(client);
return 0;
@@ -359,7 +378,14 @@ v4l2_std_id cx25840_get_v4lstd(struct i2c_client * client)
}
switch (fmt) {
- case 0x1: return V4L2_STD_NTSC_M | V4L2_STD_NTSC_M_KR;
+ case 0x1:
+ {
+ /* if the audio std is A2-M, then this is the South Korean
+ NTSC standard */
+ if (cx25840_read(client, 0x805) == 2)
+ return V4L2_STD_NTSC_M_KR;
+ return V4L2_STD_NTSC_M;
+ }
case 0x2: return V4L2_STD_NTSC_M_JP;
case 0x3: return V4L2_STD_NTSC_443;
case 0x4: return V4L2_STD_PAL;
@@ -737,16 +763,6 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
return set_input(client, state->vid_input, input->index);
}
- case VIDIOC_G_AUDIO:
- {
- struct v4l2_audio *input = arg;
-
- memset(input, 0, sizeof(*input));
- input->index = state->aud_input;
- input->capability = V4L2_AUDCAP_STEREO;
- break;
- }
-
case VIDIOC_S_FREQUENCY:
input_change(client);
break;
@@ -794,13 +810,14 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
bilingual -> lang1 */
cx25840_and_or(client, 0x809, ~0xf, 0x00);
break;
+ case V4L2_TUNER_MODE_STEREO:
case V4L2_TUNER_MODE_LANG1:
/* mono -> mono
stereo -> stereo
bilingual -> lang1 */
cx25840_and_or(client, 0x809, ~0xf, 0x04);
break;
- case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
/* mono -> mono
stereo -> stereo
bilingual -> lang1/lang2 */
@@ -808,7 +825,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
break;
case V4L2_TUNER_MODE_LANG2:
/* mono -> mono
- stereo ->stereo
+ stereo -> stereo
bilingual -> lang2 */
cx25840_and_or(client, 0x809, ~0xf, 0x01);
break;
diff --git a/drivers/media/video/cx88/Kconfig b/drivers/media/video/cx88/Kconfig
index e140996e6ee..ff0f72340d6 100644
--- a/drivers/media/video/cx88/Kconfig
+++ b/drivers/media/video/cx88/Kconfig
@@ -16,12 +16,13 @@ config VIDEO_CX88
module will be called cx8800
config VIDEO_CX88_ALSA
- tristate "ALSA DMA audio support"
+ tristate "Conexant 2388x DMA audio support"
depends on VIDEO_CX88 && SND && EXPERIMENTAL
select SND_PCM
---help---
This is a video4linux driver for direct (DMA) audio on
- Conexant 2388x based TV cards.
+ Conexant 2388x based TV cards using ALSA.
+
It only works with boards with function 01 enabled.
To check if your board supports, use lspci -n.
If supported, you should see 1471:8801 or 1471:8811
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c
index 3170b8f72c6..f9d87b86492 100644
--- a/drivers/media/video/cx88/cx88-alsa.c
+++ b/drivers/media/video/cx88/cx88-alsa.c
@@ -303,7 +303,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip)
BUG_ON(!chip->dma_size);
dprintk(2,"Freeing buffer\n");
- videobuf_dma_pci_unmap(chip->pci, &chip->dma_risc);
+ videobuf_pci_dma_unmap(chip->pci, &chip->dma_risc);
videobuf_dma_free(&chip->dma_risc);
btcx_riscmem_free(chip->pci,&chip->buf->risc);
kfree(chip->buf);
@@ -429,7 +429,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream,
videobuf_dma_init_kernel(&buf->vb.dma,PCI_DMA_FROMDEVICE,
(PAGE_ALIGN(buf->vb.size) >> PAGE_SHIFT));
- videobuf_dma_pci_map(chip->pci,&buf->vb.dma);
+ videobuf_pci_dma_map(chip->pci,&buf->vb.dma);
cx88_risc_databuffer(chip->pci, &buf->risc,
diff --git a/drivers/media/video/cx88/cx88-blackbird.c b/drivers/media/video/cx88/cx88-blackbird.c
index a502a4d6e4a..e100d8ef369 100644
--- a/drivers/media/video/cx88/cx88-blackbird.c
+++ b/drivers/media/video/cx88/cx88-blackbird.c
@@ -1341,7 +1341,7 @@ bb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
enum v4l2_field field)
{
struct cx8802_fh *fh = q->priv_data;
- return cx8802_buf_prepare(fh->dev, (struct cx88_buffer*)vb, field);
+ return cx8802_buf_prepare(q, fh->dev, (struct cx88_buffer*)vb, field);
}
static void
@@ -1354,8 +1354,7 @@ bb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void
bb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct cx8802_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci, (struct cx88_buffer*)vb);
+ cx88_free_buffer(q, (struct cx88_buffer*)vb);
}
static struct videobuf_queue_ops blackbird_qops = {
diff --git a/drivers/media/video/cx88/cx88-core.c b/drivers/media/video/cx88/cx88-core.c
index c2cdbafdb77..2c3d9f1999b 100644
--- a/drivers/media/video/cx88/cx88-core.c
+++ b/drivers/media/video/cx88/cx88-core.c
@@ -213,13 +213,13 @@ int cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
}
void
-cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf)
+cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf)
{
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
- btcx_riscmem_free(pci, &buf->risc);
+ btcx_riscmem_free((struct pci_dev *)q->dev, &buf->risc);
buf->vb.state = STATE_NEEDS_INIT;
}
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index a9fc2695b15..f0ea9b5cdbc 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -90,7 +90,7 @@ static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
enum v4l2_field field)
{
struct cx8802_dev *dev = q->priv_data;
- return cx8802_buf_prepare(dev, (struct cx88_buffer*)vb,field);
+ return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
}
static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
@@ -101,8 +101,7 @@ static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct cx8802_dev *dev = q->priv_data;
- cx88_free_buffer(dev->pci, (struct cx88_buffer*)vb);
+ cx88_free_buffer(q, (struct cx88_buffer*)vb);
}
static struct videobuf_queue_ops dvb_qops = {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index c79cc1d2bf8..7d16888b4a8 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -163,8 +163,8 @@ static int cx8802_restart_queue(struct cx8802_dev *dev,
/* ------------------------------------------------------------------ */
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
- enum v4l2_field field)
+int cx8802_buf_prepare(struct videobuf_queue *q, struct cx8802_dev *dev,
+ struct cx88_buffer *buf, enum v4l2_field field)
{
int size = dev->ts_packet_size * dev->ts_packet_count;
int rc;
@@ -179,7 +179,7 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
buf->vb.size = size;
buf->vb.field = field /*V4L2_FIELD_TOP*/;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
cx88_risc_databuffer(dev->pci, &buf->risc,
buf->vb.dma.sglist,
@@ -189,36 +189,36 @@ int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf)
{
struct cx88_buffer *prev;
- struct cx88_dmaqueue *q = &dev->mpegq;
+ struct cx88_dmaqueue *cx88q = &dev->mpegq;
dprintk( 1, "cx8802_buf_queue\n" );
/* add jump to stopper */
buf->risc.jmp[0] = cpu_to_le32(RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
- buf->risc.jmp[1] = cpu_to_le32(q->stopper.dma);
+ buf->risc.jmp[1] = cpu_to_le32(cx88q->stopper.dma);
- if (list_empty(&q->active)) {
+ if (list_empty(&cx88q->active)) {
dprintk( 0, "queue is empty - first active\n" );
- list_add_tail(&buf->vb.queue,&q->active);
- cx8802_start_dma(dev, q, buf);
+ list_add_tail(&buf->vb.queue,&cx88q->active);
+ cx8802_start_dma(dev, cx88q, buf);
buf->vb.state = STATE_ACTIVE;
- buf->count = q->count++;
- mod_timer(&q->timeout, jiffies+BUFFER_TIMEOUT);
+ buf->count = cx88q->count++;
+ mod_timer(&cx88q->timeout, jiffies+BUFFER_TIMEOUT);
dprintk(0,"[%p/%d] %s - first active\n",
buf, buf->vb.i, __FUNCTION__);
} else {
dprintk( 1, "queue is not empty - append to active\n" );
- prev = list_entry(q->active.prev, struct cx88_buffer, vb.queue);
- list_add_tail(&buf->vb.queue,&q->active);
+ prev = list_entry(cx88q->active.prev, struct cx88_buffer, vb.queue);
+ list_add_tail(&buf->vb.queue,&cx88q->active);
buf->vb.state = STATE_ACTIVE;
- buf->count = q->count++;
+ buf->count = cx88q->count++;
prev->risc.jmp[1] = cpu_to_le32(buf->risc.dma);
dprintk( 1, "[%p/%d] %s - append to active\n",
buf, buf->vb.i, __FUNCTION__);
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index da8d97ce0c4..641a0c5a649 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -885,6 +885,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
set_audio_standard_BTSC(core, 1, EN_BTSC_FORCE_SAP);
break;
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
set_audio_standard_BTSC(core, 0, EN_BTSC_FORCE_STEREO);
break;
}
@@ -905,6 +906,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
EN_NICAM_FORCE_MONO2);
break;
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
set_audio_standard_NICAM(core,
EN_NICAM_FORCE_STEREO);
break;
@@ -926,6 +928,7 @@ void cx88_set_stereo(struct cx88_core *core, u32 mode, int manual)
EN_A2_FORCE_MONO2);
break;
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
set_audio_standard_A2(core,
EN_A2_FORCE_STEREO);
break;
diff --git a/drivers/media/video/cx88/cx88-vbi.c b/drivers/media/video/cx88/cx88-vbi.c
index 9bc6c899558..846faadc9f1 100644
--- a/drivers/media/video/cx88/cx88-vbi.c
+++ b/drivers/media/video/cx88/cx88-vbi.c
@@ -175,7 +175,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->vb.field = V4L2_FIELD_SEQ_TB;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
cx88_risc_buffer(dev->pci, &buf->risc,
buf->vb.dma.sglist,
@@ -187,7 +187,7 @@ vbi_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
@@ -227,9 +227,8 @@ vbi_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void vbi_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
- struct cx8800_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci,buf);
+ cx88_free_buffer(q,buf);
}
struct videobuf_queue_ops cx8800_vbi_qops = {
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index 6c97aa740d2..72a417b3174 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -564,7 +564,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
if (STATE_NEEDS_INIT == buf->vb.state) {
init_buffer = 1;
- if (0 != (rc = videobuf_iolock(dev->pci,&buf->vb,NULL)))
+ if (0 != (rc = videobuf_iolock(q,&buf->vb,NULL)))
goto fail;
}
@@ -614,7 +614,7 @@ buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
fail:
- cx88_free_buffer(dev->pci,buf);
+ cx88_free_buffer(q,buf);
return rc;
}
@@ -671,9 +671,8 @@ buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
struct cx88_buffer *buf = container_of(vb,struct cx88_buffer,vb);
- struct cx8800_fh *fh = q->priv_data;
- cx88_free_buffer(fh->dev->pci,buf);
+ cx88_free_buffer(q,buf);
}
static struct videobuf_queue_ops cx8800_video_qops = {
@@ -1251,9 +1250,17 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
{
int err;
- dprintk(2, "CORE IOCTL: 0x%x\n", cmd );
- if (video_debug > 1)
- v4l_print_ioctl(core->name,cmd);
+ if (video_debug) {
+ if (video_debug > 1) {
+ if (_IOC_DIR(cmd) & _IOC_WRITE)
+ v4l_printk_ioctl_arg("cx88(w)",cmd, arg);
+ else if (!_IOC_DIR(cmd) & _IOC_READ) {
+ v4l_print_ioctl("cx88", cmd);
+ }
+ } else
+ v4l_print_ioctl(core->name,cmd);
+
+ }
switch (cmd) {
/* ---------- tv norms ---------- */
@@ -1460,7 +1467,19 @@ int cx88_do_ioctl(struct inode *inode, struct file *file, int radio,
static int video_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
- return video_usercopy(inode, file, cmd, arg, video_do_ioctl);
+ int retval;
+
+ retval=video_usercopy(inode, file, cmd, arg, video_do_ioctl);
+
+ if (video_debug > 1) {
+ if (retval < 0) {
+ v4l_print_ioctl("cx88(err)", cmd);
+ printk(KERN_DEBUG "cx88(err): errcode=%d\n",retval);
+ } else if (_IOC_DIR(cmd) & _IOC_READ)
+ v4l_printk_ioctl_arg("cx88(r)",cmd, (void *)arg);
+ }
+
+ return retval;
}
/* ----------------------------------------------------------- */
diff --git a/drivers/media/video/cx88/cx88.h b/drivers/media/video/cx88/cx88.h
index cfa8668784b..326a25f147f 100644
--- a/drivers/media/video/cx88/cx88.h
+++ b/drivers/media/video/cx88/cx88.h
@@ -27,7 +27,6 @@
#include <media/tuner.h>
#include <media/tveeprom.h>
-#include <media/audiochip.h>
#include <media/video-buf.h>
#include <media/video-buf-dvb.h>
@@ -485,7 +484,7 @@ extern int
cx88_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
u32 reg, u32 mask, u32 value);
extern void
-cx88_free_buffer(struct pci_dev *pci, struct cx88_buffer *buf);
+cx88_free_buffer(struct videobuf_queue *q, struct cx88_buffer *buf);
extern void cx88_risc_disasm(struct cx88_core *core,
struct btcx_riscmem *risc);
@@ -577,8 +576,8 @@ void cx88_ir_irq(struct cx88_core *core);
/* ----------------------------------------------------------- */
/* cx88-mpeg.c */
-int cx8802_buf_prepare(struct cx8802_dev *dev, struct cx88_buffer *buf,
- enum v4l2_field field);
+int cx8802_buf_prepare(struct videobuf_queue *q,struct cx8802_dev *dev,
+ struct cx88_buffer *buf, enum v4l2_field field);
void cx8802_buf_queue(struct cx8802_dev *dev, struct cx88_buffer *buf);
void cx8802_cancel_buffers(struct cx8802_dev *dev);
diff --git a/drivers/usb/media/dabfirmware.h b/drivers/media/video/dabfirmware.h
index d14d803566a..d14d803566a 100644
--- a/drivers/usb/media/dabfirmware.h
+++ b/drivers/media/video/dabfirmware.h
diff --git a/drivers/usb/media/dabusb.c b/drivers/media/video/dabusb.c
index 1774ab7a40d..b9ba95f5e02 100644
--- a/drivers/usb/media/dabusb.c
+++ b/drivers/media/video/dabusb.c
@@ -86,7 +86,7 @@ static int dabusb_add_buf_tail (pdabusb_t s, struct list_head *dst, struct list_
return ret;
}
/*-------------------------------------------------------------------*/
-#ifdef DEBUG
+#ifdef DEBUG
static void dump_urb (struct urb *urb)
{
dbg("urb :%p", urb);
@@ -136,7 +136,7 @@ static int dabusb_free_queue (struct list_head *q)
for (p = q->next; p != q;) {
b = list_entry (p, buff_t, buff_list);
-#ifdef DEBUG
+#ifdef DEBUG
dump_urb(b->purb);
#endif
kfree(b->purb->transfer_buffer);
@@ -287,7 +287,7 @@ static int dabusb_bulk (pdabusb_t s, pbulk_transfer_t pb)
}
}
-
+
if( ret == -EPIPE ) {
warn("CLEAR_FEATURE request to remove STALL condition.");
if(usb_clear_halt(s->usbdev, usb_pipeendpoint(pipe)))
@@ -328,7 +328,7 @@ static int dabusb_loadmem (pdabusb_t s, const char *fname)
PINTEL_HEX_RECORD ptr = firmware;
dbg("Enter dabusb_loadmem (internal)");
-
+
ret = dabusb_8051_reset (s, 1);
while (ptr->Type == 0) {
@@ -449,7 +449,7 @@ static int dabusb_startrek (pdabusb_t s)
if (!list_empty (&s->free_buff_list)) {
pbuff_t end;
int ret;
-
+
while (!dabusb_add_buf_tail (s, &s->rec_buff_list, &s->free_buff_list)) {
dbg("submitting: end:%p s->rec_buff_list:%p", s->rec_buff_list.prev, &s->rec_buff_list);
@@ -506,7 +506,7 @@ static ssize_t dabusb_read (struct file *file, char __user *buf, size_t count, l
err("error: rec_buf_list is empty");
goto err;
}
-
+
b = list_entry (s->rec_buff_list.next, buff_t, buff_list);
purb = b->purb;
@@ -783,9 +783,9 @@ static void dabusb_disconnect (struct usb_interface *intf)
pdabusb_t s = usb_get_intfdata (intf);
dbg("dabusb_disconnect");
-
+
init_waitqueue_entry(&__wait, current);
-
+
usb_set_intfdata (intf, NULL);
if (s) {
usb_deregister_dev (intf, &dabusb_class);
@@ -797,7 +797,7 @@ static void dabusb_disconnect (struct usb_interface *intf)
schedule();
current->state = TASK_RUNNING;
remove_wait_queue(&s->remove_ok, &__wait);
-
+
s->usbdev = NULL;
s->overruns = 0;
}
diff --git a/drivers/usb/media/dabusb.h b/drivers/media/video/dabusb.h
index 96b03e4af8b..00eb34c863e 100644
--- a/drivers/usb/media/dabusb.h
+++ b/drivers/media/video/dabusb.h
@@ -10,7 +10,7 @@ typedef struct
#define DABUSB_VERSION 0x1000
#define IOCTL_DAB_BULK _IOWR('d', 0x30, bulk_transfer_t)
#define IOCTL_DAB_OVERRUNS _IOR('d', 0x15, int)
-#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int)
+#define IOCTL_DAB_VERSION _IOR('d', 0x3f, int)
#ifdef __KERNEL__
@@ -36,7 +36,7 @@ typedef struct
struct list_head rec_buff_list;
} dabusb_t,*pdabusb_t;
-typedef struct
+typedef struct
{
pdabusb_t s;
struct urb *purb;
diff --git a/drivers/usb/media/dsbr100.c b/drivers/media/video/dsbr100.c
index 25646804d5b..3b4e9985c3d 100644
--- a/drivers/usb/media/dsbr100.c
+++ b/drivers/media/video/dsbr100.c
@@ -37,28 +37,28 @@
Markus: Updates for 2.6.x kernels, code layout changes, name sanitizing
Version 0.30:
- Markus: Updates for 2.5.x kernel and more ISO compliant source
+ Markus: Updates for 2.5.x kernel and more ISO compliant source
Version 0.25:
- PSL and Markus: Cleanup, radio now doesn't stop on device close
+ PSL and Markus: Cleanup, radio now doesn't stop on device close
Version 0.24:
- Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally
+ Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally
right. Some minor cleanup, improved standalone compilation
Version 0.23:
- Markus: Sign extension bug fixed by declaring transfer_buffer unsigned
+ Markus: Sign extension bug fixed by declaring transfer_buffer unsigned
Version 0.22:
- Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns,
+ Markus: Some (brown bag) cleanup in what VIDIOCSTUNER returns,
thanks to Mike Cox for pointing the problem out.
Version 0.21:
- Markus: Minor cleanup, warnings if something goes wrong, lame attempt
+ Markus: Minor cleanup, warnings if something goes wrong, lame attempt
to adhere to Documentation/CodingStyle
- Version 0.2:
- Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module
+ Version 0.2:
+ Brad Hards <bradh@dynamite.com.au>: Fixes to make it work as non-module
Markus: Copyright clarification
Version 0.01: Markus: initial release
@@ -163,11 +163,11 @@ static struct usb_driver usb_dsbr100_driver = {
static int dsbr100_start(dsbr100_device *radio)
{
if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- USB_REQ_GET_STATUS,
+ USB_REQ_GET_STATUS,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x00, 0xC7, radio->transfer_buffer, 8, 300)<0 ||
usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- DSB100_ONOFF,
+ DSB100_ONOFF,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x01, 0x00, radio->transfer_buffer, 8, 300)<0)
return -1;
@@ -179,11 +179,11 @@ static int dsbr100_start(dsbr100_device *radio)
static int dsbr100_stop(dsbr100_device *radio)
{
if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- USB_REQ_GET_STATUS,
+ USB_REQ_GET_STATUS,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x16, 0x1C, radio->transfer_buffer, 8, 300)<0 ||
usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- DSB100_ONOFF,
+ DSB100_ONOFF,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x00, 0x00, radio->transfer_buffer, 8, 300)<0)
return -1;
@@ -195,16 +195,16 @@ static int dsbr100_setfreq(dsbr100_device *radio, int freq)
{
freq = (freq/16*80)/1000+856;
if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- DSB100_TUNE,
+ DSB100_TUNE,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
- (freq>>8)&0x00ff, freq&0xff,
+ (freq>>8)&0x00ff, freq&0xff,
radio->transfer_buffer, 8, 300)<0 ||
usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- USB_REQ_GET_STATUS,
+ USB_REQ_GET_STATUS,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x96, 0xB7, radio->transfer_buffer, 8, 300)<0 ||
usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- USB_REQ_GET_STATUS,
+ USB_REQ_GET_STATUS,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x00, 0x24, radio->transfer_buffer, 8, 300)<0) {
radio->stereo = -1;
@@ -219,7 +219,7 @@ sees a stereo signal or not. Pity. */
static void dsbr100_getstat(dsbr100_device *radio)
{
if (usb_control_msg(radio->usbdev, usb_rcvctrlpipe(radio->usbdev, 0),
- USB_REQ_GET_STATUS,
+ USB_REQ_GET_STATUS,
USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,
0x00 , 0x24, radio->transfer_buffer, 8, 300)<0)
radio->stereo = -1;
@@ -232,7 +232,7 @@ static void dsbr100_getstat(dsbr100_device *radio)
/* check if the device is present and register with v4l and
usb if it is */
-static int usb_dsbr100_probe(struct usb_interface *intf,
+static int usb_dsbr100_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
dsbr100_device *radio;
@@ -243,7 +243,7 @@ static int usb_dsbr100_probe(struct usb_interface *intf,
kfree(radio);
return -ENOMEM;
}
- memcpy(radio->videodev, &dsbr100_videodev_template,
+ memcpy(radio->videodev, &dsbr100_videodev_template,
sizeof(dsbr100_videodev_template));
radio->removed = 0;
radio->users = 0;
@@ -310,7 +310,7 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
struct video_tuner *v = arg;
dsbr100_getstat(radio);
- if(v->tuner) /* Only 1 tuner */
+ if(v->tuner) /* Only 1 tuner */
return -EINVAL;
v->rangelow = FREQ_MIN*FREQ_MUL;
v->rangehigh = FREQ_MAX*FREQ_MUL;
@@ -355,12 +355,12 @@ static int usb_dsbr100_do_ioctl(struct inode *inode, struct file *file,
v->volume = 1;
v->step = 1;
strcpy(v->name, "Radio");
- return 0;
+ return 0;
}
case VIDIOCSAUDIO: {
struct video_audio *v = arg;
- if (v->audio)
+ if (v->audio)
return -EINVAL;
if (v->flags&VIDEO_AUDIO_MUTE) {
if (dsbr100_stop(radio)==-1)
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 4e22fc4889e..f62fd706b45 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -28,10 +28,10 @@
#include <linux/i2c.h>
#include <linux/usb.h>
#include <media/tuner.h>
-#include <media/audiochip.h>
+#include <media/msp3400.h>
#include <media/tveeprom.h>
+#include <media/audiochip.h>
#include <media/v4l2-common.h>
-#include "msp3400.h"
#include "em28xx.h"
@@ -147,11 +147,12 @@ struct em28xx_board em28xx_boards[] = {
.input = {{
.type = EM28XX_VMUX_TELEVISION,
.vmux = 0,
- .amux = 6,
+ .amux = MSP_INPUT_DEFAULT,
},{
.type = EM28XX_VMUX_SVIDEO,
.vmux = 2,
- .amux = 1,
+ .amux = MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1,
+ MSP_DSP_OUT_SCART, MSP_DSP_OUT_SCART),
}},
},
[EM2820_BOARD_MSI_VOX_USB_2] = {
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 780342f7b23..dfba33d0fa6 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -38,6 +38,7 @@
#include "em28xx.h"
#include <media/tuner.h>
#include <media/v4l2-common.h>
+#include <media/msp3400.h>
#define DRIVER_AUTHOR "Ludovico Cavedon <cavedon@sssup.it>, " \
"Markus Rechberger <mrechberger@gmail.com>, " \
@@ -216,9 +217,14 @@ static void video_mux(struct em28xx *dev, int index)
em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);
if (dev->has_msp34xx) {
+ struct v4l2_routing route;
+
if (dev->i2s_speed)
em28xx_i2c_call_clients(dev, VIDIOC_INT_I2S_CLOCK_FREQ, &dev->i2s_speed);
- em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput);
+ route.input = dev->ctl_ainput;
+ route.output = MSP_OUTPUT(MSP_OUT_SCART1_DA);
+ /* Note: this is msp3400 specific */
+ em28xx_i2c_call_clients(dev, VIDIOC_INT_S_AUDIO_ROUTING, &route);
ainput = EM28XX_AUDIO_SRC_TUNER;
em28xx_audio_source(dev, ainput);
} else {
diff --git a/drivers/media/video/et61x251/Makefile b/drivers/media/video/et61x251/Makefile
new file mode 100644
index 00000000000..2ff4db9ec88
--- /dev/null
+++ b/drivers/media/video/et61x251/Makefile
@@ -0,0 +1,4 @@
+et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
+
+obj-$(CONFIG_USB_ET61X251) += et61x251.o
+
diff --git a/drivers/usb/media/et61x251.h b/drivers/media/video/et61x251/et61x251.h
index eee8afc9be7..2e5ca403248 100644
--- a/drivers/usb/media/et61x251.h
+++ b/drivers/media/video/et61x251/et61x251.h
@@ -180,7 +180,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id)
void
et61x251_attach_sensor(struct et61x251_device* cam,
- struct et61x251_sensor* sensor)
+ struct et61x251_sensor* sensor)
{
memcpy(&cam->sensor, sensor, sizeof(struct et61x251_sensor));
}
@@ -199,7 +199,7 @@ do { \
dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
else if ((level) >= 3) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args); \
+ __FUNCTION__, __LINE__ , ## args); \
} \
} while (0)
# define KDBG(level, fmt, args...) \
@@ -209,7 +209,7 @@ do { \
pr_info("et61x251: " fmt "\n", ## args); \
else if ((level) == 3) \
pr_debug("et61x251: [%s:%d] " fmt "\n", __FUNCTION__, \
- __LINE__ , ## args); \
+ __LINE__ , ## args); \
} \
} while (0)
# define V4LDBG(level, name, cmd) \
@@ -226,7 +226,7 @@ do { \
#undef PDBG
#define PDBG(fmt, args...) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args)
+ __FUNCTION__, __LINE__ , ## args)
#undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/usb/media/et61x251_core.c b/drivers/media/video/et61x251/et61x251_core.c
index 7cc01b828b3..dfc9dd732c9 100644
--- a/drivers/usb/media/et61x251_core.c
+++ b/drivers/media/video/et61x251/et61x251_core.c
@@ -44,7 +44,7 @@
/*****************************************************************************/
#define ET61X251_MODULE_NAME "V4L2 driver for ET61X[12]51 " \
- "PC Camera Controllers"
+ "PC Camera Controllers"
#define ET61X251_MODULE_AUTHOR "(C) 2006 Luca Risolia"
#define ET61X251_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
#define ET61X251_MODULE_LICENSE "GPL"
@@ -63,68 +63,68 @@ MODULE_LICENSE(ET61X251_MODULE_LICENSE);
static short video_nr[] = {[0 ... ET61X251_MAX_DEVICES-1] = -1};
module_param_array(video_nr, short, NULL, 0444);
MODULE_PARM_DESC(video_nr,
- "\n<-1|n[,...]> Specify V4L2 minor mode number."
- "\n -1 = use next available (default)"
- "\n n = use minor number n (integer >= 0)"
- "\nYou can specify up to "
- __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way."
- "\nFor example:"
- "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
- "\nthe second registered camera and use auto for the first"
- "\none and for every other camera."
- "\n");
+ "\n<-1|n[,...]> Specify V4L2 minor mode number."
+ "\n -1 = use next available (default)"
+ "\n n = use minor number n (integer >= 0)"
+ "\nYou can specify up to "
+ __MODULE_STRING(ET61X251_MAX_DEVICES) " cameras this way."
+ "\nFor example:"
+ "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
+ "\nthe second registered camera and use auto for the first"
+ "\none and for every other camera."
+ "\n");
static short force_munmap[] = {[0 ... ET61X251_MAX_DEVICES-1] =
- ET61X251_FORCE_MUNMAP};
+ ET61X251_FORCE_MUNMAP};
module_param_array(force_munmap, bool, NULL, 0444);
MODULE_PARM_DESC(force_munmap,
- "\n<0|1[,...]> Force the application to unmap previously"
- "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
- "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
- "\nthis feature. This parameter is specific for each"
- "\ndetected camera."
- "\n 0 = do not force memory unmapping"
- "\n 1 = force memory unmapping (save memory)"
- "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
- "\n");
+ "\n<0|1[,...]> Force the application to unmap previously"
+ "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
+ "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
+ "\nthis feature. This parameter is specific for each"
+ "\ndetected camera."
+ "\n 0 = do not force memory unmapping"
+ "\n 1 = force memory unmapping (save memory)"
+ "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
+ "\n");
static unsigned int frame_timeout[] = {[0 ... ET61X251_MAX_DEVICES-1] =
- ET61X251_FRAME_TIMEOUT};
+ ET61X251_FRAME_TIMEOUT};
module_param_array(frame_timeout, uint, NULL, 0644);
MODULE_PARM_DESC(frame_timeout,
- "\n<n[,...]> Timeout for a video frame in seconds."
- "\nThis parameter is specific for each detected camera."
- "\nDefault value is "
- __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"."
- "\n");
+ "\n<n[,...]> Timeout for a video frame in seconds."
+ "\nThis parameter is specific for each detected camera."
+ "\nDefault value is "
+ __MODULE_STRING(ET61X251_FRAME_TIMEOUT)"."
+ "\n");
#ifdef ET61X251_DEBUG
static unsigned short debug = ET61X251_DEBUG_LEVEL;
module_param(debug, ushort, 0644);
MODULE_PARM_DESC(debug,
- "\n<n> Debugging information level, from 0 to 3:"
- "\n0 = none (use carefully)"
- "\n1 = critical errors"
- "\n2 = significant informations"
- "\n3 = more verbose messages"
- "\nLevel 3 is useful for testing only, when only "
- "one device is used."
- "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"."
- "\n");
+ "\n<n> Debugging information level, from 0 to 3:"
+ "\n0 = none (use carefully)"
+ "\n1 = critical errors"
+ "\n2 = significant informations"
+ "\n3 = more verbose messages"
+ "\nLevel 3 is useful for testing only, when only "
+ "one device is used."
+ "\nDefault value is "__MODULE_STRING(ET61X251_DEBUG_LEVEL)"."
+ "\n");
#endif
/*****************************************************************************/
static u32
et61x251_request_buffers(struct et61x251_device* cam, u32 count,
- enum et61x251_io_method io)
+ enum et61x251_io_method io)
{
struct v4l2_pix_format* p = &(cam->sensor.pix_format);
struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
const size_t imagesize = cam->module_param.force_munmap ||
- io == IO_READ ?
- (p->width * p->height * p->priv) / 8 :
- (r->width * r->height * p->priv) / 8;
+ io == IO_READ ?
+ (p->width * p->height * p->priv) / 8 :
+ (r->width * r->height * p->priv) / 8;
void* buff = NULL;
u32 i;
@@ -216,7 +216,7 @@ int et61x251_write_reg(struct et61x251_device* cam, u8 value, u16 index)
*buff = value;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
+ 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
if (res < 0) {
DBG(3, "Failed to write a register (value 0x%02X, index "
"0x%02X, error %d)", value, index, res);
@@ -234,7 +234,7 @@ int et61x251_read_reg(struct et61x251_device* cam, u16 index)
int res;
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
- 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
+ 0, index, buff, 1, ET61X251_CTRL_TIMEOUT);
if (res < 0)
DBG(3, "Failed to read a register (index 0x%02X, error %d)",
index, res);
@@ -269,7 +269,7 @@ et61x251_i2c_wait(struct et61x251_device* cam, struct et61x251_sensor* sensor)
int
et61x251_i2c_try_read(struct et61x251_device* cam,
- struct et61x251_sensor* sensor, u8 address)
+ struct et61x251_sensor* sensor, u8 address)
{
struct usb_device* udev = cam->usbdev;
u8* data = cam->control_buffer;
@@ -280,14 +280,14 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
data[2] = cam->sensor.rsta | 0x10;
data[3] = !(et61x251_read_reg(cam, 0x8b) & 0x02);
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT);
+ 0, 0x88, data, 4, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
err += et61x251_i2c_wait(cam, sensor);
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
- 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT);
+ 0, 0x80, data, 8, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -302,7 +302,7 @@ et61x251_i2c_try_read(struct et61x251_device* cam,
int
et61x251_i2c_try_write(struct et61x251_device* cam,
- struct et61x251_sensor* sensor, u8 address, u8 value)
+ struct et61x251_sensor* sensor, u8 address, u8 value)
{
struct usb_device* udev = cam->usbdev;
u8* data = cam->control_buffer;
@@ -312,13 +312,13 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
data[1] = cam->sensor.i2c_slave_id;
data[2] = cam->sensor.rsta | 0x12;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
+ 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
data[0] = value;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
+ 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -335,8 +335,8 @@ et61x251_i2c_try_write(struct et61x251_device* cam,
int
et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
- u8 data3, u8 data4, u8 data5, u8 data6, u8 data7,
- u8 data8, u8 address)
+ u8 data3, u8 data4, u8 data5, u8 data6, u8 data7,
+ u8 data8, u8 address)
{
struct usb_device* udev = cam->usbdev;
u8* data = cam->control_buffer;
@@ -350,7 +350,7 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
data[5] = data7;
data[6] = data8;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT);
+ 0, 0x81, data, n-1, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -358,14 +358,14 @@ et61x251_i2c_raw_write(struct et61x251_device* cam, u8 n, u8 data1, u8 data2,
data[1] = cam->sensor.i2c_slave_id;
data[2] = cam->sensor.rsta | 0x02 | (n << 4);
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
+ 0, 0x88, data, 3, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
/* Start writing through the serial interface */
data[0] = data1;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x00, 0x41,
- 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
+ 0, 0x80, data, 1, ET61X251_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -432,11 +432,11 @@ static void et61x251_urb_complete(struct urb *urb, struct pt_regs* regs)
if (!(*f))
(*f) = list_entry(cam->inqueue.next, struct et61x251_frame_t,
- frame);
+ frame);
imagesize = (cam->sensor.pix_format.width *
- cam->sensor.pix_format.height *
- cam->sensor.pix_format.priv) / 8;
+ cam->sensor.pix_format.height *
+ cam->sensor.pix_format.priv) / 8;
for (i = 0; i < urb->number_of_packets; i++) {
unsigned int len, status;
@@ -476,7 +476,7 @@ start_of_frame:
if ((*f)->state == F_GRABBING) {
if (sof && (*f)->buf.bytesused) {
if (cam->sensor.pix_format.pixelformat ==
- V4L2_PIX_FMT_ET61X251)
+ V4L2_PIX_FMT_ET61X251)
goto end_of_frame;
else {
DBG(3, "Not expected SOF detected "
@@ -508,8 +508,8 @@ end_of_frame:
list_move_tail(&(*f)->frame, &cam->outqueue);
if (!list_empty(&cam->inqueue))
(*f) = list_entry(cam->inqueue.next,
- struct et61x251_frame_t,
- frame);
+ struct et61x251_frame_t,
+ frame);
else
(*f) = NULL;
spin_unlock(&cam->queue_lock);
@@ -521,7 +521,7 @@ end_of_frame:
if (sof &&
cam->sensor.pix_format.pixelformat ==
- V4L2_PIX_FMT_ET61X251)
+ V4L2_PIX_FMT_ET61X251)
goto start_of_frame;
}
}
@@ -544,15 +544,15 @@ static int et61x251_start_transfer(struct et61x251_device* cam)
struct usb_device *udev = cam->usbdev;
struct urb* urb;
const unsigned int wMaxPacketSize[] = {0, 256, 384, 512, 640, 768, 832,
- 864, 896, 920, 956, 980, 1000,
- 1022};
+ 864, 896, 920, 956, 980, 1000,
+ 1022};
const unsigned int psz = wMaxPacketSize[ET61X251_ALTERNATE_SETTING];
s8 i, j;
int err = 0;
for (i = 0; i < ET61X251_URBS; i++) {
cam->transfer_buffer[i] = kzalloc(ET61X251_ISO_PACKETS * psz,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!cam->transfer_buffer[i]) {
err = -ENOMEM;
DBG(1, "Not enough memory");
@@ -653,9 +653,9 @@ static int et61x251_stream_interrupt(struct et61x251_device* cam)
cam->stream = STREAM_INTERRUPT;
timeout = wait_event_timeout(cam->wait_stream,
- (cam->stream == STREAM_OFF) ||
- (cam->state & DEV_DISCONNECTED),
- ET61X251_URB_TIMEOUT);
+ (cam->stream == STREAM_OFF) ||
+ (cam->state & DEV_DISCONNECTED),
+ ET61X251_URB_TIMEOUT);
if (cam->state & DEV_DISCONNECTED)
return -ENODEV;
else if (cam->stream != STREAM_OFF) {
@@ -699,7 +699,7 @@ static u8 et61x251_strtou8(const char* buff, size_t len, ssize_t* count)
/*
NOTE 1: being inside one of the following methods implies that the v4l
- device exists for sure (see kobjects and reference counters)
+ device exists for sure (see kobjects and reference counters)
NOTE 2: buffers are PAGE_SIZE long
*/
@@ -964,13 +964,13 @@ et61x251_store_i2c_val(struct class_device* cd, const char* buf, size_t len)
static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
- et61x251_show_reg, et61x251_store_reg);
+ et61x251_show_reg, et61x251_store_reg);
static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
- et61x251_show_val, et61x251_store_val);
+ et61x251_show_val, et61x251_store_val);
static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
- et61x251_show_i2c_reg, et61x251_store_i2c_reg);
+ et61x251_show_i2c_reg, et61x251_store_i2c_reg);
static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
- et61x251_show_i2c_val, et61x251_store_i2c_val);
+ et61x251_show_i2c_val, et61x251_store_i2c_val);
static void et61x251_create_sysfs(struct et61x251_device* cam)
@@ -990,7 +990,7 @@ static void et61x251_create_sysfs(struct et61x251_device* cam)
static int
et61x251_set_pix_format(struct et61x251_device* cam,
- struct v4l2_pix_format* pix)
+ struct v4l2_pix_format* pix)
{
int r, err = 0;
@@ -1007,7 +1007,7 @@ et61x251_set_pix_format(struct et61x251_device* cam,
static int
et61x251_set_compression(struct et61x251_device* cam,
- struct v4l2_jpegcompression* compression)
+ struct v4l2_jpegcompression* compression)
{
int r, err = 0;
@@ -1049,9 +1049,9 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
{
struct et61x251_sensor* s = &cam->sensor;
u16 fmw_sx = (u16)(rect->left - s->cropcap.bounds.left +
- s->active_pixel.left),
+ s->active_pixel.left),
fmw_sy = (u16)(rect->top - s->cropcap.bounds.top +
- s->active_pixel.top),
+ s->active_pixel.top),
fmw_length = (u16)(rect->width),
fmw_height = (u16)(rect->height);
int err = 0;
@@ -1061,8 +1061,8 @@ et61x251_set_crop(struct et61x251_device* cam, struct v4l2_rect* rect)
err += et61x251_write_reg(cam, fmw_length & 0xff, 0x6b);
err += et61x251_write_reg(cam, fmw_height & 0xff, 0x6c);
err += et61x251_write_reg(cam, (fmw_sx >> 8) | ((fmw_sy & 0x300) >> 6)
- | ((fmw_length & 0x300) >> 4)
- | ((fmw_height & 0x300) >> 2), 0x6d);
+ | ((fmw_length & 0x300) >> 4)
+ | ((fmw_height & 0x300) >> 2), 0x6d);
if (err)
return -EIO;
@@ -1203,8 +1203,8 @@ static int et61x251_open(struct inode* inode, struct file* filp)
}
mutex_unlock(&cam->dev_mutex);
err = wait_event_interruptible_exclusive(cam->open,
- cam->state & DEV_DISCONNECTED
- || !cam->users);
+ cam->state & DEV_DISCONNECTED
+ || !cam->users);
if (err) {
up_read(&et61x251_disconnect);
return err;
@@ -1277,7 +1277,7 @@ static int et61x251_release(struct inode* inode, struct file* filp)
static ssize_t
et61x251_read(struct file* filp, char __user * buf,
- size_t count, loff_t* f_pos)
+ size_t count, loff_t* f_pos)
{
struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
struct et61x251_frame_t* f, * i;
@@ -1310,7 +1310,7 @@ et61x251_read(struct file* filp, char __user * buf,
if (cam->io == IO_NONE) {
if (!et61x251_request_buffers(cam, cam->nreadbuffers,
- IO_READ)) {
+ IO_READ)) {
DBG(1, "read() failed, not enough memory");
mutex_unlock(&cam->fileop_mutex);
return -ENOMEM;
@@ -1336,12 +1336,12 @@ et61x251_read(struct file* filp, char __user * buf,
return -EAGAIN;
}
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
@@ -1408,7 +1408,7 @@ static unsigned int et61x251_poll(struct file *filp, poll_table *wait)
if (cam->io == IO_NONE) {
if (!et61x251_request_buffers(cam, cam->nreadbuffers,
- IO_READ)) {
+ IO_READ)) {
DBG(1, "poll() failed, not enough memory");
goto error;
}
@@ -1465,7 +1465,7 @@ static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma)
{
struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
unsigned long size = vma->vm_end - vma->vm_start,
- start = vma->vm_start;
+ start = vma->vm_start;
void *pos;
u32 i;
@@ -1533,13 +1533,13 @@ et61x251_vidioc_querycap(struct et61x251_device* cam, void __user * arg)
.driver = "et61x251",
.version = ET61X251_MODULE_VERSION_CODE,
.capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
- V4L2_CAP_STREAMING,
+ V4L2_CAP_STREAMING,
};
strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
- sizeof(cap.bus_info));
+ sizeof(cap.bus_info));
if (copy_to_user(arg, &cap, sizeof(cap)))
return -EFAULT;
@@ -1871,7 +1871,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
return -EINVAL;
pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_ET61X251)
- ? 0 : (pfmt->width * pfmt->priv) / 8;
+ ? 0 : (pfmt->width * pfmt->priv) / 8;
pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
pfmt->field = V4L2_FIELD_NONE;
memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -1885,7 +1885,7 @@ et61x251_vidioc_g_fmt(struct et61x251_device* cam, void __user * arg)
static int
et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
- void __user * arg)
+ void __user * arg)
{
struct et61x251_sensor* s = &cam->sensor;
struct v4l2_format format;
@@ -1947,7 +1947,7 @@ et61x251_vidioc_try_s_fmt(struct et61x251_device* cam, unsigned int cmd,
pix->priv = pfmt->priv; /* bpp */
pix->colorspace = pfmt->colorspace;
pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_ET61X251)
- ? 0 : (pix->width * pix->priv) / 8;
+ ? 0 : (pix->width * pix->priv) / 8;
pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
pix->field = V4L2_FIELD_NONE;
@@ -2020,7 +2020,7 @@ static int
et61x251_vidioc_g_jpegcomp(struct et61x251_device* cam, void __user * arg)
{
if (copy_to_user(arg, &cam->compression,
- sizeof(cam->compression)))
+ sizeof(cam->compression)))
return -EFAULT;
return 0;
@@ -2169,7 +2169,7 @@ et61x251_vidioc_qbuf(struct et61x251_device* cam, void __user * arg)
static int
et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
- void __user * arg)
+ void __user * arg)
{
struct v4l2_buffer b;
struct et61x251_frame_t *f;
@@ -2188,12 +2188,12 @@ et61x251_vidioc_dqbuf(struct et61x251_device* cam, struct file* filp,
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0)
return timeout;
if (cam->state & DEV_DISCONNECTED)
@@ -2317,7 +2317,7 @@ et61x251_vidioc_s_parm(struct et61x251_device* cam, void __user * arg)
static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
- unsigned int cmd, void __user * arg)
+ unsigned int cmd, void __user * arg)
{
struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
@@ -2411,7 +2411,7 @@ static int et61x251_ioctl_v4l2(struct inode* inode, struct file* filp,
static int et61x251_ioctl(struct inode* inode, struct file* filp,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct et61x251_device* cam = video_get_drvdata(video_devdata(filp));
int err = 0;
@@ -2518,7 +2518,7 @@ et61x251_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
mutex_lock(&cam->dev_mutex);
err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
- video_nr[dev_nr]);
+ video_nr[dev_nr]);
if (err) {
DBG(1, "V4L2 device registration failed");
if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/usb/media/et61x251_sensor.h b/drivers/media/video/et61x251/et61x251_sensor.h
index 56841ae8a20..65edd08dc38 100644
--- a/drivers/usb/media/et61x251_sensor.h
+++ b/drivers/media/video/et61x251/et61x251_sensor.h
@@ -47,7 +47,7 @@ et61x251_match_id(struct et61x251_device* cam, const struct usb_device_id *id);
extern void
et61x251_attach_sensor(struct et61x251_device* cam,
- struct et61x251_sensor* sensor);
+ struct et61x251_sensor* sensor);
/*****************************************************************************/
@@ -56,13 +56,13 @@ extern int et61x251_read_reg(struct et61x251_device*, u16 index);
extern int et61x251_i2c_write(struct et61x251_device*, u8 address, u8 value);
extern int et61x251_i2c_read(struct et61x251_device*, u8 address);
extern int et61x251_i2c_try_write(struct et61x251_device*,
- struct et61x251_sensor*, u8 address,
- u8 value);
+ struct et61x251_sensor*, u8 address,
+ u8 value);
extern int et61x251_i2c_try_read(struct et61x251_device*,
- struct et61x251_sensor*, u8 address);
+ struct et61x251_sensor*, u8 address);
extern int et61x251_i2c_raw_write(struct et61x251_device*, u8 n, u8 data1,
- u8 data2, u8 data3, u8 data4, u8 data5,
- u8 data6, u8 data7, u8 data8, u8 address);
+ u8 data2, u8 data3, u8 data4, u8 data5,
+ u8 data6, u8 data7, u8 data8, u8 address);
/*****************************************************************************/
@@ -100,13 +100,13 @@ struct et61x251_sensor {
int (*init)(struct et61x251_device* cam);
int (*get_ctrl)(struct et61x251_device* cam,
- struct v4l2_control* ctrl);
+ struct v4l2_control* ctrl);
int (*set_ctrl)(struct et61x251_device* cam,
- const struct v4l2_control* ctrl);
+ const struct v4l2_control* ctrl);
int (*set_crop)(struct et61x251_device* cam,
- const struct v4l2_rect* rect);
+ const struct v4l2_rect* rect);
int (*set_pix_format)(struct et61x251_device* cam,
- const struct v4l2_pix_format* pix);
+ const struct v4l2_pix_format* pix);
/* Private */
struct v4l2_queryctrl _qctrl[ET61X251_MAX_CTRLS];
diff --git a/drivers/usb/media/et61x251_tas5130d1b.c b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
index 3998d76a307..a7d65b82b2f 100644
--- a/drivers/usb/media/et61x251_tas5130d1b.c
+++ b/drivers/media/video/et61x251/et61x251_tas5130d1b.c
@@ -46,20 +46,20 @@ static int tas5130d1b_init(struct et61x251_device* cam)
static int tas5130d1b_set_ctrl(struct et61x251_device* cam,
- const struct v4l2_control* ctrl)
+ const struct v4l2_control* ctrl)
{
int err = 0;
switch (ctrl->id) {
case V4L2_CID_GAIN:
err += et61x251_i2c_raw_write(cam, 2, 0x20,
- 0xf6-ctrl->value, 0, 0, 0,
- 0, 0, 0, 0);
+ 0xf6-ctrl->value, 0, 0, 0,
+ 0, 0, 0, 0);
break;
case V4L2_CID_EXPOSURE:
err += et61x251_i2c_raw_write(cam, 2, 0x40,
- 0x47-ctrl->value, 0, 0, 0,
- 0, 0, 0, 0);
+ 0x47-ctrl->value, 0, 0, 0,
+ 0, 0, 0, 0);
break;
default:
return -EINVAL;
diff --git a/drivers/media/video/font.h b/drivers/media/video/font.h
new file mode 100644
index 00000000000..8b1fecc3759
--- /dev/null
+++ b/drivers/media/video/font.h
@@ -0,0 +1,407 @@
+static unsigned char rom8x16_bits[] = {
+/* Character 0 (0x30):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** *** |
+ |** **** |
+ |**** ** |
+ |*** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xce,
+0xde,
+0xf6,
+0xe6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 1 (0x31):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ** |
+ | **** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ****** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x18,
+0x78,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x18,
+0x7e,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 2 (0x32):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ |******* |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0x06,
+0x0c,
+0x18,
+0x30,
+0x60,
+0xc6,
+0xfe,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 3 (0x33):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ | ** |
+ | ** |
+ | **** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0x06,
+0x06,
+0x3c,
+0x06,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 4 (0x34):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ** |
+ | *** |
+ | **** |
+ | ** ** |
+ |** ** |
+ |** ** |
+ |******* |
+ | ** |
+ | ** |
+ | **** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x0c,
+0x1c,
+0x3c,
+0x6c,
+0xcc,
+0xcc,
+0xfe,
+0x0c,
+0x0c,
+0x1e,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 5 (0x35):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ |******* |
+ |** |
+ |** |
+ |** |
+ |****** |
+ | ** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0xfe,
+0xc0,
+0xc0,
+0xc0,
+0xfc,
+0x06,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 6 (0x36):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** |
+ |** |
+ |****** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc0,
+0xc0,
+0xfc,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 7 (0x37):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ |******* |
+ |** ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | ** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0xfe,
+0xc6,
+0x06,
+0x0c,
+0x18,
+0x30,
+0x30,
+0x30,
+0x30,
+0x30,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 8 (0x38):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+
+/* Character 9 (0x39):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | ***** |
+ |** ** |
+ |** ** |
+ |** ** |
+ |** ** |
+ | ****** |
+ | ** |
+ | ** |
+ |** ** |
+ | ***** |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x7c,
+0xc6,
+0xc6,
+0xc6,
+0xc6,
+0x7e,
+0x06,
+0x06,
+0xc6,
+0x7c,
+0x00,
+0x00,
+0x00,
+0x00,
+/* Character : (0x3a):
+ ht=16, width=8
+ +--------+
+ | |
+ | |
+ | |
+ | |
+ | |
+ | ** |
+ | ** |
+ | |
+ | |
+ | ** |
+ | ** |
+ | |
+ | |
+ | |
+ | |
+ | |
+ +--------+ */
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+0x0c,
+0x0c,
+0x00,
+0x00,
+0x0c,
+0x0c,
+0x00,
+0x00,
+0x00,
+0x00,
+0x00,
+};
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index 11ea9765769..c40e8ba9a2e 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -53,10 +53,11 @@
#include <linux/videodev.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
-#include <media/audiochip.h>
+#include <media/tvaudio.h>
+#include <media/msp3400.h>
#include <linux/kthread.h>
#include <linux/suspend.h>
-#include "msp3400.h"
+#include "msp3400-driver.h"
/* ---------------------------------------------------------------------- */
@@ -245,31 +246,31 @@ int msp_write_dsp(struct i2c_client *client, int addr, int val)
* ----------------------------------------------------------------------- */
static int scarts[3][9] = {
- /* MASK IN1 IN2 IN1_DA IN2_DA IN3 IN4 MONO MUTE */
+ /* MASK IN1 IN2 IN3 IN4 IN1_DA IN2_DA MONO MUTE */
/* SCART DSP Input select */
- { 0x0320, 0x0000, 0x0200, -1, -1, 0x0300, 0x0020, 0x0100, 0x0320 },
+ { 0x0320, 0x0000, 0x0200, 0x0300, 0x0020, -1, -1, 0x0100, 0x0320 },
/* SCART1 Output select */
- { 0x0c40, 0x0440, 0x0400, 0x0c00, 0x0040, 0x0000, 0x0840, 0x0800, 0x0c40 },
+ { 0x0c40, 0x0440, 0x0400, 0x0000, 0x0840, 0x0c00, 0x0040, 0x0800, 0x0c40 },
/* SCART2 Output select */
- { 0x3080, 0x1000, 0x1080, 0x0000, 0x0080, 0x2080, 0x3080, 0x2000, 0x3000 },
+ { 0x3080, 0x1000, 0x1080, 0x2080, 0x3080, 0x0000, 0x0080, 0x2000, 0x3000 },
};
static char *scart_names[] = {
- "mask", "in1", "in2", "in1 da", "in2 da", "in3", "in4", "mono", "mute"
+ "in1", "in2", "in3", "in4", "in1 da", "in2 da", "mono", "mute"
};
void msp_set_scart(struct i2c_client *client, int in, int out)
{
struct msp_state *state = i2c_get_clientdata(client);
- state->in_scart=in;
+ state->in_scart = in;
- if (in >= 1 && in <= 8 && out >= 0 && out <= 2) {
- if (-1 == scarts[out][in])
+ if (in >= 0 && in <= 7 && out >= 0 && out <= 2) {
+ if (-1 == scarts[out][in + 1])
return;
- state->acb &= ~scarts[out][SCART_MASK];
- state->acb |= scarts[out][in];
+ state->acb &= ~scarts[out][0];
+ state->acb |= scarts[out][in + 1];
} else
state->acb = 0xf60; /* Mute Input and SCART 1 Output */
@@ -336,37 +337,6 @@ void msp_set_audio(struct i2c_client *client)
msp_write_dsp(client, 0x0033, loudness);
}
-int msp_modus(struct i2c_client *client)
-{
- struct msp_state *state = i2c_get_clientdata(client);
-
- if (state->radio) {
- v4l_dbg(1, msp_debug, client, "video mode selected to Radio\n");
- return 0x0003;
- }
-
- if (state->v4l2_std & V4L2_STD_PAL) {
- v4l_dbg(1, msp_debug, client, "video mode selected to PAL\n");
-
-#if 1
- /* experimental: not sure this works with all chip versions */
- return 0x7003;
-#else
- /* previous value, try this if it breaks ... */
- return 0x1003;
-#endif
- }
- if (state->v4l2_std & V4L2_STD_NTSC) {
- v4l_dbg(1, msp_debug, client, "video mode selected to NTSC\n");
- return 0x2003;
- }
- if (state->v4l2_std & V4L2_STD_SECAM) {
- v4l_dbg(1, msp_debug, client, "video mode selected to SECAM\n");
- return 0x0003;
- }
- return 0x0003;
-}
-
/* ------------------------------------------------------------------------ */
@@ -585,51 +555,11 @@ static int msp_set_ctrl(struct i2c_client *client, struct v4l2_control *ctrl)
static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
struct msp_state *state = i2c_get_clientdata(client);
- u16 *sarg = arg;
- int scart = 0;
if (msp_debug >= 2)
v4l_i2c_print_ioctl(client, cmd);
switch (cmd) {
- case AUDC_SET_INPUT:
- if (*sarg == state->input)
- break;
- state->input = *sarg;
- switch (*sarg) {
- case AUDIO_RADIO:
- /* Hauppauge uses IN2 for the radio */
- state->mode = MSP_MODE_FM_RADIO;
- scart = SCART_IN2;
- break;
- case AUDIO_EXTERN_1:
- /* IN1 is often used for external input ... */
- state->mode = MSP_MODE_EXTERN;
- scart = SCART_IN1;
- break;
- case AUDIO_EXTERN_2:
- /* ... sometimes it is IN2 through ;) */
- state->mode = MSP_MODE_EXTERN;
- scart = SCART_IN2;
- break;
- case AUDIO_TUNER:
- state->mode = -1;
- break;
- default:
- if (*sarg & AUDIO_MUTE)
- msp_set_scart(client, SCART_MUTE, 0);
- break;
- }
- if (scart) {
- state->rxsubchans = V4L2_TUNER_SUB_STEREO;
- msp_set_scart(client, scart, 0);
- msp_write_dsp(client, 0x000d, 0x1900);
- if (state->opmode != OPMODE_AUTOSELECT)
- msp_set_audmode(client);
- }
- msp_wake_thread(client);
- break;
-
case AUDC_SET_RADIO:
if (state->radio)
return 0;
@@ -692,6 +622,7 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
if (va->mode != 0 && state->radio == 0) {
state->audmode = msp_mode_v4l1_to_v4l2(va->mode);
+ msp_set_audmode(client);
}
break;
}
@@ -728,15 +659,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
break;
}
- /* msp34xx specific */
- case MSP_SET_MATRIX:
- {
- struct msp_matrix *mspm = arg;
-
- msp_set_scart(client, mspm->input, mspm->output);
- break;
- }
-
/* --- v4l2 ioctls --- */
case VIDIOC_S_STD:
{
@@ -750,90 +672,34 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
return 0;
}
- case VIDIOC_ENUMINPUT:
- {
- struct v4l2_input *i = arg;
-
- if (i->index != 0)
- return -EINVAL;
-
- i->type = V4L2_INPUT_TYPE_TUNER;
- switch (i->index) {
- case AUDIO_RADIO:
- strcpy(i->name, "Radio");
- break;
- case AUDIO_EXTERN_1:
- strcpy(i->name, "Extern 1");
- break;
- case AUDIO_EXTERN_2:
- strcpy(i->name, "Extern 2");
- break;
- case AUDIO_TUNER:
- strcpy(i->name, "Television");
- break;
- default:
- return -EINVAL;
- }
- return 0;
- }
-
- case VIDIOC_G_AUDIO:
+ case VIDIOC_INT_G_AUDIO_ROUTING:
{
- struct v4l2_audio *a = arg;
+ struct v4l2_routing *rt = arg;
- memset(a, 0, sizeof(*a));
-
- switch (a->index) {
- case AUDIO_RADIO:
- strcpy(a->name, "Radio");
- break;
- case AUDIO_EXTERN_1:
- strcpy(a->name, "Extern 1");
- break;
- case AUDIO_EXTERN_2:
- strcpy(a->name, "Extern 2");
- break;
- case AUDIO_TUNER:
- strcpy(a->name, "Television");
- break;
- default:
- return -EINVAL;
- }
-
- a->capability = V4L2_AUDCAP_STEREO;
- a->mode = 0; /* TODO: add support for AVL */
+ *rt = state->routing;
break;
}
- case VIDIOC_S_AUDIO:
+ case VIDIOC_INT_S_AUDIO_ROUTING:
{
- struct v4l2_audio *sarg = arg;
-
- switch (sarg->index) {
- case AUDIO_RADIO:
- /* Hauppauge uses IN2 for the radio */
- state->mode = MSP_MODE_FM_RADIO;
- scart = SCART_IN2;
- break;
- case AUDIO_EXTERN_1:
- /* IN1 is often used for external input ... */
- state->mode = MSP_MODE_EXTERN;
- scart = SCART_IN1;
- break;
- case AUDIO_EXTERN_2:
- /* ... sometimes it is IN2 through ;) */
- state->mode = MSP_MODE_EXTERN;
- scart = SCART_IN2;
- break;
- case AUDIO_TUNER:
- state->mode = -1;
- break;
- }
- if (scart) {
- state->rxsubchans = V4L2_TUNER_SUB_STEREO;
- msp_set_scart(client, scart, 0);
- msp_write_dsp(client, 0x000d, 0x1900);
+ struct v4l2_routing *rt = arg;
+ int tuner = (rt->input >> 3) & 1;
+ int sc_in = rt->input & 0x7;
+ int sc1_out = rt->output & 0xf;
+ int sc2_out = (rt->output >> 4) & 0xf;
+ u16 val;
+
+ state->routing = *rt;
+ if (state->opmode == OPMODE_AUTOSELECT) {
+ val = msp_read_dem(client, 0x30) & ~0x100;
+ msp_write_dem(client, 0x30, val | (tuner ? 0x100 : 0));
+ } else {
+ val = msp_read_dem(client, 0xbb) & ~0x100;
+ msp_write_dem(client, 0xbb, val | (tuner ? 0x100 : 0));
}
+ msp_set_scart(client, sc_in, 0);
+ msp_set_scart(client, sc1_out, 1);
+ msp_set_scart(client, sc2_out, 2);
msp_set_audmode(client);
msp_wake_thread(client);
break;
@@ -866,42 +732,6 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
break;
}
- case VIDIOC_G_AUDOUT:
- {
- struct v4l2_audioout *a = (struct v4l2_audioout *)arg;
- int idx = a->index;
-
- memset(a, 0, sizeof(*a));
-
- switch (idx) {
- case 0:
- strcpy(a->name, "Scart1 Out");
- break;
- case 1:
- strcpy(a->name, "Scart2 Out");
- break;
- case 2:
- strcpy(a->name, "I2S Out");
- break;
- default:
- return -EINVAL;
- }
- break;
- }
-
- case VIDIOC_S_AUDOUT:
- {
- struct v4l2_audioout *a = (struct v4l2_audioout *)arg;
-
- if (a->index < 0 || a->index > 2)
- return -EINVAL;
-
- v4l_dbg(1, msp_debug, client, "Setting audio out on msp34xx to input %i\n", a->index);
- msp_set_scart(client, state->in_scart, a->index + 1);
-
- break;
- }
-
case VIDIOC_INT_I2S_CLOCK_FREQ:
{
u32 *a = (u32 *)arg;
@@ -979,12 +809,16 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
(state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
(state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
} else {
- v4l_info(client, "Mode: %s\n", p);
+ if (state->opmode == OPMODE_AUTODETECT)
+ v4l_info(client, "Mode: %s\n", p);
v4l_info(client, "Standard: %s (%s%s)\n",
msp_standard_std_name(state->std),
(state->rxsubchans & V4L2_TUNER_SUB_STEREO) ? "stereo" : "mono",
(state->rxsubchans & V4L2_TUNER_SUB_LANG2) ? ", dual" : "");
}
+ v4l_info(client, "Audmode: 0x%04x\n", state->audmode);
+ v4l_info(client, "Routing: 0x%08x (input) 0x%08x (output)\n",
+ state->routing.input, state->routing.output);
v4l_info(client, "ACB: 0x%04x\n", state->acb);
break;
}
@@ -1063,6 +897,9 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind)
state->muted = 0;
state->i2s_mode = 0;
init_waitqueue_head(&state->wq);
+ /* These are the reset input/output positions */
+ state->routing.input = MSP_INPUT_DEFAULT;
+ state->routing.output = MSP_OUTPUT_DEFAULT;
state->rev1 = msp_read_dsp(client, 0x1e);
if (state->rev1 != -1)
diff --git a/drivers/media/video/msp3400.h b/drivers/media/video/msp3400-driver.h
index 6fb5c8c994e..1940748bb63 100644
--- a/drivers/media/video/msp3400.h
+++ b/drivers/media/video/msp3400-driver.h
@@ -1,8 +1,10 @@
/*
*/
-#ifndef MSP3400_H
-#define MSP3400_H
+#ifndef MSP3400_DRIVER_H
+#define MSP3400_DRIVER_H
+
+#include <media/msp3400.h>
/* ---------------------------------------------------------------------- */
@@ -20,15 +22,14 @@
#define MSP_MODE_BTSC 8
#define MSP_MODE_EXTERN 9
-#define SCART_MASK 0
-#define SCART_IN1 1
-#define SCART_IN2 2
-#define SCART_IN1_DA 3
-#define SCART_IN2_DA 4
-#define SCART_IN3 5
-#define SCART_IN4 6
-#define SCART_MONO 7
-#define SCART_MUTE 8
+#define SCART_IN1 0
+#define SCART_IN2 1
+#define SCART_IN3 2
+#define SCART_IN4 3
+#define SCART_IN1_DA 4
+#define SCART_IN2_DA 5
+#define SCART_MONO 6
+#define SCART_MUTE 7
#define SCART_DSP_IN 0
#define SCART1_OUT 1
@@ -73,7 +74,7 @@ struct msp_state {
int i2s_mode;
int main, second; /* sound carrier */
int input;
- int source; /* see msp34xxg_set_source */
+ struct v4l2_routing routing;
/* v4l2 */
int audmode;
@@ -99,17 +100,16 @@ int msp_reset(struct i2c_client *client);
void msp_set_scart(struct i2c_client *client, int in, int out);
void msp_set_mute(struct i2c_client *client);
void msp_set_audio(struct i2c_client *client);
-int msp_modus(struct i2c_client *client);
int msp_sleep(struct msp_state *state, int timeout);
/* msp3400-kthreads.c */
const char *msp_standard_std_name(int std);
void msp_set_audmode(struct i2c_client *client);
-void msp_detect_stereo(struct i2c_client *client);
+int msp_detect_stereo(struct i2c_client *client);
int msp3400c_thread(void *data);
int msp3410d_thread(void *data);
int msp34xxg_thread(void *data);
void msp3400c_set_mode(struct i2c_client *client, int mode);
void msp3400c_set_carrier(struct i2c_client *client, int cdo1, int cdo2);
-#endif /* MSP3400_H */
+#endif /* MSP3400_DRIVER_H */
diff --git a/drivers/media/video/msp3400-kthreads.c b/drivers/media/video/msp3400-kthreads.c
index 852ab6a115f..c3984ea9ca0 100644
--- a/drivers/media/video/msp3400-kthreads.c
+++ b/drivers/media/video/msp3400-kthreads.c
@@ -26,10 +26,10 @@
#include <linux/videodev.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
-#include <media/audiochip.h>
+#include <media/msp3400.h>
#include <linux/kthread.h>
#include <linux/suspend.h>
-#include "msp3400.h"
+#include "msp3400-driver.h"
/* this one uses the automatic sound standard detection of newer msp34xx
chip versions */
@@ -45,11 +45,13 @@ static struct {
{ 0x0004, MSP_CARRIER(6.5), MSP_CARRIER(6.2578125), "6.5/6.25 D/K1 Dual FM-Stereo" },
{ 0x0005, MSP_CARRIER(6.5), MSP_CARRIER(6.7421875), "6.5/6.74 D/K2 Dual FM-Stereo" },
{ 0x0006, MSP_CARRIER(6.5), MSP_CARRIER(6.5), "6.5 D/K FM-Mono (HDEV3)" },
+ { 0x0007, MSP_CARRIER(6.5), MSP_CARRIER(5.7421875), "6.5/5.74 D/K3 Dual FM-Stereo" },
{ 0x0008, MSP_CARRIER(5.5), MSP_CARRIER(5.85), "5.5/5.85 B/G NICAM FM" },
{ 0x0009, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 L NICAM AM" },
{ 0x000a, MSP_CARRIER(6.0), MSP_CARRIER(6.55), "6.0/6.55 I NICAM FM" },
{ 0x000b, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM" },
{ 0x000c, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV2)" },
+ { 0x000d, MSP_CARRIER(6.5), MSP_CARRIER(5.85), "6.5/5.85 D/K NICAM FM (HDEV3)" },
{ 0x0020, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Stereo" },
{ 0x0021, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M BTSC-Mono + SAP" },
{ 0x0030, MSP_CARRIER(4.5), MSP_CARRIER(4.5), "4.5 M EIA-J Japan Stereo" },
@@ -185,13 +187,14 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
{
struct msp_state *state = i2c_get_clientdata(client);
struct msp3400c_init_data_dem *data = &msp3400c_init_data[mode];
+ int tuner = (state->routing.input >> 3) & 1;
int i;
v4l_dbg(1, msp_debug, client, "set_mode: %d\n", mode);
state->mode = mode;
state->rxsubchans = V4L2_TUNER_SUB_MONO;
- msp_write_dem(client, 0x00bb, data->ad_cv);
+ msp_write_dem(client, 0x00bb, data->ad_cv | (tuner ? 0x100 : 0));
for (i = 5; i >= 0; i--) /* fir 1 */
msp_write_dem(client, 0x0001, data->fir1[i]);
@@ -207,21 +210,22 @@ void msp3400c_set_mode(struct i2c_client *client, int mode)
msp3400c_set_carrier(client, data->cdo1, data->cdo2);
msp_set_source(client, data->dsp_src);
- msp_write_dsp(client, 0x000e, data->dsp_matrix);
+ /* set prescales */
- if (state->has_nicam) {
- /* nicam prescale */
- msp_write_dsp(client, 0x0010, 0x5a00); /* was: 0x3000 */
- }
+ /* volume prescale for SCART (AM mono input) */
+ msp_write_dsp(client, 0x000d, 0x1900);
+ msp_write_dsp(client, 0x000e, data->dsp_matrix);
+ if (state->has_nicam) /* nicam prescale */
+ msp_write_dsp(client, 0x0010, 0x5a00);
}
/* Set audio mode. Note that the pre-'G' models do not support BTSC+SAP,
nor do they support stereo BTSC. */
static void msp3400c_set_audmode(struct i2c_client *client)
{
- static char *strmode[] = { "mono", "stereo", "lang2", "lang1" };
+ static char *strmode[] = { "mono", "stereo", "lang2", "lang1", "lang1+lang2" };
struct msp_state *state = i2c_get_clientdata(client);
- char *modestr = (state->audmode >= 0 && state->audmode < 4) ?
+ char *modestr = (state->audmode >= 0 && state->audmode < 5) ?
strmode[state->audmode] : "unknown";
int src = 0; /* channel source: FM/AM, nicam or SCART */
@@ -246,6 +250,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
case V4L2_TUNER_MODE_MONO:
case V4L2_TUNER_MODE_LANG1:
case V4L2_TUNER_MODE_LANG2:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
msp_write_dsp(client, 0x000e, 0x3000);
break;
}
@@ -257,6 +262,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
msp3400c_set_carrier(client, MSP_CARRIER(6.5), MSP_CARRIER(6.5));
break;
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
msp3400c_set_carrier(client, MSP_CARRIER(7.2), MSP_CARRIER(7.02));
break;
case V4L2_TUNER_MODE_LANG1:
@@ -271,7 +277,6 @@ static void msp3400c_set_audmode(struct i2c_client *client)
case MSP_MODE_FM_NICAM2:
case MSP_MODE_AM_NICAM:
v4l_dbg(1, msp_debug, client, "NICAM set_audmode: %s\n",modestr);
- msp3400c_set_carrier(client, state->second, state->main);
if (state->nicam_on)
src = 0x0100; /* NICAM */
break;
@@ -293,6 +298,7 @@ static void msp3400c_set_audmode(struct i2c_client *client)
/* switch audio */
switch (state->audmode) {
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
src |= 0x0020;
break;
case V4L2_TUNER_MODE_MONO:
@@ -427,8 +433,8 @@ static void watch_stereo(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- if (msp3400c_detect_stereo(client)) {
- msp3400c_set_audmode(client);
+ if (msp_detect_stereo(client)) {
+ msp_set_audmode(client);
}
if (msp_once)
@@ -464,7 +470,7 @@ int msp3400c_thread(void *data)
/* mute */
msp_set_mute(client);
- msp3400c_set_mode(client, MSP_MODE_AM_DETECT /* +1 */ );
+ msp3400c_set_mode(client, MSP_MODE_AM_DETECT);
val1 = val2 = 0;
max1 = max2 = -1;
state->watch_stereo = 0;
@@ -572,8 +578,6 @@ int msp3400c_thread(void *data)
state->second = msp3400c_carrier_detect_65[max2].cdo;
msp3400c_set_mode(client, MSP_MODE_AM_NICAM);
msp3400c_set_carrier(client, state->second, state->main);
- /* volume prescale for SCART (AM mono input) */
- msp_write_dsp(client, 0x000d, 0x1900);
state->watch_stereo = 1;
} else if (max2 == 0 && state->has_nicam) {
/* D/K NICAM */
@@ -651,7 +655,8 @@ int msp3410d_thread(void *data)
if (msp_sleep(state,200))
goto restart;
- /* start autodetect */
+ /* start autodetect. Note: autodetect is not supported for
+ NTSC-M and radio, hence we force the standard in those cases. */
if (state->radio)
std = 0x40;
else
@@ -695,23 +700,19 @@ int msp3410d_thread(void *data)
v4l_dbg(1, msp_debug, client, "autodetection failed,"
" switching to backup standard: %s (0x%04x)\n",
msp_stdlist[8].name ? msp_stdlist[8].name : "unknown",val);
- val = 0x0009;
+ state->std = val = 0x0009;
msp_write_dem(client, 0x20, val);
}
- /* set various prescales */
- msp_write_dsp(client, 0x0d, 0x1900); /* scart */
- msp_write_dsp(client, 0x0e, 0x2403); /* FM */
- msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
-
/* set stereo */
switch (val) {
case 0x0008: /* B/G NICAM */
case 0x000a: /* I NICAM */
- if (val == 0x0008)
- state->mode = MSP_MODE_FM_NICAM1;
- else
+ case 0x000b: /* D/K NICAM */
+ if (val == 0x000a)
state->mode = MSP_MODE_FM_NICAM2;
+ else
+ state->mode = MSP_MODE_FM_NICAM1;
/* just turn on stereo */
state->rxsubchans = V4L2_TUNER_SUB_STEREO;
state->nicam_on = 1;
@@ -739,6 +740,7 @@ int msp3410d_thread(void *data)
/* scart routing (this doesn't belong here I think) */
msp_set_scart(client,SCART_IN2,0);
break;
+ case 0x0002:
case 0x0003:
case 0x0004:
case 0x0005:
@@ -748,12 +750,19 @@ int msp3410d_thread(void *data)
break;
}
- /* unmute, restore misc registers */
- msp_set_audio(client);
- msp_write_dsp(client, 0x13, state->acb);
+ /* set various prescales */
+ msp_write_dsp(client, 0x0d, 0x1900); /* scart */
+ msp_write_dsp(client, 0x0e, 0x3000); /* FM */
+ if (state->has_nicam)
+ msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
+
if (state->has_i2s_conf)
msp_write_dem(client, 0x40, state->i2s_mode);
+ /* unmute, restore misc registers */
+ msp_set_audio(client);
+
+ msp_write_dsp(client, 0x13, state->acb);
msp3400c_set_audmode(client);
/* monitor tv audio mode, the first time don't wait
@@ -772,97 +781,154 @@ int msp3410d_thread(void *data)
/* ----------------------------------------------------------------------- */
-/* msp34xxG + (autoselect no-thread) */
-/* this one uses both automatic standard detection and automatic sound */
-/* select which are available in the newer G versions */
-/* struct msp: only norm, acb and source are really used in this mode */
-
-/* set the same 'source' for the loudspeaker, scart and quasi-peak detector
- * the value for source is the same as bit 15:8 of DSP registers 0x08,
- * 0x0a and 0x0c: 0=mono, 1=stereo or A|B, 2=SCART, 3=stereo or A, 4=stereo or B
- *
- * this function replaces msp3400c_set_audmode
+/* msp34xxG + (autoselect no-thread)
+ * this one uses both automatic standard detection and automatic sound
+ * select which are available in the newer G versions
+ * struct msp: only norm, acb and source are really used in this mode
*/
-static void msp34xxg_set_source(struct i2c_client *client, int source)
+
+static int msp34xxg_modus(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- /* fix matrix mode to stereo and let the msp choose what
- * to output according to 'source', as recommended
- * for MONO (source==0) downmixing set bit[7:0] to 0x30
- */
- int value = (source & 0x07) << 8 | (source == 0 ? 0x30 : 0x20);
+ if (state->radio) {
+ v4l_dbg(1, msp_debug, client, "selected radio modus\n");
+ return 0x0001;
+ }
- v4l_dbg(1, msp_debug, client, "set source to %d (0x%x)\n", source, value);
- msp_set_source(client, value);
- /*
- * set identification threshold. Personally, I
- * I set it to a higher value that the default
- * of 0x190 to ignore noisy stereo signals.
- * this needs tuning. (recommended range 0x00a0-0x03c0)
- * 0x7f0 = forced mono mode
- */
- /* a2 threshold for stereo/bilingual */
- msp_write_dem(client, 0x22, msp_stereo_thresh);
- state->source = source;
+ if (state->v4l2_std & V4L2_STD_PAL) {
+ v4l_dbg(1, msp_debug, client, "selected PAL modus\n");
+ return 0x7001;
+ }
+ if (state->v4l2_std == V4L2_STD_NTSC_M_JP) {
+ v4l_dbg(1, msp_debug, client, "selected M (EIA-J) modus\n");
+ return 0x4001;
+ }
+ if (state->v4l2_std == V4L2_STD_NTSC_M_KR) {
+ v4l_dbg(1, msp_debug, client, "selected M (A2) modus\n");
+ return 0x0001;
+ }
+ if (state->v4l2_std & V4L2_STD_MN) {
+ v4l_dbg(1, msp_debug, client, "selected M (BTSC) modus\n");
+ return 0x2001;
+ }
+ if (state->v4l2_std & V4L2_STD_SECAM) {
+ v4l_dbg(1, msp_debug, client, "selected SECAM modus\n");
+ return 0x6001;
+ }
+ return 0x0001;
}
-/* (re-)initialize the msp34xxg, according to the current norm in state->norm
- * return 0 if it worked, -1 if it failed
- */
-static int msp34xxg_reset(struct i2c_client *client)
+static void msp34xxg_set_source(struct i2c_client *client, u16 reg, int in)
+ {
+ struct msp_state *state = i2c_get_clientdata(client);
+ int source, matrix;
+
+ switch (state->audmode) {
+ case V4L2_TUNER_MODE_MONO:
+ source = 0; /* mono only */
+ matrix = 0x30;
+ break;
+ case V4L2_TUNER_MODE_LANG1:
+ source = 3; /* stereo or A */
+ matrix = 0x00;
+ break;
+ case V4L2_TUNER_MODE_LANG2:
+ source = 4; /* stereo or B */
+ matrix = 0x10;
+ break;
+ case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
+ default:
+ source = 1; /* stereo or A|B */
+ matrix = 0x20;
+ break;
+ }
+
+ if (in == MSP_DSP_OUT_TUNER)
+ source = (source << 8) | 0x20;
+ /* the msp34x2g puts the MAIN_AVC, MAIN and AUX sources in 12, 13, 14
+ instead of 11, 12, 13. So we add one for that msp version. */
+ else if (in >= MSP_DSP_OUT_MAIN_AVC && state->has_dolby_pro_logic)
+ source = ((in + 1) << 8) | matrix;
+ else
+ source = (in << 8) | matrix;
+
+ v4l_dbg(1, msp_debug, client, "set source to %d (0x%x) for output %02x\n",
+ in, source, reg);
+ msp_write_dsp(client, reg, source);
+}
+
+static void msp34xxg_set_sources(struct i2c_client *client)
+{
+ struct msp_state *state = i2c_get_clientdata(client);
+ u32 in = state->routing.input;
+
+ msp34xxg_set_source(client, 0x0008, (in >> 4) & 0xf);
+ /* quasi-peak detector is set to same input as the loudspeaker (MAIN) */
+ msp34xxg_set_source(client, 0x000c, (in >> 4) & 0xf);
+ msp34xxg_set_source(client, 0x0009, (in >> 8) & 0xf);
+ msp34xxg_set_source(client, 0x000a, (in >> 12) & 0xf);
+ if (state->has_scart23_in_scart2_out)
+ msp34xxg_set_source(client, 0x0041, (in >> 16) & 0xf);
+ msp34xxg_set_source(client, 0x000b, (in >> 20) & 0xf);
+}
+
+/* (re-)initialize the msp34xxg */
+static void msp34xxg_reset(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- int modus, std;
+ int tuner = (state->routing.input >> 3) & 1;
+ int modus;
+
+ /* initialize std to 1 (autodetect) to signal that no standard is
+ selected yet. */
+ state->std = 1;
- if (msp_reset(client))
- return -1;
+ msp_reset(client);
/* make sure that input/output is muted (paranoid mode) */
/* ACB, mute DSP input, mute SCART 1 */
- if (msp_write_dsp(client, 0x13, 0x0f20))
- return -1;
+ msp_write_dsp(client, 0x13, 0x0f20);
if (state->has_i2s_conf)
msp_write_dem(client, 0x40, state->i2s_mode);
/* step-by-step initialisation, as described in the manual */
- modus = msp_modus(client);
- if (state->radio)
- std = 0x40;
- else
- std = (state->v4l2_std & V4L2_STD_NTSC) ? 0x20 : 1;
- modus &= ~0x03; /* STATUS_CHANGE = 0 */
- modus |= 0x01; /* AUTOMATIC_SOUND_DETECTION = 1 */
- if (msp_write_dem(client, 0x30, modus))
- return -1;
- if (msp_write_dem(client, 0x20, std))
- return -1;
+ modus = msp34xxg_modus(client);
+ modus |= tuner ? 0x100 : 0;
+ msp_write_dem(client, 0x30, modus);
/* write the dsps that may have an influence on
standard/audio autodetection right now */
- msp34xxg_set_source(client, state->source);
-
- /* AM/FM Prescale [15:8] 75khz deviation */
- if (msp_write_dsp(client, 0x0e, 0x3000))
- return -1;
+ msp34xxg_set_sources(client);
- /* NICAM Prescale 9db gain (as recommended) */
- if (msp_write_dsp(client, 0x10, 0x5a00))
- return -1;
+ msp_write_dsp(client, 0x0d, 0x1900); /* scart */
+ msp_write_dsp(client, 0x0e, 0x3000); /* FM */
+ if (state->has_nicam)
+ msp_write_dsp(client, 0x10, 0x5a00); /* nicam */
- return 0;
+ /* set identification threshold. Personally, I
+ * I set it to a higher value than the default
+ * of 0x190 to ignore noisy stereo signals.
+ * this needs tuning. (recommended range 0x00a0-0x03c0)
+ * 0x7f0 = forced mono mode
+ *
+ * a2 threshold for stereo/bilingual.
+ * Note: this register is part of the Manual/Compatibility mode.
+ * It is supported by all 'G'-family chips.
+ */
+ msp_write_dem(client, 0x22, msp_stereo_thresh);
}
int msp34xxg_thread(void *data)
{
struct i2c_client *client = data;
struct msp_state *state = i2c_get_clientdata(client);
- int val, std, i;
+ int val, i;
v4l_dbg(1, msp_debug, client, "msp34xxg daemon started\n");
- state->source = 1; /* default */
for (;;) {
v4l_dbg(2, msp_debug, client, "msp34xxg thread: sleep\n");
msp_sleep(state, -1);
@@ -876,12 +942,14 @@ int msp34xxg_thread(void *data)
/* setup the chip*/
msp34xxg_reset(client);
- std = msp_standard;
- if (std != 0x01)
+ state->std = state->radio ? 0x40 : msp_standard;
+ if (state->std != 1)
goto unmute;
+ /* start autodetect */
+ msp_write_dem(client, 0x20, state->std);
/* watch autodetect */
- v4l_dbg(1, msp_debug, client, "triggered autodetect, waiting for result\n");
+ v4l_dbg(1, msp_debug, client, "started autodetect, waiting for result\n");
for (i = 0; i < 10; i++) {
if (msp_sleep(state, 100))
goto restart;
@@ -889,20 +957,19 @@ int msp34xxg_thread(void *data)
/* check results */
val = msp_read_dem(client, 0x7e);
if (val < 0x07ff) {
- std = val;
+ state->std = val;
break;
}
v4l_dbg(2, msp_debug, client, "detection still in progress\n");
}
- if (std == 1) {
+ if (state->std == 1) {
v4l_dbg(1, msp_debug, client, "detection still in progress after 10 tries. giving up.\n");
continue;
}
unmute:
- state->std = std;
- v4l_dbg(1, msp_debug, client, "current standard: %s (0x%04x)\n",
- msp_standard_std_name(std), std);
+ v4l_dbg(1, msp_debug, client, "detected standard: %s (0x%04x)\n",
+ msp_standard_std_name(state->std), state->std);
/* unmute: dispatch sound to scart output, set scart volume */
msp_set_audio(client);
@@ -911,20 +978,33 @@ int msp34xxg_thread(void *data)
if (msp_write_dsp(client, 0x13, state->acb))
return -1;
- if (state->has_i2s_conf)
- msp_write_dem(client, 0x40, state->i2s_mode);
+ /* the periodic stereo/SAP check is only relevant for
+ the 0x20 standard (BTSC) */
+ if (state->std != 0x20)
+ continue;
+
+ state->watch_stereo = 1;
+
+ /* monitor tv audio mode, the first time don't wait
+ in order to get a quick stereo/SAP update */
+ watch_stereo(client);
+ while (state->watch_stereo) {
+ watch_stereo(client);
+ if (msp_sleep(state, 5000))
+ goto restart;
+ }
}
v4l_dbg(1, msp_debug, client, "thread: exit\n");
return 0;
}
-static void msp34xxg_detect_stereo(struct i2c_client *client)
+static int msp34xxg_detect_stereo(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
-
int status = msp_read_dem(client, 0x0200);
int is_bilingual = status & 0x100;
int is_stereo = status & 0x40;
+ int oldrx = state->rxsubchans;
state->rxsubchans = 0;
if (is_stereo)
@@ -932,42 +1012,31 @@ static void msp34xxg_detect_stereo(struct i2c_client *client)
else
state->rxsubchans = V4L2_TUNER_SUB_MONO;
if (is_bilingual) {
- state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
- /* I'm supposed to check whether it's SAP or not
- * and set only LANG2/SAP in this case. Yet, the MSP
- * does a lot of work to hide this and handle everything
- * the same way. I don't want to work around it so unless
- * this is a problem, I'll handle SAP just like lang1/lang2.
- */
+ if (state->std == 0x20)
+ state->rxsubchans |= V4L2_TUNER_SUB_SAP;
+ else
+ state->rxsubchans = V4L2_TUNER_SUB_LANG1 | V4L2_TUNER_SUB_LANG2;
}
v4l_dbg(1, msp_debug, client, "status=0x%x, stereo=%d, bilingual=%d -> rxsubchans=%d\n",
status, is_stereo, is_bilingual, state->rxsubchans);
+ return (oldrx != state->rxsubchans);
}
static void msp34xxg_set_audmode(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
- int source;
- switch (state->audmode) {
- case V4L2_TUNER_MODE_MONO:
- source = 0; /* mono only */
- break;
- case V4L2_TUNER_MODE_STEREO:
- source = 1; /* stereo or A|B, see comment in msp34xxg_get_v4l2_stereo() */
- /* problem: that could also mean 2 (scart input) */
- break;
- case V4L2_TUNER_MODE_LANG1:
- source = 3; /* stereo or A */
- break;
- case V4L2_TUNER_MODE_LANG2:
- source = 4; /* stereo or B */
- break;
- default:
- source = 1;
- break;
+ if (state->std == 0x20) {
+ if ((state->rxsubchans & V4L2_TUNER_SUB_SAP) &&
+ (state->audmode == V4L2_TUNER_MODE_STEREO ||
+ state->audmode == V4L2_TUNER_MODE_LANG2)) {
+ msp_write_dem(client, 0x20, 0x21);
+ } else {
+ msp_write_dem(client, 0x20, 0x20);
+ }
}
- msp34xxg_set_source(client, source);
+
+ msp34xxg_set_sources(client);
}
void msp_set_audmode(struct i2c_client *client)
@@ -977,7 +1046,6 @@ void msp_set_audmode(struct i2c_client *client)
switch (state->opmode) {
case OPMODE_MANUAL:
case OPMODE_AUTODETECT:
- state->watch_stereo = 0;
msp3400c_set_audmode(client);
break;
case OPMODE_AUTOSELECT:
@@ -986,18 +1054,17 @@ void msp_set_audmode(struct i2c_client *client)
}
}
-void msp_detect_stereo(struct i2c_client *client)
+int msp_detect_stereo(struct i2c_client *client)
{
struct msp_state *state = i2c_get_clientdata(client);
switch (state->opmode) {
case OPMODE_MANUAL:
case OPMODE_AUTODETECT:
- msp3400c_detect_stereo(client);
- break;
+ return msp3400c_detect_stereo(client);
case OPMODE_AUTOSELECT:
- msp34xxg_detect_stereo(client);
- break;
+ return msp34xxg_detect_stereo(client);
}
+ return 0;
}
diff --git a/drivers/media/video/mxb.c b/drivers/media/video/mxb.c
index eb3b3186749..b0aea4002d1 100644
--- a/drivers/media/video/mxb.c
+++ b/drivers/media/video/mxb.c
@@ -198,13 +198,13 @@ static int mxb_probe(struct saa7146_dev* dev)
/* loop through all i2c-devices on the bus and look who is there */
list_for_each(item,&mxb->i2c_adapter.clients) {
client = list_entry(item, struct i2c_client, list);
- if( I2C_TEA6420_1 == client->addr )
+ if( I2C_ADDR_TEA6420_1 == client->addr )
mxb->tea6420_1 = client;
- if( I2C_TEA6420_2 == client->addr )
+ if( I2C_ADDR_TEA6420_2 == client->addr )
mxb->tea6420_2 = client;
if( I2C_TEA6415C_2 == client->addr )
mxb->tea6415c = client;
- if( I2C_TDA9840 == client->addr )
+ if( I2C_ADDR_TDA9840 == client->addr )
mxb->tda9840 = client;
if( I2C_SAA7111 == client->addr )
mxb->saa7111a = client;
@@ -790,6 +790,12 @@ static int mxb_ioctl(struct saa7146_fh *fh, unsigned int cmd, void *arg)
DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_STEREO\n"));
break;
}
+ case V4L2_TUNER_MODE_LANG1_LANG2: {
+ mxb->cur_mode = V4L2_TUNER_MODE_LANG1_LANG2;
+ byte = TDA9840_SET_BOTH;
+ DEB_D(("VIDIOC_S_TUNER: V4L2_TUNER_MODE_LANG1_LANG2\n"));
+ break;
+ }
case V4L2_TUNER_MODE_LANG1: {
mxb->cur_mode = V4L2_TUNER_MODE_LANG1;
byte = TDA9840_SET_LANG1;
diff --git a/drivers/usb/media/ov511.c b/drivers/media/video/ov511.c
index da44579d6f2..fdc8e3f1393 100644
--- a/drivers/usb/media/ov511.c
+++ b/drivers/media/video/ov511.c
@@ -15,7 +15,7 @@
*
* Based on the Linux CPiA driver written by Peter Pregler,
* Scott J. Bertin and Johannes Erdfelt.
- *
+ *
* Please see the file: Documentation/usb/ov511.txt
* and the website at: http://alpha.dyndns.org/ov511
* for more info.
@@ -433,7 +433,7 @@ reg_w_mask(struct usb_ov511 *ov,
return (reg_w(ov, reg, newval));
}
-/*
+/*
* Writes multiple (n) byte value to a single register. Only valid with certain
* registers (0x30 and 0xc4 - 0xce).
*/
@@ -629,7 +629,7 @@ ov511_i2c_write_internal(struct usb_ov511 *ov,
/* Retry until idle */
do
rc = reg_r(ov, R511_I2C_CTL);
- while (rc > 0 && ((rc&1) == 0));
+ while (rc > 0 && ((rc&1) == 0));
if (rc < 0)
break;
@@ -1752,7 +1752,7 @@ sensor_set_picture(struct usb_ov511 *ov, struct video_picture *p)
ov->whiteness = p->whiteness;
/* Don't return error if a setting is unsupported, or rest of settings
- * will not be performed */
+ * will not be performed */
rc = sensor_set_contrast(ov, p->contrast);
if (FATAL_ERROR(rc))
@@ -1781,7 +1781,7 @@ sensor_get_picture(struct usb_ov511 *ov, struct video_picture *p)
PDEBUG(4, "sensor_get_picture");
/* Don't return error if a setting is unsupported, or rest of settings
- * will not be performed */
+ * will not be performed */
rc = sensor_get_contrast(ov, &(p->contrast));
if (FATAL_ERROR(rc))
@@ -2251,7 +2251,7 @@ mode_init_ov_sensor_regs(struct usb_ov511 *ov, int width, int height,
/******** Clock programming ********/
- /* The OV6620 needs special handling. This prevents the
+ /* The OV6620 needs special handling. This prevents the
* severe banding that normally occurs */
if (ov->sensor == SEN_OV6620 || ov->sensor == SEN_OV6630)
{
@@ -2326,7 +2326,7 @@ set_ov_sensor_window(struct usb_ov511 *ov, int width, int height, int mode,
int sub_flag)
{
int ret;
- int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize;
+ int hwsbase, hwebase, vwsbase, vwebase, hwsize, vwsize;
int hoffset, voffset, hwscale = 0, vwscale = 0;
/* The different sensor ICs handle setting up of window differently.
@@ -2575,7 +2575,7 @@ ov518_mode_init_regs(struct usb_ov511 *ov,
/* OV518 needs U and V swapped */
i2c_w_mask(ov, 0x15, 0x00, 0x01);
- if (mode == VIDEO_PALETTE_GREY) {
+ if (mode == VIDEO_PALETTE_GREY) {
/* Set 16-bit input format (UV data are ignored) */
reg_w_mask(ov, 0x20, 0x00, 0x08);
@@ -2894,7 +2894,7 @@ make_8x8(unsigned char *pIn, unsigned char *pOut, int w)
* ... ... ...
* 56 57 ... 63 120 121 ... 127 248 249 ... 255
*
- */
+ */
static void
yuv400raw_to_yuv400p(struct ov511_frame *frame,
unsigned char *pIn0, unsigned char *pOut0)
@@ -2923,7 +2923,7 @@ yuv400raw_to_yuv400p(struct ov511_frame *frame,
*
* 0 1 ... 7
* 8 9 ... 15
- * ...
+ * ...
* 56 57 ... 63
*
* U and V are shipped at half resolution (1 U,V sample -> one 2x2 block).
@@ -3034,7 +3034,7 @@ decompress(struct usb_ov511 *ov, struct ov511_frame *frame,
*/
static void
deinterlace(struct ov511_frame *frame, int rawformat,
- unsigned char *pIn0, unsigned char *pOut0)
+ unsigned char *pIn0, unsigned char *pOut0)
{
const int fieldheight = frame->rawheight / 2;
const int fieldpix = fieldheight * frame->rawwidth;
@@ -3112,7 +3112,7 @@ ov51x_postprocess_grey(struct usb_ov511 *ov, struct ov511_frame *frame)
frame->tempdata);
deinterlace(frame, RAWFMT_YUV400, frame->tempdata,
- frame->data);
+ frame->data);
} else {
if (frame->compressed)
decompress(ov, frame, frame->rawdata,
@@ -3136,7 +3136,7 @@ ov51x_postprocess_yuv420(struct usb_ov511 *ov, struct ov511_frame *frame)
frame->tempdata);
deinterlace(frame, RAWFMT_YUV420, frame->tempdata,
- frame->data);
+ frame->data);
} else {
if (frame->compressed)
decompress(ov, frame, frame->rawdata, frame->data);
@@ -3226,7 +3226,7 @@ ov511_move_data(struct usb_ov511 *ov, unsigned char *in, int n)
frame->rawwidth = ((int)(in[9]) + 1) * 8;
frame->rawheight = ((int)(in[10]) + 1) * 8;
- PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d",
+ PDEBUG(4, "Frame end, frame=%d, pnum=%d, w=%d, h=%d, recvd=%d",
ov->curframe, pnum, frame->rawwidth, frame->rawheight,
frame->bytes_recvd);
@@ -3527,10 +3527,10 @@ ov51x_isoc_irq(struct urb *urb, struct pt_regs *regs)
return;
}
- if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
- PDEBUG(4, "URB unlinked");
- return;
- }
+ if (urb->status == -ENOENT || urb->status == -ECONNRESET) {
+ PDEBUG(4, "URB unlinked");
+ return;
+ }
if (urb->status != -EINPROGRESS && urb->status != 0) {
err("ERROR: urb->status=%d: %s", urb->status,
@@ -4627,8 +4627,8 @@ ov51x_v4l1_mmap(struct file *file, struct vm_area_struct *vma)
PDEBUG(4, "mmap: %ld (%lX) bytes", size, size);
if (size > (((OV511_NUMFRAMES
- * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)
- + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))))
+ * MAX_DATA_SIZE(ov->maxwidth, ov->maxheight)
+ + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))))
return -EINVAL;
if (mutex_lock_interruptible(&ov->lock))
@@ -5062,7 +5062,7 @@ ov6xx0_configure(struct usb_ov511 *ov)
}
/* This initializes the KS0127 and KS0127B video decoders. */
-static int
+static int
ks0127_configure(struct usb_ov511 *ov)
{
int rc;
@@ -5193,7 +5193,7 @@ saa7111a_configure(struct usb_ov511 *ov)
return -1;
/* Detect version of decoder. This must be done after writing the
- * initial regs or the decoder will lock up. */
+ * initial regs or the decoder will lock up. */
rc = i2c_r(ov, 0x00);
if (rc < 0) {
@@ -5216,13 +5216,13 @@ saa7111a_configure(struct usb_ov511 *ov)
}
/* This initializes the OV511/OV511+ and the sensor */
-static int
+static int
ov511_configure(struct usb_ov511 *ov)
{
static struct ov511_regvals aRegvalsInit511[] = {
{ OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
- { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
- { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
+ { OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
+ { OV511_REG_BUS, R51x_SYS_RESET, 0x7f },
{ OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
{ OV511_REG_BUS, R51x_SYS_RESET, 0x3f },
{ OV511_REG_BUS, R51x_SYS_INIT, 0x01 },
@@ -5269,7 +5269,7 @@ ov511_configure(struct usb_ov511 *ov)
err("Please notify " EMAIL " of the name,");
err("manufacturer, model, and this number of your camera.");
err("Also include the output of the detection process.");
- }
+ }
if (ov->customid == 70) /* USB Life TV (PAL/SECAM) */
ov->pal = 1;
@@ -5336,17 +5336,17 @@ ov511_configure(struct usb_ov511 *ov)
if (i2c_w(ov, 0x10, 0x00) < 0) {
err("Can't determine sensor slave IDs");
- goto error;
+ goto error;
} else {
if (ks0127_configure(ov) < 0) {
err("Failed to configure KS0127");
- goto error;
+ goto error;
}
}
} else {
if (saa7111a_configure(ov) < 0) {
err("Failed to configure SAA7111A");
- goto error;
+ goto error;
}
}
} else {
@@ -5356,13 +5356,13 @@ ov511_configure(struct usb_ov511 *ov)
} else {
if (ov6xx0_configure(ov) < 0) {
err("Failed to configure OV6xx0");
- goto error;
+ goto error;
}
}
} else {
if (ov7xx0_configure(ov) < 0) {
err("Failed to configure OV7xx0");
- goto error;
+ goto error;
}
}
@@ -5381,12 +5381,12 @@ ov518_configure(struct usb_ov511 *ov)
/* For 518 and 518+ */
static struct ov511_regvals aRegvalsInit518[] = {
{ OV511_REG_BUS, R51x_SYS_RESET, 0x40 },
- { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
- { OV511_REG_BUS, R51x_SYS_RESET, 0x3e },
+ { OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
+ { OV511_REG_BUS, R51x_SYS_RESET, 0x3e },
{ OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
{ OV511_REG_BUS, R51x_SYS_RESET, 0x00 },
{ OV511_REG_BUS, R51x_SYS_INIT, 0xe1 },
- { OV511_REG_BUS, 0x46, 0x00 },
+ { OV511_REG_BUS, 0x46, 0x00 },
{ OV511_REG_BUS, 0x5d, 0x03 },
{ OV511_DONE_BUS, 0x0, 0x00},
};
@@ -5517,7 +5517,7 @@ ov518_configure(struct usb_ov511 *ov)
if (init_ov_sensor(ov) < 0) {
err("Can't determine sensor slave IDs");
- goto error;
+ goto error;
} else {
err("Detected unsupported OV8xx0 sensor");
goto error;
@@ -5525,13 +5525,13 @@ ov518_configure(struct usb_ov511 *ov)
} else {
if (ov6xx0_configure(ov) < 0) {
err("Failed to configure OV6xx0");
- goto error;
+ goto error;
}
}
} else {
if (ov7xx0_configure(ov) < 0) {
err("Failed to configure OV7xx0");
- goto error;
+ goto error;
}
}
@@ -5564,28 +5564,28 @@ static ssize_t show_custom_id(struct class_device *cd, char *buf)
{
struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%d\n", ov->customid);
-}
+}
static CLASS_DEVICE_ATTR(custom_id, S_IRUGO, show_custom_id, NULL);
static ssize_t show_model(struct class_device *cd, char *buf)
{
struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", ov->desc);
-}
+}
static CLASS_DEVICE_ATTR(model, S_IRUGO, show_model, NULL);
static ssize_t show_bridge(struct class_device *cd, char *buf)
{
struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", symbolic(brglist, ov->bridge));
-}
+}
static CLASS_DEVICE_ATTR(bridge, S_IRUGO, show_bridge, NULL);
static ssize_t show_sensor(struct class_device *cd, char *buf)
{
struct usb_ov511 *ov = cd_to_ov(cd);
return sprintf(buf, "%s\n", symbolic(senlist, ov->sensor));
-}
+}
static CLASS_DEVICE_ATTR(sensor, S_IRUGO, show_sensor, NULL);
static ssize_t show_brightness(struct class_device *cd, char *buf)
@@ -5597,7 +5597,7 @@ static ssize_t show_brightness(struct class_device *cd, char *buf)
return -ENODEV;
sensor_get_brightness(ov, &x);
return sprintf(buf, "%d\n", x >> 8);
-}
+}
static CLASS_DEVICE_ATTR(brightness, S_IRUGO, show_brightness, NULL);
static ssize_t show_saturation(struct class_device *cd, char *buf)
@@ -5609,7 +5609,7 @@ static ssize_t show_saturation(struct class_device *cd, char *buf)
return -ENODEV;
sensor_get_saturation(ov, &x);
return sprintf(buf, "%d\n", x >> 8);
-}
+}
static CLASS_DEVICE_ATTR(saturation, S_IRUGO, show_saturation, NULL);
static ssize_t show_contrast(struct class_device *cd, char *buf)
@@ -5621,7 +5621,7 @@ static ssize_t show_contrast(struct class_device *cd, char *buf)
return -ENODEV;
sensor_get_contrast(ov, &x);
return sprintf(buf, "%d\n", x >> 8);
-}
+}
static CLASS_DEVICE_ATTR(contrast, S_IRUGO, show_contrast, NULL);
static ssize_t show_hue(struct class_device *cd, char *buf)
@@ -5633,7 +5633,7 @@ static ssize_t show_hue(struct class_device *cd, char *buf)
return -ENODEV;
sensor_get_hue(ov, &x);
return sprintf(buf, "%d\n", x >> 8);
-}
+}
static CLASS_DEVICE_ATTR(hue, S_IRUGO, show_hue, NULL);
static ssize_t show_exposure(struct class_device *cd, char *buf)
@@ -5645,7 +5645,7 @@ static ssize_t show_exposure(struct class_device *cd, char *buf)
return -ENODEV;
sensor_get_exposure(ov, &exp);
return sprintf(buf, "%d\n", exp >> 8);
-}
+}
static CLASS_DEVICE_ATTR(exposure, S_IRUGO, show_exposure, NULL);
static void ov_create_sysfs(struct video_device *vdev)
diff --git a/drivers/usb/media/ov511.h b/drivers/media/video/ov511.h
index bce9b363388..12b3d51e1c3 100644
--- a/drivers/usb/media/ov511.h
+++ b/drivers/media/video/ov511.h
@@ -130,7 +130,7 @@
#define R511_COMP_QVY 0x76
#define R511_COMP_QVUV 0x77
#define R511_COMP_EN 0x78
-#define R511_COMP_LUT_EN 0x79
+#define R511_COMP_LUT_EN 0x79
#define R511_COMP_LUT_BEGIN 0x80
/* --------------------------------- */
@@ -459,14 +459,14 @@ struct usb_ov511 {
int subh; /* Pix Array subcapture height */
int curframe; /* Current receiving sbuf */
- struct ov511_frame frame[OV511_NUMFRAMES];
+ struct ov511_frame frame[OV511_NUMFRAMES];
struct ov511_sbuf sbuf[OV511_NUMSBUF];
wait_queue_head_t wq; /* Processes waiting */
int snap_enabled; /* Snapshot mode enabled */
-
+
int bridge; /* Type of bridge (BRG_*) */
int bclass; /* Class of bridge (BCL_*) */
int sensor; /* Type of image sensor chip (SEN_*) */
@@ -512,7 +512,7 @@ struct symbolic_list {
/* Returns the name of the matching element in the symbolic_list array. The
* end of the list must be marked with an element that has a NULL name.
*/
-static inline char *
+static inline char *
symbolic(struct symbolic_list list[], int num)
{
int i;
diff --git a/drivers/media/video/ovcamchip/Makefile b/drivers/media/video/ovcamchip/Makefile
index bca41ad93de..cba4cdf20f4 100644
--- a/drivers/media/video/ovcamchip/Makefile
+++ b/drivers/media/video/ovcamchip/Makefile
@@ -1,4 +1,4 @@
ovcamchip-objs := ovcamchip_core.o ov6x20.o ov6x30.o ov7x10.o ov7x20.o \
- ov76be.o
+ ov76be.o
obj-$(CONFIG_VIDEO_OVCAMCHIP) += ovcamchip.o
diff --git a/drivers/media/video/ovcamchip/ovcamchip_core.c b/drivers/media/video/ovcamchip/ovcamchip_core.c
index e76b53d5909..3fe9fa04cd8 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_core.c
+++ b/drivers/media/video/ovcamchip/ovcamchip_core.c
@@ -266,17 +266,17 @@ static int ovcamchip_detect(struct i2c_client *c)
PDEBUG(3, "Testing for 0V6xx0");
c->addr = OV6xx0_SID;
if (init_camchip(c) < 0) {
- return -ENODEV;
+ return -ENODEV;
} else {
if (ov6xx0_detect(c) < 0) {
PERROR("Failed to init OV6xx0");
- return -EIO;
+ return -EIO;
}
}
} else {
if (ov7xx0_detect(c) < 0) {
PERROR("Failed to init OV7xx0");
- return -EIO;
+ return -EIO;
}
}
diff --git a/drivers/media/video/ovcamchip/ovcamchip_priv.h b/drivers/media/video/ovcamchip/ovcamchip_priv.h
index 575e612a554..1231335a9f4 100644
--- a/drivers/media/video/ovcamchip/ovcamchip_priv.h
+++ b/drivers/media/video/ovcamchip/ovcamchip_priv.h
@@ -82,6 +82,6 @@ extern int ov_write_regvals(struct i2c_client *c,
struct ovcamchip_regvals *rvals);
extern int ov_write_mask(struct i2c_client *c, unsigned char reg,
- unsigned char value, unsigned char mask);
+ unsigned char value, unsigned char mask);
#endif
diff --git a/drivers/media/video/planb.c b/drivers/media/video/planb.c
index 15fd85acabd..522e9ddeb08 100644
--- a/drivers/media/video/planb.c
+++ b/drivers/media/video/planb.c
@@ -1,4 +1,4 @@
-/*
+/*
planb - PlanB frame grabber driver
PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -584,7 +584,7 @@ finish:
wake_up_interruptible(&pb->suspendq);
}
-static void add_clip(struct planb *pb, struct video_clip *clip)
+static void add_clip(struct planb *pb, struct video_clip *clip)
{
volatile unsigned char *base;
int xc = clip->x, yc = clip->y;
@@ -758,7 +758,7 @@ static void cmd_buff(struct planb *pb)
PLANB_SET(CH_SYNC));
tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
PLANB_SET(DMA_ABORT));
-
+
/* odd field data: */
jump = virt_to_bus(c1 + nlines / 2);
for (i=1; i < nlines; i += stepsize, c1++)
@@ -1247,7 +1247,7 @@ static volatile struct dbdma_cmd *setup_grab_cmd(int fr, struct planb *pb)
tab_cmd_dbdma(c1, DBDMA_NOP | BR_IFCLR, virt_to_bus(c1-3)); c1++;
tab_cmd_store(c1++, (unsigned)(&pb->planb_base_phys->ch1.br_sel),
PLANB_SET(DMA_ABORT));
-
+
/* odd field data: */
jump_addr = c1 + TAB_FACTOR * nlines / 2;
jump = virt_to_bus(jump_addr);
@@ -1383,7 +1383,7 @@ static int planb_open(struct video_device *dev, int mode)
pb->user++;
DEBUG("PlanB: device opened\n");
- return 0;
+ return 0;
}
static void planb_close(struct video_device *dev)
@@ -1424,9 +1424,9 @@ static long planb_write(struct video_device *v, const char *buf,
static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
{
struct planb *pb=(struct planb *)dev;
-
+
switch (cmd)
- {
+ {
case VIDIOCGCAP:
{
struct video_capability b;
@@ -1440,26 +1440,26 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
b.channels = 2; /* composite & svhs */
b.audios = 0;
b.maxwidth = PLANB_MAXPIXELS;
- b.maxheight = PLANB_MAXLINES;
- b.minwidth = 32; /* wild guess */
- b.minheight = 32;
- if (copy_to_user(arg,&b,sizeof(b)))
- return -EFAULT;
+ b.maxheight = PLANB_MAXLINES;
+ b.minwidth = 32; /* wild guess */
+ b.minheight = 32;
+ if (copy_to_user(arg,&b,sizeof(b)))
+ return -EFAULT;
return 0;
}
case VIDIOCSFBUF:
{
- struct video_buffer v;
+ struct video_buffer v;
unsigned short bpp;
unsigned int fmt;
DEBUG("PlanB: IOCTL VIDIOCSFBUF\n");
- if (!capable(CAP_SYS_ADMIN)
+ if (!capable(CAP_SYS_ADMIN)
|| !capable(CAP_SYS_RAWIO))
- return -EPERM;
- if (copy_from_user(&v, arg,sizeof(v)))
- return -EFAULT;
+ return -EPERM;
+ if (copy_from_user(&v, arg,sizeof(v)))
+ return -EFAULT;
planb_lock(pb);
switch(v.depth) {
case 8:
@@ -1478,7 +1478,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
break;
default:
planb_unlock(pb);
- return -EINVAL;
+ return -EINVAL;
}
if (bpp * v.width > v.bytesperline) {
planb_unlock(pb);
@@ -1493,7 +1493,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
pb->win.bpl = pb->win.bpp * pb->win.swidth;
pb->win.pad = v.bytesperline - pb->win.bpl;
- DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d,"
+ DEBUG("PlanB: Display at %p is %d by %d, bytedepth %d,"
" bpl %d (+ %d)\n", v.base, v.width,v.height,
pb->win.bpp, pb->win.bpl, pb->win.pad);
@@ -1504,11 +1504,11 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
resume_overlay(pb);
}
planb_unlock(pb);
- return 0;
+ return 0;
}
case VIDIOCGFBUF:
{
- struct video_buffer v;
+ struct video_buffer v;
DEBUG("PlanB: IOCTL VIDIOCGFBUF\n");
@@ -1518,15 +1518,15 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
v.depth = pb->win.depth;
v.bytesperline = pb->win.bpl + pb->win.pad;
if (copy_to_user(arg, &v, sizeof(v)))
- return -EFAULT;
+ return -EFAULT;
return 0;
}
case VIDIOCCAPTURE:
{
int i;
- if(copy_from_user(&i, arg, sizeof(i)))
- return -EFAULT;
+ if(copy_from_user(&i, arg, sizeof(i)))
+ return -EFAULT;
if(i==0) {
DEBUG("PlanB: IOCTL VIDIOCCAPTURE Stop\n");
@@ -1695,7 +1695,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
struct video_window vw;
struct video_clip clip;
int i;
-
+
DEBUG("PlanB: IOCTL VIDIOCSWIN\n");
if(copy_from_user(&vw,arg,sizeof(vw)))
@@ -1749,7 +1749,7 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
return -EFAULT;
return 0;
}
- case VIDIOCSYNC: {
+ case VIDIOCSYNC: {
int i;
IDEBUG("PlanB: IOCTL VIDIOCSYNC\n");
@@ -1759,42 +1759,42 @@ static int planb_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
IDEBUG("PlanB: sync to frame %d\n", i);
- if(i > (MAX_GBUFFERS - 1) || i < 0)
- return -EINVAL;
+ if(i > (MAX_GBUFFERS - 1) || i < 0)
+ return -EINVAL;
chk_grab:
- switch (pb->frame_stat[i]) {
- case GBUFFER_UNUSED:
- return -EINVAL;
+ switch (pb->frame_stat[i]) {
+ case GBUFFER_UNUSED:
+ return -EINVAL;
case GBUFFER_GRABBING:
IDEBUG("PlanB: waiting for grab"
" done (%d)\n", i);
- interruptible_sleep_on(&pb->capq);
+ interruptible_sleep_on(&pb->capq);
if(signal_pending(current))
return -EINTR;
goto chk_grab;
- case GBUFFER_DONE:
- pb->frame_stat[i] = GBUFFER_UNUSED;
- break;
- }
- return 0;
+ case GBUFFER_DONE:
+ pb->frame_stat[i] = GBUFFER_UNUSED;
+ break;
+ }
+ return 0;
}
- case VIDIOCMCAPTURE:
+ case VIDIOCMCAPTURE:
{
- struct video_mmap vm;
+ struct video_mmap vm;
volatile unsigned int status;
IDEBUG("PlanB: IOCTL VIDIOCMCAPTURE\n");
if(copy_from_user((void *) &vm,(void *)arg,sizeof(vm)))
return -EFAULT;
- status = pb->frame_stat[vm.frame];
- if (status != GBUFFER_UNUSED)
- return -EBUSY;
+ status = pb->frame_stat[vm.frame];
+ if (status != GBUFFER_UNUSED)
+ return -EBUSY;
- return vgrab(pb, &vm);
+ return vgrab(pb, &vm);
}
-
+
case VIDIOCGMBUF:
{
int i;
@@ -1811,7 +1811,7 @@ chk_grab:
return -EFAULT;
return 0;
}
-
+
case PLANBIOCGSAAREGS:
{
struct planb_saa_regs preg;
@@ -1828,7 +1828,7 @@ chk_grab:
return -EFAULT;
return 0;
}
-
+
case PLANBIOCSSAAREGS:
{
struct planb_saa_regs preg;
@@ -1842,7 +1842,7 @@ chk_grab:
saa_set (preg.addr, preg.val, pb);
return 0;
}
-
+
case PLANBIOCGSTAT:
{
struct planb_stat_regs pstat;
@@ -1859,7 +1859,7 @@ chk_grab:
return -EFAULT;
return 0;
}
-
+
case PLANBIOCSMODE: {
int v;
@@ -1985,10 +1985,10 @@ static int planb_mmap(struct vm_area_struct *vma, struct video_device *dev, cons
{
int i;
struct planb *pb = (struct planb *)dev;
- unsigned long start = (unsigned long)adr;
+ unsigned long start = (unsigned long)adr;
if (size > MAX_GBUFFERS * PLANB_MAX_FBUF)
- return -EINVAL;
+ return -EINVAL;
if (!pb->rawbuf) {
int err;
if((err=grabbuf_alloc(pb)))
@@ -2091,10 +2091,10 @@ static int init_planb(struct planb *pb)
/* clear interrupt mask */
pb->intr_mask = PLANB_CLR_IRQ;
- result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb);
- if (result < 0) {
- if (result==-EINVAL)
- printk(KERN_ERR "PlanB: Bad irq number (%d) "
+ result = request_irq(pb->irq, planb_irq, 0, "PlanB", (void *)pb);
+ if (result < 0) {
+ if (result==-EINVAL)
+ printk(KERN_ERR "PlanB: Bad irq number (%d) "
"or handler\n", (int)pb->irq);
else if (result==-EBUSY)
printk(KERN_ERR "PlanB: I don't know why, "
@@ -2102,7 +2102,7 @@ static int init_planb(struct planb *pb)
return result;
}
disable_irq(pb->irq);
-
+
/* Now add the template and register the device unit. */
memcpy(&pb->video_dev,&planb_template,sizeof(planb_template));
@@ -2143,7 +2143,7 @@ static int init_planb(struct planb *pb)
}
/*
- * Scan for a PlanB controller, request the irq and map the io memory
+ * Scan for a PlanB controller, request the irq and map the io memory
*/
static int find_planb(void)
@@ -2171,9 +2171,9 @@ static int find_planb(void)
pb = &planbs[0];
planb_num = 1;
- if (planb_devices->n_addrs != 1) {
- printk (KERN_WARNING "PlanB: expecting 1 address for planb "
- "(got %d)", planb_devices->n_addrs);
+ if (planb_devices->n_addrs != 1) {
+ printk (KERN_WARNING "PlanB: expecting 1 address for planb "
+ "(got %d)", planb_devices->n_addrs);
return 0;
}
@@ -2236,7 +2236,7 @@ static int find_planb(void)
pb->planb_base = planb_regs;
pb->planb_base_phys = (struct planb_registers *)new_base;
pb->irq = irq;
-
+
return planb_num;
err_out_disable:
@@ -2251,7 +2251,7 @@ static void release_planb(void)
int i;
struct planb *pb;
- for (i=0;i<planb_num; i++)
+ for (i=0;i<planb_num; i++)
{
pb=&planbs[i];
@@ -2278,7 +2278,7 @@ static void release_planb(void)
static int __init init_planbs(void)
{
int i;
-
+
if (find_planb()<=0)
return -EIO;
@@ -2288,9 +2288,9 @@ static int __init init_planbs(void)
" with v4l\n", i);
release_planb();
return -EIO;
- }
+ }
printk(KERN_INFO "PlanB: registered device %d with v4l\n", i);
- }
+ }
return 0;
}
diff --git a/drivers/media/video/planb.h b/drivers/media/video/planb.h
index 79b6b561426..92823211d0c 100644
--- a/drivers/media/video/planb.h
+++ b/drivers/media/video/planb.h
@@ -1,4 +1,4 @@
-/*
+/*
planb - PlanB frame grabber driver
PlanB is used in the 7x00/8x00 series of PowerMacintosh
@@ -167,7 +167,7 @@ struct planb {
struct video_device video_dev;
struct video_picture picture; /* Current picture params */
struct video_audio audio_dev; /* Current audio params */
-
+
volatile struct planb_registers *planb_base; /* virt base of planb */
struct planb_registers *planb_base_phys; /* phys base of planb */
void *priv_space; /* Org. alloc. mem for kfree */
@@ -209,7 +209,7 @@ struct planb {
int gwidth[MAX_GBUFFERS], gheight[MAX_GBUFFERS];
unsigned int gfmt[MAX_GBUFFERS];
int gnorm_switch[MAX_GBUFFERS];
- volatile unsigned int *frame_stat;
+ volatile unsigned int *frame_stat;
#define GBUFFER_UNUSED 0x00U
#define GBUFFER_GRABBING 0x01U
#define GBUFFER_DONE 0x02U
diff --git a/drivers/media/video/pms.c b/drivers/media/video/pms.c
index 05ca55939e7..09835ca098b 100644
--- a/drivers/media/video/pms.c
+++ b/drivers/media/video/pms.c
@@ -12,10 +12,10 @@
* Most of this code is directly derived from his userspace driver.
* His driver works so send any reports to alan@redhat.com unless the
* userspace driver also doesn't work for you...
- *
+ *
* Changes:
* 08/07/2003 Daniele Bellucci <bellucda@tiscali.it>
- * - pms_capture: report back -EFAULT
+ * - pms_capture: report back -EFAULT
*/
#include <linux/module.h>
@@ -66,14 +66,14 @@ static int standard = 0; /* 0 - auto 1 - ntsc 2 - pal 3 - secam */
/*
* I/O ports and Shared Memory
*/
-
+
static int io_port = 0x250;
static int data_port = 0x251;
static int mem_base = 0xC8000;
static void __iomem *mem;
static int video_nr = -1;
-
+
static inline void mvv_write(u8 index, u8 value)
{
@@ -90,9 +90,9 @@ static int pms_i2c_stat(u8 slave)
{
int counter;
int i;
-
+
outb(0x28, io_port);
-
+
counter=0;
while((inb(data_port)&0x01)==0)
if(counter++==256)
@@ -101,9 +101,9 @@ static int pms_i2c_stat(u8 slave)
while((inb(data_port)&0x01)!=0)
if(counter++==256)
break;
-
+
outb(slave, io_port);
-
+
counter=0;
while((inb(data_port)&0x01)==0)
if(counter++==256)
@@ -112,7 +112,7 @@ static int pms_i2c_stat(u8 slave)
while((inb(data_port)&0x01)!=0)
if(counter++==256)
break;
-
+
for(i=0;i<12;i++)
{
char st=inb(data_port);
@@ -122,7 +122,7 @@ static int pms_i2c_stat(u8 slave)
break;
}
outb(0x29, io_port);
- return inb(data_port);
+ return inb(data_port);
}
static int pms_i2c_write(u16 slave, u16 sub, u16 data)
@@ -130,19 +130,19 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
int skip=0;
int count;
int i;
-
+
for(i=0;i<i2c_count;i++)
{
if((i2cinfo[i].slave==slave) &&
(i2cinfo[i].sub == sub))
{
- if(i2cinfo[i].data==data)
- skip=1;
- i2cinfo[i].data=data;
- i=i2c_count+1;
+ if(i2cinfo[i].data==data)
+ skip=1;
+ i2cinfo[i].data=data;
+ i=i2c_count+1;
}
}
-
+
if(i==i2c_count && i2c_count<64)
{
i2cinfo[i2c_count].slave=slave;
@@ -150,16 +150,16 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
i2cinfo[i2c_count].data=data;
i2c_count++;
}
-
+
if(skip)
return 0;
-
+
mvv_write(0x29, sub);
mvv_write(0x2A, data);
mvv_write(0x28, slave);
-
+
outb(0x28, io_port);
-
+
count=0;
while((inb(data_port)&1)==0)
if(count>255)
@@ -167,9 +167,9 @@ static int pms_i2c_write(u16 slave, u16 sub, u16 data)
while((inb(data_port)&1)!=0)
if(count>255)
break;
-
+
count=inb(data_port);
-
+
if(count&2)
return -1;
return count;
@@ -189,8 +189,8 @@ static int pms_i2c_read(int slave, int sub)
static void pms_i2c_andor(int slave, int sub, int and, int or)
{
- u8 tmp;
-
+ u8 tmp;
+
tmp=pms_i2c_read(slave, sub);
tmp = (tmp&and)|or;
pms_i2c_write(slave, sub, tmp);
@@ -199,7 +199,7 @@ static void pms_i2c_andor(int slave, int sub, int and, int or)
/*
* Control functions
*/
-
+
static void pms_videosource(short source)
{
@@ -234,8 +234,8 @@ static void pms_colour(short colour)
break;
}
}
-
-
+
+
static void pms_contrast(short contrast)
{
switch(decoder)
@@ -269,14 +269,14 @@ static void pms_format(short format)
{
int target;
standard = format;
-
+
if(decoder==PHILIPS1)
target=0x42;
else if(decoder==PHILIPS2)
target=0x8A;
else
return;
-
+
switch(format)
{
case 0: /* Auto */
@@ -302,7 +302,7 @@ static void pms_format(short format)
/*
* These features of the PMS card are not currently exposes. They
- * could become a private v4l ioctl for PMSCONFIG or somesuch if
+ * could become a private v4l ioctl for PMSCONFIG or somesuch if
* people need it. We also don't yet use the PMS interrupt.
*/
@@ -324,7 +324,7 @@ static void pms_hstart(short start)
/*
* Bandpass filters
*/
-
+
static void pms_bandpass(short pass)
{
if(decoder==PHILIPS2)
@@ -493,7 +493,7 @@ static void pms_vert(u8 deciden, u8 decinum)
/*
* Turn 16bit ratios into best small ratio the chipset can grok
*/
-
+
static void pms_vertdeci(unsigned short decinum, unsigned short deciden)
{
/* Knock it down by /5 once */
@@ -546,7 +546,7 @@ static void pms_horzdeci(short decinum, short deciden)
decinum=512;
deciden=640; /* 768 would be ideal */
}
-
+
while(((decinum|deciden)&1)==0)
{
decinum>>=1;
@@ -559,7 +559,7 @@ static void pms_horzdeci(short decinum, short deciden)
}
if(deciden==32)
deciden--;
-
+
mvv_write(0x24, 0x80|deciden);
mvv_write(0x25, decinum);
}
@@ -567,14 +567,14 @@ static void pms_horzdeci(short decinum, short deciden)
static void pms_resolution(short width, short height)
{
int fg_height;
-
+
fg_height=height;
if(fg_height>280)
fg_height=280;
-
+
mvv_write(0x18, fg_height);
mvv_write(0x19, fg_height>>8);
-
+
if(standard==1)
{
mvv_write(0x1A, 0xFC);
@@ -598,7 +598,7 @@ static void pms_resolution(short width, short height)
mvv_write(0x42, 0x00);
mvv_write(0x43, 0x00);
mvv_write(0x44, MVVMEMORYWIDTH);
-
+
mvv_write(0x22, width+8);
mvv_write(0x23, (width+8)>> 8);
@@ -618,7 +618,7 @@ static void pms_resolution(short width, short height)
/*
* Set Input
*/
-
+
static void pms_vcrinput(short input)
{
if(decoder==PHILIPS2)
@@ -643,20 +643,20 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
mvv_write(0x08,r8); /* capture rgb555/565, init DRAM, PC enable */
/* printf("%d %d %d %d %d %x %x\n",width,height,voff,nom,den,mvv_buf); */
-
- for (y = 0; y < dev->height; y++ )
+
+ for (y = 0; y < dev->height; y++ )
{
writeb(0, mem); /* synchronisiert neue Zeile */
-
+
/*
* This is in truth a fifo, be very careful as if you
* forgot this odd things will occur 8)
*/
-
+
memcpy_fromio(tmp, mem, dw+32); /* discard 16 word */
cnt -= dev->height;
- while (cnt <= 0)
- {
+ while (cnt <= 0)
+ {
/*
* Don't copy too far
*/
@@ -666,7 +666,7 @@ static int pms_capture(struct pms_device *dev, char __user *buf, int rgb555, int
cnt += dev->height;
if (copy_to_user(buf, tmp+32, dt))
return len ? len : -EFAULT;
- buf += dt;
+ buf += dt;
len += dt;
}
}
@@ -683,7 +683,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
{
struct video_device *dev = video_devdata(file);
struct pms_device *pd=(struct pms_device *)dev;
-
+
switch(cmd)
{
case VIDIOCGCAP:
@@ -806,7 +806,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
||(p->palette==VIDEO_PALETTE_RGB555 && p->depth==15)))
return -EINVAL;
pd->picture= *p;
-
+
/*
* Now load the card.
*/
@@ -815,7 +815,7 @@ static int pms_do_ioctl(struct inode *inode, struct file *file,
pms_brightness(p->brightness>>8);
pms_hue(p->hue>>8);
pms_colour(p->colour>>8);
- pms_contrast(p->contrast>>8);
+ pms_contrast(p->contrast>>8);
mutex_unlock(&pd->lock);
return 0;
}
@@ -873,7 +873,7 @@ static ssize_t pms_read(struct file *file, char __user *buf,
struct video_device *v = video_devdata(file);
struct pms_device *pd=(struct pms_device *)v;
int len;
-
+
mutex_lock(&pd->lock);
len=pms_capture(pd, buf, (pd->picture.depth==16)?0:1,count);
mutex_unlock(&pd->lock);
@@ -905,13 +905,13 @@ static struct pms_device pms_device;
/*
* Probe for and initialise the Mediavision PMS
*/
-
+
static int init_mediavision(void)
{
int id;
int idec, decst;
int i;
-
+
unsigned char i2c_defs[]={
0x4C,0x30,0x00,0xE8,
0xB6,0xE2,0x00,0x00,
@@ -925,7 +925,7 @@ static int init_mediavision(void)
mem = ioremap(mem_base, 0x800);
if (!mem)
return -ENOMEM;
-
+
if (!request_region(0x9A01, 1, "Mediavision PMS config"))
{
printk(KERN_WARNING "mediavision: unable to detect: 0x9A01 in use.\n");
@@ -941,18 +941,18 @@ static int init_mediavision(void)
}
outb(0xB8, 0x9A01); /* Unlock */
outb(io_port>>4, 0x9A01); /* Set IO port */
-
-
+
+
id=mvv_read(3);
decst=pms_i2c_stat(0x43);
-
+
if(decst!=-1)
idec=2;
else if(pms_i2c_stat(0xb9)!=-1)
idec=3;
else if(pms_i2c_stat(0x8b)!=-1)
idec=1;
- else
+ else
idec=0;
printk(KERN_INFO "PMS type is %d\n", idec);
@@ -966,11 +966,11 @@ static int init_mediavision(void)
/*
* Ok we have a PMS of some sort
*/
-
+
mvv_write(0x04, mem_base>>12); /* Set the memory area */
-
+
/* Ok now load the defaults */
-
+
for(i=0;i<0x19;i++)
{
if(i2c_defs[i]==0xFF)
@@ -978,7 +978,7 @@ static int init_mediavision(void)
else
pms_i2c_write(0x8A, i, i2c_defs[i]);
}
-
+
pms_i2c_write(0xB8,0x00,0x12);
pms_i2c_write(0xB8,0x04,0x00);
pms_i2c_write(0xB8,0x07,0x00);
@@ -987,18 +987,18 @@ static int init_mediavision(void)
pms_i2c_write(0xB8,0x0A,0x00);
pms_i2c_write(0xB8,0x0B,0x10);
pms_i2c_write(0xB8,0x10,0x03);
-
+
mvv_write(0x01, 0x00);
mvv_write(0x05, 0xA0);
mvv_write(0x08, 0x25);
mvv_write(0x09, 0x00);
- mvv_write(0x0A, 0x20|MVVMEMORYWIDTH);
-
+ mvv_write(0x0A, 0x20|MVVMEMORYWIDTH);
+
mvv_write(0x10, 0x02);
mvv_write(0x1E, 0x0C);
mvv_write(0x1F, 0x03);
mvv_write(0x26, 0x06);
-
+
mvv_write(0x2B, 0x00);
mvv_write(0x2C, 0x20);
mvv_write(0x2D, 0x00);
@@ -1018,13 +1018,13 @@ static int init_mediavision(void)
/*
* Initialization and module stuff
*/
-
+
static int __init init_pms_cards(void)
{
printk(KERN_INFO "Mediavision Pro Movie Studio driver 0.02\n");
-
+
data_port = io_port +1;
-
+
if(init_mediavision())
{
printk(KERN_INFO "Board not found.\n");
diff --git a/drivers/usb/media/pwc/Makefile b/drivers/media/video/pwc/Makefile
index 2d93a775011..8326684f49f 100644
--- a/drivers/usb/media/pwc/Makefile
+++ b/drivers/media/video/pwc/Makefile
@@ -15,6 +15,6 @@ default:
endif
clean:
- rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
+ rm -f *.[oas] .*.flags *.ko .*.cmd .*.d .*.tmp *.mod.c
rm -rf .tmp_versions
diff --git a/drivers/usb/media/pwc/philips.txt b/drivers/media/video/pwc/philips.txt
index 04a640d723e..11f751a6bda 100644
--- a/drivers/usb/media/pwc/philips.txt
+++ b/drivers/media/video/pwc/philips.txt
@@ -47,17 +47,17 @@ don't know how to set it properly in the driver. The options are:
size
Can be one of 'sqcif', 'qsif', 'qcif', 'sif', 'cif' or
'vga', for an image size of resp. 128x96, 160x120, 176x144,
- 320x240, 352x288 and 640x480 (of course, only for those cameras that
+ 320x240, 352x288 and 640x480 (of course, only for those cameras that
support these resolutions).
fps
Specifies the desired framerate. Is an integer in the range of 4-30.
fbufs
- This paramter specifies the number of internal buffers to use for storing
- frames from the cam. This will help if the process that reads images from
- the cam is a bit slow or momentarely busy. However, on slow machines it
- only introduces lag, so choose carefully. The default is 3, which is
+ This paramter specifies the number of internal buffers to use for storing
+ frames from the cam. This will help if the process that reads images from
+ the cam is a bit slow or momentarely busy. However, on slow machines it
+ only introduces lag, so choose carefully. The default is 3, which is
reasonable. You can set it between 2 and 5.
mbufs
@@ -65,9 +65,9 @@ mbufs
buffers to reserve for mmap(), VIDIOCCGMBUF, VIDIOCMCAPTURE and friends.
The default is 2, which is adequate for most applications (double
buffering).
-
+
Should you experience a lot of 'Dumping frame...' messages during
- grabbing with a tool that uses mmap(), you might want to increase if.
+ grabbing with a tool that uses mmap(), you might want to increase if.
However, it doesn't really buffer images, it just gives you a bit more
slack when your program is behind. But you need a multi-threaded or
forked program to really take advantage of these buffers.
@@ -88,15 +88,15 @@ power_save
compression (only useful with the plugin)
With this option you can control the compression factor that the camera
- uses to squeeze the image through the USB bus. You can set the
+ uses to squeeze the image through the USB bus. You can set the
parameter between 0 and 3:
0 = prefer uncompressed images; if the requested mode is not available
- in an uncompressed format, the driver will silently switch to low
- compression.
+ in an uncompressed format, the driver will silently switch to low
+ compression.
1 = low compression.
2 = medium compression.
3 = high compression.
-
+
High compression takes less bandwidth of course, but it could also
introduce some unwanted artefacts. The default is 2, medium compression.
See the FAQ on the website for an overview of which modes require
@@ -112,7 +112,7 @@ leds
this is let the LED blink while the camera is in use. This:
leds=500,500
-
+
will blink the LED once every second. But with:
leds=0,0
@@ -123,7 +123,7 @@ leds
when the camera is not used anymore.
This parameter works only with the ToUCam range of cameras (720, 730, 740,
- 750) and OEMs. For other cameras this command is silently ignored, and
+ 750) and OEMs. For other cameras this command is silently ignored, and
the LED cannot be controlled.
Finally: this parameters does not take effect UNTIL the first time you
@@ -144,35 +144,35 @@ dev_hint
format:
[type[.serialnumber]:]node
-
+
The square brackets mean that both the type and the serialnumber are
optional, but a serialnumber cannot be specified without a type (which
would be rather pointless). The serialnumber is separated from the type
by a '.'; the node number by a ':'.
-
+
This somewhat cryptic syntax is best explained by a few examples:
dev_hint=3,5 The first detected cam gets assigned
- /dev/video3, the second /dev/video5. Any
- other cameras will get the first free
- available slot (see below).
+ /dev/video3, the second /dev/video5. Any
+ other cameras will get the first free
+ available slot (see below).
dev_hint=645:1,680:2 The PCA645 camera will get /dev/video1,
- and a PCVC680 /dev/video2.
-
- dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
- 0123 goes to /dev/video3, the same
- camera model with the 4567 serial
- gets /dev/video0.
+ and a PCVC680 /dev/video2.
+
+ dev_hint=645.0123:3,645.4567:0 The PCA645 camera with serialnumber
+ 0123 goes to /dev/video3, the same
+ camera model with the 4567 serial
+ gets /dev/video0.
- dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
- next 3 Philips cams will use /dev/video4
- through /dev/video6.
+ dev_hint=750:1,4,5,6 The PCVC750 camera will get /dev/video1, the
+ next 3 Philips cams will use /dev/video4
+ through /dev/video6.
Some points worth knowing:
- - Serialnumbers are case sensitive and must be written full, including
+ - Serialnumbers are case sensitive and must be written full, including
leading zeroes (it's treated as a string).
- - If a device node is already occupied, registration will fail and
+ - If a device node is already occupied, registration will fail and
the webcam is not available.
- You can have up to 64 video devices; be sure to make enough device
nodes in /dev if you want to spread the numbers (this does not apply
@@ -186,13 +186,13 @@ trace
kernel log at debug level.
The trace variable is a bitmask; each bit represents a certain feature.
- If you want to trace something, look up the bit value(s) in the table
+ If you want to trace something, look up the bit value(s) in the table
below, add the values together and supply that to the trace variable.
Value Value Description Default
(dec) (hex)
1 0x1 Module initialization; this will log messages On
- while loading and unloading the module
+ while loading and unloading the module
2 0x2 probe() and disconnect() traces On
@@ -203,7 +203,7 @@ trace
16 0x10 Memory allocation of buffers, etc. Off
32 0x20 Showing underflow, overflow and Dumping frame On
- messages
+ messages
64 0x40 Show viewport and image sizes Off
@@ -217,7 +217,7 @@ trace
Example:
-
+
# modprobe pwc size=cif fps=15 power_save=1
The fbufs, mbufs and trace parameters are global and apply to all connected
diff --git a/drivers/usb/media/pwc/pwc-ctrl.c b/drivers/media/video/pwc/pwc-ctrl.c
index 0398b812e0c..4ba549bfa0e 100644
--- a/drivers/usb/media/pwc/pwc-ctrl.c
+++ b/drivers/media/video/pwc/pwc-ctrl.c
@@ -31,17 +31,17 @@
/*
Changes
- 2001/08/03 Alvarado Added methods for changing white balance and
- red/green gains
+ 2001/08/03 Alvarado Added methods for changing white balance and
+ red/green gains
*/
/* Control functions for the cam; brightness, contrast, video mode, etc. */
#ifdef __KERNEL__
-#include <asm/uaccess.h>
+#include <asm/uaccess.h>
#endif
#include <asm/errno.h>
-
+
#include "pwc.h"
#include "pwc-ioctl.h"
#include "pwc-uncompress.h"
@@ -116,13 +116,13 @@ static const char *size2name[PSZ_MAX] =
"SIF",
"CIF",
"VGA",
-};
+};
/********/
-/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
+/* Entries for the Nala (645/646) camera; the Nala doesn't have compression
preferences, so you either get compressed or non-compressed streams.
-
+
An alternate value of 0 means this mode is not available at all.
*/
@@ -205,13 +205,13 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
{ /* closest match of framerate */
0, 0, 0, 0, 4, /* 0-4 */
5, 5, 7, 7, 10, /* 5-9 */
- 10, 10, 12, 12, 15, /* 10-14 */
- 15, 15, 15, 20, 20, /* 15-19 */
- 20, 20, 20, 24, 24, /* 20-24 */
- 24, 24, 24, 24, 24, /* 25-29 */
- 24 /* 30 */
+ 10, 10, 12, 12, 15, /* 10-14 */
+ 15, 15, 15, 20, 20, /* 15-19 */
+ 20, 20, 20, 24, 24, /* 20-24 */
+ 24, 24, 24, 24, 24, /* 25-29 */
+ 24 /* 30 */
};
- int frames2table[31] =
+ int frames2table[31] =
{ 0, 0, 0, 0, 0, /* 0-4 */
1, 1, 1, 2, 2, /* 5-9 */
3, 3, 4, 4, 4, /* 10-14 */
@@ -220,7 +220,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
7, 7, 7, 7, 7, /* 25-29 */
7 /* 30 */
};
-
+
if (size < 0 || size > PSZ_CIF || frames < 4 || frames > 25)
return -EINVAL;
frames = frames2frames[frames];
@@ -232,7 +232,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
if (pEntry->compressed)
return -ENOENT; /* Not supported. */
- memcpy(buf, pEntry->mode, 3);
+ memcpy(buf, pEntry->mode, 3);
ret = send_video_command(pdev->udev, pdev->vendpoint, buf, 3);
if (ret < 0) {
Debug("Failed to send video command... %d\n", ret);
@@ -257,7 +257,7 @@ static inline int set_video_mode_Nala(struct pwc_device *pdev, int size, int fra
break;
}
}
-
+
pdev->cmd_len = 3;
memcpy(pdev->cmd_buf, buf, 3);
@@ -352,13 +352,13 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
/* special case: VGA @ 5 fps and snapshot is raw bayer mode */
if (size == PSZ_VGA && frames == 5 && snapshot)
{
- /* Only available in case the raw palette is selected or
- we have the decompressor available. This mode is
- only available in compressed form
+ /* Only available in case the raw palette is selected or
+ we have the decompressor available. This mode is
+ only available in compressed form
*/
if (pdev->vpalette == VIDEO_PALETTE_RAW)
{
- Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
+ Info("Choosing VGA/5 BAYER mode (%d).\n", pdev->vpalette);
pChoose = &RawEntry;
}
else
@@ -368,9 +368,9 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
}
else
{
- /* Find a supported framerate with progressively higher compression ratios
+ /* Find a supported framerate with progressively higher compression ratios
if the preferred ratio is not available.
- Skip this step when using RAW modes.
+ Skip this step when using RAW modes.
*/
while (compression <= 3) {
pChoose = &Kiara_table[size][fps][compression];
@@ -383,7 +383,7 @@ static inline int set_video_mode_Kiara(struct pwc_device *pdev, int size, int fr
return -ENOENT; /* Not supported. */
Debug("Using alternate setting %d.\n", pChoose->alternate);
-
+
/* usb_control_msg won't take staticly allocated arrays as argument?? */
memcpy(buf, pChoose->mode, 12);
if (snapshot)
@@ -463,9 +463,9 @@ static void pwc_set_image_buffer_size(struct pwc_device *pdev)
*/
int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frames, int compression, int snapshot)
{
- int ret, size;
+ int ret, size;
- Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
+ Trace(TRACE_FLOW, "set_video_mode(%dx%d @ %d, palette %d).\n", width, height, frames, pdev->vpalette);
size = pwc_decode_size(pdev, width, height);
if (size < 0) {
Debug("Could not find suitable size.\n");
@@ -473,7 +473,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
}
Debug("decode_size = %d.\n", size);
- ret = -EINVAL;
+ ret = -EINVAL;
switch(pdev->type) {
case 645:
case 646:
@@ -485,7 +485,7 @@ int pwc_set_video_mode(struct pwc_device *pdev, int width, int height, int frame
case 690:
ret = set_video_mode_Timon(pdev, size, frames, compression, snapshot);
break;
-
+
case 720:
case 730:
case 740:
@@ -517,7 +517,7 @@ int pwc_get_brightness(struct pwc_device *pdev)
char buf;
int ret;
- ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
+ ret = RecvControlMsg(GET_LUM_CTL, BRIGHTNESS_FORMATTER, 1);
if (ret < 0)
return ret;
return buf << 9;
@@ -566,7 +566,7 @@ int pwc_get_gamma(struct pwc_device *pdev)
{
char buf;
int ret;
-
+
ret = RecvControlMsg(GET_LUM_CTL, GAMMA_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -622,14 +622,14 @@ static inline int pwc_set_agc(struct pwc_device *pdev, int mode, int value)
{
char buf;
int ret;
-
+
if (mode)
buf = 0x0; /* auto */
else
buf = 0xff; /* fixed */
ret = SendControlMsg(SET_LUM_CTL, AGC_MODE_FORMATTER, 1);
-
+
if (!mode && ret >= 0) {
if (value < 0)
value = 0;
@@ -647,7 +647,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_LUM_CTL, AGC_MODE_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -658,7 +658,7 @@ static inline int pwc_get_agc(struct pwc_device *pdev, int *value)
return ret;
if (buf > 0x3F)
buf = 0x3F;
- *value = (buf << 10);
+ *value = (buf << 10);
}
else { /* auto */
ret = RecvControlMsg(GET_STATUS_CTL, READ_AGC_FORMATTER, 1);
@@ -683,7 +683,7 @@ static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int v
buf[0] = 0x0; /* auto */
else
buf[0] = 0xff; /* fixed */
-
+
ret = SendControlMsg(SET_LUM_CTL, SHUTTER_MODE_FORMATTER, 1);
if (!mode && ret >= 0) {
@@ -713,7 +713,7 @@ static inline int pwc_set_shutter_speed(struct pwc_device *pdev, int mode, int v
ret = SendControlMsg(SET_LUM_CTL, PRESET_SHUTTER_FORMATTER, 2);
}
return ret;
-}
+}
/* POWER */
@@ -765,22 +765,22 @@ static inline int pwc_restore_factory(struct pwc_device *pdev)
* 02: fluorescent lighting
* 03: manual
* 04: auto
- */
+ */
static inline int pwc_set_awb(struct pwc_device *pdev, int mode)
{
char buf;
int ret;
-
+
if (mode < 0)
mode = 0;
-
+
if (mode > 4)
mode = 4;
-
+
buf = mode & 0x07; /* just the lowest three bits */
-
+
ret = SendControlMsg(SET_CHROM_CTL, WB_MODE_FORMATTER, 1);
-
+
if (ret < 0)
return ret;
return 0;
@@ -790,17 +790,17 @@ static inline int pwc_get_awb(struct pwc_device *pdev)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_CHROM_CTL, WB_MODE_FORMATTER, 1);
- if (ret < 0)
+ if (ret < 0)
return ret;
return buf;
}
static inline int pwc_set_red_gain(struct pwc_device *pdev, int value)
{
- unsigned char buf;
+ unsigned char buf;
if (value < 0)
value = 0;
@@ -815,7 +815,7 @@ static inline int pwc_get_red_gain(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_RED_GAIN_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -841,7 +841,7 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_CHROM_CTL, PRESET_MANUAL_BLUE_GAIN_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -851,14 +851,14 @@ static inline int pwc_get_blue_gain(struct pwc_device *pdev, int *value)
/* The following two functions are different, since they only read the
- internal red/blue gains, which may be different from the manual
+ internal red/blue gains, which may be different from the manual
gains set or read above.
- */
+ */
static inline int pwc_read_red_gain(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_STATUS_CTL, READ_RED_GAIN_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -870,7 +870,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_STATUS_CTL, READ_BLUE_GAIN_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -882,7 +882,7 @@ static inline int pwc_read_blue_gain(struct pwc_device *pdev, int *value)
static inline int pwc_set_wb_speed(struct pwc_device *pdev, int speed)
{
unsigned char buf;
-
+
/* useful range is 0x01..0x20 */
buf = speed / 0x7f0;
return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
@@ -892,7 +892,7 @@ static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_SPEED_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -904,7 +904,7 @@ static inline int pwc_get_wb_speed(struct pwc_device *pdev, int *value)
static inline int pwc_set_wb_delay(struct pwc_device *pdev, int delay)
{
unsigned char buf;
-
+
/* useful range is 0x01..0x3F */
buf = (delay >> 10);
return SendControlMsg(SET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
@@ -914,7 +914,7 @@ static inline int pwc_get_wb_delay(struct pwc_device *pdev, int *value)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_CHROM_CTL, AWB_CONTROL_DELAY_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -950,7 +950,7 @@ static int pwc_get_leds(struct pwc_device *pdev, int *on_value, int *off_value)
{
unsigned char buf[2];
int ret;
-
+
if (pdev->type < 730) {
*on_value = -1;
*off_value = -1;
@@ -969,7 +969,7 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
{
unsigned char buf;
int ret;
-
+
if (contour < 0)
buf = 0xff; /* auto contour on */
else
@@ -977,16 +977,16 @@ static inline int pwc_set_contour(struct pwc_device *pdev, int contour)
ret = SendControlMsg(SET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
if (ret < 0)
return ret;
-
+
if (contour < 0)
return 0;
if (contour > 0xffff)
contour = 0xffff;
-
+
buf = (contour >> 10); /* contour preset is [0..3f] */
ret = SendControlMsg(SET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
- if (ret < 0)
- return ret;
+ if (ret < 0)
+ return ret;
return 0;
}
@@ -994,7 +994,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
{
unsigned char buf;
int ret;
-
+
ret = RecvControlMsg(GET_LUM_CTL, AUTO_CONTOUR_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -1002,7 +1002,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
if (buf == 0) {
/* auto mode off, query current preset value */
ret = RecvControlMsg(GET_LUM_CTL, PRESET_CONTOUR_FORMATTER, 1);
- if (ret < 0)
+ if (ret < 0)
return ret;
*contour = buf << 10;
}
@@ -1015,7 +1015,7 @@ static inline int pwc_get_contour(struct pwc_device *pdev, int *contour)
static inline int pwc_set_backlight(struct pwc_device *pdev, int backlight)
{
unsigned char buf;
-
+
if (backlight)
buf = 0xff;
else
@@ -1027,7 +1027,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
{
int ret;
unsigned char buf;
-
+
ret = RecvControlMsg(GET_LUM_CTL, BACK_LIGHT_COMPENSATION_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -1039,7 +1039,7 @@ static inline int pwc_get_backlight(struct pwc_device *pdev, int *backlight)
static inline int pwc_set_flicker(struct pwc_device *pdev, int flicker)
{
unsigned char buf;
-
+
if (flicker)
buf = 0xff;
else
@@ -1051,7 +1051,7 @@ static inline int pwc_get_flicker(struct pwc_device *pdev, int *flicker)
{
int ret;
unsigned char buf;
-
+
ret = RecvControlMsg(GET_LUM_CTL, FLICKERLESS_MODE_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -1076,7 +1076,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
{
int ret;
unsigned char buf;
-
+
ret = RecvControlMsg(GET_LUM_CTL, DYNAMIC_NOISE_CONTROL_FORMATTER, 1);
if (ret < 0)
return ret;
@@ -1087,7 +1087,7 @@ static inline int pwc_get_dynamic_noise(struct pwc_device *pdev, int *noise)
static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
{
unsigned char buf;
-
+
buf = flags & 0x03; // only lower two bits are currently used
return SendControlMsg(SET_MPT_CTL, PT_RESET_CONTROL_FORMATTER, 1);
}
@@ -1095,7 +1095,7 @@ static int pwc_mpt_reset(struct pwc_device *pdev, int flags)
static inline int pwc_mpt_set_angle(struct pwc_device *pdev, int pan, int tilt)
{
unsigned char buf[4];
-
+
/* set new relative angle; angles are expressed in degrees * 100,
but cam as .5 degree resolution, hence divide by 200. Also
the angle must be multiplied by 64 before it's send to
@@ -1114,7 +1114,7 @@ static inline int pwc_mpt_get_status(struct pwc_device *pdev, struct pwc_mpt_sta
{
int ret;
unsigned char buf[5];
-
+
ret = RecvControlMsg(GET_MPT_CTL, PT_STATUS_FORMATTER, 5);
if (ret < 0)
return ret;
@@ -1129,14 +1129,14 @@ int pwc_get_cmos_sensor(struct pwc_device *pdev, int *sensor)
{
unsigned char buf;
int ret = -1, request;
-
+
if (pdev->type < 675)
request = SENSOR_TYPE_FORMATTER1;
else if (pdev->type < 730)
return -1; /* The Vesta series doesn't have this call */
else
request = SENSOR_TYPE_FORMATTER2;
-
+
ret = RecvControlMsg(GET_STATUS_CTL, request, 1);
if (ret < 0)
return ret;
@@ -1163,23 +1163,23 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = -EINVAL;
break;
}
-
+
case VIDIOCPWCSUSER:
{
if (pwc_save_user(pdev))
ret = -EINVAL;
break;
}
-
+
case VIDIOCPWCFACTORY:
{
if (pwc_restore_factory(pdev))
ret = -EINVAL;
break;
}
-
+
case VIDIOCPWCSCQUAL:
- {
+ {
int *qual = arg;
if (*qual < 0 || *qual > 3)
@@ -1190,14 +1190,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
pdev->vcompression = *qual;
break;
}
-
+
case VIDIOCPWCGCQUAL:
{
int *qual = arg;
*qual = pdev->vcompression;
break;
}
-
+
case VIDIOCPWCPROBE:
{
struct pwc_probe *probe = arg;
@@ -1220,27 +1220,27 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = -EINVAL;
break;
}
-
+
case VIDIOCPWCGAGC:
{
int *agc = arg;
-
+
if (pwc_get_agc(pdev, agc))
ret = -EINVAL;
break;
}
-
+
case VIDIOCPWCSSHUTTER:
{
int *shutter_speed = arg;
ret = pwc_set_shutter_speed(pdev, *shutter_speed < 0 ? 1 : 0, *shutter_speed);
break;
}
-
- case VIDIOCPWCSAWB:
+
+ case VIDIOCPWCSAWB:
{
struct pwc_whitebalance *wb = arg;
-
+
ret = pwc_set_awb(pdev, wb->mode);
if (ret >= 0 && wb->mode == PWC_WB_MANUAL) {
pwc_set_red_gain(pdev, wb->manual_red);
@@ -1270,18 +1270,18 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = pwc_read_red_gain(pdev, &wb->read_red);
if (ret < 0)
break;
- ret = pwc_read_blue_gain(pdev, &wb->read_blue);
- if (ret < 0)
- break;
+ ret = pwc_read_blue_gain(pdev, &wb->read_blue);
+ if (ret < 0)
+ break;
}
}
break;
}
-
+
case VIDIOCPWCSAWBSPEED:
{
struct pwc_wb_speed *wbs = arg;
-
+
if (wbs->control_speed > 0) {
ret = pwc_set_wb_speed(pdev, wbs->control_speed);
}
@@ -1290,11 +1290,11 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
}
break;
}
-
+
case VIDIOCPWCGAWBSPEED:
{
struct pwc_wb_speed *wbs = arg;
-
+
ret = pwc_get_wb_speed(pdev, &wbs->control_speed);
if (ret < 0)
break;
@@ -1304,7 +1304,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
break;
}
- case VIDIOCPWCSLED:
+ case VIDIOCPWCSLED:
{
struct pwc_leds *leds = arg;
ret = pwc_set_leds(pdev, leds->led_on, leds->led_off);
@@ -1325,14 +1325,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = pwc_set_contour(pdev, *contour);
break;
}
-
+
case VIDIOCPWCGCONTOUR:
{
int *contour = arg;
ret = pwc_get_contour(pdev, contour);
break;
}
-
+
case VIDIOCPWCSBACKLIGHT:
{
int *backlight = arg;
@@ -1346,7 +1346,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = pwc_get_backlight(pdev, backlight);
break;
}
-
+
case VIDIOCPWCSFLICKER:
{
int *flicker = arg;
@@ -1360,14 +1360,14 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = pwc_get_flicker(pdev, flicker);
break;
}
-
+
case VIDIOCPWCSDYNNOISE:
{
int *dynnoise = arg;
ret = pwc_set_dynamic_noise(pdev, *dynnoise);
break;
}
-
+
case VIDIOCPWCGDYNNOISE:
{
int *dynnoise = arg;
@@ -1381,61 +1381,61 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
size->width = pdev->image.x;
size->height = pdev->image.y;
break;
- }
-
- case VIDIOCPWCMPTRESET:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- int *flags = arg;
+ }
+
+ case VIDIOCPWCMPTRESET:
+ {
+ if (pdev->features & FEATURE_MOTOR_PANTILT)
+ {
+ int *flags = arg;
ret = pwc_mpt_reset(pdev, *flags);
- if (ret >= 0)
- {
- pdev->pan_angle = 0;
- pdev->tilt_angle = 0;
- }
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTGRANGE:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- struct pwc_mpt_range *range = arg;
- *range = pdev->angle_range;
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTSANGLE:
- {
- int new_pan, new_tilt;
-
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- struct pwc_mpt_angles *angles = arg;
+ if (ret >= 0)
+ {
+ pdev->pan_angle = 0;
+ pdev->tilt_angle = 0;
+ }
+ }
+ else
+ {
+ ret = -ENXIO;
+ }
+ break;
+ }
+
+ case VIDIOCPWCMPTGRANGE:
+ {
+ if (pdev->features & FEATURE_MOTOR_PANTILT)
+ {
+ struct pwc_mpt_range *range = arg;
+ *range = pdev->angle_range;
+ }
+ else
+ {
+ ret = -ENXIO;
+ }
+ break;
+ }
+
+ case VIDIOCPWCMPTSANGLE:
+ {
+ int new_pan, new_tilt;
+
+ if (pdev->features & FEATURE_MOTOR_PANTILT)
+ {
+ struct pwc_mpt_angles *angles = arg;
/* The camera can only set relative angles, so
do some calculations when getting an absolute angle .
*/
if (angles->absolute)
{
- new_pan = angles->pan;
- new_tilt = angles->tilt;
- }
- else
- {
- new_pan = pdev->pan_angle + angles->pan;
- new_tilt = pdev->tilt_angle + angles->tilt;
+ new_pan = angles->pan;
+ new_tilt = angles->tilt;
+ }
+ else
+ {
+ new_pan = pdev->pan_angle + angles->pan;
+ new_tilt = pdev->tilt_angle + angles->tilt;
}
/* check absolute ranges */
if (new_pan < pdev->angle_range.pan_min ||
@@ -1463,53 +1463,53 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
pdev->tilt_angle += new_tilt;
}
if (ret == -EPIPE) /* stall -> out of range */
- ret = -ERANGE;
+ ret = -ERANGE;
}
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTGANGLE:
- {
-
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- struct pwc_mpt_angles *angles = arg;
-
- angles->absolute = 1;
- angles->pan = pdev->pan_angle;
- angles->tilt = pdev->tilt_angle;
- }
- else
- {
- ret = -ENXIO;
- }
- break;
- }
-
- case VIDIOCPWCMPTSTATUS:
- {
- if (pdev->features & FEATURE_MOTOR_PANTILT)
- {
- struct pwc_mpt_status *status = arg;
- ret = pwc_mpt_get_status(pdev, status);
- }
- else
- {
- ret = -ENXIO;
- }
- break;
+ }
+ else
+ {
+ ret = -ENXIO;
+ }
+ break;
+ }
+
+ case VIDIOCPWCMPTGANGLE:
+ {
+
+ if (pdev->features & FEATURE_MOTOR_PANTILT)
+ {
+ struct pwc_mpt_angles *angles = arg;
+
+ angles->absolute = 1;
+ angles->pan = pdev->pan_angle;
+ angles->tilt = pdev->tilt_angle;
+ }
+ else
+ {
+ ret = -ENXIO;
+ }
+ break;
+ }
+
+ case VIDIOCPWCMPTSTATUS:
+ {
+ if (pdev->features & FEATURE_MOTOR_PANTILT)
+ {
+ struct pwc_mpt_status *status = arg;
+ ret = pwc_mpt_get_status(pdev, status);
+ }
+ else
+ {
+ ret = -ENXIO;
+ }
+ break;
}
case VIDIOCPWCGVIDCMD:
{
struct pwc_video_command *cmd = arg;
-
- cmd->type = pdev->type;
+
+ cmd->type = pdev->type;
cmd->release = pdev->release;
cmd->command_len = pdev->cmd_len;
memcpy(&cmd->command_buf, pdev->cmd_buf, pdev->cmd_len);
@@ -1531,7 +1531,7 @@ int pwc_ioctl(struct pwc_device *pdev, unsigned int cmd, void *arg)
ret = -ENOIOCTLCMD;
break;
}
-
+
if (ret > 0)
return 0;
return ret;
diff --git a/drivers/usb/media/pwc/pwc-if.c b/drivers/media/video/pwc/pwc-if.c
index 90eb2604281..41418294a32 100644
--- a/drivers/usb/media/pwc/pwc-if.c
+++ b/drivers/media/video/pwc/pwc-if.c
@@ -25,18 +25,18 @@
*/
-/*
+/*
This code forms the interface between the USB layers and the Philips
specific stuff. Some adanved stuff of the driver falls under an
NDA, signed between me and Philips B.V., Eindhoven, the Netherlands, and
- is thus not distributed in source form. The binary pwcx.o module
+ is thus not distributed in source form. The binary pwcx.o module
contains the code that falls under the NDA.
-
- In case you're wondering: 'pwc' stands for "Philips WebCam", but
+
+ In case you're wondering: 'pwc' stands for "Philips WebCam", but
I really didn't want to type 'philips_web_cam' every time (I'm lazy as
any Linux kernel hacker, but I don't like uncomprehensible abbreviations
without explanation).
-
+
Oh yes, convention: to disctinguish between all the various pointers to
device-structures, I use these names for the pointer variables:
udev: struct usb_device *
@@ -170,14 +170,14 @@ static struct video_device pwc_template = {
/* Okay, this is some magic that I worked out and the reasoning behind it...
- The biggest problem with any USB device is of course: "what to do
+ The biggest problem with any USB device is of course: "what to do
when the user unplugs the device while it is in use by an application?"
We have several options:
1) Curse them with the 7 plagues when they do (requires divine intervention)
2) Tell them not to (won't work: they'll do it anyway)
3) Oops the kernel (this will have a negative effect on a user's uptime)
4) Do something sensible.
-
+
Of course, we go for option 4.
It happens that this device will be linked to two times, once from
@@ -185,15 +185,15 @@ static struct video_device pwc_template = {
pointers. This is done when the device is probed() and all initialization
succeeded. The pwc_device struct links back to both structures.
- When a device is unplugged while in use it will be removed from the
- list of known USB devices; I also de-register it as a V4L device, but
+ When a device is unplugged while in use it will be removed from the
+ list of known USB devices; I also de-register it as a V4L device, but
unfortunately I can't free the memory since the struct is still in use
by the file descriptor. This free-ing is then deferend until the first
opportunity. Crude, but it works.
-
+
A small 'advantage' is that if a user unplugs the cam and plugs it back
in, it should get assigned the same video device minor, but unfortunately
- it's non-trivial to re-link the cam back to the video device... (that
+ it's non-trivial to re-link the cam back to the video device... (that
would surely be magic! :))
*/
@@ -203,14 +203,14 @@ static struct video_device pwc_template = {
/* Here we want the physical address of the memory.
* This is used when initializing the contents of the area.
*/
-static inline unsigned long kvirt_to_pa(unsigned long adr)
+static inline unsigned long kvirt_to_pa(unsigned long adr)
{
- unsigned long kva, ret;
+ unsigned long kva, ret;
kva = (unsigned long) page_address(vmalloc_to_page((void *)adr));
kva |= adr & (PAGE_SIZE-1); /* restore the offset */
ret = __pa(kva);
- return ret;
+ return ret;
}
static void * rvmalloc(unsigned long size)
@@ -219,13 +219,13 @@ static void * rvmalloc(unsigned long size)
unsigned long adr;
size=PAGE_ALIGN(size);
- mem=vmalloc_32(size);
- if (mem)
+ mem=vmalloc_32(size);
+ if (mem)
{
memset(mem, 0, size); /* Clear the ram out, no junk to the user */
- adr=(unsigned long) mem;
- while (size > 0)
- {
+ adr=(unsigned long) mem;
+ while (size > 0)
+ {
SetPageReserved(vmalloc_to_page((void *)adr));
adr+=PAGE_SIZE;
size-=PAGE_SIZE;
@@ -236,13 +236,13 @@ static void * rvmalloc(unsigned long size)
static void rvfree(void * mem, unsigned long size)
{
- unsigned long adr;
+ unsigned long adr;
- if (mem)
+ if (mem)
{
- adr=(unsigned long) mem;
- while ((long) size > 0)
- {
+ adr=(unsigned long) mem;
+ while ((long) size > 0)
+ {
ClearPageReserved(vmalloc_to_page((void *)adr));
adr+=PAGE_SIZE;
size-=PAGE_SIZE;
@@ -263,13 +263,13 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
if (pdev == NULL)
return -ENXIO;
-
+
#ifdef PWC_MAGIC
if (pdev->magic != PWC_MAGIC) {
Err("allocate_buffers(): magic failed.\n");
return -ENXIO;
}
-#endif
+#endif
/* Allocate Isochronous pipe buffers */
for (i = 0; i < MAX_ISO_BUFS; i++) {
if (pdev->sbuf[i].data == NULL) {
@@ -308,7 +308,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
memset(kbuf, 128, PWC_FRAME_SIZE);
}
}
-
+
/* Allocate decompressor table space */
kbuf = NULL;
switch (pdev->type)
@@ -320,7 +320,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
case 730:
case 740:
case 750:
-#if 0
+#if 0
Trace(TRACE_MEMORY,"private_data(%zu)\n",sizeof(struct pwc_dec23_private));
kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL); /* Timon & Kiara */
break;
@@ -329,11 +329,11 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
/* TODO & FIXME */
kbuf = kmalloc(sizeof(struct pwc_dec23_private), GFP_KERNEL);
break;
-#endif
+#endif
;
}
pdev->decompress_data = kbuf;
-
+
/* Allocate image buffer; double buffer for mmap() */
kbuf = rvmalloc(default_mbufs * pdev->len_per_image);
if (kbuf == NULL) {
@@ -348,7 +348,7 @@ static int pwc_allocate_buffers(struct pwc_device *pdev)
pdev->image_ptr[i] = NULL;
kbuf = NULL;
-
+
Trace(TRACE_MEMORY, "<< pwc_allocate_buffers()\n");
return 0;
}
@@ -366,7 +366,7 @@ static void pwc_free_buffers(struct pwc_device *pdev)
Err("free_buffers(): magic failed.\n");
return;
}
-#endif
+#endif
/* Release Iso-pipe buffers */
for (i = 0; i < MAX_ISO_BUFS; i++)
@@ -403,17 +403,17 @@ static void pwc_free_buffers(struct pwc_device *pdev)
rvfree(pdev->image_data, default_mbufs * pdev->len_per_image);
}
pdev->image_data = NULL;
-
+
Trace(TRACE_MEMORY, "Leaving free_buffers().\n");
}
-/* The frame & image buffer mess.
+/* The frame & image buffer mess.
Yes, this is a mess. Well, it used to be simple, but alas... In this
module, 3 buffers schemes are used to get the data from the USB bus to
the user program. The first scheme involves the ISO buffers (called thus
since they transport ISO data from the USB controller), and not really
- interesting. Suffices to say the data from this buffer is quickly
+ interesting. Suffices to say the data from this buffer is quickly
gathered in an interrupt handler (pwc_isoc_handler) and placed into the
frame buffer.
@@ -443,8 +443,8 @@ static void pwc_free_buffers(struct pwc_device *pdev)
and a 'full' frame list:
* Initially, all frame buffers but one are on the 'empty' list; the one
remaining buffer is our initial fill frame.
- * If a frame is needed for filling, we try to take it from the 'empty'
- list, unless that list is empty, in which case we take the buffer at
+ * If a frame is needed for filling, we try to take it from the 'empty'
+ list, unless that list is empty, in which case we take the buffer at
the head of the 'full' list.
* When our fill buffer has been filled, it is appended to the 'full'
list.
@@ -646,7 +646,7 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
case -ETIMEDOUT: errmsg = "NAK (device does not respond)"; break;
}
Trace(TRACE_FLOW, "pwc_isoc_handler() called with status %d [%s].\n", urb->status, errmsg);
- /* Give up after a number of contiguous errors on the USB bus.
+ /* Give up after a number of contiguous errors on the USB bus.
Appearantly something is wrong so we simulate an unplug event.
*/
if (++pdev->visoc_errors > MAX_ISOC_ERRORS)
@@ -673,8 +673,8 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
pdev->visoc_errors = 0;
/* vsync: 0 = don't copy data
- 1 = sync-hunt
- 2 = synched
+ 1 = sync-hunt
+ 2 = synched
*/
/* Compact data */
for (i = 0; i < urb->number_of_packets; i++) {
@@ -701,18 +701,18 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
} /* ..flen > 0 */
if (flen < pdev->vlast_packet_size) {
- /* Shorter packet... We probably have the end of an image-frame;
+ /* Shorter packet... We probably have the end of an image-frame;
wake up read() process and let select()/poll() do something.
Decompression is done in user time over there.
*/
if (pdev->vsync == 2) {
- /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
- frames on the USB wire after an exposure change. This conditition is
+ /* The ToUCam Fun CMOS sensor causes the firmware to send 2 or 3 bogus
+ frames on the USB wire after an exposure change. This conditition is
however detected in the cam and a bit is set in the header.
*/
if (pdev->type == 730) {
unsigned char *ptr = (unsigned char *)fbuf->data;
-
+
if (ptr[1] == 1 && ptr[0] & 0x10) {
#if PWC_DEBUG
Debug("Hyundai CMOS sensor bug. Dropping frame %d.\n", fbuf->sequence);
@@ -733,13 +733,13 @@ static void pwc_isoc_handler(struct urb *urb, struct pt_regs *regs)
Info("Image is normal.\n");
}
pdev->vmirror = ptr[0] & 0x03;
- /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
+ /* Sometimes the trailer of the 730 is still sent as a 4 byte packet
after a short frame; this condition is filtered out specifically. A 4 byte
frame doesn't make sense anyway.
- So we get either this sequence:
- drop_bit set -> 4 byte frame -> short frame -> good frame
+ So we get either this sequence:
+ drop_bit set -> 4 byte frame -> short frame -> good frame
Or this one:
- drop_bit set -> short frame -> good frame
+ drop_bit set -> short frame -> good frame
So we drop either 3 or 2 frames in all!
*/
if (fbuf->filled == 4)
@@ -830,7 +830,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
intf = usb_ifnum_to_if(udev, 0);
if (intf)
idesc = usb_altnum_to_altsetting(intf, pdev->valternate);
-
+
if (!idesc)
return -EFAULT;
@@ -841,7 +841,7 @@ static int pwc_isoc_init(struct pwc_device *pdev)
pdev->vmax_packet_size = le16_to_cpu(idesc->endpoint[i].desc.wMaxPacketSize);
break;
}
-
+
if (pdev->vmax_packet_size < 0 || pdev->vmax_packet_size > ISO_MAX_FRAME_SIZE) {
Err("Failed to find packet size for video endpoint in current alternate setting.\n");
return -ENFILE; /* Odd error, that should be noticeable */
@@ -875,18 +875,18 @@ static int pwc_isoc_init(struct pwc_device *pdev)
return ret;
}
- /* init URB structure */
+ /* init URB structure */
for (i = 0; i < MAX_ISO_BUFS; i++) {
urb = pdev->sbuf[i].urb;
urb->interval = 1; // devik
urb->dev = udev;
- urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
+ urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint);
urb->transfer_flags = URB_ISO_ASAP;
- urb->transfer_buffer = pdev->sbuf[i].data;
- urb->transfer_buffer_length = ISO_BUFFER_SIZE;
- urb->complete = pwc_isoc_handler;
- urb->context = pdev;
+ urb->transfer_buffer = pdev->sbuf[i].data;
+ urb->transfer_buffer_length = ISO_BUFFER_SIZE;
+ urb->complete = pwc_isoc_handler;
+ urb->context = pdev;
urb->start_frame = 0;
urb->number_of_packets = ISO_FRAMES_PER_DESC;
for (j = 0; j < ISO_FRAMES_PER_DESC; j++) {
@@ -935,7 +935,7 @@ static void pwc_isoc_cleanup(struct pwc_device *pdev)
}
/* Stop camera, but only if we are sure the camera is still there (unplug
- is signalled by EPIPE)
+ is signalled by EPIPE)
*/
if (pdev->error_status && pdev->error_status != EPIPE) {
Trace(TRACE_OPEN, "Setting alternate interface 0.\n");
@@ -956,12 +956,12 @@ int pwc_try_video_mode(struct pwc_device *pdev, int width, int height, int new_f
pwc_reset_buffers(pdev);
/* Try to set video mode... */
start = ret = pwc_set_video_mode(pdev, width, height, new_fps, new_compression, new_snapshot);
- if (ret) {
- Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n");
+ if (ret) {
+ Trace(TRACE_FLOW, "pwc_set_video_mode attempt 1 failed.\n");
/* That failed... restore old mode (we know that worked) */
start = pwc_set_video_mode(pdev, pdev->view.x, pdev->view.y, pdev->vframes, pdev->vcompression, pdev->vsnapshot);
if (start) {
- Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n");
+ Trace(TRACE_FLOW, "pwc_set_video_mode attempt 2 failed.\n");
}
}
if (start == 0)
@@ -987,18 +987,18 @@ static int pwc_video_open(struct inode *inode, struct file *file)
struct pwc_device *pdev;
Trace(TRACE_OPEN, ">> video_open called(vdev = 0x%p).\n", vdev);
-
+
pdev = (struct pwc_device *)vdev->priv;
if (pdev == NULL)
BUG();
if (pdev->vopen)
return -EBUSY;
-
+
down(&pdev->modlock);
if (!pdev->usb_init) {
Trace(TRACE_OPEN, "Doing first time initialization.\n");
pdev->usb_init = 1;
-
+
if (pwc_trace & TRACE_OPEN)
{
/* Query sensor type */
@@ -1036,7 +1036,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
/* Set LED on/off time */
if (pwc_set_leds(pdev, led_on, led_off) < 0)
Info("Failed to set LED on/off time.\n");
-
+
pwc_construct(pdev); /* set min/max sizes correct */
/* So far, so good. Allocate memory. */
@@ -1046,7 +1046,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
up(&pdev->modlock);
return i;
}
-
+
/* Reset buffers & parameters */
pwc_reset_buffers(pdev);
for (i = 0; i < default_mbufs; i++)
@@ -1081,7 +1081,7 @@ static int pwc_video_open(struct inode *inode, struct file *file)
up(&pdev->modlock);
return i;
}
-
+
i = pwc_isoc_init(pdev);
if (i) {
Trace(TRACE_OPEN, "Failed to init ISOC stuff = %d.\n", i);
@@ -1155,13 +1155,13 @@ static int pwc_video_close(struct inode *inode, struct file *file)
/*
* FIXME: what about two parallel reads ????
* ANSWER: Not supported. You can't open the device more than once,
- despite what the V4L1 interface says. First, I don't see
- the need, second there's no mechanism of alerting the
- 2nd/3rd/... process of events like changing image size.
- And I don't see the point of blocking that for the
- 2nd/3rd/... process.
- In multi-threaded environments reading parallel from any
- device is tricky anyhow.
+ despite what the V4L1 interface says. First, I don't see
+ the need, second there's no mechanism of alerting the
+ 2nd/3rd/... process of events like changing image size.
+ And I don't see the point of blocking that for the
+ 2nd/3rd/... process.
+ In multi-threaded environments reading parallel from any
+ device is tricky anyhow.
*/
static ssize_t pwc_video_read(struct file *file, char __user * buf,
@@ -1171,7 +1171,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
struct pwc_device *pdev;
int noblock = file->f_flags & O_NONBLOCK;
DECLARE_WAITQUEUE(wait, current);
- int bytes_to_read;
+ int bytes_to_read;
Trace(TRACE_READ, "video_read(0x%p, %p, %zu) called.\n", vdev, buf, count);
if (vdev == NULL)
@@ -1193,22 +1193,22 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
set_current_state(TASK_RUNNING);
return -pdev->error_status ;
}
- if (noblock) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -EWOULDBLOCK;
- }
- if (signal_pending(current)) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -ERESTARTSYS;
- }
- schedule();
- set_current_state(TASK_INTERRUPTIBLE);
+ if (noblock) {
+ remove_wait_queue(&pdev->frameq, &wait);
+ set_current_state(TASK_RUNNING);
+ return -EWOULDBLOCK;
+ }
+ if (signal_pending(current)) {
+ remove_wait_queue(&pdev->frameq, &wait);
+ set_current_state(TASK_RUNNING);
+ return -ERESTARTSYS;
+ }
+ schedule();
+ set_current_state(TASK_INTERRUPTIBLE);
}
remove_wait_queue(&pdev->frameq, &wait);
set_current_state(TASK_RUNNING);
-
+
/* Decompress and release frame */
if (pwc_handle_frame(pdev))
return -EFAULT;
@@ -1218,7 +1218,7 @@ static ssize_t pwc_video_read(struct file *file, char __user * buf,
if (pdev->vpalette == VIDEO_PALETTE_RAW)
bytes_to_read = pdev->frame_size;
else
- bytes_to_read = pdev->view.size;
+ bytes_to_read = pdev->view.size;
/* copy bytes to user space; we allow for partial reads */
if (count + pdev->image_read_pos > bytes_to_read)
@@ -1348,11 +1348,11 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
struct video_picture *p = arg;
/*
* FIXME: Suppose we are mid read
- ANSWER: No problem: the firmware of the camera
- can handle brightness/contrast/etc
- changes at _any_ time, and the palette
- is used exactly once in the uncompress
- routine.
+ ANSWER: No problem: the firmware of the camera
+ can handle brightness/contrast/etc
+ changes at _any_ time, and the palette
+ is used exactly once in the uncompress
+ routine.
*/
pwc_set_brightness(pdev, p->brightness);
pwc_set_contrast(pdev, p->contrast);
@@ -1373,21 +1373,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
break;
}
- /* Window/size parameters */
+ /* Window/size parameters */
case VIDIOCGWIN:
{
struct video_window *vw = arg;
-
+
vw->x = 0;
vw->y = 0;
vw->width = pdev->view.x;
vw->height = pdev->view.y;
vw->chromakey = 0;
- vw->flags = (pdev->vframes << PWC_FPS_SHIFT) |
- (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0);
+ vw->flags = (pdev->vframes << PWC_FPS_SHIFT) |
+ (pdev->vsnapshot ? PWC_FPS_SNAPSHOT : 0);
break;
}
-
+
case VIDIOCSWIN:
{
struct video_window *vw = arg;
@@ -1402,9 +1402,9 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
ret = pwc_try_video_mode(pdev, vw->width, vw->height, fps, pdev->vcompression, snapshot);
if (ret)
return ret;
- break;
+ break;
}
-
+
/* We don't have overlay support (yet) */
case VIDIOCGFBUF:
{
@@ -1471,8 +1471,8 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
return -EBUSY; /* buffer wasn't available. Bummer */
pdev->image_used[vm->frame] = 1;
- /* Okay, we're done here. In the SYNC call we wait until a
- frame comes available, then expand image into the given
+ /* Okay, we're done here. In the SYNC call we wait until a
+ frame comes available, then expand image into the given
buffer.
In contrast to the CPiA cam the Philips cams deliver a
constant stream, almost like a grabber card. Also,
@@ -1487,16 +1487,16 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
{
/* The doc says: "Whenever a buffer is used it should
call VIDIOCSYNC to free this frame up and continue."
-
- The only odd thing about this whole procedure is
+
+ The only odd thing about this whole procedure is
that MCAPTURE flags the buffer as "in use", and
- SYNC immediately unmarks it, while it isn't
+ SYNC immediately unmarks it, while it isn't
after SYNC that you know that the buffer actually
got filled! So you better not start a CAPTURE in
- the same frame immediately (use double buffering).
- This is not a problem for this cam, since it has
- extra intermediate buffers, but a hardware
- grabber card will then overwrite the buffer
+ the same frame immediately (use double buffering).
+ This is not a problem for this cam, since it has
+ extra intermediate buffers, but a hardware
+ grabber card will then overwrite the buffer
you're working on.
*/
int *mbuf = arg;
@@ -1512,10 +1512,10 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
/* Add ourselves to the frame wait-queue.
-
+
FIXME: needs auditing for safety.
QUESTION: In what respect? I think that using the
- frameq is safe now.
+ frameq is safe now.
*/
add_wait_queue(&pdev->frameq, &wait);
while (pdev->full_frames == NULL) {
@@ -1524,21 +1524,21 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
set_current_state(TASK_RUNNING);
return -pdev->error_status;
}
-
- if (signal_pending(current)) {
- remove_wait_queue(&pdev->frameq, &wait);
- set_current_state(TASK_RUNNING);
- return -ERESTARTSYS;
- }
- schedule();
- set_current_state(TASK_INTERRUPTIBLE);
+
+ if (signal_pending(current)) {
+ remove_wait_queue(&pdev->frameq, &wait);
+ set_current_state(TASK_RUNNING);
+ return -ERESTARTSYS;
+ }
+ schedule();
+ set_current_state(TASK_INTERRUPTIBLE);
}
remove_wait_queue(&pdev->frameq, &wait);
set_current_state(TASK_RUNNING);
-
- /* The frame is ready. Expand in the image buffer
- requested by the user. I don't care if you
- mmap() 5 buffers and request data in this order:
+
+ /* The frame is ready. Expand in the image buffer
+ requested by the user. I don't care if you
+ mmap() 5 buffers and request data in this order:
buffer 4 2 3 0 1 2 3 0 4 3 1 . . .
Grabber hardware may not be so forgiving.
*/
@@ -1551,11 +1551,11 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
return -EFAULT;
break;
}
-
+
case VIDIOCGAUDIO:
{
struct video_audio *v = arg;
-
+
strcpy(v->name, "Microphone");
v->audio = -1; /* unknown audio minor */
v->flags = 0;
@@ -1565,19 +1565,19 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
v->treble = 0;
v->balance = 0x8000;
v->step = 1;
- break;
+ break;
}
-
+
case VIDIOCSAUDIO:
{
/* Dummy: nothing can be set */
break;
}
-
+
case VIDIOCGUNIT:
{
struct video_unit *vu = arg;
-
+
vu->video = pdev->vdev->minor & 0x3F;
vu->audio = -1; /* not known yet */
vu->vbi = -1;
@@ -1589,7 +1589,7 @@ static int pwc_video_do_ioctl(struct inode *inode, struct file *file,
return pwc_ioctl(pdev, cmd, arg);
} /* ..switch */
return 0;
-}
+}
static int pwc_video_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
@@ -1605,10 +1605,10 @@ static int pwc_video_mmap(struct file *file, struct vm_area_struct *vma)
unsigned long start = vma->vm_start;
unsigned long size = vma->vm_end-vma->vm_start;
unsigned long page, pos;
-
+
Trace(TRACE_MEMORY, "mmap(0x%p, 0x%lx, %lu) called.\n", vdev, start, size);
pdev = vdev->priv;
-
+
vma->vm_flags |= VM_IO;
pos = (unsigned long)pdev->image_data;
@@ -1646,7 +1646,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
char serial_number[30], *name;
/* Check if we can handle this device */
- Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n",
+ Trace(TRACE_PROBE, "probe() called [%04X %04X], if %d\n",
le16_to_cpu(udev->descriptor.idVendor),
le16_to_cpu(udev->descriptor.idProduct),
intf->altsetting->desc.bInterfaceNumber);
@@ -1770,11 +1770,11 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
name = "Logitech QuickCam (res.)";
type_id = 730; /* Assuming CMOS */
break;
- default:
+ default:
return -ENODEV;
- break;
- }
- }
+ break;
+ }
+ }
else if (vendor_id == 0x055d) {
/* I don't know the difference between the C10 and the C30;
I suppose the difference is the sensor, but both cameras
@@ -1837,7 +1837,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
return -ENODEV;
break;
}
-
+
}
else if (vendor_id == 0x0d81) {
switch(product_id) {
@@ -1856,7 +1856,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
break;
}
}
- else
+ else
return -ENODEV; /* Not any of the know types; but the list keeps growing. */
memset(serial_number, 0, 30);
@@ -1880,9 +1880,9 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
if (vendor_id == 0x046D && product_id == 0x08B5)
{
/* Logitech QuickCam Orbit
- The ranges have been determined experimentally; they may differ from cam to cam.
- Also, the exact ranges left-right and up-down are different for my cam
- */
+ The ranges have been determined experimentally; they may differ from cam to cam.
+ Also, the exact ranges left-right and up-down are different for my cam
+ */
pdev->angle_range.pan_min = -7000;
pdev->angle_range.pan_max = 7000;
pdev->angle_range.tilt_min = -3000;
@@ -1939,7 +1939,7 @@ static int usb_pwc_probe(struct usb_interface *intf, const struct usb_device_id
}
/* occupy slot */
- if (hint < MAX_DEV_HINTS)
+ if (hint < MAX_DEV_HINTS)
device_hint[hint].pdev = pdev;
Trace(TRACE_PROBE, "probe() function returning struct at 0x%p.\n", pdev);
@@ -1968,13 +1968,13 @@ static void usb_pwc_disconnect(struct usb_interface *intf)
Err("pwc_disconnect() Woops: pointer mismatch udev/pdev.\n");
goto disconnect_out;
}
-#ifdef PWC_MAGIC
+#ifdef PWC_MAGIC
if (pdev->magic != PWC_MAGIC) {
Err("pwc_disconnect() Magic number failed. Consult your scrolls and try again.\n");
goto disconnect_out;
}
#endif
-
+
/* We got unplugged; this is signalled by an EPIPE error code */
if (pdev->vopen) {
Info("Disconnected while webcam is in use!\n");
@@ -2017,8 +2017,8 @@ static int pwc_atoi(const char *s)
}
-/*
- * Initialization code & module stuff
+/*
+ * Initialization code & module stuff
*/
static char size[10];
@@ -2168,7 +2168,7 @@ static int __init usb_pwc_init(void)
if (*dot != '\0') {
/* There's a serial number as well */
int k;
-
+
dot++;
k = 0;
while (*dot != ':' && k < 29) {
@@ -2178,18 +2178,18 @@ static int __init usb_pwc_init(void)
device_hint[i].serial_number[k] = '\0';
}
}
-#if PWC_DEBUG
+#if PWC_DEBUG
Debug("device_hint[%d]:\n", i);
Debug(" type : %d\n", device_hint[i].type);
Debug(" serial# : %s\n", device_hint[i].serial_number);
Debug(" node : %d\n", device_hint[i].device_node);
-#endif
+#endif
}
else
device_hint[i].type = 0; /* not filled */
} /* ..for MAX_DEV_HINTS */
- Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver);
+ Trace(TRACE_PROBE, "Registering driver at address 0x%p.\n", &pwc_driver);
return usb_register(&pwc_driver);
}
diff --git a/drivers/usb/media/pwc/pwc-ioctl.h b/drivers/media/video/pwc/pwc-ioctl.h
index 5f9cb08bc02..784bc72521f 100644
--- a/drivers/usb/media/pwc/pwc-ioctl.h
+++ b/drivers/media/video/pwc/pwc-ioctl.h
@@ -33,10 +33,10 @@
/*
Changes
2001/08/03 Alvarado Added ioctl constants to access methods for
- changing white balance and red/blue gains
+ changing white balance and red/blue gains
2002/12/15 G. H. Fernandez-Toribio VIDIOCGREALSIZE
2003/12/13 Nemosft Unv. Some modifications to make interfacing to
- PWCX easier
+ PWCX easier
*/
/* These are private ioctl() commands, specific for the Philips webcams.
@@ -45,10 +45,10 @@
The #define names are built up like follows:
VIDIOC VIDeo IOCtl prefix
- PWC Philps WebCam
- G optional: Get
- S optional: Set
- ... the function
+ PWC Philps WebCam
+ G optional: Get
+ S optional: Set
+ ... the function
*/
@@ -94,7 +94,7 @@ struct pwc_serial
{
char serial[30]; /* String with serial number. Contains terminating 0 */
};
-
+
/* pwc_whitebalance.mode values */
#define PWC_WB_INDOOR 0
#define PWC_WB_OUTDOOR 1
@@ -102,14 +102,14 @@ struct pwc_serial
#define PWC_WB_MANUAL 3
#define PWC_WB_AUTO 4
-/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
+/* Used with VIDIOCPWC[SG]AWB (Auto White Balance).
Set mode to one of the PWC_WB_* values above.
- *red and *blue are the respective gains of these colour components inside
+ *red and *blue are the respective gains of these colour components inside
the camera; range 0..65535
- When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
+ When 'mode' == PWC_WB_MANUAL, 'manual_red' and 'manual_blue' are set or read;
otherwise undefined.
'read_red' and 'read_blue' are read-only.
-*/
+*/
struct pwc_whitebalance
{
int mode;
@@ -117,9 +117,9 @@ struct pwc_whitebalance
int read_red, read_blue; /* R/O */
};
-/*
+/*
'control_speed' and 'control_delay' are used in automatic whitebalance mode,
- and tell the camera how fast it should react to changes in lighting, and
+ and tell the camera how fast it should react to changes in lighting, and
with how much delay. Valid values are 0..65535.
*/
struct pwc_wb_speed
@@ -148,11 +148,11 @@ struct pwc_imagesize
#define PWC_MPT_TILT 0x02
#define PWC_MPT_TIMEOUT 0x04 /* for status */
-/* Set angles; when absolute != 0, the angle is absolute and the
+/* Set angles; when absolute != 0, the angle is absolute and the
driver calculates the relative offset for you. This can only
be used with VIDIOCPWCSANGLE; VIDIOCPWCGANGLE always returns
absolute angles.
- */
+ */
struct pwc_mpt_angles
{
int absolute; /* write-only */
@@ -179,14 +179,14 @@ struct pwc_mpt_status
/* This is used for out-of-kernel decompression. With it, you can get
all the necessary information to initialize and use the decompressor
routines in standalone applications.
- */
+ */
struct pwc_video_command
{
int type; /* camera type (645, 675, 730, etc.) */
int release; /* release number */
- int size; /* one of PSZ_* */
- int alternate;
+ int size; /* one of PSZ_* */
+ int alternate;
int command_len; /* length of USB video command */
unsigned char command_buf[13]; /* Actual USB video command */
int bandlength; /* >0 = compressed */
@@ -264,7 +264,7 @@ struct pwc_video_command
/* Flickerless mode; = 0 off, otherwise on */
#define VIDIOCPWCSFLICKER _IOW('v', 208, int)
-#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
+#define VIDIOCPWCGFLICKER _IOR('v', 208, int)
/* Dynamic noise reduction; 0 off, 3 = high noise reduction */
#define VIDIOCPWCSDYNNOISE _IOW('v', 209, int)
@@ -273,7 +273,7 @@ struct pwc_video_command
/* Real image size as used by the camera; tells you whether or not there's a gray border around the image */
#define VIDIOCPWCGREALSIZE _IOR('v', 210, struct pwc_imagesize)
- /* Motorized pan & tilt functions */
+ /* Motorized pan & tilt functions */
#define VIDIOCPWCMPTRESET _IOW('v', 211, int)
#define VIDIOCPWCMPTGRANGE _IOR('v', 211, struct pwc_mpt_range)
#define VIDIOCPWCMPTSANGLE _IOW('v', 212, struct pwc_mpt_angles)
diff --git a/drivers/media/video/pwc/pwc-kiara.c b/drivers/media/video/pwc/pwc-kiara.c
new file mode 100644
index 00000000000..4c96037f7be
--- /dev/null
+++ b/drivers/media/video/pwc/pwc-kiara.c
@@ -0,0 +1,318 @@
+/* Linux driver for Philips webcam
+ (C) 2004 Luc Saillard (luc@saillard.org)
+
+ NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
+ driver and thus may have bugs that are not present in the original version.
+ Please send bug reports and support requests to <luc@saillard.org>.
+ The decompression routines have been implemented by reverse-engineering the
+ Nemosoft binary pwcx module. Caveat emptor.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/* This tables contains entries for the 730/740/750 (Kiara) camera, with
+ 4 different qualities (no compression, low, medium, high).
+ It lists the bandwidth requirements for said mode by its alternate interface
+ number. An alternate of 0 means that the mode is unavailable.
+
+ There are 6 * 4 * 4 entries:
+ 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
+ 6 framerates: 5, 10, 15, 20, 25, 30
+ 4 compression modi: none, low, medium, high
+
+ When an uncompressed mode is not available, the next available compressed mode
+ will be chosen (unless the decompressor is absent). Sometimes there are only
+ 1 or 2 compressed modes available; in that case entries are duplicated.
+*/
+
+
+#include "pwc-kiara.h"
+#include "pwc-uncompress.h"
+
+const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
+{
+ /* SQCIF */
+ {
+ /* 5 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ },
+ /* QSIF */
+ {
+ /* 5 fps */
+ {
+ {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
+ {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
+ {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
+ {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
+ },
+ /* 10 fps */
+ {
+ {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
+ {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
+ {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
+ {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
+ },
+ /* 15 fps */
+ {
+ {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
+ {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
+ {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
+ {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
+ },
+ /* 20 fps */
+ {
+ {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
+ {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
+ {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
+ {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
+ },
+ /* 25 fps */
+ {
+ {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
+ {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
+ {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
+ {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
+ },
+ /* 30 fps */
+ {
+ {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
+ {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
+ {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
+ {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
+ },
+ },
+ /* QCIF */
+ {
+ /* 5 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ },
+ /* SIF */
+ {
+ /* 5 fps */
+ {
+ {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
+ {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
+ {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
+ {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
+ {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
+ {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
+ {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
+ {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
+ {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
+ {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
+ {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
+ {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
+ {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
+ {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
+ },
+ },
+ /* CIF */
+ {
+ /* 5 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ },
+ /* VGA */
+ {
+ /* 5 fps */
+ {
+ {0, },
+ {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
+ {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
+ {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
+ {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
+ {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
+ {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
+ {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ },
+};
+
diff --git a/drivers/usb/media/pwc/pwc-kiara.h b/drivers/media/video/pwc/pwc-kiara.h
index 12929abbb1f..12929abbb1f 100644
--- a/drivers/usb/media/pwc/pwc-kiara.h
+++ b/drivers/media/video/pwc/pwc-kiara.h
diff --git a/drivers/usb/media/pwc/pwc-misc.c b/drivers/media/video/pwc/pwc-misc.c
index b7a4bd3524c..58fe7974799 100644
--- a/drivers/usb/media/pwc/pwc-misc.c
+++ b/drivers/media/video/pwc/pwc-misc.c
@@ -1,4 +1,4 @@
-/* Linux driver for Philips webcam
+/* Linux driver for Philips webcam
Various miscellaneous functions and tables.
(C) 1999-2003 Nemosoft Unv.
(C) 2004 Luc Saillard (luc@saillard.org)
@@ -44,17 +44,17 @@ int pwc_decode_size(struct pwc_device *pdev, int width, int height)
int i, find;
/* Make sure we don't go beyond our max size.
- NB: we have different limits for RAW and normal modes. In case
- you don't have the decompressor loaded or use RAW mode,
- the maximum viewable size is smaller.
- */
+ NB: we have different limits for RAW and normal modes. In case
+ you don't have the decompressor loaded or use RAW mode,
+ the maximum viewable size is smaller.
+ */
if (pdev->vpalette == VIDEO_PALETTE_RAW)
{
if (width > pdev->abs_max.x || height > pdev->abs_max.y)
{
Debug("VIDEO_PALETTE_RAW: going beyond abs_max.\n");
- return -1;
- }
+ return -1;
+ }
}
else
{
@@ -88,8 +88,8 @@ void pwc_construct(struct pwc_device *pdev)
pdev->view_min.y = 96;
pdev->view_max.x = 352;
pdev->view_max.y = 288;
- pdev->abs_max.x = 352;
- pdev->abs_max.y = 288;
+ pdev->abs_max.x = 352;
+ pdev->abs_max.y = 288;
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QCIF | 1 << PSZ_CIF;
pdev->vcinterface = 2;
pdev->vendpoint = 4;
@@ -105,8 +105,8 @@ void pwc_construct(struct pwc_device *pdev)
pdev->view_max.x = 640;
pdev->view_max.y = 480;
pdev->image_mask = 1 << PSZ_SQCIF | 1 << PSZ_QSIF | 1 << PSZ_QCIF | 1 << PSZ_SIF | 1 << PSZ_CIF | 1 << PSZ_VGA;
- pdev->abs_max.x = 640;
- pdev->abs_max.y = 480;
+ pdev->abs_max.x = 640;
+ pdev->abs_max.y = 480;
pdev->vcinterface = 3;
pdev->vendpoint = 4;
pdev->frame_header_size = 0;
@@ -121,8 +121,8 @@ void pwc_construct(struct pwc_device *pdev)
pdev->view_max.x = 640;
pdev->view_max.y = 480;
pdev->image_mask = 1 << PSZ_QSIF | 1 << PSZ_SIF | 1 << PSZ_VGA;
- pdev->abs_max.x = 640;
- pdev->abs_max.y = 480;
+ pdev->abs_max.x = 640;
+ pdev->abs_max.y = 480;
pdev->vcinterface = 3;
pdev->vendpoint = 5;
pdev->frame_header_size = TOUCAM_HEADER_SIZE;
diff --git a/drivers/usb/media/pwc/pwc-nala.h b/drivers/media/video/pwc/pwc-nala.h
index e6c5cb69d03..168c73ef75d 100644
--- a/drivers/usb/media/pwc/pwc-nala.h
+++ b/drivers/media/video/pwc/pwc-nala.h
@@ -54,7 +54,7 @@
{0},
},
/* VGA */
- {
+ {
{0},
{0},
{0},
diff --git a/drivers/media/video/pwc/pwc-timon.c b/drivers/media/video/pwc/pwc-timon.c
new file mode 100644
index 00000000000..175250d089c
--- /dev/null
+++ b/drivers/media/video/pwc/pwc-timon.c
@@ -0,0 +1,316 @@
+/* Linux driver for Philips webcam
+ (C) 2004 Luc Saillard (luc@saillard.org)
+
+ NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
+ driver and thus may have bugs that are not present in the original version.
+ Please send bug reports and support requests to <luc@saillard.org>.
+ The decompression routines have been implemented by reverse-engineering the
+ Nemosoft binary pwcx module. Caveat emptor.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/* This tables contains entries for the 675/680/690 (Timon) camera, with
+ 4 different qualities (no compression, low, medium, high).
+ It lists the bandwidth requirements for said mode by its alternate interface
+ number. An alternate of 0 means that the mode is unavailable.
+
+ There are 6 * 4 * 4 entries:
+ 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
+ 6 framerates: 5, 10, 15, 20, 25, 30
+ 4 compression modi: none, low, medium, high
+
+ When an uncompressed mode is not available, the next available compressed mode
+ will be chosen (unless the decompressor is absent). Sometimes there are only
+ 1 or 2 compressed modes available; in that case entries are duplicated.
+*/
+
+#include "pwc-timon.h"
+
+const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
+{
+ /* SQCIF */
+ {
+ /* 5 fps */
+ {
+ {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
+ {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
+ {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
+ {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
+ {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
+ {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
+ {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
+ {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
+ {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
+ {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
+ {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
+ {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
+ {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
+ },
+ /* 25 fps */
+ {
+ {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
+ {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
+ {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
+ {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
+ },
+ /* 30 fps */
+ {
+ {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
+ {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
+ {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
+ {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
+ },
+ },
+ /* QSIF */
+ {
+ /* 5 fps */
+ {
+ {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
+ {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
+ {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
+ {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
+ {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
+ {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
+ {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
+ {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
+ {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
+ {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
+ {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
+ {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
+ {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
+ },
+ /* 25 fps */
+ {
+ {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
+ {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
+ {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
+ {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
+ },
+ /* 30 fps */
+ {
+ {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
+ {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
+ {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
+ {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
+ },
+ },
+ /* QCIF */
+ {
+ /* 5 fps */
+ {
+ {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
+ {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
+ {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
+ {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
+ {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
+ {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
+ {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
+ {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
+ {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
+ {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
+ {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
+ {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
+ {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
+ },
+ /* 25 fps */
+ {
+ {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
+ {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
+ {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
+ {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
+ {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
+ {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
+ },
+ },
+ /* SIF */
+ {
+ /* 5 fps */
+ {
+ {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
+ {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
+ {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
+ {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
+ {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
+ {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
+ {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
+ {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
+ {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
+ {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
+ {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
+ {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
+ {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
+ {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
+ },
+ },
+ /* CIF */
+ {
+ /* 5 fps */
+ {
+ {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
+ {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
+ {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
+ {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
+ {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
+ {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
+ {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
+ {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
+ {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
+ {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
+ {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
+ {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
+ {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
+ {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
+ },
+ },
+ /* VGA */
+ {
+ /* 5 fps */
+ {
+ {0, },
+ {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
+ {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
+ {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
+ },
+ /* 10 fps */
+ {
+ {0, },
+ {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
+ {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
+ {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
+ },
+ /* 15 fps */
+ {
+ {0, },
+ {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
+ {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
+ {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
+ },
+ /* 20 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 25 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ /* 30 fps */
+ {
+ {0, },
+ {0, },
+ {0, },
+ {0, },
+ },
+ },
+};
+
diff --git a/drivers/usb/media/pwc/pwc-timon.h b/drivers/media/video/pwc/pwc-timon.h
index a86b3782a08..a86b3782a08 100644
--- a/drivers/usb/media/pwc/pwc-timon.h
+++ b/drivers/media/video/pwc/pwc-timon.h
diff --git a/drivers/usb/media/pwc/pwc-uncompress.c b/drivers/media/video/pwc/pwc-uncompress.c
index ef4204eab6c..b37a89a163f 100644
--- a/drivers/usb/media/pwc/pwc-uncompress.c
+++ b/drivers/media/video/pwc/pwc-uncompress.c
@@ -109,9 +109,9 @@ int pwc_decompress(struct pwc_device *pdev)
in planar format immediately.
*/
int flags;
-
- flags = PWCX_FLAG_PLANAR;
- if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
+
+ flags = PWCX_FLAG_PLANAR;
+ if (pdev->vsize == PSZ_VGA && pdev->vframes == 5 && pdev->vsnapshot)
{
printk(KERN_ERR "pwc: Mode Bayer is not supported for now\n");
flags |= PWCX_FLAG_BAYER;
diff --git a/drivers/usb/media/pwc/pwc-uncompress.h b/drivers/media/video/pwc/pwc-uncompress.h
index d3b9250e4ed..f75e1b6cbe1 100644
--- a/drivers/usb/media/pwc/pwc-uncompress.h
+++ b/drivers/media/video/pwc/pwc-uncompress.h
@@ -24,7 +24,7 @@
/* This file is the bridge between the kernel module and the plugin; it
describes the structures and datatypes used in both modules. Any
- significant change should be reflected by increasing the
+ significant change should be reflected by increasing the
pwc_decompressor_version major number.
*/
#ifndef PWC_UNCOMPRESS_H
diff --git a/drivers/usb/media/pwc/pwc.h b/drivers/media/video/pwc/pwc.h
index 6dd76bb3dff..1b0ee0ced0e 100644
--- a/drivers/usb/media/pwc/pwc.h
+++ b/drivers/media/video/pwc/pwc.h
@@ -123,7 +123,7 @@ struct pwc_device
#endif
/* Pointer to our usb_device */
struct usb_device *udev;
-
+
int type; /* type of cam (645, 646, 675, 680, 690, 720, 730, 740, 750) */
int release; /* release number */
int features; /* feature bits */
@@ -149,7 +149,7 @@ struct pwc_device
char vsnapshot; /* snapshot mode */
char vsync; /* used by isoc handler */
char vmirror; /* for ToUCaM series */
-
+
int cmd_len;
unsigned char cmd_buf[13];
diff --git a/drivers/media/video/saa5249.c b/drivers/media/video/saa5249.c
index a9f3cf0b1e3..531e9461cb6 100644
--- a/drivers/media/video/saa5249.c
+++ b/drivers/media/video/saa5249.c
@@ -71,7 +71,7 @@
#define NUM_BUFS 8
#define IF_NAME "SAA5249"
-static const int disp_modes[8][3] =
+static const int disp_modes[8][3] =
{
{ 0x46, 0x03, 0x03 }, /* DISPOFF */
{ 0x46, 0xcc, 0xcc }, /* DISPNORM */
@@ -150,8 +150,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
client=kmalloc(sizeof(*client), GFP_KERNEL);
if(client==NULL)
return -ENOMEM;
- client_template.adapter = adap;
- client_template.addr = addr;
+ client_template.adapter = adap;
+ client_template.addr = addr;
memcpy(client, &client_template, sizeof(*client));
t = kzalloc(sizeof(*t), GFP_KERNEL);
if(t==NULL)
@@ -161,11 +161,11 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
}
strlcpy(client->name, IF_NAME, I2C_NAME_SIZE);
mutex_init(&t->lock);
-
+
/*
* Now create a video4linux device
*/
-
+
vd = kmalloc(sizeof(struct video_device), GFP_KERNEL);
if(vd==NULL)
{
@@ -175,8 +175,8 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
}
i2c_set_clientdata(client, vd);
memcpy(vd, &saa_template, sizeof(*vd));
-
- for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
+
+ for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
{
memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -186,9 +186,9 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
t->vdau[pgbuf].stopped = TRUE;
t->is_searching[pgbuf] = FALSE;
}
- vd->priv=t;
-
-
+ vd->priv=t;
+
+
/*
* Register it
*/
@@ -208,7 +208,7 @@ static int saa5249_attach(struct i2c_adapter *adap, int addr, int kind)
/*
* We do most of the hard work when we become a device on the i2c.
*/
-
+
static int saa5249_probe(struct i2c_adapter *adap)
{
if (adap->class & I2C_CLASS_TV_ANALOG)
@@ -229,7 +229,7 @@ static int saa5249_detach(struct i2c_client *client)
/* new I2C driver support */
-static struct i2c_driver i2c_driver_videotext =
+static struct i2c_driver i2c_driver_videotext =
{
.driver = {
.name = IF_NAME, /* name */
@@ -249,7 +249,7 @@ static struct i2c_client client_template = {
* delay may be longer.
*/
-static void jdelay(unsigned long delay)
+static void jdelay(unsigned long delay)
{
sigset_t oldblocked = current->blocked;
@@ -269,14 +269,14 @@ static void jdelay(unsigned long delay)
/*
* I2C interfaces
*/
-
-static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data)
+
+static int i2c_sendbuf(struct saa5249_device *t, int reg, int count, u8 *data)
{
char buf[64];
-
+
buf[0] = reg;
memcpy(buf+1, data, count);
-
+
if(i2c_master_send(t->client, buf, count+1)==count+1)
return 0;
return -1;
@@ -289,7 +289,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
int ct=0;
va_list argp;
va_start(argp,t);
-
+
while((v=va_arg(argp,int))!=-1)
buf[ct++]=v;
return i2c_sendbuf(t, buf[0], ct-1, buf+1);
@@ -301,7 +301,7 @@ static int i2c_senddata(struct saa5249_device *t, ...)
* Returns -1 if I²C-device didn't send acknowledge, 0 otherwise
*/
-static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
+static int i2c_getdata(struct saa5249_device *t, int count, u8 *buf)
{
if(i2c_master_recv(t->client, buf, count)!=count)
return -1;
@@ -320,9 +320,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv;
- switch(cmd)
+ switch(cmd)
{
- case VTXIOCGETINFO:
+ case VTXIOCGETINFO:
{
vtx_info_t *info = arg;
info->version_major = VTX_VER_MAJ;
@@ -332,10 +332,10 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCCLRPAGE:
+ case VTXIOCCLRPAGE:
{
vtx_pagereq_t *req = arg;
-
+
if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
return -EINVAL;
memset(t->vdau[req->pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
@@ -343,17 +343,17 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCCLRFOUND:
+ case VTXIOCCLRFOUND:
{
vtx_pagereq_t *req = arg;
-
+
if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
return -EINVAL;
t->vdau[req->pgbuf].clrfound = TRUE;
return 0;
}
- case VTXIOCPAGEREQ:
+ case VTXIOCPAGEREQ:
{
vtx_pagereq_t *req = arg;
if (!(req->pagemask & PGMASK_PAGE))
@@ -381,7 +381,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCGETSTAT:
+ case VTXIOCGETSTAT:
{
vtx_pagereq_t *req = arg;
u8 infobits[10];
@@ -390,7 +390,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
if (req->pgbuf < 0 || req->pgbuf >= NUM_DAUS)
return -EINVAL;
- if (!t->vdau[req->pgbuf].stopped)
+ if (!t->vdau[req->pgbuf].stopped)
{
if (i2c_senddata(t, 2, 0, -1) ||
i2c_sendbuf(t, 3, sizeof(t->vdau[0].sregs), t->vdau[req->pgbuf].sregs) ||
@@ -403,7 +403,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return -EIO;
if (!(infobits[8] & 0x10) && !(infobits[7] & 0xf0) && /* check FOUND-bit */
- (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) ||
+ (memcmp(infobits, t->vdau[req->pgbuf].laststat, sizeof(infobits)) ||
time_after_eq(jiffies, t->vdau[req->pgbuf].expire)))
{ /* check if new page arrived */
if (i2c_senddata(t, 8, 0, 0, 0, -1) ||
@@ -411,7 +411,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return -EIO;
t->vdau[req->pgbuf].expire = jiffies + PGBUF_EXPIRE;
memset(t->vdau[req->pgbuf].pgbuf + VTX_PAGESIZE, ' ', VTX_VIRTUALSIZE - VTX_PAGESIZE);
- if (t->virtual_mode)
+ if (t->virtual_mode)
{
/* Packet X/24 */
if (i2c_senddata(t, 8, 0, 0x20, 0, -1) ||
@@ -459,9 +459,9 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
info.notfound = !!(infobits[8] & 0x10);
info.pblf = !!(infobits[9] & 0x20);
info.hamming = 0;
- for (a = 0; a <= 7; a++)
+ for (a = 0; a <= 7; a++)
{
- if (infobits[a] & 0xf0)
+ if (infobits[a] & 0xf0)
{
info.hamming = 1;
break;
@@ -471,14 +471,14 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
info.notfound = 1;
if(copy_to_user(req->buffer, &info, sizeof(vtx_pageinfo_t)))
return -EFAULT;
- if (!info.hamming && !info.notfound)
+ if (!info.hamming && !info.notfound)
{
t->is_searching[req->pgbuf] = FALSE;
}
return 0;
}
- case VTXIOCGETPAGE:
+ case VTXIOCGETPAGE:
{
vtx_pagereq_t *req = arg;
int start, end;
@@ -488,15 +488,15 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
if(copy_to_user(req->buffer, &t->vdau[req->pgbuf].pgbuf[req->start], req->end - req->start + 1))
return -EFAULT;
-
- /*
+
+ /*
* Always read the time directly from SAA5249
*/
-
- if (req->start <= 39 && req->end >= 32)
+
+ if (req->start <= 39 && req->end >= 32)
{
int len;
- char buf[16];
+ char buf[16];
start = max(req->start, 32);
end = min(req->end, 39);
len=end-start+1;
@@ -507,7 +507,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return -EFAULT;
}
/* Insert the current header if DAU is still searching for a page */
- if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf])
+ if (req->start <= 31 && req->end >= 7 && t->is_searching[req->pgbuf])
{
char buf[32];
int len;
@@ -523,7 +523,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCSTOPDAU:
+ case VTXIOCSTOPDAU:
{
vtx_pagereq_t *req = arg;
@@ -534,12 +534,12 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCPUTPAGE:
- case VTXIOCSETDISP:
- case VTXIOCPUTSTAT:
+ case VTXIOCPUTPAGE:
+ case VTXIOCSETDISP:
+ case VTXIOCPUTSTAT:
return 0;
-
- case VTXIOCCLRCACHE:
+
+ case VTXIOCCLRCACHE:
{
if (i2c_senddata(t, 0, NUM_DAUS, 0, 8, -1) || i2c_senddata(t, 11,
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
@@ -551,7 +551,7 @@ static int do_saa5249_ioctl(struct inode *inode, struct file *file,
return 0;
}
- case VTXIOCSETVIRT:
+ case VTXIOCSETVIRT:
{
/* The SAA5249 has virtual-row reception turned on always */
t->virtual_mode = (int)(long)arg;
@@ -612,14 +612,14 @@ static inline unsigned int vtx_fix_command(unsigned int cmd)
/*
* Handle the locking
*/
-
+
static int saa5249_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv;
int err;
-
+
cmd = vtx_fix_command(cmd);
mutex_lock(&t->lock);
err = video_usercopy(inode,file,cmd,arg,do_saa5249_ioctl);
@@ -627,7 +627,7 @@ static int saa5249_ioctl(struct inode *inode, struct file *file,
return err;
}
-static int saa5249_open(struct inode *inode, struct file *file)
+static int saa5249_open(struct inode *inode, struct file *file)
{
struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv;
@@ -636,7 +636,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
err = video_exclusive_open(inode,file);
if (err < 0)
return err;
-
+
if (t->client==NULL) {
err = -ENODEV;
goto fail;
@@ -647,13 +647,13 @@ static int saa5249_open(struct inode *inode, struct file *file)
i2c_senddata(t, 1, disp_modes[t->disp_mode][0], 0, -1) ||
/* Display TV-picture, no virtual rows */
i2c_senddata(t, 4, NUM_DAUS, disp_modes[t->disp_mode][1], disp_modes[t->disp_mode][2], 7, -1)) /* Set display to page 4 */
-
+
{
err = -EIO;
goto fail;
}
- for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
+ for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++)
{
memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
memset(t->vdau[pgbuf].sregs, 0, sizeof(t->vdau[0].sregs));
@@ -673,7 +673,7 @@ static int saa5249_open(struct inode *inode, struct file *file)
-static int saa5249_release(struct inode *inode, struct file *file)
+static int saa5249_release(struct inode *inode, struct file *file)
{
struct video_device *vd = video_devdata(file);
struct saa5249_device *t=vd->priv;
@@ -690,7 +690,7 @@ static int __init init_saa_5249 (void)
return i2c_add_driver(&i2c_driver_videotext);
}
-static void __exit cleanup_saa_5249 (void)
+static void __exit cleanup_saa_5249 (void)
{
i2c_del_driver(&i2c_driver_videotext);
}
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c
index d17395c4f55..a81285ca7d5 100644
--- a/drivers/media/video/saa6588.c
+++ b/drivers/media/video/saa6588.c
@@ -32,7 +32,7 @@
#include <asm/uaccess.h>
-#include "rds.h"
+#include <media/rds.h>
/* Addresses to scan */
static unsigned short normal_i2c[] = {
diff --git a/drivers/media/video/saa7110.c b/drivers/media/video/saa7110.c
index 7bb85a7b326..41d951db6ec 100644
--- a/drivers/media/video/saa7110.c
+++ b/drivers/media/video/saa7110.c
@@ -39,7 +39,6 @@ MODULE_AUTHOR("Pauline Middelink");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -108,13 +107,8 @@ saa7110_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
struct saa7110 *decoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
- msg.len = len;
- msg.buf = (char *) data;
- msg.addr = client->addr;
- msg.flags = 0;
- ret = i2c_transfer(client->adapter, &msg, 1);
+ ret = i2c_master_send(client, data, len);
/* Cache the written data */
memcpy(decoder->reg + reg, data + 1, len - 1);
@@ -145,7 +139,7 @@ saa7110_read (struct i2c_client *client)
static int
saa7110_selmux (struct i2c_client *client,
- int chan)
+ int chan)
{
static const unsigned char modes[9][8] = {
/* mode 0 */
@@ -432,15 +426,13 @@ saa7110_command (struct i2c_client *client,
break;
case DECODER_DUMP:
- for (v = 0; v < 0x34; v += 16) {
+ for (v = 0; v < SAA7110_NR_REG; v += 16) {
int j;
- dprintk(1, KERN_INFO "%s: %03x\n", I2C_NAME(client),
+ dprintk(1, KERN_DEBUG "%s: %02x:", I2C_NAME(client),
v);
- for (j = 0; j < 16; j++) {
- dprintk(1, KERN_INFO " %02x",
- decoder->reg[v + j]);
- }
- dprintk(1, KERN_INFO "\n");
+ for (j = 0; j < 16 && v + j < SAA7110_NR_REG; j++)
+ dprintk(1, " %02x", decoder->reg[v + j]);
+ dprintk(1, "\n");
}
break;
@@ -465,7 +457,7 @@ static unsigned short normal_i2c[] = {
};
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/saa7111.c b/drivers/media/video/saa7111.c
index 8c06592b37f..686fd474620 100644
--- a/drivers/media/video/saa7111.c
+++ b/drivers/media/video/saa7111.c
@@ -1,4 +1,4 @@
-/*
+/*
* saa7111 - Philips SAA7111A video decoder driver version 0.0.3
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -52,7 +52,6 @@ MODULE_AUTHOR("Dave Perks");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -70,8 +69,10 @@ MODULE_PARM_DESC(debug, "Debug level (0-1)");
/* ----------------------------------------------------------------------- */
+#define SAA7111_NR_REG 0x18
+
struct saa7111 {
- unsigned char reg[32];
+ unsigned char reg[SAA7111_NR_REG];
int norm;
int input;
@@ -110,24 +111,21 @@ saa7111_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct saa7111 *decoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
+ block_data[block_len++] =
decoder->reg[reg++] = data[1];
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -210,6 +208,7 @@ saa7111_command (struct i2c_client *client,
switch (cmd) {
case 0:
+ break;
case DECODER_INIT:
{
struct video_decoder_init *init = arg;
@@ -227,11 +226,11 @@ saa7111_command (struct i2c_client *client,
{
int i;
- for (i = 0; i < 32; i += 16) {
+ for (i = 0; i < SAA7111_NR_REG; i += 16) {
int j;
printk(KERN_DEBUG "%s: %03x", I2C_NAME(client), i);
- for (j = 0; j < 16; ++j) {
+ for (j = 0; j < 16 && i + j < SAA7111_NR_REG; ++j) {
printk(" %02x",
saa7111_read(client, i + j));
}
@@ -483,7 +482,7 @@ saa7111_command (struct i2c_client *client,
static unsigned short normal_i2c[] = { I2C_SAA7111 >> 1, I2C_CLIENT_END };
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/saa7114.c b/drivers/media/video/saa7114.c
index fd0a4b4ef01..90398ab8252 100644
--- a/drivers/media/video/saa7114.c
+++ b/drivers/media/video/saa7114.c
@@ -1,4 +1,4 @@
-/*
+/*
* saa7114 - Philips SAA7114H video decoder driver version 0.0.1
*
* Copyright (C) 2002 Maxim Yevtyushkin <max@linuxmedialabs.com>
@@ -55,7 +55,6 @@ MODULE_AUTHOR("Maxim Yevtyushkin");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(x) (x)->name
@@ -139,9 +138,6 @@ saa7114_write (struct i2c_client *client,
u8 reg,
u8 value)
{
- /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
-
- /*decoder->reg[reg] = value;*/
return i2c_smbus_write_byte_data(client, reg, value);
}
@@ -157,25 +153,21 @@ saa7114_write_block (struct i2c_client *client,
* the adapter understands raw I2C */
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
- /*struct saa7114 *decoder = i2c_get_clientdata(client);*/
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
- /*decoder->reg[reg++] =*/ data[1];
+ block_data[block_len++] = data[1];
+ reg++;
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -308,7 +300,7 @@ static const unsigned char init[] = {
0x55, 0xff,
0x56, 0xff,
0x57, 0xff,
- 0x58, 0x40, // framing code
+ 0x58, 0x40, // framing code
0x59, 0x47, // horizontal offset
0x5a, 0x06, // vertical offset
0x5b, 0x83, // field offset
@@ -353,7 +345,7 @@ static const unsigned char init[] = {
0x82, 0x00,
0x83, 0x00,
0x84, 0xc5,
- 0x85, 0x0d, // hsync and vsync ?
+ 0x85, 0x0d, // hsync and vsync ?
0x86, 0x40,
0x87, 0x01,
0x88, 0x00,
@@ -442,7 +434,7 @@ static const unsigned char init[] = {
0xd9, 0x04,
0xda, 0x00, // horizontal luminance phase offset
0xdb, 0x00,
- 0xdc, 0x00, // horizontal chrominance scaling increment
+ 0xdc, 0x00, // horizontal chrominance scaling increment
0xdd, 0x02,
0xde, 0x00, // horizontal chrominance phase offset
0xdf, 0x00,
@@ -762,7 +754,7 @@ saa7114_command (struct i2c_client *client,
saa7114_write(client, 0x87,
decoder->reg[REG_ADDR(0x87)]);
saa7114_write(client, 0x88, 0xd8); // sw reset scaler
- saa7114_write(client, 0x88, 0xf8); // sw reset scaler release
+ saa7114_write(client, 0x88, 0xf8); // sw reset scaler release
saa7114_write(client, 0x80, 0x36);
}
@@ -821,7 +813,7 @@ static unsigned short normal_i2c[] =
{ I2C_SAA7114 >> 1, I2C_SAA7114A >> 1, I2C_CLIENT_END };
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index b184fd00b4e..b0501528260 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -40,7 +40,6 @@
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
-#include <media/audiochip.h>
#include <asm/div64.h>
MODULE_DESCRIPTION("Philips SAA7113/SAA7114/SAA7115 video decoder driver");
diff --git a/drivers/media/video/saa711x.c b/drivers/media/video/saa711x.c
index 6c161f2f5e2..708fae51e8e 100644
--- a/drivers/media/video/saa711x.c
+++ b/drivers/media/video/saa711x.c
@@ -45,7 +45,6 @@ MODULE_AUTHOR("Dave Perks, Jose Ignacio Gijon, Joerg Heckenbach, Mark McClelland
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
diff --git a/drivers/media/video/saa7121.h b/drivers/media/video/saa7121.h
index 74e37d40520..66967ae3749 100644
--- a/drivers/media/video/saa7121.h
+++ b/drivers/media/video/saa7121.h
@@ -64,7 +64,7 @@
#define PAL_MSB_VERTICAL 0x40 /* 7c */
/* Initialization Sequence */
-
+
static __u8 init7121ntsc[] = {
0x26, 0x0, 0x27, 0x0,
0x28, NTSC_BURST_START, 0x29, NTSC_BURST_END,
@@ -95,7 +95,7 @@ static __u8 init7121ntsc[] = {
0x78, 0x0, 0x79, 0x0, 0x7a, NTSC_FIRST_ACTIVE,
0x7b, NTSC_LAST_ACTIVE, 0x7c, NTSC_MSB_VERTICAL,
0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
-};
+};
#define INIT7121LEN (sizeof(init7121ntsc)/2)
static __u8 init7121pal[] = {
@@ -128,5 +128,5 @@ static __u8 init7121pal[] = {
0x78, 0x0, 0x79, 0x0, 0x7a, PAL_FIRST_ACTIVE,
0x7b, PAL_LAST_ACTIVE, 0x7c, PAL_MSB_VERTICAL,
0x7d, 0x0, 0x7e, 0x0, 0x7f, 0x0
-};
+};
#endif
diff --git a/drivers/media/video/saa7134/saa7134-alsa.c b/drivers/media/video/saa7134/saa7134-alsa.c
index aca84d2f982..bb3e0ba946d 100644
--- a/drivers/media/video/saa7134/saa7134-alsa.c
+++ b/drivers/media/video/saa7134/saa7134-alsa.c
@@ -507,7 +507,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
/* release the old buffer */
if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
@@ -523,12 +523,12 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
return err;
}
- if (0 != (err = videobuf_dma_pci_map(dev->pci, &dev->dmasound.dma))) {
+ if (0 != (err = videobuf_pci_dma_map(dev->pci, &dev->dmasound.dma))) {
dsp_buffer_free(dev);
return err;
}
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt))) {
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
@@ -537,7 +537,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream,
dev->dmasound.dma.sglen,
0))) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
return err;
}
@@ -571,7 +571,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream)
if (substream->runtime->dma_area) {
saa7134_pgtable_free(dev->pci, &dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci, &dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci, &dev->dmasound.dma);
dsp_buffer_free(dev);
substream->runtime->dma_area = NULL;
}
diff --git a/drivers/media/video/saa7134/saa7134-core.c b/drivers/media/video/saa7134/saa7134-core.c
index 58e568d7d2e..c98571c9d5a 100644
--- a/drivers/media/video/saa7134/saa7134-core.c
+++ b/drivers/media/video/saa7134/saa7134-core.c
@@ -254,12 +254,12 @@ void saa7134_pgtable_free(struct pci_dev *pci, struct saa7134_pgtable *pt)
/* ------------------------------------------------------------------ */
-void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf)
+void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf)
{
BUG_ON(in_interrupt());
videobuf_waiton(&buf->vb,0,0);
- videobuf_dma_pci_unmap(dev->pci, &buf->vb.dma);
+ videobuf_dma_unmap(q, &buf->vb.dma);
videobuf_dma_free(&buf->vb.dma);
buf->vb.state = STATE_NEEDS_INIT;
}
@@ -960,7 +960,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
if (saa7134_no_overlay <= 0) {
saa7134_video_template.type |= VID_TYPE_OVERLAY;
} else {
- printk("bttv: Overlay support disabled.\n");
+ printk("%s: Overlay support disabled.\n",dev->name);
}
dev->video_dev = vdev_init(dev,&saa7134_video_template,"video");
err = video_register_device(dev->video_dev,VFL_TYPE_GRABBER,
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index d79d05f8870..7aa02b34e01 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -124,7 +124,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
unsigned long flags;
/* prepare buffer */
- if (0 != (err = videobuf_dma_pci_map(dev->pci,&dev->dmasound.dma)))
+ if (0 != (err = videobuf_pci_dma_map(dev->pci,&dev->dmasound.dma)))
return err;
if (0 != (err = saa7134_pgtable_alloc(dev->pci,&dev->dmasound.pt)))
goto fail1;
@@ -213,7 +213,7 @@ static int dsp_rec_start(struct saa7134_dev *dev)
fail2:
saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
fail1:
- videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
return err;
}
@@ -231,7 +231,7 @@ static int dsp_rec_stop(struct saa7134_dev *dev)
/* unlock buffer */
saa7134_pgtable_free(dev->pci,&dev->dmasound.pt);
- videobuf_dma_pci_unmap(dev->pci,&dev->dmasound.dma);
+ videobuf_pci_dma_unmap(dev->pci,&dev->dmasound.dma);
return 0;
}
diff --git a/drivers/media/video/saa7134/saa7134-ts.c b/drivers/media/video/saa7134/saa7134-ts.c
index 470903e2f5e..60a90a2617a 100644
--- a/drivers/media/video/saa7134/saa7134-ts.c
+++ b/drivers/media/video/saa7134/saa7134-ts.c
@@ -89,7 +89,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return -EINVAL;
if (buf->vb.size != size) {
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -98,7 +98,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
buf->vb.size = size;
buf->pt = &dev->ts.pt_ts;
- err = videobuf_iolock(dev->pci,&buf->vb,NULL);
+ err = videobuf_iolock(q,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -126,7 +126,7 @@ static int buffer_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -152,10 +152,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_dev *dev = q->priv_data;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
struct videobuf_queue_ops saa7134_ts_qops = {
diff --git a/drivers/media/video/saa7134/saa7134-tvaudio.c b/drivers/media/video/saa7134/saa7134-tvaudio.c
index 3043233a8b6..0db53d192b2 100644
--- a/drivers/media/video/saa7134/saa7134-tvaudio.c
+++ b/drivers/media/video/saa7134/saa7134-tvaudio.c
@@ -482,12 +482,14 @@ static int tvaudio_setstereo(struct saa7134_dev *dev, struct saa7134_tvaudio *au
[ V4L2_TUNER_MODE_STEREO ] = "stereo",
[ V4L2_TUNER_MODE_LANG1 ] = "lang1",
[ V4L2_TUNER_MODE_LANG2 ] = "lang2",
+ [ V4L2_TUNER_MODE_LANG1_LANG2 ] = "lang1+lang2",
};
static u32 fm[] = {
[ V4L2_TUNER_MODE_MONO ] = 0x00, /* ch1 */
[ V4L2_TUNER_MODE_STEREO ] = 0x80, /* auto */
[ V4L2_TUNER_MODE_LANG1 ] = 0x00, /* ch1 */
[ V4L2_TUNER_MODE_LANG2 ] = 0x01, /* ch2 */
+ [ V4L2_TUNER_MODE_LANG1_LANG2 ] = 0x80, /* auto */
};
u32 reg;
diff --git a/drivers/media/video/saa7134/saa7134-vbi.c b/drivers/media/video/saa7134/saa7134-vbi.c
index f4aee0af80e..f38366a470f 100644
--- a/drivers/media/video/saa7134/saa7134-vbi.c
+++ b/drivers/media/video/saa7134/saa7134-vbi.c
@@ -135,7 +135,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return -EINVAL;
if (buf->vb.size != size)
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
if (STATE_NEEDS_INIT == buf->vb.state) {
buf->vb.width = llength;
@@ -143,7 +143,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.size = size;
buf->pt = &fh->pt_vbi;
- err = videobuf_iolock(dev->pci,&buf->vb,NULL);
+ err = videobuf_iolock(q,&buf->vb,NULL);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -159,7 +159,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -190,11 +190,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_fh *fh = q->priv_data;
- struct saa7134_dev *dev = fh->dev;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
struct videobuf_queue_ops saa7134_vbi_qops = {
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 57a11e71d99..aeef80f88a6 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -993,7 +993,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->vb.size != size ||
buf->vb.field != field ||
buf->fmt != fh->fmt) {
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
}
if (STATE_NEEDS_INIT == buf->vb.state) {
@@ -1004,7 +1004,7 @@ static int buffer_prepare(struct videobuf_queue *q,
buf->fmt = fh->fmt;
buf->pt = &fh->pt_cap;
- err = videobuf_iolock(dev->pci,&buf->vb,&dev->ovbuf);
+ err = videobuf_iolock(q,&buf->vb,&dev->ovbuf);
if (err)
goto oops;
err = saa7134_pgtable_build(dev->pci,buf->pt,
@@ -1019,7 +1019,7 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0;
oops:
- saa7134_dma_free(dev,buf);
+ saa7134_dma_free(q,buf);
return err;
}
@@ -1045,10 +1045,9 @@ static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{
- struct saa7134_fh *fh = q->priv_data;
struct saa7134_buf *buf = container_of(vb,struct saa7134_buf,vb);
- saa7134_dma_free(fh->dev,buf);
+ saa7134_dma_free(q,buf);
}
static struct videobuf_queue_ops video_qops = {
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index ce1c2e0b065..31ba293854c 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -34,7 +34,6 @@
#include <asm/io.h>
#include <media/tuner.h>
-#include <media/audiochip.h>
#include <media/ir-common.h>
#include <media/ir-kbd-i2c.h>
#include <media/video-buf.h>
@@ -579,7 +578,7 @@ void saa7134_buffer_finish(struct saa7134_dev *dev, struct saa7134_dmaqueue *q,
unsigned int state);
void saa7134_buffer_next(struct saa7134_dev *dev, struct saa7134_dmaqueue *q);
void saa7134_buffer_timeout(unsigned long data);
-void saa7134_dma_free(struct saa7134_dev *dev,struct saa7134_buf *buf);
+void saa7134_dma_free(struct videobuf_queue *q,struct saa7134_buf *buf);
int saa7134_set_dmabits(struct saa7134_dev *dev);
diff --git a/drivers/media/video/saa7146.h b/drivers/media/video/saa7146.h
index 756963f01bb..2830b5e33ae 100644
--- a/drivers/media/video/saa7146.h
+++ b/drivers/media/video/saa7146.h
@@ -1,7 +1,7 @@
-/*
+/*
saa7146.h - definitions philips saa7146 based cards
Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -27,7 +27,7 @@
#include <linux/videodev.h>
-#ifndef O_NONCAP
+#ifndef O_NONCAP
#define O_NONCAP O_TRUNC
#endif
@@ -36,7 +36,7 @@
#ifdef __KERNEL__
-struct saa7146_window
+struct saa7146_window
{
int x, y;
ushort width, height;
@@ -70,7 +70,7 @@ struct saa7146
int irqstate; /* irq routine is state driven */
int writemode;
int playmode;
- unsigned int nr;
+ unsigned int nr;
unsigned long irq; /* IRQ used by SAA7146 card */
unsigned short id;
unsigned char revision;
diff --git a/drivers/media/video/saa7146reg.h b/drivers/media/video/saa7146reg.h
index 6cc910f50a4..80ec2c146b4 100644
--- a/drivers/media/video/saa7146reg.h
+++ b/drivers/media/video/saa7146reg.h
@@ -1,7 +1,7 @@
-/*
+/*
saa7146.h - definitions philips saa7146 based cards
Copyright (C) 1999 Nathan Laredo (laredo@gnu.org)
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
diff --git a/drivers/media/video/saa7185.c b/drivers/media/video/saa7185.c
index 3ed0edb870a..9c308410856 100644
--- a/drivers/media/video/saa7185.c
+++ b/drivers/media/video/saa7185.c
@@ -1,4 +1,4 @@
-/*
+/*
* saa7185 - Philips SAA7185B video encoder driver version 0.0.3
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -49,7 +49,6 @@ MODULE_AUTHOR("Dave Perks");
MODULE_LICENSE("GPL");
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(s) (s)->name
@@ -113,24 +112,21 @@ saa7185_write_block (struct i2c_client *client,
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
/* do raw I2C, not smbus compatible */
struct saa7185 *encoder = i2c_get_clientdata(client);
- struct i2c_msg msg;
u8 block_data[32];
+ int block_len;
- msg.addr = client->addr;
- msg.flags = 0;
while (len >= 2) {
- msg.buf = (char *) block_data;
- msg.len = 0;
- block_data[msg.len++] = reg = data[0];
+ block_len = 0;
+ block_data[block_len++] = reg = data[0];
do {
- block_data[msg.len++] =
+ block_data[block_len++] =
encoder->reg[reg++] = data[1];
len -= 2;
data += 2;
} while (len >= 2 && data[0] == reg &&
- msg.len < 32);
- if ((ret = i2c_transfer(client->adapter,
- &msg, 1)) < 0)
+ block_len < 32);
+ if ((ret = i2c_master_send(client, block_data,
+ block_len)) < 0)
break;
}
} else {
@@ -381,7 +377,7 @@ saa7185_command (struct i2c_client *client,
static unsigned short normal_i2c[] = { I2C_SAA7185 >> 1, I2C_CLIENT_END };
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
diff --git a/drivers/media/video/saa7196.h b/drivers/media/video/saa7196.h
index f92f21cfbca..cd4b6354a7b 100644
--- a/drivers/media/video/saa7196.h
+++ b/drivers/media/video/saa7196.h
@@ -2,14 +2,14 @@
Definitions for the Philips SAA7196 digital video decoder,
scaler, and clock generator circuit (DESCpro), as used in
the PlanB video input of the Powermac 7x00/8x00 series.
-
+
Copyright (C) 1998 Michel Lanners (mlan@cpu.lu)
The register defines are shamelessly copied from the meteor
driver out of NetBSD (with permission),
and are copyrighted (c) 1995 Mark Tinguely and Jim Lowe
(Thanks !)
-
+
Additional debugging and coding by Takashi Oe (toe@unlinfo.unl.edu)
The default values used for PlanB are my mistakes.
diff --git a/drivers/usb/media/se401.c b/drivers/media/video/se401.c
index f03ea7f8959..a846ebc78cd 100644
--- a/drivers/usb/media/se401.c
+++ b/drivers/media/video/se401.c
@@ -4,7 +4,7 @@
* Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
*
* Still somewhat based on the Linux ov511 driver.
- *
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
@@ -114,16 +114,16 @@ static int se401_sndctrl(int set, struct usb_se401 *se401, unsigned short req,
unsigned short value, unsigned char *cp, int size)
{
return usb_control_msg (
- se401->dev,
- set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0),
- req,
- (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- value,
- 0,
- cp,
- size,
- 1000
- );
+ se401->dev,
+ set ? usb_sndctrlpipe(se401->dev, 0) : usb_rcvctrlpipe(se401->dev, 0),
+ req,
+ (set ? USB_DIR_OUT : USB_DIR_IN) | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ value,
+ 0,
+ cp,
+ size,
+ 1000
+ );
}
static int se401_set_feature(struct usb_se401 *se401, unsigned short selector,
@@ -140,30 +140,30 @@ static int se401_set_feature(struct usb_se401 *se401, unsigned short selector,
USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
param,
selector,
- NULL,
- 0,
- 1000
- );
+ NULL,
+ 0,
+ 1000
+ );
}
-static unsigned short se401_get_feature(struct usb_se401 *se401,
- unsigned short selector)
+static unsigned short se401_get_feature(struct usb_se401 *se401,
+ unsigned short selector)
{
/* For 'set' the selecetor should be in index, not sure if the spec is
wrong here to....
*/
unsigned char cp[2];
- usb_control_msg (
- se401->dev,
- usb_rcvctrlpipe(se401->dev, 0),
- SE401_REQ_GET_EXT_FEATURE,
- USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- 0,
- selector,
- cp,
- 2,
- 1000
- );
+ usb_control_msg (
+ se401->dev,
+ usb_rcvctrlpipe(se401->dev, 0),
+ SE401_REQ_GET_EXT_FEATURE,
+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ 0,
+ selector,
+ cp,
+ 2,
+ 1000
+ );
return cp[0]+cp[1]*256;
}
@@ -183,14 +183,14 @@ static int se401_send_pict(struct usb_se401 *se401)
se401_set_feature(se401, HV7131_REG_ARCG, se401->rgain);/* red color gain */
se401_set_feature(se401, HV7131_REG_AGCG, se401->ggain);/* green color gain */
se401_set_feature(se401, HV7131_REG_ABCG, se401->bgain);/* blue color gain */
-
+
return 0;
}
static void se401_set_exposure(struct usb_se401 *se401, int brightness)
{
int integration=brightness<<5;
-
+
if (flickerless==50) {
integration=integration-integration%106667;
}
@@ -255,11 +255,11 @@ static void se401_auto_resetlevel(struct usb_se401 *se401)
/* For some reason this normally read-only register doesn't get reset
to zero after reading them just once...
*/
- se401_get_feature(se401, HV7131_REG_HIREFNOH);
+ se401_get_feature(se401, HV7131_REG_HIREFNOH);
se401_get_feature(se401, HV7131_REG_HIREFNOL);
se401_get_feature(se401, HV7131_REG_LOREFNOH);
se401_get_feature(se401, HV7131_REG_LOREFNOL);
- ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) +
+ ahrc=256*se401_get_feature(se401, HV7131_REG_HIREFNOH) +
se401_get_feature(se401, HV7131_REG_HIREFNOL);
alrc=256*se401_get_feature(se401, HV7131_REG_LOREFNOH) +
se401_get_feature(se401, HV7131_REG_LOREFNOL);
@@ -287,12 +287,12 @@ static void se401_button_irq(struct urb *urb, struct pt_regs *regs)
{
struct usb_se401 *se401 = urb->context;
int status;
-
+
if (!se401->dev) {
info("ohoh: device vapourished");
return;
}
-
+
switch (urb->status) {
case 0:
/* success */
@@ -368,7 +368,7 @@ static void se401_video_irq(struct urb *urb, struct pt_regs *regs)
if (se401->nullpackets > SE401_MAX_NULLPACKETS) {
if (waitqueue_active(&se401->wq)) {
wake_up_interruptible(&se401->wq);
- }
+ }
}
}
@@ -433,8 +433,8 @@ static int se401_start_stream(struct usb_se401 *se401)
int err=0, i;
se401->streaming=1;
- se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
- se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
/* Set picture settings */
se401_set_feature(se401, HV7131_REG_MODE_B, 0x05);/*windowed + pix intg */
@@ -571,7 +571,7 @@ static inline void decode_JangGu_integrate(struct usb_se401 *se401, int data)
}
/* First three are absolute, all others relative.
- * Format is rgb from right to left (mirrorred image),
+ * Format is rgb from right to left (mirrorred image),
* we flip it to get bgr from left to right. */
if (frame->curlinepix < 3) {
*(frame->curline-frame->curlinepix)=1+data*4;
@@ -703,7 +703,7 @@ static inline void decode_bayer (struct usb_se401 *se401, struct se401_scratch *
int width=se401->cwidth;
int blineoffset=0, bline;
int linelength=width*3, i;
-
+
if (frame->curpix==0) {
if (frame->grabstate==FRAME_READY) {
@@ -831,7 +831,7 @@ static int se401_newframe(struct usb_se401 *se401, int framenr)
se401->nullpackets=0;
info("to many null length packets, restarting capture");
se401_stop_stream(se401);
- se401_start_stream(se401);
+ se401_start_stream(se401);
} else {
if (se401->scratch[se401->scratch_use].state!=BUFFER_READY) {
se401->frame[framenr].grabstate=FRAME_ERROR;
@@ -866,7 +866,7 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
{
int i;
- se401->dev = NULL;
+ se401->dev = NULL;
for (i=0; i<SE401_NUMSBUF; i++)
if (se401->urb[i]) {
@@ -882,9 +882,9 @@ static void usb_se401_remove_disconnected (struct usb_se401 *se401)
usb_kill_urb(se401->inturb);
usb_free_urb(se401->inturb);
}
- info("%s disconnected", se401->camera_name);
+ info("%s disconnected", se401->camera_name);
- /* Free the memory */
+ /* Free the memory */
kfree(se401->width);
kfree(se401->height);
kfree(se401);
@@ -910,7 +910,7 @@ static int se401_open(struct inode *inode, struct file *file)
se401->fbuf = rvmalloc(se401->maxframesize * SE401_NUMFRAMES);
if (se401->fbuf)
file->private_data = dev;
- else
+ else
err = -ENOMEM;
se401->user = !err;
@@ -920,11 +920,11 @@ static int se401_open(struct inode *inode, struct file *file)
static int se401_close(struct inode *inode, struct file *file)
{
struct video_device *dev = file->private_data;
- struct usb_se401 *se401 = (struct usb_se401 *)dev;
+ struct usb_se401 *se401 = (struct usb_se401 *)dev;
int i;
rvfree(se401->fbuf, se401->maxframesize * SE401_NUMFRAMES);
- if (se401->removed) {
+ if (se401->removed) {
usb_se401_remove_disconnected(se401);
info("device unregistered");
} else {
@@ -942,12 +942,12 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, void *arg)
{
struct video_device *vdev = file->private_data;
- struct usb_se401 *se401 = (struct usb_se401 *)vdev;
+ struct usb_se401 *se401 = (struct usb_se401 *)vdev;
- if (!se401->dev)
- return -EIO;
+ if (!se401->dev)
+ return -EIO;
- switch (cmd) {
+ switch (cmd) {
case VIDIOCGCAP:
{
struct video_capability *b = arg;
@@ -981,8 +981,8 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
return -EINVAL;
return 0;
}
- case VIDIOCGPICT:
- {
+ case VIDIOCGPICT:
+ {
struct video_picture *p = arg;
se401_get_pict(se401, p);
@@ -1007,7 +1007,7 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
if (se401_set_size(se401, vw->width, vw->height))
return -EINVAL;
return 0;
- }
+ }
case VIDIOCGWIN:
{
struct video_window *vw = arg;
@@ -1095,11 +1095,11 @@ static int se401_do_ioctl(struct inode *inode, struct file *file,
case VIDIOCGAUDIO:
case VIDIOCSAUDIO:
return -EINVAL;
- default:
- return -ENOIOCTLCMD;
- } /* end switch */
+ default:
+ return -ENOIOCTLCMD;
+ } /* end switch */
- return 0;
+ return 0;
}
static int se401_ioctl(struct inode *inode, struct file *file,
@@ -1142,7 +1142,7 @@ static ssize_t se401_read(struct file *file, char __user *buf,
se401->frame[0].grabstate=FRAME_UNUSED;
if (ret)
- return ret;
+ return ret;
if (copy_to_user(buf, se401->frame[0].data, realcount))
return -EFAULT;
@@ -1183,24 +1183,24 @@ static int se401_mmap(struct file *file, struct vm_area_struct *vma)
}
mutex_unlock(&se401->lock);
- return 0;
+ return 0;
}
static struct file_operations se401_fops = {
.owner = THIS_MODULE,
- .open = se401_open,
- .release = se401_close,
- .read = se401_read,
- .mmap = se401_mmap,
+ .open = se401_open,
+ .release = se401_close,
+ .read = se401_read,
+ .mmap = se401_mmap,
.ioctl = se401_ioctl,
.compat_ioctl = v4l_compat_ioctl32,
.llseek = no_llseek,
};
static struct video_device se401_template = {
.owner = THIS_MODULE,
- .name = "se401 USB camera",
- .type = VID_TYPE_CAPTURE,
- .hardware = VID_HARDWARE_SE401,
+ .name = "se401 USB camera",
+ .type = VID_TYPE_CAPTURE,
+ .hardware = VID_HARDWARE_SE401,
.fops = &se401_fops,
};
@@ -1209,12 +1209,12 @@ static struct video_device se401_template = {
/***************************/
static int se401_init(struct usb_se401 *se401, int button)
{
- int i=0, rc;
- unsigned char cp[0x40];
+ int i=0, rc;
+ unsigned char cp[0x40];
char temp[200];
/* led on */
- se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
/* get camera descriptor */
rc=se401_sndctrl(0, se401, SE401_REQ_GET_CAMERA_DESCRIPTOR, 0, cp, sizeof(cp));
@@ -1254,7 +1254,7 @@ static int se401_init(struct usb_se401 *se401, int button)
return 1;
}
/* set output mode (BAYER) */
- se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_SET_OUTPUT_MODE, SE401_FORMAT_BAYER, NULL, 0);
rc=se401_sndctrl(0, se401, SE401_REQ_GET_BRT, 0, cp, sizeof(cp));
se401->brightness=cp[0]+cp[1]*256;
@@ -1292,71 +1292,71 @@ static int se401_init(struct usb_se401 *se401, int button)
} else
se401->inturb=NULL;
- /* Flash the led */
- se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
- se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
- se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
+ /* Flash the led */
+ se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 1, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 1, NULL, 0);
+ se401_sndctrl(1, se401, SE401_REQ_CAMERA_POWER, 0, NULL, 0);
se401_sndctrl(1, se401, SE401_REQ_LED_CONTROL, 0, NULL, 0);
- return 0;
+ return 0;
}
static int se401_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{
struct usb_device *dev = interface_to_usbdev(intf);
- struct usb_interface_descriptor *interface;
- struct usb_se401 *se401;
- char *camera_name=NULL;
+ struct usb_interface_descriptor *interface;
+ struct usb_se401 *se401;
+ char *camera_name=NULL;
int button=1;
- /* We don't handle multi-config cameras */
- if (dev->descriptor.bNumConfigurations != 1)
- return -ENODEV;
+ /* We don't handle multi-config cameras */
+ if (dev->descriptor.bNumConfigurations != 1)
+ return -ENODEV;
- interface = &intf->cur_altsetting->desc;
+ interface = &intf->cur_altsetting->desc;
- /* Is it an se401? */
- if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 &&
- le16_to_cpu(dev->descriptor.idProduct) == 0x0004) {
- camera_name="Endpoints/Aox SE401";
- } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 &&
- le16_to_cpu(dev->descriptor.idProduct) == 0x030b) {
- camera_name="Philips PCVC665K";
- } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
+ /* Is it an se401? */
+ if (le16_to_cpu(dev->descriptor.idVendor) == 0x03e8 &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x0004) {
+ camera_name="Endpoints/Aox SE401";
+ } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x0471 &&
+ le16_to_cpu(dev->descriptor.idProduct) == 0x030b) {
+ camera_name="Philips PCVC665K";
+ } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
le16_to_cpu(dev->descriptor.idProduct) == 0x5001) {
camera_name="Kensington VideoCAM 67014";
- } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
+ } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
le16_to_cpu(dev->descriptor.idProduct) == 0x5002) {
camera_name="Kensington VideoCAM 6701(5/7)";
- } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
+ } else if (le16_to_cpu(dev->descriptor.idVendor) == 0x047d &&
le16_to_cpu(dev->descriptor.idProduct) == 0x5003) {
camera_name="Kensington VideoCAM 67016";
button=0;
} else
return -ENODEV;
- /* Checking vendor/product should be enough, but what the hell */
- if (interface->bInterfaceClass != 0x00)
+ /* Checking vendor/product should be enough, but what the hell */
+ if (interface->bInterfaceClass != 0x00)
return -ENODEV;
- if (interface->bInterfaceSubClass != 0x00)
+ if (interface->bInterfaceSubClass != 0x00)
return -ENODEV;
- /* We found one */
- info("SE401 camera found: %s", camera_name);
+ /* We found one */
+ info("SE401 camera found: %s", camera_name);
- if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
- err("couldn't kmalloc se401 struct");
+ if ((se401 = kzalloc(sizeof(*se401), GFP_KERNEL)) == NULL) {
+ err("couldn't kmalloc se401 struct");
return -ENOMEM;
- }
+ }
- se401->dev = dev;
- se401->iface = interface->bInterfaceNumber;
- se401->camera_name = camera_name;
+ se401->dev = dev;
+ se401->iface = interface->bInterfaceNumber;
+ se401->camera_name = camera_name;
info("firmware version: %02x", le16_to_cpu(dev->descriptor.bcdDevice) & 255);
- if (se401_init(se401, button)) {
+ if (se401_init(se401, button)) {
kfree(se401);
return -EIO;
}
@@ -1375,7 +1375,7 @@ static int se401_probe(struct usb_interface *intf,
info("registered new video device: video%d", se401->vdev.minor);
usb_set_intfdata (intf, se401);
- return 0;
+ return 0;
}
static void se401_disconnect(struct usb_interface *intf)
@@ -1400,10 +1400,10 @@ static void se401_disconnect(struct usb_interface *intf)
}
static struct usb_driver se401_driver = {
- .name = "se401",
- .id_table = device_table,
+ .name = "se401",
+ .id_table = device_table,
.probe = se401_probe,
- .disconnect = se401_disconnect,
+ .disconnect = se401_disconnect,
};
diff --git a/drivers/usb/media/se401.h b/drivers/media/video/se401.h
index e88a40d4c86..a7a216bd441 100644
--- a/drivers/usb/media/se401.h
+++ b/drivers/media/video/se401.h
@@ -177,7 +177,7 @@ struct usb_se401 {
int expose_m;
int expose_l;
int resetlevel;
-
+
int enhance;
int format;
@@ -200,12 +200,12 @@ struct usb_se401 {
struct urb *urb[SE401_NUMSBUF];
struct urb *inturb;
-
+
int button;
int buttonpressed;
int curframe; /* Current receiving frame */
- struct se401_frame frame[SE401_NUMFRAMES];
+ struct se401_frame frame[SE401_NUMFRAMES];
int readcount;
int framecount;
int error;
diff --git a/drivers/media/video/sn9c102/Makefile b/drivers/media/video/sn9c102/Makefile
new file mode 100644
index 00000000000..536ad3098da
--- /dev/null
+++ b/drivers/media/video/sn9c102/Makefile
@@ -0,0 +1,7 @@
+sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
+ sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
+ sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
+ sn9c102_tas5130d1b.o
+
+obj-$(CONFIG_USB_SN9C102) += sn9c102.o
+
diff --git a/drivers/usb/media/sn9c102.h b/drivers/media/video/sn9c102/sn9c102.h
index 1d70a62b9f2..2c6ff396daf 100644
--- a/drivers/usb/media/sn9c102.h
+++ b/drivers/media/video/sn9c102/sn9c102.h
@@ -164,7 +164,7 @@ sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id)
void
sn9c102_attach_sensor(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor)
+ struct sn9c102_sensor* sensor)
{
memcpy(&cam->sensor, sensor, sizeof(struct sn9c102_sensor));
}
@@ -183,7 +183,7 @@ do { \
dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
else if ((level) >= 3) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args); \
+ __FUNCTION__, __LINE__ , ## args); \
} \
} while (0)
# define V4LDBG(level, name, cmd) \
@@ -198,7 +198,7 @@ do { \
pr_info("sn9c102: " fmt "\n", ## args); \
else if ((level) == 3) \
pr_debug("sn9c102: [%s:%d] " fmt "\n", __FUNCTION__, \
- __LINE__ , ## args); \
+ __LINE__ , ## args); \
} \
} while (0)
#else
@@ -210,7 +210,7 @@ do { \
#undef PDBG
#define PDBG(fmt, args...) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args)
+ __FUNCTION__, __LINE__ , ## args)
#undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/media/video/sn9c102/sn9c102_core.c
index 4c6cc639572..ea4394dc941 100644
--- a/drivers/usb/media/sn9c102_core.c
+++ b/drivers/media/video/sn9c102/sn9c102_core.c
@@ -62,53 +62,53 @@ MODULE_LICENSE(SN9C102_MODULE_LICENSE);
static short video_nr[] = {[0 ... SN9C102_MAX_DEVICES-1] = -1};
module_param_array(video_nr, short, NULL, 0444);
MODULE_PARM_DESC(video_nr,
- "\n<-1|n[,...]> Specify V4L2 minor mode number."
- "\n -1 = use next available (default)"
- "\n n = use minor number n (integer >= 0)"
- "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES)
- " cameras this way."
- "\nFor example:"
- "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
- "\nthe second camera and use auto for the first"
- "\none and for every other camera."
- "\n");
-
-static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
- SN9C102_FORCE_MUNMAP};
+ "\n<-1|n[,...]> Specify V4L2 minor mode number."
+ "\n -1 = use next available (default)"
+ "\n n = use minor number n (integer >= 0)"
+ "\nYou can specify up to "__MODULE_STRING(SN9C102_MAX_DEVICES)
+ " cameras this way."
+ "\nFor example:"
+ "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
+ "\nthe second camera and use auto for the first"
+ "\none and for every other camera."
+ "\n");
+
+static short force_munmap[] = {[0 ... SN9C102_MAX_DEVICES-1] =
+ SN9C102_FORCE_MUNMAP};
module_param_array(force_munmap, bool, NULL, 0444);
MODULE_PARM_DESC(force_munmap,
- "\n<0|1[,...]> Force the application to unmap previously"
- "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
- "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
- "\nthis feature. This parameter is specific for each"
- "\ndetected camera."
- "\n 0 = do not force memory unmapping"
- "\n 1 = force memory unmapping (save memory)"
- "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
- "\n");
+ "\n<0|1[,...]> Force the application to unmap previously"
+ "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
+ "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
+ "\nthis feature. This parameter is specific for each"
+ "\ndetected camera."
+ "\n 0 = do not force memory unmapping"
+ "\n 1 = force memory unmapping (save memory)"
+ "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
+ "\n");
static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] =
- SN9C102_FRAME_TIMEOUT};
+ SN9C102_FRAME_TIMEOUT};
module_param_array(frame_timeout, uint, NULL, 0644);
MODULE_PARM_DESC(frame_timeout,
- "\n<n[,...]> Timeout for a video frame in seconds."
- "\nThis parameter is specific for each detected camera."
- "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"."
- "\n");
+ "\n<n[,...]> Timeout for a video frame in seconds."
+ "\nThis parameter is specific for each detected camera."
+ "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"."
+ "\n");
#ifdef SN9C102_DEBUG
static unsigned short debug = SN9C102_DEBUG_LEVEL;
module_param(debug, ushort, 0644);
MODULE_PARM_DESC(debug,
- "\n<n> Debugging information level, from 0 to 3:"
- "\n0 = none (use carefully)"
- "\n1 = critical errors"
- "\n2 = significant informations"
- "\n3 = more verbose messages"
- "\nLevel 3 is useful for testing only, when only "
- "one device is used."
- "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"."
- "\n");
+ "\n<n> Debugging information level, from 0 to 3:"
+ "\n0 = none (use carefully)"
+ "\n1 = critical errors"
+ "\n2 = significant informations"
+ "\n3 = more verbose messages"
+ "\nLevel 3 is useful for testing only, when only "
+ "one device is used."
+ "\nDefault value is "__MODULE_STRING(SN9C102_DEBUG_LEVEL)"."
+ "\n");
#endif
/*****************************************************************************/
@@ -131,16 +131,16 @@ static sn9c102_eof_header_t sn9c102_eof_header[] = {
/*****************************************************************************/
-static u32
-sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
- enum sn9c102_io_method io)
+static u32
+sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
+ enum sn9c102_io_method io)
{
struct v4l2_pix_format* p = &(cam->sensor.pix_format);
struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
const size_t imagesize = cam->module_param.force_munmap ||
- io == IO_READ ?
- (p->width * p->height * p->priv) / 8 :
- (r->width * r->height * p->priv) / 8;
+ io == IO_READ ?
+ (p->width * p->height * p->priv) / 8 :
+ (r->width * r->height * p->priv) / 8;
void* buff = NULL;
u32 i;
@@ -232,8 +232,8 @@ int sn9c102_write_regs(struct sn9c102_device* cam, u8* buff, u16 index)
return -1;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
- index, 0, buff, sizeof(buff),
- SN9C102_CTRL_TIMEOUT*sizeof(buff));
+ index, 0, buff, sizeof(buff),
+ SN9C102_CTRL_TIMEOUT*sizeof(buff));
if (res < 0) {
DBG(3, "Failed to write registers (index 0x%02X, error %d)",
index, res);
@@ -259,7 +259,7 @@ int sn9c102_write_reg(struct sn9c102_device* cam, u8 value, u16 index)
*buff = value;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
- index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
+ index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
if (res < 0) {
DBG(3, "Failed to write a register (value 0x%02X, index "
"0x%02X, error %d)", value, index, res);
@@ -280,7 +280,7 @@ static int sn9c102_read_reg(struct sn9c102_device* cam, u16 index)
int res;
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
- index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
+ index, 0, buff, 1, SN9C102_CTRL_TIMEOUT);
if (res < 0)
DBG(3, "Failed to read a register (index 0x%02X, error %d)",
index, res);
@@ -319,8 +319,8 @@ sn9c102_i2c_wait(struct sn9c102_device* cam, struct sn9c102_sensor* sensor)
static int
-sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor)
+sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
+ struct sn9c102_sensor* sensor)
{
int r;
r = sn9c102_read_reg(cam, 0x08);
@@ -329,8 +329,8 @@ sn9c102_i2c_detect_read_error(struct sn9c102_device* cam,
static int
-sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor)
+sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
+ struct sn9c102_sensor* sensor)
{
int r;
r = sn9c102_read_reg(cam, 0x08);
@@ -338,10 +338,10 @@ sn9c102_i2c_detect_write_error(struct sn9c102_device* cam,
}
-int
+int
sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 data0, u8 data1,
- u8 n, u8 buffer[])
+ struct sn9c102_sensor* sensor, u8 data0, u8 data1,
+ u8 n, u8 buffer[])
{
struct usb_device* udev = cam->usbdev;
u8* data = cam->control_buffer;
@@ -349,12 +349,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
/* Write cycle */
data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
- ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10;
+ ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) | 0x10;
data[1] = data0; /* I2C slave id */
data[2] = data1; /* address */
data[7] = 0x10;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
- 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
+ 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -362,12 +362,12 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
/* Read cycle - n bytes */
data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
- ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) |
- (n << 4) | 0x02;
+ ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0) |
+ (n << 4) | 0x02;
data[1] = data0;
data[7] = 0x10;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
- 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
+ 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -375,7 +375,7 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
/* The first read byte will be placed in data[4] */
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x00, 0xc1,
- 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT);
+ 0x0a, 0, data, 5, SN9C102_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -396,10 +396,10 @@ sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
}
-int
+int
sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 n, u8 data0,
- u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
+ struct sn9c102_sensor* sensor, u8 n, u8 data0,
+ u8 data1, u8 data2, u8 data3, u8 data4, u8 data5)
{
struct usb_device* udev = cam->usbdev;
u8* data = cam->control_buffer;
@@ -407,8 +407,8 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
/* Write cycle. It usually is address + value */
data[0] = ((sensor->interface == SN9C102_I2C_2WIRES) ? 0x80 : 0) |
- ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0)
- | ((n - 1) << 4);
+ ((sensor->frequency & SN9C102_I2C_400KHZ) ? 0x01 : 0)
+ | ((n - 1) << 4);
data[1] = data0;
data[2] = data1;
data[3] = data2;
@@ -417,7 +417,7 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
data[6] = data5;
data[7] = 0x14;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x08, 0x41,
- 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
+ 0x08, 0, data, 8, SN9C102_CTRL_TIMEOUT);
if (res < 0)
err += res;
@@ -437,20 +437,20 @@ sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
int
sn9c102_i2c_try_read(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 address)
+ struct sn9c102_sensor* sensor, u8 address)
{
return sn9c102_i2c_try_raw_read(cam, sensor, sensor->i2c_slave_id,
- address, 1, NULL);
+ address, 1, NULL);
}
int
sn9c102_i2c_try_write(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 address, u8 value)
+ struct sn9c102_sensor* sensor, u8 address, u8 value)
{
- return sn9c102_i2c_try_raw_write(cam, sensor, 3,
- sensor->i2c_slave_id, address,
- value, 0, 0, 0);
+ return sn9c102_i2c_try_raw_write(cam, sensor, 3,
+ sensor->i2c_slave_id, address,
+ value, 0, 0, 0);
}
@@ -484,7 +484,7 @@ sn9c102_find_sof_header(struct sn9c102_device* cam, void* mem, size_t len)
n = sizeof(sn9c103_sof_header) / soflen;
}
- for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
+ for (i = 0; (len >= soflen) && (i <= len - soflen); i++)
for (j = 0; j < n; j++)
/* The invariable part of the header is 6 bytes long */
if ((cam->bridge != BRIDGE_SN9C103 &&
@@ -552,15 +552,15 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs)
if (!(*f))
(*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t,
- frame);
+ frame);
imagesize = (cam->sensor.pix_format.width *
- cam->sensor.pix_format.height *
- cam->sensor.pix_format.priv) / 8;
+ cam->sensor.pix_format.height *
+ cam->sensor.pix_format.priv) / 8;
soflen = (cam->bridge) == BRIDGE_SN9C103 ?
- sizeof(sn9c103_sof_header_t) :
- sizeof(sn9c102_sof_header_t);
+ sizeof(sn9c103_sof_header_t) :
+ sizeof(sn9c102_sof_header_t);
for (i = 0; i < urb->number_of_packets; i++) {
unsigned int img, len, status;
@@ -611,19 +611,19 @@ end_of_frame:
if ((*f)->buf.bytesused == imagesize ||
(cam->sensor.pix_format.pixelformat ==
- V4L2_PIX_FMT_SN9C10X && eof)) {
+ V4L2_PIX_FMT_SN9C10X && eof)) {
u32 b;
b = (*f)->buf.bytesused;
(*f)->state = F_DONE;
(*f)->buf.sequence= ++cam->frame_count;
spin_lock(&cam->queue_lock);
list_move_tail(&(*f)->frame,
- &cam->outqueue);
+ &cam->outqueue);
if (!list_empty(&cam->inqueue))
(*f) = list_entry(
- cam->inqueue.next,
- struct sn9c102_frame_t,
- frame );
+ cam->inqueue.next,
+ struct sn9c102_frame_t,
+ frame );
else
(*f) = NULL;
spin_unlock(&cam->queue_lock);
@@ -638,7 +638,7 @@ end_of_frame:
} else if (eof) {
(*f)->state = F_ERROR;
DBG(3, "Not expected EOF after %lu "
- "bytes of image data",
+ "bytes of image data",
(unsigned long)
((*f)->buf.bytesused));
}
@@ -676,7 +676,7 @@ start_of_frame:
goto end_of_frame;
} else {
DBG(3, "SOF before expected EOF after "
- "%lu bytes of image data",
+ "%lu bytes of image data",
(unsigned long)
((*f)->buf.bytesused));
goto start_of_frame;
@@ -702,18 +702,18 @@ static int sn9c102_start_transfer(struct sn9c102_device* cam)
struct usb_device *udev = cam->usbdev;
struct urb* urb;
const unsigned int sn9c102_wMaxPacketSize[] = {0, 128, 256, 384, 512,
- 680, 800, 900, 1023};
+ 680, 800, 900, 1023};
const unsigned int sn9c103_wMaxPacketSize[] = {0, 128, 256, 384, 512,
- 680, 800, 900, 1003};
+ 680, 800, 900, 1003};
const unsigned int psz = (cam->bridge == BRIDGE_SN9C103) ?
- sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
- sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
+ sn9c103_wMaxPacketSize[SN9C102_ALTERNATE_SETTING] :
+ sn9c102_wMaxPacketSize[SN9C102_ALTERNATE_SETTING];
s8 i, j;
int err = 0;
for (i = 0; i < SN9C102_URBS; i++) {
cam->transfer_buffer[i] = kzalloc(SN9C102_ISO_PACKETS * psz,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!cam->transfer_buffer[i]) {
err = -ENOMEM;
DBG(1, "Not enough memory");
@@ -815,9 +815,9 @@ static int sn9c102_stream_interrupt(struct sn9c102_device* cam)
cam->stream = STREAM_INTERRUPT;
timeout = wait_event_timeout(cam->wait_stream,
- (cam->stream == STREAM_OFF) ||
- (cam->state & DEV_DISCONNECTED),
- SN9C102_URB_TIMEOUT);
+ (cam->stream == STREAM_OFF) ||
+ (cam->state & DEV_DISCONNECTED),
+ SN9C102_URB_TIMEOUT);
if (cam->state & DEV_DISCONNECTED)
return -ENODEV;
else if (cam->stream != STREAM_OFF) {
@@ -861,7 +861,7 @@ static u8 sn9c102_strtou8(const char* buff, size_t len, ssize_t* count)
/*
NOTE 1: being inside one of the following methods implies that the v4l
- device exists for sure (see kobjects and reference counters)
+ device exists for sure (see kobjects and reference counters)
NOTE 2: buffers are PAGE_SIZE long
*/
@@ -884,10 +884,10 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf)
mutex_unlock(&sn9c102_sysfs_lock);
return count;
-}
+}
-static ssize_t
+static ssize_t
sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len)
{
struct sn9c102_device* cam;
@@ -947,7 +947,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf)
mutex_unlock(&sn9c102_sysfs_lock);
return count;
-}
+}
static ssize_t
@@ -1013,7 +1013,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf)
}
-static ssize_t
+static ssize_t
sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len)
{
struct sn9c102_device* cam;
@@ -1078,7 +1078,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf)
mutex_unlock(&sn9c102_sysfs_lock);
return count;
-}
+}
static ssize_t
@@ -1222,22 +1222,22 @@ static ssize_t sn9c102_show_frame_header(struct class_device* cd, char* buf)
DBG(3, "Frame header, read bytes: %zd", count);
return count;
-}
+}
static CLASS_DEVICE_ATTR(reg, S_IRUGO | S_IWUSR,
- sn9c102_show_reg, sn9c102_store_reg);
+ sn9c102_show_reg, sn9c102_store_reg);
static CLASS_DEVICE_ATTR(val, S_IRUGO | S_IWUSR,
- sn9c102_show_val, sn9c102_store_val);
+ sn9c102_show_val, sn9c102_store_val);
static CLASS_DEVICE_ATTR(i2c_reg, S_IRUGO | S_IWUSR,
- sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
+ sn9c102_show_i2c_reg, sn9c102_store_i2c_reg);
static CLASS_DEVICE_ATTR(i2c_val, S_IRUGO | S_IWUSR,
- sn9c102_show_i2c_val, sn9c102_store_i2c_val);
+ sn9c102_show_i2c_val, sn9c102_store_i2c_val);
static CLASS_DEVICE_ATTR(green, S_IWUGO, NULL, sn9c102_store_green);
static CLASS_DEVICE_ATTR(blue, S_IWUGO, NULL, sn9c102_store_blue);
static CLASS_DEVICE_ATTR(red, S_IWUGO, NULL, sn9c102_store_red);
static CLASS_DEVICE_ATTR(frame_header, S_IRUGO,
- sn9c102_show_frame_header, NULL);
+ sn9c102_show_frame_header, NULL);
static void sn9c102_create_sysfs(struct sn9c102_device* cam)
@@ -1278,7 +1278,7 @@ sn9c102_set_pix_format(struct sn9c102_device* cam, struct v4l2_pix_format* pix)
static int
sn9c102_set_compression(struct sn9c102_device* cam,
- struct v4l2_jpegcompression* compression)
+ struct v4l2_jpegcompression* compression)
{
int err = 0;
@@ -1469,8 +1469,8 @@ static int sn9c102_open(struct inode* inode, struct file* filp)
}
mutex_unlock(&cam->dev_mutex);
err = wait_event_interruptible_exclusive(cam->open,
- cam->state & DEV_DISCONNECTED
- || !cam->users);
+ cam->state & DEV_DISCONNECTED
+ || !cam->users);
if (err) {
up_read(&sn9c102_disconnect);
return err;
@@ -1600,12 +1600,12 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
return -EAGAIN;
}
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
@@ -1672,7 +1672,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait)
if (cam->io == IO_NONE) {
if (!sn9c102_request_buffers(cam, cam->nreadbuffers,
- IO_READ)) {
+ IO_READ)) {
DBG(1, "poll() failed, not enough memory");
goto error;
}
@@ -1729,7 +1729,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma)
{
struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
unsigned long size = vma->vm_end - vma->vm_start,
- start = vma->vm_start;
+ start = vma->vm_start;
void *pos;
u32 i;
@@ -1797,13 +1797,13 @@ sn9c102_vidioc_querycap(struct sn9c102_device* cam, void __user * arg)
.driver = "sn9c102",
.version = SN9C102_MODULE_VERSION_CODE,
.capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
- V4L2_CAP_STREAMING,
+ V4L2_CAP_STREAMING,
};
strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
- sizeof(cap.bus_info));
+ sizeof(cap.bus_info));
if (copy_to_user(arg, &cap, sizeof(cap)))
return -EFAULT;
@@ -2138,7 +2138,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
return -EINVAL;
pfmt->bytesperline = (pfmt->pixelformat==V4L2_PIX_FMT_SN9C10X)
- ? 0 : (pfmt->width * pfmt->priv) / 8;
+ ? 0 : (pfmt->width * pfmt->priv) / 8;
pfmt->sizeimage = pfmt->height * ((pfmt->width*pfmt->priv)/8);
pfmt->field = V4L2_FIELD_NONE;
memcpy(&(format.fmt.pix), pfmt, sizeof(*pfmt));
@@ -2152,7 +2152,7 @@ sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg)
static int
sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
- void __user * arg)
+ void __user * arg)
{
struct sn9c102_sensor* s = &cam->sensor;
struct v4l2_format format;
@@ -2214,7 +2214,7 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
pix->priv = pfmt->priv; /* bpp */
pix->colorspace = pfmt->colorspace;
pix->bytesperline = (pix->pixelformat == V4L2_PIX_FMT_SN9C10X)
- ? 0 : (pix->width * pix->priv) / 8;
+ ? 0 : (pix->width * pix->priv) / 8;
pix->sizeimage = pix->height * ((pix->width * pix->priv) / 8);
pix->field = V4L2_FIELD_NONE;
@@ -2287,7 +2287,7 @@ static int
sn9c102_vidioc_g_jpegcomp(struct sn9c102_device* cam, void __user * arg)
{
if (copy_to_user(arg, &cam->compression,
- sizeof(cam->compression)))
+ sizeof(cam->compression)))
return -EFAULT;
return 0;
@@ -2436,7 +2436,7 @@ sn9c102_vidioc_qbuf(struct sn9c102_device* cam, void __user * arg)
static int
sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
- void __user * arg)
+ void __user * arg)
{
struct v4l2_buffer b;
struct sn9c102_frame_t *f;
@@ -2455,12 +2455,12 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp,
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0)
return timeout;
if (cam->state & DEV_DISCONNECTED)
@@ -2584,7 +2584,7 @@ sn9c102_vidioc_s_parm(struct sn9c102_device* cam, void __user * arg)
static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
- unsigned int cmd, void __user * arg)
+ unsigned int cmd, void __user * arg)
{
struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
@@ -2678,7 +2678,7 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp,
static int sn9c102_ioctl(struct inode* inode, struct file* filp,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp));
int err = 0;
@@ -2761,7 +2761,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
}
cam->bridge = (id->idProduct & 0xffc0) == 0x6080 ?
- BRIDGE_SN9C103 : BRIDGE_SN9C102;
+ BRIDGE_SN9C103 : BRIDGE_SN9C102;
switch (cam->bridge) {
case BRIDGE_SN9C101:
case BRIDGE_SN9C102:
@@ -2807,7 +2807,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
mutex_lock(&cam->dev_mutex);
err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
- video_nr[dev_nr]);
+ video_nr[dev_nr]);
if (err) {
DBG(1, "V4L2 device registration failed");
if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/usb/media/sn9c102_hv7131d.c b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
index 46c12ec3ca6..c4117bf64b6 100644
--- a/drivers/usb/media/sn9c102_hv7131d.c
+++ b/drivers/media/video/sn9c102/sn9c102_hv7131d.c
@@ -44,8 +44,8 @@ static int hv7131d_init(struct sn9c102_device* cam)
}
-static int hv7131d_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
+static int hv7131d_get_ctrl(struct sn9c102_device* cam,
+ struct v4l2_control* ctrl)
{
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
@@ -88,8 +88,8 @@ static int hv7131d_get_ctrl(struct sn9c102_device* cam,
}
-static int hv7131d_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int hv7131d_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -121,8 +121,8 @@ static int hv7131d_set_ctrl(struct sn9c102_device* cam,
}
-static int hv7131d_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int hv7131d_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &hv7131d;
int err = 0;
@@ -136,8 +136,8 @@ static int hv7131d_set_crop(struct sn9c102_device* cam,
}
-static int hv7131d_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int hv7131d_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
diff --git a/drivers/usb/media/sn9c102_mi0343.c b/drivers/media/video/sn9c102/sn9c102_mi0343.c
index d9aa7a61095..4169ea4a2e2 100644
--- a/drivers/usb/media/sn9c102_mi0343.c
+++ b/drivers/media/video/sn9c102/sn9c102_mi0343.c
@@ -39,64 +39,64 @@ static int mi0343_init(struct sn9c102_device* cam)
err += sn9c102_write_reg(cam, 0xa0, 0x19);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x0d, 0x00, 0x01, 0, 0);
+ 0x0d, 0x00, 0x01, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x0d, 0x00, 0x00, 0, 0);
+ 0x0d, 0x00, 0x00, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x03, 0x01, 0xe1, 0, 0);
+ 0x03, 0x01, 0xe1, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x04, 0x02, 0x81, 0, 0);
+ 0x04, 0x02, 0x81, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x05, 0x00, 0x17, 0, 0);
+ 0x05, 0x00, 0x17, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x06, 0x00, 0x11, 0, 0);
+ 0x06, 0x00, 0x11, 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4, mi0343.i2c_slave_id,
- 0x62, 0x04, 0x9a, 0, 0);
+ 0x62, 0x04, 0x9a, 0, 0);
return err;
}
-static int mi0343_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
+static int mi0343_get_ctrl(struct sn9c102_device* cam,
+ struct v4l2_control* ctrl)
{
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x09, 2+1, mi0343_i2c_data) < 0)
+ 0x09, 2+1, mi0343_i2c_data) < 0)
return -EIO;
ctrl->value = mi0343_i2c_data[2];
return 0;
case V4L2_CID_GAIN:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x35, 2+1, mi0343_i2c_data) < 0)
+ 0x35, 2+1, mi0343_i2c_data) < 0)
return -EIO;
break;
case V4L2_CID_HFLIP:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x20, 2+1, mi0343_i2c_data) < 0)
+ 0x20, 2+1, mi0343_i2c_data) < 0)
return -EIO;
ctrl->value = mi0343_i2c_data[3] & 0x20 ? 1 : 0;
return 0;
case V4L2_CID_VFLIP:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x20, 2+1, mi0343_i2c_data) < 0)
+ 0x20, 2+1, mi0343_i2c_data) < 0)
return -EIO;
ctrl->value = mi0343_i2c_data[3] & 0x80 ? 1 : 0;
return 0;
case V4L2_CID_RED_BALANCE:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x2d, 2+1, mi0343_i2c_data) < 0)
+ 0x2d, 2+1, mi0343_i2c_data) < 0)
return -EIO;
break;
case V4L2_CID_BLUE_BALANCE:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x2c, 2+1, mi0343_i2c_data) < 0)
+ 0x2c, 2+1, mi0343_i2c_data) < 0)
return -EIO;
break;
case SN9C102_V4L2_CID_GREEN_BALANCE:
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id,
- 0x2e, 2+1, mi0343_i2c_data) < 0)
+ 0x2e, 2+1, mi0343_i2c_data) < 0)
return -EIO;
break;
default:
@@ -121,8 +121,8 @@ static int mi0343_get_ctrl(struct sn9c102_device* cam,
}
-static int mi0343_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int mi0343_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
u16 reg = 0;
int err = 0;
@@ -144,51 +144,51 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x09, ctrl->value, 0x00,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x09, ctrl->value, 0x00,
+ 0, 0);
break;
case V4L2_CID_GAIN:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x35, reg >> 8, reg & 0xff,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x35, reg >> 8, reg & 0xff,
+ 0, 0);
break;
case V4L2_CID_HFLIP:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x20, ctrl->value ? 0x40:0x00,
- ctrl->value ? 0x20:0x00,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x20, ctrl->value ? 0x40:0x00,
+ ctrl->value ? 0x20:0x00,
+ 0, 0);
break;
case V4L2_CID_VFLIP:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x20, ctrl->value ? 0x80:0x00,
- ctrl->value ? 0x80:0x00,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x20, ctrl->value ? 0x80:0x00,
+ ctrl->value ? 0x80:0x00,
+ 0, 0);
break;
case V4L2_CID_RED_BALANCE:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x2d, reg >> 8, reg & 0xff,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x2d, reg >> 8, reg & 0xff,
+ 0, 0);
break;
case V4L2_CID_BLUE_BALANCE:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x2c, reg >> 8, reg & 0xff,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x2c, reg >> 8, reg & 0xff,
+ 0, 0);
break;
case SN9C102_V4L2_CID_GREEN_BALANCE:
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x2b, reg >> 8, reg & 0xff,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x2b, reg >> 8, reg & 0xff,
+ 0, 0);
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x2e, reg >> 8, reg & 0xff,
- 0, 0);
+ mi0343.i2c_slave_id,
+ 0x2e, reg >> 8, reg & 0xff,
+ 0, 0);
break;
default:
return -EINVAL;
@@ -198,8 +198,8 @@ static int mi0343_set_ctrl(struct sn9c102_device* cam,
}
-static int mi0343_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int mi0343_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &mi0343;
int err = 0;
@@ -213,20 +213,20 @@ static int mi0343_set_crop(struct sn9c102_device* cam,
}
-static int mi0343_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int mi0343_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
if (pix->pixelformat == V4L2_PIX_FMT_SN9C10X) {
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x0a, 0x00, 0x03, 0, 0);
+ mi0343.i2c_slave_id,
+ 0x0a, 0x00, 0x03, 0, 0);
err += sn9c102_write_reg(cam, 0x20, 0x19);
} else {
err += sn9c102_i2c_try_raw_write(cam, &mi0343, 4,
- mi0343.i2c_slave_id,
- 0x0a, 0x00, 0x05, 0, 0);
+ mi0343.i2c_slave_id,
+ 0x0a, 0x00, 0x05, 0, 0);
err += sn9c102_write_reg(cam, 0xa0, 0x19);
}
@@ -351,7 +351,7 @@ int sn9c102_probe_mi0343(struct sn9c102_device* cam)
return -EIO;
if (sn9c102_i2c_try_raw_read(cam, &mi0343, mi0343.i2c_slave_id, 0x00,
- 2, mi0343_i2c_data) < 0)
+ 2, mi0343_i2c_data) < 0)
return -EIO;
if (mi0343_i2c_data[4] != 0x32 && mi0343_i2c_data[3] != 0xe3)
diff --git a/drivers/usb/media/sn9c102_ov7630.c b/drivers/media/video/sn9c102/sn9c102_ov7630.c
index 42852b7cb04..3da04202178 100644
--- a/drivers/usb/media/sn9c102_ov7630.c
+++ b/drivers/media/video/sn9c102/sn9c102_ov7630.c
@@ -69,7 +69,7 @@ static int ov7630_init(struct sn9c102_device* cam)
static int ov7630_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -89,8 +89,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
break;
case V4L2_CID_CONTRAST:
err += ctrl->value ? sn9c102_i2c_write(cam, 0x05,
- (ctrl->value-1) | 0x20)
- : sn9c102_i2c_write(cam, 0x05, 0x00);
+ (ctrl->value-1) | 0x20)
+ : sn9c102_i2c_write(cam, 0x05, 0x00);
break;
case V4L2_CID_BRIGHTNESS:
err += sn9c102_i2c_write(cam, 0x06, ctrl->value);
@@ -100,8 +100,8 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
break;
case V4L2_CID_HUE:
err += ctrl->value ? sn9c102_i2c_write(cam, 0x04,
- (ctrl->value-1) | 0x20)
- : sn9c102_i2c_write(cam, 0x04, 0x00);
+ (ctrl->value-1) | 0x20)
+ : sn9c102_i2c_write(cam, 0x04, 0x00);
break;
case V4L2_CID_DO_WHITE_BALANCE:
err += sn9c102_i2c_write(cam, 0x0c, ctrl->value);
@@ -139,7 +139,7 @@ static int ov7630_set_ctrl(struct sn9c102_device* cam,
static int ov7630_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &ov7630;
int err = 0;
@@ -152,7 +152,7 @@ static int ov7630_set_crop(struct sn9c102_device* cam,
static int ov7630_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+ const struct v4l2_pix_format* pix)
{
int err = 0;
diff --git a/drivers/usb/media/sn9c102_pas106b.c b/drivers/media/video/sn9c102/sn9c102_pas106b.c
index b1dee78abe0..9915944235e 100644
--- a/drivers/usb/media/sn9c102_pas106b.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas106b.c
@@ -53,8 +53,8 @@ static int pas106b_init(struct sn9c102_device* cam)
}
-static int pas106b_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
+static int pas106b_get_ctrl(struct sn9c102_device* cam,
+ struct v4l2_control* ctrl)
{
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
@@ -102,8 +102,8 @@ static int pas106b_get_ctrl(struct sn9c102_device* cam,
}
-static int pas106b_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int pas106b_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -140,8 +140,8 @@ static int pas106b_set_ctrl(struct sn9c102_device* cam,
}
-static int pas106b_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int pas106b_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &pas106b;
int err = 0;
@@ -155,8 +155,8 @@ static int pas106b_set_crop(struct sn9c102_device* cam,
}
-static int pas106b_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int pas106b_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
diff --git a/drivers/usb/media/sn9c102_pas202bca.c b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
index 3453237055b..c8f1ae2152b 100644
--- a/drivers/usb/media/sn9c102_pas202bca.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bca.c
@@ -54,7 +54,7 @@ static int pas202bca_init(struct sn9c102_device* cam)
static int pas202bca_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+ const struct v4l2_pix_format* pix)
{
int err = 0;
@@ -68,7 +68,7 @@ static int pas202bca_set_pix_format(struct sn9c102_device* cam,
static int pas202bca_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -102,7 +102,7 @@ static int pas202bca_set_ctrl(struct sn9c102_device* cam,
static int pas202bca_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &pas202bca;
int err = 0;
diff --git a/drivers/usb/media/sn9c102_pas202bcb.c b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
index d068616ab33..e3c1178e339 100644
--- a/drivers/usb/media/sn9c102_pas202bcb.c
+++ b/drivers/media/video/sn9c102/sn9c102_pas202bcb.c
@@ -58,8 +58,8 @@ static int pas202bcb_init(struct sn9c102_device* cam)
}
-static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
- struct v4l2_control* ctrl)
+static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
+ struct v4l2_control* ctrl)
{
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
@@ -101,8 +101,8 @@ static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
}
-static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
@@ -115,8 +115,8 @@ static int pas202bcb_set_pix_format(struct sn9c102_device* cam,
}
-static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -149,8 +149,8 @@ static int pas202bcb_set_ctrl(struct sn9c102_device* cam,
}
-static int pas202bcb_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int pas202bcb_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &pas202bcb;
int err = 0;
@@ -167,7 +167,7 @@ static int pas202bcb_set_crop(struct sn9c102_device* cam,
static struct sn9c102_sensor pas202bcb = {
.name = "PAS202BCB",
.maintainer = "Carlos Eduardo Medaglia Dyonisio "
- "<medaglia@undl.org.br>",
+ "<medaglia@undl.org.br>",
.sysfs_ops = SN9C102_I2C_READ | SN9C102_I2C_WRITE,
.frequency = SN9C102_I2C_400KHZ | SN9C102_I2C_100KHZ,
.interface = SN9C102_I2C_2WIRES,
diff --git a/drivers/usb/media/sn9c102_sensor.h b/drivers/media/video/sn9c102/sn9c102_sensor.h
index 2afd9e9d09b..2a874ee6f9f 100644
--- a/drivers/usb/media/sn9c102_sensor.h
+++ b/drivers/media/video/sn9c102/sn9c102_sensor.h
@@ -58,7 +58,7 @@ struct sn9c102_sensor;
Probing functions: on success, you must attach the sensor to the camera
by calling sn9c102_attach_sensor() provided below.
To enable the I2C communication, you might need to perform a really basic
- initialization of the SN9C10X chip by using the write function declared
+ initialization of the SN9C10X chip by using the write function declared
ahead.
Functions must return 0 on success, the appropriate error otherwise.
*/
@@ -73,7 +73,7 @@ extern int sn9c102_probe_tas5130d1b(struct sn9c102_device* cam);
/*
Add the above entries to this table. Be sure to add the entry in the right
- place, since, on failure, the next probing routine is called according to
+ place, since, on failure, the next probing routine is called according to
the order of the list below, from top to bottom.
*/
#define SN9C102_SENSOR_TABLE \
@@ -94,9 +94,9 @@ extern struct sn9c102_device*
sn9c102_match_id(struct sn9c102_device* cam, const struct usb_device_id *id);
/* Attach a probed sensor to the camera. */
-extern void
+extern void
sn9c102_attach_sensor(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor);
+ struct sn9c102_sensor* sensor);
/*
Each SN9C10x camera has proper PID/VID identifiers.
@@ -105,7 +105,7 @@ sn9c102_attach_sensor(struct sn9c102_device* cam,
*/
#define SN9C102_USB_DEVICE(vend, prod, intclass) \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
- USB_DEVICE_ID_MATCH_INT_CLASS, \
+ USB_DEVICE_ID_MATCH_INT_CLASS, \
.idVendor = (vend), \
.idProduct = (prod), \
.bInterfaceClass = (intclass)
@@ -162,19 +162,19 @@ static const struct usb_device_id sn9c102_id_table[] = { \
Read/write routines: they always return -1 on error, 0 or the read value
otherwise. NOTE that a real read operation is not supported by the SN9C10X
chip for some of its registers. To work around this problem, a pseudo-read
- call is provided instead: it returns the last successfully written value
+ call is provided instead: it returns the last successfully written value
on the register (0 if it has never been written), the usual -1 on error.
*/
/* The "try" I2C I/O versions are used when probing the sensor */
extern int sn9c102_i2c_try_write(struct sn9c102_device*,struct sn9c102_sensor*,
- u8 address, u8 value);
+ u8 address, u8 value);
extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
- u8 address);
+ u8 address);
/*
These must be used if and only if the sensor doesn't implement the standard
- I2C protocol. There are a number of good reasons why you must use the
+ I2C protocol. There are a number of good reasons why you must use the
single-byte versions of these functions: do not abuse. The first function
writes n bytes, from data0 to datan, to registers 0x09 - 0x09+n of SN9C10X
chip. The second one programs the registers 0x09 and 0x10 with data0 and
@@ -184,12 +184,12 @@ extern int sn9c102_i2c_try_read(struct sn9c102_device*,struct sn9c102_sensor*,
byte.
*/
extern int sn9c102_i2c_try_raw_write(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 n,
- u8 data0, u8 data1, u8 data2, u8 data3,
- u8 data4, u8 data5);
+ struct sn9c102_sensor* sensor, u8 n,
+ u8 data0, u8 data1, u8 data2, u8 data3,
+ u8 data4, u8 data5);
extern int sn9c102_i2c_try_raw_read(struct sn9c102_device* cam,
- struct sn9c102_sensor* sensor, u8 data0,
- u8 data1, u8 n, u8 buffer[]);
+ struct sn9c102_sensor* sensor, u8 data0,
+ u8 data1, u8 n, u8 buffer[]);
/* To be used after the sensor struct has been attached to the camera struct */
extern int sn9c102_i2c_write(struct sn9c102_device*, u8 address, u8 value);
@@ -252,17 +252,17 @@ struct sn9c102_sensor {
/*
NOTE: Where not noted,most of the functions below are not mandatory.
- Set to null if you do not implement them. If implemented,
- they must return 0 on success, the proper error otherwise.
+ Set to null if you do not implement them. If implemented,
+ they must return 0 on success, the proper error otherwise.
*/
int (*init)(struct sn9c102_device* cam);
/*
- This function will be called after the sensor has been attached.
+ This function will be called after the sensor has been attached.
It should be used to initialize the sensor only, but may also
configure part of the SN9C10X chip if necessary. You don't need to
setup picture settings like brightness, contrast, etc.. here, if
- the corrisponding controls are implemented (see below), since
+ the corrisponding controls are implemented (see below), since
they are adjusted in the core driver by calling the set_ctrl()
method after init(), where the arguments are the default values
specified in the v4l2_queryctrl list of supported controls;
@@ -273,13 +273,13 @@ struct sn9c102_sensor {
struct v4l2_queryctrl qctrl[SN9C102_MAX_CTRLS];
/*
- Optional list of default controls, defined as indicated in the
+ Optional list of default controls, defined as indicated in the
V4L2 API. Menu type controls are not handled by this interface.
*/
int (*get_ctrl)(struct sn9c102_device* cam, struct v4l2_control* ctrl);
int (*set_ctrl)(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl);
+ const struct v4l2_control* ctrl);
/*
You must implement at least the set_ctrl method if you have defined
the list above. The returned value must follow the V4L2
@@ -306,7 +306,7 @@ struct sn9c102_sensor {
specified in the cropcap substructures 'bounds' and 'defrect'.
By default, the source rectangle should cover the largest possible
area. Again, it is not always true that the largest source rectangle
- can cover the entire active window, although it is a rare case for
+ can cover the entire active window, although it is a rare case for
the hardware we have. The bounds of the source rectangle _must_ be
multiple of 16 and must use the same coordinate system as indicated
before; their centers shall align initially.
@@ -317,13 +317,13 @@ struct sn9c102_sensor {
defined the correct default bounds in the structures.
See the V4L2 API for further details.
NOTE: once you have defined the bounds of the active window
- (struct cropcap.bounds) you must not change them.anymore.
+ (struct cropcap.bounds) you must not change them.anymore.
Only 'bounds' and 'defrect' fields are mandatory, other fields
will be ignored.
*/
int (*set_crop)(struct sn9c102_device* cam,
- const struct v4l2_rect* rect);
+ const struct v4l2_rect* rect);
/*
To be called on VIDIOC_C_SETCROP. The core module always calls a
default routine which configures the appropriate SN9C10X regs (also
@@ -332,12 +332,12 @@ struct sn9c102_sensor {
case you override the default function, you always have to program
the chip to match those values; on error return the corresponding
error code without rolling back.
- NOTE: in case, you must program the SN9C10X chip to get rid of
- blank pixels or blank lines at the _start_ of each line or
- frame after each HSYNC or VSYNC, so that the image starts with
- real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
- V_SIZE you don't have to care about blank pixels or blank
- lines at the end of each line or frame).
+ NOTE: in case, you must program the SN9C10X chip to get rid of
+ blank pixels or blank lines at the _start_ of each line or
+ frame after each HSYNC or VSYNC, so that the image starts with
+ real RGB data (see regs 0x12, 0x13) (having set H_SIZE and,
+ V_SIZE you don't have to care about blank pixels or blank
+ lines at the end of each line or frame).
*/
struct v4l2_pix_format pix_format;
@@ -349,17 +349,17 @@ struct sn9c102_sensor {
number of bits per pixel for uncompressed video, 8 or 9 (despite the
current value of 'pixelformat').
NOTE 1: both 'width' and 'height' _must_ be either 1/1 or 1/2 or 1/4
- of cropcap.defrect.width and cropcap.defrect.height. I
- suggest 1/1.
+ of cropcap.defrect.width and cropcap.defrect.height. I
+ suggest 1/1.
NOTE 2: The initial compression quality is defined by the first bit
- of reg 0x17 during the initialization of the image sensor.
+ of reg 0x17 during the initialization of the image sensor.
NOTE 3: as said above, you have to program the SN9C10X chip to get
- rid of any blank pixels, so that the output of the sensor
- matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
+ rid of any blank pixels, so that the output of the sensor
+ matches the RGB bayer sequence (i.e. BGBGBG...GRGRGR).
*/
int (*set_pix_format)(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix);
+ const struct v4l2_pix_format* pix);
/*
To be called on VIDIOC_S_FMT, when switching from the SBGGR8 to
SN9C10X pixel format or viceversa. On error return the corresponding
diff --git a/drivers/usb/media/sn9c102_tas5110c1b.c b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
index 2e08c552f40..294eb02fbd8 100644
--- a/drivers/usb/media/sn9c102_tas5110c1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5110c1b.c
@@ -44,8 +44,8 @@ static int tas5110c1b_init(struct sn9c102_device* cam)
}
-static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -61,8 +61,8 @@ static int tas5110c1b_set_ctrl(struct sn9c102_device* cam,
}
-static int tas5110c1b_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int tas5110c1b_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &tas5110c1b;
int err = 0;
@@ -81,8 +81,8 @@ static int tas5110c1b_set_crop(struct sn9c102_device* cam,
}
-static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int tas5110c1b_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
diff --git a/drivers/usb/media/sn9c102_tas5130d1b.c b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
index c7b339740bb..9ecb09032b6 100644
--- a/drivers/usb/media/sn9c102_tas5130d1b.c
+++ b/drivers/media/video/sn9c102/sn9c102_tas5130d1b.c
@@ -42,8 +42,8 @@ static int tas5130d1b_init(struct sn9c102_device* cam)
}
-static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
- const struct v4l2_control* ctrl)
+static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
+ const struct v4l2_control* ctrl)
{
int err = 0;
@@ -62,8 +62,8 @@ static int tas5130d1b_set_ctrl(struct sn9c102_device* cam,
}
-static int tas5130d1b_set_crop(struct sn9c102_device* cam,
- const struct v4l2_rect* rect)
+static int tas5130d1b_set_crop(struct sn9c102_device* cam,
+ const struct v4l2_rect* rect)
{
struct sn9c102_sensor* s = &tas5130d1b;
u8 h_start = (u8)(rect->left - s->cropcap.bounds.left) + 104,
@@ -82,8 +82,8 @@ static int tas5130d1b_set_crop(struct sn9c102_device* cam,
}
-static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
- const struct v4l2_pix_format* pix)
+static int tas5130d1b_set_pix_format(struct sn9c102_device* cam,
+ const struct v4l2_pix_format* pix)
{
int err = 0;
diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c
index 9d769264a32..07476c71174 100644
--- a/drivers/media/video/stradis.c
+++ b/drivers/media/video/stradis.c
@@ -1,4 +1,4 @@
-/*
+/*
* stradis.c - stradis 4:2:2 mpeg decoder driver
*
* Stradis 4:2:2 MPEG-2 Decoder Driver
@@ -1191,9 +1191,9 @@ static void saa7146_set_winsize(struct saa7146 *saa)
}
/* clip_draw_rectangle(cm,x,y,w,h) -- handle clipping an area
- * bitmap is fixed width, 128 bytes (1024 pixels represented)
- * arranged most-sigificant-bit-left in 32-bit words
- * based on saa7146 clipping hardware, it swaps bytes if LE
+ * bitmap is fixed width, 128 bytes (1024 pixels represented)
+ * arranged most-sigificant-bit-left in 32-bit words
+ * based on saa7146 clipping hardware, it swaps bytes if LE
* much of this makes up for egcs brain damage -- so if you
* are wondering "why did he do this?" it is because the C
* was adjusted to generate the optimal asm output without
@@ -1259,7 +1259,7 @@ static void make_clip_tab(struct saa7146 *saa, struct video_clip *cr, int ncr)
clip_draw_rectangle(clipmap, cr[i].x, cr[i].y,
cr[i].width, cr[i].height);
}
- /* clip against viewing window AND screen
+ /* clip against viewing window AND screen
so we do not have to rely on the user program
*/
clip_draw_rectangle(clipmap, (saa->win.x + width > saa->win.swidth) ?
diff --git a/drivers/usb/media/stv680.c b/drivers/media/video/stv680.c
index 9636da20748..b38bda83a7c 100644
--- a/drivers/usb/media/stv680.c
+++ b/drivers/media/video/stv680.c
@@ -1,16 +1,16 @@
/*
* STV0680 USB Camera Driver, by Kevin Sisson (kjsisson@bellsouth.net)
- *
- * Thanks to STMicroelectronics for information on the usb commands, and
- * to Steve Miller at STM for his help and encouragement while I was
+ *
+ * Thanks to STMicroelectronics for information on the usb commands, and
+ * to Steve Miller at STM for his help and encouragement while I was
* writing this driver.
*
- * This driver is based heavily on the
+ * This driver is based heavily on the
* Endpoints (formerly known as AOX) se401 USB Camera Driver
* Copyright (c) 2000 Jeroen B. Vreeken (pe1rxq@amsat.org)
*
* Still somewhat based on the Linux ov511 driver.
- *
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
@@ -25,18 +25,18 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
- * History:
- * ver 0.1 October, 2001. Initial attempt.
+ * History:
+ * ver 0.1 October, 2001. Initial attempt.
*
* ver 0.2 November, 2001. Fixed asbility to resize, added brightness
* function, made more stable (?)
*
- * ver 0.21 Nov, 2001. Added gamma correction and white balance,
- * due to Alexander Schwartz. Still trying to
+ * ver 0.21 Nov, 2001. Added gamma correction and white balance,
+ * due to Alexander Schwartz. Still trying to
* improve stablility. Moved stuff into stv680.h
*
- * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet,
- * mike@easysw.com) from GIMP, also used in pencam.
+ * ver 0.22 Nov, 2001. Added sharpen function (by Michael Sweet,
+ * mike@easysw.com) from GIMP, also used in pencam.
* Simple, fast, good integer math routine.
*
* ver 0.23 Dec, 2001 (gkh)
@@ -44,11 +44,11 @@
* Lindent, and did other minor tweaks to get
* things to work properly with 2.5.1
*
- * ver 0.24 Jan, 2002 (kjs)
+ * ver 0.24 Jan, 2002 (kjs)
* Fixed the problem with webcam crashing after
- * two pictures. Changed the way pic is halved to
- * improve quality. Got rid of green line around
- * frame. Fix brightness reset when changing size
+ * two pictures. Changed the way pic is halved to
+ * improve quality. Got rid of green line around
+ * frame. Fix brightness reset when changing size
* bug. Adjusted gamma filters slightly.
*
* ver 0.25 Jan, 2002 (kjs)
@@ -484,7 +484,7 @@ exit:
PDEBUG (1, "STV(i): swapRGB is (forced) ON");
else if (swapRGB_on == -1)
PDEBUG (1, "STV(i): swapRGB is (forced) OFF");
-
+
if (stv_set_video_mode (stv680) < 0) {
PDEBUG (0, "STV(e): Could not set video mode in stv_init");
return -1;
@@ -570,7 +570,7 @@ static int stv680_set_pict (struct usb_stv *stv680, struct video_picture *p)
if (stv680->brightness != p->brightness) {
stv680->chgbright = 1;
stv680->brightness = p->brightness;
- }
+ }
stv680->whiteness = p->whiteness; /* greyscale */
stv680->colour = p->colour;
@@ -612,7 +612,7 @@ static void stv680_video_irq (struct urb *urb, struct pt_regs *regs)
case BUFFER_UNUSED:
memcpy (stv680->scratch[stv680->scratch_next].data,
- (unsigned char *) urb->transfer_buffer, length);
+ (unsigned char *) urb->transfer_buffer, length);
stv680->scratch[stv680->scratch_next].state = BUFFER_READY;
stv680->scratch[stv680->scratch_next].length = length;
if (waitqueue_active (&stv680->wq)) {
@@ -752,7 +752,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
PDEBUG (1, "STV(e): request for non-supported size: request: v.width = %i, v.height = %i actual: stv.width = %i, stv.height = %i", width, height, stv680->vwidth, stv680->vheight);
return 1;
}
-
+
/* Stop a current stream and start it again at the new size */
if (wasstreaming)
stv680_stop_stream (stv680);
@@ -773,7 +773,7 @@ static int stv680_set_size (struct usb_stv *stv680, int width, int height)
/*
* STV0680 Vision Camera Chipset Driver
- * Copyright (C) 2000 Adam Harrison <adam@antispin.org>
+ * Copyright (C) 2000 Adam Harrison <adam@antispin.org>
*/
#define RED 0
@@ -842,7 +842,7 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
colour = 2;
break;
}
- i = (y * vw + x) * 3;
+ i = (y * vw + x) * 3;
*(output + i + colour) = (unsigned char) p;
} /* for x */
@@ -850,9 +850,9 @@ static void bayer_unshuffle (struct usb_stv *stv680, struct stv680_scratch *buff
/****** gamma correction plus hardcoded white balance */
/* Thanks to Alexander Schwartx <alexander.schwartx@gmx.net> for this code.
- Correction values red[], green[], blue[], are generated by
- (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255.
- White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and
+ Correction values red[], green[], blue[], are generated by
+ (pow(i/256.0, GAMMA)*255.0)*white balanceRGB where GAMMA=0.55, 1<i<255.
+ White balance (RGB)= 1.0, 1.17, 1.48. Values are calculated as double float and
converted to unsigned char. Values are in stv680.h */
for (y = 0; y < vh; y++) {
diff --git a/drivers/usb/media/stv680.h b/drivers/media/video/stv680.h
index ea46e0001e6..a08f1b08a4b 100644
--- a/drivers/usb/media/stv680.h
+++ b/drivers/media/video/stv680.h
@@ -9,12 +9,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -152,76 +152,76 @@ struct usb_stv {
static const unsigned char red[256] = {
- 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
- 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
- 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,
- 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,
- 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
- 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,
- 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,
- 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,
- 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,
- 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,
- 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,
- 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,
- 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,
- 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,
- 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,
- 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,
- 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,
- 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,
- 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,
- 220, 220, 221, 221
-};
+ 0, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 25, 30, 35, 38, 42,
+ 44, 47, 50, 53, 54, 57, 59, 61, 63, 65, 67, 69,
+ 71, 71, 73, 75, 77, 78, 80, 81, 82, 84, 85, 87,
+ 88, 89, 90, 91, 93, 94, 95, 97, 98, 98, 99, 101,
+ 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
+ 114, 115, 116, 116, 117, 118, 119, 120, 121, 122, 123, 124,
+ 125, 125, 126, 127, 128, 129, 129, 130, 131, 132, 133, 134,
+ 134, 135, 135, 136, 137, 138, 139, 140, 140, 141, 142, 143,
+ 143, 143, 144, 145, 146, 147, 147, 148, 149, 150, 150, 151,
+ 152, 152, 152, 153, 154, 154, 155, 156, 157, 157, 158, 159,
+ 159, 160, 161, 161, 161, 162, 163, 163, 164, 165, 165, 166,
+ 167, 167, 168, 168, 169, 170, 170, 170, 171, 171, 172, 173,
+ 173, 174, 174, 175, 176, 176, 177, 178, 178, 179, 179, 179,
+ 180, 180, 181, 181, 182, 183, 183, 184, 184, 185, 185, 186,
+ 187, 187, 188, 188, 188, 188, 189, 190, 190, 191, 191, 192,
+ 192, 193, 193, 194, 195, 195, 196, 196, 197, 197, 197, 197,
+ 198, 198, 199, 199, 200, 201, 201, 202, 202, 203, 203, 204,
+ 204, 205, 205, 206, 206, 206, 206, 207, 207, 208, 208, 209,
+ 209, 210, 210, 211, 211, 212, 212, 213, 213, 214, 214, 215,
+ 215, 215, 215, 216, 216, 217, 217, 218, 218, 218, 219, 219,
+ 220, 220, 221, 221
+};
static const unsigned char green[256] = {
- 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
- 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
- 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
- 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,
- 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,
- 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,
- 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
- 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,
- 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,
- 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,
- 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,
- 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,
- 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,
- 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
- 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,
- 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
- 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,
- 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
- 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,
- 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
- 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,
- 245, 245, 246, 246
-};
+ 0, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 28, 34, 39, 43, 47,
+ 50, 53, 56, 59, 61, 64, 66, 68, 71, 73, 75, 77,
+ 79, 80, 82, 84, 86, 87, 89, 91, 92, 94, 95, 97,
+ 98, 100, 101, 102, 104, 105, 106, 108, 109, 110, 111, 113,
+ 114, 115, 116, 117, 118, 120, 121, 122, 123, 124, 125, 126,
+ 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
+ 139, 140, 141, 142, 143, 144, 144, 145, 146, 147, 148, 149,
+ 150, 151, 151, 152, 153, 154, 155, 156, 156, 157, 158, 159,
+ 160, 160, 161, 162, 163, 164, 164, 165, 166, 167, 167, 168,
+ 169, 170, 170, 171, 172, 172, 173, 174, 175, 175, 176, 177,
+ 177, 178, 179, 179, 180, 181, 182, 182, 183, 184, 184, 185,
+ 186, 186, 187, 187, 188, 189, 189, 190, 191, 191, 192, 193,
+ 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 199, 200,
+ 201, 201, 202, 202, 203, 204, 204, 205, 205, 206, 206, 207,
+ 208, 208, 209, 209, 210, 210, 211, 212, 212, 213, 213, 214,
+ 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220,
+ 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
+ 227, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233,
+ 233, 234, 234, 235, 235, 236, 236, 237, 237, 238, 238, 239,
+ 239, 240, 240, 241, 241, 242, 242, 243, 243, 243, 244, 244,
+ 245, 245, 246, 246
+};
static const unsigned char blue[256] = {
- 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
- 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
- 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
- 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,
- 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,
- 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,
- 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,
- 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,
- 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,
- 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,
- 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,
- 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,
- 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,
- 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,
- 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
- 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,
- 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,
- 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,
- 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255
-};
+ 0, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 30, 37, 42, 47, 51,
+ 55, 58, 61, 64, 67, 70, 72, 74, 78, 80, 82, 84,
+ 86, 88, 90, 92, 94, 95, 97, 100, 101, 103, 104, 106,
+ 107, 110, 111, 112, 114, 115, 116, 118, 119, 121, 122, 124,
+ 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138,
+ 139, 140, 141, 143, 144, 145, 146, 147, 148, 149, 150, 151,
+ 152, 154, 155, 156, 157, 158, 158, 159, 160, 161, 162, 163,
+ 165, 166, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174,
+ 176, 176, 177, 178, 179, 180, 180, 181, 182, 183, 183, 184,
+ 185, 187, 187, 188, 189, 189, 190, 191, 192, 192, 193, 194,
+ 194, 195, 196, 196, 198, 199, 200, 200, 201, 202, 202, 203,
+ 204, 204, 205, 205, 206, 207, 207, 209, 210, 210, 211, 212,
+ 212, 213, 213, 214, 215, 215, 216, 217, 217, 218, 218, 220,
+ 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227,
+ 228, 228, 229, 229, 231, 231, 232, 233, 233, 234, 234, 235,
+ 235, 236, 236, 237, 238, 238, 239, 239, 240, 240, 242, 242,
+ 243, 243, 244, 244, 245, 246, 246, 247, 247, 248, 248, 249,
+ 249, 250, 250, 251, 251, 253, 253, 254, 254, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255
+};
diff --git a/drivers/media/video/tda7432.c b/drivers/media/video/tda7432.c
index fc3d5824eff..78e043ac9ea 100644
--- a/drivers/media/video/tda7432.c
+++ b/drivers/media/video/tda7432.c
@@ -48,9 +48,8 @@
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
-#include "bttv.h"
-#include <media/audiochip.h>
#include <media/v4l2-common.h>
+#include <media/i2c-addr.h>
#ifndef VIDEO_AUDIO_BALANCE
# define VIDEO_AUDIO_BALANCE 32
@@ -71,7 +70,7 @@ module_param(maxvol, int, S_IRUGO | S_IWUSR);
/* Address to scan (I2C address of this chip) */
static unsigned short normal_i2c[] = {
- I2C_TDA7432 >> 1,
+ I2C_ADDR_TDA7432 >> 1,
I2C_CLIENT_END,
};
I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tda9840.c b/drivers/media/video/tda9840.c
index 0243700f58a..ef494febb5e 100644
--- a/drivers/media/video/tda9840.c
+++ b/drivers/media/video/tda9840.c
@@ -35,7 +35,7 @@ static int debug = 0; /* insmod parameter */
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
#define dprintk(args...) \
- do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
+ do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
#define SWITCH 0x00
#define LEVEL_ADJUST 0x02
@@ -43,7 +43,7 @@ MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
#define TEST 0x04
/* addresses to scan, found only at 0x42 (7-Bit) */
-static unsigned short normal_i2c[] = { I2C_TDA9840, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { I2C_ADDR_TDA9840, I2C_CLIENT_END };
/* magic definition of all other variables and things */
I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tda9840.h b/drivers/media/video/tda9840.h
index 28021053bd0..7da8432cdca 100644
--- a/drivers/media/video/tda9840.h
+++ b/drivers/media/video/tda9840.h
@@ -1,7 +1,7 @@
#ifndef __INCLUDED_TDA9840__
#define __INCLUDED_TDA9840__
-#define I2C_TDA9840 0x42
+#define I2C_ADDR_TDA9840 0x42
#define TDA9840_DETECT _IOR('v',1,int)
/* return values for TDA9840_DETCT */
diff --git a/drivers/media/video/tda9875.c b/drivers/media/video/tda9875.c
index ef98c498225..103ccb91929 100644
--- a/drivers/media/video/tda9875.c
+++ b/drivers/media/video/tda9875.c
@@ -30,24 +30,22 @@
#include <linux/i2c-algo-bit.h>
#include <linux/init.h>
-#include "bttv.h"
-#include <media/audiochip.h>
+
+#include <media/i2c-addr.h>
static int debug; /* insmod parameter */
module_param(debug, int, S_IRUGO | S_IWUSR);
MODULE_LICENSE("GPL");
-
/* Addresses to scan */
static unsigned short normal_i2c[] = {
- I2C_TDA9875 >> 1,
+ I2C_ADDR_TDA9875 >> 1,
I2C_CLIENT_END
};
I2C_CLIENT_INSMOD;
/* This is a superset of the TDA9875 */
struct tda9875 {
- int mode;
int rvol, lvol;
int bass, treble;
struct i2c_client c;
@@ -197,7 +195,6 @@ static void do_tda9875_init(struct i2c_client *client)
tda9875_write(client, TDA9875_MUT, 0xcc ); /* General mute */
- t->mode=AUDIO_UNMUTE;
t->lvol=t->rvol =0; /* 0dB */
t->bass=0; /* 0dB */
t->treble=0; /* 0dB */
diff --git a/drivers/media/video/tea6415c.c b/drivers/media/video/tea6415c.c
index 774ed0dbc56..523df0b8cc6 100644
--- a/drivers/media/video/tea6415c.c
+++ b/drivers/media/video/tea6415c.c
@@ -37,7 +37,7 @@ static int debug = 0; /* insmod parameter */
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
#define dprintk(args...) \
- do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
+ do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
#define TEA6415C_NUM_INPUTS 8
#define TEA6415C_NUM_OUTPUTS 6
diff --git a/drivers/media/video/tea6420.c b/drivers/media/video/tea6420.c
index ad7d2872cfb..e0ff811fab6 100644
--- a/drivers/media/video/tea6420.c
+++ b/drivers/media/video/tea6420.c
@@ -37,10 +37,10 @@ static int debug = 0; /* insmod parameter */
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off device debugging (default:off).");
#define dprintk(args...) \
- do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
+ do { if (debug) { printk("%s: %s()[%d]: ", KBUILD_MODNAME, __FUNCTION__, __LINE__); printk(args); } } while (0)
/* addresses to scan, found only at 0x4c and/or 0x4d (7-Bit) */
-static unsigned short normal_i2c[] = { I2C_TEA6420_1, I2C_TEA6420_2, I2C_CLIENT_END };
+static unsigned short normal_i2c[] = { I2C_ADDR_TEA6420_1, I2C_ADDR_TEA6420_2, I2C_CLIENT_END };
/* magic definition of all other variables and things */
I2C_CLIENT_INSMOD;
diff --git a/drivers/media/video/tea6420.h b/drivers/media/video/tea6420.h
index ea664df15ad..5ef7c18e0c5 100644
--- a/drivers/media/video/tea6420.h
+++ b/drivers/media/video/tea6420.h
@@ -2,8 +2,8 @@
#define __INCLUDED_TEA6420__
/* possible addresses */
-#define I2C_TEA6420_1 0x4c
-#define I2C_TEA6420_2 0x4d
+#define I2C_ADDR_TEA6420_1 0x4c
+#define I2C_ADDR_TEA6420_2 0x4d
struct tea6420_multiplex
{
diff --git a/drivers/media/video/tuner-3036.c b/drivers/media/video/tuner-3036.c
index c4a78e7a5a5..74ab48c09c6 100644
--- a/drivers/media/video/tuner-3036.c
+++ b/drivers/media/video/tuner-3036.c
@@ -5,7 +5,7 @@
*
* The SAB3036 is just about different enough from the chips that
* tuner.c copes with to make it not worth the effort to crowbar
- * the support into that file. So instead we have a separate driver.
+ * the support into that file. So instead we have a separate driver.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -56,15 +56,15 @@ tuner_getstatus (struct i2c_client *c)
#define TUNER_FL 0x80
-static int
+static int
tuner_islocked (struct i2c_client *c)
{
- return (tuner_getstatus(c) & TUNER_FL);
+ return (tuner_getstatus(c) & TUNER_FL);
}
/* ---------------------------------------------------------------------- */
-static void
+static void
set_tv_freq(struct i2c_client *c, int freq)
{
u16 div = ((freq * 20) / 16);
@@ -73,26 +73,26 @@ set_tv_freq(struct i2c_client *c, int freq)
if (debug)
printk(KERN_DEBUG "tuner: setting frequency %dMHz, divisor %x\n", freq / 16, div);
-
+
/* Select high tuning current */
buffer[0] = 0x29;
buffer[1] = 0x3e;
if (i2c_master_send(c, buffer, 2) != 2)
printk("tuner: i2c i/o error 1\n");
-
+
buffer[0] = 0x80 | ((div>>8) & 0x7f);
buffer[1] = div & 0xff;
if (i2c_master_send(c, buffer, 2) != 2)
printk("tuner: i2c i/o error 2\n");
-
+
while (!tuner_islocked(c) && time_before(jiffies, give_up))
schedule();
-
+
if (!tuner_islocked(c))
printk(KERN_WARNING "tuner: failed to achieve PLL lock\n");
-
+
/* Select low tuning current and engage AFC */
buffer[0] = 0x29;
buffer[1] = 0xb2;
@@ -106,7 +106,7 @@ set_tv_freq(struct i2c_client *c, int freq)
/* ---------------------------------------------------------------------- */
-static int
+static int
tuner_attach(struct i2c_adapter *adap, int addr, int kind)
{
static unsigned char buffer[] = { 0x29, 0x32, 0x2a, 0, 0x2b, 0 };
@@ -116,18 +116,18 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
if (this_adap > 0)
return -1;
this_adap++;
-
- client_template.adapter = adap;
- client_template.addr = addr;
+
+ client_template.adapter = adap;
+ client_template.addr = addr;
client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL);
- if (client == NULL)
- return -ENOMEM;
- memcpy(client, &client_template, sizeof(struct i2c_client));
+ if (client == NULL)
+ return -ENOMEM;
+ memcpy(client, &client_template, sizeof(struct i2c_client));
printk("tuner: SAB3036 found, status %02x\n", tuner_getstatus(client));
- i2c_attach_client(client);
+ i2c_attach_client(client);
if (i2c_master_send(client, buffer, 2) != 2)
printk("tuner: i2c i/o error 1\n");
@@ -138,30 +138,30 @@ tuner_attach(struct i2c_adapter *adap, int addr, int kind)
return 0;
}
-static int
+static int
tuner_detach(struct i2c_client *c)
{
return 0;
}
-static int
+static int
tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
int *iarg = (int*)arg;
- switch (cmd)
+ switch (cmd)
{
case VIDIOCSFREQ:
set_tv_freq(client, *iarg);
break;
-
+
default:
return -EINVAL;
}
return 0;
}
-static int
+static int
tuner_probe(struct i2c_adapter *adap)
{
this_adap = 0;
@@ -172,8 +172,8 @@ tuner_probe(struct i2c_adapter *adap)
/* ----------------------------------------------------------------------- */
-static struct i2c_driver
-i2c_driver_tuner =
+static struct i2c_driver
+i2c_driver_tuner =
{
.driver = {
.name = "sab3036",
@@ -186,7 +186,7 @@ i2c_driver_tuner =
static struct i2c_client client_template =
{
- .driver = &i2c_driver_tuner,
+ .driver = &i2c_driver_tuner,
.name = "SAB3036",
};
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c
index 32e1849441f..df195c90536 100644
--- a/drivers/media/video/tuner-core.c
+++ b/drivers/media/video/tuner-core.c
@@ -21,7 +21,6 @@
#include <media/tuner.h>
#include <media/v4l2-common.h>
-#include <media/audiochip.h>
#define UNSET (-1U)
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 4efb01bb44a..356bff455ad 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -30,10 +30,10 @@
#include <linux/init.h>
#include <linux/smp_lock.h>
-#include <media/audiochip.h>
+#include <media/tvaudio.h>
#include <media/v4l2-common.h>
-#include "tvaudio.h"
+#include <media/i2c-addr.h>
/* ---------------------------------------------------------------------- */
/* insmod args */
@@ -102,7 +102,7 @@ struct CHIPDESC {
/* input switch register + values for v4l inputs */
int inputreg;
- int inputmap[8];
+ int inputmap[4];
int inputmute;
int inputmask;
};
@@ -119,9 +119,10 @@ struct CHIPSTATE {
audiocmd shadow;
/* current settings */
- __u16 left,right,treble,bass,mode;
+ __u16 left,right,treble,bass,muted,mode;
int prevmode;
int radio;
+ int input;
/* thread */
pid_t tpid;
@@ -137,14 +138,14 @@ struct CHIPSTATE {
/* i2c addresses */
static unsigned short normal_i2c[] = {
- I2C_TDA8425 >> 1,
- I2C_TEA6300 >> 1,
- I2C_TEA6420 >> 1,
- I2C_TDA9840 >> 1,
- I2C_TDA985x_L >> 1,
- I2C_TDA985x_H >> 1,
- I2C_TDA9874 >> 1,
- I2C_PIC16C54 >> 1,
+ I2C_ADDR_TDA8425 >> 1,
+ I2C_ADDR_TEA6300 >> 1,
+ I2C_ADDR_TEA6420 >> 1,
+ I2C_ADDR_TDA9840 >> 1,
+ I2C_ADDR_TDA985x_L >> 1,
+ I2C_ADDR_TDA985x_H >> 1,
+ I2C_ADDR_TDA9874 >> 1,
+ I2C_ADDR_PIC16C54 >> 1,
I2C_CLIENT_END };
I2C_CLIENT_INSMOD;
@@ -1101,9 +1102,8 @@ static int tda8425_shift12(int val) { return (val >> 12) | 0xf0; }
static int tda8425_initialize(struct CHIPSTATE *chip)
{
struct CHIPDESC *desc = chiplist + chip->type;
- int inputmap[8] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
- /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF,
- /* off */ TDA8425_S1_OFF, /* on */ TDA8425_S1_CH2};
+ int inputmap[4] = { /* tuner */ TDA8425_S1_CH2, /* radio */ TDA8425_S1_CH1,
+ /* extern */ TDA8425_S1_CH1, /* intern */ TDA8425_S1_OFF};
if (chip->c.adapter->id == I2C_HW_B_RIVA) {
memcpy (desc->inputmap, inputmap, sizeof (inputmap));
@@ -1269,8 +1269,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tda9840",
.id = I2C_DRIVERID_TDA9840,
.insmodopt = &tda9840,
- .addr_lo = I2C_TDA9840 >> 1,
- .addr_hi = I2C_TDA9840 >> 1,
+ .addr_lo = I2C_ADDR_TDA9840 >> 1,
+ .addr_hi = I2C_ADDR_TDA9840 >> 1,
.registers = 5,
.checkit = tda9840_checkit,
@@ -1286,8 +1286,8 @@ static struct CHIPDESC chiplist[] = {
.id = I2C_DRIVERID_TDA9873,
.checkit = tda9873_checkit,
.insmodopt = &tda9873,
- .addr_lo = I2C_TDA985x_L >> 1,
- .addr_hi = I2C_TDA985x_H >> 1,
+ .addr_lo = I2C_ADDR_TDA985x_L >> 1,
+ .addr_hi = I2C_ADDR_TDA985x_H >> 1,
.registers = 3,
.flags = CHIP_HAS_INPUTSEL,
@@ -1298,7 +1298,7 @@ static struct CHIPDESC chiplist[] = {
.init = { 4, { TDA9873_SW, 0xa4, 0x06, 0x03 } },
.inputreg = TDA9873_SW,
.inputmute = TDA9873_MUTE | TDA9873_AUTOMUTE,
- .inputmap = {0xa0, 0xa2, 0xa0, 0xa0, 0xc0},
+ .inputmap = {0xa0, 0xa2, 0xa0, 0xa0},
.inputmask = TDA9873_INP_MASK|TDA9873_MUTE|TDA9873_AUTOMUTE,
},
@@ -1308,8 +1308,8 @@ static struct CHIPDESC chiplist[] = {
.checkit = tda9874a_checkit,
.initialize = tda9874a_initialize,
.insmodopt = &tda9874a,
- .addr_lo = I2C_TDA9874 >> 1,
- .addr_hi = I2C_TDA9874 >> 1,
+ .addr_lo = I2C_ADDR_TDA9874 >> 1,
+ .addr_hi = I2C_ADDR_TDA9874 >> 1,
.getmode = tda9874a_getmode,
.setmode = tda9874a_setmode,
@@ -1319,8 +1319,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tda9850",
.id = I2C_DRIVERID_TDA9850,
.insmodopt = &tda9850,
- .addr_lo = I2C_TDA985x_L >> 1,
- .addr_hi = I2C_TDA985x_H >> 1,
+ .addr_lo = I2C_ADDR_TDA985x_L >> 1,
+ .addr_hi = I2C_ADDR_TDA985x_H >> 1,
.registers = 11,
.getmode = tda985x_getmode,
@@ -1332,8 +1332,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tda9855",
.id = I2C_DRIVERID_TDA9855,
.insmodopt = &tda9855,
- .addr_lo = I2C_TDA985x_L >> 1,
- .addr_hi = I2C_TDA985x_H >> 1,
+ .addr_lo = I2C_ADDR_TDA985x_L >> 1,
+ .addr_hi = I2C_ADDR_TDA985x_H >> 1,
.registers = 11,
.flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE,
@@ -1357,8 +1357,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tea6300",
.id = I2C_DRIVERID_TEA6300,
.insmodopt = &tea6300,
- .addr_lo = I2C_TEA6300 >> 1,
- .addr_hi = I2C_TEA6300 >> 1,
+ .addr_lo = I2C_ADDR_TEA6300 >> 1,
+ .addr_hi = I2C_ADDR_TEA6300 >> 1,
.registers = 6,
.flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
@@ -1379,8 +1379,8 @@ static struct CHIPDESC chiplist[] = {
.id = I2C_DRIVERID_TEA6300,
.initialize = tea6320_initialize,
.insmodopt = &tea6320,
- .addr_lo = I2C_TEA6300 >> 1,
- .addr_hi = I2C_TEA6300 >> 1,
+ .addr_lo = I2C_ADDR_TEA6300 >> 1,
+ .addr_hi = I2C_ADDR_TEA6300 >> 1,
.registers = 8,
.flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
@@ -1400,8 +1400,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tea6420",
.id = I2C_DRIVERID_TEA6420,
.insmodopt = &tea6420,
- .addr_lo = I2C_TEA6420 >> 1,
- .addr_hi = I2C_TEA6420 >> 1,
+ .addr_lo = I2C_ADDR_TEA6420 >> 1,
+ .addr_hi = I2C_ADDR_TEA6420 >> 1,
.registers = 1,
.flags = CHIP_HAS_INPUTSEL,
@@ -1413,8 +1413,8 @@ static struct CHIPDESC chiplist[] = {
.name = "tda8425",
.id = I2C_DRIVERID_TDA8425,
.insmodopt = &tda8425,
- .addr_lo = I2C_TDA8425 >> 1,
- .addr_hi = I2C_TDA8425 >> 1,
+ .addr_lo = I2C_ADDR_TDA8425 >> 1,
+ .addr_hi = I2C_ADDR_TDA8425 >> 1,
.registers = 9,
.flags = CHIP_HAS_VOLUME | CHIP_HAS_BASSTREBLE | CHIP_HAS_INPUTSEL,
@@ -1437,8 +1437,8 @@ static struct CHIPDESC chiplist[] = {
.name = "pic16c54 (PV951)",
.id = I2C_DRIVERID_PIC16C54_PV9,
.insmodopt = &pic16c54,
- .addr_lo = I2C_PIC16C54 >> 1,
- .addr_hi = I2C_PIC16C54>> 1,
+ .addr_lo = I2C_ADDR_PIC16C54 >> 1,
+ .addr_hi = I2C_ADDR_PIC16C54>> 1,
.registers = 2,
.flags = CHIP_HAS_INPUTSEL,
@@ -1446,8 +1446,7 @@ static struct CHIPDESC chiplist[] = {
.inputmap = {PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_TUNER,
PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
PIC16C54_MISC_SND_NOTMUTE|PIC16C54_MISC_SWITCH_LINE,
- PIC16C54_MISC_SND_MUTE,PIC16C54_MISC_SND_MUTE,
- PIC16C54_MISC_SND_NOTMUTE},
+ PIC16C54_MISC_SND_MUTE},
.inputmute = PIC16C54_MISC_SND_MUTE,
},
{
@@ -1456,8 +1455,8 @@ static struct CHIPDESC chiplist[] = {
/*.id = I2C_DRIVERID_TA8874Z, */
.checkit = ta8874z_checkit,
.insmodopt = &ta8874z,
- .addr_lo = I2C_TDA9840 >> 1,
- .addr_hi = I2C_TDA9840 >> 1,
+ .addr_lo = I2C_ADDR_TDA9840 >> 1,
+ .addr_hi = I2C_ADDR_TDA9840 >> 1,
.registers = 2,
.getmode = ta8874z_getmode,
@@ -1583,28 +1582,40 @@ static int chip_detach(struct i2c_client *client)
return 0;
}
+static int tvaudio_set_ctrl(struct CHIPSTATE *chip, struct v4l2_control *ctrl)
+{
+ struct CHIPDESC *desc = chiplist + chip->type;
+
+ switch (ctrl->id) {
+ case V4L2_CID_AUDIO_MUTE:
+ if (ctrl->value < 0 || ctrl->value >= 2)
+ return -ERANGE;
+ chip->muted = ctrl->value;
+ if (chip->muted)
+ chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
+ else
+ chip_write_masked(chip,desc->inputreg,
+ desc->inputmap[chip->input],desc->inputmask);
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+
/* ---------------------------------------------------------------------- */
/* video4linux interface */
static int chip_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
- __u16 *sarg = arg;
struct CHIPSTATE *chip = i2c_get_clientdata(client);
struct CHIPDESC *desc = chiplist + chip->type;
v4l_dbg(1, debug, &chip->c, "%s: chip_command 0x%x\n", chip->c.name, cmd);
switch (cmd) {
- case AUDC_SET_INPUT:
- if (desc->flags & CHIP_HAS_INPUTSEL) {
- if (*sarg & 0x80)
- chip_write_masked(chip,desc->inputreg,desc->inputmute,desc->inputmask);
- else
- chip_write_masked(chip,desc->inputreg,desc->inputmap[*sarg],desc->inputmask);
- }
- break;
-
case AUDC_SET_RADIO:
chip->radio = 1;
chip->watch_stereo = 0;
@@ -1668,6 +1679,48 @@ static int chip_command(struct i2c_client *client,
break;
}
+ case VIDIOC_S_CTRL:
+ return tvaudio_set_ctrl(chip, arg);
+
+ case VIDIOC_INT_G_AUDIO_ROUTING:
+ {
+ struct v4l2_routing *rt = arg;
+
+ rt->input = chip->input;
+ rt->output = 0;
+ break;
+ }
+
+ case VIDIOC_INT_S_AUDIO_ROUTING:
+ {
+ struct v4l2_routing *rt = arg;
+
+ if (!(desc->flags & CHIP_HAS_INPUTSEL) || rt->input >= 4)
+ return -EINVAL;
+ /* There are four inputs: tuner, radio, extern and intern. */
+ chip->input = rt->input;
+ if (chip->muted)
+ break;
+ chip_write_masked(chip, desc->inputreg,
+ desc->inputmap[chip->input], desc->inputmask);
+ break;
+ }
+
+ case VIDIOC_S_AUDIO:
+ {
+ struct v4l2_audio *sarg = arg;
+
+ if (!(desc->flags & CHIP_HAS_INPUTSEL) || sarg->index >= 4)
+ return -EINVAL;
+ /* There are four inputs: tuner, radio, extern and intern. */
+ chip->input = sarg->index;
+ if (chip->muted)
+ break;
+ chip_write_masked(chip, desc->inputreg,
+ desc->inputmap[chip->input], desc->inputmask);
+ break;
+ }
+
case VIDIOC_S_TUNER:
{
struct v4l2_tuner *vt = arg;
@@ -1680,6 +1733,7 @@ static int chip_command(struct i2c_client *client,
mode = VIDEO_SOUND_MONO;
break;
case V4L2_TUNER_MODE_STEREO:
+ case V4L2_TUNER_MODE_LANG1_LANG2:
mode = VIDEO_SOUND_STEREO;
break;
case V4L2_TUNER_MODE_LANG1:
diff --git a/drivers/media/video/tvaudio.h b/drivers/media/video/tvaudio.h
deleted file mode 100644
index af7e116af9a..00000000000
--- a/drivers/media/video/tvaudio.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * i2c bus addresses for the chips supported by tvaudio.c
- */
-
-#define I2C_TDA8425 0x82
-#define I2C_TDA9840 0x84 /* also used by TA8874Z */
-#define I2C_TDA985x_L 0xb4 /* also used by 9873 */
-#define I2C_TDA985x_H 0xb6
-#define I2C_TDA9874 0xb0 /* also used by 9875 */
-
-#define I2C_TEA6300 0x80 /* also used by 6320 */
-#define I2C_TEA6420 0x98
-
-#define I2C_PIC16C54 0x96 /* PV951 */
diff --git a/drivers/media/video/tveeprom.c b/drivers/media/video/tveeprom.c
index 582551b0969..e0d2ff83fc9 100644
--- a/drivers/media/video/tveeprom.c
+++ b/drivers/media/video/tveeprom.c
@@ -248,32 +248,32 @@ audioIC[] =
{AUDIO_CHIP_MSP34XX, "MSP3410D"},
{AUDIO_CHIP_MSP34XX, "MSP3415"},
{AUDIO_CHIP_MSP34XX, "MSP3430"},
- {AUDIO_CHIP_UNKNOWN, "MSP3438"},
+ {AUDIO_CHIP_MSP34XX, "MSP3438"},
{AUDIO_CHIP_UNKNOWN, "CS5331"},
/* 10-14 */
{AUDIO_CHIP_MSP34XX, "MSP3435"},
{AUDIO_CHIP_MSP34XX, "MSP3440"},
{AUDIO_CHIP_MSP34XX, "MSP3445"},
- {AUDIO_CHIP_UNKNOWN, "MSP3411"},
- {AUDIO_CHIP_UNKNOWN, "MSP3416"},
+ {AUDIO_CHIP_MSP34XX, "MSP3411"},
+ {AUDIO_CHIP_MSP34XX, "MSP3416"},
/* 15-19 */
{AUDIO_CHIP_MSP34XX, "MSP3425"},
- {AUDIO_CHIP_UNKNOWN, "MSP3451"},
- {AUDIO_CHIP_UNKNOWN, "MSP3418"},
+ {AUDIO_CHIP_MSP34XX, "MSP3451"},
+ {AUDIO_CHIP_MSP34XX, "MSP3418"},
{AUDIO_CHIP_UNKNOWN, "Type 0x12"},
{AUDIO_CHIP_UNKNOWN, "OKI7716"},
/* 20-24 */
- {AUDIO_CHIP_UNKNOWN, "MSP4410"},
- {AUDIO_CHIP_UNKNOWN, "MSP4420"},
- {AUDIO_CHIP_UNKNOWN, "MSP4440"},
- {AUDIO_CHIP_UNKNOWN, "MSP4450"},
- {AUDIO_CHIP_UNKNOWN, "MSP4408"},
+ {AUDIO_CHIP_MSP34XX, "MSP4410"},
+ {AUDIO_CHIP_MSP34XX, "MSP4420"},
+ {AUDIO_CHIP_MSP34XX, "MSP4440"},
+ {AUDIO_CHIP_MSP34XX, "MSP4450"},
+ {AUDIO_CHIP_MSP34XX, "MSP4408"},
/* 25-29 */
- {AUDIO_CHIP_UNKNOWN, "MSP4418"},
- {AUDIO_CHIP_UNKNOWN, "MSP4428"},
- {AUDIO_CHIP_UNKNOWN, "MSP4448"},
- {AUDIO_CHIP_UNKNOWN, "MSP4458"},
- {AUDIO_CHIP_UNKNOWN, "Type 0x1d"},
+ {AUDIO_CHIP_MSP34XX, "MSP4418"},
+ {AUDIO_CHIP_MSP34XX, "MSP4428"},
+ {AUDIO_CHIP_MSP34XX, "MSP4448"},
+ {AUDIO_CHIP_MSP34XX, "MSP4458"},
+ {AUDIO_CHIP_MSP34XX, "Type 0x1d"},
/* 30-34 */
{AUDIO_CHIP_INTERNAL, "CX880"},
{AUDIO_CHIP_INTERNAL, "CX881"},
diff --git a/drivers/media/video/usbvideo/Makefile b/drivers/media/video/usbvideo/Makefile
new file mode 100644
index 00000000000..ed410a5ee8c
--- /dev/null
+++ b/drivers/media/video/usbvideo/Makefile
@@ -0,0 +1,4 @@
+obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o
+obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
+obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o
+
diff --git a/drivers/usb/media/ibmcam.c b/drivers/media/video/usbvideo/ibmcam.c
index a42c2229412..76f771b6a32 100644
--- a/drivers/usb/media/ibmcam.c
+++ b/drivers/media/video/usbvideo/ibmcam.c
@@ -1300,11 +1300,11 @@ static void ibmcam_model2_Packet1(struct uvd *uvd, unsigned short v1, unsigned s
/*
* ibmcam_model3_Packet1()
*
- * 00_0078_012d
+ * 00_0078_012d
* 00_0097_012f
- * 00_d141_0124
+ * 00_d141_0124
* 00_0096_0127
- * 00_fea8_0124
+ * 00_fea8_0124
*/
static void ibmcam_model3_Packet1(struct uvd *uvd, unsigned short v1, unsigned short v2)
{
@@ -2687,7 +2687,7 @@ static void ibmcam_model4_setup_after_video_if(struct uvd *uvd)
ibmcam_veio(uvd, 0, 0x0004, 0x0127);
ibmcam_veio(uvd, 0, 0xfea8, 0x0124);
ibmcam_veio(uvd, 0, 0x00c0, 0x010c);
- break;
+ break;
}
usb_clear_halt(uvd->dev, usb_rcvisocpipe(uvd->dev, uvd->video_endp));
}
@@ -3238,7 +3238,7 @@ static void ibmcam_model3_setup_after_video_if(struct uvd *uvd)
{0, 0x0062, 0x0107},
{0, 0x0003, 0x0111},
};
-#define NUM_INIT_DATA
+#define NUM_INIT_DATA
unsigned short compression = 0; /* 0=none, 7=best frame rate */
int f_rate; /* 0=Fastest 7=slowest */
diff --git a/drivers/usb/media/konicawc.c b/drivers/media/video/usbvideo/konicawc.c
index e2ede583518..c11f5d46b11 100644
--- a/drivers/usb/media/konicawc.c
+++ b/drivers/media/video/usbvideo/konicawc.c
@@ -36,7 +36,7 @@
enum ctrl_req {
SetWhitebal = 0x01,
SetBrightness = 0x02,
- SetSharpness = 0x03,
+ SetSharpness = 0x03,
SetContrast = 0x04,
SetSaturation = 0x05,
};
@@ -47,7 +47,7 @@ enum frame_sizes {
SIZE_160X136 = 1,
SIZE_176X144 = 2,
SIZE_320X240 = 3,
-
+
};
#define MAX_FRAME_SIZE SIZE_320X240
@@ -69,7 +69,7 @@ static const int debug = 0;
/* Some default values for initial camera settings,
can be set by modprobe */
-static int size;
+static int size;
static int speed = 6; /* Speed (fps) 0 (slowest) to 6 (fastest) */
static int brightness = MAX_BRIGHTNESS/2;
static int contrast = MAX_CONTRAST/2;
@@ -132,24 +132,24 @@ struct konicawc {
static int konicawc_ctrl_msg(struct uvd *uvd, u8 dir, u8 request, u16 value, u16 index, void *buf, int len)
{
- int retval = usb_control_msg(uvd->dev,
+ int retval = usb_control_msg(uvd->dev,
dir ? usb_rcvctrlpipe(uvd->dev, 0) : usb_sndctrlpipe(uvd->dev, 0),
request, 0x40 | dir, value, index, buf, len, 1000);
- return retval < 0 ? retval : 0;
+ return retval < 0 ? retval : 0;
}
static inline void konicawc_camera_on(struct uvd *uvd)
{
- DEBUG(0, "camera on");
- konicawc_set_misc(uvd, 0x2, 1, 0x0b);
+ DEBUG(0, "camera on");
+ konicawc_set_misc(uvd, 0x2, 1, 0x0b);
}
static inline void konicawc_camera_off(struct uvd *uvd)
{
- DEBUG(0, "camera off");
- konicawc_set_misc(uvd, 0x2, 0, 0x0b);
+ DEBUG(0, "camera off");
+ konicawc_set_misc(uvd, 0x2, 0, 0x0b);
}
@@ -317,7 +317,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
button = !!(sts & 0x40);
sts &= ~0x40;
}
-
+
/* work out the button status, but don't do
anything with it for now */
@@ -331,7 +331,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
discard++;
continue;
}
-
+
if((sts > 0x01) && (sts < 0x80)) {
info("unknown status %2.2x", sts);
bad++;
@@ -350,7 +350,7 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
DEBUG(2, "found initial image");
cam->lastframe = -1;
}
-
+
marker[3] = sts & 0x7F;
RingQueue_Enqueue(&uvd->dp, marker, 4);
totlen += 4;
@@ -367,16 +367,16 @@ static int konicawc_compress_iso(struct uvd *uvd, struct urb *dataurb, struct ur
static void resubmit_urb(struct uvd *uvd, struct urb *urb)
{
- int i, ret;
- for (i = 0; i < FRAMES_PER_DESC; i++) {
- urb->iso_frame_desc[i].status = 0;
- }
- urb->dev = uvd->dev;
- urb->status = 0;
+ int i, ret;
+ for (i = 0; i < FRAMES_PER_DESC; i++) {
+ urb->iso_frame_desc[i].status = 0;
+ }
+ urb->dev = uvd->dev;
+ urb->status = 0;
ret = usb_submit_urb(urb, GFP_ATOMIC);
DEBUG(3, "submitting urb of length %d", urb->transfer_buffer_length);
- if(ret)
- err("usb_submit_urb error (%d)", ret);
+ if(ret)
+ err("usb_submit_urb error (%d)", ret);
}
@@ -490,7 +490,7 @@ static int konicawc_start_data(struct uvd *uvd)
}
cam->last_data_urb = NULL;
-
+
/* Submit all URBs */
for (i=0; i < USBVIDEO_NUMSBUF; i++) {
errFlag = usb_submit_urb(cam->sts_urb[i], GFP_KERNEL);
@@ -539,7 +539,7 @@ static void konicawc_stop_data(struct uvd *uvd)
static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
-{
+{
struct konicawc *cam = (struct konicawc *)uvd->user_data;
int maxline = cam->maxline;
int yplanesz = cam->yplanesz;
@@ -583,13 +583,13 @@ static void konicawc_process_isoc(struct uvd *uvd, struct usbvideo_frame *frame)
if(frame->scanstate == ScanState_Scanning)
return;
-
+
/* Try to move data from queue into frame buffer
* We get data in blocks of 384 bytes made up of:
* 256 Y, 64 U, 64 V.
* This needs to be written out as a Y plane, a U plane and a V plane.
*/
-
+
while ( frame->curline < maxline && (RingQueue_GetLength(&uvd->dp) >= 384)) {
/* Y */
RingQueue_Dequeue(&uvd->dp, frame->data + (frame->curline * 256), 256);
diff --git a/drivers/usb/media/ultracam.c b/drivers/media/video/usbvideo/ultracam.c
index 75ff755224d..10c58b4a2e5 100644
--- a/drivers/usb/media/ultracam.c
+++ b/drivers/media/video/usbvideo/ultracam.c
@@ -23,7 +23,7 @@
typedef struct {
int initialized; /* Had we already sent init sequence? */
int camera_model; /* What type of IBM camera we got? */
- int has_hdr;
+ int has_hdr;
} ultracam_t;
#define ULTRACAM_T(uvd) ((ultracam_t *)((uvd)->user_data))
diff --git a/drivers/usb/media/usbvideo.c b/drivers/media/video/usbvideo/usbvideo.c
index 0b51fae720a..13b37c8c0d5 100644
--- a/drivers/usb/media/usbvideo.c
+++ b/drivers/media/video/usbvideo/usbvideo.c
@@ -574,7 +574,7 @@ void usbvideo_TestPattern(struct uvd *uvd, int fullframe, int pmode)
} else {
/* Just the blue screen */
}
-
+
*f++ = cb;
*f++ = cg;
*f++ = cr;
@@ -1243,7 +1243,7 @@ static int usbvideo_v4l_close(struct inode *inode, struct file *file)
#if USBVIDEO_REPORT_STATS
usbvideo_ReportStatistics(uvd);
-#endif
+#endif
uvd->user--;
if (uvd->remove_pending) {
@@ -1290,7 +1290,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
return 0;
}
case VIDIOCSCHAN:
- {
+ {
struct video_channel *v = arg;
if (v->channel != 0)
return -EINVAL;
@@ -1347,7 +1347,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
vw->chromakey = 0;
if (VALID_CALLBACK(uvd, getFPS))
vw->flags = GET_CALLBACK(uvd, getFPS)(uvd);
- else
+ else
vw->flags = 10; /* FIXME: do better! */
return 0;
}
@@ -1359,7 +1359,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
memset(vm, 0, sizeof(*vm));
vm->size = uvd->max_frame_size * USBVIDEO_NUMFRAMES;
vm->frames = USBVIDEO_NUMFRAMES;
- for(i = 0; i < USBVIDEO_NUMFRAMES; i++)
+ for(i = 0; i < USBVIDEO_NUMFRAMES; i++)
vm->offsets[i] = i * uvd->max_frame_size;
return 0;
@@ -1425,7 +1425,7 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
if (*frameNum < 0 || *frameNum >= USBVIDEO_NUMFRAMES)
return -EINVAL;
-
+
if (uvd->debug >= 1)
info("VIDIOCSYNC: syncing to frame %d.", *frameNum);
if (uvd->flags & FLAGS_NO_DECODING)
@@ -1454,8 +1454,8 @@ static int usbvideo_v4l_do_ioctl(struct inode *inode, struct file *file,
struct video_buffer *vb = arg;
memset(vb, 0, sizeof(*vb));
- return 0;
- }
+ return 0;
+ }
case VIDIOCKEY:
return 0;
@@ -1704,7 +1704,7 @@ static void usbvideo_IsocIrq(struct urb *urb, struct pt_regs *regs)
info("Not streaming, but interrupt!");
return;
}
-
+
uvd->stats.urb_count++;
if (urb->actual_length <= 0)
goto urb_done_with;
@@ -1763,7 +1763,7 @@ static int usbvideo_StartDataPump(struct uvd *uvd)
}
if (VALID_CALLBACK(uvd, videoStart))
GET_CALLBACK(uvd, videoStart)(uvd);
- else
+ else
err("%s: videoStart not set", __FUNCTION__);
/* We double buffer the Iso lists */
@@ -1830,7 +1830,7 @@ static void usbvideo_StopDataPump(struct uvd *uvd)
/* Invoke minidriver's magic to stop the camera */
if (VALID_CALLBACK(uvd, videoStop))
GET_CALLBACK(uvd, videoStop)(uvd);
- else
+ else
err("%s: videoStop not set", __FUNCTION__);
/* Set packet size to 0 */
@@ -1963,14 +1963,14 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
info("%s($%p,%d.)", __FUNCTION__, uvd, frameNum);
switch (frame->frameState) {
- case FrameState_Unused:
+ case FrameState_Unused:
if (uvd->debug >= 2)
info("%s: FrameState_Unused", __FUNCTION__);
return -EINVAL;
- case FrameState_Ready:
- case FrameState_Grabbing:
- case FrameState_Error:
- {
+ case FrameState_Ready:
+ case FrameState_Grabbing:
+ case FrameState_Error:
+ {
int ntries, signalPending;
redo:
if (!CAMERA_IS_OPERATIONAL(uvd)) {
@@ -1978,7 +1978,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
info("%s: Camera is not operational (1)", __FUNCTION__);
return -EIO;
}
- ntries = 0;
+ ntries = 0;
do {
RingQueue_InterruptibleSleepOn(&uvd->dp);
signalPending = signal_pending(current);
@@ -2010,7 +2010,7 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
usbvideo_CollectRawData(uvd, frame);
else if (VALID_CALLBACK(uvd, processData))
GET_CALLBACK(uvd, processData)(uvd, frame);
- else
+ else
err("%s: processData not set", __FUNCTION__);
}
} while (frame->frameState == FrameState_Grabbing);
@@ -2027,8 +2027,8 @@ static int usbvideo_GetFrame(struct uvd *uvd, int frameNum)
goto redo;
}
/* Note that we fall through to meet our destiny below */
- }
- case FrameState_Done:
+ }
+ case FrameState_Done:
/*
* Do all necessary postprocessing of data prepared in
* "interrupt" code and the collecting code above. The
@@ -2157,7 +2157,7 @@ EXPORT_SYMBOL(usbvideo_DeinterlaceFrame);
* History:
* 09-Feb-2001 Created.
*/
-static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd,
+static void usbvideo_SoftwareContrastAdjustment(struct uvd *uvd,
struct usbvideo_frame *frame)
{
int i, j, v4l_linesize;
diff --git a/drivers/usb/media/usbvideo.h b/drivers/media/video/usbvideo/usbvideo.h
index 135433c2680..3cbf4fc499a 100644
--- a/drivers/usb/media/usbvideo.h
+++ b/drivers/media/video/usbvideo/usbvideo.h
@@ -189,11 +189,11 @@ struct usbvideo_frame {
/* Statistics that can be overlaid on screen */
struct usbvideo_statistics {
- unsigned long frame_num; /* Sequential number of the frame */
- unsigned long urb_count; /* How many URBs we received so far */
- unsigned long urb_length; /* Length of last URB */
- unsigned long data_count; /* How many bytes we received */
- unsigned long header_count; /* How many frame headers we found */
+ unsigned long frame_num; /* Sequential number of the frame */
+ unsigned long urb_count; /* How many URBs we received so far */
+ unsigned long urb_length; /* Length of last URB */
+ unsigned long data_count; /* How many bytes we received */
+ unsigned long header_count; /* How many frame headers we found */
unsigned long iso_skip_count; /* How many empty ISO packets received */
unsigned long iso_err_count; /* How many bad ISO packets received */
};
diff --git a/drivers/usb/media/vicam.c b/drivers/media/video/usbvideo/vicam.c
index 1d06e53ec7c..90d48e8510b 100644
--- a/drivers/usb/media/vicam.c
+++ b/drivers/media/video/usbvideo/vicam.c
@@ -69,10 +69,10 @@
#define VICAM_HEADER_SIZE 64
#define clamp( x, l, h ) max_t( __typeof__( x ), \
- ( l ), \
- min_t( __typeof__( x ), \
- ( h ), \
- ( x ) ) )
+ ( l ), \
+ min_t( __typeof__( x ), \
+ ( h ), \
+ ( x ) ) )
/* Not sure what all the bytes in these char
* arrays do, but they're necessary to make
@@ -357,7 +357,7 @@ static unsigned char setup5[] = {
* Not sure why these are not yet non-statics which I can reference through
* usbvideo.h the same as it is in 2.4.20. I bet this will get fixed sometime
* in the future.
- *
+ *
*/
static void *rvmalloc(unsigned long size)
{
@@ -603,12 +603,12 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
case VIDIOCSPICT:
{
struct video_picture vp;
-
+
if (copy_from_user(&vp, user_arg, sizeof(vp))) {
retval = -EFAULT;
break;
}
-
+
DBG("VIDIOCSPICT depth = %d, pal = %d\n", vp.depth,
vp.palette);
@@ -655,7 +655,7 @@ vicam_ioctl(struct inode *inode, struct file *file, unsigned int ioctlnr, unsign
}
DBG("VIDIOCSWIN %d x %d\n", vw.width, vw.height);
-
+
if ( vw.width != 320 || vw.height != 240 )
retval = -EFAULT;
@@ -809,12 +809,12 @@ vicam_open(struct inode *inode, struct file *file)
cam->needsDummyRead = 1;
cam->open_count++;
- file->private_data = cam;
-
+ file->private_data = cam;
+
return 0;
}
-static int
+static int
vicam_close(struct inode *inode, struct file *file)
{
struct vicam_camera *cam = file->private_data;
@@ -1187,7 +1187,7 @@ vicam_create_proc_entry(struct vicam_camera *cam)
if ( !cam->proc_dir )
return; // FIXME: We should probably return an error here
-
+
ent = create_proc_entry("shutter", S_IFREG | S_IRUGO | S_IWUSR,
cam->proc_dir);
if (ent) {
@@ -1282,7 +1282,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
const struct usb_host_interface *interface;
const struct usb_endpoint_descriptor *endpoint;
struct vicam_camera *cam;
-
+
printk(KERN_INFO "ViCam based webcam connected\n");
interface = intf->cur_altsetting;
@@ -1331,7 +1331,7 @@ vicam_probe( struct usb_interface *intf, const struct usb_device_id *id)
printk(KERN_INFO "ViCam webcam driver now controlling video device %d\n",cam->vdev.minor);
usb_set_intfdata (intf, cam);
-
+
return 0;
}
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index 95a6e47c99f..11a97f30b87 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -312,8 +312,6 @@ static const char *v4l2_int_ioctls[] = {
[_IOC_NR(DECODER_DUMP)] = "DECODER_DUMP",
#endif
[_IOC_NR(AUDC_SET_RADIO)] = "AUDC_SET_RADIO",
- [_IOC_NR(AUDC_SET_INPUT)] = "AUDC_SET_INPUT",
- [_IOC_NR(MSP_SET_MATRIX)] = "MSP_SET_MATRIX",
[_IOC_NR(TUNER_SET_TYPE_ADDR)] = "TUNER_SET_TYPE_ADDR",
[_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
@@ -419,7 +417,6 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
case TUNER_SET_TYPE_ADDR:
case TUNER_SET_STANDBY:
case TDA9887_SET_CONFIG:
- case AUDC_SET_INPUT:
case VIDIOC_OVERLAY_OLD:
case VIDIOC_STREAMOFF:
case VIDIOC_G_OUTPUT:
@@ -433,12 +430,6 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
printk ("%s: value=%d\n", s, *p);
break;
}
- case MSP_SET_MATRIX:
- {
- struct msp_matrix *p=arg;
- printk ("%s: input=%d, output=%d\n", s, p->input, p->output);
- break;
- }
case VIDIOC_G_AUDIO:
case VIDIOC_S_AUDIO:
case VIDIOC_ENUMAUDIO:
@@ -467,7 +458,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
struct v4l2_buffer *p=arg;
struct v4l2_timecode *tc=&p->timecode;
printk ("%s: %02ld:%02d:%02d.%08ld index=%d, type=%s, "
- "bytesused=%d, flags=0x%08d, "
+ "bytesused=%d, flags=0x%08x, "
"field=%0d, sequence=%d, memory=%s, offset/userptr=0x%08lx\n",
s,
(p->timestamp.tv_sec/3600),
@@ -481,16 +472,16 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
prt_names(p->memory,v4l2_memory_names),
p->m.userptr);
printk ("%s: timecode= %02d:%02d:%02d type=%d, "
- "flags=0x%08d, frames=%d, userbits=0x%08x",
+ "flags=0x%08x, frames=%d, userbits=0x%p\n",
s,tc->hours,tc->minutes,tc->seconds,
- tc->type, tc->flags, tc->frames, (__u32) tc->userbits);
+ tc->type, tc->flags, tc->frames, tc->userbits);
break;
}
case VIDIOC_QUERYCAP:
{
struct v4l2_capability *p=arg;
- printk ("%s: driver=%s, card=%s, bus=%s, version=%d, "
- "capabilities=%d\n", s,
+ printk ("%s: driver=%s, card=%s, bus=%s, version=0x%08x, "
+ "capabilities=0x%08x\n", s,
p->driver,p->card,p->bus_info,
p->version,
p->capabilities);
@@ -574,9 +565,10 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
{
struct v4l2_input *p=arg;
printk ("%s: index=%d, name=%s, type=%d, audioset=%d, "
- "tuner=%d, std=%lld, status=%d\n", s,
+ "tuner=%d, std=%Ld, status=%d\n", s,
p->index,p->name,p->type,p->audioset,
- p->tuner,p->std,
+ p->tuner,
+ (unsigned long long)p->std,
p->status);
break;
}
@@ -620,9 +612,10 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
{
struct v4l2_output *p=arg;
printk ("%s: index=%d, name=%s,type=%d, audioset=%d, "
- "modulator=%d, std=%lld\n",
+ "modulator=%d, std=%Ld\n",
s,p->index,p->name,p->type,p->audioset,
- p->modulator,p->std);
+ p->modulator,
+ (unsigned long long)p->std);
break;
}
case VIDIOC_QUERYCTRL:
@@ -665,7 +658,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
case VIDIOC_INT_G_VIDEO_ROUTING:
{
struct v4l2_routing *p=arg;
- printk ("%s: input=%d, output=%d\n", s, p->input, p->output);
+ printk ("%s: input=0x%x, output=0x%x\n", s, p->input, p->output);
break;
}
case VIDIOC_G_SLICED_VBI_CAP:
@@ -686,8 +679,9 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
case VIDIOC_ENUMSTD:
{
struct v4l2_standard *p=arg;
- printk ("%s: index=%d, id=%lld, name=%s, fps=%d/%d, framelines=%d\n", s,
- p->index, p->id, p->name,
+ printk ("%s: index=%d, id=%Ld, name=%s, fps=%d/%d, "
+ "framelines=%d\n", s, p->index,
+ (unsigned long long)p->id, p->name,
p->frameperiod.numerator,
p->frameperiod.denominator,
p->framelines);
@@ -907,7 +901,7 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
{
v4l2_std_id *p=arg;
- printk ("%s: value=%llu\n", s, *p);
+ printk ("%s: value=%Lu\n", s, (unsigned long long)*p);
break;
}
}
diff --git a/drivers/media/video/video-buf.c b/drivers/media/video/video-buf.c
index 87e937581d5..d2ca0f08d0d 100644
--- a/drivers/media/video/video-buf.c
+++ b/drivers/media/video/video-buf.c
@@ -1,15 +1,20 @@
/*
*
* generic helper functions for video4linux capture buffers, to handle
- * memory management and PCI DMA. Right now bttv + saa7134 use it.
+ * memory management and PCI DMA.
+ * Right now, bttv, saa7134, saa7146 and cx88 use it.
*
* The functions expect the hardware being able to scatter gatter
* (i.e. the buffers are not linear in physical memory, but fragmented
* into PAGE_SIZE chunks). They also assume the driver does not need
- * to touch the video data (thus it is probably not useful for USB 1.1
- * as data often must be uncompressed by the drivers).
+ * to touch the video data.
+ *
+ * device specific map/unmap/sync stuff now are mapped as operations
+ * to allow its usage by USB and virtual devices.
*
* (c) 2001-2004 Gerd Knorr <kraxel@bytesex.org> [SUSE Labs]
+ * (c) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+ * (c) 2006 Ted Walther and John Sokol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -167,6 +172,9 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
dprintk(1,"vmalloc_32(%d pages) failed\n",nr_pages);
return -ENOMEM;
}
+ dprintk(1,"vmalloc is at addr 0x%08lx, size=%d\n",
+ (unsigned long)dma->vmalloc,
+ nr_pages << PAGE_SHIFT);
memset(dma->vmalloc,0,nr_pages << PAGE_SHIFT);
dma->nr_pages = nr_pages;
return 0;
@@ -186,8 +194,10 @@ int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
return 0;
}
-int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
BUG_ON(0 == dma->nr_pages);
@@ -197,7 +207,7 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
}
if (dma->vmalloc) {
dma->sglist = videobuf_vmalloc_to_sg
- (dma->vmalloc,dma->nr_pages);
+ (dma->vmalloc,dma->nr_pages);
}
if (dma->bus_addr) {
dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL);
@@ -212,13 +222,14 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
dprintk(1,"scatterlist is NULL\n");
return -ENOMEM;
}
-
if (!dma->bus_addr) {
- dma->sglen = pci_map_sg(dev,dma->sglist,dma->nr_pages,
- dma->direction);
+ if (q->ops->vb_map_sg) {
+ dma->sglen = q->ops->vb_map_sg(dev,dma->sglist,
+ dma->nr_pages, dma->direction);
+ }
if (0 == dma->sglen) {
printk(KERN_WARNING
- "%s: pci_map_sg failed\n",__FUNCTION__);
+ "%s: videobuf_map_sg failed\n",__FUNCTION__);
kfree(dma->sglist);
dma->sglist = NULL;
dma->sglen = 0;
@@ -228,24 +239,31 @@ int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma)
return 0;
}
-int videobuf_dma_pci_sync(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
BUG_ON(!dma->sglen);
- if (!dma->bus_addr)
- pci_dma_sync_sg_for_cpu(dev,dma->sglist,dma->nr_pages,dma->direction);
+ if (!dma->bus_addr && q->ops->vb_dma_sync_sg)
+ q->ops->vb_dma_sync_sg(dev,dma->sglist,dma->nr_pages,
+ dma->direction);
+
return 0;
}
-int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma)
+int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma)
{
+ void *dev=q->dev;
+
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
if (!dma->sglen)
return 0;
- if (!dma->bus_addr)
- pci_unmap_sg(dev,dma->sglist,dma->nr_pages,dma->direction);
+ if (!dma->bus_addr && q->ops->vb_unmap_sg)
+ q->ops->vb_unmap_sg(dev,dma->sglist,dma->nr_pages,
+ dma->direction);
kfree(dma->sglist);
dma->sglist = NULL;
dma->sglen = 0;
@@ -318,7 +336,7 @@ int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)
}
int
-videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
+videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
struct v4l2_framebuffer *fbuf)
{
int err,pages;
@@ -357,7 +375,7 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
default:
BUG();
}
- err = videobuf_dma_pci_map(pci,&vb->dma);
+ err = videobuf_dma_map(q,&vb->dma);
if (0 != err)
return err;
@@ -366,9 +384,41 @@ videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
/* --------------------------------------------------------------------- */
+void videobuf_queue_pci(struct videobuf_queue* q)
+{
+ /* If not specified, defaults to PCI map sg */
+ if (!q->ops->vb_map_sg)
+ q->ops->vb_map_sg=(vb_map_sg_t *)pci_map_sg;
+
+ if (!q->ops->vb_dma_sync_sg)
+ q->ops->vb_dma_sync_sg=(vb_map_sg_t *)pci_dma_sync_sg_for_cpu;
+ if (!q->ops->vb_unmap_sg)
+ q->ops->vb_unmap_sg=(vb_map_sg_t *)pci_unmap_sg;
+}
+
+int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma)
+{
+ struct videobuf_queue q;
+
+ q.dev=pci;
+ q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
+
+ return (videobuf_dma_unmap(&q,dma));
+}
+
+int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma)
+{
+ struct videobuf_queue q;
+
+ q.dev=pci;
+ q.ops->vb_map_sg=(vb_map_sg_t *)pci_unmap_sg;
+
+ return (videobuf_dma_unmap(&q,dma));
+}
+
void videobuf_queue_init(struct videobuf_queue* q,
struct videobuf_queue_ops *ops,
- struct pci_dev *pci,
+ void *dev,
spinlock_t *irqlock,
enum v4l2_buf_type type,
enum v4l2_field field,
@@ -377,13 +427,15 @@ void videobuf_queue_init(struct videobuf_queue* q,
{
memset(q,0,sizeof(*q));
q->irqlock = irqlock;
- q->pci = pci;
+ q->dev = dev;
q->type = type;
q->field = field;
q->msize = msize;
q->ops = ops;
q->priv_data = priv;
+ videobuf_queue_pci(q);
+
mutex_init(&q->lock);
INIT_LIST_HEAD(&q->stream);
}
@@ -431,7 +483,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
int i;
/* remove queued buffers from list */
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
if (NULL == q->bufs[i])
continue;
@@ -440,7 +493,8 @@ videobuf_queue_cancel(struct videobuf_queue *q)
q->bufs[i]->state = STATE_ERROR;
}
}
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
/* free all buffers + clear queue */
for (i = 0; i < VIDEO_MAX_FRAME; i++) {
@@ -534,19 +588,29 @@ videobuf_reqbufs(struct videobuf_queue *q,
unsigned int size,count;
int retval;
- if (req->type != q->type)
+ if (req->type != q->type) {
+ dprintk(1,"reqbufs: queue type invalid\n");
return -EINVAL;
- if (req->count < 1)
+ }
+ if (req->count < 1) {
+ dprintk(1,"reqbufs: count invalid (%d)\n",req->count);
return -EINVAL;
+ }
if (req->memory != V4L2_MEMORY_MMAP &&
req->memory != V4L2_MEMORY_USERPTR &&
- req->memory != V4L2_MEMORY_OVERLAY)
+ req->memory != V4L2_MEMORY_OVERLAY) {
+ dprintk(1,"reqbufs: memory type invalid\n");
return -EINVAL;
+ }
- if (q->streaming)
+ if (q->streaming) {
+ dprintk(1,"reqbufs: streaming already exists\n");
return -EBUSY;
- if (!list_empty(&q->stream))
+ }
+ if (!list_empty(&q->stream)) {
+ dprintk(1,"reqbufs: stream running\n");
return -EBUSY;
+ }
mutex_lock(&q->lock);
count = req->count;
@@ -559,8 +623,10 @@ videobuf_reqbufs(struct videobuf_queue *q,
count, size, (count*size)>>PAGE_SHIFT);
retval = videobuf_mmap_setup(q,count,size,req->memory);
- if (retval < 0)
+ if (retval < 0) {
+ dprintk(1,"reqbufs: mmap setup returned %d\n",retval);
goto done;
+ }
req->count = count;
@@ -572,12 +638,18 @@ videobuf_reqbufs(struct videobuf_queue *q,
int
videobuf_querybuf(struct videobuf_queue *q, struct v4l2_buffer *b)
{
- if (unlikely(b->type != q->type))
+ if (unlikely(b->type != q->type)) {
+ dprintk(1,"querybuf: Wrong type.\n");
return -EINVAL;
- if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME))
+ }
+ if (unlikely(b->index < 0 || b->index >= VIDEO_MAX_FRAME)) {
+ dprintk(1,"querybuf: index out of range.\n");
return -EINVAL;
- if (unlikely(NULL == q->bufs[b->index]))
+ }
+ if (unlikely(NULL == q->bufs[b->index])) {
+ dprintk(1,"querybuf: buffer is null.\n");
return -EINVAL;
+ }
videobuf_status(b,q->bufs[b->index],q->type);
return 0;
}
@@ -593,26 +665,40 @@ videobuf_qbuf(struct videobuf_queue *q,
mutex_lock(&q->lock);
retval = -EBUSY;
- if (q->reading)
+ if (q->reading) {
+ dprintk(1,"qbuf: Reading running...\n");
goto done;
+ }
retval = -EINVAL;
- if (b->type != q->type)
+ if (b->type != q->type) {
+ dprintk(1,"qbuf: Wrong type.\n");
goto done;
- if (b->index < 0 || b->index >= VIDEO_MAX_FRAME)
+ }
+ if (b->index < 0 || b->index >= VIDEO_MAX_FRAME) {
+ dprintk(1,"qbuf: index out of range.\n");
goto done;
+ }
buf = q->bufs[b->index];
- if (NULL == buf)
+ if (NULL == buf) {
+ dprintk(1,"qbuf: buffer is null.\n");
goto done;
+ }
MAGIC_CHECK(buf->magic,MAGIC_BUFFER);
- if (buf->memory != b->memory)
+ if (buf->memory != b->memory) {
+ dprintk(1,"qbuf: memory type is wrong.\n");
goto done;
+ }
if (buf->state == STATE_QUEUED ||
- buf->state == STATE_ACTIVE)
+ buf->state == STATE_ACTIVE) {
+ dprintk(1,"qbuf: buffer is already queued or active.\n");
goto done;
+ }
if (b->flags & V4L2_BUF_FLAG_INPUT) {
- if (b->input >= q->inputs)
+ if (b->input >= q->inputs) {
+ dprintk(1,"qbuf: wrong input.\n");
goto done;
+ }
buf->input = b->input;
} else {
buf->input = UNSET;
@@ -620,12 +706,16 @@ videobuf_qbuf(struct videobuf_queue *q,
switch (b->memory) {
case V4L2_MEMORY_MMAP:
- if (0 == buf->baddr)
+ if (0 == buf->baddr) {
+ dprintk(1,"qbuf: mmap requested but buffer addr is zero!\n");
goto done;
+ }
break;
case V4L2_MEMORY_USERPTR:
- if (b->length < buf->bsize)
+ if (b->length < buf->bsize) {
+ dprintk(1,"qbuf: buffer length is not enough\n");
goto done;
+ }
if (STATE_NEEDS_INIT != buf->state && buf->baddr != b->m.userptr)
q->ops->buf_release(q,buf);
buf->baddr = b->m.userptr;
@@ -634,20 +724,27 @@ videobuf_qbuf(struct videobuf_queue *q,
buf->boff = b->m.offset;
break;
default:
+ dprintk(1,"qbuf: wrong memory type\n");
goto done;
}
+ dprintk(1,"qbuf: requesting next field\n");
field = videobuf_next_field(q);
retval = q->ops->buf_prepare(q,buf,field);
- if (0 != retval)
+ if (0 != retval) {
+ dprintk(1,"qbuf: buffer_prepare returned %d\n",retval);
goto done;
+ }
list_add_tail(&buf->stream,&q->stream);
if (q->streaming) {
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
}
+ dprintk(1,"qbuf: succeded\n");
retval = 0;
done:
@@ -664,26 +761,39 @@ videobuf_dqbuf(struct videobuf_queue *q,
mutex_lock(&q->lock);
retval = -EBUSY;
- if (q->reading)
+ if (q->reading) {
+ dprintk(1,"dqbuf: Reading running...\n");
goto done;
+ }
retval = -EINVAL;
- if (b->type != q->type)
+ if (b->type != q->type) {
+ dprintk(1,"dqbuf: Wrong type.\n");
goto done;
- if (list_empty(&q->stream))
+ }
+ if (list_empty(&q->stream)) {
+ dprintk(1,"dqbuf: stream running\n");
goto done;
+ }
buf = list_entry(q->stream.next, struct videobuf_buffer, stream);
retval = videobuf_waiton(buf, nonblocking, 1);
- if (retval < 0)
+ if (retval < 0) {
+ dprintk(1,"dqbuf: waiton returned %d\n",retval);
goto done;
+ }
switch (buf->state) {
case STATE_ERROR:
+ dprintk(1,"dqbuf: state is error\n");
retval = -EIO;
- /* fall through */
+ videobuf_dma_sync(q,&buf->dma);
+ buf->state = STATE_IDLE;
+ break;
case STATE_DONE:
- videobuf_dma_pci_sync(q->pci,&buf->dma);
+ dprintk(1,"dqbuf: state is done\n");
+ videobuf_dma_sync(q,&buf->dma);
buf->state = STATE_IDLE;
break;
default:
+ dprintk(1,"dqbuf: state invalid\n");
retval = -EINVAL;
goto done;
}
@@ -711,13 +821,15 @@ int videobuf_streamon(struct videobuf_queue *q)
if (q->streaming)
goto done;
q->streaming = 1;
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
list_for_each(list,&q->stream) {
buf = list_entry(list, struct videobuf_buffer, stream);
if (buf->state == STATE_PREPARED)
q->ops->buf_queue(q,buf);
}
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
done:
mutex_unlock(&q->lock);
@@ -762,12 +874,14 @@ videobuf_read_zerocopy(struct videobuf_queue *q, char __user *data,
goto done;
/* start capture & wait */
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
retval = videobuf_waiton(q->read_buf,0,0);
if (0 == retval) {
- videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);
+ videobuf_dma_sync(q,&q->read_buf->dma);
if (STATE_ERROR == q->read_buf->state)
retval = -EIO;
else
@@ -809,6 +923,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
/* need to capture a new frame */
retval = -ENOMEM;
q->read_buf = videobuf_alloc(q->msize);
+ dprintk(1,"video alloc=0x%08x\n",(unsigned int) q->read_buf);
if (NULL == q->read_buf)
goto done;
q->read_buf->memory = V4L2_MEMORY_USERPTR;
@@ -820,9 +935,11 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
q->read_buf = NULL;
goto done;
}
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->read_off = 0;
}
@@ -830,7 +947,7 @@ ssize_t videobuf_read_one(struct videobuf_queue *q,
retval = videobuf_waiton(q->read_buf, nonblocking, 1);
if (0 != retval)
goto done;
- videobuf_dma_pci_sync(q->pci,&q->read_buf->dma);
+ videobuf_dma_sync(q,&q->read_buf->dma);
if (STATE_ERROR == q->read_buf->state) {
/* catch I/O errors */
@@ -887,10 +1004,12 @@ int videobuf_read_start(struct videobuf_queue *q)
return err;
list_add_tail(&q->bufs[i]->stream, &q->stream);
}
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
for (i = 0; i < count; i++)
q->ops->buf_queue(q,q->bufs[i]);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->reading = 1;
return 0;
}
@@ -985,9 +1104,11 @@ ssize_t videobuf_read_stream(struct videobuf_queue *q,
if (q->read_off == q->read_buf->size) {
list_add_tail(&q->read_buf->stream,
&q->stream);
- spin_lock_irqsave(q->irqlock,flags);
+ if (q->irqlock)
+ spin_lock_irqsave(q->irqlock,flags);
q->ops->buf_queue(q,q->read_buf);
- spin_unlock_irqrestore(q->irqlock,flags);
+ if (q->irqlock)
+ spin_unlock_irqrestore(q->irqlock,flags);
q->read_buf = NULL;
}
if (retval < 0)
@@ -1249,11 +1370,14 @@ EXPORT_SYMBOL_GPL(videobuf_dma_init);
EXPORT_SYMBOL_GPL(videobuf_dma_init_user);
EXPORT_SYMBOL_GPL(videobuf_dma_init_kernel);
EXPORT_SYMBOL_GPL(videobuf_dma_init_overlay);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_map);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_sync);
-EXPORT_SYMBOL_GPL(videobuf_dma_pci_unmap);
+EXPORT_SYMBOL_GPL(videobuf_dma_map);
+EXPORT_SYMBOL_GPL(videobuf_dma_sync);
+EXPORT_SYMBOL_GPL(videobuf_dma_unmap);
EXPORT_SYMBOL_GPL(videobuf_dma_free);
+EXPORT_SYMBOL_GPL(videobuf_pci_dma_map);
+EXPORT_SYMBOL_GPL(videobuf_pci_dma_unmap);
+
EXPORT_SYMBOL_GPL(videobuf_alloc);
EXPORT_SYMBOL_GPL(videobuf_waiton);
EXPORT_SYMBOL_GPL(videobuf_iolock);
diff --git a/drivers/media/video/videocodec.h b/drivers/media/video/videocodec.h
index b1239ac7f37..8c233720b6a 100644
--- a/drivers/media/video/videocodec.h
+++ b/drivers/media/video/videocodec.h
@@ -57,7 +57,7 @@
therfor they may not be initialized.
The other fuctions are just for convenience, as they are for sure used by
- most/all of the codecs. The last ones may be ommited, too.
+ most/all of the codecs. The last ones may be ommited, too.
See the structure declaration below for more information and which data has
to be set up for the master and the slave.
@@ -75,52 +75,52 @@
/* ========================================== */
/*
- ==== master setup ====
+ ==== master setup ====
name -> name of the device structure for reference and debugging
master_data -> data ref. for the master (e.g. the zr36055,57,67)
readreg -> ref. to read-fn from register (setup by master, used by slave)
writereg -> ref. to write-fn to register (setup by master, used by slave)
- this two functions do the lowlevel I/O job
+ this two functions do the lowlevel I/O job
- ==== slave functionality setup ====
- slave_data -> data ref. for the slave (e.g. the zr36050,60)
+ ==== slave functionality setup ====
+ slave_data -> data ref. for the slave (e.g. the zr36050,60)
check -> fn-ref. checks availability of an device, returns -EIO on failure or
- the type on success
- this makes espcecially sense if a driver module supports more than
- one codec which may be quite similar to access, nevertheless it
- is good for a first functionality check
+ the type on success
+ this makes espcecially sense if a driver module supports more than
+ one codec which may be quite similar to access, nevertheless it
+ is good for a first functionality check
- -- main functions you always need for compression/decompression --
+ -- main functions you always need for compression/decompression --
set_mode -> this fn-ref. resets the entire codec, and sets up the mode
- with the last defined norm/size (or device default if not
- available) - it returns 0 if the mode is possible
+ with the last defined norm/size (or device default if not
+ available) - it returns 0 if the mode is possible
set_size -> this fn-ref. sets the norm and image size for
- compression/decompression (returns 0 on success)
- the norm param is defined in videodev.h (VIDEO_MODE_*)
+ compression/decompression (returns 0 on success)
+ the norm param is defined in videodev.h (VIDEO_MODE_*)
additional setup may be available, too - but the codec should work with
- some default values even without this
+ some default values even without this
- set_data -> sets device-specific data (tables, quality etc.)
- get_data -> query device-specific data (tables, quality etc.)
+ set_data -> sets device-specific data (tables, quality etc.)
+ get_data -> query device-specific data (tables, quality etc.)
- if the device delivers interrupts, they may be setup/handled here
- setup_interrupt -> codec irq setup (not needed for 36050/60)
- handle_interrupt -> codec irq handling (not needed for 36050/60)
+ if the device delivers interrupts, they may be setup/handled here
+ setup_interrupt -> codec irq setup (not needed for 36050/60)
+ handle_interrupt -> codec irq handling (not needed for 36050/60)
- if the device delivers pictures, they may be handled here
- put_image -> puts image data to the codec (not needed for 36050/60)
- get_image -> gets image data from the codec (not needed for 36050/60)
- the calls include frame numbers and flags (even/odd/...)
- if needed and a flag which allows blocking until its ready
+ if the device delivers pictures, they may be handled here
+ put_image -> puts image data to the codec (not needed for 36050/60)
+ get_image -> gets image data from the codec (not needed for 36050/60)
+ the calls include frame numbers and flags (even/odd/...)
+ if needed and a flag which allows blocking until its ready
*/
/* ============== */
/* user interface */
/* ============== */
-/*
+/*
Currently there is only a information display planned, as the layer
is not visible for the user space at all.
diff --git a/drivers/media/video/vino.c b/drivers/media/video/vino.c
index 0229819d0aa..a8c101494cf 100644
--- a/drivers/media/video/vino.c
+++ b/drivers/media/video/vino.c
@@ -1555,12 +1555,12 @@ static void vino_update_line_size(struct vino_channel_settings *vcs)
unsigned int w = vcs->clipping.right - vcs->clipping.left;
unsigned int d = vcs->decimation;
unsigned int bpp = vino_data_formats[vcs->data_format].bpp;
- unsigned int lsize;
+ unsigned int lsize;
dprintk("update_line_size(): before: w = %d, d = %d, "
"line_size = %d\n", w, d, vcs->line_size);
- /* line size must be multiple of 8 bytes */
+ /* line size must be multiple of 8 bytes */
lsize = (bpp * (w / d)) & ~7;
w = (lsize / bpp) * d;
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c
new file mode 100644
index 00000000000..5e813404d06
--- /dev/null
+++ b/drivers/media/video/vivi.c
@@ -0,0 +1,1454 @@
+/*
+ * Virtual Video driver - This code emulates a real video device with v4l2 api
+ *
+ * Copyright (c) 2006 by:
+ * Mauro Carvalho Chehab <mchehab--a.t--infradead.org>
+ * Ted Walther <ted--a.t--enumera.com>
+ * John Sokol <sokol--a.t--videotechnology.com>
+ * http://v4l.videotechnology.com/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the BSD Licence, GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version
+ */
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/mm.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/sched.h>
+#include <linux/pci.h>
+#include <linux/random.h>
+#include <linux/version.h>
+#include <linux/videodev2.h>
+#include <linux/interrupt.h>
+#include <media/video-buf.h>
+#include <media/v4l2-common.h>
+#include <linux/kthread.h>
+#include <linux/highmem.h>
+
+/* Wake up at about 30 fps */
+#define WAKE_NUMERATOR 30
+#define WAKE_DENOMINATOR 1001
+#define BUFFER_TIMEOUT msecs_to_jiffies(500) /* 0.5 seconds */
+
+/* These timers are for 1 fps - used only for testing */
+//#define WAKE_DENOMINATOR 30 /* hack for testing purposes */
+//#define BUFFER_TIMEOUT msecs_to_jiffies(5000) /* 5 seconds */
+
+#include "font.h"
+
+#ifndef kzalloc
+#define kzalloc(size, flags) \
+({ \
+ void *__ret = kmalloc(size, flags); \
+ if (__ret) \
+ memset(__ret, 0, size); \
+ __ret; \
+})
+#endif
+
+MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board");
+MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
+MODULE_LICENSE("Dual BSD/GPL");
+
+#define VIVI_MAJOR_VERSION 0
+#define VIVI_MINOR_VERSION 4
+#define VIVI_RELEASE 0
+#define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE)
+
+static int video_nr = -1; /* /dev/videoN, -1 for autodetect */
+module_param(video_nr, int, 0);
+
+static int debug = 0;
+module_param(debug, int, 0);
+
+static unsigned int vid_limit = 16;
+module_param(vid_limit,int,0644);
+MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes");
+
+/* supported controls */
+static struct v4l2_queryctrl vivi_qctrl[] = {
+ {
+ .id = V4L2_CID_AUDIO_VOLUME,
+ .name = "Volume",
+ .minimum = 0,
+ .maximum = 65535,
+ .step = 65535/100,
+ .default_value = 65535,
+ .flags = 0,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ },{
+ .id = V4L2_CID_BRIGHTNESS,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Brightness",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 1,
+ .default_value = 127,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_CONTRAST,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Contrast",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 0x1,
+ .default_value = 0x10,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_SATURATION,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Saturation",
+ .minimum = 0,
+ .maximum = 255,
+ .step = 0x1,
+ .default_value = 127,
+ .flags = 0,
+ }, {
+ .id = V4L2_CID_HUE,
+ .type = V4L2_CTRL_TYPE_INTEGER,
+ .name = "Hue",
+ .minimum = -128,
+ .maximum = 127,
+ .step = 0x1,
+ .default_value = 0,
+ .flags = 0,
+ }
+};
+
+static int qctl_regs[ARRAY_SIZE(vivi_qctrl)];
+
+#define dprintk(level,fmt, arg...) \
+ do { \
+ if (debug >= (level)) \
+ printk(KERN_DEBUG "vivi: " fmt , ## arg); \
+ } while (0)
+
+/* ------------------------------------------------------------------
+ Basic structures
+ ------------------------------------------------------------------*/
+
+struct vivi_fmt {
+ char *name;
+ u32 fourcc; /* v4l2 format id */
+ int depth;
+};
+
+static struct vivi_fmt format = {
+ .name = "4:2:2, packed, YUYV",
+ .fourcc = V4L2_PIX_FMT_YUYV,
+ .depth = 16,
+};
+
+struct sg_to_addr {
+ int pos;
+ struct scatterlist *sg;
+};
+
+/* buffer for one video frame */
+struct vivi_buffer {
+ /* common v4l buffer stuff -- must be first */
+ struct videobuf_buffer vb;
+
+ struct vivi_fmt *fmt;
+
+ struct sg_to_addr *to_addr;
+};
+
+struct vivi_dmaqueue {
+ struct list_head active;
+ struct list_head queued;
+ struct timer_list timeout;
+
+ /* thread for generating video stream*/
+ struct task_struct *kthread;
+ wait_queue_head_t wq;
+ /* Counters to control fps rate */
+ int frame;
+ int ini_jiffies;
+};
+
+static LIST_HEAD(vivi_devlist);
+
+struct vivi_dev {
+ struct list_head vivi_devlist;
+
+ struct semaphore lock;
+
+ int users;
+
+ /* various device info */
+ unsigned int resources;
+ struct video_device video_dev;
+
+ struct vivi_dmaqueue vidq;
+
+ /* Several counters */
+ int h,m,s,us,jiffies;
+ char timestr[13];
+};
+
+struct vivi_fh {
+ struct vivi_dev *dev;
+
+ /* video capture */
+ struct vivi_fmt *fmt;
+ unsigned int width,height;
+ struct videobuf_queue vb_vidq;
+
+ enum v4l2_buf_type type;
+};
+
+/* ------------------------------------------------------------------
+ DMA and thread functions
+ ------------------------------------------------------------------*/
+
+/* Bars and Colors should match positions */
+
+enum colors {
+ WHITE,
+ AMBAR,
+ CYAN,
+ GREEN,
+ MAGENTA,
+ RED,
+ BLUE
+};
+
+static u8 bars[8][3] = {
+ /* R G B */
+ {204,204,204}, /* white */
+ {208,208, 0}, /* ambar */
+ { 0,206,206}, /* cyan */
+ { 0,239, 0}, /* green */
+ {239, 0,239}, /* magenta */
+ {205, 0, 0}, /* red */
+ { 0, 0,255}, /* blue */
+ { 0, 0, 0}
+};
+
+#define TO_Y(r,g,b) (((16829*r +33039*g +6416*b + 32768)>>16)+16)
+/* RGB to V(Cr) Color transform */
+#define TO_V(r,g,b) (((28784*r -24103*g -4681*b + 32768)>>16)+128)
+/* RGB to U(Cb) Color transform */
+#define TO_U(r,g,b) (((-9714*r -19070*g +28784*b + 32768)>>16)+128)
+
+#define TSTAMP_MIN_Y 24
+#define TSTAMP_MAX_Y TSTAMP_MIN_Y+15
+#define TSTAMP_MIN_X 64
+
+void prep_to_addr(struct sg_to_addr to_addr[],struct videobuf_buffer *vb)
+{
+ int i, pos=0;
+
+ for (i=0;i<vb->dma.nr_pages;i++) {
+ to_addr[i].sg=&vb->dma.sglist[i];
+ to_addr[i].pos=pos;
+ pos += vb->dma.sglist[i].length;
+ }
+}
+
+inline int get_addr_pos(int pos, int pages, struct sg_to_addr to_addr[])
+{
+ int p1=0,p2=pages-1,p3=pages/2;
+
+ /* Sanity test */
+ BUG_ON (pos>=to_addr[p2].pos+to_addr[p2].sg->length);
+
+ while (p1+1<p2) {
+ if (pos < to_addr[p3].pos) {
+ p2=p3;
+ } else {
+ p1=p3;
+ }
+ p3=(p1+p2)/2;
+ }
+ if (pos >= to_addr[p2].pos)
+ p1=p2;
+
+ return (p1);
+}
+
+void gen_line(struct sg_to_addr to_addr[],int inipos,int pages,int wmax,
+ int hmax, int line, char *timestr)
+{
+ int w,i,j,pos=inipos,pgpos,oldpg,y;
+ char *p,*s,*basep;
+ struct page *pg;
+ u8 chr,r,g,b,color;
+
+ /* Get first addr pointed to pixel position */
+ oldpg=get_addr_pos(pos,pages,to_addr);
+ pg=pfn_to_page(to_addr[oldpg].sg->dma_address >> PAGE_SHIFT);
+ basep = kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[oldpg].sg->offset;
+
+ /* We will just duplicate the second pixel at the packet */
+ wmax/=2;
+
+ /* Generate a standard color bar pattern */
+ for (w=0;w<wmax;w++) {
+ r=bars[w*7/wmax][0];
+ g=bars[w*7/wmax][1];
+ b=bars[w*7/wmax][2];
+
+ for (color=0;color<4;color++) {
+ pgpos=get_addr_pos(pos,pages,to_addr);
+ if (pgpos!=oldpg) {
+ pg=pfn_to_page(to_addr[pgpos].sg->dma_address >> PAGE_SHIFT);
+ kunmap_atomic(basep, KM_BOUNCE_READ);
+ basep= kmap_atomic(pg, KM_BOUNCE_READ)+to_addr[pgpos].sg->offset;
+ oldpg=pgpos;
+ }
+ p=basep+pos-to_addr[pgpos].pos;
+
+ switch (color) {
+ case 0:
+ case 2:
+ *p=TO_Y(r,g,b); /* Luminance */
+ break;
+ case 1:
+ *p=TO_U(r,g,b); /* Cb */
+ break;
+ case 3:
+ *p=TO_V(r,g,b); /* Cr */
+ break;
+ }
+ pos++;
+ }
+ }
+
+ /* Checks if it is possible to show timestamp */
+ if (TSTAMP_MAX_Y>=hmax)
+ goto end;
+ if (TSTAMP_MIN_X+strlen(timestr)>=wmax)
+ goto end;
+
+ /* Print stream time */
+ if (line>=TSTAMP_MIN_Y && line<=TSTAMP_MAX_Y) {
+ j=TSTAMP_MIN_X;
+ for (s=timestr;*s;s++) {
+ chr=rom8x16_bits[(*s-0x30)*16+line-TSTAMP_MIN_Y];
+ for (i=0;i<7;i++) {
+ if (chr&1<<(7-i)) { /* Font color*/
+ r=bars[BLUE][0];
+ g=bars[BLUE][1];
+ b=bars[BLUE][2];
+ r=g=b=0;
+ g=198;
+ } else { /* Background color */
+ r=bars[WHITE][0];
+ g=bars[WHITE][1];
+ b=bars[WHITE][2];
+ r=g=b=0;
+ }
+
+ pos=inipos+j*2;
+ for (color=0;color<4;color++) {
+ pgpos=get_addr_pos(pos,pages,to_addr);
+ if (pgpos!=oldpg) {
+ pg=pfn_to_page(to_addr[pgpos].
+ sg->dma_address
+ >> PAGE_SHIFT);
+ kunmap_atomic(basep,
+ KM_BOUNCE_READ);
+ basep= kmap_atomic(pg,
+ KM_BOUNCE_READ)+
+ to_addr[pgpos].sg->offset;
+ oldpg=pgpos;
+ }
+ p=basep+pos-to_addr[pgpos].pos;
+
+ y=TO_Y(r,g,b);
+
+ switch (color) {
+ case 0:
+ case 2:
+ *p=TO_Y(r,g,b); /* Luminance */
+ break;
+ case 1:
+ *p=TO_U(r,g,b); /* Cb */
+ break;
+ case 3:
+ *p=TO_V(r,g,b); /* Cr */
+ break;
+ }
+ pos++;
+ }
+ j++;
+ }
+ }
+ }
+
+
+end:
+ kunmap_atomic(basep, KM_BOUNCE_READ);
+}
+static void vivi_fillbuff(struct vivi_dev *dev,struct vivi_buffer *buf)
+{
+ int h,pos=0;
+ int hmax = buf->vb.height;
+ int wmax = buf->vb.width;
+ struct videobuf_buffer *vb=&buf->vb;
+ struct sg_to_addr *to_addr=buf->to_addr;
+ struct timeval ts;
+
+ /* Test if DMA mapping is ready */
+ if (!vb->dma.sglist[0].dma_address)
+ return;
+
+ prep_to_addr(to_addr,vb);
+
+ /* Check if there is enough memory */
+ BUG_ON(buf->vb.dma.nr_pages << PAGE_SHIFT < (buf->vb.width*buf->vb.height)*2);
+
+ for (h=0;h<hmax;h++) {
+ gen_line(to_addr,pos,vb->dma.nr_pages,wmax,hmax,h,dev->timestr);
+ pos += wmax*2;
+ }
+
+ /* Updates stream time */
+
+ dev->us+=jiffies_to_usecs(jiffies-dev->jiffies);
+ dev->jiffies=jiffies;
+ if (dev->us>=1000000) {
+ dev->us-=1000000;
+ dev->s++;
+ if (dev->s>=60) {
+ dev->s-=60;
+ dev->m++;
+ if (dev->m>60) {
+ dev->m-=60;
+ dev->h++;
+ if (dev->h>24)
+ dev->h-=24;
+ }
+ }
+ }
+ sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
+ dev->h,dev->m,dev->s,(dev->us+500)/1000);
+
+ dprintk(2,"vivifill at %s: Buffer 0x%08lx size= %d\n",dev->timestr,
+ (unsigned long)buf->vb.dma.vmalloc,pos);
+
+ /* Advice that buffer was filled */
+ buf->vb.state = STATE_DONE;
+ buf->vb.field_count++;
+ do_gettimeofday(&ts);
+ buf->vb.ts = ts;
+
+ list_del(&buf->vb.queue);
+ wake_up(&buf->vb.done);
+}
+
+static int restart_video_queue(struct vivi_dmaqueue *dma_q);
+
+static void vivi_thread_tick(struct vivi_dmaqueue *dma_q)
+{
+ struct vivi_buffer *buf;
+ struct vivi_dev *dev= container_of(dma_q,struct vivi_dev,vidq);
+
+ int bc;
+
+ /* Announces videobuf that all went ok */
+ for (bc = 0;; bc++) {
+ if (list_empty(&dma_q->active)) {
+ dprintk(1,"No active queue to serve\n");
+ break;
+ }
+
+ buf = list_entry(dma_q->active.next,
+ struct vivi_buffer, vb.queue);
+
+ /* Nobody is waiting something to be done, just return */
+ if (!waitqueue_active(&buf->vb.done)) {
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ return;
+ }
+
+ do_gettimeofday(&buf->vb.ts);
+ dprintk(2,"[%p/%d] wakeup\n",buf,buf->vb.i);
+
+ /* Fill buffer */
+ vivi_fillbuff(dev,buf);
+ }
+ if (list_empty(&dma_q->active)) {
+ del_timer(&dma_q->timeout);
+ } else {
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ }
+ if (bc != 1)
+ dprintk(1,"%s: %d buffers handled (should be 1)\n",__FUNCTION__,bc);
+}
+
+void vivi_sleep(struct vivi_dmaqueue *dma_q)
+{
+ int timeout;
+ DECLARE_WAITQUEUE(wait, current);
+
+ dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+
+ add_wait_queue(&dma_q->wq, &wait);
+ if (!kthread_should_stop()) {
+ dma_q->frame++;
+
+ /* Calculate time to wake up */
+ timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
+
+ if (timeout <= 0) {
+ int old=dma_q->frame;
+ dma_q->frame=(jiffies_to_msecs(jiffies-dma_q->ini_jiffies)*WAKE_DENOMINATOR)/(WAKE_NUMERATOR*1000)+1;
+
+ timeout=dma_q->ini_jiffies+msecs_to_jiffies((dma_q->frame*WAKE_NUMERATOR*1000)/WAKE_DENOMINATOR)-jiffies;
+
+ dprintk(1,"underrun, losed %d frames. "
+ "Now, frame is %d. Waking on %d jiffies\n",
+ dma_q->frame-old,dma_q->frame,timeout);
+ } else
+ dprintk(1,"will sleep for %i jiffies\n",timeout);
+
+ vivi_thread_tick(dma_q);
+
+ schedule_timeout_interruptible (timeout);
+ }
+
+ remove_wait_queue(&dma_q->wq, &wait);
+ try_to_freeze();
+}
+
+int vivi_thread(void *data)
+{
+ struct vivi_dmaqueue *dma_q=data;
+
+ dprintk(1,"thread started\n");
+
+ for (;;) {
+ vivi_sleep(dma_q);
+
+ if (kthread_should_stop())
+ break;
+ }
+ dprintk(1, "thread: exit\n");
+ return 0;
+}
+
+int vivi_start_thread(struct vivi_dmaqueue *dma_q)
+{
+ dma_q->frame=0;
+ dma_q->ini_jiffies=jiffies;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+ init_waitqueue_head(&dma_q->wq);
+
+ dma_q->kthread = kthread_run(vivi_thread, dma_q, "vivi");
+
+ if (dma_q->kthread == NULL) {
+ printk(KERN_ERR "vivi: kernel_thread() failed\n");
+ return -EINVAL;
+ }
+ dprintk(1,"returning from %s\n",__FUNCTION__);
+ return 0;
+}
+
+void vivi_stop_thread(struct vivi_dmaqueue *dma_q)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+ /* shutdown control thread */
+ if (dma_q->kthread) {
+ kthread_stop(dma_q->kthread);
+ dma_q->kthread=NULL;
+ }
+}
+
+static int restart_video_queue(struct vivi_dmaqueue *dma_q)
+{
+ struct vivi_buffer *buf, *prev;
+ struct list_head *item;
+
+ dprintk(1,"%s dma_q=0x%08lx\n",__FUNCTION__,(unsigned long)dma_q);
+
+ if (!list_empty(&dma_q->active)) {
+ buf = list_entry(dma_q->active.next, struct vivi_buffer, vb.queue);
+ dprintk(2,"restart_queue [%p/%d]: restart dma\n",
+ buf, buf->vb.i);
+
+ dprintk(1,"Restarting video dma\n");
+ vivi_stop_thread(dma_q);
+// vivi_start_thread(dma_q);
+
+ /* cancel all outstanding capture / vbi requests */
+ list_for_each(item,&dma_q->active) {
+ buf = list_entry(item, struct vivi_buffer, vb.queue);
+
+ list_del(&buf->vb.queue);
+ buf->vb.state = STATE_ERROR;
+ wake_up(&buf->vb.done);
+ }
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+
+ return 0;
+ }
+
+ prev = NULL;
+ for (;;) {
+ if (list_empty(&dma_q->queued))
+ return 0;
+ buf = list_entry(dma_q->queued.next, struct vivi_buffer, vb.queue);
+ if (NULL == prev) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&dma_q->active);
+
+ dprintk(1,"Restarting video dma\n");
+ vivi_stop_thread(dma_q);
+ vivi_start_thread(dma_q);
+
+ buf->vb.state = STATE_ACTIVE;
+ mod_timer(&dma_q->timeout, jiffies+BUFFER_TIMEOUT);
+ dprintk(2,"[%p/%d] restart_queue - first active\n",
+ buf,buf->vb.i);
+
+ } else if (prev->vb.width == buf->vb.width &&
+ prev->vb.height == buf->vb.height &&
+ prev->fmt == buf->fmt) {
+ list_del(&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&dma_q->active);
+ buf->vb.state = STATE_ACTIVE;
+ dprintk(2,"[%p/%d] restart_queue - move to active\n",
+ buf,buf->vb.i);
+ } else {
+ return 0;
+ }
+ prev = buf;
+ }
+}
+
+static void vivi_vid_timeout(unsigned long data)
+{
+ struct vivi_dev *dev = (struct vivi_dev*)data;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+ struct vivi_buffer *buf;
+
+ while (!list_empty(&vidq->active)) {
+ buf = list_entry(vidq->active.next, struct vivi_buffer, vb.queue);
+ list_del(&buf->vb.queue);
+ buf->vb.state = STATE_ERROR;
+ wake_up(&buf->vb.done);
+ printk("vivi/0: [%p/%d] timeout\n", buf, buf->vb.i);
+ }
+
+ restart_video_queue(vidq);
+}
+
+/* ------------------------------------------------------------------
+ Videobuf operations
+ ------------------------------------------------------------------*/
+static int
+buffer_setup(struct videobuf_queue *vq, unsigned int *count, unsigned int *size)
+{
+ struct vivi_fh *fh = vq->priv_data;
+
+ *size = fh->width*fh->height*2;
+
+ if (0 == *count)
+ *count = 32;
+ while (*size * *count > vid_limit * 1024 * 1024)
+ (*count)--;
+ return 0;
+}
+
+void
+free_buffer(struct videobuf_queue *vq, struct vivi_buffer *buf)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ if (in_interrupt())
+ BUG();
+
+ /*FIXME: Maybe a spinlock is required here */
+ kfree(buf->to_addr);
+ buf->to_addr=NULL;
+
+ videobuf_waiton(&buf->vb,0,0);
+ videobuf_dma_unmap(vq, &buf->vb.dma);
+ videobuf_dma_free(&buf->vb.dma);
+ buf->vb.state = STATE_NEEDS_INIT;
+}
+
+#define norm_maxw() 1024
+#define norm_maxh() 768
+static int
+buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb,
+ enum v4l2_field field)
+{
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ int rc, init_buffer = 0;
+
+// dprintk(1,"%s, field=%d\n",__FUNCTION__,field);
+
+ BUG_ON(NULL == fh->fmt);
+ if (fh->width < 48 || fh->width > norm_maxw() ||
+ fh->height < 32 || fh->height > norm_maxh())
+ return -EINVAL;
+ buf->vb.size = fh->width*fh->height*2;
+ if (0 != buf->vb.baddr && buf->vb.bsize < buf->vb.size)
+ return -EINVAL;
+
+ if (buf->fmt != fh->fmt ||
+ buf->vb.width != fh->width ||
+ buf->vb.height != fh->height ||
+ buf->vb.field != field) {
+ buf->fmt = fh->fmt;
+ buf->vb.width = fh->width;
+ buf->vb.height = fh->height;
+ buf->vb.field = field;
+ init_buffer = 1;
+ }
+
+ if (STATE_NEEDS_INIT == buf->vb.state) {
+ if (0 != (rc = videobuf_iolock(vq,&buf->vb,NULL)))
+ goto fail;
+ }
+
+ buf->vb.state = STATE_PREPARED;
+
+ if (NULL == (buf->to_addr = kmalloc(sizeof(*buf->to_addr) * vb->dma.nr_pages,GFP_KERNEL))) {
+ rc=-ENOMEM;
+ goto fail;
+ }
+
+ return 0;
+
+fail:
+ free_buffer(vq,buf);
+ return rc;
+}
+
+static void
+buffer_queue(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+{
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_dev *dev = fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+ struct vivi_buffer *prev;
+
+ if (!list_empty(&vidq->queued)) {
+ dprintk(1,"adding vb queue=0x%08lx\n",(unsigned long)&buf->vb.queue);
+ list_add_tail(&buf->vb.queue,&vidq->queued);
+ buf->vb.state = STATE_QUEUED;
+ dprintk(2,"[%p/%d] buffer_queue - append to queued\n",
+ buf, buf->vb.i);
+ } else if (list_empty(&vidq->active)) {
+ list_add_tail(&buf->vb.queue,&vidq->active);
+
+ buf->vb.state = STATE_ACTIVE;
+ mod_timer(&vidq->timeout, jiffies+BUFFER_TIMEOUT);
+ dprintk(2,"[%p/%d] buffer_queue - first active\n",
+ buf, buf->vb.i);
+
+ vivi_start_thread(vidq);
+ } else {
+ prev = list_entry(vidq->active.prev, struct vivi_buffer, vb.queue);
+ if (prev->vb.width == buf->vb.width &&
+ prev->vb.height == buf->vb.height &&
+ prev->fmt == buf->fmt) {
+ list_add_tail(&buf->vb.queue,&vidq->active);
+ buf->vb.state = STATE_ACTIVE;
+ dprintk(2,"[%p/%d] buffer_queue - append to active\n",
+ buf, buf->vb.i);
+
+ } else {
+ list_add_tail(&buf->vb.queue,&vidq->queued);
+ buf->vb.state = STATE_QUEUED;
+ dprintk(2,"[%p/%d] buffer_queue - first queued\n",
+ buf, buf->vb.i);
+ }
+ }
+}
+
+static void buffer_release(struct videobuf_queue *vq, struct videobuf_buffer *vb)
+{
+ struct vivi_buffer *buf = container_of(vb,struct vivi_buffer,vb);
+ struct vivi_fh *fh = vq->priv_data;
+ struct vivi_dev *dev = (struct vivi_dev*)fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ vivi_stop_thread(vidq);
+
+ free_buffer(vq,buf);
+}
+
+int vivi_map_sg (void *dev, struct scatterlist *sg, int nents,
+ int direction)
+{
+ int i;
+
+ dprintk(1,"%s, number of pages=%d\n",__FUNCTION__,nents);
+ BUG_ON(direction == DMA_NONE);
+
+ for (i = 0; i < nents; i++ ) {
+ BUG_ON(!sg[i].page);
+
+ sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset;
+ }
+
+ return nents;
+}
+
+int vivi_unmap_sg(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction)
+{
+ dprintk(1,"%s\n",__FUNCTION__);
+ return 0;
+}
+
+int vivi_dma_sync_sg(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction)
+{
+// dprintk(1,"%s\n",__FUNCTION__);
+
+// flush_write_buffers();
+ return 0;
+}
+
+static struct videobuf_queue_ops vivi_video_qops = {
+ .buf_setup = buffer_setup,
+ .buf_prepare = buffer_prepare,
+ .buf_queue = buffer_queue,
+ .buf_release = buffer_release,
+
+ /* Non-pci handling routines */
+ .vb_map_sg = vivi_map_sg,
+ .vb_dma_sync_sg = vivi_dma_sync_sg,
+ .vb_unmap_sg = vivi_unmap_sg,
+};
+
+/* ------------------------------------------------------------------
+ IOCTL handling
+ ------------------------------------------------------------------*/
+
+static int vivi_try_fmt(struct vivi_dev *dev, struct vivi_fh *fh,
+ struct v4l2_format *f)
+{
+ struct vivi_fmt *fmt;
+ enum v4l2_field field;
+ unsigned int maxw, maxh;
+
+ if (format.fourcc != f->fmt.pix.pixelformat) {
+ dprintk(1,"Fourcc format invalid.\n");
+ return -EINVAL;
+ }
+ fmt=&format;
+
+ field = f->fmt.pix.field;
+
+ if (field == V4L2_FIELD_ANY) {
+// field=V4L2_FIELD_INTERLACED;
+ field=V4L2_FIELD_SEQ_TB;
+ } else if (V4L2_FIELD_INTERLACED != field) {
+ dprintk(1,"Field type invalid.\n");
+ return -EINVAL;
+ }
+
+ maxw = norm_maxw();
+ maxh = norm_maxh();
+
+ f->fmt.pix.field = field;
+ if (f->fmt.pix.height < 32)
+ f->fmt.pix.height = 32;
+ if (f->fmt.pix.height > maxh)
+ f->fmt.pix.height = maxh;
+ if (f->fmt.pix.width < 48)
+ f->fmt.pix.width = 48;
+ if (f->fmt.pix.width > maxw)
+ f->fmt.pix.width = maxw;
+ f->fmt.pix.width &= ~0x03;
+ f->fmt.pix.bytesperline =
+ (f->fmt.pix.width * fmt->depth) >> 3;
+ f->fmt.pix.sizeimage =
+ f->fmt.pix.height * f->fmt.pix.bytesperline;
+
+ return 0;
+}
+
+static int res_get(struct vivi_dev *dev, struct vivi_fh *fh)
+{
+ /* is it free? */
+ down(&dev->lock);
+ if (dev->resources) {
+ /* no, someone else uses it */
+ up(&dev->lock);
+ return 0;
+ }
+ /* it's free, grab it */
+ dev->resources =1;
+ dprintk(1,"res: get\n");
+ up(&dev->lock);
+ return 1;
+}
+
+static inline int res_locked(struct vivi_dev *dev)
+{
+ return (dev->resources);
+}
+
+static void res_free(struct vivi_dev *dev, struct vivi_fh *fh)
+{
+ down(&dev->lock);
+ dev->resources = 0;
+ dprintk(1,"res: put\n");
+ up(&dev->lock);
+}
+
+static int vivi_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_dev *dev = fh->dev;
+ int ret=0;
+
+ if (debug) {
+ if (_IOC_DIR(cmd) & _IOC_WRITE)
+ v4l_printk_ioctl_arg("vivi(w)",cmd, arg);
+ else if (!_IOC_DIR(cmd) & _IOC_READ) {
+ v4l_print_ioctl("vivi", cmd);
+ }
+ }
+
+ switch(cmd) {
+ /* --- capabilities ------------------------------------------ */
+ case VIDIOC_QUERYCAP:
+ {
+ struct v4l2_capability *cap = (struct v4l2_capability*)arg;
+
+ memset(cap, 0, sizeof(*cap));
+
+ strcpy(cap->driver, "vivi");
+ strcpy(cap->card, "vivi");
+ cap->version = VIVI_VERSION;
+ cap->capabilities =
+ V4L2_CAP_VIDEO_CAPTURE |
+ V4L2_CAP_STREAMING |
+ V4L2_CAP_READWRITE;
+ break;
+ }
+ /* --- capture ioctls ---------------------------------------- */
+ case VIDIOC_ENUM_FMT:
+ {
+ struct v4l2_fmtdesc *f = arg;
+ enum v4l2_buf_type type;
+ unsigned int index;
+
+ index = f->index;
+ type = f->type;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ switch (type) {
+ case V4L2_BUF_TYPE_VIDEO_CAPTURE:
+ if (index > 0){
+ ret=-EINVAL;
+ break;
+ }
+ memset(f,0,sizeof(*f));
+
+ f->index = index;
+ f->type = type;
+ strlcpy(f->description,format.name,sizeof(f->description));
+ f->pixelformat = format.fourcc;
+ break;
+ default:
+ ret=-EINVAL;
+ }
+ break;
+ }
+ case VIDIOC_G_FMT:
+ {
+ struct v4l2_format *f = (struct v4l2_format *)arg;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ memset(&f->fmt.pix,0,sizeof(f->fmt.pix));
+ f->fmt.pix.width = fh->width;
+ f->fmt.pix.height = fh->height;
+ f->fmt.pix.field = fh->vb_vidq.field;
+ f->fmt.pix.pixelformat = fh->fmt->fourcc;
+ f->fmt.pix.bytesperline =
+ (f->fmt.pix.width * fh->fmt->depth) >> 3;
+ f->fmt.pix.sizeimage =
+ f->fmt.pix.height * f->fmt.pix.bytesperline;
+ break;
+ }
+ case VIDIOC_S_FMT:
+ {
+ struct v4l2_format *f = arg;
+
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ dprintk(1,"Only capture supported.\n");
+ ret=-EINVAL;
+ break;
+ }
+
+ ret = vivi_try_fmt(dev,fh,f);
+ if (ret < 0)
+ break;
+
+ fh->fmt = &format;
+ fh->width = f->fmt.pix.width;
+ fh->height = f->fmt.pix.height;
+ fh->vb_vidq.field = f->fmt.pix.field;
+ fh->type = f->type;
+
+ break;
+ }
+ case VIDIOC_TRY_FMT:
+ {
+ struct v4l2_format *f = arg;
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+
+ ret=vivi_try_fmt(dev,fh,f);
+ break;
+ }
+ case VIDIOC_REQBUFS:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_reqbufs(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_QUERYBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_querybuf(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_QBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_qbuf(&fh->vb_vidq, arg);
+ break;
+ case VIDIOC_DQBUF:
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret=videobuf_dqbuf(&fh->vb_vidq, arg,
+ file->f_flags & O_NONBLOCK);
+ break;
+#ifdef HAVE_V4L1
+ /* --- streaming capture ------------------------------------- */
+ case VIDIOCGMBUF:
+ {
+ struct video_mbuf *mbuf = arg;
+ struct videobuf_queue *q=&fh->vb_vidq;
+ struct v4l2_requestbuffers req;
+ unsigned int i;
+
+ memset(&req,0,sizeof(req));
+ req.type = q->type;
+ req.count = 8;
+ req.memory = V4L2_MEMORY_MMAP;
+ ret = videobuf_reqbufs(q,&req);
+ if (ret < 0)
+ break;
+ memset(mbuf,0,sizeof(*mbuf));
+ mbuf->frames = req.count;
+ mbuf->size = 0;
+ for (i = 0; i < mbuf->frames; i++) {
+ mbuf->offsets[i] = q->bufs[i]->boff;
+ mbuf->size += q->bufs[i]->bsize;
+ }
+ break;
+ }
+#endif
+ case VIDIOC_STREAMON:
+ {
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ return -EINVAL;
+ if (!res_get(dev,fh))
+ return -EBUSY;
+ ret=videobuf_streamon(&fh->vb_vidq);
+ break;
+ }
+ case VIDIOC_STREAMOFF:
+ {
+ if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ ret=-EINVAL;
+ break;
+ }
+ ret = videobuf_streamoff(&fh->vb_vidq);
+ if (ret < 0)
+ break;
+ res_free(dev,fh);
+ break;
+ }
+ /* ---------- tv norms ---------- */
+ case VIDIOC_ENUMSTD:
+ {
+ struct v4l2_standard *e = arg;
+
+ if (e->index>0) {
+ ret=-EINVAL;
+ break;
+ }
+ ret = v4l2_video_std_construct(e, V4L2_STD_NTSC_M, "NTSC-M");
+
+ /* Allows vivi to use different fps from video std */
+ e->frameperiod.numerator = WAKE_NUMERATOR;
+ e->frameperiod.denominator = WAKE_DENOMINATOR;
+
+ break;
+ }
+ case VIDIOC_G_STD:
+ {
+ v4l2_std_id *id = arg;
+
+ *id = V4L2_STD_NTSC_M;
+ break;
+ }
+ case VIDIOC_S_STD:
+ {
+ break;
+ }
+ /* ------ input switching ---------- */
+ case VIDIOC_ENUMINPUT:
+ { /* only one input in this sample driver */
+ struct v4l2_input *inp = arg;
+
+ if (inp->index != 0) {
+ ret=-EINVAL;
+ break;
+ }
+ memset(inp, 0, sizeof(*inp));
+
+ inp->index = 0;
+ inp->type = V4L2_INPUT_TYPE_CAMERA;
+ inp->std = V4L2_STD_NTSC_M;
+ strcpy(inp->name,"Camera");
+ break;
+ }
+ case VIDIOC_G_INPUT:
+ {
+ unsigned int *i = arg;
+
+ *i = 0;
+ break;
+ }
+ case VIDIOC_S_INPUT:
+ {
+ unsigned int *i = arg;
+
+ if (*i > 0)
+ ret=-EINVAL;
+ break;
+ }
+
+ /* --- controls ---------------------------------------------- */
+ case VIDIOC_QUERYCTRL:
+ {
+ struct v4l2_queryctrl *qc = arg;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (qc->id && qc->id == vivi_qctrl[i].id) {
+ memcpy(qc, &(vivi_qctrl[i]),
+ sizeof(*qc));
+ break;
+ }
+
+ ret=-EINVAL;
+ break;
+ }
+ case VIDIOC_G_CTRL:
+ {
+ struct v4l2_control *ctrl = arg;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (ctrl->id == vivi_qctrl[i].id) {
+ ctrl->value=qctl_regs[i];
+ break;
+ }
+
+ ret=-EINVAL;
+ break;
+ }
+ case VIDIOC_S_CTRL:
+ {
+ struct v4l2_control *ctrl = arg;
+ int i;
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ if (ctrl->id == vivi_qctrl[i].id) {
+ if (ctrl->value <
+ vivi_qctrl[i].minimum
+ || ctrl->value >
+ vivi_qctrl[i].maximum) {
+ ret=-ERANGE;
+ break;
+ }
+ qctl_regs[i]=ctrl->value;
+ break;
+ }
+ ret=-EINVAL;
+ break;
+ }
+ default:
+ ret=v4l_compat_translate_ioctl(inode,file,cmd,arg,vivi_do_ioctl);
+ }
+
+ if (debug) {
+ if (ret<0) {
+ v4l_print_ioctl("vivi(err)", cmd);
+ dprintk(1,"errcode=%d\n",ret);
+ } else if (_IOC_DIR(cmd) & _IOC_READ)
+ v4l_printk_ioctl_arg("vivi(r)",cmd, arg);
+ }
+
+ return ret;
+}
+
+static int vivi_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg)
+{
+ return video_usercopy(inode, file, cmd, arg, vivi_do_ioctl);
+}
+
+/* ------------------------------------------------------------------
+ File operations for the device
+ ------------------------------------------------------------------*/
+
+#define line_buf_size(norm) (norm_maxw(norm)*(format.depth+7)/8)
+
+static int vivi_open(struct inode *inode, struct file *file)
+{
+ int minor = iminor(inode);
+ struct vivi_dev *h,*dev = NULL;
+ struct vivi_fh *fh;
+ struct list_head *list;
+ enum v4l2_buf_type type = 0;
+ int i;
+
+ printk(KERN_DEBUG "vivi: open called (minor=%d)\n",minor);
+
+ list_for_each(list,&vivi_devlist) {
+ h = list_entry(list, struct vivi_dev, vivi_devlist);
+ if (h->video_dev.minor == minor) {
+ dev = h;
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ }
+ }
+ if (NULL == dev)
+ return -ENODEV;
+
+
+ /* If more than one user, mutex should be added */
+ dev->users++;
+
+ dprintk(1,"open minor=%d type=%s users=%d\n",
+ minor,v4l2_type_names[type],dev->users);
+
+ /* allocate + initialize per filehandle data */
+ fh = kzalloc(sizeof(*fh),GFP_KERNEL);
+ if (NULL == fh) {
+ dev->users--;
+ return -ENOMEM;
+ }
+
+ file->private_data = fh;
+ fh->dev = dev;
+ fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fh->fmt = &format;
+ fh->width = 640;
+ fh->height = 480;
+
+ /* Put all controls at a sane state */
+ for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++)
+ qctl_regs[i] =vivi_qctrl[i].default_value;
+
+ dprintk(1,"Open: fh=0x%08lx, dev=0x%08lx, dev->vidq=0x%08lx\n",
+ (unsigned long)fh,(unsigned long)dev,(unsigned long)&dev->vidq);
+ dprintk(1,"Open: list_empty queued=%d\n",list_empty(&dev->vidq.queued));
+ dprintk(1,"Open: list_empty active=%d\n",list_empty(&dev->vidq.active));
+
+ /* Resets frame counters */
+ dev->h=0;
+ dev->m=0;
+ dev->s=0;
+ dev->us=0;
+ dev->jiffies=jiffies;
+ sprintf(dev->timestr,"%02d:%02d:%02d:%03d",
+ dev->h,dev->m,dev->s,(dev->us+500)/1000);
+
+ videobuf_queue_init(&fh->vb_vidq, &vivi_video_qops,
+ NULL, NULL,
+ fh->type,
+ V4L2_FIELD_INTERLACED,
+ sizeof(struct vivi_buffer),fh);
+
+ return 0;
+}
+
+static ssize_t
+vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
+{
+ struct vivi_fh *fh = file->private_data;
+
+ if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ if (res_locked(fh->dev))
+ return -EBUSY;
+ return videobuf_read_one(&fh->vb_vidq, data, count, ppos,
+ file->f_flags & O_NONBLOCK);
+ }
+ return 0;
+}
+
+static unsigned int
+vivi_poll(struct file *file, struct poll_table_struct *wait)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_buffer *buf;
+
+ dprintk(1,"%s\n",__FUNCTION__);
+
+ if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type)
+ return POLLERR;
+
+ if (res_get(fh->dev,fh)) {
+ dprintk(1,"poll: mmap interface\n");
+ /* streaming capture */
+ if (list_empty(&fh->vb_vidq.stream))
+ return POLLERR;
+ buf = list_entry(fh->vb_vidq.stream.next,struct vivi_buffer,vb.stream);
+ } else {
+ dprintk(1,"poll: read() interface\n");
+ /* read() capture */
+ buf = (struct vivi_buffer*)fh->vb_vidq.read_buf;
+ if (NULL == buf)
+ return POLLERR;
+ }
+ poll_wait(file, &buf->vb.done, wait);
+ if (buf->vb.state == STATE_DONE ||
+ buf->vb.state == STATE_ERROR)
+ return POLLIN|POLLRDNORM;
+ return 0;
+}
+
+static int vivi_release(struct inode *inode, struct file *file)
+{
+ struct vivi_fh *fh = file->private_data;
+ struct vivi_dev *dev = fh->dev;
+ struct vivi_dmaqueue *vidq = &dev->vidq;
+
+ int minor = iminor(inode);
+
+ vivi_stop_thread(vidq);
+ videobuf_mmap_free(&fh->vb_vidq);
+
+ kfree (fh);
+
+ dev->users--;
+
+ printk(KERN_DEBUG "vivi: close called (minor=%d, users=%d)\n",minor,dev->users);
+
+ return 0;
+}
+
+static int
+vivi_mmap(struct file *file, struct vm_area_struct * vma)
+{
+ struct vivi_fh *fh = file->private_data;
+ int ret;
+
+ dprintk (1,"mmap called, vma=0x%08lx\n",(unsigned long)vma);
+
+ ret=videobuf_mmap_mapper(&fh->vb_vidq, vma);
+
+ dprintk (1,"vma start=0x%08lx, size=%ld, ret=%d\n",
+ (unsigned long)vma->vm_start,
+ (unsigned long)vma->vm_end-(unsigned long)vma->vm_start,
+ ret);
+
+ return ret;
+}
+
+static struct file_operations vivi_fops = {
+ .owner = THIS_MODULE,
+ .open = vivi_open,
+ .release = vivi_release,
+ .read = vivi_read,
+ .poll = vivi_poll,
+ .ioctl = vivi_ioctl,
+ .mmap = vivi_mmap,
+ .llseek = no_llseek,
+};
+
+static struct video_device vivi = {
+ .name = "VTM Virtual Video Capture Board",
+ .type = VID_TYPE_CAPTURE,
+ .hardware = 0,
+ .fops = &vivi_fops,
+ .minor = -1,
+// .release = video_device_release,
+};
+/* ------------------------------------------------------------------
+ Initialization and module stuff
+ ------------------------------------------------------------------*/
+
+static int __init vivi_init(void)
+{
+ int ret;
+ struct vivi_dev *dev;
+
+ dev = kzalloc(sizeof(*dev),GFP_KERNEL);
+ if (NULL == dev)
+ return -ENOMEM;
+ list_add_tail(&dev->vivi_devlist,&vivi_devlist);
+
+ /* init video dma queues */
+ INIT_LIST_HEAD(&dev->vidq.active);
+ INIT_LIST_HEAD(&dev->vidq.queued);
+
+ /* initialize locks */
+ init_MUTEX(&dev->lock);
+
+ dev->vidq.timeout.function = vivi_vid_timeout;
+ dev->vidq.timeout.data = (unsigned long)dev;
+ init_timer(&dev->vidq.timeout);
+
+ ret = video_register_device(&vivi, VFL_TYPE_GRABBER, video_nr);
+ printk(KERN_INFO "Video Technology Magazine Virtual Video Capture Board (Load status: %d)\n", ret);
+ return ret;
+}
+
+static void __exit vivi_exit(void)
+{
+ struct vivi_dev *h;
+ struct list_head *list;
+
+ list_for_each(list,&vivi_devlist) {
+ h = list_entry(list, struct vivi_dev, vivi_devlist);
+ kfree (h);
+ }
+ video_unregister_device(&vivi);
+}
+
+module_init(vivi_init);
+module_exit(vivi_exit);
diff --git a/drivers/media/video/vpx3220.c b/drivers/media/video/vpx3220.c
index d0a1e72ea8c..40b205b9148 100644
--- a/drivers/media/video/vpx3220.c
+++ b/drivers/media/video/vpx3220.c
@@ -1,4 +1,4 @@
-/*
+/*
* vpx3220a, vpx3216b & vpx3214c video decoder driver version 0.0.1
*
* Copyright (C) 2001 Laurent Pinchart <lpinchart@freegates.be>
@@ -30,7 +30,6 @@
#include <asm/uaccess.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#define I2C_NAME(x) (x)->name
@@ -177,8 +176,8 @@ vpx3220_write_block (struct i2c_client *client,
static int
vpx3220_write_fp_block (struct i2c_client *client,
- const u16 *data,
- unsigned int len)
+ const u16 *data,
+ unsigned int len)
{
u8 reg;
int ret = 0;
@@ -317,7 +316,7 @@ vpx3220_command (struct i2c_client *client,
vpx3220_write_fp_block(client, init_fp,
sizeof(init_fp) >> 1);
switch (decoder->norm) {
-
+
case VIDEO_MODE_NTSC:
vpx3220_write_fp_block(client, init_ntsc,
sizeof(init_ntsc) >> 1);
@@ -325,7 +324,7 @@ vpx3220_command (struct i2c_client *client,
case VIDEO_MODE_PAL:
vpx3220_write_fp_block(client, init_pal,
- sizeof(init_pal) >> 1);
+ sizeof(init_pal) >> 1);
break;
case VIDEO_MODE_SECAM:
vpx3220_write_fp_block(client, init_secam,
@@ -333,10 +332,10 @@ vpx3220_command (struct i2c_client *client,
break;
default:
vpx3220_write_fp_block(client, init_pal,
- sizeof(init_pal) >> 1);
+ sizeof(init_pal) >> 1);
break;
}
- }
+ }
break;
case DECODER_DUMP:
@@ -412,7 +411,7 @@ vpx3220_command (struct i2c_client *client,
/* Here we back up the input selection because it gets
overwritten when we fill the registers with the
- choosen video norm */
+ choosen video norm */
temp_input = vpx3220_fp_read(client, 0xf2);
dprintk(1, KERN_DEBUG "%s: DECODER_SET_NORM %d\n",
@@ -579,7 +578,7 @@ static unsigned short normal_i2c[] =
};
static unsigned short ignore = I2C_CLIENT_END;
-
+
static struct i2c_client_address_data addr_data = {
.normal_i2c = normal_i2c,
.probe = &ignore,
@@ -662,7 +661,7 @@ vpx3220_detect_client (struct i2c_adapter *adapter,
break;
default:
dprintk(1,
- KERN_INFO
+ KERN_INFO
"%s: Wrong part number (0x%04x)\n",
__func__, pn);
kfree(client);
diff --git a/drivers/media/video/w9966.c b/drivers/media/video/w9966.c
index b7b0afffd21..80ef8a1b8f6 100644
--- a/drivers/media/video/w9966.c
+++ b/drivers/media/video/w9966.c
@@ -26,7 +26,7 @@
Does any other model using the w9966 interface chip exist ?
Todo:
-
+
*Add a working EPP mode, since DMA ECP read isn't implemented
in the parport drivers. (That's why it's so sloow)
@@ -47,9 +47,9 @@
*Probably some bugs that I don't know of
Please support me by sending feedback!
-
+
Changes:
-
+
Alan Cox: Removed RGB mode for kernel merge, added THIS_MODULE
and owner support for newer module locks
*/
@@ -204,7 +204,7 @@ static struct video_device w9966_template = {
*/
-// Set camera phase flags, so we know what to uninit when terminating
+// Set camera phase flags, so we know what to uninit when terminating
static inline void w9966_setState(struct w9966_dev* cam, int mask, int val)
{
cam->dev_state = (cam->dev_state & ~mask) ^ val;
@@ -233,7 +233,7 @@ static inline void w9966_pdev_release(struct w9966_dev* cam)
parport_release(cam->pdev);
w9966_setState(cam, W9966_STATE_CLAIMED, 0);
}
-
+
// Read register from W9966 interface-chip
// Expects a claimed pdev
// -1 on error, else register data (byte)
@@ -242,7 +242,7 @@ static int w9966_rReg(struct w9966_dev* cam, int reg)
// ECP, read, regtransfer, REG, REG, REG, REG, REG
const unsigned char addr = 0x80 | (reg & 0x1f);
unsigned char val;
-
+
if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
return -1;
if (parport_write(cam->pport, &addr, 1) != 1)
@@ -263,7 +263,7 @@ static int w9966_wReg(struct w9966_dev* cam, int reg, int data)
// ECP, write, regtransfer, REG, REG, REG, REG, REG
const unsigned char addr = 0xc0 | (reg & 0x1f);
const unsigned char val = data;
-
+
if (parport_negotiate(cam->pport, cam->ppmode | IEEE1284_ADDR) != 0)
return -1;
if (parport_write(cam->pport, &addr, 1) != 1)
@@ -284,7 +284,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
{
if (cam->dev_state != 0)
return -1;
-
+
cam->pport = port;
cam->brightness = 128;
cam->contrast = 64;
@@ -302,7 +302,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
cam->ppmode = IEEE1284_MODE_EPP;
else
cam->ppmode = IEEE1284_MODE_ECP;
- break;
+ break;
case 1: // hw- or sw-ecp
cam->ppmode = IEEE1284_MODE_ECP;
break;
@@ -310,7 +310,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
cam->ppmode = IEEE1284_MODE_EPP;
break;
}
-
+
// Tell the parport driver that we exists
cam->pdev = parport_register_device(port, "w9966", NULL, NULL, NULL, 0, NULL);
if (cam->pdev == NULL) {
@@ -320,7 +320,7 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
w9966_setState(cam, W9966_STATE_PDEV, W9966_STATE_PDEV);
w9966_pdev_claim(cam);
-
+
// Setup a default capture mode
if (w9966_setup(cam, 0, 0, 1023, 1023, 200, 160) != 0) {
DPRINTF("w9966_setup() failed.\n");
@@ -333,11 +333,11 @@ static int w9966_init(struct w9966_dev* cam, struct parport* port)
memcpy(&cam->vdev, &w9966_template, sizeof(struct video_device));
cam->vdev.priv = cam;
- if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1)
+ if (video_register_device(&cam->vdev, VFL_TYPE_GRABBER, video_nr) == -1)
return -1;
-
+
w9966_setState(cam, W9966_STATE_VDEV, W9966_STATE_VDEV);
-
+
// All ok
printk(
"w9966cf: Found and initialized a webcam on %s.\n",
@@ -391,7 +391,7 @@ static int w9966_findlen(int near, int size, int maxlen)
// Only continue as long as we keep getting better values
if (err > besterr)
break;
-
+
besterr = err;
bestlen = len;
}
@@ -399,7 +399,7 @@ static int w9966_findlen(int near, int size, int maxlen)
return bestlen;
}
-// Modify capture window (if necessary)
+// Modify capture window (if necessary)
// and calculate downscaling
// Return -1 on error
static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsigned char* factor)
@@ -407,7 +407,7 @@ static int w9966_calcscale(int size, int min, int max, int* beg, int* end, unsig
int maxlen = max - min;
int len = *end - *beg + 1;
int newlen = w9966_findlen(len, size, maxlen);
- int err = newlen - len;
+ int err = newlen - len;
// Check for bad format
if (newlen > maxlen || newlen < size)
@@ -452,8 +452,8 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
0x48, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x71, 0xe7, 0x00, 0x00, 0xc0
};
-
-
+
+
if (w*h*2 > W9966_SRAMSIZE)
{
DPRINTF("capture window exceeds SRAM size!.\n");
@@ -469,9 +469,9 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
cam->width = w;
cam->height = h;
- enh_s = 0;
+ enh_s = 0;
enh_e = w*h*2;
-
+
// Modify capture window if necessary and calculate downscaling
if (
w9966_calcscale(w, W9966_WND_MIN_X, W9966_WND_MAX_X, &x1, &x2, &scale_x) != 0 ||
@@ -482,14 +482,14 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
"%dx%d, x: %d<->%d, y: %d<->%d, sx: %d/64, sy: %d/64.\n",
w, h, x1, x2, y1, y2, scale_x&~0x80, scale_y&~0x80
);
-
+
// Setup registers
regs[0x00] = 0x00; // Set normal operation
regs[0x01] = 0x18; // Capture mode
regs[0x02] = scale_y; // V-scaling
regs[0x03] = scale_x; // H-scaling
-
- // Capture window
+
+ // Capture window
regs[0x04] = (x1 & 0x0ff); // X-start (8 low bits)
regs[0x05] = (x1 & 0x300)>>8; // X-start (2 high bits)
regs[0x06] = (y1 & 0x0ff); // Y-start (8 low bits)
@@ -499,7 +499,7 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
regs[0x0a] = (y2 & 0x0ff); // Y-end (8 low bits)
regs[0x0c] = W9966_SRAMID; // SRAM-banks (1x 128kb)
-
+
// Enhancement layer
regs[0x0d] = (enh_s& 0x000ff); // Enh. start (0-7)
regs[0x0e] = (enh_s& 0x0ff00)>>8; // Enh. start (8-15)
@@ -515,7 +515,7 @@ static int w9966_setup(struct w9966_dev* cam, int x1, int y1, int x2, int y2, in
regs[0x19] = 0xff; // I/O port direction control
regs[0x1a] = 0xff; // I/O port data register
regs[0x1b] = 0x10; // ???
-
+
// SAA7111 chip settings
saa7111_regs[0x0a] = cam->brightness;
saa7111_regs[0x0b] = cam->contrast;
@@ -551,7 +551,7 @@ static inline void w9966_i2c_setsda(struct w9966_dev* cam, int state)
cam->i2c_state |= W9966_I2C_W_DATA;
else
cam->i2c_state &= ~W9966_I2C_W_DATA;
-
+
w9966_wReg(cam, 0x18, cam->i2c_state);
udelay(5);
}
@@ -577,7 +577,7 @@ static inline int w9966_i2c_setscl(struct w9966_dev* cam, int state)
w9966_wReg(cam, 0x18, cam->i2c_state);
udelay(5);
-
+
// we go to high, we also expect the peripheral to ack.
if (state) {
timeout = jiffies + 100;
@@ -607,16 +607,16 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
w9966_i2c_setsda(cam, (data >> i) & 0x01);
if (w9966_i2c_setscl(cam, 1) == -1)
- return -1;
+ return -1;
w9966_i2c_setscl(cam, 0);
}
w9966_i2c_setsda(cam, 1);
-
+
if (w9966_i2c_setscl(cam, 1) == -1)
return -1;
w9966_i2c_setscl(cam, 0);
-
+
return 0;
}
@@ -626,8 +626,8 @@ static int w9966_i2c_wbyte(struct w9966_dev* cam, int data)
static int w9966_i2c_rbyte(struct w9966_dev* cam)
{
unsigned char data = 0x00;
- int i;
-
+ int i;
+
w9966_i2c_setsda(cam, 1);
for (i = 0; i < 8; i++)
@@ -637,7 +637,7 @@ static int w9966_i2c_rbyte(struct w9966_dev* cam)
data = data << 1;
if (w9966_i2c_getsda(cam))
data |= 0x01;
-
+
w9966_i2c_setscl(cam, 0);
}
return data;
@@ -673,11 +673,11 @@ static int w9966_rReg_i2c(struct w9966_dev* cam, int reg)
return -1;
w9966_i2c_setsda(cam, 0);
-
+
if (w9966_i2c_setscl(cam, 1) == -1)
return -1;
w9966_i2c_setsda(cam, 1);
-
+
return data;
}
#endif
@@ -699,7 +699,7 @@ static int w9966_wReg_i2c(struct w9966_dev* cam, int reg, int data)
w9966_i2c_setsda(cam, 0);
if (w9966_i2c_setscl(cam, 1) == -1)
return -1;
-
+
w9966_i2c_setsda(cam, 1);
return 0;
@@ -714,7 +714,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
{
struct video_device *vdev = video_devdata(file);
struct w9966_dev *cam = vdev->priv;
-
+
switch(cmd)
{
case VIDIOCGCAP:
@@ -790,14 +790,14 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
struct video_picture *vpic = arg;
if (vpic->depth != 16 || vpic->palette != VIDEO_PALETTE_YUV422)
return -EINVAL;
-
+
cam->brightness = vpic->brightness >> 8;
cam->hue = (vpic->hue >> 8) - 128;
cam->color = vpic->colour >> 9;
cam->contrast = vpic->contrast >> 9;
w9966_pdev_claim(cam);
-
+
if (
w9966_wReg_i2c(cam, 0x0a, cam->brightness) == -1 ||
w9966_wReg_i2c(cam, 0x0b, cam->contrast) == -1 ||
@@ -807,7 +807,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
w9966_pdev_release(cam);
return -EIO;
}
-
+
w9966_pdev_release(cam);
return 0;
}
@@ -815,13 +815,13 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
{
int ret;
struct video_window *vwin = arg;
-
+
if (vwin->flags != 0)
return -EINVAL;
if (vwin->clipcount != 0)
return -EINVAL;
if (vwin->width < 2 || vwin->width > W9966_WND_MAX_W)
- return -EINVAL;
+ return -EINVAL;
if (vwin->height < 1 || vwin->height > W9966_WND_MAX_H)
return -EINVAL;
@@ -829,12 +829,12 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
w9966_pdev_claim(cam);
ret = w9966_setup(cam, 0, 0, 1023, 1023, vwin->width, vwin->height);
w9966_pdev_release(cam);
-
+
if (ret != 0) {
DPRINTF("VIDIOCSWIN: w9966_setup() failed.\n");
return -EIO;
}
-
+
return 0;
}
case VIDIOCGWIN:
@@ -846,7 +846,7 @@ static int w9966_v4l_do_ioctl(struct inode *inode, struct file *file,
return 0;
}
// Unimplemented
- case VIDIOCCAPTURE:
+ case VIDIOCCAPTURE:
case VIDIOCGFBUF:
case VIDIOCSFBUF:
case VIDIOCKEY:
@@ -877,17 +877,17 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
unsigned char __user *dest = (unsigned char __user *)buf;
unsigned long dleft = count;
unsigned char *tbuf;
-
+
// Why would anyone want more than this??
if (count > cam->width * cam->height * 2)
return -EINVAL;
-
+
w9966_pdev_claim(cam);
w9966_wReg(cam, 0x00, 0x02); // Reset ECP-FIFO buffer
w9966_wReg(cam, 0x00, 0x00); // Return to normal operation
w9966_wReg(cam, 0x01, 0x98); // Enable capture
- // write special capture-addr and negotiate into data transfer
+ // write special capture-addr and negotiate into data transfer
if (
(parport_negotiate(cam->pport, cam->ppmode|IEEE1284_ADDR) != 0 )||
(parport_write(cam->pport, &addr, 1) != 1 )||
@@ -906,7 +906,7 @@ static ssize_t w9966_v4l_read(struct file *file, char __user *buf,
while(dleft > 0)
{
unsigned long tsize = (dleft > W9966_RBUFFER) ? W9966_RBUFFER : dleft;
-
+
if (parport_read(cam->pport, tbuf, tsize) < tsize) {
count = -EFAULT;
goto out;
@@ -933,7 +933,7 @@ out:
static void w9966_attach(struct parport *port)
{
int i;
-
+
for (i = 0; i < W9966_MAXCAMS; i++)
{
if (w9966_cams[i].dev_state != 0) // Cam is already assigned
diff --git a/drivers/usb/media/w9968cf.c b/drivers/media/video/w9968cf.c
index b57dec3782e..20f211b55ad 100644
--- a/drivers/usb/media/w9968cf.c
+++ b/drivers/media/video/w9968cf.c
@@ -71,39 +71,39 @@ MODULE_SUPPORTED_DEVICE("Video");
static int ovmod_load = W9968CF_OVMOD_LOAD;
static unsigned short simcams = W9968CF_SIMCAMS;
static short video_nr[]={[0 ... W9968CF_MAX_DEVICES-1] = -1}; /*-1=first free*/
-static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_PACKET_SIZE};
-static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_BUFFERS};
-static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_DOUBLE_BUFFER};
+static unsigned int packet_size[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_PACKET_SIZE};
+static unsigned short max_buffers[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_BUFFERS};
+static int double_buffer[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_DOUBLE_BUFFER};
static int clamping[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLAMPING};
-static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_FILTER_TYPE};
+static unsigned short filter_type[]= {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_FILTER_TYPE};
static int largeview[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_LARGEVIEW};
-static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_DECOMPRESSION};
+static unsigned short decompression[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_DECOMPRESSION};
static int upscaling[]= {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_UPSCALING};
static unsigned short force_palette[] = {[0 ... W9968CF_MAX_DEVICES-1] = 0};
static int force_rgb[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_FORCE_RGB};
static int autobright[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOBRIGHT};
static int autoexp[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_AUTOEXP};
-static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_LIGHTFREQ};
+static unsigned short lightfreq[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_LIGHTFREQ};
static int bandingfilter[] = {[0 ... W9968CF_MAX_DEVICES-1]=
- W9968CF_BANDINGFILTER};
+ W9968CF_BANDINGFILTER};
static short clockdiv[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_CLOCKDIV};
static int backlight[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_BACKLIGHT};
static int mirror[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_MIRROR};
static int monochrome[] = {[0 ... W9968CF_MAX_DEVICES-1]=W9968CF_MONOCHROME};
-static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_BRIGHTNESS};
+static unsigned int brightness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_BRIGHTNESS};
static unsigned int hue[] = {[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_HUE};
static unsigned int colour[]={[0 ... W9968CF_MAX_DEVICES-1] = W9968CF_COLOUR};
-static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_CONTRAST};
-static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
- W9968CF_WHITENESS};
+static unsigned int contrast[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_CONTRAST};
+static unsigned int whiteness[] = {[0 ... W9968CF_MAX_DEVICES-1] =
+ W9968CF_WHITENESS};
#ifdef W9968CF_DEBUG
static unsigned short debug = W9968CF_DEBUG_LEVEL;
static int specific_debug = W9968CF_SPECIFIC_DEBUG;
@@ -145,251 +145,251 @@ module_param(specific_debug, bool, 0644);
#endif
#ifdef CONFIG_KMOD
-MODULE_PARM_DESC(ovmod_load,
- "\n<0|1> Automatic 'ovcamchip' module loading."
- "\n0 disabled, 1 enabled."
- "\nIf enabled,'insmod' searches for the required 'ovcamchip'"
- "\nmodule in the system, according to its configuration, and"
- "\nattempts to load that module automatically. This action is"
- "\nperformed once as soon as the 'w9968cf' module is loaded"
- "\ninto memory."
- "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
- "\n");
+MODULE_PARM_DESC(ovmod_load,
+ "\n<0|1> Automatic 'ovcamchip' module loading."
+ "\n0 disabled, 1 enabled."
+ "\nIf enabled,'insmod' searches for the required 'ovcamchip'"
+ "\nmodule in the system, according to its configuration, and"
+ "\nattempts to load that module automatically. This action is"
+ "\nperformed once as soon as the 'w9968cf' module is loaded"
+ "\ninto memory."
+ "\nDefault value is "__MODULE_STRING(W9968CF_OVMOD_LOAD)"."
+ "\n");
#endif
-MODULE_PARM_DESC(simcams,
- "\n<n> Number of cameras allowed to stream simultaneously."
- "\nn may vary from 0 to "
- __MODULE_STRING(W9968CF_MAX_DEVICES)"."
- "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
- "\n");
+MODULE_PARM_DESC(simcams,
+ "\n<n> Number of cameras allowed to stream simultaneously."
+ "\nn may vary from 0 to "
+ __MODULE_STRING(W9968CF_MAX_DEVICES)"."
+ "\nDefault value is "__MODULE_STRING(W9968CF_SIMCAMS)"."
+ "\n");
MODULE_PARM_DESC(video_nr,
- "\n<-1|n[,...]> Specify V4L minor mode number."
- "\n -1 = use next available (default)"
- "\n n = use minor number n (integer >= 0)"
- "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES)
- " cameras this way."
- "\nFor example:"
- "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
- "\nthe second camera and use auto for the first"
- "\none and for every other camera."
- "\n");
+ "\n<-1|n[,...]> Specify V4L minor mode number."
+ "\n -1 = use next available (default)"
+ "\n n = use minor number n (integer >= 0)"
+ "\nYou can specify up to "__MODULE_STRING(W9968CF_MAX_DEVICES)
+ " cameras this way."
+ "\nFor example:"
+ "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
+ "\nthe second camera and use auto for the first"
+ "\none and for every other camera."
+ "\n");
MODULE_PARM_DESC(packet_size,
- "\n<n[,...]> Specify the maximum data payload"
- "\nsize in bytes for alternate settings, for each device."
- "\nn is scaled between 63 and 1023 "
- "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
- "\n");
+ "\n<n[,...]> Specify the maximum data payload"
+ "\nsize in bytes for alternate settings, for each device."
+ "\nn is scaled between 63 and 1023 "
+ "(default is "__MODULE_STRING(W9968CF_PACKET_SIZE)")."
+ "\n");
MODULE_PARM_DESC(max_buffers,
- "\n<n[,...]> For advanced users."
- "\nSpecify the maximum number of video frame buffers"
- "\nto allocate for each device, from 2 to "
- __MODULE_STRING(W9968CF_MAX_BUFFERS)
- ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
- "\n");
-MODULE_PARM_DESC(double_buffer,
- "\n<0|1[,...]> "
- "Hardware double buffering: 0 disabled, 1 enabled."
- "\nIt should be enabled if you want smooth video output: if"
- "\nyou obtain out of sync. video, disable it, or try to"
- "\ndecrease the 'clockdiv' module parameter value."
- "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
- " for every device."
- "\n");
-MODULE_PARM_DESC(clamping,
- "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
- "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
- " for every device."
- "\n");
-MODULE_PARM_DESC(filter_type,
- "\n<0|1|2[,...]> Video filter type."
- "\n0 none, 1 (1-2-1) 3-tap filter, "
- "2 (2-3-6-3-2) 5-tap filter."
- "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
- " for every device."
- "\nThe filter is used to reduce noise and aliasing artifacts"
- "\nproduced by the CCD or CMOS image sensor, and the scaling"
- " process."
- "\n");
-MODULE_PARM_DESC(largeview,
- "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
- "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
- " for every device."
- "\n");
-MODULE_PARM_DESC(upscaling,
- "\n<0|1[,...]> Software scaling (for non-compressed video):"
- "\n0 disabled, 1 enabled."
- "\nDisable it if you have a slow CPU or you don't have"
- " enough memory."
- "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING)
- " for every device."
- "\nIf 'w9968cf-vpp' is not present, this parameter is"
- " set to 0."
- "\n");
+ "\n<n[,...]> For advanced users."
+ "\nSpecify the maximum number of video frame buffers"
+ "\nto allocate for each device, from 2 to "
+ __MODULE_STRING(W9968CF_MAX_BUFFERS)
+ ". (default is "__MODULE_STRING(W9968CF_BUFFERS)")."
+ "\n");
+MODULE_PARM_DESC(double_buffer,
+ "\n<0|1[,...]> "
+ "Hardware double buffering: 0 disabled, 1 enabled."
+ "\nIt should be enabled if you want smooth video output: if"
+ "\nyou obtain out of sync. video, disable it, or try to"
+ "\ndecrease the 'clockdiv' module parameter value."
+ "\nDefault value is "__MODULE_STRING(W9968CF_DOUBLE_BUFFER)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(clamping,
+ "\n<0|1[,...]> Video data clamping: 0 disabled, 1 enabled."
+ "\nDefault value is "__MODULE_STRING(W9968CF_CLAMPING)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(filter_type,
+ "\n<0|1|2[,...]> Video filter type."
+ "\n0 none, 1 (1-2-1) 3-tap filter, "
+ "2 (2-3-6-3-2) 5-tap filter."
+ "\nDefault value is "__MODULE_STRING(W9968CF_FILTER_TYPE)
+ " for every device."
+ "\nThe filter is used to reduce noise and aliasing artifacts"
+ "\nproduced by the CCD or CMOS image sensor, and the scaling"
+ " process."
+ "\n");
+MODULE_PARM_DESC(largeview,
+ "\n<0|1[,...]> Large view: 0 disabled, 1 enabled."
+ "\nDefault value is "__MODULE_STRING(W9968CF_LARGEVIEW)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(upscaling,
+ "\n<0|1[,...]> Software scaling (for non-compressed video):"
+ "\n0 disabled, 1 enabled."
+ "\nDisable it if you have a slow CPU or you don't have"
+ " enough memory."
+ "\nDefault value is "__MODULE_STRING(W9968CF_UPSCALING)
+ " for every device."
+ "\nIf 'w9968cf-vpp' is not present, this parameter is"
+ " set to 0."
+ "\n");
MODULE_PARM_DESC(decompression,
- "\n<0|1|2[,...]> Software video decompression:"
- "\n- 0 disables decompression (doesn't allow formats needing"
- " decompression)"
- "\n- 1 forces decompression (allows formats needing"
- " decompression only);"
- "\n- 2 allows any permitted formats."
- "\nFormats supporting compressed video are YUV422P and"
- " YUV420P/YUV420 "
- "\nin any resolutions where both width and height are "
- "a multiple of 16."
- "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION)
- " for every device."
- "\nIf 'w9968cf-vpp' is not present, forcing decompression is "
- "\nnot allowed; in this case this parameter is set to 2."
- "\n");
+ "\n<0|1|2[,...]> Software video decompression:"
+ "\n- 0 disables decompression (doesn't allow formats needing"
+ " decompression)"
+ "\n- 1 forces decompression (allows formats needing"
+ " decompression only);"
+ "\n- 2 allows any permitted formats."
+ "\nFormats supporting compressed video are YUV422P and"
+ " YUV420P/YUV420 "
+ "\nin any resolutions where both width and height are "
+ "a multiple of 16."
+ "\nDefault value is "__MODULE_STRING(W9968CF_DECOMPRESSION)
+ " for every device."
+ "\nIf 'w9968cf-vpp' is not present, forcing decompression is "
+ "\nnot allowed; in this case this parameter is set to 2."
+ "\n");
MODULE_PARM_DESC(force_palette,
- "\n<0"
- "|" __MODULE_STRING(VIDEO_PALETTE_UYVY)
- "|" __MODULE_STRING(VIDEO_PALETTE_YUV420)
- "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P)
- "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P)
- "|" __MODULE_STRING(VIDEO_PALETTE_YUYV)
- "|" __MODULE_STRING(VIDEO_PALETTE_YUV422)
- "|" __MODULE_STRING(VIDEO_PALETTE_GREY)
- "|" __MODULE_STRING(VIDEO_PALETTE_RGB555)
- "|" __MODULE_STRING(VIDEO_PALETTE_RGB565)
- "|" __MODULE_STRING(VIDEO_PALETTE_RGB24)
- "|" __MODULE_STRING(VIDEO_PALETTE_RGB32)
- "[,...]>"
- " Force picture palette."
- "\nIn order:"
- "\n- 0 allows any of the following formats:"
- "\n- UYVY 16 bpp - Original video, compression disabled"
- "\n- YUV420 12 bpp - Original video, compression enabled"
- "\n- YUV422P 16 bpp - Original video, compression enabled"
- "\n- YUV420P 12 bpp - Original video, compression enabled"
- "\n- YUVY 16 bpp - Software conversion from UYVY"
- "\n- YUV422 16 bpp - Software conversion from UYVY"
- "\n- GREY 8 bpp - Software conversion from UYVY"
- "\n- RGB555 16 bpp - Software conversion from UYVY"
- "\n- RGB565 16 bpp - Software conversion from UYVY"
- "\n- RGB24 24 bpp - Software conversion from UYVY"
- "\n- RGB32 32 bpp - Software conversion from UYVY"
- "\nWhen not 0, this parameter will override 'decompression'."
- "\nDefault value is 0 for every device."
- "\nInitial palette is "
- __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"."
- "\nIf 'w9968cf-vpp' is not present, this parameter is"
- " set to 9 (UYVY)."
- "\n");
-MODULE_PARM_DESC(force_rgb,
- "\n<0|1[,...]> Read RGB video data instead of BGR:"
- "\n 1 = use RGB component ordering."
- "\n 0 = use BGR component ordering."
- "\nThis parameter has effect when using RGBX palettes only."
- "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB)
- " for every device."
- "\n");
+ "\n<0"
+ "|" __MODULE_STRING(VIDEO_PALETTE_UYVY)
+ "|" __MODULE_STRING(VIDEO_PALETTE_YUV420)
+ "|" __MODULE_STRING(VIDEO_PALETTE_YUV422P)
+ "|" __MODULE_STRING(VIDEO_PALETTE_YUV420P)
+ "|" __MODULE_STRING(VIDEO_PALETTE_YUYV)
+ "|" __MODULE_STRING(VIDEO_PALETTE_YUV422)
+ "|" __MODULE_STRING(VIDEO_PALETTE_GREY)
+ "|" __MODULE_STRING(VIDEO_PALETTE_RGB555)
+ "|" __MODULE_STRING(VIDEO_PALETTE_RGB565)
+ "|" __MODULE_STRING(VIDEO_PALETTE_RGB24)
+ "|" __MODULE_STRING(VIDEO_PALETTE_RGB32)
+ "[,...]>"
+ " Force picture palette."
+ "\nIn order:"
+ "\n- 0 allows any of the following formats:"
+ "\n- UYVY 16 bpp - Original video, compression disabled"
+ "\n- YUV420 12 bpp - Original video, compression enabled"
+ "\n- YUV422P 16 bpp - Original video, compression enabled"
+ "\n- YUV420P 12 bpp - Original video, compression enabled"
+ "\n- YUVY 16 bpp - Software conversion from UYVY"
+ "\n- YUV422 16 bpp - Software conversion from UYVY"
+ "\n- GREY 8 bpp - Software conversion from UYVY"
+ "\n- RGB555 16 bpp - Software conversion from UYVY"
+ "\n- RGB565 16 bpp - Software conversion from UYVY"
+ "\n- RGB24 24 bpp - Software conversion from UYVY"
+ "\n- RGB32 32 bpp - Software conversion from UYVY"
+ "\nWhen not 0, this parameter will override 'decompression'."
+ "\nDefault value is 0 for every device."
+ "\nInitial palette is "
+ __MODULE_STRING(W9968CF_PALETTE_DECOMP_ON)"."
+ "\nIf 'w9968cf-vpp' is not present, this parameter is"
+ " set to 9 (UYVY)."
+ "\n");
+MODULE_PARM_DESC(force_rgb,
+ "\n<0|1[,...]> Read RGB video data instead of BGR:"
+ "\n 1 = use RGB component ordering."
+ "\n 0 = use BGR component ordering."
+ "\nThis parameter has effect when using RGBX palettes only."
+ "\nDefault value is "__MODULE_STRING(W9968CF_FORCE_RGB)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(autobright,
- "\n<0|1[,...]> Image sensor automatically changes brightness:"
- "\n 0 = no, 1 = yes"
- "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Image sensor automatically changes brightness:"
+ "\n 0 = no, 1 = yes"
+ "\nDefault value is "__MODULE_STRING(W9968CF_AUTOBRIGHT)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(autoexp,
- "\n<0|1[,...]> Image sensor automatically changes exposure:"
- "\n 0 = no, 1 = yes"
- "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Image sensor automatically changes exposure:"
+ "\n 0 = no, 1 = yes"
+ "\nDefault value is "__MODULE_STRING(W9968CF_AUTOEXP)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(lightfreq,
- "\n<50|60[,...]> Light frequency in Hz:"
- "\n 50 for European and Asian lighting,"
- " 60 for American lighting."
- "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ)
- " for every device."
- "\n");
+ "\n<50|60[,...]> Light frequency in Hz:"
+ "\n 50 for European and Asian lighting,"
+ " 60 for American lighting."
+ "\nDefault value is "__MODULE_STRING(W9968CF_LIGHTFREQ)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(bandingfilter,
- "\n<0|1[,...]> Banding filter to reduce effects of"
- " fluorescent lighting:"
- "\n 0 disabled, 1 enabled."
- "\nThis filter tries to reduce the pattern of horizontal"
- "\nlight/dark bands caused by some (usually fluorescent)"
- " lighting."
- "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Banding filter to reduce effects of"
+ " fluorescent lighting:"
+ "\n 0 disabled, 1 enabled."
+ "\nThis filter tries to reduce the pattern of horizontal"
+ "\nlight/dark bands caused by some (usually fluorescent)"
+ " lighting."
+ "\nDefault value is "__MODULE_STRING(W9968CF_BANDINGFILTER)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(clockdiv,
- "\n<-1|n[,...]> "
- "Force pixel clock divisor to a specific value (for experts):"
- "\n n may vary from 0 to 127."
- "\n -1 for automatic value."
- "\nSee also the 'double_buffer' module parameter."
- "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV)
- " for every device."
- "\n");
+ "\n<-1|n[,...]> "
+ "Force pixel clock divisor to a specific value (for experts):"
+ "\n n may vary from 0 to 127."
+ "\n -1 for automatic value."
+ "\nSee also the 'double_buffer' module parameter."
+ "\nDefault value is "__MODULE_STRING(W9968CF_CLOCKDIV)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(backlight,
- "\n<0|1[,...]> Objects are lit from behind:"
- "\n 0 = no, 1 = yes"
- "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Objects are lit from behind:"
+ "\n 0 = no, 1 = yes"
+ "\nDefault value is "__MODULE_STRING(W9968CF_BACKLIGHT)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(mirror,
- "\n<0|1[,...]> Reverse image horizontally:"
- "\n 0 = no, 1 = yes"
- "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Reverse image horizontally:"
+ "\n 0 = no, 1 = yes"
+ "\nDefault value is "__MODULE_STRING(W9968CF_MIRROR)
+ " for every device."
+ "\n");
MODULE_PARM_DESC(monochrome,
- "\n<0|1[,...]> Use image sensor as monochrome sensor:"
- "\n 0 = no, 1 = yes"
- "\nNot all the sensors support monochrome color."
- "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME)
- " for every device."
- "\n");
-MODULE_PARM_DESC(brightness,
- "\n<n[,...]> Set picture brightness (0-65535)."
- "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS)
- " for every device."
- "\nThis parameter has no effect if 'autobright' is enabled."
- "\n");
-MODULE_PARM_DESC(hue,
- "\n<n[,...]> Set picture hue (0-65535)."
- "\nDefault value is "__MODULE_STRING(W9968CF_HUE)
- " for every device."
- "\n");
-MODULE_PARM_DESC(colour,
- "\n<n[,...]> Set picture saturation (0-65535)."
- "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR)
- " for every device."
- "\n");
-MODULE_PARM_DESC(contrast,
- "\n<n[,...]> Set picture contrast (0-65535)."
- "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST)
- " for every device."
- "\n");
-MODULE_PARM_DESC(whiteness,
- "\n<n[,...]> Set picture whiteness (0-65535)."
- "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS)
- " for every device."
- "\n");
+ "\n<0|1[,...]> Use image sensor as monochrome sensor:"
+ "\n 0 = no, 1 = yes"
+ "\nNot all the sensors support monochrome color."
+ "\nDefault value is "__MODULE_STRING(W9968CF_MONOCHROME)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(brightness,
+ "\n<n[,...]> Set picture brightness (0-65535)."
+ "\nDefault value is "__MODULE_STRING(W9968CF_BRIGHTNESS)
+ " for every device."
+ "\nThis parameter has no effect if 'autobright' is enabled."
+ "\n");
+MODULE_PARM_DESC(hue,
+ "\n<n[,...]> Set picture hue (0-65535)."
+ "\nDefault value is "__MODULE_STRING(W9968CF_HUE)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(colour,
+ "\n<n[,...]> Set picture saturation (0-65535)."
+ "\nDefault value is "__MODULE_STRING(W9968CF_COLOUR)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(contrast,
+ "\n<n[,...]> Set picture contrast (0-65535)."
+ "\nDefault value is "__MODULE_STRING(W9968CF_CONTRAST)
+ " for every device."
+ "\n");
+MODULE_PARM_DESC(whiteness,
+ "\n<n[,...]> Set picture whiteness (0-65535)."
+ "\nDefault value is "__MODULE_STRING(W9968CF_WHITENESS)
+ " for every device."
+ "\n");
#ifdef W9968CF_DEBUG
MODULE_PARM_DESC(debug,
- "\n<n> Debugging information level, from 0 to 6:"
- "\n0 = none (use carefully)"
- "\n1 = critical errors"
- "\n2 = significant informations"
- "\n3 = configuration or general messages"
- "\n4 = warnings"
- "\n5 = called functions"
- "\n6 = function internals"
- "\nLevel 5 and 6 are useful for testing only, when only "
- "one device is used."
- "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"."
- "\n");
+ "\n<n> Debugging information level, from 0 to 6:"
+ "\n0 = none (use carefully)"
+ "\n1 = critical errors"
+ "\n2 = significant informations"
+ "\n3 = configuration or general messages"
+ "\n4 = warnings"
+ "\n5 = called functions"
+ "\n6 = function internals"
+ "\nLevel 5 and 6 are useful for testing only, when only "
+ "one device is used."
+ "\nDefault value is "__MODULE_STRING(W9968CF_DEBUG_LEVEL)"."
+ "\n");
MODULE_PARM_DESC(specific_debug,
- "\n<0|1> Enable or disable specific debugging messages:"
- "\n0 = print messages concerning every level"
- " <= 'debug' level."
- "\n1 = print messages concerning the level"
- " indicated by 'debug'."
- "\nDefault value is "
- __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"."
- "\n");
+ "\n<0|1> Enable or disable specific debugging messages:"
+ "\n0 = print messages concerning every level"
+ " <= 'debug' level."
+ "\n1 = print messages concerning the level"
+ " indicated by 'debug'."
+ "\nDefault value is "
+ __MODULE_STRING(W9968CF_SPECIFIC_DEBUG)"."
+ "\n");
#endif /* W9968CF_DEBUG */
@@ -406,7 +406,7 @@ static int w9968cf_mmap(struct file*, struct vm_area_struct*);
static int w9968cf_ioctl(struct inode*, struct file*, unsigned, unsigned long);
static ssize_t w9968cf_read(struct file*, char __user *, size_t, loff_t*);
static int w9968cf_v4l_ioctl(struct inode*, struct file*, unsigned int,
- void __user *);
+ void __user *);
/* USB-specific */
static int w9968cf_start_transfer(struct w9968cf_device*);
@@ -428,25 +428,25 @@ static int w9968cf_smbus_write_ack(struct w9968cf_device*);
static int w9968cf_smbus_read_ack(struct w9968cf_device*);
static int w9968cf_smbus_refresh_bus(struct w9968cf_device*);
static int w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
- u16 address, u8* value);
-static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address,
- u8 subaddress, u8* value);
+ u16 address, u8* value);
+static int w9968cf_i2c_adap_read_byte_data(struct w9968cf_device*, u16 address,
+ u8 subaddress, u8* value);
static int w9968cf_i2c_adap_write_byte(struct w9968cf_device*,
- u16 address, u8 subaddress);
+ u16 address, u8 subaddress);
static int w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device*,
- u16 address, u8 subaddress,
- u8 value);
+ u16 address, u8 subaddress,
+ u8 value);
/* I2C interface to kernel */
static int w9968cf_i2c_init(struct w9968cf_device*);
-static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
- unsigned short flags, char read_write,
- u8 command, int size, union i2c_smbus_data*);
+static int w9968cf_i2c_smbus_xfer(struct i2c_adapter*, u16 addr,
+ unsigned short flags, char read_write,
+ u8 command, int size, union i2c_smbus_data*);
static u32 w9968cf_i2c_func(struct i2c_adapter*);
static int w9968cf_i2c_attach_inform(struct i2c_client*);
static int w9968cf_i2c_detach_inform(struct i2c_client*);
static int w9968cf_i2c_control(struct i2c_adapter*, unsigned int cmd,
- unsigned long arg);
+ unsigned long arg);
/* Memory management */
static void* rvmalloc(unsigned long size);
@@ -458,17 +458,17 @@ static int w9968cf_allocate_memory(struct w9968cf_device*);
static int w9968cf_sensor_set_control(struct w9968cf_device*,int cid,int val);
static int w9968cf_sensor_get_control(struct w9968cf_device*,int cid,int *val);
static int w9968cf_sensor_cmd(struct w9968cf_device*,
- unsigned int cmd, void *arg);
+ unsigned int cmd, void *arg);
static int w9968cf_sensor_init(struct w9968cf_device*);
static int w9968cf_sensor_update_settings(struct w9968cf_device*);
static int w9968cf_sensor_get_picture(struct w9968cf_device*);
-static int w9968cf_sensor_update_picture(struct w9968cf_device*,
- struct video_picture pict);
+static int w9968cf_sensor_update_picture(struct w9968cf_device*,
+ struct video_picture pict);
/* Other helper functions */
static void w9968cf_configure_camera(struct w9968cf_device*,struct usb_device*,
- enum w9968cf_model_id,
- const unsigned short dev_nr);
+ enum w9968cf_model_id,
+ const unsigned short dev_nr);
static void w9968cf_adjust_configuration(struct w9968cf_device*);
static int w9968cf_turn_on_led(struct w9968cf_device*);
static int w9968cf_init_chip(struct w9968cf_device*);
@@ -477,8 +477,8 @@ static inline u16 w9968cf_valid_depth(u16 palette);
static inline u8 w9968cf_need_decompression(u16 palette);
static int w9968cf_set_picture(struct w9968cf_device*, struct video_picture);
static int w9968cf_set_window(struct w9968cf_device*, struct video_window);
-static int w9968cf_postprocess_frame(struct w9968cf_device*,
- struct w9968cf_frame_t*);
+static int w9968cf_postprocess_frame(struct w9968cf_device*,
+ struct w9968cf_frame_t*);
static int w9968cf_adjust_window_size(struct w9968cf_device*, u16* w, u16* h);
static void w9968cf_init_framelist(struct w9968cf_device*);
static void w9968cf_push_frame(struct w9968cf_device*, u8 f_num);
@@ -497,11 +497,11 @@ struct w9968cf_symbolic_list {
const char *name;
};
-/*--------------------------------------------------------------------------
+/*--------------------------------------------------------------------------
Returns the name of the matching element in the symbolic_list array. The
end of the list must be marked with an element that has a NULL name.
--------------------------------------------------------------------------*/
-static inline const char *
+static inline const char *
symbolic(struct w9968cf_symbolic_list list[], const int num)
{
int i;
@@ -568,7 +568,7 @@ static struct w9968cf_symbolic_list v4l1_plist[] = {
static struct w9968cf_symbolic_list decoder_errlist[] = {
{ W9968CF_DEC_ERR_CORRUPTED_DATA, "Corrupted data" },
{ W9968CF_DEC_ERR_BUF_OVERFLOW, "Buffer overflow" },
- { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" },
+ { W9968CF_DEC_ERR_NO_SOI, "SOI marker not found" },
{ W9968CF_DEC_ERR_NO_SOF0, "SOF0 marker not found" },
{ W9968CF_DEC_ERR_NO_SOS, "SOS marker not found" },
{ W9968CF_DEC_ERR_NO_EOI, "EOI marker not found" },
@@ -695,7 +695,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
bpp = (w9968cf_vpp) ? 4 : 2;
if (cam->upscaling)
vpp_bufsize = max(W9968CF_MAX_WIDTH*W9968CF_MAX_HEIGHT*bpp,
- cam->maxwidth*cam->maxheight*bpp);
+ cam->maxwidth*cam->maxheight*bpp);
else
vpp_bufsize = cam->maxwidth*cam->maxheight*bpp;
@@ -704,7 +704,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
if (!(cam->transfer_buffer[i] =
kzalloc(W9968CF_ISO_PACKETS*p_size, GFP_KERNEL))) {
DBG(1, "Couldn't allocate memory for the isochronous "
- "transfer buffers (%u bytes)",
+ "transfer buffers (%u bytes)",
p_size * W9968CF_ISO_PACKETS)
return -ENOMEM;
}
@@ -780,7 +780,7 @@ static int w9968cf_allocate_memory(struct w9968cf_device* cam)
of the next video frame; if an error is encountered in a packet, the entire
video frame is discarded and grabbed again.
If there are no requested frames in the FIFO list, packets are collected into
- a temporary buffer.
+ a temporary buffer.
--------------------------------------------------------------------------*/
static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
{
@@ -799,7 +799,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
/* "(*f)" will be used instead of "cam->frame_current" */
f = &cam->frame_current;
- /* If a frame has been requested and we are grabbing into
+ /* If a frame has been requested and we are grabbing into
the temporary frame, we'll switch to that requested frame */
if ((*f) == &cam->frame_tmp && *cam->requested_frame) {
if (cam->frame_tmp.status == F_GRABBING) {
@@ -808,7 +808,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
(*f)->length = cam->frame_tmp.length;
memcpy((*f)->buffer, cam->frame_tmp.buffer,
(*f)->length);
- DBG(6, "Switched from temp. frame to frame #%d",
+ DBG(6, "Switched from temp. frame to frame #%d",
(*f)->number)
}
}
@@ -850,7 +850,7 @@ static void w9968cf_urb_complete(struct urb *urb, struct pt_regs *regs)
if (cam->vpp_flag & VPP_DECOMPRESSION) {
err = w9968cf_vpp->check_headers((*f)->buffer,
- (*f)->length);
+ (*f)->length);
if (err) {
DBG(4, "Skip corrupted frame: %s",
symbolic(decoder_errlist, err))
@@ -975,7 +975,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
cam->frame_current = &cam->frame_tmp;
if (!(cam->vpp_flag & VPP_DECOMPRESSION))
- DBG(5, "Isochronous transfer size: %lu bytes/frame",
+ DBG(5, "Isochronous transfer size: %lu bytes/frame",
(unsigned long)t_size*2)
DBG(5, "Starting the isochronous transfer...")
@@ -992,7 +992,7 @@ static int w9968cf_start_transfer(struct w9968cf_device* cam)
usb_free_urb(cam->urb[j]);
}
DBG(1, "Couldn't send a transfer request to the "
- "USB core (error #%d, %s)", err,
+ "USB core (error #%d, %s)", err,
symbolic(urb_errlist, err))
return err;
}
@@ -1016,7 +1016,7 @@ static int w9968cf_stop_transfer(struct w9968cf_device* cam)
if (!cam->streaming)
return 0;
- /* This avoids race conditions with usb_submit_urb()
+ /* This avoids race conditions with usb_submit_urb()
in the URB completition handler */
spin_lock_irqsave(&cam->urb_lock, lock_flags);
cam->streaming = 0;
@@ -1050,7 +1050,7 @@ exit:
/*--------------------------------------------------------------------------
- Write a W9968CF register.
+ Write a W9968CF register.
Return 0 on success, -1 otherwise.
--------------------------------------------------------------------------*/
static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
@@ -1059,8 +1059,8 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
int res;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
- USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
- value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT);
+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
+ value, index, NULL, 0, W9968CF_USB_CTRL_TIMEOUT);
if (res < 0)
DBG(4, "Failed to write a register "
@@ -1072,7 +1072,7 @@ static int w9968cf_write_reg(struct w9968cf_device* cam, u16 value, u16 index)
/*--------------------------------------------------------------------------
- Read a W9968CF register.
+ Read a W9968CF register.
Return the register value on success, -1 otherwise.
--------------------------------------------------------------------------*/
static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
@@ -1082,8 +1082,8 @@ static int w9968cf_read_reg(struct w9968cf_device* cam, u16 index)
int res;
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 1,
- USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
- 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT);
+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
+ 0, index, buff, 2, W9968CF_USB_CTRL_TIMEOUT);
if (res < 0)
DBG(4, "Failed to read a register "
@@ -1107,8 +1107,8 @@ static int w9968cf_write_fsb(struct w9968cf_device* cam, u16* data)
value = *data++;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0,
- USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
- value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT);
+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE,
+ value, 0x06, data, 6, W9968CF_USB_CTRL_TIMEOUT);
if (res < 0)
DBG(4, "Failed to write the FSB registers "
@@ -1287,9 +1287,9 @@ static int w9968cf_smbus_refresh_bus(struct w9968cf_device* cam)
/* SMBus protocol: S Addr Wr [A] Subaddr [A] Value [A] P */
-static int
-w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
- u16 address, u8 subaddress,u8 value)
+static int
+w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
+ u16 address, u8 subaddress,u8 value)
{
u16* data = cam->data_buffer;
int err = 0;
@@ -1348,7 +1348,7 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
"value 0x%02X", address, subaddress, value)
else
DBG(5, "I2C write byte data failed, addr.0x%04X, "
- "subaddr.0x%02X, value 0x%02X",
+ "subaddr.0x%02X, value 0x%02X",
address, subaddress, value)
return err;
@@ -1356,10 +1356,10 @@ w9968cf_i2c_adap_fastwrite_byte_data(struct w9968cf_device* cam,
/* SMBus protocol: S Addr Wr [A] Subaddr [A] P S Addr+1 Rd [A] [Value] NA P */
-static int
-w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
- u16 address, u8 subaddress,
- u8* value)
+static int
+w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
+ u16 address, u8 subaddress,
+ u8* value)
{
int err = 0;
@@ -1384,7 +1384,7 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
if (!err)
DBG(5, "I2C read byte data done, addr.0x%04X, "
- "subaddr.0x%02X, value 0x%02X",
+ "subaddr.0x%02X, value 0x%02X",
address, subaddress, *value)
else
DBG(5, "I2C read byte data failed, addr.0x%04X, "
@@ -1396,9 +1396,9 @@ w9968cf_i2c_adap_read_byte_data(struct w9968cf_device* cam,
/* SMBus protocol: S Addr+1 Rd [A] [Value] NA P */
-static int
+static int
w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
- u16 address, u8* value)
+ u16 address, u8* value)
{
int err = 0;
@@ -1411,7 +1411,7 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
err += w9968cf_smbus_read_byte(cam, value);
err += w9968cf_smbus_write_ack(cam);
err += w9968cf_smbus_stop(cam);
-
+
/* Serial data disable */
err += w9968cf_write_sb(cam, 0x0000);
@@ -1427,9 +1427,9 @@ w9968cf_i2c_adap_read_byte(struct w9968cf_device* cam,
/* SMBus protocol: S Addr Wr [A] Value [A] P */
-static int
+static int
w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
- u16 address, u8 value)
+ u16 address, u8 value)
{
DBG(4, "i2c_write_byte() is an unsupported transfer mode")
return -EINVAL;
@@ -1442,13 +1442,13 @@ w9968cf_i2c_adap_write_byte(struct w9968cf_device* cam,
****************************************************************************/
static int
-w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
- unsigned short flags, char read_write, u8 command,
- int size, union i2c_smbus_data *data)
+w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
+ unsigned short flags, char read_write, u8 command,
+ int size, union i2c_smbus_data *data)
{
struct w9968cf_device* cam = i2c_get_adapdata(adapter);
u8 i;
- int err = 0;
+ int err = 0;
switch (addr) {
case OV6xx0_SID:
@@ -1464,20 +1464,20 @@ w9968cf_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
addr <<= 1;
if (read_write == I2C_SMBUS_WRITE)
- err = w9968cf_i2c_adap_write_byte(cam, addr, command);
- else if (read_write == I2C_SMBUS_READ)
+ err = w9968cf_i2c_adap_write_byte(cam, addr, command);
+ else if (read_write == I2C_SMBUS_READ)
err = w9968cf_i2c_adap_read_byte(cam,addr,&data->byte);
} else if (size == I2C_SMBUS_BYTE_DATA) {
addr <<= 1;
if (read_write == I2C_SMBUS_WRITE)
- err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr,
- command, data->byte);
+ err = w9968cf_i2c_adap_fastwrite_byte_data(cam, addr,
+ command, data->byte);
else if (read_write == I2C_SMBUS_READ) {
for (i = 1; i <= W9968CF_I2C_RW_RETRIES; i++) {
err = w9968cf_i2c_adap_read_byte_data(cam,addr,
- command, &data->byte);
+ command, &data->byte);
if (err) {
if (w9968cf_smbus_refresh_bus(cam)) {
err = -EIO;
@@ -1520,7 +1520,7 @@ static int w9968cf_i2c_attach_inform(struct i2c_client* client)
return err;
}
} else {
- DBG(4, "Rejected client [%s] with driver [%s]",
+ DBG(4, "Rejected client [%s] with driver [%s]",
client->name, client->driver->driver.name)
return -EINVAL;
}
@@ -1545,9 +1545,9 @@ static int w9968cf_i2c_detach_inform(struct i2c_client* client)
}
-static int
+static int
w9968cf_i2c_control(struct i2c_adapter* adapter, unsigned int cmd,
- unsigned long arg)
+ unsigned long arg)
{
return 0;
}
@@ -1625,12 +1625,12 @@ static int w9968cf_turn_on_led(struct w9968cf_device* cam)
static int w9968cf_init_chip(struct w9968cf_device* cam)
{
unsigned long hw_bufsize = cam->maxwidth*cam->maxheight*2,
- y0 = 0x0000,
- u0 = y0 + hw_bufsize/2,
- v0 = u0 + hw_bufsize/4,
- y1 = v0 + hw_bufsize/4,
- u1 = y1 + hw_bufsize/2,
- v1 = u1 + hw_bufsize/4;
+ y0 = 0x0000,
+ u0 = y0 + hw_bufsize/2,
+ v0 = u0 + hw_bufsize/4,
+ y1 = v0 + hw_bufsize/4,
+ u1 = y1 + hw_bufsize/2,
+ v1 = u1 + hw_bufsize/4;
int err = 0;
err += w9968cf_write_reg(cam, 0xff00, 0x00); /* power off */
@@ -1762,7 +1762,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
cam->vpp_flag = VPP_SWAP_YUV_BYTES;
hw_palette = VIDEO_PALETTE_UYVY;
break;
- /* Original video is used instead of RGBX palettes.
+ /* Original video is used instead of RGBX palettes.
Software conversion later. */
case VIDEO_PALETTE_GREY:
case VIDEO_PALETTE_RGB555:
@@ -1777,7 +1777,7 @@ w9968cf_set_picture(struct w9968cf_device* cam, struct video_picture pict)
}
/* NOTE: due to memory issues, it is better to disable the hardware
- double buffering during compression */
+ double buffering during compression */
if (cam->double_buffer && !(cam->vpp_flag & VPP_DECOMPRESSION))
reg_v |= 0x0080;
@@ -1832,8 +1832,8 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
#define __UNSC(x) ((x) >> 10)
/* Make sure we are using a supported resolution */
- if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
- (u16*)&win.height)))
+ if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
+ (u16*)&win.height)))
goto error;
/* Scaling factors */
@@ -1962,7 +1962,7 @@ w9968cf_set_window(struct w9968cf_device* cam, struct video_window win)
/* Settings changed, so we clear the frame buffers */
memset(cam->frame[0].buffer, 0, cam->nbuffers*cam->frame[0].size);
- DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)",
+ DBG(4, "The capture area is %dx%d, Offset (x,y)=(%u,%u)",
win.width, win.height, win.x, win.y)
PDBGG("x=%u ,y=%u, w=%u, h=%u, ax=%u, ay=%u, s_win.x=%u, s_win.y=%u, "
@@ -1978,11 +1978,11 @@ error:
}
-/*--------------------------------------------------------------------------
+/*--------------------------------------------------------------------------
Adjust the asked values for window width and height.
Return 0 on success, -1 otherwise.
--------------------------------------------------------------------------*/
-static int
+static int
w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
{
u16 maxw, maxh;
@@ -1992,10 +1992,10 @@ w9968cf_adjust_window_size(struct w9968cf_device* cam, u16* width, u16* height)
maxw = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
w9968cf_vpp ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
- : cam->maxwidth;
+ : cam->maxwidth;
maxh = cam->upscaling && !(cam->vpp_flag & VPP_DECOMPRESSION) &&
w9968cf_vpp ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
- : cam->maxheight;
+ : cam->maxheight;
if (*width > maxw)
*width = maxw;
@@ -2054,7 +2054,7 @@ static void w9968cf_push_frame(struct w9968cf_device* cam, u8 f_num)
Read, store and remove the first pointer in the FIFO list of requested
frames. This function is called in interrupt context.
--------------------------------------------------------------------------*/
-static void
+static void
w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
{
u8 i;
@@ -2078,9 +2078,9 @@ w9968cf_pop_frame(struct w9968cf_device* cam, struct w9968cf_frame_t** framep)
High-level video post-processing routine on grabbed frames.
Return 0 on success, a negative number otherwise.
--------------------------------------------------------------------------*/
-static int
-w9968cf_postprocess_frame(struct w9968cf_device* cam,
- struct w9968cf_frame_t* fr)
+static int
+w9968cf_postprocess_frame(struct w9968cf_device* cam,
+ struct w9968cf_frame_t* fr)
{
void *pIn = fr->buffer, *pOut = cam->frame_vpp.buffer, *tmp;
u16 w = cam->window.width,
@@ -2127,7 +2127,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
w9968cf_vpp->uyvy_to_rgbx(pIn, fr->length, pOut, fmt, rgb);
fr->length = (w*h*d)/8;
_PSWAP(pIn, pOut)
- DBG(6, "UYVY-16bit to %s conversion done",
+ DBG(6, "UYVY-16bit to %s conversion done",
symbolic(v4l1_plist, fmt))
}
@@ -2143,7 +2143,7 @@ w9968cf_postprocess_frame(struct w9968cf_device* cam,
* Image sensor control routines *
****************************************************************************/
-static int
+static int
w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
{
struct ovcamchip_control ctl;
@@ -2158,7 +2158,7 @@ w9968cf_sensor_set_control(struct w9968cf_device* cam, int cid, int val)
}
-static int
+static int
w9968cf_sensor_get_control(struct w9968cf_device* cam, int cid, int* val)
{
struct ovcamchip_control ctl;
@@ -2198,38 +2198,38 @@ static int w9968cf_sensor_update_settings(struct w9968cf_device* cam)
int err = 0;
/* Auto brightness */
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT,
- cam->auto_brt);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOBRIGHT,
+ cam->auto_brt);
if (err)
return err;
/* Auto exposure */
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP,
- cam->auto_exp);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_AUTOEXP,
+ cam->auto_exp);
if (err)
return err;
/* Banding filter */
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT,
- cam->bandfilt);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BANDFILT,
+ cam->bandfilt);
if (err)
return err;
/* Light frequency */
err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_FREQ,
- cam->lightfreq);
+ cam->lightfreq);
if (err)
return err;
/* Back light */
err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BACKLIGHT,
- cam->backlight);
+ cam->backlight);
if (err)
return err;
/* Mirror */
err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_MIRROR,
- cam->mirror);
+ cam->mirror);
if (err)
return err;
@@ -2281,15 +2281,15 @@ static int w9968cf_sensor_get_picture(struct w9968cf_device* cam)
Returns: 0 on success, a negative number otherwise.
--------------------------------------------------------------------------*/
static int
-w9968cf_sensor_update_picture(struct w9968cf_device* cam,
- struct video_picture pict)
+w9968cf_sensor_update_picture(struct w9968cf_device* cam,
+ struct video_picture pict)
{
int err = 0;
if ((!cam->sensor_initialized)
|| pict.contrast != cam->picture.contrast) {
err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_CONT,
- pict.contrast);
+ pict.contrast);
if (err)
goto fail;
DBG(4, "Contrast changed from %u to %u",
@@ -2297,10 +2297,10 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
cam->picture.contrast = pict.contrast;
}
- if (((!cam->sensor_initialized) ||
+ if (((!cam->sensor_initialized) ||
pict.brightness != cam->picture.brightness) && (!cam->auto_brt)) {
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT,
- pict.brightness);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_BRIGHT,
+ pict.brightness);
if (err)
goto fail;
DBG(4, "Brightness changed from %u to %u",
@@ -2309,8 +2309,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
}
if ((!cam->sensor_initialized) || pict.colour != cam->picture.colour) {
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT,
- pict.colour);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_SAT,
+ pict.colour);
if (err)
goto fail;
DBG(4, "Colour changed from %u to %u",
@@ -2319,8 +2319,8 @@ w9968cf_sensor_update_picture(struct w9968cf_device* cam,
}
if ((!cam->sensor_initialized) || pict.hue != cam->picture.hue) {
- err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE,
- pict.hue);
+ err = w9968cf_sensor_set_control(cam, OVCAMCHIP_CID_HUE,
+ pict.hue);
if (err)
goto fail;
DBG(4, "Hue changed from %u to %u",
@@ -2349,12 +2349,12 @@ static int w9968cf_sensor_init(struct w9968cf_device* cam)
{
int err = 0;
- if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE,
- &cam->monochrome)))
+ if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_INITIALIZE,
+ &cam->monochrome)))
goto error;
- if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE,
- &cam->sensor)))
+ if ((err = w9968cf_sensor_cmd(cam, OVCAMCHIP_CMD_Q_SUBTYPE,
+ &cam->sensor)))
goto error;
/* NOTE: Make sure width and height are a multiple of 16 */
@@ -2416,14 +2416,14 @@ error:
/*--------------------------------------------------------------------------
Fill some basic fields in the main device data structure.
- This function is called once on w9968cf_usb_probe() for each recognized
+ This function is called once on w9968cf_usb_probe() for each recognized
camera.
--------------------------------------------------------------------------*/
static void
w9968cf_configure_camera(struct w9968cf_device* cam,
- struct usb_device* udev,
- enum w9968cf_model_id mod_id,
- const unsigned short dev_nr)
+ struct usb_device* udev,
+ enum w9968cf_model_id mod_id,
+ const unsigned short dev_nr)
{
mutex_init(&cam->fileop_mutex);
init_waitqueue_head(&cam->open);
@@ -2444,60 +2444,60 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
packet_size[dev_nr] < wMaxPacketSize[cam->altsetting-1];
cam->altsetting++);
- cam->max_buffers = (max_buffers[dev_nr] < 2 ||
- max_buffers[dev_nr] > W9968CF_MAX_BUFFERS)
- ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr];
+ cam->max_buffers = (max_buffers[dev_nr] < 2 ||
+ max_buffers[dev_nr] > W9968CF_MAX_BUFFERS)
+ ? W9968CF_BUFFERS : (u8)max_buffers[dev_nr];
- cam->double_buffer = (double_buffer[dev_nr] == 0 ||
- double_buffer[dev_nr] == 1)
- ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER;
+ cam->double_buffer = (double_buffer[dev_nr] == 0 ||
+ double_buffer[dev_nr] == 1)
+ ? (u8)double_buffer[dev_nr]:W9968CF_DOUBLE_BUFFER;
cam->clamping = (clamping[dev_nr] == 0 || clamping[dev_nr] == 1)
- ? (u8)clamping[dev_nr] : W9968CF_CLAMPING;
-
+ ? (u8)clamping[dev_nr] : W9968CF_CLAMPING;
+
cam->filter_type = (filter_type[dev_nr] == 0 ||
- filter_type[dev_nr] == 1 ||
- filter_type[dev_nr] == 2)
- ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE;
+ filter_type[dev_nr] == 1 ||
+ filter_type[dev_nr] == 2)
+ ? (u8)filter_type[dev_nr] : W9968CF_FILTER_TYPE;
cam->capture = 1;
cam->largeview = (largeview[dev_nr] == 0 || largeview[dev_nr] == 1)
- ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW;
+ ? (u8)largeview[dev_nr] : W9968CF_LARGEVIEW;
- cam->decompression = (decompression[dev_nr] == 0 ||
- decompression[dev_nr] == 1 ||
- decompression[dev_nr] == 2)
- ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION;
+ cam->decompression = (decompression[dev_nr] == 0 ||
+ decompression[dev_nr] == 1 ||
+ decompression[dev_nr] == 2)
+ ? (u8)decompression[dev_nr]:W9968CF_DECOMPRESSION;
- cam->upscaling = (upscaling[dev_nr] == 0 ||
- upscaling[dev_nr] == 1)
- ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING;
+ cam->upscaling = (upscaling[dev_nr] == 0 ||
+ upscaling[dev_nr] == 1)
+ ? (u8)upscaling[dev_nr] : W9968CF_UPSCALING;
cam->auto_brt = (autobright[dev_nr] == 0 || autobright[dev_nr] == 1)
- ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT;
+ ? (u8)autobright[dev_nr] : W9968CF_AUTOBRIGHT;
cam->auto_exp = (autoexp[dev_nr] == 0 || autoexp[dev_nr] == 1)
- ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP;
+ ? (u8)autoexp[dev_nr] : W9968CF_AUTOEXP;
cam->lightfreq = (lightfreq[dev_nr] == 50 || lightfreq[dev_nr] == 60)
- ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ;
+ ? (u8)lightfreq[dev_nr] : W9968CF_LIGHTFREQ;
- cam->bandfilt = (bandingfilter[dev_nr] == 0 ||
- bandingfilter[dev_nr] == 1)
- ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER;
+ cam->bandfilt = (bandingfilter[dev_nr] == 0 ||
+ bandingfilter[dev_nr] == 1)
+ ? (u8)bandingfilter[dev_nr] : W9968CF_BANDINGFILTER;
cam->backlight = (backlight[dev_nr] == 0 || backlight[dev_nr] == 1)
- ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT;
+ ? (u8)backlight[dev_nr] : W9968CF_BACKLIGHT;
cam->clockdiv = (clockdiv[dev_nr] == -1 || clockdiv[dev_nr] >= 0)
- ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV;
+ ? (s8)clockdiv[dev_nr] : W9968CF_CLOCKDIV;
cam->mirror = (mirror[dev_nr] == 0 || mirror[dev_nr] == 1)
- ? (u8)mirror[dev_nr] : W9968CF_MIRROR;
+ ? (u8)mirror[dev_nr] : W9968CF_MIRROR;
cam->monochrome = (monochrome[dev_nr] == 0 || monochrome[dev_nr] == 1)
- ? monochrome[dev_nr] : W9968CF_MONOCHROME;
+ ? monochrome[dev_nr] : W9968CF_MONOCHROME;
cam->picture.brightness = (u16)brightness[dev_nr];
cam->picture.hue = (u16)hue[dev_nr];
@@ -2519,7 +2519,7 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
cam->picture.depth = w9968cf_valid_depth(cam->picture.palette);
cam->force_rgb = (force_rgb[dev_nr] == 0 || force_rgb[dev_nr] == 1)
- ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB;
+ ? (u8)force_rgb[dev_nr] : W9968CF_FORCE_RGB;
cam->window.x = 0;
cam->window.y = 0;
@@ -2531,16 +2531,16 @@ w9968cf_configure_camera(struct w9968cf_device* cam,
DBG(3, "%s configured with settings #%u:",
symbolic(camlist, cam->id), dev_nr)
-
+
DBG(3, "- Data packet size for USB isochrnous transfer: %u bytes",
wMaxPacketSize[cam->altsetting-1])
-
+
DBG(3, "- Number of requested video frame buffers: %u",
cam->max_buffers)
if (cam->double_buffer)
DBG(3, "- Hardware double buffering enabled")
- else
+ else
DBG(3, "- Hardware double buffering disabled")
if (cam->filter_type == 0)
@@ -2648,7 +2648,7 @@ static void w9968cf_adjust_configuration(struct w9968cf_device* cam)
/*--------------------------------------------------------------------------
Release the resources used by the driver.
- This function is called on disconnect
+ This function is called on disconnect
(or on close if deallocation has been deferred)
--------------------------------------------------------------------------*/
static void w9968cf_release_resources(struct w9968cf_device* cam)
@@ -2706,8 +2706,8 @@ static int w9968cf_open(struct inode* inode, struct file* filp)
}
mutex_unlock(&cam->dev_mutex);
err = wait_event_interruptible_exclusive(cam->open,
- cam->disconnected ||
- !cam->users);
+ cam->disconnected ||
+ !cam->users);
if (err) {
up_read(&w9968cf_disconnect);
return err;
@@ -2820,9 +2820,9 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
w9968cf_push_frame(cam, 1);
err = wait_event_interruptible(cam->wait_queue,
- cam->frame[0].status == F_READY ||
- cam->frame[1].status == F_READY ||
- cam->disconnected);
+ cam->frame[0].status == F_READY ||
+ cam->frame[1].status == F_READY ||
+ cam->disconnected);
if (err) {
mutex_unlock(&cam->fileop_mutex);
return err;
@@ -2859,12 +2859,12 @@ w9968cf_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
{
struct w9968cf_device* cam = (struct w9968cf_device*)
- video_get_drvdata(video_devdata(filp));
+ video_get_drvdata(video_devdata(filp));
unsigned long vsize = vma->vm_end - vma->vm_start,
- psize = cam->nbuffers * cam->frame[0].size,
- start = vma->vm_start,
- pos = (unsigned long)cam->frame[0].buffer,
- page;
+ psize = cam->nbuffers * cam->frame[0].size,
+ start = vma->vm_start,
+ pos = (unsigned long)cam->frame[0].buffer,
+ page;
if (cam->disconnected) {
DBG(2, "Device not present")
@@ -2898,7 +2898,7 @@ static int w9968cf_mmap(struct file* filp, struct vm_area_struct *vma)
static int
w9968cf_ioctl(struct inode* inode, struct file* filp,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct w9968cf_device* cam;
int err;
@@ -2928,21 +2928,21 @@ w9968cf_ioctl(struct inode* inode, struct file* filp,
static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
- unsigned int cmd, void __user * arg)
+ unsigned int cmd, void __user * arg)
{
struct w9968cf_device* cam;
const char* v4l1_ioctls[] = {
- "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER",
+ "?", "CGAP", "GCHAN", "SCHAN", "GTUNER", "STUNER",
"GPICT", "SPICT", "CCAPTURE", "GWIN", "SWIN", "GFBUF",
"SFBUF", "KEY", "GFREQ", "SFREQ", "GAUDIO", "SAUDIO",
"SYNC", "MCAPTURE", "GMBUF", "GUNIT", "GCAPTURE", "SCAPTURE",
- "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE",
- "GVBIFMT", "SVBIFMT"
+ "SPLAYMODE", "SWRITEMODE", "GPLAYINFO", "SMICROCODE",
+ "GVBIFMT", "SVBIFMT"
};
#define V4L1_IOCTL(cmd) \
- ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
- v4l1_ioctls[_IOC_NR((cmd))] : "?")
+ ((_IOC_NR((cmd)) < ARRAY_SIZE(v4l1_ioctls)) ? \
+ v4l1_ioctls[_IOC_NR((cmd))] : "?")
cam = (struct w9968cf_device*)video_get_drvdata(video_devdata(filp));
@@ -2957,14 +2957,14 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
.minwidth = cam->minwidth,
.minheight = cam->minheight,
};
- sprintf(cap.name, "W996[87]CF USB Camera #%d",
- cam->v4ldev->minor);
+ sprintf(cap.name, "W996[87]CF USB Camera #%d",
+ cam->v4ldev->minor);
cap.maxwidth = (cam->upscaling && w9968cf_vpp)
- ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
- : cam->maxwidth;
+ ? max((u16)W9968CF_MAX_WIDTH, cam->maxwidth)
+ : cam->maxwidth;
cap.maxheight = (cam->upscaling && w9968cf_vpp)
- ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
- : cam->maxheight;
+ ? max((u16)W9968CF_MAX_HEIGHT, cam->maxheight)
+ : cam->maxheight;
if (copy_to_user(arg, &cap, sizeof(cap)))
return -EFAULT;
@@ -3029,7 +3029,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
if (copy_from_user(&pict, arg, sizeof(pict)))
return -EFAULT;
- if ( (cam->force_palette || !w9968cf_vpp)
+ if ( (cam->force_palette || !w9968cf_vpp)
&& pict.palette != cam->picture.palette ) {
DBG(4, "Palette %s rejected: only %s is allowed",
symbolic(v4l1_plist, pict.palette),
@@ -3046,24 +3046,24 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
if (!cam->force_palette) {
if (cam->decompression == 0) {
if (w9968cf_need_decompression(pict.palette)) {
- DBG(4, "Decompression disabled: palette %s is not "
- "allowed. VIDIOCSPICT failed",
- symbolic(v4l1_plist, pict.palette))
- return -EINVAL;
+ DBG(4, "Decompression disabled: palette %s is not "
+ "allowed. VIDIOCSPICT failed",
+ symbolic(v4l1_plist, pict.palette))
+ return -EINVAL;
}
} else if (cam->decompression == 1) {
if (!w9968cf_need_decompression(pict.palette)) {
- DBG(4, "Decompression forced: palette %s is not "
- "allowed. VIDIOCSPICT failed",
- symbolic(v4l1_plist, pict.palette))
- return -EINVAL;
+ DBG(4, "Decompression forced: palette %s is not "
+ "allowed. VIDIOCSPICT failed",
+ symbolic(v4l1_plist, pict.palette))
+ return -EINVAL;
}
}
}
if (pict.depth != w9968cf_valid_depth(pict.palette)) {
DBG(4, "Requested depth %u bpp is not valid for %s "
- "palette: ignored and changed to %u bpp",
+ "palette: ignored and changed to %u bpp",
pict.depth, symbolic(v4l1_plist, pict.palette),
w9968cf_valid_depth(pict.palette))
pict.depth = w9968cf_valid_depth(pict.palette);
@@ -3074,9 +3074,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
|| cam->frame_current->queued) {
err = wait_event_interruptible
( cam->wait_queue,
- cam->disconnected ||
- (!*cam->requested_frame &&
- !cam->frame_current->queued) );
+ cam->disconnected ||
+ (!*cam->requested_frame &&
+ !cam->frame_current->queued) );
if (err)
return err;
if (cam->disconnected)
@@ -3116,7 +3116,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
return -EINVAL;
if ((err = w9968cf_adjust_window_size(cam, (u16*)&win.width,
- (u16*)&win.height))) {
+ (u16*)&win.height))) {
DBG(4, "Resolution not supported (%ux%u). "
"VIDIOCSWIN failed", win.width, win.height)
return err;
@@ -3130,9 +3130,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
|| cam->frame_current->queued) {
err = wait_event_interruptible
( cam->wait_queue,
- cam->disconnected ||
- (!*cam->requested_frame &&
- !cam->frame_current->queued) );
+ cam->disconnected ||
+ (!*cam->requested_frame &&
+ !cam->frame_current->queued) );
if (err)
return err;
if (cam->disconnected)
@@ -3175,7 +3175,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
mbuf.frames = cam->nbuffers;
for (i = 0; i < cam->nbuffers; i++)
mbuf.offsets[i] = (unsigned long)cam->frame[i].buffer -
- (unsigned long)cam->frame[0].buffer;
+ (unsigned long)cam->frame[0].buffer;
if (copy_to_user(arg, &mbuf, sizeof(mbuf)))
return -EFAULT;
@@ -3194,7 +3194,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
return -EFAULT;
DBG(6, "VIDIOCMCAPTURE called: frame #%u, format=%s, %dx%d",
- mmap.frame, symbolic(v4l1_plist, mmap.format),
+ mmap.frame, symbolic(v4l1_plist, mmap.format),
mmap.width, mmap.height)
if (mmap.frame >= cam->nbuffers) {
@@ -3203,7 +3203,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
return -EINVAL;
}
- if (mmap.format!=cam->picture.palette &&
+ if (mmap.format!=cam->picture.palette &&
(cam->force_palette || !w9968cf_vpp)) {
DBG(4, "Palette %s rejected: only %s is allowed",
symbolic(v4l1_plist, mmap.format),
@@ -3213,7 +3213,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
if (!w9968cf_valid_palette(mmap.format)) {
DBG(4, "Palette %s not supported. "
- "VIDIOCMCAPTURE failed",
+ "VIDIOCMCAPTURE failed",
symbolic(v4l1_plist, mmap.format))
return -EINVAL;
}
@@ -3221,23 +3221,23 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
if (!cam->force_palette) {
if (cam->decompression == 0) {
if (w9968cf_need_decompression(mmap.format)) {
- DBG(4, "Decompression disabled: palette %s is not "
- "allowed. VIDIOCSPICT failed",
- symbolic(v4l1_plist, mmap.format))
- return -EINVAL;
+ DBG(4, "Decompression disabled: palette %s is not "
+ "allowed. VIDIOCSPICT failed",
+ symbolic(v4l1_plist, mmap.format))
+ return -EINVAL;
}
} else if (cam->decompression == 1) {
if (!w9968cf_need_decompression(mmap.format)) {
- DBG(4, "Decompression forced: palette %s is not "
- "allowed. VIDIOCSPICT failed",
- symbolic(v4l1_plist, mmap.format))
- return -EINVAL;
+ DBG(4, "Decompression forced: palette %s is not "
+ "allowed. VIDIOCSPICT failed",
+ symbolic(v4l1_plist, mmap.format))
+ return -EINVAL;
}
}
}
- if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width,
- (u16*)&mmap.height))) {
+ if ((err = w9968cf_adjust_window_size(cam, (u16*)&mmap.width,
+ (u16*)&mmap.height))) {
DBG(4, "Resolution not supported (%dx%d). "
"VIDIOCMCAPTURE failed",
mmap.width, mmap.height)
@@ -3258,12 +3258,12 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
DBG(6, "VIDIOCMCAPTURE. Change settings for "
"frame #%u: %dx%d, format %s. Wait...",
mmap.frame, mmap.width, mmap.height,
- symbolic(v4l1_plist, mmap.format))
+ symbolic(v4l1_plist, mmap.format))
err = wait_event_interruptible
( cam->wait_queue,
- cam->disconnected ||
- (!*cam->requested_frame &&
- !cam->frame_current->queued) );
+ cam->disconnected ||
+ (!*cam->requested_frame &&
+ !cam->frame_current->queued) );
if (err)
return err;
if (cam->disconnected)
@@ -3280,7 +3280,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
goto ioctl_fail;
/* This before set_window */
- if (w9968cf_set_picture(cam, pict))
+ if (w9968cf_set_picture(cam, pict))
goto ioctl_fail;
if (w9968cf_set_window(cam, win))
@@ -3292,10 +3292,10 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
} else if (fr->queued) {
DBG(6, "Wait until frame #%u is free", mmap.frame)
-
- err = wait_event_interruptible(cam->wait_queue,
- cam->disconnected ||
- (!fr->queued));
+
+ err = wait_event_interruptible(cam->wait_queue,
+ cam->disconnected ||
+ (!fr->queued));
if (err)
return err;
if (cam->disconnected)
@@ -3335,9 +3335,9 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
}
case F_ERROR:
case F_GRABBING:
- err = wait_event_interruptible(cam->wait_queue,
- (fr->status == F_READY)
- || cam->disconnected);
+ err = wait_event_interruptible(cam->wait_queue,
+ (fr->status == F_READY)
+ || cam->disconnected);
if (err)
return err;
if (cam->disconnected)
@@ -3439,7 +3439,7 @@ static int w9968cf_v4l_ioctl(struct inode* inode, struct file* filp,
DBG(4, "Unsupported V4L1 IOCtl: VIDIOC%s "
"(type 0x%01X, "
"n. 0x%01X, "
- "dir. 0x%01X, "
+ "dir. 0x%01X, "
"size 0x%02X)",
V4L1_IOCTL(cmd),
_IOC_TYPE(cmd),_IOC_NR(cmd),_IOC_DIR(cmd),_IOC_SIZE(cmd))
@@ -3499,13 +3499,13 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[0].idProduct)
mod_id = W9968CF_MOD_CLVBWGP; /* see camlist[] table */
else if (le16_to_cpu(udev->descriptor.idVendor) == winbond_id_table[1].idVendor &&
- le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)
+ le16_to_cpu(udev->descriptor.idProduct) == winbond_id_table[1].idProduct)
mod_id = W9968CF_MOD_GENERIC; /* see camlist[] table */
else
return -ENODEV;
cam = (struct w9968cf_device*)
- kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL);
+ kzalloc(sizeof(struct w9968cf_device), GFP_KERNEL);
if (!cam)
return -ENOMEM;
@@ -3569,7 +3569,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
cam->v4ldev->dev = &cam->dev;
err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
- video_nr[dev_nr]);
+ video_nr[dev_nr]);
if (err) {
DBG(1, "V4L device registration failed")
if (err == -ENFILE && video_nr[dev_nr] == -1)
@@ -3611,7 +3611,7 @@ fail: /* Free unused memory */
static void w9968cf_usb_disconnect(struct usb_interface* intf)
{
- struct w9968cf_device* cam =
+ struct w9968cf_device* cam =
(struct w9968cf_device*)usb_get_intfdata(intf);
down_write(&w9968cf_disconnect);
diff --git a/drivers/usb/media/w9968cf.h b/drivers/media/video/w9968cf.h
index a87be719a28..2836b45ec20 100644
--- a/drivers/usb/media/w9968cf.h
+++ b/drivers/media/video/w9968cf.h
@@ -61,7 +61,7 @@
/* Maximum data payload sizes in bytes for alternate settings */
static const u16 wMaxPacketSize[] = {1023, 959, 895, 831, 767, 703, 639, 575,
- 511, 447, 383, 319, 255, 191, 127, 63};
+ 511, 447, 383, 319, 255, 191, 127, 63};
#define W9968CF_PACKET_SIZE 1023 /* according to wMaxPacketSizes[] */
#define W9968CF_MIN_PACKET_SIZE 63 /* minimum value */
#define W9968CF_ISO_PACKETS 5 /* n.of packets for isochronous transfers */
@@ -134,7 +134,7 @@ static const struct w9968cf_format w9968cf_formatlist[] = {
****************************************************************************/
#define W9968CF_MODULE_NAME "V4L driver for W996[87]CF JPEG USB " \
- "Dual Mode Camera Chip"
+ "Dual Mode Camera Chip"
#define W9968CF_MODULE_VERSION "1:1.33-basic"
#define W9968CF_MODULE_AUTHOR "(C) 2002-2004 Luca Risolia"
#define W9968CF_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
@@ -270,9 +270,9 @@ struct w9968cf_device {
/* Locks */
struct mutex dev_mutex, /* for probe, disconnect,open and close */
- fileop_mutex; /* for read and ioctl */
+ fileop_mutex; /* for read and ioctl */
spinlock_t urb_lock, /* for submit_urb() and unlink_urb() */
- flist_lock; /* for requested frame list accesses */
+ flist_lock; /* for requested frame list accesses */
wait_queue_head_t open, wait_queue;
char command[16]; /* name of the program holding the device */
@@ -299,7 +299,7 @@ struct w9968cf_device {
dev_warn(&cam->dev, fmt "\n", ## args); \
else if ((level) >= 5) \
dev_info(&cam->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args); \
+ __FUNCTION__, __LINE__ , ## args); \
} \
}
/* For generic kernel (not device specific) messages */
@@ -311,7 +311,7 @@ struct w9968cf_device {
pr_info("w9968cf: " fmt "\n", ## args); \
else if ((level) >= 5) \
pr_debug("w9968cf: [%s:%d] " fmt "\n", __FUNCTION__, \
- __LINE__ , ## args); \
+ __LINE__ , ## args); \
} \
}
#else
diff --git a/drivers/usb/media/w9968cf_decoder.h b/drivers/media/video/w9968cf_decoder.h
index 31faccbe8f0..59decbfc540 100644
--- a/drivers/usb/media/w9968cf_decoder.h
+++ b/drivers/media/video/w9968cf_decoder.h
@@ -78,9 +78,9 @@ static const unsigned char UV_QUANTABLE[64] = {
#define W9968CF_DEC_ERR_NO_EOI -6
extern void w9968cf_init_decoder(void);
-extern int w9968cf_check_headers(const unsigned char* Pin,
- const unsigned long BUF_SIZE);
-extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
- const unsigned W, const unsigned H, char* Pout);
+extern int w9968cf_check_headers(const unsigned char* Pin,
+ const unsigned long BUF_SIZE);
+extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
+ const unsigned W, const unsigned H, char* Pout);
#endif /* _W9968CF_DECODER_H_ */
diff --git a/drivers/usb/media/w9968cf_vpp.h b/drivers/media/video/w9968cf_vpp.h
index f3b91b78267..88c9b6c0cc3 100644
--- a/drivers/usb/media/w9968cf_vpp.h
+++ b/drivers/media/video/w9968cf_vpp.h
@@ -29,7 +29,7 @@ struct w9968cf_vpp_t {
struct module* owner;
int (*check_headers)(const unsigned char*, const unsigned long);
int (*decode)(const char*, const unsigned long, const unsigned,
- const unsigned, char*);
+ const unsigned, char*);
void (*swap_yuvbytes)(void*, unsigned long);
void (*uyvy_to_rgbx)(u8*, unsigned long, u8*, u16, u8);
void (*scale_up)(u8*, u8*, u16, u16, u16, u16, u16);
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index 8cb64f8a8a9..d81a88bbe43 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -79,21 +79,26 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
void *arg)
{
struct wm8775_state *state = i2c_get_clientdata(client);
- struct v4l2_audio *input = arg;
+ struct v4l2_routing *route = arg;
struct v4l2_control *ctrl = arg;
switch (cmd) {
- case VIDIOC_S_AUDIO:
+ case VIDIOC_INT_G_AUDIO_ROUTING:
+ route->input = state->input;
+ route->output = 0;
+ break;
+
+ case VIDIOC_INT_S_AUDIO_ROUTING:
/* There are 4 inputs and one output. Zero or more inputs
are multiplexed together to the output. Hence there are
16 combinations.
If only one input is active (the normal case) then the
input values 1, 2, 4 or 8 should be used. */
- if (input->index > 15) {
- v4l_err(client, "Invalid input %d.\n", input->index);
+ if (route->input > 15) {
+ v4l_err(client, "Invalid input %d.\n", route->input);
return -EINVAL;
}
- state->input = input->index;
+ state->input = route->input;
if (state->muted)
break;
wm8775_write(client, R21, 0x0c0);
@@ -102,11 +107,6 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
wm8775_write(client, R21, 0x100 + state->input);
break;
- case VIDIOC_G_AUDIO:
- memset(input, 0, sizeof(*input));
- input->index = state->input;
- break;
-
case VIDIOC_G_CTRL:
if (ctrl->id != V4L2_CID_AUDIO_MUTE)
return -EINVAL;
diff --git a/drivers/media/video/zc0301/Makefile b/drivers/media/video/zc0301/Makefile
new file mode 100644
index 00000000000..d749199d8f0
--- /dev/null
+++ b/drivers/media/video/zc0301/Makefile
@@ -0,0 +1,3 @@
+zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
+
+obj-$(CONFIG_USB_ZC0301) += zc0301.o
diff --git a/drivers/usb/media/zc0301.h b/drivers/media/video/zc0301/zc0301.h
index 8e0655140e6..b9c93b8c16f 100644
--- a/drivers/usb/media/zc0301.h
+++ b/drivers/media/video/zc0301/zc0301.h
@@ -157,7 +157,7 @@ do { \
dev_info(&cam->usbdev->dev, fmt "\n", ## args); \
else if ((level) >= 3) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args); \
+ __FUNCTION__, __LINE__ , ## args); \
} \
} while (0)
# define KDBG(level, fmt, args...) \
@@ -167,7 +167,7 @@ do { \
pr_info("zc0301: " fmt "\n", ## args); \
else if ((level) == 3) \
pr_debug("zc0301: [%s:%d] " fmt "\n", __FUNCTION__, \
- __LINE__ , ## args); \
+ __LINE__ , ## args); \
} \
} while (0)
# define V4LDBG(level, name, cmd) \
@@ -184,7 +184,7 @@ do { \
#undef PDBG
#define PDBG(fmt, args...) \
dev_info(&cam->usbdev->dev, "[%s:%d] " fmt "\n", \
- __FUNCTION__, __LINE__ , ## args)
+ __FUNCTION__, __LINE__ , ## args)
#undef PDBGG
#define PDBGG(fmt, args...) do {;} while(0) /* placeholder */
diff --git a/drivers/usb/media/zc0301_core.c b/drivers/media/video/zc0301/zc0301_core.c
index 4036c6268bf..0fad39754f7 100644
--- a/drivers/usb/media/zc0301_core.c
+++ b/drivers/media/video/zc0301/zc0301_core.c
@@ -48,7 +48,7 @@
/*****************************************************************************/
#define ZC0301_MODULE_NAME "V4L2 driver for ZC0301 " \
- "Image Processor and Control Chip"
+ "Image Processor and Control Chip"
#define ZC0301_MODULE_AUTHOR "(C) 2006 Luca Risolia"
#define ZC0301_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>"
#define ZC0301_MODULE_LICENSE "GPL"
@@ -67,67 +67,67 @@ MODULE_LICENSE(ZC0301_MODULE_LICENSE);
static short video_nr[] = {[0 ... ZC0301_MAX_DEVICES-1] = -1};
module_param_array(video_nr, short, NULL, 0444);
MODULE_PARM_DESC(video_nr,
- "\n<-1|n[,...]> Specify V4L2 minor mode number."
- "\n -1 = use next available (default)"
- "\n n = use minor number n (integer >= 0)"
- "\nYou can specify up to "
- __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way."
- "\nFor example:"
- "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
- "\nthe second registered camera and use auto for the first"
- "\none and for every other camera."
- "\n");
+ "\n<-1|n[,...]> Specify V4L2 minor mode number."
+ "\n -1 = use next available (default)"
+ "\n n = use minor number n (integer >= 0)"
+ "\nYou can specify up to "
+ __MODULE_STRING(ZC0301_MAX_DEVICES) " cameras this way."
+ "\nFor example:"
+ "\nvideo_nr=-1,2,-1 would assign minor number 2 to"
+ "\nthe second registered camera and use auto for the first"
+ "\none and for every other camera."
+ "\n");
static short force_munmap[] = {[0 ... ZC0301_MAX_DEVICES-1] =
- ZC0301_FORCE_MUNMAP};
+ ZC0301_FORCE_MUNMAP};
module_param_array(force_munmap, bool, NULL, 0444);
MODULE_PARM_DESC(force_munmap,
- "\n<0|1[,...]> Force the application to unmap previously"
- "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
- "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
- "\nthis feature. This parameter is specific for each"
- "\ndetected camera."
- "\n 0 = do not force memory unmapping"
- "\n 1 = force memory unmapping (save memory)"
- "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
- "\n");
+ "\n<0|1[,...]> Force the application to unmap previously"
+ "\nmapped buffer memory before calling any VIDIOC_S_CROP or"
+ "\nVIDIOC_S_FMT ioctl's. Not all the applications support"
+ "\nthis feature. This parameter is specific for each"
+ "\ndetected camera."
+ "\n 0 = do not force memory unmapping"
+ "\n 1 = force memory unmapping (save memory)"
+ "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"."
+ "\n");
static unsigned int frame_timeout[] = {[0 ... ZC0301_MAX_DEVICES-1] =
- ZC0301_FRAME_TIMEOUT};
+ ZC0301_FRAME_TIMEOUT};
module_param_array(frame_timeout, uint, NULL, 0644);
MODULE_PARM_DESC(frame_timeout,
- "\n<n[,...]> Timeout for a video frame in seconds."
- "\nThis parameter is specific for each detected camera."
- "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"."
- "\n");
+ "\n<n[,...]> Timeout for a video frame in seconds."
+ "\nThis parameter is specific for each detected camera."
+ "\nDefault value is "__MODULE_STRING(ZC0301_FRAME_TIMEOUT)"."
+ "\n");
#ifdef ZC0301_DEBUG
static unsigned short debug = ZC0301_DEBUG_LEVEL;
module_param(debug, ushort, 0644);
MODULE_PARM_DESC(debug,
- "\n<n> Debugging information level, from 0 to 3:"
- "\n0 = none (use carefully)"
- "\n1 = critical errors"
- "\n2 = significant informations"
- "\n3 = more verbose messages"
- "\nLevel 3 is useful for testing only, when only "
- "one device is used."
- "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"."
- "\n");
+ "\n<n> Debugging information level, from 0 to 3:"
+ "\n0 = none (use carefully)"
+ "\n1 = critical errors"
+ "\n2 = significant informations"
+ "\n3 = more verbose messages"
+ "\nLevel 3 is useful for testing only, when only "
+ "one device is used."
+ "\nDefault value is "__MODULE_STRING(ZC0301_DEBUG_LEVEL)"."
+ "\n");
#endif
/*****************************************************************************/
static u32
zc0301_request_buffers(struct zc0301_device* cam, u32 count,
- enum zc0301_io_method io)
+ enum zc0301_io_method io)
{
struct v4l2_pix_format* p = &(cam->sensor.pix_format);
struct v4l2_rect* r = &(cam->sensor.cropcap.bounds);
const size_t imagesize = cam->module_param.force_munmap ||
- io == IO_READ ?
- (p->width * p->height * p->priv) / 8 :
- (r->width * r->height * p->priv) / 8;
+ io == IO_READ ?
+ (p->width * p->height * p->priv) / 8 :
+ (r->width * r->height * p->priv) / 8;
void* buff = NULL;
u32 i;
@@ -216,7 +216,7 @@ int zc0301_write_reg(struct zc0301_device* cam, u16 index, u16 value)
int res;
res = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0xa0, 0x40,
- value, index, NULL, 0, ZC0301_CTRL_TIMEOUT);
+ value, index, NULL, 0, ZC0301_CTRL_TIMEOUT);
if (res < 0) {
DBG(3, "Failed to write a register (index 0x%04X, "
"value 0x%02X, error %d)",index, value, res);
@@ -234,7 +234,7 @@ int zc0301_read_reg(struct zc0301_device* cam, u16 index)
int res;
res = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xa1, 0xc0,
- 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT);
+ 0x0001, index, buff, 1, ZC0301_CTRL_TIMEOUT);
if (res < 0)
DBG(3, "Failed to read a register (index 0x%04X, error %d)",
index, res);
@@ -337,11 +337,11 @@ static void zc0301_urb_complete(struct urb *urb, struct pt_regs* regs)
if (!(*f))
(*f) = list_entry(cam->inqueue.next, struct zc0301_frame_t,
- frame);
+ frame);
imagesize = (cam->sensor.pix_format.width *
- cam->sensor.pix_format.height *
- cam->sensor.pix_format.priv) / 8;
+ cam->sensor.pix_format.height *
+ cam->sensor.pix_format.priv) / 8;
for (i = 0; i < urb->number_of_packets; i++) {
unsigned int len, status;
@@ -395,8 +395,8 @@ end_of_frame:
list_move_tail(&(*f)->frame, &cam->outqueue);
if (!list_empty(&cam->inqueue))
(*f) = list_entry(cam->inqueue.next,
- struct zc0301_frame_t,
- frame);
+ struct zc0301_frame_t,
+ frame);
else
(*f) = NULL;
spin_unlock(&cam->queue_lock);
@@ -429,14 +429,14 @@ static int zc0301_start_transfer(struct zc0301_device* cam)
struct usb_device *udev = cam->usbdev;
struct urb* urb;
const unsigned int wMaxPacketSize[] = {0, 128, 192, 256, 384,
- 512, 768, 1023};
+ 512, 768, 1023};
const unsigned int psz = wMaxPacketSize[ZC0301_ALTERNATE_SETTING];
s8 i, j;
int err = 0;
for (i = 0; i < ZC0301_URBS; i++) {
cam->transfer_buffer[i] = kzalloc(ZC0301_ISO_PACKETS * psz,
- GFP_KERNEL);
+ GFP_KERNEL);
if (!cam->transfer_buffer[i]) {
err = -ENOMEM;
DBG(1, "Not enough memory");
@@ -528,9 +528,9 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
cam->stream = STREAM_INTERRUPT;
timeout = wait_event_timeout(cam->wait_stream,
- (cam->stream == STREAM_OFF) ||
- (cam->state & DEV_DISCONNECTED),
- ZC0301_URB_TIMEOUT);
+ (cam->stream == STREAM_OFF) ||
+ (cam->state & DEV_DISCONNECTED),
+ ZC0301_URB_TIMEOUT);
if (cam->state & DEV_DISCONNECTED)
return -ENODEV;
else if (cam->stream != STREAM_OFF) {
@@ -548,7 +548,7 @@ static int zc0301_stream_interrupt(struct zc0301_device* cam)
static int
zc0301_set_compression(struct zc0301_device* cam,
- struct v4l2_jpegcompression* compression)
+ struct v4l2_jpegcompression* compression)
{
int r, err = 0;
@@ -670,8 +670,8 @@ static int zc0301_open(struct inode* inode, struct file* filp)
}
mutex_unlock(&cam->dev_mutex);
err = wait_event_interruptible_exclusive(cam->open,
- cam->state & DEV_DISCONNECTED
- || !cam->users);
+ cam->state & DEV_DISCONNECTED
+ || !cam->users);
if (err) {
up_read(&zc0301_disconnect);
return err;
@@ -802,12 +802,12 @@ zc0301_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos)
return -EAGAIN;
}
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0) {
mutex_unlock(&cam->fileop_mutex);
return timeout;
@@ -930,7 +930,7 @@ static int zc0301_mmap(struct file* filp, struct vm_area_struct *vma)
{
struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
unsigned long size = vma->vm_end - vma->vm_start,
- start = vma->vm_start;
+ start = vma->vm_start;
void *pos;
u32 i;
@@ -998,13 +998,13 @@ zc0301_vidioc_querycap(struct zc0301_device* cam, void __user * arg)
.driver = "zc0301",
.version = ZC0301_MODULE_VERSION_CODE,
.capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_READWRITE |
- V4L2_CAP_STREAMING,
+ V4L2_CAP_STREAMING,
};
strlcpy(cap.card, cam->v4ldev->name, sizeof(cap.card));
if (usb_make_path(cam->usbdev, cap.bus_info, sizeof(cap.bus_info)) < 0)
strlcpy(cap.bus_info, cam->usbdev->dev.bus_id,
- sizeof(cap.bus_info));
+ sizeof(cap.bus_info));
if (copy_to_user(arg, &cap, sizeof(cap)))
return -EFAULT;
@@ -1337,7 +1337,7 @@ zc0301_vidioc_g_fmt(struct zc0301_device* cam, void __user * arg)
static int
zc0301_vidioc_try_s_fmt(struct zc0301_device* cam, unsigned int cmd,
- void __user * arg)
+ void __user * arg)
{
struct zc0301_sensor* s = &cam->sensor;
struct v4l2_format format;
@@ -1600,7 +1600,7 @@ zc0301_vidioc_qbuf(struct zc0301_device* cam, void __user * arg)
static int
zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
- void __user * arg)
+ void __user * arg)
{
struct v4l2_buffer b;
struct zc0301_frame_t *f;
@@ -1619,12 +1619,12 @@ zc0301_vidioc_dqbuf(struct zc0301_device* cam, struct file* filp,
if (filp->f_flags & O_NONBLOCK)
return -EAGAIN;
timeout = wait_event_interruptible_timeout
- ( cam->wait_frame,
- (!list_empty(&cam->outqueue)) ||
- (cam->state & DEV_DISCONNECTED) ||
- (cam->state & DEV_MISCONFIGURED),
- cam->module_param.frame_timeout *
- 1000 * msecs_to_jiffies(1) );
+ ( cam->wait_frame,
+ (!list_empty(&cam->outqueue)) ||
+ (cam->state & DEV_DISCONNECTED) ||
+ (cam->state & DEV_MISCONFIGURED),
+ cam->module_param.frame_timeout *
+ 1000 * msecs_to_jiffies(1) );
if (timeout < 0)
return timeout;
if (cam->state & DEV_DISCONNECTED)
@@ -1748,7 +1748,7 @@ zc0301_vidioc_s_parm(struct zc0301_device* cam, void __user * arg)
static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
- unsigned int cmd, void __user * arg)
+ unsigned int cmd, void __user * arg)
{
struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
@@ -1842,7 +1842,7 @@ static int zc0301_ioctl_v4l2(struct inode* inode, struct file* filp,
static int zc0301_ioctl(struct inode* inode, struct file* filp,
- unsigned int cmd, unsigned long arg)
+ unsigned int cmd, unsigned long arg)
{
struct zc0301_device* cam = video_get_drvdata(video_devdata(filp));
int err = 0;
@@ -1948,7 +1948,7 @@ zc0301_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
mutex_lock(&cam->dev_mutex);
err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER,
- video_nr[dev_nr]);
+ video_nr[dev_nr]);
if (err) {
DBG(1, "V4L2 device registration failed");
if (err == -ENFILE && video_nr[dev_nr] == -1)
diff --git a/drivers/usb/media/zc0301_pas202bcb.c b/drivers/media/video/zc0301/zc0301_pas202bcb.c
index 9d282a22c15..eaadf025204 100644
--- a/drivers/usb/media/zc0301_pas202bcb.c
+++ b/drivers/media/video/zc0301/zc0301_pas202bcb.c
@@ -24,10 +24,10 @@
/*
NOTE: Sensor controls are disabled for now, becouse changing them while
- streaming sometimes results in out-of-sync video frames. We'll use
- the default initialization, until we know how to stop and start video
- in the chip. However, the image quality still looks good under various
- light conditions.
+ streaming sometimes results in out-of-sync video frames. We'll use
+ the default initialization, until we know how to stop and start video
+ in the chip. However, the image quality still looks good under various
+ light conditions.
*/
#include <linux/delay.h>
@@ -165,7 +165,7 @@ static int pas202bcb_init(struct zc0301_device* cam)
static int pas202bcb_get_ctrl(struct zc0301_device* cam,
- struct v4l2_control* ctrl)
+ struct v4l2_control* ctrl)
{
switch (ctrl->id) {
case V4L2_CID_EXPOSURE:
@@ -208,7 +208,7 @@ static int pas202bcb_get_ctrl(struct zc0301_device* cam,
static int pas202bcb_set_ctrl(struct zc0301_device* cam,
- const struct v4l2_control* ctrl)
+ const struct v4l2_control* ctrl)
{
int err = 0;
diff --git a/drivers/usb/media/zc0301_sensor.h b/drivers/media/video/zc0301/zc0301_sensor.h
index cf0965a81d0..1f95c28b101 100644
--- a/drivers/usb/media/zc0301_sensor.h
+++ b/drivers/media/video/zc0301/zc0301_sensor.h
@@ -51,7 +51,7 @@ zc0301_attach_sensor(struct zc0301_device* cam, struct zc0301_sensor* sensor);
#define ZC0301_USB_DEVICE(vend, prod, intclass) \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
- USB_DEVICE_ID_MATCH_INT_CLASS, \
+ USB_DEVICE_ID_MATCH_INT_CLASS, \
.idVendor = (vend), \
.idProduct = (prod), \
.bInterfaceClass = (intclass)
@@ -92,7 +92,7 @@ struct zc0301_sensor {
int (*init)(struct zc0301_device*);
int (*get_ctrl)(struct zc0301_device*, struct v4l2_control* ctrl);
int (*set_ctrl)(struct zc0301_device*,
- const struct v4l2_control* ctrl);
+ const struct v4l2_control* ctrl);
int (*set_crop)(struct zc0301_device*, const struct v4l2_rect* rect);
/* Private */
diff --git a/drivers/media/video/zoran.h b/drivers/media/video/zoran.h
index 9fe6ad3b635..0166f555a5c 100644
--- a/drivers/media/video/zoran.h
+++ b/drivers/media/video/zoran.h
@@ -1,4 +1,4 @@
-/*
+/*
* zoran - Iomega Buz driver
*
* Copyright (C) 1999 Rainer Johanni <Rainer@Johanni.de>
@@ -395,7 +395,7 @@ struct zoran {
struct videocodec *codec; /* video codec */
struct videocodec *vfe; /* video front end */
- struct semaphore resource_lock; /* prevent evil stuff */
+ struct mutex resource_lock; /* prevent evil stuff */
u8 initialized; /* flag if zoran has been correctly initalized */
int user; /* number of current users */
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 246e67cd8b5..0a85c9e7fb4 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles card-specific data and detection
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
@@ -47,6 +47,7 @@
#include <linux/interrupt.h>
#include <linux/video_decoder.h>
#include <linux/video_encoder.h>
+#include <linux/mutex.h>
#include <asm/io.h>
@@ -673,7 +674,7 @@ zoran_i2c_client_register (struct i2c_client *client)
KERN_DEBUG "%s: i2c_client_register() - driver id = %d\n",
ZR_DEVNAME(zr), client->driver->id);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (zr->user > 0) {
/* we're already busy, so we keep a reference to
@@ -694,7 +695,7 @@ zoran_i2c_client_register (struct i2c_client *client)
}
clientreg_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -707,7 +708,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
dprintk(2, KERN_DEBUG "%s: i2c_client_unregister()\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (zr->user > 0) {
res = -EBUSY;
@@ -722,7 +723,7 @@ zoran_i2c_client_unregister (struct i2c_client *client)
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%d]", zr->id);
}
clientunreg_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -995,10 +996,7 @@ test_interrupts (struct zoran *zr)
static int __devinit
zr36057_init (struct zoran *zr)
{
- u32 *mem;
- void *vdev;
- unsigned mem_needed;
- int j;
+ int j, err;
int two = 2;
int zero = 0;
@@ -1049,19 +1047,16 @@ zr36057_init (struct zoran *zr)
/* allocate memory *before* doing anything to the hardware
* in case allocation fails */
- mem_needed = BUZ_NUM_STAT_COM * 4;
- mem = kzalloc(mem_needed, GFP_KERNEL);
- vdev = (void *) kmalloc(sizeof(struct video_device), GFP_KERNEL);
- if (!mem || !vdev) {
+ zr->stat_com = kzalloc(BUZ_NUM_STAT_COM * 4, GFP_KERNEL);
+ zr->video_dev = kmalloc(sizeof(struct video_device), GFP_KERNEL);
+ if (!zr->stat_com || !zr->video_dev) {
dprintk(1,
KERN_ERR
"%s: zr36057_init() - kmalloc (STAT_COM) failed\n",
ZR_DEVNAME(zr));
- kfree(vdev);
- kfree(mem);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto exit_free;
}
- zr->stat_com = mem;
for (j = 0; j < BUZ_NUM_STAT_COM; j++) {
zr->stat_com[j] = 1; /* mark as unavailable to zr36057 */
}
@@ -1069,16 +1064,11 @@ zr36057_init (struct zoran *zr)
/*
* Now add the template and register the device unit.
*/
- zr->video_dev = vdev;
memcpy(zr->video_dev, &zoran_template, sizeof(zoran_template));
strcpy(zr->video_dev->name, ZR_DEVNAME(zr));
- if (video_register_device(zr->video_dev, VFL_TYPE_GRABBER,
- video_nr) < 0) {
- zoran_unregister_i2c(zr);
- kfree((void *) zr->stat_com);
- kfree(vdev);
- return -1;
- }
+ err = video_register_device(zr->video_dev, VFL_TYPE_GRABBER, video_nr);
+ if (err < 0)
+ goto exit_unregister;
zoran_init_hardware(zr);
if (*zr_debug > 2)
@@ -1092,6 +1082,13 @@ zr36057_init (struct zoran *zr)
zr->zoran_proc = NULL;
zr->initialized = 1;
return 0;
+
+exit_unregister:
+ zoran_unregister_i2c(zr);
+exit_free:
+ kfree(zr->stat_com);
+ kfree(zr->video_dev);
+ return err;
}
static void
@@ -1121,7 +1118,7 @@ zoran_release (struct zoran *zr)
btwrite(0, ZR36057_SPGPPCR);
free_irq(zr->pci_dev->irq, zr);
/* unmap and free memory */
- kfree((void *) zr->stat_com);
+ kfree(zr->stat_com);
zoran_proc_cleanup(zr);
iounmap(zr->zr36057_mem);
pci_disable_device(zr->pci_dev);
@@ -1206,7 +1203,7 @@ find_zr36057 (void)
zr->id = zoran_num;
snprintf(ZR_DEVNAME(zr), sizeof(ZR_DEVNAME(zr)), "MJPEG[%u]", zr->id);
spin_lock_init(&zr->spinlock);
- init_MUTEX(&zr->resource_lock);
+ mutex_init(&zr->resource_lock);
if (pci_enable_device(dev))
continue;
zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
diff --git a/drivers/media/video/zoran_card.h b/drivers/media/video/zoran_card.h
index e5b6acd3eed..ad997c30bee 100644
--- a/drivers/media/video/zoran_card.h
+++ b/drivers/media/video/zoran_card.h
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles card-specific data and detection
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
diff --git a/drivers/media/video/zoran_device.c b/drivers/media/video/zoran_device.c
index 4e15afdec4c..c690b2ee880 100644
--- a/drivers/media/video/zoran_device.c
+++ b/drivers/media/video/zoran_device.c
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles device access (PCI/I2C/codec/...)
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
@@ -492,7 +492,7 @@ zr36057_set_vfe (struct zoran *zr,
/* (Ronald) don't write this if overlay_mask = NULL */
if (zr->overlay_mask) {
/* Write overlay clipping mask data, but don't enable overlay clipping */
- /* RJ: since this makes only sense on the screen, we use
+ /* RJ: since this makes only sense on the screen, we use
* zr->overlay_settings.width instead of video_width */
mask_line_size = (BUZ_MAX_WIDTH + 31) / 32;
@@ -819,12 +819,12 @@ zr36057_set_jpg (struct zoran *zr,
if (zr->card.vfe_pol.hsync_pol)
btor(ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
else
- btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
+ btand(~ZR36057_VFEHCR_HSPol, ZR36057_VFEHCR);
reg = ((tvn->HSyncStart) << ZR36057_HSP_HsyncStart) |
(tvn->Wt << ZR36057_HSP_LineTot);
btwrite(reg, ZR36057_HSP);
reg = ((zr->jpg_settings.img_x +
- tvn->HStart + 4) << ZR36057_FHAP_NAX) |
+ tvn->HStart + 4) << ZR36057_FHAP_NAX) |
(zr->jpg_settings.img_width << ZR36057_FHAP_PAX);
btwrite(reg, ZR36057_FHAP);
@@ -1272,15 +1272,15 @@ error_handler (struct zoran *zr,
if (zr->JPEG_error != 1) {
/*
* First entry: error just happened during normal operation
- *
+ *
* In BUZ_MODE_MOTION_COMPRESS:
- *
+ *
* Possible glitch in TV signal. In this case we should
* stop the codec and wait for good quality signal before
* restarting it to avoid further problems
- *
+ *
* In BUZ_MODE_MOTION_DECOMPRESS:
- *
+ *
* Bad JPEG frame: we have to mark it as processed (codec crashed
* and was not able to do it itself), and to remove it from queue.
*/
diff --git a/drivers/media/video/zoran_device.h b/drivers/media/video/zoran_device.h
index f315203d710..f19705cbdb3 100644
--- a/drivers/media/video/zoran_device.h
+++ b/drivers/media/video/zoran_device.h
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles card-specific data and detection
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 485553be190..b5a576a37fd 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -81,6 +81,7 @@
#include <linux/video_decoder.h>
#include <linux/video_encoder.h>
+#include <linux/mutex.h>
#include "zoran.h"
#include "zoran_device.h"
#include "zoran_card.h"
@@ -93,7 +94,7 @@
V4L2_CAP_VIDEO_CAPTURE |\
V4L2_CAP_VIDEO_OUTPUT |\
V4L2_CAP_VIDEO_OVERLAY \
- )
+ )
#endif
#include <asm/byteorder.h>
@@ -164,7 +165,7 @@ const struct zoran_format zoran_formats[] = {
#endif
.depth = 16,
.flags = ZORAN_FORMAT_CAPTURE |
- ZORAN_FORMAT_OVERLAY,
+ ZORAN_FORMAT_OVERLAY,
}, {
.name = "Hardware-encoded Motion-JPEG",
.palette = -1,
@@ -669,7 +670,7 @@ jpg_fbuffer_free (struct file *file)
j]))));
free_page((unsigned long)
bus_to_virt
- (le32_to_cpu
+ (le32_to_cpu
(fh->jpg_buffers.
buffer[i].
frag_tab[2 * j])));
@@ -1292,7 +1293,7 @@ zoran_open (struct inode *inode,
/* see fs/device.c - the kernel already locks during open(),
* so locking ourselves only causes deadlocks */
- /*down(&zr->resource_lock);*/
+ /*mutex_lock(&zr->resource_lock);*/
if (!zr->decoder) {
dprintk(1,
@@ -1371,7 +1372,7 @@ zoran_open (struct inode *inode,
if (zr->user++ == 0)
first_open = 1;
- /*up(&zr->resource_lock);*/
+ /*mutex_unlock(&zr->resource_lock);*/
/* default setup - TODO: look at flags */
if (first_open) { /* First device open */
@@ -1401,7 +1402,7 @@ open_unlock_and_return:
/* if there's no device found, we didn't obtain the lock either */
if (zr) {
- /*up(&zr->resource_lock);*/
+ /*mutex_unlock(&zr->resource_lock);*/
}
return res;
@@ -1419,7 +1420,7 @@ zoran_close (struct inode *inode,
/* kernel locks (fs/device.c), so don't do that ourselves
* (prevents deadlocks) */
- /*down(&zr->resource_lock);*/
+ /*mutex_lock(&zr->resource_lock);*/
zoran_close_end_session(file);
@@ -1466,7 +1467,7 @@ zoran_close (struct inode *inode,
}
module_put(THIS_MODULE);
- /*up(&zr->resource_lock);*/
+ /*mutex_unlock(&zr->resource_lock);*/
dprintk(4, KERN_INFO "%s: zoran_close() done\n", ZR_DEVNAME(zr));
@@ -1870,7 +1871,7 @@ zoran_v4l2_buffer_status (struct file *file,
static int
zoran_set_norm (struct zoran *zr,
- int norm) /* VIDEO_MODE_* */
+ int norm) /* VIDEO_MODE_* */
{
int norm_encoder, on;
@@ -2005,9 +2006,9 @@ zoran_set_input (struct zoran *zr,
static int
zoran_do_ioctl (struct inode *inode,
- struct file *file,
- unsigned int cmd,
- void *arg)
+ struct file *file,
+ unsigned int cmd,
+ void *arg)
{
struct zoran_fh *fh = file->private_data;
struct zoran *zr = fh->zr;
@@ -2027,14 +2028,14 @@ zoran_do_ioctl (struct inode *inode,
* but moving the free code outside the munmap() handler fixes
* all this... If someone knows why, please explain me (Ronald)
*/
- if (!down_trylock(&zr->resource_lock)) {
+ if (!!mutex_trylock(&zr->resource_lock)) {
/* we obtained it! Let's try to free some things */
if (fh->jpg_buffers.ready_to_be_freed)
jpg_fbuffer_free(file);
if (fh->v4l_buffers.ready_to_be_freed)
v4l_fbuffer_free(file);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
}
switch (cmd) {
@@ -2051,12 +2052,12 @@ zoran_do_ioctl (struct inode *inode,
vcap->channels = zr->card.inputs;
vcap->audios = 0;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
vcap->maxwidth = BUZ_MAX_WIDTH;
vcap->maxheight = BUZ_MAX_HEIGHT;
vcap->minwidth = BUZ_MIN_WIDTH;
vcap->minheight = BUZ_MIN_HEIGHT;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -2084,9 +2085,9 @@ zoran_do_ioctl (struct inode *inode,
vchan->tuners = 0;
vchan->flags = 0;
vchan->type = VIDEO_TYPE_CAMERA;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
vchan->norm = zr->norm;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
vchan->channel = channel;
return 0;
@@ -2094,7 +2095,7 @@ zoran_do_ioctl (struct inode *inode,
break;
/* RJ: the documentation at http://roadrunner.swansea.linux.org.uk/v4lapi.shtml says:
- *
+ *
* * "The VIDIOCSCHAN ioctl takes an integer argument and switches the capture to this input."
* * ^^^^^^^
* * The famos BTTV driver has it implemented with a struct video_channel argument
@@ -2113,7 +2114,7 @@ zoran_do_ioctl (struct inode *inode,
"%s: VIDIOCSCHAN - channel=%d, norm=%d\n",
ZR_DEVNAME(zr), vchan->channel, vchan->norm);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if ((res = zoran_set_input(zr, vchan->channel)))
goto schan_unlock_and_return;
if ((res = zoran_set_norm(zr, vchan->norm)))
@@ -2122,7 +2123,7 @@ zoran_do_ioctl (struct inode *inode,
/* Make sure the changes come into effect */
res = wait_grab_pending(zr);
schan_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -2134,7 +2135,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGPICT\n", ZR_DEVNAME(zr));
memset(vpict, 0, sizeof(struct video_picture));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
vpict->hue = zr->hue;
vpict->brightness = zr->brightness;
vpict->contrast = zr->contrast;
@@ -2145,7 +2146,7 @@ zoran_do_ioctl (struct inode *inode,
} else {
vpict->depth = 0;
}
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -2180,7 +2181,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
decoder_command(zr, DECODER_SET_PICTURE, vpict);
@@ -2191,7 +2192,7 @@ zoran_do_ioctl (struct inode *inode,
fh->overlay_settings.format = &zoran_formats[i];
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -2204,9 +2205,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCCAPTURE - on=%d\n",
ZR_DEVNAME(zr), *on);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = setup_overlay(file, *on);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2219,12 +2220,12 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGWIN\n", ZR_DEVNAME(zr));
memset(vwin, 0, sizeof(struct video_window));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
vwin->x = fh->overlay_settings.x;
vwin->y = fh->overlay_settings.y;
vwin->width = fh->overlay_settings.width;
vwin->height = fh->overlay_settings.height;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
vwin->clipcount = 0;
return 0;
}
@@ -2241,12 +2242,12 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), vwin->x, vwin->y, vwin->width,
vwin->height, vwin->clipcount);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res =
setup_window(file, vwin->x, vwin->y, vwin->width,
vwin->height, vwin->clips,
vwin->clipcount, NULL);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2258,9 +2259,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCGFBUF\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
*vbuf = zr->buffer;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
break;
@@ -2287,12 +2288,12 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res =
setup_fbuffer(file, vbuf->base, &zoran_formats[i],
vbuf->width, vbuf->height,
vbuf->bytesperline);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2305,9 +2306,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOCSYNC - frame=%d\n",
ZR_DEVNAME(zr), *frame);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = v4l_sync(file, *frame);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
if (!res)
zr->v4l_sync_tail++;
return res;
@@ -2325,9 +2326,9 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), vmap->frame, vmap->width, vmap->height,
vmap->format);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = v4l_grab(file, vmap);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -2348,7 +2349,7 @@ zoran_do_ioctl (struct inode *inode,
i * fh->v4l_buffers.buffer_size;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1,
@@ -2367,7 +2368,7 @@ zoran_do_ioctl (struct inode *inode,
/* The next mmap will map the V4L buffers */
fh->map_mode = ZORAN_MAP_MODE_RAW;
v4l1reqbuf_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2421,7 +2422,7 @@ zoran_do_ioctl (struct inode *inode,
bparams->major_version = MAJOR_VERSION;
bparams->minor_version = MINOR_VERSION;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
bparams->norm = zr->norm;
bparams->input = zr->input;
@@ -2450,7 +2451,7 @@ zoran_do_ioctl (struct inode *inode,
bparams->jpeg_markers =
fh->jpg_settings.jpg_comp.jpeg_markers;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
bparams->VFIFO_FB = 0;
@@ -2486,7 +2487,7 @@ zoran_do_ioctl (struct inode *inode,
sizeof(bparams->COM_data));
settings.jpg_comp.jpeg_markers = bparams->jpeg_markers;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (zr->codec_mode != BUZ_MODE_IDLE) {
dprintk(1,
@@ -2506,7 +2507,7 @@ zoran_do_ioctl (struct inode *inode,
fh->jpg_settings = settings;
sparams_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2538,7 +2539,7 @@ zoran_do_ioctl (struct inode *inode,
breq->size > MAX_KMALLOC_MEM)
breq->size = MAX_KMALLOC_MEM;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1,
@@ -2561,7 +2562,7 @@ zoran_do_ioctl (struct inode *inode,
* also be *_PLAY, but it doesn't matter here */
fh->map_mode = ZORAN_MAP_MODE_JPG_REC;
jpgreqbuf_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2574,9 +2575,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_CAPT - frame=%d\n",
ZR_DEVNAME(zr), *frame);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_COMPRESS);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2589,9 +2590,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_QBUF_PLAY - frame=%d\n",
ZR_DEVNAME(zr), *frame);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = jpg_qbuf(file, *frame, BUZ_MODE_MOTION_DECOMPRESS);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2604,9 +2605,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: BUZIOC_SYNC\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = jpg_sync(file, bsync);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -2630,7 +2631,7 @@ zoran_do_ioctl (struct inode *inode,
input = zr->card.input[bstat->input].muxsel;
norm = VIDEO_MODE_AUTO;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (zr->codec_mode != BUZ_MODE_IDLE) {
dprintk(1,
@@ -2655,7 +2656,7 @@ zoran_do_ioctl (struct inode *inode,
decoder_command(zr, DECODER_SET_INPUT, &input);
decoder_command(zr, DECODER_SET_NORM, &zr->norm);
gstat_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
if (!res) {
bstat->signal =
@@ -2763,7 +2764,7 @@ zoran_do_ioctl (struct inode *inode,
switch (fmt->type) {
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
fmt->fmt.win.w.left = fh->overlay_settings.x;
fmt->fmt.win.w.top = fh->overlay_settings.y;
@@ -2776,14 +2777,14 @@ zoran_do_ioctl (struct inode *inode,
else
fmt->fmt.win.field = V4L2_FIELD_TOP;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE &&
fh->map_mode == ZORAN_MAP_MODE_RAW) {
@@ -2837,7 +2838,7 @@ zoran_do_ioctl (struct inode *inode,
V4L2_COLORSPACE_SMPTE170M;
}
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
break;
@@ -2870,7 +2871,7 @@ zoran_do_ioctl (struct inode *inode,
fmt->fmt.win.w.height,
fmt->fmt.win.clipcount,
fmt->fmt.win.bitmap);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res =
setup_window(file, fmt->fmt.win.w.left,
fmt->fmt.win.w.top,
@@ -2880,7 +2881,7 @@ zoran_do_ioctl (struct inode *inode,
fmt->fmt.win.clips,
fmt->fmt.win.clipcount,
fmt->fmt.win.bitmap);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
break;
@@ -2917,7 +2918,7 @@ zoran_do_ioctl (struct inode *inode,
}
if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) {
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
settings = fh->jpg_settings;
@@ -2995,7 +2996,7 @@ zoran_do_ioctl (struct inode *inode,
ZORAN_MAP_MODE_JPG_REC :
ZORAN_MAP_MODE_JPG_PLAY;
sfmtjpg_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
} else {
for (i = 0; i < zoran_num_formats; i++)
if (fmt->fmt.pix.pixelformat ==
@@ -3010,7 +3011,7 @@ zoran_do_ioctl (struct inode *inode,
(char *) &printformat);
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated ||
(fh->v4l_buffers.allocated &&
fh->v4l_buffers.active !=
@@ -3052,7 +3053,7 @@ zoran_do_ioctl (struct inode *inode,
fh->map_mode = ZORAN_MAP_MODE_RAW;
sfmtv4l_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
}
break;
@@ -3077,7 +3078,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_FBUF\n", ZR_DEVNAME(zr));
memset(fb, 0, sizeof(*fb));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
fb->base = zr->buffer.base;
fb->fmt.width = zr->buffer.width;
fb->fmt.height = zr->buffer.height;
@@ -3086,7 +3087,7 @@ zoran_do_ioctl (struct inode *inode,
fh->overlay_settings.format->fourcc;
}
fb->fmt.bytesperline = zr->buffer.bytesperline;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
fb->fmt.colorspace = V4L2_COLORSPACE_SRGB;
fb->fmt.field = V4L2_FIELD_INTERLACED;
fb->flags = V4L2_FBUF_FLAG_OVERLAY;
@@ -3121,12 +3122,12 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res =
setup_fbuffer(file, fb->base, &zoran_formats[i],
fb->fmt.width, fb->fmt.height,
fb->fmt.bytesperline);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3139,9 +3140,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_PREVIEW - on=%d\n",
ZR_DEVNAME(zr), *on);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = setup_overlay(file, *on);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3163,7 +3164,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.allocated || fh->jpg_buffers.allocated) {
dprintk(1,
@@ -3224,7 +3225,7 @@ zoran_do_ioctl (struct inode *inode,
goto v4l2reqbuf_unlock_and_return;
}
v4l2reqbuf_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -3245,9 +3246,9 @@ zoran_do_ioctl (struct inode *inode,
buf->type = type;
buf->index = index;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
res = zoran_v4l2_buffer_status(file, buf, buf->index);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3262,7 +3263,7 @@ zoran_do_ioctl (struct inode *inode,
KERN_DEBUG "%s: VIDIOC_QBUF - type=%d, index=%d\n",
ZR_DEVNAME(zr), buf->type, buf->index);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW:
@@ -3322,7 +3323,7 @@ zoran_do_ioctl (struct inode *inode,
goto qbuf_unlock_and_return;
}
qbuf_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3336,7 +3337,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_DQBUF - type=%d\n",
ZR_DEVNAME(zr), buf->type);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW:
@@ -3410,7 +3411,7 @@ zoran_do_ioctl (struct inode *inode,
goto dqbuf_unlock_and_return;
}
dqbuf_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3422,7 +3423,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMON\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: /* raw capture */
@@ -3470,7 +3471,7 @@ zoran_do_ioctl (struct inode *inode,
goto strmon_unlock_and_return;
}
strmon_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3482,7 +3483,7 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_STREAMOFF\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW: /* raw capture */
@@ -3540,7 +3541,7 @@ zoran_do_ioctl (struct inode *inode,
goto strmoff_unlock_and_return;
}
strmoff_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3600,7 +3601,7 @@ zoran_do_ioctl (struct inode *inode,
ctrl->id > V4L2_CID_HUE)
return -EINVAL;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
ctrl->value = zr->brightness;
@@ -3615,7 +3616,7 @@ zoran_do_ioctl (struct inode *inode,
ctrl->value = zr->hue;
break;
}
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -3642,7 +3643,7 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (ctrl->id) {
case V4L2_CID_BRIGHTNESS:
zr->brightness = ctrl->value;
@@ -3664,7 +3665,7 @@ zoran_do_ioctl (struct inode *inode,
decoder_command(zr, DECODER_SET_PICTURE, &pict);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -3732,9 +3733,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_STD\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
norm = zr->norm;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
switch (norm) {
case VIDEO_MODE_PAL:
@@ -3776,13 +3777,13 @@ zoran_do_ioctl (struct inode *inode,
return -EINVAL;
}
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if ((res = zoran_set_norm(zr, norm)))
goto sstd_unlock_and_return;
res = wait_grab_pending(zr);
sstd_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -3809,9 +3810,9 @@ zoran_do_ioctl (struct inode *inode,
inp->std = V4L2_STD_ALL;
/* Get status of video decoder */
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
decoder_command(zr, DECODER_GET_STATUS, &status);
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
if (!(status & DECODER_STATUS_GOOD)) {
inp->status |= V4L2_IN_ST_NO_POWER;
@@ -3830,9 +3831,9 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_G_INPUT\n", ZR_DEVNAME(zr));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
*input = zr->input;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -3845,14 +3846,14 @@ zoran_do_ioctl (struct inode *inode,
dprintk(3, KERN_DEBUG "%s: VIDIOC_S_INPUT - input=%d\n",
ZR_DEVNAME(zr), *input);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if ((res = zoran_set_input(zr, *input)))
goto sinput_unlock_and_return;
/* Make sure the changes come into effect */
res = wait_grab_pending(zr);
sinput_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -3914,7 +3915,7 @@ zoran_do_ioctl (struct inode *inode,
memset(cropcap, 0, sizeof(*cropcap));
cropcap->type = type;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (cropcap->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
(cropcap->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
@@ -3934,7 +3935,7 @@ zoran_do_ioctl (struct inode *inode,
cropcap->defrect.width = BUZ_MIN_WIDTH;
cropcap->defrect.height = BUZ_MIN_HEIGHT;
cropcap_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -3950,7 +3951,7 @@ zoran_do_ioctl (struct inode *inode,
memset(crop, 0, sizeof(*crop));
crop->type = type;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (crop->type != V4L2_BUF_TYPE_VIDEO_OUTPUT &&
(crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE ||
@@ -3969,7 +3970,7 @@ zoran_do_ioctl (struct inode *inode,
crop->c.height = fh->jpg_settings.img_height;
gcrop_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -3988,7 +3989,7 @@ zoran_do_ioctl (struct inode *inode,
ZR_DEVNAME(zr), crop->type, crop->c.left, crop->c.top,
crop->c.width, crop->c.height);
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.allocated || fh->v4l_buffers.allocated) {
dprintk(1,
@@ -4024,7 +4025,7 @@ zoran_do_ioctl (struct inode *inode,
fh->jpg_settings = settings;
scrop_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
break;
@@ -4038,7 +4039,7 @@ zoran_do_ioctl (struct inode *inode,
memset(params, 0, sizeof(*params));
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
params->quality = fh->jpg_settings.jpg_comp.quality;
params->APPn = fh->jpg_settings.jpg_comp.APPn;
@@ -4053,7 +4054,7 @@ zoran_do_ioctl (struct inode *inode,
params->jpeg_markers =
fh->jpg_settings.jpg_comp.jpeg_markers;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -4074,7 +4075,7 @@ zoran_do_ioctl (struct inode *inode,
settings.jpg_comp = *params;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.active != ZORAN_FREE ||
fh->jpg_buffers.active != ZORAN_FREE) {
@@ -4093,7 +4094,7 @@ zoran_do_ioctl (struct inode *inode,
zoran_v4l2_calc_bufsize(&fh->jpg_settings);
fh->jpg_settings.jpg_comp = *params = settings.jpg_comp;
sjpegc_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return 0;
}
@@ -4127,7 +4128,7 @@ zoran_do_ioctl (struct inode *inode,
switch (fmt->type) {
case V4L2_BUF_TYPE_VIDEO_OVERLAY:
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fmt->fmt.win.w.width > BUZ_MAX_WIDTH)
fmt->fmt.win.w.width = BUZ_MAX_WIDTH;
@@ -4138,7 +4139,7 @@ zoran_do_ioctl (struct inode *inode,
if (fmt->fmt.win.w.height < BUZ_MIN_HEIGHT)
fmt->fmt.win.w.height = BUZ_MIN_HEIGHT;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
break;
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
@@ -4146,7 +4147,7 @@ zoran_do_ioctl (struct inode *inode,
if (fmt->fmt.pix.bytesperline > 0)
return -EINVAL;
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fmt->fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG) {
settings = fh->jpg_settings;
@@ -4229,7 +4230,7 @@ zoran_do_ioctl (struct inode *inode,
goto tryfmt_unlock_and_return;
}
tryfmt_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
break;
@@ -4280,7 +4281,7 @@ zoran_poll (struct file *file,
* if no buffers queued or so, return POLLNVAL
*/
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
switch (fh->map_mode) {
case ZORAN_MAP_MODE_RAW:
@@ -4329,7 +4330,7 @@ zoran_poll (struct file *file,
}
poll_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
return res;
}
@@ -4385,7 +4386,7 @@ zoran_vm_close (struct vm_area_struct *vma)
if (fh->jpg_buffers.buffer[i].map)
break;
if (i == fh->jpg_buffers.num_buffers) {
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->jpg_buffers.active != ZORAN_FREE) {
jpg_qbuf(file, -1, zr->codec_mode);
@@ -4398,7 +4399,7 @@ zoran_vm_close (struct vm_area_struct *vma)
fh->jpg_buffers.allocated = 0;
fh->jpg_buffers.ready_to_be_freed = 1;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
}
break;
@@ -4421,7 +4422,7 @@ zoran_vm_close (struct vm_area_struct *vma)
if (fh->v4l_buffers.buffer[i].map)
break;
if (i == fh->v4l_buffers.num_buffers) {
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
if (fh->v4l_buffers.active != ZORAN_FREE) {
zr36057_set_memgrab(zr, 0);
@@ -4434,7 +4435,7 @@ zoran_vm_close (struct vm_area_struct *vma)
fh->v4l_buffers.allocated = 0;
fh->v4l_buffers.ready_to_be_freed = 1;
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
}
break;
@@ -4489,7 +4490,7 @@ zoran_mmap (struct file *file,
case ZORAN_MAP_MODE_JPG_PLAY:
/* lock */
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
/* Map the MJPEG buffers */
if (!fh->jpg_buffers.allocated) {
@@ -4579,13 +4580,13 @@ zoran_mmap (struct file *file,
}
jpg_mmap_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
break;
case ZORAN_MAP_MODE_RAW:
- down(&zr->resource_lock);
+ mutex_lock(&zr->resource_lock);
/* Map the V4L buffers */
if (!fh->v4l_buffers.allocated) {
@@ -4657,7 +4658,7 @@ zoran_mmap (struct file *file,
break;
}
v4l_mmap_unlock_and_return:
- up(&zr->resource_lock);
+ mutex_unlock(&zr->resource_lock);
break;
diff --git a/drivers/media/video/zoran_procfs.c b/drivers/media/video/zoran_procfs.c
index f0d9b13c3c6..a00fae90229 100644
--- a/drivers/media/video/zoran_procfs.c
+++ b/drivers/media/video/zoran_procfs.c
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles the procFS entries (/proc/ZORAN[%d])
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
diff --git a/drivers/media/video/zoran_procfs.h b/drivers/media/video/zoran_procfs.h
index 8904fc95955..f2d5b1ba448 100644
--- a/drivers/media/video/zoran_procfs.h
+++ b/drivers/media/video/zoran_procfs.h
@@ -4,7 +4,7 @@
* Media Labs LML33/LML33R10.
*
* This part handles card-specific data and detection
- *
+ *
* Copyright (C) 2000 Serguei Miridonov <mirsev@cicese.mx>
*
* Currently maintained by:
diff --git a/drivers/media/video/zr36016.c b/drivers/media/video/zr36016.c
index 10130ef67ea..62f77584fb8 100644
--- a/drivers/media/video/zr36016.c
+++ b/drivers/media/video/zr36016.c
@@ -34,7 +34,7 @@
#include <linux/types.h>
#include <linux/wait.h>
-/* includes for structures and defines regarding video
+/* includes for structures and defines regarding video
#include<linux/videodev.h> */
/* I/O commands, error codes */
@@ -143,8 +143,8 @@ zr36016_readi (struct zr36016 *ptr,
static void
zr36016_writei (struct zr36016 *ptr,
- u16 reg,
- u8 value)
+ u16 reg,
+ u8 value)
{
dprintk(4, "%s: writing indirect 0x%02x to 0x%04x\n", ptr->name,
value, reg);
@@ -192,7 +192,7 @@ zr36016_basic_test (struct zr36016 *ptr)
dprintk(1, "\n");
}
// for testing just write 0, then the default value to a register and read
- // it back in both cases
+ // it back in both cases
zr36016_writei(ptr, ZR016I_PAX_LO, 0x00);
if (zr36016_readi(ptr, ZR016I_PAX_LO) != 0x0) {
dprintk(1,
@@ -232,17 +232,17 @@ zr36016_basic_test (struct zr36016 *ptr)
static int zr36016_pushit (struct zr36016 *ptr,
u16 startreg,
u16 len,
- const char *data)
+ const char *data)
{
- int i=0;
+ int i=0;
- dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
+ dprintk(4, "%s: write data block to 0x%04x (len=%d)\n",
ptr->name, startreg,len);
- while (i<len) {
- zr36016_writei(ptr, startreg++, data[i++]);
- }
+ while (i<len) {
+ zr36016_writei(ptr, startreg++, data[i++]);
+ }
- return i;
+ return i;
}
#endif
diff --git a/drivers/media/video/zr36050.c b/drivers/media/video/zr36050.c
index 6699725be60..a6bbd125631 100644
--- a/drivers/media/video/zr36050.c
+++ b/drivers/media/video/zr36050.c
@@ -34,7 +34,7 @@
#include <linux/types.h>
#include <linux/wait.h>
-/* includes for structures and defines regarding video
+/* includes for structures and defines regarding video
#include<linux/videodev.h> */
/* I/O commands, error codes */
@@ -171,7 +171,7 @@ zr36050_wait_end (struct zr36050 *ptr)
/* =========================================================================
Local helper function:
- basic test of "connectivity", writes/reads to/from memory the SOF marker
+ basic test of "connectivity", writes/reads to/from memory the SOF marker
========================================================================= */
static int
@@ -218,9 +218,9 @@ zr36050_basic_test (struct zr36050 *ptr)
static int
zr36050_pushit (struct zr36050 *ptr,
- u16 startreg,
- u16 len,
- const char *data)
+ u16 startreg,
+ u16 len,
+ const char *data)
{
int i = 0;
@@ -345,7 +345,7 @@ static const char zr36050_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
/* ------------------------------------------------------------------------- */
/* SOF (start of frame) segment depends on width, height and sampling ratio
- of each color component */
+ of each color component */
static int
zr36050_set_sof (struct zr36050 *ptr)
@@ -376,8 +376,8 @@ zr36050_set_sof (struct zr36050 *ptr)
/* ------------------------------------------------------------------------- */
-/* SOS (start of scan) segment depends on the used scan components
- of each color component */
+/* SOS (start of scan) segment depends on the used scan components
+ of each color component */
static int
zr36050_set_sos (struct zr36050 *ptr)
diff --git a/drivers/media/video/zr36057.h b/drivers/media/video/zr36057.h
index 159abfa034d..54c9362aa98 100644
--- a/drivers/media/video/zr36057.h
+++ b/drivers/media/video/zr36057.h
@@ -1,4 +1,4 @@
-/*
+/*
* zr36057.h - zr36057 register offsets
*
* Copyright (C) 1998 Dave Perks <dperks@ibm.net>
@@ -27,14 +27,14 @@
#define ZR36057_VFEHCR 0x000 /* Video Front End, Horizontal Configuration Register */
#define ZR36057_VFEHCR_HSPol (1<<30)
#define ZR36057_VFEHCR_HStart 10
-#define ZR36057_VFEHCR_HEnd 0
-#define ZR36057_VFEHCR_Hmask 0x3ff
+#define ZR36057_VFEHCR_HEnd 0
+#define ZR36057_VFEHCR_Hmask 0x3ff
#define ZR36057_VFEVCR 0x004 /* Video Front End, Vertical Configuration Register */
#define ZR36057_VFEVCR_VSPol (1<<30)
#define ZR36057_VFEVCR_VStart 10
-#define ZR36057_VFEVCR_VEnd 0
-#define ZR36057_VFEVCR_Vmask 0x3ff
+#define ZR36057_VFEVCR_VEnd 0
+#define ZR36057_VFEVCR_Vmask 0x3ff
#define ZR36057_VFESPFR 0x008 /* Video Front End, Scaler and Pixel Format Register */
#define ZR36057_VFESPFR_ExtFl (1<<26)
diff --git a/drivers/media/video/zr36060.c b/drivers/media/video/zr36060.c
index d8dd003a7aa..97c8f9b9dc1 100644
--- a/drivers/media/video/zr36060.c
+++ b/drivers/media/video/zr36060.c
@@ -34,7 +34,7 @@
#include <linux/types.h>
#include <linux/wait.h>
-/* includes for structures and defines regarding video
+/* includes for structures and defines regarding video
#include<linux/videodev.h> */
/* I/O commands, error codes */
@@ -173,7 +173,7 @@ zr36060_wait_end (struct zr36060 *ptr)
/* =========================================================================
Local helper function:
- basic test of "connectivity", writes/reads to/from memory the SOF marker
+ basic test of "connectivity", writes/reads to/from memory the SOF marker
========================================================================= */
static int
@@ -208,9 +208,9 @@ zr36060_basic_test (struct zr36060 *ptr)
static int
zr36060_pushit (struct zr36060 *ptr,
- u16 startreg,
- u16 len,
- const char *data)
+ u16 startreg,
+ u16 len,
+ const char *data)
{
int i = 0;
@@ -335,7 +335,7 @@ static const char zr36060_decimation_v[8] = { 1, 1, 1, 0, 0, 0, 0, 0 };
/* ------------------------------------------------------------------------- */
/* SOF (start of frame) segment depends on width, height and sampling ratio
- of each color component */
+ of each color component */
static int
zr36060_set_sof (struct zr36060 *ptr)
@@ -367,8 +367,8 @@ zr36060_set_sof (struct zr36060 *ptr)
/* ------------------------------------------------------------------------- */
-/* SOS (start of scan) segment depends on the used scan components
- of each color component */
+/* SOS (start of scan) segment depends on the used scan components
+ of each color component */
static int
zr36060_set_sos (struct zr36060 *ptr)
@@ -385,7 +385,7 @@ zr36060_set_sos (struct zr36060 *ptr)
for (i = 0; i < NO_OF_COMPONENTS; i++) {
sos_data[5 + (i * 2)] = i; // index
sos_data[6 + (i * 2)] = (zr36060_td[i] << 4) |
- zr36060_ta[i]; // AC/DC tbl.sel.
+ zr36060_ta[i]; // AC/DC tbl.sel.
}
sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 2] = 00; // scan start
sos_data[2 + 1 + (2 * NO_OF_COMPONENTS) + 3] = 0x3f;
@@ -999,7 +999,7 @@ zr36060_cleanup_module (void)
dprintk(1,
"zr36060: something's wrong - %d codecs left somehow.\n",
zr36060_codecs);
- }
+ }
/* however, we can't just stay alive */
videocodec_unregister(&zr36060_codec);
diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c
index d4c633b8a7f..6ac3b674008 100644
--- a/drivers/media/video/zr36120.c
+++ b/drivers/media/video/zr36120.c
@@ -70,10 +70,10 @@ MODULE_AUTHOR("Pauline Middelink <middelin@polyware.nl>");
MODULE_DESCRIPTION("Zoran ZR36120 based framegrabber");
MODULE_LICENSE("GPL");
-MODULE_PARM(triton1,"i");
-MODULE_PARM(cardtype,"1-" __MODULE_STRING(ZORAN_MAX) "i");
-MODULE_PARM(video_nr,"i");
-MODULE_PARM(vbi_nr,"i");
+module_param(triton1, uint, 0);
+module_param_array(cardtype, uint, NULL, 0);
+module_param(video_nr, int, 0);
+module_param(vbi_nr, int, 0);
static int zoran_cards;
static struct zoran zorans[ZORAN_MAX];
@@ -316,7 +316,7 @@ DEBUG(printk(CARD_DEBUG "%p added to queue\n",CARD,item));
item->status = FBUFFER_BUSY;
if (!lastitem)
ztv->workqueue = item;
- else
+ else
lastitem->next = item;
lastitem = item;
}
@@ -516,7 +516,7 @@ DEBUG(printk(KERN_DEBUG " %d: clip(%d,%d,%d,%d)\n", i,vp->x,vp->y,vp->widt
zraor((ztv->vidInterlace*ystep)<<0,~ZORAN_OCR_MASKSTRIDE,ZORAN_OCR);
}
-struct tvnorm
+struct tvnorm
{
u16 Wt, Wa, Ht, Ha, HStart, VStart;
};
@@ -660,7 +660,7 @@ DEBUG(printk(KERN_DEBUG " Y: scale=0, start=%d, end=%d\n", Hstart, Hend));
int HorDcm = 64-X;
int hcrop1 = 2*(Wa-We)/4;
/*
- * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi>
+ * BUGFIX: Juha Nurmela <junki@qn-lpr2-165.quicknet.inet.fi>
* found the solution to the color phase shift.
* See ChangeLog for the full explanation)
*/
@@ -812,12 +812,12 @@ void zoran_close(struct video_device* dev)
zoran_common_close(ztv);
- /*
- * This is sucky but right now I can't find a good way to
- * be sure its safe to free the buffer. We wait 5-6 fields
- * which is more than sufficient to be sure.
- */
- msleep(100); /* Wait 1/10th of a second */
+ /*
+ * This is sucky but right now I can't find a good way to
+ * be sure its safe to free the buffer. We wait 5-6 fields
+ * which is more than sufficient to be sure.
+ */
+ msleep(100); /* Wait 1/10th of a second */
/* free the allocated framebuffer */
bfree(ztv->fbuffer, ZORAN_MAX_FBUFSIZE);
@@ -1436,7 +1436,7 @@ int zoran_ioctl(struct video_device* dev, unsigned int cmd, void *arg)
/* Why isn't this in the API?
* And why doesn't it take a buffer number?
- case BTTV_FIELDNR:
+ case BTTV_FIELDNR:
{
unsigned long v = ztv->lastfieldnr;
if (copy_to_user(arg,&v,sizeof(v)))
@@ -1557,12 +1557,12 @@ void vbi_close(struct video_device *dev)
zoran_common_close(ztv);
- /*
- * This is sucky but right now I can't find a good way to
- * be sure its safe to free the buffer. We wait 5-6 fields
- * which is more than sufficient to be sure.
- */
- msleep(100); /* Wait 1/10th of a second */
+ /*
+ * This is sucky but right now I can't find a good way to
+ * be sure its safe to free the buffer. We wait 5-6 fields
+ * which is more than sufficient to be sure.
+ */
+ msleep(100); /* Wait 1/10th of a second */
for (item=ztv->readinfo; item!=ztv->readinfo+ZORAN_VBI_BUFFERS; item++)
{
@@ -1620,7 +1620,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
write_unlock_irq(&ztv->lock);
return -EWOULDBLOCK;
}
-
+
/* mark the unused buffer as wanted */
unused->status = FBUFFER_BUSY;
unused->next = 0;
@@ -1671,7 +1671,7 @@ long vbi_read(struct video_device* dev, char* buf, unsigned long count, int nonb
if (count == 2*19*2048) {
/*
* Extreme HACK, old VBI programs expect 2048 points
- * of data, and we only got 864 orso. Double each
+ * of data, and we only got 864 orso. Double each
* datapoint and clear the rest of the line.
* This way we have appear to have a
* sample_frequency of 29.5 Mc.
@@ -1956,7 +1956,7 @@ int __init init_zoran(int card)
zrand(~ZORAN_VDC_TRICOM, ZORAN_VDC);
/* external FL determines TOP frame */
- zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC);
+ zror(ZORAN_VFEC_EXTFL, ZORAN_VFEC);
/* set HSpol */
if (ztv->card->hsync_pos)
@@ -2012,7 +2012,7 @@ void release_zoran(int max)
struct zoran *ztv;
int i;
- for (i=0;i<max; i++)
+ for (i=0;i<max; i++)
{
ztv = &zorans[i];
@@ -2029,7 +2029,7 @@ void release_zoran(int max)
/* free it */
free_irq(ztv->dev->irq,ztv);
-
+
/* unregister i2c_bus */
i2c_unregister_bus((&ztv->i2c));
@@ -2050,7 +2050,7 @@ void __exit zr36120_exit(void)
int __init zr36120_init(void)
{
int card;
-
+
handle_chipset();
zoran_cards = find_zoran();
if (zoran_cards<0)
@@ -2063,7 +2063,7 @@ int __init zr36120_init(void)
/* only release the zorans we have registered */
release_zoran(card);
return -EIO;
- }
+ }
}
return 0;
}
diff --git a/drivers/media/video/zr36120.h b/drivers/media/video/zr36120.h
index 571f8e84b58..a71e485b0f9 100644
--- a/drivers/media/video/zr36120.h
+++ b/drivers/media/video/zr36120.h
@@ -1,4 +1,4 @@
-/*
+/*
zr36120.h - Zoran 36120/36125 based framegrabbers
Copyright (C) 1998-1999 Pauline Middelink (middelin@polyware.nl)
@@ -89,7 +89,7 @@ struct vidinfo {
ulong* overlay; /* kernel addr of overlay mask */
};
-struct zoran
+struct zoran
{
struct video_device video_dev;
#define CARD_DEBUG KERN_DEBUG "%s(%lu): "
@@ -106,7 +106,7 @@ struct zoran
uint norm; /* 0=PAL, 1=NTSC, 2=SECAM */
uint tuner_freq; /* Current freq in kHz */
struct video_picture picture; /* Current picture params */
-
+
/* videocard details */
uint swidth; /* screen width */
uint sheight; /* screen height */
diff --git a/drivers/message/i2o/debug.c b/drivers/message/i2o/debug.c
index 40d4ea898db..5a6cca8e8c4 100644
--- a/drivers/message/i2o/debug.c
+++ b/drivers/message/i2o/debug.c
@@ -419,58 +419,53 @@ void i2o_dump_hrt(struct i2o_controller *c)
d = (u8 *) (rows + 2);
state = p[1] << 8 | p[0];
- printk(KERN_DEBUG "TID %04X:[", state & 0xFFF);
+ printk("TID %04X:[", state & 0xFFF);
state >>= 12;
if (state & (1 << 0))
- printk(KERN_DEBUG "H"); /* Hidden */
+ printk("H"); /* Hidden */
if (state & (1 << 2)) {
- printk(KERN_DEBUG "P"); /* Present */
+ printk("P"); /* Present */
if (state & (1 << 1))
- printk(KERN_DEBUG "C"); /* Controlled */
+ printk("C"); /* Controlled */
}
if (state > 9)
- printk(KERN_DEBUG "*"); /* Hard */
+ printk("*"); /* Hard */
- printk(KERN_DEBUG "]:");
+ printk("]:");
switch (p[3] & 0xFFFF) {
case 0:
/* Adapter private bus - easy */
- printk(KERN_DEBUG
- "Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
+ printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
d[1] << 8 | d[0], *(u32 *) (d + 4));
break;
case 1:
/* ISA bus */
- printk(KERN_DEBUG
- "ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
+ printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
break;
case 2: /* EISA bus */
- printk(KERN_DEBUG
- "EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
+ printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
break;
case 3: /* MCA bus */
- printk(KERN_DEBUG
- "MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
+ printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
break;
case 4: /* PCI bus */
- printk(KERN_DEBUG
- "PCI %d: Bus %d Device %d Function %d", p[2],
+ printk("PCI %d: Bus %d Device %d Function %d", p[2],
d[2], d[1], d[0]);
break;
case 0x80: /* Other */
default:
- printk(KERN_DEBUG "Unsupported bus type.");
+ printk("Unsupported bus type.");
break;
}
- printk(KERN_DEBUG "\n");
+ printk("\n");
rows += length;
}
}
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 550f2974481..fc3c8854f43 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -3,6 +3,7 @@
#
menu "Multimedia Capabilities Port drivers"
+ depends on ARCH_SA1100
config MCP
tristate
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 5d397b7a549..3f5d77f633f 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -49,6 +49,17 @@ config MMC_PXA
If unsure, say N.
+config MMC_SDHCI
+ tristate "Secure Digital Host Controller Interface support (EXPERIMENTAL)"
+ depends on PCI && MMC && EXPERIMENTAL
+ help
+ This select the generic Secure Digital Host Controller Interface.
+ It is used by manufacturers such as Texas Instruments(R), Ricoh(R)
+ and Toshiba(R). Most controllers found in laptops are of this type.
+ If you have a controller with this interface, say Y or M here.
+
+ If unsure, say N.
+
config MMC_WBSD
tristate "Winbond W83L51xD SD/MMC Card Interface support"
depends on MMC && ISA_DMA_API
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index e351e71146e..769d545284a 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_MMC_BLOCK) += mmc_block.o
#
obj-$(CONFIG_MMC_ARMMMCI) += mmci.o
obj-$(CONFIG_MMC_PXA) += pxamci.o
+obj-$(CONFIG_MMC_SDHCI) += sdhci.o
obj-$(CONFIG_MMC_WBSD) += wbsd.o
obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
diff --git a/drivers/mmc/au1xmmc.c b/drivers/mmc/au1xmmc.c
index 8d84b045bc8..85e89c77bde 100644
--- a/drivers/mmc/au1xmmc.c
+++ b/drivers/mmc/au1xmmc.c
@@ -87,7 +87,7 @@ struct au1xmmc_host *au1xmmc_hosts[AU1XMMC_CONTROLLER_COUNT];
static int dma = 1;
#ifdef MODULE
-MODULE_PARM(dma, "i");
+module_param(dma, bool, 0);
MODULE_PARM_DESC(dma, "Use DMA engine for data transfers (0 = disabled)");
#endif
diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
new file mode 100644
index 00000000000..8b811d94371
--- /dev/null
+++ b/drivers/mmc/sdhci.c
@@ -0,0 +1,1265 @@
+/*
+ * linux/drivers/mmc/sdhci.c - Secure Digital Host Controller Interface driver
+ *
+ * Copyright (C) 2005-2006 Pierre Ossman, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+ /*
+ * Note that PIO transfer is rather crappy atm. The buffer full/empty
+ * interrupts aren't reliable so we currently transfer the entire buffer
+ * directly. Patches to solve the problem are welcome.
+ */
+
+#include <linux/delay.h>
+#include <linux/highmem.h>
+#include <linux/pci.h>
+#include <linux/dma-mapping.h>
+
+#include <linux/mmc/host.h>
+#include <linux/mmc/protocol.h>
+
+#include <asm/scatterlist.h>
+
+#include "sdhci.h"
+
+#define DRIVER_NAME "sdhci"
+#define DRIVER_VERSION "0.11"
+
+#define BUGMAIL "<sdhci-devel@list.drzeus.cx>"
+
+#ifdef CONFIG_MMC_DEBUG
+#define DBG(f, x...) \
+ printk(KERN_DEBUG DRIVER_NAME " [%s()]: " f, __func__,## x)
+#else
+#define DBG(f, x...) do { } while (0)
+#endif
+
+static const struct pci_device_id pci_ids[] __devinitdata = {
+ /* handle any SD host controller */
+ {PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)},
+ { /* end: all zeroes */ },
+};
+
+MODULE_DEVICE_TABLE(pci, pci_ids);
+
+static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
+static void sdhci_finish_data(struct sdhci_host *);
+
+static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
+static void sdhci_finish_command(struct sdhci_host *);
+
+static void sdhci_dumpregs(struct sdhci_host *host)
+{
+ printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
+
+ printk(KERN_DEBUG DRIVER_NAME ": Sys addr: 0x%08x | Version: 0x%08x\n",
+ readl(host->ioaddr + SDHCI_DMA_ADDRESS),
+ readw(host->ioaddr + SDHCI_HOST_VERSION));
+ printk(KERN_DEBUG DRIVER_NAME ": Blk size: 0x%08x | Blk cnt: 0x%08x\n",
+ readw(host->ioaddr + SDHCI_BLOCK_SIZE),
+ readw(host->ioaddr + SDHCI_BLOCK_COUNT));
+ printk(KERN_DEBUG DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
+ readl(host->ioaddr + SDHCI_ARGUMENT),
+ readw(host->ioaddr + SDHCI_TRANSFER_MODE));
+ printk(KERN_DEBUG DRIVER_NAME ": Present: 0x%08x | Host ctl: 0x%08x\n",
+ readl(host->ioaddr + SDHCI_PRESENT_STATE),
+ readb(host->ioaddr + SDHCI_HOST_CONTROL));
+ printk(KERN_DEBUG DRIVER_NAME ": Power: 0x%08x | Blk gap: 0x%08x\n",
+ readb(host->ioaddr + SDHCI_POWER_CONTROL),
+ readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL));
+ printk(KERN_DEBUG DRIVER_NAME ": Wake-up: 0x%08x | Clock: 0x%08x\n",
+ readb(host->ioaddr + SDHCI_WALK_UP_CONTROL),
+ readw(host->ioaddr + SDHCI_CLOCK_CONTROL));
+ printk(KERN_DEBUG DRIVER_NAME ": Timeout: 0x%08x | Int stat: 0x%08x\n",
+ readb(host->ioaddr + SDHCI_TIMEOUT_CONTROL),
+ readl(host->ioaddr + SDHCI_INT_STATUS));
+ printk(KERN_DEBUG DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
+ readl(host->ioaddr + SDHCI_INT_ENABLE),
+ readl(host->ioaddr + SDHCI_SIGNAL_ENABLE));
+ printk(KERN_DEBUG DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
+ readw(host->ioaddr + SDHCI_ACMD12_ERR),
+ readw(host->ioaddr + SDHCI_SLOT_INT_STATUS));
+ printk(KERN_DEBUG DRIVER_NAME ": Caps: 0x%08x | Max curr: 0x%08x\n",
+ readl(host->ioaddr + SDHCI_CAPABILITIES),
+ readl(host->ioaddr + SDHCI_MAX_CURRENT));
+
+ printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
+}
+
+/*****************************************************************************\
+ * *
+ * Low level functions *
+ * *
+\*****************************************************************************/
+
+static void sdhci_reset(struct sdhci_host *host, u8 mask)
+{
+ writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET);
+
+ if (mask & SDHCI_RESET_ALL) {
+ host->clock = 0;
+
+ mdelay(50);
+ }
+}
+
+static void sdhci_init(struct sdhci_host *host)
+{
+ u32 intmask;
+
+ sdhci_reset(host, SDHCI_RESET_ALL);
+
+ intmask = ~(SDHCI_INT_CARD_INT | SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
+
+ writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
+ writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
+
+ /* This is unknown magic. */
+ writeb(0xE, host->ioaddr + SDHCI_TIMEOUT_CONTROL);
+}
+
+static void sdhci_activate_led(struct sdhci_host *host)
+{
+ u8 ctrl;
+
+ ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
+ ctrl |= SDHCI_CTRL_LED;
+ writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
+}
+
+static void sdhci_deactivate_led(struct sdhci_host *host)
+{
+ u8 ctrl;
+
+ ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
+ ctrl &= ~SDHCI_CTRL_LED;
+ writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
+}
+
+/*****************************************************************************\
+ * *
+ * Core functions *
+ * *
+\*****************************************************************************/
+
+static inline char* sdhci_kmap_sg(struct sdhci_host* host)
+{
+ host->mapped_sg = kmap_atomic(host->cur_sg->page, KM_BIO_SRC_IRQ);
+ return host->mapped_sg + host->cur_sg->offset;
+}
+
+static inline void sdhci_kunmap_sg(struct sdhci_host* host)
+{
+ kunmap_atomic(host->mapped_sg, KM_BIO_SRC_IRQ);
+}
+
+static inline int sdhci_next_sg(struct sdhci_host* host)
+{
+ /*
+ * Skip to next SG entry.
+ */
+ host->cur_sg++;
+ host->num_sg--;
+
+ /*
+ * Any entries left?
+ */
+ if (host->num_sg > 0) {
+ host->offset = 0;
+ host->remain = host->cur_sg->length;
+ }
+
+ return host->num_sg;
+}
+
+static void sdhci_transfer_pio(struct sdhci_host *host)
+{
+ char *buffer;
+ u32 mask;
+ int bytes, size;
+ unsigned long max_jiffies;
+
+ BUG_ON(!host->data);
+
+ if (host->num_sg == 0)
+ return;
+
+ bytes = 0;
+ if (host->data->flags & MMC_DATA_READ)
+ mask = SDHCI_DATA_AVAILABLE;
+ else
+ mask = SDHCI_SPACE_AVAILABLE;
+
+ buffer = sdhci_kmap_sg(host) + host->offset;
+
+ /* Transfer shouldn't take more than 5 s */
+ max_jiffies = jiffies + HZ * 5;
+
+ while (host->size > 0) {
+ if (time_after(jiffies, max_jiffies)) {
+ printk(KERN_ERR "%s: PIO transfer stalled. "
+ "Please report this to "
+ BUGMAIL ".\n", mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+
+ sdhci_kunmap_sg(host);
+
+ host->data->error = MMC_ERR_FAILED;
+ sdhci_finish_data(host);
+ return;
+ }
+
+ if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask))
+ continue;
+
+ size = min(host->size, host->remain);
+
+ if (size >= 4) {
+ if (host->data->flags & MMC_DATA_READ)
+ *(u32*)buffer = readl(host->ioaddr + SDHCI_BUFFER);
+ else
+ writel(*(u32*)buffer, host->ioaddr + SDHCI_BUFFER);
+ size = 4;
+ } else if (size >= 2) {
+ if (host->data->flags & MMC_DATA_READ)
+ *(u16*)buffer = readw(host->ioaddr + SDHCI_BUFFER);
+ else
+ writew(*(u16*)buffer, host->ioaddr + SDHCI_BUFFER);
+ size = 2;
+ } else {
+ if (host->data->flags & MMC_DATA_READ)
+ *(u8*)buffer = readb(host->ioaddr + SDHCI_BUFFER);
+ else
+ writeb(*(u8*)buffer, host->ioaddr + SDHCI_BUFFER);
+ size = 1;
+ }
+
+ buffer += size;
+ host->offset += size;
+ host->remain -= size;
+
+ bytes += size;
+ host->size -= size;
+
+ if (host->remain == 0) {
+ sdhci_kunmap_sg(host);
+ if (sdhci_next_sg(host) == 0) {
+ DBG("PIO transfer: %d bytes\n", bytes);
+ return;
+ }
+ buffer = sdhci_kmap_sg(host);
+ }
+ }
+
+ sdhci_kunmap_sg(host);
+
+ DBG("PIO transfer: %d bytes\n", bytes);
+}
+
+static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
+{
+ u16 mode;
+
+ WARN_ON(host->data);
+
+ if (data == NULL) {
+ writew(0, host->ioaddr + SDHCI_TRANSFER_MODE);
+ return;
+ }
+
+ DBG("blksz %04x blks %04x flags %08x\n",
+ 1 << data->blksz_bits, data->blocks, data->flags);
+ DBG("tsac %d ms nsac %d clk\n",
+ data->timeout_ns / 1000000, data->timeout_clks);
+
+ mode = SDHCI_TRNS_BLK_CNT_EN;
+ if (data->blocks > 1)
+ mode |= SDHCI_TRNS_MULTI;
+ if (data->flags & MMC_DATA_READ)
+ mode |= SDHCI_TRNS_READ;
+ if (host->flags & SDHCI_USE_DMA)
+ mode |= SDHCI_TRNS_DMA;
+
+ writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE);
+
+ writew(1 << data->blksz_bits, host->ioaddr + SDHCI_BLOCK_SIZE);
+ writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT);
+
+ if (host->flags & SDHCI_USE_DMA) {
+ int count;
+
+ count = pci_map_sg(host->chip->pdev, data->sg, data->sg_len,
+ (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
+ BUG_ON(count != 1);
+
+ writel(sg_dma_address(data->sg), host->ioaddr + SDHCI_DMA_ADDRESS);
+ } else {
+ host->size = (1 << data->blksz_bits) * data->blocks;
+
+ host->cur_sg = data->sg;
+ host->num_sg = data->sg_len;
+
+ host->offset = 0;
+ host->remain = host->cur_sg->length;
+ }
+}
+
+static void sdhci_finish_data(struct sdhci_host *host)
+{
+ struct mmc_data *data;
+ u32 intmask;
+ u16 blocks;
+
+ BUG_ON(!host->data);
+
+ data = host->data;
+ host->data = NULL;
+
+ if (host->flags & SDHCI_USE_DMA) {
+ pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len,
+ (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
+ } else {
+ intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE);
+ intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
+ writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
+
+ intmask = readl(host->ioaddr + SDHCI_INT_ENABLE);
+ intmask &= ~(SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL);
+ writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
+ }
+
+ /*
+ * Controller doesn't count down when in single block mode.
+ */
+ if ((data->blocks == 1) && (data->error == MMC_ERR_NONE))
+ blocks = 0;
+ else
+ blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT);
+ data->bytes_xfered = (1 << data->blksz_bits) * (data->blocks - blocks);
+
+ if ((data->error == MMC_ERR_NONE) && blocks) {
+ printk(KERN_ERR "%s: Controller signalled completion even "
+ "though there were blocks left. Please report this "
+ "to " BUGMAIL ".\n", mmc_hostname(host->mmc));
+ data->error = MMC_ERR_FAILED;
+ }
+
+ if (host->size != 0) {
+ printk(KERN_ERR "%s: %d bytes were left untransferred. "
+ "Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc), host->size);
+ data->error = MMC_ERR_FAILED;
+ }
+
+ DBG("Ending data transfer (%d bytes)\n", data->bytes_xfered);
+
+ if (data->stop) {
+ /*
+ * The controller needs a reset of internal state machines
+ * upon error conditions.
+ */
+ if (data->error != MMC_ERR_NONE) {
+ sdhci_reset(host, SDHCI_RESET_CMD);
+ sdhci_reset(host, SDHCI_RESET_DATA);
+ }
+
+ sdhci_send_command(host, data->stop);
+ } else
+ tasklet_schedule(&host->finish_tasklet);
+}
+
+static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
+{
+ int flags;
+ u32 present;
+ unsigned long max_jiffies;
+
+ WARN_ON(host->cmd);
+
+ DBG("Sending cmd (%x)\n", cmd->opcode);
+
+ /* Wait max 10 ms */
+ max_jiffies = jiffies + (HZ + 99)/100;
+ do {
+ if (time_after(jiffies, max_jiffies)) {
+ printk(KERN_ERR "%s: Controller never released "
+ "inhibit bits. Please report this to "
+ BUGMAIL ".\n", mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+ cmd->error = MMC_ERR_FAILED;
+ tasklet_schedule(&host->finish_tasklet);
+ return;
+ }
+ present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
+ } while (present & (SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT));
+
+ mod_timer(&host->timer, jiffies + 10 * HZ);
+
+ host->cmd = cmd;
+
+ sdhci_prepare_data(host, cmd->data);
+
+ writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT);
+
+ if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
+ printk(KERN_ERR "%s: Unsupported response type! "
+ "Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ cmd->error = MMC_ERR_INVALID;
+ tasklet_schedule(&host->finish_tasklet);
+ return;
+ }
+
+ if (!(cmd->flags & MMC_RSP_PRESENT))
+ flags = SDHCI_CMD_RESP_NONE;
+ else if (cmd->flags & MMC_RSP_136)
+ flags = SDHCI_CMD_RESP_LONG;
+ else if (cmd->flags & MMC_RSP_BUSY)
+ flags = SDHCI_CMD_RESP_SHORT_BUSY;
+ else
+ flags = SDHCI_CMD_RESP_SHORT;
+
+ if (cmd->flags & MMC_RSP_CRC)
+ flags |= SDHCI_CMD_CRC;
+ if (cmd->flags & MMC_RSP_OPCODE)
+ flags |= SDHCI_CMD_INDEX;
+ if (cmd->data)
+ flags |= SDHCI_CMD_DATA;
+
+ writel(SDHCI_MAKE_CMD(cmd->opcode, flags),
+ host->ioaddr + SDHCI_COMMAND);
+}
+
+static void sdhci_finish_command(struct sdhci_host *host)
+{
+ int i;
+
+ BUG_ON(host->cmd == NULL);
+
+ if (host->cmd->flags & MMC_RSP_PRESENT) {
+ if (host->cmd->flags & MMC_RSP_136) {
+ /* CRC is stripped so we need to do some shifting. */
+ for (i = 0;i < 4;i++) {
+ host->cmd->resp[i] = readl(host->ioaddr +
+ SDHCI_RESPONSE + (3-i)*4) << 8;
+ if (i != 3)
+ host->cmd->resp[i] |=
+ readb(host->ioaddr +
+ SDHCI_RESPONSE + (3-i)*4-1);
+ }
+ } else {
+ host->cmd->resp[0] = readl(host->ioaddr + SDHCI_RESPONSE);
+ }
+ }
+
+ host->cmd->error = MMC_ERR_NONE;
+
+ DBG("Ending cmd (%x)\n", host->cmd->opcode);
+
+ if (host->cmd->data) {
+ u32 intmask;
+
+ host->data = host->cmd->data;
+
+ if (!(host->flags & SDHCI_USE_DMA)) {
+ /*
+ * Don't enable the interrupts until now to make sure we
+ * get stable handling of the FIFO.
+ */
+ intmask = readl(host->ioaddr + SDHCI_INT_ENABLE);
+ intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL;
+ writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
+
+ intmask = readl(host->ioaddr + SDHCI_SIGNAL_ENABLE);
+ intmask |= SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL;
+ writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
+
+ /*
+ * The buffer interrupts are to unreliable so we
+ * start the transfer immediatly.
+ */
+ sdhci_transfer_pio(host);
+ }
+ } else
+ tasklet_schedule(&host->finish_tasklet);
+
+ host->cmd = NULL;
+}
+
+static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
+{
+ int div;
+ u16 clk;
+ unsigned long max_jiffies;
+
+ if (clock == host->clock)
+ return;
+
+ writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
+
+ if (clock == 0)
+ goto out;
+
+ for (div = 1;div < 256;div *= 2) {
+ if ((host->max_clk / div) <= clock)
+ break;
+ }
+ div >>= 1;
+
+ clk = div << SDHCI_DIVIDER_SHIFT;
+ clk |= SDHCI_CLOCK_INT_EN;
+ writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
+
+ /* Wait max 10 ms */
+ max_jiffies = jiffies + (HZ + 99)/100;
+ do {
+ if (time_after(jiffies, max_jiffies)) {
+ printk(KERN_ERR "%s: Internal clock never stabilised. "
+ "Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+ return;
+ }
+ clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL);
+ } while (!(clk & SDHCI_CLOCK_INT_STABLE));
+
+ clk |= SDHCI_CLOCK_CARD_EN;
+ writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
+
+out:
+ host->clock = clock;
+}
+
+/*****************************************************************************\
+ * *
+ * MMC callbacks *
+ * *
+\*****************************************************************************/
+
+static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+
+ host = mmc_priv(mmc);
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ WARN_ON(host->mrq != NULL);
+
+ sdhci_activate_led(host);
+
+ host->mrq = mrq;
+
+ if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
+ host->mrq->cmd->error = MMC_ERR_TIMEOUT;
+ tasklet_schedule(&host->finish_tasklet);
+ } else
+ sdhci_send_command(host, mrq->cmd);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+}
+
+static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+ u8 ctrl;
+
+ host = mmc_priv(mmc);
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ DBG("clock %uHz busmode %u powermode %u cs %u Vdd %u width %u\n",
+ ios->clock, ios->bus_mode, ios->power_mode, ios->chip_select,
+ ios->vdd, ios->bus_width);
+
+ /*
+ * Reset the chip on each power off.
+ * Should clear out any weird states.
+ */
+ if (ios->power_mode == MMC_POWER_OFF) {
+ writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE);
+ spin_unlock_irqrestore(&host->lock, flags);
+ sdhci_init(host);
+ spin_lock_irqsave(&host->lock, flags);
+ }
+
+ sdhci_set_clock(host, ios->clock);
+
+ if (ios->power_mode == MMC_POWER_OFF)
+ writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
+ else
+ writeb(0xFF, host->ioaddr + SDHCI_POWER_CONTROL);
+
+ ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
+ if (ios->bus_width == MMC_BUS_WIDTH_4)
+ ctrl |= SDHCI_CTRL_4BITBUS;
+ else
+ ctrl &= ~SDHCI_CTRL_4BITBUS;
+ writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+}
+
+static int sdhci_get_ro(struct mmc_host *mmc)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+ int present;
+
+ host = mmc_priv(mmc);
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ return !(present & SDHCI_WRITE_PROTECT);
+}
+
+static struct mmc_host_ops sdhci_ops = {
+ .request = sdhci_request,
+ .set_ios = sdhci_set_ios,
+ .get_ro = sdhci_get_ro,
+};
+
+/*****************************************************************************\
+ * *
+ * Tasklets *
+ * *
+\*****************************************************************************/
+
+static void sdhci_tasklet_card(unsigned long param)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+
+ host = (struct sdhci_host*)param;
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
+ if (host->mrq) {
+ printk(KERN_ERR "%s: Card removed during transfer!\n",
+ mmc_hostname(host->mmc));
+ printk(KERN_ERR "%s: Resetting controller.\n",
+ mmc_hostname(host->mmc));
+
+ sdhci_reset(host, SDHCI_RESET_CMD);
+ sdhci_reset(host, SDHCI_RESET_DATA);
+
+ host->mrq->cmd->error = MMC_ERR_FAILED;
+ tasklet_schedule(&host->finish_tasklet);
+ }
+ }
+
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ mmc_detect_change(host->mmc, msecs_to_jiffies(500));
+}
+
+static void sdhci_tasklet_finish(unsigned long param)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+ struct mmc_request *mrq;
+
+ host = (struct sdhci_host*)param;
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ del_timer(&host->timer);
+
+ mrq = host->mrq;
+
+ DBG("Ending request, cmd (%x)\n", mrq->cmd->opcode);
+
+ /*
+ * The controller needs a reset of internal state machines
+ * upon error conditions.
+ */
+ if ((mrq->cmd->error != MMC_ERR_NONE) ||
+ (mrq->data && ((mrq->data->error != MMC_ERR_NONE) ||
+ (mrq->data->stop && (mrq->data->stop->error != MMC_ERR_NONE))))) {
+ sdhci_reset(host, SDHCI_RESET_CMD);
+ sdhci_reset(host, SDHCI_RESET_DATA);
+ }
+
+ host->mrq = NULL;
+ host->cmd = NULL;
+ host->data = NULL;
+
+ sdhci_deactivate_led(host);
+
+ spin_unlock_irqrestore(&host->lock, flags);
+
+ mmc_request_done(host->mmc, mrq);
+}
+
+static void sdhci_timeout_timer(unsigned long data)
+{
+ struct sdhci_host *host;
+ unsigned long flags;
+
+ host = (struct sdhci_host*)data;
+
+ spin_lock_irqsave(&host->lock, flags);
+
+ if (host->mrq) {
+ printk(KERN_ERR "%s: Timeout waiting for hardware interrupt. "
+ "Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+
+ if (host->data) {
+ host->data->error = MMC_ERR_TIMEOUT;
+ sdhci_finish_data(host);
+ } else {
+ if (host->cmd)
+ host->cmd->error = MMC_ERR_TIMEOUT;
+ else
+ host->mrq->cmd->error = MMC_ERR_TIMEOUT;
+
+ tasklet_schedule(&host->finish_tasklet);
+ }
+ }
+
+ spin_unlock_irqrestore(&host->lock, flags);
+}
+
+/*****************************************************************************\
+ * *
+ * Interrupt handling *
+ * *
+\*****************************************************************************/
+
+static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
+{
+ BUG_ON(intmask == 0);
+
+ if (!host->cmd) {
+ printk(KERN_ERR "%s: Got command interrupt even though no "
+ "command operation was in progress.\n",
+ mmc_hostname(host->mmc));
+ printk(KERN_ERR "%s: Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+ return;
+ }
+
+ if (intmask & SDHCI_INT_RESPONSE)
+ sdhci_finish_command(host);
+ else {
+ if (intmask & SDHCI_INT_TIMEOUT)
+ host->cmd->error = MMC_ERR_TIMEOUT;
+ else if (intmask & SDHCI_INT_CRC)
+ host->cmd->error = MMC_ERR_BADCRC;
+ else if (intmask & (SDHCI_INT_END_BIT | SDHCI_INT_INDEX))
+ host->cmd->error = MMC_ERR_FAILED;
+ else
+ host->cmd->error = MMC_ERR_INVALID;
+
+ tasklet_schedule(&host->finish_tasklet);
+ }
+}
+
+static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
+{
+ BUG_ON(intmask == 0);
+
+ if (!host->data) {
+ /*
+ * A data end interrupt is sent together with the response
+ * for the stop command.
+ */
+ if (intmask & SDHCI_INT_DATA_END)
+ return;
+
+ printk(KERN_ERR "%s: Got data interrupt even though no "
+ "data operation was in progress.\n",
+ mmc_hostname(host->mmc));
+ printk(KERN_ERR "%s: Please report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+
+ return;
+ }
+
+ if (intmask & SDHCI_INT_DATA_TIMEOUT)
+ host->data->error = MMC_ERR_TIMEOUT;
+ else if (intmask & SDHCI_INT_DATA_CRC)
+ host->data->error = MMC_ERR_BADCRC;
+ else if (intmask & SDHCI_INT_DATA_END_BIT)
+ host->data->error = MMC_ERR_FAILED;
+
+ if (host->data->error != MMC_ERR_NONE)
+ sdhci_finish_data(host);
+ else {
+ if (intmask & (SDHCI_INT_BUF_FULL | SDHCI_INT_BUF_EMPTY))
+ sdhci_transfer_pio(host);
+
+ if (intmask & SDHCI_INT_DATA_END)
+ sdhci_finish_data(host);
+ }
+}
+
+static irqreturn_t sdhci_irq(int irq, void *dev_id, struct pt_regs *regs)
+{
+ irqreturn_t result;
+ struct sdhci_host* host = dev_id;
+ u32 intmask;
+
+ spin_lock(&host->lock);
+
+ intmask = readl(host->ioaddr + SDHCI_INT_STATUS);
+
+ if (!intmask) {
+ result = IRQ_NONE;
+ goto out;
+ }
+
+ DBG("*** %s got interrupt: 0x%08x\n", host->slot_descr, intmask);
+
+ if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE))
+ tasklet_schedule(&host->card_tasklet);
+
+ if (intmask & SDHCI_INT_CMD_MASK) {
+ sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
+
+ writel(intmask & SDHCI_INT_CMD_MASK,
+ host->ioaddr + SDHCI_INT_STATUS);
+ }
+
+ if (intmask & SDHCI_INT_DATA_MASK) {
+ sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
+
+ writel(intmask & SDHCI_INT_DATA_MASK,
+ host->ioaddr + SDHCI_INT_STATUS);
+ }
+
+ intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
+
+ if (intmask & SDHCI_INT_CARD_INT) {
+ printk(KERN_ERR "%s: Unexpected card interrupt. Please "
+ "report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+ }
+
+ if (intmask & SDHCI_INT_BUS_POWER) {
+ printk(KERN_ERR "%s: Unexpected bus power interrupt. Please "
+ "report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+ }
+
+ if (intmask & SDHCI_INT_ACMD12ERR) {
+ printk(KERN_ERR "%s: Unexpected auto CMD12 error. Please "
+ "report this to " BUGMAIL ".\n",
+ mmc_hostname(host->mmc));
+ sdhci_dumpregs(host);
+
+ writew(~0, host->ioaddr + SDHCI_ACMD12_ERR);
+ }
+
+ if (intmask)
+ writel(intmask, host->ioaddr + SDHCI_INT_STATUS);
+
+ result = IRQ_HANDLED;
+
+out:
+ spin_unlock(&host->lock);
+
+ return result;
+}
+
+/*****************************************************************************\
+ * *
+ * Suspend/resume *
+ * *
+\*****************************************************************************/
+
+#ifdef CONFIG_PM
+
+static int sdhci_suspend (struct pci_dev *pdev, pm_message_t state)
+{
+ struct sdhci_chip *chip;
+ int i, ret;
+
+ chip = pci_get_drvdata(pdev);
+ if (!chip)
+ return 0;
+
+ DBG("Suspending...\n");
+
+ for (i = 0;i < chip->num_slots;i++) {
+ if (!chip->hosts[i])
+ continue;
+ ret = mmc_suspend_host(chip->hosts[i]->mmc, state);
+ if (ret) {
+ for (i--;i >= 0;i--)
+ mmc_resume_host(chip->hosts[i]->mmc);
+ return ret;
+ }
+ }
+
+ pci_save_state(pdev);
+ pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
+ pci_disable_device(pdev);
+ pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
+ return 0;
+}
+
+static int sdhci_resume (struct pci_dev *pdev)
+{
+ struct sdhci_chip *chip;
+ int i, ret;
+
+ chip = pci_get_drvdata(pdev);
+ if (!chip)
+ return 0;
+
+ DBG("Resuming...\n");
+
+ pci_set_power_state(pdev, PCI_D0);
+ pci_restore_state(pdev);
+ pci_enable_device(pdev);
+
+ for (i = 0;i < chip->num_slots;i++) {
+ if (!chip->hosts[i])
+ continue;
+ if (chip->hosts[i]->flags & SDHCI_USE_DMA)
+ pci_set_master(pdev);
+ sdhci_init(chip->hosts[i]);
+ ret = mmc_resume_host(chip->hosts[i]->mmc);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+#else /* CONFIG_PM */
+
+#define sdhci_suspend NULL
+#define sdhci_resume NULL
+
+#endif /* CONFIG_PM */
+
+/*****************************************************************************\
+ * *
+ * Device probing/removal *
+ * *
+\*****************************************************************************/
+
+static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
+{
+ int ret;
+ struct sdhci_chip *chip;
+ struct mmc_host *mmc;
+ struct sdhci_host *host;
+
+ u8 first_bar;
+ unsigned int caps;
+
+ chip = pci_get_drvdata(pdev);
+ BUG_ON(!chip);
+
+ ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
+ if (ret)
+ return ret;
+
+ first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
+
+ if (first_bar > 5) {
+ printk(KERN_ERR DRIVER_NAME ": Invalid first BAR. Aborting.\n");
+ return -ENODEV;
+ }
+
+ if (!(pci_resource_flags(pdev, first_bar + slot) & IORESOURCE_MEM)) {
+ printk(KERN_ERR DRIVER_NAME ": BAR is not iomem. Aborting.\n");
+ return -ENODEV;
+ }
+
+ if (pci_resource_len(pdev, first_bar + slot) != 0x100) {
+ printk(KERN_ERR DRIVER_NAME ": Invalid iomem size. Aborting.\n");
+ return -ENODEV;
+ }
+
+ mmc = mmc_alloc_host(sizeof(struct sdhci_host), &pdev->dev);
+ if (!mmc)
+ return -ENOMEM;
+
+ host = mmc_priv(mmc);
+ host->mmc = mmc;
+
+ host->bar = first_bar + slot;
+
+ host->addr = pci_resource_start(pdev, host->bar);
+ host->irq = pdev->irq;
+
+ DBG("slot %d at 0x%08lx, irq %d\n", slot, host->addr, host->irq);
+
+ snprintf(host->slot_descr, 20, "sdhci:slot%d", slot);
+
+ ret = pci_request_region(pdev, host->bar, host->slot_descr);
+ if (ret)
+ goto free;
+
+ host->ioaddr = ioremap_nocache(host->addr,
+ pci_resource_len(pdev, host->bar));
+ if (!host->ioaddr) {
+ ret = -ENOMEM;
+ goto release;
+ }
+
+ caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
+
+ if ((caps & SDHCI_CAN_DO_DMA) && ((pdev->class & 0x0000FF) == 0x01))
+ host->flags |= SDHCI_USE_DMA;
+
+ if (host->flags & SDHCI_USE_DMA) {
+ if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
+ printk(KERN_WARNING "%s: No suitable DMA available. "
+ "Falling back to PIO.\n", host->slot_descr);
+ host->flags &= ~SDHCI_USE_DMA;
+ }
+ }
+
+ if (host->flags & SDHCI_USE_DMA)
+ pci_set_master(pdev);
+ else /* XXX: Hack to get MMC layer to avoid highmem */
+ pdev->dma_mask = 0;
+
+ host->max_clk = (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
+ host->max_clk *= 1000000;
+
+ /*
+ * Set host parameters.
+ */
+ mmc->ops = &sdhci_ops;
+ mmc->f_min = host->max_clk / 256;
+ mmc->f_max = host->max_clk;
+ mmc->ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34;
+ mmc->caps = MMC_CAP_4_BIT_DATA;
+
+ spin_lock_init(&host->lock);
+
+ /*
+ * Maximum number of segments. Hardware cannot do scatter lists.
+ */
+ if (host->flags & SDHCI_USE_DMA)
+ mmc->max_hw_segs = 1;
+ else
+ mmc->max_hw_segs = 16;
+ mmc->max_phys_segs = 16;
+
+ /*
+ * Maximum number of sectors in one transfer. Limited by sector
+ * count register.
+ */
+ mmc->max_sectors = 0x3FFF;
+
+ /*
+ * Maximum segment size. Could be one segment with the maximum number
+ * of sectors.
+ */
+ mmc->max_seg_size = mmc->max_sectors * 512;
+
+ /*
+ * Init tasklets.
+ */
+ tasklet_init(&host->card_tasklet,
+ sdhci_tasklet_card, (unsigned long)host);
+ tasklet_init(&host->finish_tasklet,
+ sdhci_tasklet_finish, (unsigned long)host);
+
+ setup_timer(&host->timer, sdhci_timeout_timer, (int)host);
+
+ ret = request_irq(host->irq, sdhci_irq, SA_SHIRQ,
+ host->slot_descr, host);
+ if (ret)
+ goto unmap;
+
+ sdhci_init(host);
+
+#ifdef CONFIG_MMC_DEBUG
+ sdhci_dumpregs(host);
+#endif
+
+ host->chip = chip;
+ chip->hosts[slot] = host;
+
+ mmc_add_host(mmc);
+
+ printk(KERN_INFO "%s: SDHCI at 0x%08lx irq %d %s\n", mmc_hostname(mmc),
+ host->addr, host->irq,
+ (host->flags & SDHCI_USE_DMA)?"DMA":"PIO");
+
+ return 0;
+
+unmap:
+ tasklet_kill(&host->card_tasklet);
+ tasklet_kill(&host->finish_tasklet);
+
+ iounmap(host->ioaddr);
+release:
+ pci_release_region(pdev, host->bar);
+free:
+ mmc_free_host(mmc);
+
+ return ret;
+}
+
+static void sdhci_remove_slot(struct pci_dev *pdev, int slot)
+{
+ struct sdhci_chip *chip;
+ struct mmc_host *mmc;
+ struct sdhci_host *host;
+
+ chip = pci_get_drvdata(pdev);
+ host = chip->hosts[slot];
+ mmc = host->mmc;
+
+ chip->hosts[slot] = NULL;
+
+ mmc_remove_host(mmc);
+
+ sdhci_reset(host, SDHCI_RESET_ALL);
+
+ free_irq(host->irq, host);
+
+ del_timer_sync(&host->timer);
+
+ tasklet_kill(&host->card_tasklet);
+ tasklet_kill(&host->finish_tasklet);
+
+ iounmap(host->ioaddr);
+
+ pci_release_region(pdev, host->bar);
+
+ mmc_free_host(mmc);
+}
+
+static int __devinit sdhci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int ret, i;
+ u8 slots;
+ struct sdhci_chip *chip;
+
+ BUG_ON(pdev == NULL);
+ BUG_ON(ent == NULL);
+
+ DBG("found at %s\n", pci_name(pdev));
+
+ ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
+ if (ret)
+ return ret;
+
+ slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
+ DBG("found %d slot(s)\n", slots);
+ if (slots == 0)
+ return -ENODEV;
+
+ ret = pci_enable_device(pdev);
+ if (ret)
+ return ret;
+
+ chip = kzalloc(sizeof(struct sdhci_chip) +
+ sizeof(struct sdhci_host*) * slots, GFP_KERNEL);
+ if (!chip) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ chip->pdev = pdev;
+
+ chip->num_slots = slots;
+ pci_set_drvdata(pdev, chip);
+
+ for (i = 0;i < slots;i++) {
+ ret = sdhci_probe_slot(pdev, i);
+ if (ret) {
+ for (i--;i >= 0;i--)
+ sdhci_remove_slot(pdev, i);
+ goto free;
+ }
+ }
+
+ return 0;
+
+free:
+ pci_set_drvdata(pdev, NULL);
+ kfree(chip);
+
+err:
+ pci_disable_device(pdev);
+ return ret;
+}
+
+static void __devexit sdhci_remove(struct pci_dev *pdev)
+{
+ int i;
+ struct sdhci_chip *chip;
+
+ chip = pci_get_drvdata(pdev);
+
+ if (chip) {
+ for (i = 0;i < chip->num_slots;i++)
+ sdhci_remove_slot(pdev, i);
+
+ pci_set_drvdata(pdev, NULL);
+
+ kfree(chip);
+ }
+
+ pci_disable_device(pdev);
+}
+
+static struct pci_driver sdhci_driver = {
+ .name = DRIVER_NAME,
+ .id_table = pci_ids,
+ .probe = sdhci_probe,
+ .remove = __devexit_p(sdhci_remove),
+ .suspend = sdhci_suspend,
+ .resume = sdhci_resume,
+};
+
+/*****************************************************************************\
+ * *
+ * Driver init/exit *
+ * *
+\*****************************************************************************/
+
+static int __init sdhci_drv_init(void)
+{
+ printk(KERN_INFO DRIVER_NAME
+ ": Secure Digital Host Controller Interface driver, "
+ DRIVER_VERSION "\n");
+ printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
+
+ return pci_register_driver(&sdhci_driver);
+}
+
+static void __exit sdhci_drv_exit(void)
+{
+ DBG("Exiting\n");
+
+ pci_unregister_driver(&sdhci_driver);
+}
+
+module_init(sdhci_drv_init);
+module_exit(sdhci_drv_exit);
+
+MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
+MODULE_DESCRIPTION("Secure Digital Host Controller Interface driver");
+MODULE_VERSION(DRIVER_VERSION);
+MODULE_LICENSE("GPL");
diff --git a/drivers/mmc/sdhci.h b/drivers/mmc/sdhci.h
new file mode 100644
index 00000000000..3b270ef486b
--- /dev/null
+++ b/drivers/mmc/sdhci.h
@@ -0,0 +1,185 @@
+/*
+ * linux/drivers/mmc/sdhci.h - Secure Digital Host Controller Interface driver
+ *
+ * Copyright (C) 2005 Pierre Ossman, All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * PCI registers
+ */
+
+#define PCI_SLOT_INFO 0x40 /* 8 bits */
+#define PCI_SLOT_INFO_SLOTS(x) ((x >> 4) & 7)
+#define PCI_SLOT_INFO_FIRST_BAR_MASK 0x07
+
+/*
+ * Controller registers
+ */
+
+#define SDHCI_DMA_ADDRESS 0x00
+
+#define SDHCI_BLOCK_SIZE 0x04
+
+#define SDHCI_BLOCK_COUNT 0x06
+
+#define SDHCI_ARGUMENT 0x08
+
+#define SDHCI_TRANSFER_MODE 0x0C
+#define SDHCI_TRNS_DMA 0x01
+#define SDHCI_TRNS_BLK_CNT_EN 0x02
+#define SDHCI_TRNS_ACMD12 0x04
+#define SDHCI_TRNS_READ 0x10
+#define SDHCI_TRNS_MULTI 0x20
+
+#define SDHCI_COMMAND 0x0E
+#define SDHCI_CMD_RESP_MASK 0x03
+#define SDHCI_CMD_CRC 0x08
+#define SDHCI_CMD_INDEX 0x10
+#define SDHCI_CMD_DATA 0x20
+
+#define SDHCI_CMD_RESP_NONE 0x00
+#define SDHCI_CMD_RESP_LONG 0x01
+#define SDHCI_CMD_RESP_SHORT 0x02
+#define SDHCI_CMD_RESP_SHORT_BUSY 0x03
+
+#define SDHCI_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
+
+#define SDHCI_RESPONSE 0x10
+
+#define SDHCI_BUFFER 0x20
+
+#define SDHCI_PRESENT_STATE 0x24
+#define SDHCI_CMD_INHIBIT 0x00000001
+#define SDHCI_DATA_INHIBIT 0x00000002
+#define SDHCI_DOING_WRITE 0x00000100
+#define SDHCI_DOING_READ 0x00000200
+#define SDHCI_SPACE_AVAILABLE 0x00000400
+#define SDHCI_DATA_AVAILABLE 0x00000800
+#define SDHCI_CARD_PRESENT 0x00010000
+#define SDHCI_WRITE_PROTECT 0x00080000
+
+#define SDHCI_HOST_CONTROL 0x28
+#define SDHCI_CTRL_LED 0x01
+#define SDHCI_CTRL_4BITBUS 0x02
+
+#define SDHCI_POWER_CONTROL 0x29
+
+#define SDHCI_BLOCK_GAP_CONTROL 0x2A
+
+#define SDHCI_WALK_UP_CONTROL 0x2B
+
+#define SDHCI_CLOCK_CONTROL 0x2C
+#define SDHCI_DIVIDER_SHIFT 8
+#define SDHCI_CLOCK_CARD_EN 0x0004
+#define SDHCI_CLOCK_INT_STABLE 0x0002
+#define SDHCI_CLOCK_INT_EN 0x0001
+
+#define SDHCI_TIMEOUT_CONTROL 0x2E
+
+#define SDHCI_SOFTWARE_RESET 0x2F
+#define SDHCI_RESET_ALL 0x01
+#define SDHCI_RESET_CMD 0x02
+#define SDHCI_RESET_DATA 0x04
+
+#define SDHCI_INT_STATUS 0x30
+#define SDHCI_INT_ENABLE 0x34
+#define SDHCI_SIGNAL_ENABLE 0x38
+#define SDHCI_INT_RESPONSE 0x00000001
+#define SDHCI_INT_DATA_END 0x00000002
+#define SDHCI_INT_DMA_END 0x00000008
+#define SDHCI_INT_BUF_EMPTY 0x00000010
+#define SDHCI_INT_BUF_FULL 0x00000020
+#define SDHCI_INT_CARD_INSERT 0x00000040
+#define SDHCI_INT_CARD_REMOVE 0x00000080
+#define SDHCI_INT_CARD_INT 0x00000100
+#define SDHCI_INT_TIMEOUT 0x00010000
+#define SDHCI_INT_CRC 0x00020000
+#define SDHCI_INT_END_BIT 0x00040000
+#define SDHCI_INT_INDEX 0x00080000
+#define SDHCI_INT_DATA_TIMEOUT 0x00100000
+#define SDHCI_INT_DATA_CRC 0x00200000
+#define SDHCI_INT_DATA_END_BIT 0x00400000
+#define SDHCI_INT_BUS_POWER 0x00800000
+#define SDHCI_INT_ACMD12ERR 0x01000000
+
+#define SDHCI_INT_NORMAL_MASK 0x00007FFF
+#define SDHCI_INT_ERROR_MASK 0xFFFF8000
+
+#define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \
+ SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX)
+#define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \
+ SDHCI_INT_BUF_EMPTY | SDHCI_INT_BUF_FULL | \
+ SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \
+ SDHCI_INT_DATA_END_BIT)
+
+#define SDHCI_ACMD12_ERR 0x3C
+
+/* 3E-3F reserved */
+
+#define SDHCI_CAPABILITIES 0x40
+#define SDHCI_CAN_DO_DMA 0x00400000
+#define SDHCI_CLOCK_BASE_MASK 0x00003F00
+#define SDHCI_CLOCK_BASE_SHIFT 8
+
+/* 44-47 reserved for more caps */
+
+#define SDHCI_MAX_CURRENT 0x48
+
+/* 4C-4F reserved for more max current */
+
+/* 50-FB reserved */
+
+#define SDHCI_SLOT_INT_STATUS 0xFC
+
+#define SDHCI_HOST_VERSION 0xFE
+
+struct sdhci_chip;
+
+struct sdhci_host {
+ struct sdhci_chip *chip;
+ struct mmc_host *mmc; /* MMC structure */
+
+ spinlock_t lock; /* Mutex */
+
+ int flags; /* Host attributes */
+#define SDHCI_USE_DMA (1<<0)
+
+ unsigned int max_clk; /* Max possible freq (MHz) */
+
+ unsigned int clock; /* Current clock (MHz) */
+
+ struct mmc_request *mrq; /* Current request */
+ struct mmc_command *cmd; /* Current command */
+ struct mmc_data *data; /* Current data request */
+
+ struct scatterlist *cur_sg; /* We're working on this */
+ char *mapped_sg; /* This is where it's mapped */
+ int num_sg; /* Entries left */
+ int offset; /* Offset into current sg */
+ int remain; /* Bytes left in current */
+
+ int size; /* Remaining bytes in transfer */
+
+ char slot_descr[20]; /* Name for reservations */
+
+ int irq; /* Device IRQ */
+ int bar; /* PCI BAR index */
+ unsigned long addr; /* Bus address */
+ void __iomem * ioaddr; /* Mapped address */
+
+ struct tasklet_struct card_tasklet; /* Tasklet structures */
+ struct tasklet_struct finish_tasklet;
+
+ struct timer_list timer; /* Timer for timeouts */
+};
+
+struct sdhci_chip {
+ struct pci_dev *pdev;
+
+ int num_slots; /* Slots on controller */
+ struct sdhci_host *hosts[0]; /* Pointers to hosts */
+};
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index f0f8916da7a..f988c817e19 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -28,7 +28,7 @@
#ifdef CONFIG_MTD_DEBUG
static int debug = CONFIG_MTD_DEBUG_VERBOSE;
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "Set Debug Level 0=quiet, 5=noisy");
#undef DEBUG
#define DEBUG(n, format, arg...) \
@@ -89,17 +89,17 @@ static int mem_type;
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Simon Evans <spse@secret.org.uk>");
MODULE_DESCRIPTION(DRIVER_DESC);
-MODULE_PARM(bankwidth, "i");
+module_param(bankwidth, int, 0);
MODULE_PARM_DESC(bankwidth, "Set bankwidth (1=8 bit, 2=16 bit, default=2)");
-MODULE_PARM(mem_speed, "i");
+module_param(mem_speed, int, 0);
MODULE_PARM_DESC(mem_speed, "Set memory access speed in ns");
-MODULE_PARM(force_size, "i");
+module_param(force_size, int, 0);
MODULE_PARM_DESC(force_size, "Force size of card in MiB (1-64)");
-MODULE_PARM(setvpp, "i");
+module_param(setvpp, int, 0);
MODULE_PARM_DESC(setvpp, "Set Vpp (0=Never, 1=On writes, 2=Always on, default=0)");
-MODULE_PARM(vpp, "i");
+module_param(vpp, int, 0);
MODULE_PARM_DESC(vpp, "Vpp value in 1/10ths eg 33=3.3V 120=12V (Dangerous)");
-MODULE_PARM(mem_type, "i");
+module_param(mem_type, int, 0);
MODULE_PARM_DESC(mem_type, "Set Memory type (0=Flash, 1=RAM, 2=ROM, default=0)");
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index 5d11a06ecb2..d339308539f 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -1096,14 +1096,18 @@ static int __init vortex_eisa_init (void)
int orig_cards_found = vortex_cards_found;
#ifdef CONFIG_EISA
- if (eisa_driver_register (&vortex_eisa_driver) >= 0) {
- /* Because of the way EISA bus is probed, we cannot assume
- * any device have been found when we exit from
- * eisa_driver_register (the bus root driver may not be
- * initialized yet). So we blindly assume something was
- * found, and let the sysfs magic happend... */
-
- eisa_found = 1;
+ int err;
+
+ err = eisa_driver_register (&vortex_eisa_driver);
+ if (!err) {
+ /*
+ * Because of the way EISA bus is probed, we cannot assume
+ * any device have been found when we exit from
+ * eisa_driver_register (the bus root driver may not be
+ * initialized yet). So we blindly assume something was
+ * found, and let the sysfs magic happend...
+ */
+ eisa_found = 1;
}
#endif
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index f5ee064ab6b..feae7832fc8 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -1131,7 +1131,7 @@ static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
No extra delay is needed with 33Mhz PCI, but 66Mhz may change this.
*/
-#define eeprom_delay() RTL_R32(Cfg9346)
+#define eeprom_delay() (void)RTL_R32(Cfg9346)
/* The EEPROM commands include the alway-set leading bit. */
#define EE_WRITE_CMD (5)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 00993e8ba58..e20b849a22e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2172,6 +2172,7 @@ config BNX2
config SPIDER_NET
tristate "Spider Gigabit Ethernet driver"
depends on PCI && PPC_CELL
+ select FW_LOADER
help
This driver supports the Gigabit Ethernet chips present on the
Cell Processor-Based Blades from IBM.
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 00e72b12fb9..b90468aea07 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -58,8 +58,8 @@ obj-$(CONFIG_STNIC) += stnic.o 8390.o
obj-$(CONFIG_FEALNX) += fealnx.o
obj-$(CONFIG_TIGON3) += tg3.o
obj-$(CONFIG_BNX2) += bnx2.o
-spidernet-y += spider_net.o spider_net_ethtool.o sungem_phy.o
-obj-$(CONFIG_SPIDER_NET) += spidernet.o
+spidernet-y += spider_net.o spider_net_ethtool.o
+obj-$(CONFIG_SPIDER_NET) += spidernet.o sungem_phy.o
obj-$(CONFIG_TC35815) += tc35815.o
obj-$(CONFIG_SKGE) += skge.o
obj-$(CONFIG_SKY2) += sky2.o
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c
index 8e538a6d7d9..79bb56b8dce 100644
--- a/drivers/net/a2065.c
+++ b/drivers/net/a2065.c
@@ -829,7 +829,7 @@ static void __devexit a2065_remove_one(struct zorro_dev *z)
static int __init a2065_init_module(void)
{
- return zorro_module_init(&a2065_driver);
+ return zorro_register_driver(&a2065_driver);
}
static void __exit a2065_cleanup_module(void)
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c
index 9fe93acfc8e..d1b6b1f794e 100644
--- a/drivers/net/ariadne.c
+++ b/drivers/net/ariadne.c
@@ -864,7 +864,7 @@ static void __devexit ariadne_remove_one(struct zorro_dev *z)
static int __init ariadne_init_module(void)
{
- return zorro_module_init(&ariadne_driver);
+ return zorro_register_driver(&ariadne_driver);
}
static void __exit ariadne_cleanup_module(void)
diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig
index 625184b65e3..77fe20dbea3 100644
--- a/drivers/net/arm/Kconfig
+++ b/drivers/net/arm/Kconfig
@@ -31,3 +31,11 @@ config ARM_ETHERH
help
If you have an Acorn system with one of these network cards, you
should say Y to this option if you wish to use it with Linux.
+
+config ARM_AT91_ETHER
+ tristate "AT91RM9200 Ethernet support"
+ depends on NET_ETHERNET && ARM && ARCH_AT91RM9200
+ select MII
+ help
+ If you wish to compile a kernel for the AT91RM9200 and enable
+ ethernet support, then you should always answer Y to this.
diff --git a/drivers/net/arm/Makefile b/drivers/net/arm/Makefile
index bc263edf06a..42c95b79c26 100644
--- a/drivers/net/arm/Makefile
+++ b/drivers/net/arm/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_ARM_AM79C961A) += am79c961a.o
obj-$(CONFIG_ARM_ETHERH) += etherh.o
obj-$(CONFIG_ARM_ETHER3) += ether3.o
obj-$(CONFIG_ARM_ETHER1) += ether1.o
+obj-$(CONFIG_ARM_AT91_ETHER) += at91_ether.o
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
new file mode 100644
index 00000000000..5503dc8a66e
--- /dev/null
+++ b/drivers/net/arm/at91_ether.c
@@ -0,0 +1,1110 @@
+/*
+ * Ethernet driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * Copyright (C) 2003 SAN People (Pty) Ltd
+ *
+ * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
+ * Initial version by Rick Bronson 01/11/2003
+ *
+ * Intel LXT971A PHY support by Christopher Bahns & David Knickerbocker
+ * (Polaroid Corporation)
+ *
+ * Realtek RTL8201(B)L PHY support by Roman Avramenko <roman@imsystems.ru>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/config.h>
+#include <linux/mii.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/dma-mapping.h>
+#include <linux/ethtool.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+
+#include <asm/io.h>
+#include <asm/uaccess.h>
+#include <asm/mach-types.h>
+
+#include <asm/arch/at91rm9200_emac.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/board.h>
+
+#include "at91_ether.h"
+
+#define DRV_NAME "at91_ether"
+#define DRV_VERSION "1.0"
+
+static struct net_device *at91_dev;
+static struct clk *ether_clk;
+
+/* ..................................................................... */
+
+/*
+ * Read from a EMAC register.
+ */
+static inline unsigned long at91_emac_read(unsigned int reg)
+{
+ void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
+
+ return __raw_readl(emac_base + reg);
+}
+
+/*
+ * Write to a EMAC register.
+ */
+static inline void at91_emac_write(unsigned int reg, unsigned long value)
+{
+ void __iomem *emac_base = (void __iomem *)AT91_VA_BASE_EMAC;
+
+ __raw_writel(value, emac_base + reg);
+}
+
+/* ........................... PHY INTERFACE ........................... */
+
+/*
+ * Enable the MDIO bit in MAC control register
+ * When not called from an interrupt-handler, access to the PHY must be
+ * protected by a spinlock.
+ */
+static void enable_mdi(void)
+{
+ unsigned long ctl;
+
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_MPE); /* enable management port */
+}
+
+/*
+ * Disable the MDIO bit in the MAC control register
+ */
+static void disable_mdi(void)
+{
+ unsigned long ctl;
+
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_MPE); /* disable management port */
+}
+
+/*
+ * Wait until the PHY operation is complete.
+ */
+static inline void at91_phy_wait(void) {
+ unsigned long timeout = jiffies + 2;
+
+ while (!(at91_emac_read(AT91_EMAC_SR) & AT91_EMAC_SR_IDLE)) {
+ if (time_after(jiffies, timeout)) {
+ printk("at91_ether: MIO timeout\n");
+ break;
+ }
+ cpu_relax();
+ }
+}
+
+/*
+ * Write value to the a PHY register
+ * Note: MDI interface is assumed to already have been enabled.
+ */
+static void write_phy(unsigned char phy_addr, unsigned char address, unsigned int value)
+{
+ at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_W
+ | ((phy_addr & 0x1f) << 23) | (address << 18) | (value & AT91_EMAC_DATA));
+
+ /* Wait until IDLE bit in Network Status register is cleared */
+ at91_phy_wait();
+}
+
+/*
+ * Read value stored in a PHY register.
+ * Note: MDI interface is assumed to already have been enabled.
+ */
+static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int *value)
+{
+ at91_emac_write(AT91_EMAC_MAN, AT91_EMAC_MAN_802_3 | AT91_EMAC_RW_R
+ | ((phy_addr & 0x1f) << 23) | (address << 18));
+
+ /* Wait until IDLE bit in Network Status register is cleared */
+ at91_phy_wait();
+
+ *value = at91_emac_read(AT91_EMAC_MAN) & AT91_EMAC_DATA;
+}
+
+/* ........................... PHY MANAGEMENT .......................... */
+
+/*
+ * Access the PHY to determine the current link speed and mode, and update the
+ * MAC accordingly.
+ * If no link or auto-negotiation is busy, then no changes are made.
+ */
+static void update_linkspeed(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int bmsr, bmcr, lpa, mac_cfg;
+ unsigned int speed, duplex;
+
+ if (!mii_link_ok(&lp->mii)) { /* no link */
+ netif_carrier_off(dev);
+ printk(KERN_INFO "%s: Link down.\n", dev->name);
+ return;
+ }
+
+ /* Link up, or auto-negotiation still in progress */
+ read_phy(lp->phy_address, MII_BMSR, &bmsr);
+ read_phy(lp->phy_address, MII_BMCR, &bmcr);
+ if (bmcr & BMCR_ANENABLE) { /* AutoNegotiation is enabled */
+ if (!(bmsr & BMSR_ANEGCOMPLETE))
+ return; /* Do nothing - another interrupt generated when negotiation complete */
+
+ read_phy(lp->phy_address, MII_LPA, &lpa);
+ if ((lpa & LPA_100FULL) || (lpa & LPA_100HALF)) speed = SPEED_100;
+ else speed = SPEED_10;
+ if ((lpa & LPA_100FULL) || (lpa & LPA_10FULL)) duplex = DUPLEX_FULL;
+ else duplex = DUPLEX_HALF;
+ } else {
+ speed = (bmcr & BMCR_SPEED100) ? SPEED_100 : SPEED_10;
+ duplex = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF;
+ }
+
+ /* Update the MAC */
+ mac_cfg = at91_emac_read(AT91_EMAC_CFG) & ~(AT91_EMAC_SPD | AT91_EMAC_FD);
+ if (speed == SPEED_100) {
+ if (duplex == DUPLEX_FULL) /* 100 Full Duplex */
+ mac_cfg |= AT91_EMAC_SPD | AT91_EMAC_FD;
+ else /* 100 Half Duplex */
+ mac_cfg |= AT91_EMAC_SPD;
+ } else {
+ if (duplex == DUPLEX_FULL) /* 10 Full Duplex */
+ mac_cfg |= AT91_EMAC_FD;
+ else {} /* 10 Half Duplex */
+ }
+ at91_emac_write(AT91_EMAC_CFG, mac_cfg);
+
+ printk(KERN_INFO "%s: Link now %i-%s\n", dev->name, speed, (duplex == DUPLEX_FULL) ? "FullDuplex" : "HalfDuplex");
+ netif_carrier_on(dev);
+}
+
+/*
+ * Handle interrupts from the PHY
+ */
+static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct net_device *dev = (struct net_device *) dev_id;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int phy;
+
+ /*
+ * This hander is triggered on both edges, but the PHY chips expect
+ * level-triggering. We therefore have to check if the PHY actually has
+ * an IRQ pending.
+ */
+ enable_mdi();
+ if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
+ read_phy(lp->phy_address, MII_DSINTR_REG, &phy); /* ack interrupt in Davicom PHY */
+ if (!(phy & (1 << 0)))
+ goto done;
+ }
+ else if (lp->phy_type == MII_LXT971A_ID) {
+ read_phy(lp->phy_address, MII_ISINTS_REG, &phy); /* ack interrupt in Intel PHY */
+ if (!(phy & (1 << 2)))
+ goto done;
+ }
+ else if (lp->phy_type == MII_BCM5221_ID) {
+ read_phy(lp->phy_address, MII_BCMINTR_REG, &phy); /* ack interrupt in Broadcom PHY */
+ if (!(phy & (1 << 0)))
+ goto done;
+ }
+ else if (lp->phy_type == MII_KS8721_ID) {
+ read_phy(lp->phy_address, MII_TPISTATUS, &phy); /* ack interrupt in Micrel PHY */
+ if (!(phy & ((1 << 2) | 1)))
+ goto done;
+ }
+
+ update_linkspeed(dev);
+
+done:
+ disable_mdi();
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * Initialize and enable the PHY interrupt for link-state changes
+ */
+static void enable_phyirq(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int dsintr, irq_number;
+ int status;
+
+ if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */
+ return;
+ if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */
+ return;
+ if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */
+ return;
+
+ irq_number = lp->board_data.phy_irq_pin;
+ status = request_irq(irq_number, at91ether_phy_interrupt, 0, dev->name, dev);
+ if (status) {
+ printk(KERN_ERR "at91_ether: PHY IRQ %d request failed - status %d!\n", irq_number, status);
+ return;
+ }
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
+ read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
+ dsintr = dsintr & ~0xf00; /* clear bits 8..11 */
+ write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
+ read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
+ dsintr = dsintr | 0xf2; /* set bits 1, 4..7 */
+ write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
+ dsintr = (1 << 15) | ( 1 << 14);
+ write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
+ dsintr = (1 << 10) | ( 1 << 8);
+ write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
+ }
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+}
+
+/*
+ * Disable the PHY interrupt
+ */
+static void disable_phyirq(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int dsintr;
+ unsigned int irq_number;
+
+ if (lp->phy_type == MII_RTL8201_ID) /* RTL8201 does not have an interrupt */
+ return;
+ if (lp->phy_type == MII_DP83847_ID) /* DP83847 does not have an interrupt */
+ return;
+ if (lp->phy_type == MII_AC101L_ID) /* AC101L interrupt not supported yet */
+ return;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ if ((lp->phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) { /* for Davicom PHY */
+ read_phy(lp->phy_address, MII_DSINTR_REG, &dsintr);
+ dsintr = dsintr | 0xf00; /* set bits 8..11 */
+ write_phy(lp->phy_address, MII_DSINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_LXT971A_ID) { /* for Intel PHY */
+ read_phy(lp->phy_address, MII_ISINTE_REG, &dsintr);
+ dsintr = dsintr & ~0xf2; /* clear bits 1, 4..7 */
+ write_phy(lp->phy_address, MII_ISINTE_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_BCM5221_ID) { /* for Broadcom PHY */
+ read_phy(lp->phy_address, MII_BCMINTR_REG, &dsintr);
+ dsintr = ~(1 << 14);
+ write_phy(lp->phy_address, MII_BCMINTR_REG, dsintr);
+ }
+ else if (lp->phy_type == MII_KS8721_ID) { /* for Micrel PHY */
+ read_phy(lp->phy_address, MII_TPISTATUS, &dsintr);
+ dsintr = ~((1 << 10) | (1 << 8));
+ write_phy(lp->phy_address, MII_TPISTATUS, dsintr);
+ }
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ irq_number = lp->board_data.phy_irq_pin;
+ free_irq(irq_number, dev); /* Free interrupt handler */
+}
+
+/*
+ * Perform a software reset of the PHY.
+ */
+#if 0
+static void reset_phy(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned int bmcr;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ /* Perform PHY reset */
+ write_phy(lp->phy_address, MII_BMCR, BMCR_RESET);
+
+ /* Wait until PHY reset is complete */
+ do {
+ read_phy(lp->phy_address, MII_BMCR, &bmcr);
+ } while (!(bmcr && BMCR_RESET));
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+}
+#endif
+
+/* ......................... ADDRESS MANAGEMENT ........................ */
+
+/*
+ * NOTE: Your bootloader must always set the MAC address correctly before
+ * booting into Linux.
+ *
+ * - It must always set the MAC address after reset, even if it doesn't
+ * happen to access the Ethernet while it's booting. Some versions of
+ * U-Boot on the AT91RM9200-DK do not do this.
+ *
+ * - Likewise it must store the addresses in the correct byte order.
+ * MicroMonitor (uMon) on the CSB337 does this incorrectly (and
+ * continues to do so, for bug-compatibility).
+ */
+
+static short __init unpack_mac_address(struct net_device *dev, unsigned int hi, unsigned int lo)
+{
+ char addr[6];
+
+ if (machine_is_csb337()) {
+ addr[5] = (lo & 0xff); /* The CSB337 bootloader stores the MAC the wrong-way around */
+ addr[4] = (lo & 0xff00) >> 8;
+ addr[3] = (lo & 0xff0000) >> 16;
+ addr[2] = (lo & 0xff000000) >> 24;
+ addr[1] = (hi & 0xff);
+ addr[0] = (hi & 0xff00) >> 8;
+ }
+ else {
+ addr[0] = (lo & 0xff);
+ addr[1] = (lo & 0xff00) >> 8;
+ addr[2] = (lo & 0xff0000) >> 16;
+ addr[3] = (lo & 0xff000000) >> 24;
+ addr[4] = (hi & 0xff);
+ addr[5] = (hi & 0xff00) >> 8;
+ }
+
+ if (is_valid_ether_addr(addr)) {
+ memcpy(dev->dev_addr, &addr, 6);
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ * Set the ethernet MAC address in dev->dev_addr
+ */
+static void __init get_mac_address(struct net_device *dev)
+{
+ /* Check Specific-Address 1 */
+ if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA1H), at91_emac_read(AT91_EMAC_SA1L)))
+ return;
+ /* Check Specific-Address 2 */
+ if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA2H), at91_emac_read(AT91_EMAC_SA2L)))
+ return;
+ /* Check Specific-Address 3 */
+ if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA3H), at91_emac_read(AT91_EMAC_SA3L)))
+ return;
+ /* Check Specific-Address 4 */
+ if (unpack_mac_address(dev, at91_emac_read(AT91_EMAC_SA4H), at91_emac_read(AT91_EMAC_SA4L)))
+ return;
+
+ printk(KERN_ERR "at91_ether: Your bootloader did not configure a MAC address.\n");
+}
+
+/*
+ * Program the hardware MAC address from dev->dev_addr.
+ */
+static void update_mac_address(struct net_device *dev)
+{
+ at91_emac_write(AT91_EMAC_SA1L, (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) | (dev->dev_addr[1] << 8) | (dev->dev_addr[0]));
+ at91_emac_write(AT91_EMAC_SA1H, (dev->dev_addr[5] << 8) | (dev->dev_addr[4]));
+
+ at91_emac_write(AT91_EMAC_SA2L, 0);
+ at91_emac_write(AT91_EMAC_SA2H, 0);
+}
+
+/*
+ * Store the new hardware address in dev->dev_addr, and update the MAC.
+ */
+static int set_mac_address(struct net_device *dev, void* addr)
+{
+ struct sockaddr *address = addr;
+
+ if (!is_valid_ether_addr(address->sa_data))
+ return -EADDRNOTAVAIL;
+
+ memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
+ update_mac_address(dev);
+
+ printk("%s: Setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name,
+ dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+ dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+
+ return 0;
+}
+
+static int inline hash_bit_value(int bitnr, __u8 *addr)
+{
+ if (addr[bitnr / 8] & (1 << (bitnr % 8)))
+ return 1;
+ return 0;
+}
+
+/*
+ * The hash address register is 64 bits long and takes up two locations in the memory map.
+ * The least significant bits are stored in EMAC_HSL and the most significant
+ * bits in EMAC_HSH.
+ *
+ * The unicast hash enable and the multicast hash enable bits in the network configuration
+ * register enable the reception of hash matched frames. The destination address is
+ * reduced to a 6 bit index into the 64 bit hash register using the following hash function.
+ * The hash function is an exclusive or of every sixth bit of the destination address.
+ * hash_index[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47]
+ * hash_index[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46]
+ * hash_index[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45]
+ * hash_index[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44]
+ * hash_index[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43]
+ * hash_index[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42]
+ * da[0] represents the least significant bit of the first byte received, that is, the multicast/
+ * unicast indicator, and da[47] represents the most significant bit of the last byte
+ * received.
+ * If the hash index points to a bit that is set in the hash register then the frame will be
+ * matched according to whether the frame is multicast or unicast.
+ * A multicast match will be signalled if the multicast hash enable bit is set, da[0] is 1 and
+ * the hash index points to a bit set in the hash register.
+ * A unicast match will be signalled if the unicast hash enable bit is set, da[0] is 0 and the
+ * hash index points to a bit set in the hash register.
+ * To receive all multicast frames, the hash register should be set with all ones and the
+ * multicast hash enable bit should be set in the network configuration register.
+ */
+
+/*
+ * Return the hash index value for the specified address.
+ */
+static int hash_get_index(__u8 *addr)
+{
+ int i, j, bitval;
+ int hash_index = 0;
+
+ for (j = 0; j < 6; j++) {
+ for (i = 0, bitval = 0; i < 8; i++)
+ bitval ^= hash_bit_value(i*6 + j, addr);
+
+ hash_index |= (bitval << j);
+ }
+
+ return hash_index;
+}
+
+/*
+ * Add multicast addresses to the internal multicast-hash table.
+ */
+static void at91ether_sethashtable(struct net_device *dev)
+{
+ struct dev_mc_list *curr;
+ unsigned long mc_filter[2];
+ unsigned int i, bitnr;
+
+ mc_filter[0] = mc_filter[1] = 0;
+
+ curr = dev->mc_list;
+ for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
+ if (!curr) break; /* unexpected end of list */
+
+ bitnr = hash_get_index(curr->dmi_addr);
+ mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
+ }
+
+ at91_emac_write(AT91_EMAC_HSH, mc_filter[0]);
+ at91_emac_write(AT91_EMAC_HSL, mc_filter[1]);
+}
+
+/*
+ * Enable/Disable promiscuous and multicast modes.
+ */
+static void at91ether_set_rx_mode(struct net_device *dev)
+{
+ unsigned long cfg;
+
+ cfg = at91_emac_read(AT91_EMAC_CFG);
+
+ if (dev->flags & IFF_PROMISC) /* Enable promiscuous mode */
+ cfg |= AT91_EMAC_CAF;
+ else if (dev->flags & (~IFF_PROMISC)) /* Disable promiscuous mode */
+ cfg &= ~AT91_EMAC_CAF;
+
+ if (dev->flags & IFF_ALLMULTI) { /* Enable all multicast mode */
+ at91_emac_write(AT91_EMAC_HSH, -1);
+ at91_emac_write(AT91_EMAC_HSL, -1);
+ cfg |= AT91_EMAC_MTI;
+ } else if (dev->mc_count > 0) { /* Enable specific multicasts */
+ at91ether_sethashtable(dev);
+ cfg |= AT91_EMAC_MTI;
+ } else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
+ at91_emac_write(AT91_EMAC_HSH, 0);
+ at91_emac_write(AT91_EMAC_HSL, 0);
+ cfg &= ~AT91_EMAC_MTI;
+ }
+
+ at91_emac_write(AT91_EMAC_CFG, cfg);
+}
+
+
+/* ......................... ETHTOOL SUPPORT ........................... */
+
+
+static int mdio_read(struct net_device *dev, int phy_id, int location)
+{
+ unsigned int value;
+
+ read_phy(phy_id, location, &value);
+ return value;
+}
+
+static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
+{
+ write_phy(phy_id, location, value);
+}
+
+static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ int ret;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ ret = mii_ethtool_gset(&lp->mii, cmd);
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ if (lp->phy_media == PORT_FIBRE) { /* override media type since mii.c doesn't know */
+ cmd->supported = SUPPORTED_FIBRE;
+ cmd->port = PORT_FIBRE;
+ }
+
+ return ret;
+}
+
+static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ int ret;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ ret = mii_ethtool_sset(&lp->mii, cmd);
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ return ret;
+}
+
+static int at91ether_nwayreset(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ int ret;
+
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+
+ ret = mii_nway_restart(&lp->mii);
+
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ return ret;
+}
+
+static void at91ether_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
+{
+ strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+ strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+ strlcpy(info->bus_info, dev->class_dev.dev->bus_id, sizeof(info->bus_info));
+}
+
+static struct ethtool_ops at91ether_ethtool_ops = {
+ .get_settings = at91ether_get_settings,
+ .set_settings = at91ether_set_settings,
+ .get_drvinfo = at91ether_get_drvinfo,
+ .nway_reset = at91ether_nwayreset,
+ .get_link = ethtool_op_get_link,
+};
+
+
+/* ................................ MAC ................................ */
+
+/*
+ * Initialize and start the Receiver and Transmit subsystems
+ */
+static void at91ether_start(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ struct recv_desc_bufs *dlist, *dlist_phys;
+ int i;
+ unsigned long ctl;
+
+ dlist = lp->dlist;
+ dlist_phys = lp->dlist_phys;
+
+ for (i = 0; i < MAX_RX_DESCR; i++) {
+ dlist->descriptors[i].addr = (unsigned int) &dlist_phys->recv_buf[i][0];
+ dlist->descriptors[i].size = 0;
+ }
+
+ /* Set the Wrap bit on the last descriptor */
+ dlist->descriptors[i-1].addr |= EMAC_DESC_WRAP;
+
+ /* Reset buffer index */
+ lp->rxBuffIndex = 0;
+
+ /* Program address of descriptor list in Rx Buffer Queue register */
+ at91_emac_write(AT91_EMAC_RBQP, (unsigned long) dlist_phys);
+
+ /* Enable Receive and Transmit */
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE | AT91_EMAC_TE);
+}
+
+/*
+ * Open the ethernet interface
+ */
+static int at91ether_open(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned long ctl;
+
+ if (!is_valid_ether_addr(dev->dev_addr))
+ return -EADDRNOTAVAIL;
+
+ clk_enable(ether_clk); /* Re-enable Peripheral clock */
+
+ /* Clear internal statistics */
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_CSR);
+
+ /* Update the MAC address (incase user has changed it) */
+ update_mac_address(dev);
+
+ /* Enable PHY interrupt */
+ enable_phyirq(dev);
+
+ /* Enable MAC interrupts */
+ at91_emac_write(AT91_EMAC_IER, AT91_EMAC_RCOM | AT91_EMAC_RBNA
+ | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
+ | AT91_EMAC_ROVR | AT91_EMAC_ABT);
+
+ /* Determine current link speed */
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+ update_linkspeed(dev);
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ at91ether_start(dev);
+ netif_start_queue(dev);
+ return 0;
+}
+
+/*
+ * Close the interface
+ */
+static int at91ether_close(struct net_device *dev)
+{
+ unsigned long ctl;
+
+ /* Disable Receiver and Transmitter */
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl & ~(AT91_EMAC_TE | AT91_EMAC_RE));
+
+ /* Disable PHY interrupt */
+ disable_phyirq(dev);
+
+ /* Disable MAC interrupts */
+ at91_emac_write(AT91_EMAC_IDR, AT91_EMAC_RCOM | AT91_EMAC_RBNA
+ | AT91_EMAC_TUND | AT91_EMAC_RTRY | AT91_EMAC_TCOM
+ | AT91_EMAC_ROVR | AT91_EMAC_ABT);
+
+ netif_stop_queue(dev);
+
+ clk_disable(ether_clk); /* Disable Peripheral clock */
+
+ return 0;
+}
+
+/*
+ * Transmit packet.
+ */
+static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+
+ if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
+ netif_stop_queue(dev);
+
+ /* Store packet information (to free when Tx completed) */
+ lp->skb = skb;
+ lp->skb_length = skb->len;
+ lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, DMA_TO_DEVICE);
+ lp->stats.tx_bytes += skb->len;
+
+ /* Set address of the data in the Transmit Address register */
+ at91_emac_write(AT91_EMAC_TAR, lp->skb_physaddr);
+ /* Set length of the packet in the Transmit Control register */
+ at91_emac_write(AT91_EMAC_TCR, skb->len);
+
+ dev->trans_start = jiffies;
+ } else {
+ printk(KERN_ERR "at91_ether.c: at91ether_tx() called, but device is busy!\n");
+ return 1; /* if we return anything but zero, dev.c:1055 calls kfree_skb(skb)
+ on this skb, he also reports -ENETDOWN and printk's, so either
+ we free and return(0) or don't free and return 1 */
+ }
+
+ return 0;
+}
+
+/*
+ * Update the current statistics from the internal statistics registers.
+ */
+static struct net_device_stats *at91ether_stats(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ int ale, lenerr, seqe, lcol, ecol;
+
+ if (netif_running(dev)) {
+ lp->stats.rx_packets += at91_emac_read(AT91_EMAC_OK); /* Good frames received */
+ ale = at91_emac_read(AT91_EMAC_ALE);
+ lp->stats.rx_frame_errors += ale; /* Alignment errors */
+ lenerr = at91_emac_read(AT91_EMAC_ELR) + at91_emac_read(AT91_EMAC_USF);
+ lp->stats.rx_length_errors += lenerr; /* Excessive Length or Undersize Frame error */
+ seqe = at91_emac_read(AT91_EMAC_SEQE);
+ lp->stats.rx_crc_errors += seqe; /* CRC error */
+ lp->stats.rx_fifo_errors += at91_emac_read(AT91_EMAC_DRFC); /* Receive buffer not available */
+ lp->stats.rx_errors += (ale + lenerr + seqe
+ + at91_emac_read(AT91_EMAC_CDE) + at91_emac_read(AT91_EMAC_RJB));
+
+ lp->stats.tx_packets += at91_emac_read(AT91_EMAC_FRA); /* Frames successfully transmitted */
+ lp->stats.tx_fifo_errors += at91_emac_read(AT91_EMAC_TUE); /* Transmit FIFO underruns */
+ lp->stats.tx_carrier_errors += at91_emac_read(AT91_EMAC_CSE); /* Carrier Sense errors */
+ lp->stats.tx_heartbeat_errors += at91_emac_read(AT91_EMAC_SQEE);/* Heartbeat error */
+
+ lcol = at91_emac_read(AT91_EMAC_LCOL);
+ ecol = at91_emac_read(AT91_EMAC_ECOL);
+ lp->stats.tx_window_errors += lcol; /* Late collisions */
+ lp->stats.tx_aborted_errors += ecol; /* 16 collisions */
+
+ lp->stats.collisions += (at91_emac_read(AT91_EMAC_SCOL) + at91_emac_read(AT91_EMAC_MCOL) + lcol + ecol);
+ }
+ return &lp->stats;
+}
+
+/*
+ * Extract received frame from buffer descriptors and sent to upper layers.
+ * (Called from interrupt context)
+ */
+static void at91ether_rx(struct net_device *dev)
+{
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ struct recv_desc_bufs *dlist;
+ unsigned char *p_recv;
+ struct sk_buff *skb;
+ unsigned int pktlen;
+
+ dlist = lp->dlist;
+ while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) {
+ p_recv = dlist->recv_buf[lp->rxBuffIndex];
+ pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */
+ skb = alloc_skb(pktlen + 2, GFP_ATOMIC);
+ if (skb != NULL) {
+ skb_reserve(skb, 2);
+ memcpy(skb_put(skb, pktlen), p_recv, pktlen);
+
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->len = pktlen;
+ dev->last_rx = jiffies;
+ lp->stats.rx_bytes += pktlen;
+ netif_rx(skb);
+ }
+ else {
+ lp->stats.rx_dropped += 1;
+ printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", dev->name);
+ }
+
+ if (dlist->descriptors[lp->rxBuffIndex].size & EMAC_MULTICAST)
+ lp->stats.multicast++;
+
+ dlist->descriptors[lp->rxBuffIndex].addr &= ~EMAC_DESC_DONE; /* reset ownership bit */
+ if (lp->rxBuffIndex == MAX_RX_DESCR-1) /* wrap after last buffer */
+ lp->rxBuffIndex = 0;
+ else
+ lp->rxBuffIndex++;
+ }
+}
+
+/*
+ * MAC interrupt handler
+ */
+static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ struct net_device *dev = (struct net_device *) dev_id;
+ struct at91_private *lp = (struct at91_private *) dev->priv;
+ unsigned long intstatus, ctl;
+
+ /* MAC Interrupt Status register indicates what interrupts are pending.
+ It is automatically cleared once read. */
+ intstatus = at91_emac_read(AT91_EMAC_ISR);
+
+ if (intstatus & AT91_EMAC_RCOM) /* Receive complete */
+ at91ether_rx(dev);
+
+ if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */
+ /* The TCOM bit is set even if the transmission failed. */
+ if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY))
+ lp->stats.tx_errors += 1;
+
+ if (lp->skb) {
+ dev_kfree_skb_irq(lp->skb);
+ lp->skb = NULL;
+ dma_unmap_single(NULL, lp->skb_physaddr, lp->skb_length, DMA_TO_DEVICE);
+ }
+ netif_wake_queue(dev);
+ }
+
+ /* Work-around for Errata #11 */
+ if (intstatus & AT91_EMAC_RBNA) {
+ ctl = at91_emac_read(AT91_EMAC_CTL);
+ at91_emac_write(AT91_EMAC_CTL, ctl & ~AT91_EMAC_RE);
+ at91_emac_write(AT91_EMAC_CTL, ctl | AT91_EMAC_RE);
+ }
+
+ if (intstatus & AT91_EMAC_ROVR)
+ printk("%s: ROVR error\n", dev->name);
+
+ return IRQ_HANDLED;
+}
+
+/*
+ * Initialize the ethernet interface
+ */
+static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev)
+{
+ struct at91_eth_data *board_data = pdev->dev.platform_data;
+ struct net_device *dev;
+ struct at91_private *lp;
+ unsigned int val;
+ int res;
+
+ if (at91_dev) /* already initialized */
+ return 0;
+
+ dev = alloc_etherdev(sizeof(struct at91_private));
+ if (!dev)
+ return -ENOMEM;
+
+ dev->base_addr = AT91_VA_BASE_EMAC;
+ dev->irq = AT91_ID_EMAC;
+ SET_MODULE_OWNER(dev);
+
+ /* Install the interrupt handler */
+ if (request_irq(dev->irq, at91ether_interrupt, 0, dev->name, dev)) {
+ free_netdev(dev);
+ return -EBUSY;
+ }
+
+ /* Allocate memory for DMA Receive descriptors */
+ lp = (struct at91_private *)dev->priv;
+ lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
+ if (lp->dlist == NULL) {
+ free_irq(dev->irq, dev);
+ free_netdev(dev);
+ return -ENOMEM;
+ }
+ lp->board_data = *board_data;
+ platform_set_drvdata(pdev, dev);
+
+ spin_lock_init(&lp->lock);
+
+ ether_setup(dev);
+ dev->open = at91ether_open;
+ dev->stop = at91ether_close;
+ dev->hard_start_xmit = at91ether_tx;
+ dev->get_stats = at91ether_stats;
+ dev->set_multicast_list = at91ether_set_rx_mode;
+ dev->set_mac_address = set_mac_address;
+ dev->ethtool_ops = &at91ether_ethtool_ops;
+
+ SET_NETDEV_DEV(dev, &pdev->dev);
+
+ get_mac_address(dev); /* Get ethernet address and store it in dev->dev_addr */
+ update_mac_address(dev); /* Program ethernet address into MAC */
+
+ at91_emac_write(AT91_EMAC_CTL, 0);
+
+ if (lp->board_data.is_rmii)
+ at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG | AT91_EMAC_RMII);
+ else
+ at91_emac_write(AT91_EMAC_CFG, AT91_EMAC_CLK_DIV32 | AT91_EMAC_BIG);
+
+ /* Perform PHY-specific initialization */
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+ if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) {
+ read_phy(phy_address, MII_DSCR_REG, &val);
+ if ((val & (1 << 10)) == 0) /* DSCR bit 10 is 0 -- fiber mode */
+ lp->phy_media = PORT_FIBRE;
+ } else if (machine_is_csb337()) {
+ /* mix link activity status into LED2 link state */
+ write_phy(phy_address, MII_LEDCTRL_REG, 0x0d22);
+ }
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+
+ lp->mii.dev = dev; /* Support for ethtool */
+ lp->mii.mdio_read = mdio_read;
+ lp->mii.mdio_write = mdio_write;
+
+ lp->phy_type = phy_type; /* Type of PHY connected */
+ lp->phy_address = phy_address; /* MDI address of PHY */
+
+ /* Register the network interface */
+ res = register_netdev(dev);
+ if (res) {
+ free_irq(dev->irq, dev);
+ free_netdev(dev);
+ dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
+ return res;
+ }
+ at91_dev = dev;
+
+ /* Determine current link speed */
+ spin_lock_irq(&lp->lock);
+ enable_mdi();
+ update_linkspeed(dev);
+ disable_mdi();
+ spin_unlock_irq(&lp->lock);
+ netif_carrier_off(dev); /* will be enabled in open() */
+
+ /* Display ethernet banner */
+ printk(KERN_INFO "%s: AT91 ethernet at 0x%08x int=%d %s%s (%02x:%02x:%02x:%02x:%02x:%02x)\n",
+ dev->name, (uint) dev->base_addr, dev->irq,
+ at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_SPD ? "100-" : "10-",
+ at91_emac_read(AT91_EMAC_CFG) & AT91_EMAC_FD ? "FullDuplex" : "HalfDuplex",
+ dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
+ dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+ if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
+ printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
+ else if (phy_type == MII_LXT971A_ID)
+ printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
+ else if (phy_type == MII_RTL8201_ID)
+ printk(KERN_INFO "%s: Realtek RTL8201(B)L PHY\n", dev->name);
+ else if (phy_type == MII_BCM5221_ID)
+ printk(KERN_INFO "%s: Broadcom BCM5221 PHY\n", dev->name);
+ else if (phy_type == MII_DP83847_ID)
+ printk(KERN_INFO "%s: National Semiconductor DP83847 PHY\n", dev->name);
+ else if (phy_type == MII_AC101L_ID)
+ printk(KERN_INFO "%s: Altima AC101L PHY\n", dev->name);
+ else if (phy_type == MII_KS8721_ID)
+ printk(KERN_INFO "%s: Micrel KS8721 PHY\n", dev->name);
+
+ return 0;
+}
+
+/*
+ * Detect MAC and PHY and perform initialization
+ */
+static int __init at91ether_probe(struct platform_device *pdev)
+{
+ unsigned int phyid1, phyid2;
+ int detected = -1;
+ unsigned long phy_id;
+ unsigned short phy_address = 0;
+
+ ether_clk = clk_get(&pdev->dev, "ether_clk");
+ if (!ether_clk) {
+ printk(KERN_ERR "at91_ether: no clock defined\n");
+ return -ENODEV;
+ }
+ clk_enable(ether_clk); /* Enable Peripheral clock */
+
+ while ((detected != 0) && (phy_address < 32)) {
+ /* Read the PHY ID registers */
+ enable_mdi();
+ read_phy(phy_address, MII_PHYSID1, &phyid1);
+ read_phy(phy_address, MII_PHYSID2, &phyid2);
+ disable_mdi();
+
+ phy_id = (phyid1 << 16) | (phyid2 & 0xfff0);
+ switch (phy_id) {
+ case MII_DM9161_ID: /* Davicom 9161: PHY_ID1 = 0x181, PHY_ID2 = B881 */
+ case MII_DM9161A_ID: /* Davicom 9161A: PHY_ID1 = 0x181, PHY_ID2 = B8A0 */
+ case MII_LXT971A_ID: /* Intel LXT971A: PHY_ID1 = 0x13, PHY_ID2 = 78E0 */
+ case MII_RTL8201_ID: /* Realtek RTL8201: PHY_ID1 = 0, PHY_ID2 = 0x8201 */
+ case MII_BCM5221_ID: /* Broadcom BCM5221: PHY_ID1 = 0x40, PHY_ID2 = 0x61e0 */
+ case MII_DP83847_ID: /* National Semiconductor DP83847: */
+ case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
+ case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
+ detected = at91ether_setup(phy_id, phy_address, pdev);
+ break;
+ }
+
+ phy_address++;
+ }
+
+ clk_disable(ether_clk); /* Disable Peripheral clock */
+
+ return detected;
+}
+
+static int __devexit at91ether_remove(struct platform_device *pdev)
+{
+ struct at91_private *lp = (struct at91_private *) at91_dev->priv;
+
+ unregister_netdev(at91_dev);
+ free_irq(at91_dev->irq, at91_dev);
+ dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
+ clk_put(ether_clk);
+
+ free_netdev(at91_dev);
+ at91_dev = NULL;
+ return 0;
+}
+
+static struct platform_driver at91ether_driver = {
+ .probe = at91ether_probe,
+ .remove = __devexit_p(at91ether_remove),
+ /* FIXME: support suspend and resume */
+ .driver = {
+ .name = DRV_NAME,
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init at91ether_init(void)
+{
+ return platform_driver_register(&at91ether_driver);
+}
+
+static void __exit at91ether_exit(void)
+{
+ platform_driver_unregister(&at91ether_driver);
+}
+
+module_init(at91ether_init)
+module_exit(at91ether_exit)
+
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("AT91RM9200 EMAC Ethernet driver");
+MODULE_AUTHOR("Andrew Victor");
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h
new file mode 100644
index 00000000000..9885735c9c8
--- /dev/null
+++ b/drivers/net/arm/at91_ether.h
@@ -0,0 +1,101 @@
+/*
+ * Ethernet driver for the Atmel AT91RM9200 (Thunder)
+ *
+ * Copyright (C) SAN People (Pty) Ltd
+ *
+ * Based on an earlier Atmel EMAC macrocell driver by Atmel and Lineo Inc.
+ * Initial version by Rick Bronson.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#ifndef AT91_ETHERNET
+#define AT91_ETHERNET
+
+
+/* Davicom 9161 PHY */
+#define MII_DM9161_ID 0x0181b880
+#define MII_DM9161A_ID 0x0181b8a0
+
+/* Davicom specific registers */
+#define MII_DSCR_REG 16
+#define MII_DSCSR_REG 17
+#define MII_DSINTR_REG 21
+
+/* Intel LXT971A PHY */
+#define MII_LXT971A_ID 0x001378E0
+
+/* Intel specific registers */
+#define MII_ISINTE_REG 18
+#define MII_ISINTS_REG 19
+#define MII_LEDCTRL_REG 20
+
+/* Realtek RTL8201 PHY */
+#define MII_RTL8201_ID 0x00008200
+
+/* Broadcom BCM5221 PHY */
+#define MII_BCM5221_ID 0x004061e0
+
+/* Broadcom specific registers */
+#define MII_BCMINTR_REG 26
+
+/* National Semiconductor DP83847 */
+#define MII_DP83847_ID 0x20005c30
+
+/* Altima AC101L PHY */
+#define MII_AC101L_ID 0x00225520
+
+/* Micrel KS8721 PHY */
+#define MII_KS8721_ID 0x00221610
+
+/* ........................................................................ */
+
+#define MAX_RBUFF_SZ 0x600 /* 1518 rounded up */
+#define MAX_RX_DESCR 9 /* max number of receive buffers */
+
+#define EMAC_DESC_DONE 0x00000001 /* bit for if DMA is done */
+#define EMAC_DESC_WRAP 0x00000002 /* bit for wrap */
+
+#define EMAC_BROADCAST 0x80000000 /* broadcast address */
+#define EMAC_MULTICAST 0x40000000 /* multicast address */
+#define EMAC_UNICAST 0x20000000 /* unicast address */
+
+struct rbf_t
+{
+ unsigned int addr;
+ unsigned long size;
+};
+
+struct recv_desc_bufs
+{
+ struct rbf_t descriptors[MAX_RX_DESCR]; /* must be on sizeof (rbf_t) boundary */
+ char recv_buf[MAX_RX_DESCR][MAX_RBUFF_SZ]; /* must be on long boundary */
+};
+
+struct at91_private
+{
+ struct net_device_stats stats;
+ struct mii_if_info mii; /* ethtool support */
+ struct at91_eth_data board_data; /* board-specific configuration */
+
+ /* PHY */
+ unsigned long phy_type; /* type of PHY (PHY_ID) */
+ spinlock_t lock; /* lock for MDI interface */
+ short phy_media; /* media interface type */
+ unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */
+
+ /* Transmit */
+ struct sk_buff *skb; /* holds skb until xmit interrupt completes */
+ dma_addr_t skb_physaddr; /* phys addr from pci_map_single */
+ int skb_length; /* saved skb length for pci_unmap_single */
+
+ /* Receive */
+ int rxBuffIndex; /* index into receive descriptor list */
+ struct recv_desc_bufs *dlist; /* descriptor list address */
+ struct recv_desc_bufs *dlist_phys; /* descriptor list physical address */
+};
+
+#endif
diff --git a/drivers/net/atari_bionet.c b/drivers/net/atari_bionet.c
index 0095384ff45..5e5f80b99b9 100644
--- a/drivers/net/atari_bionet.c
+++ b/drivers/net/atari_bionet.c
@@ -123,7 +123,7 @@ static char version[] =
* Global variable 'bionet_debug'. Can be set at load time by 'insmod'
*/
unsigned int bionet_debug = NET_DEBUG;
-MODULE_PARM(bionet_debug, "i");
+module_param(bionet_debug, int, 0);
MODULE_PARM_DESC(bionet_debug, "bionet debug level (0-2)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/atari_pamsnet.c b/drivers/net/atari_pamsnet.c
index 8b997809f9d..d6039e62d83 100644
--- a/drivers/net/atari_pamsnet.c
+++ b/drivers/net/atari_pamsnet.c
@@ -119,7 +119,7 @@ static char *version =
* Global variable 'pamsnet_debug'. Can be set at load time by 'insmod'
*/
unsigned int pamsnet_debug = NET_DEBUG;
-MODULE_PARM(pamsnet_debug, "i");
+module_param(pamsnet_debug, int, 0);
MODULE_PARM_DESC(pamsnet_debug, "pamsnet debug enable (0-1)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c
index e01b6a78ec6..442b2cbeb58 100644
--- a/drivers/net/atarilance.c
+++ b/drivers/net/atarilance.c
@@ -78,7 +78,7 @@ static int lance_debug = LANCE_DEBUG;
#else
static int lance_debug = 1;
#endif
-MODULE_PARM(lance_debug, "i");
+module_param(lance_debug, int, 0);
MODULE_PARM_DESC(lance_debug, "atarilance debug level (0-3)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c
index cd0b1dccfb6..1363083b4d8 100644
--- a/drivers/net/au1000_eth.c
+++ b/drivers/net/au1000_eth.c
@@ -90,8 +90,6 @@ static void au1000_tx_timeout(struct net_device *);
static int au1000_set_config(struct net_device *dev, struct ifmap *map);
static void set_rx_mode(struct net_device *);
static struct net_device_stats *au1000_get_stats(struct net_device *);
-static inline void update_tx_stats(struct net_device *, u32, u32);
-static inline void update_rx_stats(struct net_device *, u32);
static void au1000_timer(unsigned long);
static int au1000_ioctl(struct net_device *, struct ifreq *, int);
static int mdio_read(struct net_device *, int, int);
@@ -1825,16 +1823,11 @@ static void __exit au1000_cleanup_module(void)
}
}
-
-static inline void
-update_tx_stats(struct net_device *dev, u32 status, u32 pkt_len)
+static void update_tx_stats(struct net_device *dev, u32 status)
{
struct au1000_private *aup = (struct au1000_private *) dev->priv;
struct net_device_stats *ps = &aup->stats;
- ps->tx_packets++;
- ps->tx_bytes += pkt_len;
-
if (status & TX_FRAME_ABORTED) {
if (dev->if_port == IF_PORT_100BASEFX) {
if (status & (TX_JAB_TIMEOUT | TX_UNDERRUN)) {
@@ -1867,7 +1860,7 @@ static void au1000_tx_ack(struct net_device *dev)
ptxd = aup->tx_dma_ring[aup->tx_tail];
while (ptxd->buff_stat & TX_T_DONE) {
- update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff);
+ update_tx_stats(dev, ptxd->status);
ptxd->buff_stat &= ~TX_T_DONE;
ptxd->len = 0;
au_sync();
@@ -1889,6 +1882,7 @@ static void au1000_tx_ack(struct net_device *dev)
static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
{
struct au1000_private *aup = (struct au1000_private *) dev->priv;
+ struct net_device_stats *ps = &aup->stats;
volatile tx_dma_t *ptxd;
u32 buff_stat;
db_dest_t *pDB;
@@ -1908,7 +1902,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
return 1;
}
else if (buff_stat & TX_T_DONE) {
- update_tx_stats(dev, ptxd->status, ptxd->len & 0x3ff);
+ update_tx_stats(dev, ptxd->status);
ptxd->len = 0;
}
@@ -1928,6 +1922,9 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
else
ptxd->len = skb->len;
+ ps->tx_packets++;
+ ps->tx_bytes += ptxd->len;
+
ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
au_sync();
dev_kfree_skb(skb);
@@ -1936,7 +1933,6 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev)
return 0;
}
-
static inline void update_rx_stats(struct net_device *dev, u32 status)
{
struct au1000_private *aup = (struct au1000_private *) dev->priv;
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 7d213707008..2671da20a49 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -9,13 +9,54 @@
* Written by: Michael Chan (mchan@broadcom.com)
*/
+#include <linux/config.h>
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+
+#include <linux/kernel.h>
+#include <linux/timer.h>
+#include <linux/errno.h>
+#include <linux/ioport.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/interrupt.h>
+#include <linux/pci.h>
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#include <linux/etherdevice.h>
+#include <linux/skbuff.h>
+#include <linux/dma-mapping.h>
+#include <asm/bitops.h>
+#include <asm/io.h>
+#include <asm/irq.h>
+#include <linux/delay.h>
+#include <asm/byteorder.h>
+#include <linux/time.h>
+#include <linux/ethtool.h>
+#include <linux/mii.h>
+#ifdef NETIF_F_HW_VLAN_TX
+#include <linux/if_vlan.h>
+#define BCM_VLAN 1
+#endif
+#ifdef NETIF_F_TSO
+#include <net/ip.h>
+#include <net/tcp.h>
+#include <net/checksum.h>
+#define BCM_TSO 1
+#endif
+#include <linux/workqueue.h>
+#include <linux/crc32.h>
+#include <linux/prefetch.h>
+#include <linux/cache.h>
+
#include "bnx2.h"
#include "bnx2_fw.h"
#define DRV_MODULE_NAME "bnx2"
#define PFX DRV_MODULE_NAME ": "
-#define DRV_MODULE_VERSION "1.4.38"
-#define DRV_MODULE_RELDATE "February 10, 2006"
+#define DRV_MODULE_VERSION "1.4.39"
+#define DRV_MODULE_RELDATE "March 22, 2006"
#define RUN_AT(x) (jiffies + (x))
@@ -313,8 +354,6 @@ bnx2_disable_int(struct bnx2 *bp)
static void
bnx2_enable_int(struct bnx2 *bp)
{
- u32 val;
-
REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID |
BNX2_PCICFG_INT_ACK_CMD_MASK_INT | bp->last_status_idx);
@@ -322,8 +361,7 @@ bnx2_enable_int(struct bnx2 *bp)
REG_WR(bp, BNX2_PCICFG_INT_ACK_CMD,
BNX2_PCICFG_INT_ACK_CMD_INDEX_VALID | bp->last_status_idx);
- val = REG_RD(bp, BNX2_HC_COMMAND);
- REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
+ REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW);
}
static void
@@ -362,15 +400,11 @@ bnx2_free_mem(struct bnx2 *bp)
{
int i;
- if (bp->stats_blk) {
- pci_free_consistent(bp->pdev, sizeof(struct statistics_block),
- bp->stats_blk, bp->stats_blk_mapping);
- bp->stats_blk = NULL;
- }
if (bp->status_blk) {
- pci_free_consistent(bp->pdev, sizeof(struct status_block),
+ pci_free_consistent(bp->pdev, bp->status_stats_size,
bp->status_blk, bp->status_blk_mapping);
bp->status_blk = NULL;
+ bp->stats_blk = NULL;
}
if (bp->tx_desc_ring) {
pci_free_consistent(bp->pdev,
@@ -395,14 +429,13 @@ bnx2_free_mem(struct bnx2 *bp)
static int
bnx2_alloc_mem(struct bnx2 *bp)
{
- int i;
+ int i, status_blk_size;
- bp->tx_buf_ring = kmalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
- GFP_KERNEL);
+ bp->tx_buf_ring = kzalloc(sizeof(struct sw_bd) * TX_DESC_CNT,
+ GFP_KERNEL);
if (bp->tx_buf_ring == NULL)
return -ENOMEM;
- memset(bp->tx_buf_ring, 0, sizeof(struct sw_bd) * TX_DESC_CNT);
bp->tx_desc_ring = pci_alloc_consistent(bp->pdev,
sizeof(struct tx_bd) *
TX_DESC_CNT,
@@ -428,21 +461,22 @@ bnx2_alloc_mem(struct bnx2 *bp)
}
- bp->status_blk = pci_alloc_consistent(bp->pdev,
- sizeof(struct status_block),
+ /* Combine status and statistics blocks into one allocation. */
+ status_blk_size = L1_CACHE_ALIGN(sizeof(struct status_block));
+ bp->status_stats_size = status_blk_size +
+ sizeof(struct statistics_block);
+
+ bp->status_blk = pci_alloc_consistent(bp->pdev, bp->status_stats_size,
&bp->status_blk_mapping);
if (bp->status_blk == NULL)
goto alloc_mem_err;
- memset(bp->status_blk, 0, sizeof(struct status_block));
+ memset(bp->status_blk, 0, bp->status_stats_size);
- bp->stats_blk = pci_alloc_consistent(bp->pdev,
- sizeof(struct statistics_block),
- &bp->stats_blk_mapping);
- if (bp->stats_blk == NULL)
- goto alloc_mem_err;
+ bp->stats_blk = (void *) ((unsigned long) bp->status_blk +
+ status_blk_size);
- memset(bp->stats_blk, 0, sizeof(struct statistics_block));
+ bp->stats_blk_mapping = bp->status_blk_mapping + status_blk_size;
return 0;
@@ -1926,6 +1960,13 @@ bnx2_poll(struct net_device *dev, int *budget)
spin_lock(&bp->phy_lock);
bnx2_phy_int(bp);
spin_unlock(&bp->phy_lock);
+
+ /* This is needed to take care of transient status
+ * during link changes.
+ */
+ REG_WR(bp, BNX2_HC_COMMAND,
+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
+ REG_RD(bp, BNX2_HC_COMMAND);
}
if (bp->status_blk->status_tx_quick_consumer_index0 != bp->hw_tx_cons)
@@ -3307,6 +3348,8 @@ bnx2_init_chip(struct bnx2 *bp)
udelay(20);
+ bp->hc_cmd = REG_RD(bp, BNX2_HC_COMMAND);
+
return rc;
}
@@ -3746,7 +3789,6 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
struct sk_buff *skb, *rx_skb;
unsigned char *packet;
u16 rx_start_idx, rx_idx;
- u32 val;
dma_addr_t map;
struct tx_bd *txbd;
struct sw_bd *rx_buf;
@@ -3777,8 +3819,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
map = pci_map_single(bp->pdev, skb->data, pkt_size,
PCI_DMA_TODEVICE);
- val = REG_RD(bp, BNX2_HC_COMMAND);
- REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
+ REG_WR(bp, BNX2_HC_COMMAND,
+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
+
REG_RD(bp, BNX2_HC_COMMAND);
udelay(5);
@@ -3802,8 +3845,9 @@ bnx2_run_loopback(struct bnx2 *bp, int loopback_mode)
udelay(100);
- val = REG_RD(bp, BNX2_HC_COMMAND);
- REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
+ REG_WR(bp, BNX2_HC_COMMAND,
+ bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW_WO_INT);
+
REG_RD(bp, BNX2_HC_COMMAND);
udelay(5);
@@ -3939,7 +3983,6 @@ static int
bnx2_test_intr(struct bnx2 *bp)
{
int i;
- u32 val;
u16 status_idx;
if (!netif_running(bp->dev))
@@ -3948,8 +3991,7 @@ bnx2_test_intr(struct bnx2 *bp)
status_idx = REG_RD(bp, BNX2_PCICFG_INT_ACK_CMD) & 0xffff;
/* This register is not touched during run-time. */
- val = REG_RD(bp, BNX2_HC_COMMAND);
- REG_WR(bp, BNX2_HC_COMMAND, val | BNX2_HC_COMMAND_COAL_NOW);
+ REG_WR(bp, BNX2_HC_COMMAND, bp->hc_cmd | BNX2_HC_COMMAND_COAL_NOW);
REG_RD(bp, BNX2_HC_COMMAND);
for (i = 0; i < 10; i++) {
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index fd4b7f2eb47..b87925f6a22 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -13,46 +13,6 @@
#ifndef BNX2_H
#define BNX2_H
-#include <linux/config.h>
-
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-
-#include <linux/kernel.h>
-#include <linux/timer.h>
-#include <linux/errno.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/vmalloc.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
-#include <linux/init.h>
-#include <linux/netdevice.h>
-#include <linux/etherdevice.h>
-#include <linux/skbuff.h>
-#include <linux/dma-mapping.h>
-#include <asm/bitops.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <linux/delay.h>
-#include <asm/byteorder.h>
-#include <linux/time.h>
-#include <linux/ethtool.h>
-#include <linux/mii.h>
-#ifdef NETIF_F_HW_VLAN_TX
-#include <linux/if_vlan.h>
-#define BCM_VLAN 1
-#endif
-#ifdef NETIF_F_TSO
-#include <net/ip.h>
-#include <net/tcp.h>
-#include <net/checksum.h>
-#define BCM_TSO 1
-#endif
-#include <linux/workqueue.h>
-#include <linux/crc32.h>
-#include <linux/prefetch.h>
-
/* Hardware data structures and register definitions automatically
* generated from RTL code. Do not modify.
*/
@@ -3917,15 +3877,17 @@ struct bnx2 {
#define USING_MSI_FLAG 0x20
#define ASF_ENABLE_FLAG 0x40
- struct tx_bd *tx_desc_ring;
- struct sw_bd *tx_buf_ring;
- u32 tx_prod_bseq;
- u16 tx_prod;
- u16 tx_cons;
- int tx_ring_size;
+ /* Put tx producer and consumer fields in separate cache lines. */
- u16 hw_tx_cons;
- u16 hw_rx_cons;
+ u32 tx_prod_bseq __attribute__((aligned(L1_CACHE_BYTES)));
+ u16 tx_prod;
+
+ struct tx_bd *tx_desc_ring;
+ struct sw_bd *tx_buf_ring;
+ int tx_ring_size;
+
+ u16 tx_cons __attribute__((aligned(L1_CACHE_BYTES)));
+ u16 hw_tx_cons;
#ifdef BCM_VLAN
struct vlan_group *vlgrp;
@@ -3939,6 +3901,7 @@ struct bnx2 {
u32 rx_prod_bseq;
u16 rx_prod;
u16 rx_cons;
+ u16 hw_rx_cons;
u32 rx_csum;
@@ -4038,6 +4001,7 @@ struct bnx2 {
struct statistics_block *stats_blk;
dma_addr_t stats_blk_mapping;
+ u32 hc_cmd;
u32 rx_mode;
u16 req_line_speed;
@@ -4082,6 +4046,8 @@ struct bnx2 {
struct flash_spec *flash_info;
u32 flash_size;
+
+ int status_stats_size;
};
static u32 bnx2_reg_rd_ind(struct bnx2 *bp, u32 offset);
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c
index 8f1573e658a..ac48f754350 100644
--- a/drivers/net/cassini.c
+++ b/drivers/net/cassini.c
@@ -192,12 +192,15 @@
static char version[] __devinitdata =
DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
+static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
+static int link_mode;
+
MODULE_AUTHOR("Adrian Sun (asun@darksunrising.com)");
MODULE_DESCRIPTION("Sun Cassini(+) ethernet driver");
MODULE_LICENSE("GPL");
-MODULE_PARM(cassini_debug, "i");
+module_param(cassini_debug, int, 0);
MODULE_PARM_DESC(cassini_debug, "Cassini bitmapped debugging message enable value");
-MODULE_PARM(link_mode, "i");
+module_param(link_mode, int, 0);
MODULE_PARM_DESC(link_mode, "default link mode");
/*
@@ -209,7 +212,7 @@ MODULE_PARM_DESC(link_mode, "default link mode");
* Value in seconds, for user input.
*/
static int linkdown_timeout = DEFAULT_LINKDOWN_TIMEOUT;
-MODULE_PARM(linkdown_timeout, "i");
+module_param(linkdown_timeout, int, 0);
MODULE_PARM_DESC(linkdown_timeout,
"min reset interval in sec. for PCS linkdown issue; disabled if not positive");
@@ -221,8 +224,6 @@ MODULE_PARM_DESC(linkdown_timeout,
static int link_transition_timeout;
-static int cassini_debug = -1; /* -1 == use CAS_DEF_MSG_ENABLE as value */
-static int link_mode;
static u16 link_modes[] __devinitdata = {
BMCR_ANENABLE, /* 0 : autoneg */
diff --git a/drivers/net/chelsio/cxgb2.c b/drivers/net/chelsio/cxgb2.c
index 349ebe783ed..7fe2638ae06 100644
--- a/drivers/net/chelsio/cxgb2.c
+++ b/drivers/net/chelsio/cxgb2.c
@@ -124,7 +124,7 @@ MODULE_LICENSE("GPL");
static int dflt_msg_enable = DFLT_MSG_ENABLE;
-MODULE_PARM(dflt_msg_enable, "i");
+module_param(dflt_msg_enable, int, 0);
MODULE_PARM_DESC(dflt_msg_enable, "Chelsio T1 message enable bitmap");
diff --git a/drivers/net/depca.c b/drivers/net/depca.c
index 03804cc38be..0941d40f046 100644
--- a/drivers/net/depca.c
+++ b/drivers/net/depca.c
@@ -1412,7 +1412,7 @@ static int __init depca_mca_probe(struct device *device)
irq = 11;
break;
default:
- printk("%s: mca_probe IRQ error. You should never get here (%d).\n", dev->name, where);
+ printk("%s: mca_probe IRQ error. You should never get here (%d).\n", mdev->name, where);
return -EINVAL;
}
diff --git a/drivers/net/dgrs.c b/drivers/net/dgrs.c
index 32d13166c6e..e175d487668 100644
--- a/drivers/net/dgrs.c
+++ b/drivers/net/dgrs.c
@@ -1551,7 +1551,7 @@ MODULE_PARM_DESC(nicmode, "Digi RightSwitch operating mode (1: switch, 2: multi-
static int __init dgrs_init_module (void)
{
int i;
- int cardcount = 0;
+ int err;
/*
* Command line variable overrides
@@ -1593,13 +1593,13 @@ static int __init dgrs_init_module (void)
* Find and configure all the cards
*/
#ifdef CONFIG_EISA
- cardcount = eisa_driver_register(&dgrs_eisa_driver);
- if (cardcount < 0)
- return cardcount;
+ err = eisa_driver_register(&dgrs_eisa_driver);
+ if (err)
+ return err;
#endif
- cardcount = pci_register_driver(&dgrs_pci_driver);
- if (cardcount)
- return cardcount;
+ err = pci_register_driver(&dgrs_pci_driver);
+ if (err)
+ return err;
return 0;
}
diff --git a/drivers/net/fec_8xx/fec_main.c b/drivers/net/fec_8xx/fec_main.c
index b4f3a9f8a53..7e433809713 100644
--- a/drivers/net/fec_8xx/fec_main.c
+++ b/drivers/net/fec_8xx/fec_main.c
@@ -55,11 +55,11 @@ MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>");
MODULE_DESCRIPTION("Motorola 8xx FEC ethernet driver");
MODULE_LICENSE("GPL");
-MODULE_PARM(fec_8xx_debug, "i");
+int fec_8xx_debug = -1; /* -1 == use FEC_8XX_DEF_MSG_ENABLE as value */
+module_param(fec_8xx_debug, int, 0);
MODULE_PARM_DESC(fec_8xx_debug,
"FEC 8xx bitmapped debugging message enable value");
-int fec_8xx_debug = -1; /* -1 == use FEC_8XX_DEF_MSG_ENABLE as value */
/*************************************************/
diff --git a/drivers/net/fs_enet/fs_enet-main.c b/drivers/net/fs_enet/fs_enet-main.c
index f5d49a11065..196298f33db 100644
--- a/drivers/net/fs_enet/fs_enet-main.c
+++ b/drivers/net/fs_enet/fs_enet-main.c
@@ -58,11 +58,11 @@ MODULE_DESCRIPTION("Freescale Ethernet Driver");
MODULE_LICENSE("GPL");
MODULE_VERSION(DRV_MODULE_VERSION);
-MODULE_PARM(fs_enet_debug, "i");
+int fs_enet_debug = -1; /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
+module_param(fs_enet_debug, int, 0);
MODULE_PARM_DESC(fs_enet_debug,
"Freescale bitmapped debugging message enable value");
-int fs_enet_debug = -1; /* -1 == use FS_ENET_DEF_MSG_ENABLE as value */
static void fs_set_multicast_list(struct net_device *dev)
{
diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c
index 5958a631472..2d243540461 100644
--- a/drivers/net/gt96100eth.c
+++ b/drivers/net/gt96100eth.c
@@ -114,8 +114,8 @@ static int max_interrupt_work = 32;
static char mac0[18] = "00.02.03.04.05.06";
static char mac1[18] = "00.01.02.03.04.05";
-MODULE_PARM(mac0, "c18");
-MODULE_PARM(mac1, "c18");
+module_param_string(mac0, mac0, 18, 0);
+module_param_string(mac1, mac0, 18, 0);
MODULE_PARM_DESC(mac0, "MAC address for GT96100 ethernet port 0");
MODULE_PARM_DESC(mac1, "MAC address for GT96100 ethernet port 1");
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c
index c8dc40214a0..79a8fbcf5f9 100644
--- a/drivers/net/hamradio/dmascc.c
+++ b/drivers/net/hamradio/dmascc.c
@@ -280,7 +280,7 @@ static unsigned long rand;
MODULE_AUTHOR("Klaus Kudielka");
MODULE_DESCRIPTION("Driver for high-speed SCC boards");
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NUM_DEVS) "i");
+module_param_array(io, int, NULL, 0);
MODULE_LICENSE("GPL");
static void __exit dmascc_exit(void)
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c
index dc5e9d59dee..d81a8e1eeb8 100644
--- a/drivers/net/hamradio/mkiss.c
+++ b/drivers/net/hamradio/mkiss.c
@@ -1012,7 +1012,7 @@ static void __exit mkiss_exit_driver(void)
MODULE_AUTHOR("Ralf Baechle DL5RB <ralf@linux-mips.org>");
MODULE_DESCRIPTION("KISS driver for AX.25 over TTYs");
-MODULE_PARM(crc_force, "i");
+module_param(crc_force, int, 0);
MODULE_PARM_DESC(crc_force, "crc [0 = auto | 1 = none | 2 = flexnet | 3 = smack]");
MODULE_LICENSE("GPL");
MODULE_ALIAS_LDISC(N_AX25);
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c
index 74e167e7dea..0d7a6250e34 100644
--- a/drivers/net/hp-plus.c
+++ b/drivers/net/hp-plus.c
@@ -250,6 +250,12 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
ei_status.block_output = &hpp_mem_block_output;
ei_status.get_8390_hdr = &hpp_mem_get_8390_hdr;
dev->mem_start = mem_start;
+ ei_status.mem = ioremap(mem_start,
+ (HP_STOP_PG - HP_START_PG)*256);
+ if (!ei_status.mem) {
+ retval = -ENOMEM;
+ goto out;
+ }
ei_status.rmem_start = dev->mem_start + TX_PAGES/2*256;
dev->mem_end = ei_status.rmem_end
= dev->mem_start + (HP_STOP_PG - HP_START_PG)*256;
@@ -262,8 +268,10 @@ static int __init hpp_probe1(struct net_device *dev, int ioaddr)
retval = register_netdev(dev);
if (retval)
- goto out;
+ goto out1;
return 0;
+out1:
+ iounmap(ei_status.mem);
out:
release_region(ioaddr, HP_IO_EXTENT);
return retval;
@@ -372,7 +380,7 @@ hpp_mem_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring
outw((ring_page<<8), ioaddr + HPP_IN_ADDR);
outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
- isa_memcpy_fromio(hdr, dev->mem_start, sizeof(struct e8390_pkt_hdr));
+ memcpy_fromio(hdr, ei_status.mem, sizeof(struct e8390_pkt_hdr));
outw(option_reg, ioaddr + HPP_OPTION);
hdr->count = (le16_to_cpu(hdr->count) + 3) & ~3; /* Round up allocation. */
}
@@ -391,7 +399,7 @@ hpp_mem_block_input(struct net_device *dev, int count, struct sk_buff *skb, int
Also note that we *can't* use eth_io_copy_and_sum() because
it will not always copy "count" bytes (e.g. padded IP). */
- isa_memcpy_fromio(skb->data, dev->mem_start, count);
+ memcpy_fromio(skb->data, ei_status.mem, count);
outw(option_reg, ioaddr + HPP_OPTION);
}
@@ -416,7 +424,7 @@ hpp_mem_block_output(struct net_device *dev, int count,
outw(start_page << 8, ioaddr + HPP_OUT_ADDR);
outw(option_reg & ~(MemDisable + BootROMEnb), ioaddr + HPP_OPTION);
- isa_memcpy_toio(dev->mem_start, buf, (count + 3) & ~3);
+ memcpy_toio(ei_status.mem, buf, (count + 3) & ~3);
outw(option_reg, ioaddr + HPP_OPTION);
return;
@@ -470,6 +478,7 @@ init_module(void)
static void cleanup_card(struct net_device *dev)
{
/* NB: hpp_close() handles free_irq */
+ iounmap(ei_status.mem);
release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT);
}
diff --git a/drivers/net/hplance.c b/drivers/net/hplance.c
index d8410634bca..68569346460 100644
--- a/drivers/net/hplance.c
+++ b/drivers/net/hplance.c
@@ -217,7 +217,7 @@ static int hplance_close(struct net_device *dev)
int __init hplance_init_module(void)
{
- return dio_module_init(&hplance_driver);
+ return dio_register_driver(&hplance_driver);
}
void __exit hplance_cleanup_module(void)
diff --git a/drivers/net/hydra.c b/drivers/net/hydra.c
index 6e0ca7340a8..d9fb8e74e63 100644
--- a/drivers/net/hydra.c
+++ b/drivers/net/hydra.c
@@ -242,7 +242,7 @@ static void __devexit hydra_remove_one(struct zorro_dev *z)
static int __init hydra_init_module(void)
{
- return zorro_module_init(&hydra_driver);
+ return zorro_register_driver(&hydra_driver);
}
static void __exit hydra_cleanup_module(void)
diff --git a/drivers/net/irda/irport.c b/drivers/net/irda/irport.c
index 6070195b87b..98fa5319e5c 100644
--- a/drivers/net/irda/irport.c
+++ b/drivers/net/irda/irport.c
@@ -1118,9 +1118,9 @@ static void __exit irport_cleanup(void)
}
}
-MODULE_PARM(io, "1-4i");
+module_param_array(io, int, NULL, 0);
MODULE_PARM_DESC(io, "Base I/O addresses");
-MODULE_PARM(irq, "1-4i");
+module_param_array(irq, int, NULL, 0);
MODULE_PARM_DESC(irq, "IRQ lines");
MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no>");
diff --git a/drivers/net/ixp2000/enp2611.c b/drivers/net/ixp2000/enp2611.c
index d82651a97ba..6f7dce8eba5 100644
--- a/drivers/net/ixp2000/enp2611.c
+++ b/drivers/net/ixp2000/enp2611.c
@@ -16,7 +16,7 @@
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
-#include <asm/arch/uengine.h>
+#include <asm/hardware/uengine.h>
#include <asm/mach-types.h>
#include <asm/io.h>
#include "ixpdev.h"
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 09f03f493be..77f104a005f 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -16,7 +16,7 @@
#include <linux/etherdevice.h>
#include <linux/init.h>
#include <linux/moduleparam.h>
-#include <asm/arch/uengine.h>
+#include <asm/hardware/uengine.h>
#include <asm/mach-types.h>
#include <asm/io.h>
#include "ixp2400_rx.ucode"
diff --git a/drivers/net/lance.c b/drivers/net/lance.c
index d1d714faa6c..bb5ad479210 100644
--- a/drivers/net/lance.c
+++ b/drivers/net/lance.c
@@ -464,20 +464,25 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
static int did_version; /* Already printed version info. */
unsigned long flags;
int err = -ENOMEM;
+ void __iomem *bios;
/* First we look for special cases.
Check for HP's on-board ethernet by looking for 'HP' in the BIOS.
There are two HP versions, check the BIOS for the configuration port.
This method provided by L. Julliard, Laurent_Julliard@grenoble.hp.com.
*/
- if (isa_readw(0x000f0102) == 0x5048) {
+ bios = ioremap(0xf00f0, 0x14);
+ if (!bios)
+ return -ENOMEM;
+ if (readw(bios + 0x12) == 0x5048) {
static const short ioaddr_table[] = { 0x300, 0x320, 0x340, 0x360};
- int hp_port = (isa_readl(0x000f00f1) & 1) ? 0x499 : 0x99;
+ int hp_port = (readl(bios + 1) & 1) ? 0x499 : 0x99;
/* We can have boards other than the built-in! Verify this is on-board. */
if ((inb(hp_port) & 0xc0) == 0x80
&& ioaddr_table[inb(hp_port) & 3] == ioaddr)
hp_builtin = hp_port;
}
+ iounmap(bios);
/* We also recognize the HP Vectra on-board here, but check below. */
hpJ2405A = (inb(ioaddr) == 0x08 && inb(ioaddr+1) == 0x00
&& inb(ioaddr+2) == 0x09);
diff --git a/drivers/net/lasi_82596.c b/drivers/net/lasi_82596.c
index f7b7238d835..957888de3d7 100644
--- a/drivers/net/lasi_82596.c
+++ b/drivers/net/lasi_82596.c
@@ -177,7 +177,7 @@ static int i596_debug = (DEB_SERIOUS|DEB_PROBE);
MODULE_AUTHOR("Richard Hirst");
MODULE_DESCRIPTION("i82596 driver");
MODULE_LICENSE("GPL");
-MODULE_PARM(i596_debug, "i");
+module_param(i596_debug, int, 0);
MODULE_PARM_DESC(i596_debug, "lasi_82596 debug mask");
/* Copy frames shorter than rx_copybreak, otherwise pass on up in
@@ -1520,9 +1520,9 @@ static void set_multicast_list(struct net_device *dev)
}
}
-MODULE_PARM(debug, "i");
-MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
static int debug = -1;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, "lasi_82596 debug mask");
static int num_drivers;
static struct net_device *netdevs[MAX_DRIVERS];
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index 690a1aae0b3..0c13795dca3 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -172,11 +172,9 @@ static struct net_device_stats *get_stats(struct net_device *dev)
memset(stats, 0, sizeof(struct net_device_stats));
- for (i=0; i < NR_CPUS; i++) {
+ for_each_cpu(i) {
struct net_device_stats *lb_stats;
- if (!cpu_possible(i))
- continue;
lb_stats = &per_cpu(loopback_stats, i);
stats->rx_bytes += lb_stats->rx_bytes;
stats->tx_bytes += lb_stats->tx_bytes;
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c
index f65b0db111b..cd3c9a5a98b 100644
--- a/drivers/net/mac89x0.c
+++ b/drivers/net/mac89x0.c
@@ -629,7 +629,7 @@ static int set_mac_address(struct net_device *dev, void *addr)
static struct net_device *dev_cs89x0;
static int debug;
-MODULE_PARM(debug, "i");
+module_param(debug, int, 0);
MODULE_PARM_DESC(debug, "CS89[02]0 debug level (0-5)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/mace.c b/drivers/net/mace.c
index 2a5add257b8..77792b28602 100644
--- a/drivers/net/mace.c
+++ b/drivers/net/mace.c
@@ -1042,7 +1042,7 @@ static void __exit mace_cleanup(void)
MODULE_AUTHOR("Paul Mackerras");
MODULE_DESCRIPTION("PowerMac MACE driver.");
-MODULE_PARM(port_aaui, "i");
+module_param(port_aaui, int, 0);
MODULE_PARM_DESC(port_aaui, "MACE uses AAUI port (0-1)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index e23655f5049..d644bf3a933 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -62,7 +62,7 @@ MODULE_DESCRIPTION("SGI O2 Builtin Fast Ethernet driver");
#ifdef HAVE_TX_TIMEOUT
static int timeout = TX_TIMEOUT;
-MODULE_PARM(timeout, "i");
+module_param(timeout, int, 0);
#endif
/*
diff --git a/drivers/net/ne-h8300.c b/drivers/net/ne-h8300.c
index aaebd28a192..7ea3d596ac3 100644
--- a/drivers/net/ne-h8300.c
+++ b/drivers/net/ne-h8300.c
@@ -601,9 +601,9 @@ static int io[MAX_NE_CARDS];
static int irq[MAX_NE_CARDS];
static int bad[MAX_NE_CARDS]; /* 0xbad = bad sig or no reset ack */
-MODULE_PARM(io, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(irq, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
-MODULE_PARM(bad, "1-" __MODULE_STRING(MAX_NE_CARDS) "i");
+module_param_array(io, int, NULL, 0);
+module_param_array(irq, int, NULL, 0);
+module_param_array(bad, int, NULL, 0);
MODULE_PARM_DESC(io, "I/O base address(es)");
MODULE_PARM_DESC(irq, "IRQ number(s)");
MODULE_DESCRIPTION("H8/300 NE2000 Ethernet driver");
diff --git a/drivers/net/ne2k-pci.c b/drivers/net/ne2k-pci.c
index e3ebb5803b0..d11821dd86e 100644
--- a/drivers/net/ne2k-pci.c
+++ b/drivers/net/ne2k-pci.c
@@ -117,7 +117,7 @@ enum ne2k_pci_chipsets {
};
-static const struct {
+static struct {
char *name;
int flags;
} pci_clone_list[] __devinitdata = {
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c
index 2ab01a5d1d2..a68bf474f6e 100644
--- a/drivers/net/ni5010.c
+++ b/drivers/net/ni5010.c
@@ -766,8 +766,8 @@ static void ni5010_show_registers(struct net_device *dev)
#ifdef MODULE
static struct net_device *dev_ni5010;
-MODULE_PARM(io, "i");
-MODULE_PARM(irq, "i");
+module_param(io, int, 0);
+module_param(irq, int, 0);
MODULE_PARM_DESC(io, "ni5010 I/O base address");
MODULE_PARM_DESC(irq, "ni5010 IRQ number");
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index f608c12e3e8..b2073fce821 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -46,6 +46,7 @@
#include <linux/rwsem.h>
#include <linux/stddef.h>
#include <linux/device.h>
+#include <linux/mutex.h>
#include <net/slhc_vj.h>
#include <asm/atomic.h>
@@ -198,11 +199,11 @@ static unsigned int cardmap_find_first_free(struct cardmap *map);
static void cardmap_destroy(struct cardmap **map);
/*
- * all_ppp_sem protects the all_ppp_units mapping.
+ * all_ppp_mutex protects the all_ppp_units mapping.
* It also ensures that finding a ppp unit in the all_ppp_units map
* and updating its file.refcnt field is atomic.
*/
-static DECLARE_MUTEX(all_ppp_sem);
+static DEFINE_MUTEX(all_ppp_mutex);
static struct cardmap *all_ppp_units;
static atomic_t ppp_unit_count = ATOMIC_INIT(0);
@@ -804,7 +805,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
/* Attach to an existing ppp unit */
if (get_user(unit, p))
break;
- down(&all_ppp_sem);
+ mutex_lock(&all_ppp_mutex);
err = -ENXIO;
ppp = ppp_find_unit(unit);
if (ppp != 0) {
@@ -812,7 +813,7 @@ static int ppp_unattached_ioctl(struct ppp_file *pf, struct file *file,
file->private_data = &ppp->file;
err = 0;
}
- up(&all_ppp_sem);
+ mutex_unlock(&all_ppp_mutex);
break;
case PPPIOCATTCHAN:
@@ -2446,7 +2447,7 @@ ppp_create_interface(int unit, int *retp)
dev->do_ioctl = ppp_net_ioctl;
ret = -EEXIST;
- down(&all_ppp_sem);
+ mutex_lock(&all_ppp_mutex);
if (unit < 0)
unit = cardmap_find_first_free(all_ppp_units);
else if (cardmap_get(all_ppp_units, unit) != NULL)
@@ -2465,12 +2466,12 @@ ppp_create_interface(int unit, int *retp)
atomic_inc(&ppp_unit_count);
cardmap_set(&all_ppp_units, unit, ppp);
- up(&all_ppp_sem);
+ mutex_unlock(&all_ppp_mutex);
*retp = 0;
return ppp;
out2:
- up(&all_ppp_sem);
+ mutex_unlock(&all_ppp_mutex);
free_netdev(dev);
out1:
kfree(ppp);
@@ -2500,7 +2501,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
{
struct net_device *dev;
- down(&all_ppp_sem);
+ mutex_lock(&all_ppp_mutex);
ppp_lock(ppp);
dev = ppp->dev;
ppp->dev = NULL;
@@ -2514,7 +2515,7 @@ static void ppp_shutdown_interface(struct ppp *ppp)
ppp->file.dead = 1;
ppp->owner = NULL;
wake_up_interruptible(&ppp->file.rwait);
- up(&all_ppp_sem);
+ mutex_unlock(&all_ppp_mutex);
}
/*
@@ -2556,7 +2557,7 @@ static void ppp_destroy_interface(struct ppp *ppp)
/*
* Locate an existing ppp unit.
- * The caller should have locked the all_ppp_sem.
+ * The caller should have locked the all_ppp_mutex.
*/
static struct ppp *
ppp_find_unit(int unit)
@@ -2601,7 +2602,7 @@ ppp_connect_channel(struct channel *pch, int unit)
int ret = -ENXIO;
int hdrlen;
- down(&all_ppp_sem);
+ mutex_lock(&all_ppp_mutex);
ppp = ppp_find_unit(unit);
if (ppp == 0)
goto out;
@@ -2626,7 +2627,7 @@ ppp_connect_channel(struct channel *pch, int unit)
outl:
write_unlock_bh(&pch->upl);
out:
- up(&all_ppp_sem);
+ mutex_unlock(&all_ppp_mutex);
return ret;
}
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c
index a1cb07cdb60..253440a9802 100644
--- a/drivers/net/sis900.c
+++ b/drivers/net/sis900.c
@@ -128,6 +128,7 @@ static const struct mii_chip_info {
{ "SiS 900 Internal MII PHY", 0x001d, 0x8000, LAN },
{ "SiS 7014 Physical Layer Solution", 0x0016, 0xf830, LAN },
{ "Altimata AC101LF PHY", 0x0022, 0x5520, LAN },
+ { "ADM 7001 LAN PHY", 0x002e, 0xcc60, LAN },
{ "AMD 79C901 10BASE-T PHY", 0x0000, 0x6B70, LAN },
{ "AMD 79C901 HomePNA PHY", 0x0000, 0x6B90, HOME},
{ "ICS LAN PHY", 0x0015, 0xF440, LAN },
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c
index a5f2b1ee075..38a26df4095 100644
--- a/drivers/net/sk98lin/skge.c
+++ b/drivers/net/sk98lin/skge.c
@@ -1727,7 +1727,7 @@ struct sk_buff *pMessage) /* pointer to send-message */
pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
pTxd->pMBuf = pMessage;
- pTxd->TBControl = Control | BMU_OWN | sk_frag->size;;
+ pTxd->TBControl = Control | BMU_OWN | sk_frag->size;
/*
** Do we have the last fragment?
diff --git a/drivers/net/skge.c b/drivers/net/skge.c
index 4eda81d41b1..35dbf05c7f0 100644
--- a/drivers/net/skge.c
+++ b/drivers/net/skge.c
@@ -44,7 +44,7 @@
#include "skge.h"
#define DRV_NAME "skge"
-#define DRV_VERSION "1.4"
+#define DRV_VERSION "1.5"
#define PFX DRV_NAME " "
#define DEFAULT_TX_RING_SIZE 128
@@ -357,7 +357,7 @@ static struct net_device_stats *skge_get_stats(struct net_device *dev)
skge->net_stats.rx_bytes = data[1];
skge->net_stats.tx_packets = data[2] + data[4] + data[6];
skge->net_stats.rx_packets = data[3] + data[5] + data[7];
- skge->net_stats.multicast = data[5] + data[7];
+ skge->net_stats.multicast = data[3] + data[5];
skge->net_stats.collisions = data[10];
skge->net_stats.tx_aborted_errors = data[12];
@@ -781,7 +781,7 @@ static void skge_rx_setup(struct skge_port *skge, struct skge_element *e,
* Note: DMA address is not changed by chip.
* MTU not changed while receiver active.
*/
-static void skge_rx_reuse(struct skge_element *e, unsigned int size)
+static inline void skge_rx_reuse(struct skge_element *e, unsigned int size)
{
struct skge_rx_desc *rd = e->desc;
@@ -829,7 +829,7 @@ static int skge_rx_fill(struct skge_port *skge)
do {
struct sk_buff *skb;
- skb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN);
+ skb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_KERNEL);
if (!skb)
return -ENOMEM;
@@ -847,8 +847,7 @@ static void skge_link_up(struct skge_port *skge)
LED_BLK_OFF|LED_SYNC_OFF|LED_ON);
netif_carrier_on(skge->netdev);
- if (skge->tx_avail > MAX_SKB_FRAGS + 1)
- netif_wake_queue(skge->netdev);
+ netif_wake_queue(skge->netdev);
if (netif_msg_link(skge))
printk(KERN_INFO PFX
@@ -2155,7 +2154,7 @@ static int skge_up(struct net_device *dev)
printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
if (dev->mtu > RX_BUF_SIZE)
- skge->rx_buf_size = dev->mtu + ETH_HLEN + NET_IP_ALIGN;
+ skge->rx_buf_size = dev->mtu + ETH_HLEN;
else
skge->rx_buf_size = RX_BUF_SIZE;
@@ -2190,8 +2189,6 @@ static int skge_up(struct net_device *dev)
if (err)
goto free_rx_ring;
- skge->tx_avail = skge->tx_ring.count - 1;
-
/* Initialize MAC */
spin_lock_bh(&hw->phy_lock);
if (hw->chip_id == CHIP_ID_GENESIS)
@@ -2294,6 +2291,12 @@ static int skge_down(struct net_device *dev)
return 0;
}
+static inline int skge_avail(const struct skge_ring *ring)
+{
+ return ((ring->to_clean > ring->to_use) ? 0 : ring->count)
+ + (ring->to_clean - ring->to_use) - 1;
+}
+
static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
{
struct skge_port *skge = netdev_priv(dev);
@@ -2314,7 +2317,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_LOCKED;
}
- if (unlikely(skge->tx_avail < skb_shinfo(skb)->nr_frags +1)) {
+ if (unlikely(skge_avail(&skge->tx_ring) < skb_shinfo(skb)->nr_frags + 1)) {
if (!netif_queue_stopped(dev)) {
netif_stop_queue(dev);
@@ -2390,8 +2393,7 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
dev->name, e - ring->start, skb->len);
ring->to_use = e->next;
- skge->tx_avail -= skb_shinfo(skb)->nr_frags + 1;
- if (skge->tx_avail <= MAX_SKB_FRAGS + 1) {
+ if (skge_avail(&skge->tx_ring) <= MAX_SKB_FRAGS + 1) {
pr_debug("%s: transmit queue full\n", dev->name);
netif_stop_queue(dev);
}
@@ -2404,35 +2406,37 @@ static int skge_xmit_frame(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}
-static inline void skge_tx_free(struct skge_hw *hw, struct skge_element *e)
+static void skge_tx_complete(struct skge_port *skge, struct skge_element *last)
{
- /* This ring element can be skb or fragment */
- if (e->skb) {
- pci_unmap_single(hw->pdev,
- pci_unmap_addr(e, mapaddr),
- pci_unmap_len(e, maplen),
- PCI_DMA_TODEVICE);
- dev_kfree_skb(e->skb);
+ struct pci_dev *pdev = skge->hw->pdev;
+ struct skge_element *e;
+
+ for (e = skge->tx_ring.to_clean; e != last; e = e->next) {
+ struct sk_buff *skb = e->skb;
+ int i;
+
e->skb = NULL;
- } else {
- pci_unmap_page(hw->pdev,
- pci_unmap_addr(e, mapaddr),
- pci_unmap_len(e, maplen),
- PCI_DMA_TODEVICE);
+ pci_unmap_single(pdev, pci_unmap_addr(e, mapaddr),
+ skb_headlen(skb), PCI_DMA_TODEVICE);
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ e = e->next;
+ pci_unmap_page(pdev, pci_unmap_addr(e, mapaddr),
+ skb_shinfo(skb)->frags[i].size,
+ PCI_DMA_TODEVICE);
+ }
+
+ dev_kfree_skb(skb);
}
+ skge->tx_ring.to_clean = e;
}
static void skge_tx_clean(struct skge_port *skge)
{
- struct skge_ring *ring = &skge->tx_ring;
- struct skge_element *e;
spin_lock_bh(&skge->tx_lock);
- for (e = ring->to_clean; e != ring->to_use; e = e->next) {
- ++skge->tx_avail;
- skge_tx_free(skge->hw, e);
- }
- ring->to_clean = e;
+ skge_tx_complete(skge, skge->tx_ring.to_use);
+ netif_wake_queue(skge->netdev);
spin_unlock_bh(&skge->tx_lock);
}
@@ -2592,7 +2596,7 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
goto error;
if (len < RX_COPY_THRESHOLD) {
- skb = dev_alloc_skb(len + 2);
+ skb = alloc_skb(len + 2, GFP_ATOMIC);
if (!skb)
goto resubmit;
@@ -2607,10 +2611,11 @@ static inline struct sk_buff *skge_rx_get(struct skge_port *skge,
skge_rx_reuse(e, skge->rx_buf_size);
} else {
struct sk_buff *nskb;
- nskb = dev_alloc_skb(skge->rx_buf_size + NET_IP_ALIGN);
+ nskb = alloc_skb(skge->rx_buf_size + NET_IP_ALIGN, GFP_ATOMIC);
if (!nskb)
goto resubmit;
+ skb_reserve(nskb, NET_IP_ALIGN);
pci_unmap_single(skge->hw->pdev,
pci_unmap_addr(e, mapaddr),
pci_unmap_len(e, maplen),
@@ -2661,30 +2666,29 @@ resubmit:
static void skge_tx_done(struct skge_port *skge)
{
struct skge_ring *ring = &skge->tx_ring;
- struct skge_element *e;
+ struct skge_element *e, *last;
spin_lock(&skge->tx_lock);
- for (e = ring->to_clean; prefetch(e->next), e != ring->to_use; e = e->next) {
+ last = ring->to_clean;
+ for (e = ring->to_clean; e != ring->to_use; e = e->next) {
struct skge_tx_desc *td = e->desc;
- u32 control;
- rmb();
- control = td->control;
- if (control & BMU_OWN)
+ if (td->control & BMU_OWN)
break;
- if (unlikely(netif_msg_tx_done(skge)))
- printk(KERN_DEBUG PFX "%s: tx done slot %td status 0x%x\n",
- skge->netdev->name, e - ring->start, td->status);
-
- skge_tx_free(skge->hw, e);
- e->skb = NULL;
- ++skge->tx_avail;
+ if (td->control & BMU_EOF) {
+ last = e->next;
+ if (unlikely(netif_msg_tx_done(skge)))
+ printk(KERN_DEBUG PFX "%s: tx done slot %td\n",
+ skge->netdev->name, e - ring->start);
+ }
}
- ring->to_clean = e;
+
+ skge_tx_complete(skge, last);
+
skge_write8(skge->hw, Q_ADDR(txqaddr[skge->port], Q_CSR), CSR_IRQ_CL_F);
- if (skge->tx_avail > MAX_SKB_FRAGS + 1)
+ if (skge_avail(&skge->tx_ring) > MAX_SKB_FRAGS + 1)
netif_wake_queue(skge->netdev);
spin_unlock(&skge->tx_lock);
@@ -2718,8 +2722,7 @@ static int skge_poll(struct net_device *dev, int *budget)
netif_receive_skb(skb);
++work_done;
- } else
- skge_rx_reuse(e, skge->rx_buf_size);
+ }
}
ring->to_clean = e;
diff --git a/drivers/net/skge.h b/drivers/net/skge.h
index 2efdacc290e..1f1ce88c818 100644
--- a/drivers/net/skge.h
+++ b/drivers/net/skge.h
@@ -2418,7 +2418,6 @@ struct skge_port {
int port;
spinlock_t tx_lock;
- u32 tx_avail;
struct skge_ring tx_ring;
struct skge_ring rx_ring;
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index f08fe6c884b..68f9c206a62 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1175,7 +1175,7 @@ static int sky2_xmit_frame(struct sk_buff *skb, struct net_device *dev)
/* just drop the packet if non-linear expansion fails */
if (skb_header_cloned(skb) &&
pskb_expand_head(skb, 0, 0, GFP_ATOMIC)) {
- dev_kfree_skb_any(skb);
+ dev_kfree_skb(skb);
goto out_unlock;
}
@@ -1324,7 +1324,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
PCI_DMA_TODEVICE);
}
- dev_kfree_skb_any(skb);
+ dev_kfree_skb(skb);
}
sky2->tx_cons = put;
@@ -2478,17 +2478,34 @@ static const struct sky2_stat {
{ "rx_unicast", GM_RXF_UC_OK },
{ "tx_mac_pause", GM_TXF_MPAUSE },
{ "rx_mac_pause", GM_RXF_MPAUSE },
- { "collisions", GM_TXF_SNG_COL },
+ { "collisions", GM_TXF_COL },
{ "late_collision",GM_TXF_LAT_COL },
{ "aborted", GM_TXF_ABO_COL },
+ { "single_collisions", GM_TXF_SNG_COL },
{ "multi_collisions", GM_TXF_MUL_COL },
- { "fifo_underrun", GM_TXE_FIFO_UR },
- { "fifo_overflow", GM_RXE_FIFO_OV },
- { "rx_toolong", GM_RXF_LNG_ERR },
- { "rx_jabber", GM_RXF_JAB_PKT },
+
+ { "rx_short", GM_RXF_SHT },
{ "rx_runt", GM_RXE_FRAG },
+ { "rx_64_byte_packets", GM_RXF_64B },
+ { "rx_65_to_127_byte_packets", GM_RXF_127B },
+ { "rx_128_to_255_byte_packets", GM_RXF_255B },
+ { "rx_256_to_511_byte_packets", GM_RXF_511B },
+ { "rx_512_to_1023_byte_packets", GM_RXF_1023B },
+ { "rx_1024_to_1518_byte_packets", GM_RXF_1518B },
+ { "rx_1518_to_max_byte_packets", GM_RXF_MAX_SZ },
{ "rx_too_long", GM_RXF_LNG_ERR },
+ { "rx_fifo_overflow", GM_RXE_FIFO_OV },
+ { "rx_jabber", GM_RXF_JAB_PKT },
{ "rx_fcs_error", GM_RXF_FCS_ERR },
+
+ { "tx_64_byte_packets", GM_TXF_64B },
+ { "tx_65_to_127_byte_packets", GM_TXF_127B },
+ { "tx_128_to_255_byte_packets", GM_TXF_255B },
+ { "tx_256_to_511_byte_packets", GM_TXF_511B },
+ { "tx_512_to_1023_byte_packets", GM_TXF_1023B },
+ { "tx_1024_to_1518_byte_packets", GM_TXF_1518B },
+ { "tx_1519_to_max_byte_packets", GM_TXF_MAX_SZ },
+ { "tx_fifo_underrun", GM_TXE_FIFO_UR },
};
static u32 sky2_get_rx_csum(struct net_device *dev)
@@ -2590,7 +2607,7 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
sky2->net_stats.rx_bytes = data[1];
sky2->net_stats.tx_packets = data[2] + data[4] + data[6];
sky2->net_stats.rx_packets = data[3] + data[5] + data[7];
- sky2->net_stats.multicast = data[5] + data[7];
+ sky2->net_stats.multicast = data[3] + data[5];
sky2->net_stats.collisions = data[10];
sky2->net_stats.tx_aborted_errors = data[12];
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index d63cd5a1b71..62532b4e45c 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1373,23 +1373,23 @@ enum {
GM_SMI_CTRL = 0x0080, /* 16 bit r/w SMI Control Register */
GM_SMI_DATA = 0x0084, /* 16 bit r/w SMI Data Register */
GM_PHY_ADDR = 0x0088, /* 16 bit r/w GPHY Address Register */
+/* MIB Counters */
+ GM_MIB_CNT_BASE = 0x0100, /* Base Address of MIB Counters */
+ GM_MIB_CNT_SIZE = 256,
};
-/* MIB Counters */
-#define GM_MIB_CNT_BASE 0x0100 /* Base Address of MIB Counters */
-#define GM_MIB_CNT_SIZE 44 /* Number of MIB Counters */
/*
* MIB Counters base address definitions (low word) -
* use offset 4 for access to high word (32 bit r/o)
*/
enum {
- GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */
+ GM_RXF_UC_OK = GM_MIB_CNT_BASE + 0, /* Unicast Frames Received OK */
GM_RXF_BC_OK = GM_MIB_CNT_BASE + 8, /* Broadcast Frames Received OK */
GM_RXF_MPAUSE = GM_MIB_CNT_BASE + 16, /* Pause MAC Ctrl Frames Received */
GM_RXF_MC_OK = GM_MIB_CNT_BASE + 24, /* Multicast Frames Received OK */
GM_RXF_FCS_ERR = GM_MIB_CNT_BASE + 32, /* Rx Frame Check Seq. Error */
- /* GM_MIB_CNT_BASE + 40: reserved */
+
GM_RXO_OK_LO = GM_MIB_CNT_BASE + 48, /* Octets Received OK Low */
GM_RXO_OK_HI = GM_MIB_CNT_BASE + 56, /* Octets Received OK High */
GM_RXO_ERR_LO = GM_MIB_CNT_BASE + 64, /* Octets Received Invalid Low */
@@ -1397,37 +1397,36 @@ enum {
GM_RXF_SHT = GM_MIB_CNT_BASE + 80, /* Frames <64 Byte Received OK */
GM_RXE_FRAG = GM_MIB_CNT_BASE + 88, /* Frames <64 Byte Received with FCS Err */
GM_RXF_64B = GM_MIB_CNT_BASE + 96, /* 64 Byte Rx Frame */
- GM_RXF_127B = GM_MIB_CNT_BASE + 104, /* 65-127 Byte Rx Frame */
- GM_RXF_255B = GM_MIB_CNT_BASE + 112, /* 128-255 Byte Rx Frame */
- GM_RXF_511B = GM_MIB_CNT_BASE + 120, /* 256-511 Byte Rx Frame */
- GM_RXF_1023B = GM_MIB_CNT_BASE + 128, /* 512-1023 Byte Rx Frame */
- GM_RXF_1518B = GM_MIB_CNT_BASE + 136, /* 1024-1518 Byte Rx Frame */
- GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144, /* 1519-MaxSize Byte Rx Frame */
- GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152, /* Rx Frame too Long Error */
- GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160, /* Rx Jabber Packet Frame */
- /* GM_MIB_CNT_BASE + 168: reserved */
- GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176, /* Rx FIFO overflow Event */
- /* GM_MIB_CNT_BASE + 184: reserved */
- GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192, /* Unicast Frames Xmitted OK */
- GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200, /* Broadcast Frames Xmitted OK */
- GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208, /* Pause MAC Ctrl Frames Xmitted */
- GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216, /* Multicast Frames Xmitted OK */
- GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224, /* Octets Transmitted OK Low */
- GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232, /* Octets Transmitted OK High */
- GM_TXF_64B = GM_MIB_CNT_BASE + 240, /* 64 Byte Tx Frame */
- GM_TXF_127B = GM_MIB_CNT_BASE + 248, /* 65-127 Byte Tx Frame */
- GM_TXF_255B = GM_MIB_CNT_BASE + 256, /* 128-255 Byte Tx Frame */
- GM_TXF_511B = GM_MIB_CNT_BASE + 264, /* 256-511 Byte Tx Frame */
- GM_TXF_1023B = GM_MIB_CNT_BASE + 272, /* 512-1023 Byte Tx Frame */
- GM_TXF_1518B = GM_MIB_CNT_BASE + 280, /* 1024-1518 Byte Tx Frame */
- GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288, /* 1519-MaxSize Byte Tx Frame */
-
- GM_TXF_COL = GM_MIB_CNT_BASE + 304, /* Tx Collision */
- GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312, /* Tx Late Collision */
- GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320, /* Tx aborted due to Exces. Col. */
- GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328, /* Tx Multiple Collision */
- GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336, /* Tx Single Collision */
- GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344, /* Tx FIFO Underrun Event */
+ GM_RXF_127B = GM_MIB_CNT_BASE + 104,/* 65-127 Byte Rx Frame */
+ GM_RXF_255B = GM_MIB_CNT_BASE + 112,/* 128-255 Byte Rx Frame */
+ GM_RXF_511B = GM_MIB_CNT_BASE + 120,/* 256-511 Byte Rx Frame */
+ GM_RXF_1023B = GM_MIB_CNT_BASE + 128,/* 512-1023 Byte Rx Frame */
+ GM_RXF_1518B = GM_MIB_CNT_BASE + 136,/* 1024-1518 Byte Rx Frame */
+ GM_RXF_MAX_SZ = GM_MIB_CNT_BASE + 144,/* 1519-MaxSize Byte Rx Frame */
+ GM_RXF_LNG_ERR = GM_MIB_CNT_BASE + 152,/* Rx Frame too Long Error */
+ GM_RXF_JAB_PKT = GM_MIB_CNT_BASE + 160,/* Rx Jabber Packet Frame */
+
+ GM_RXE_FIFO_OV = GM_MIB_CNT_BASE + 176,/* Rx FIFO overflow Event */
+ GM_TXF_UC_OK = GM_MIB_CNT_BASE + 192,/* Unicast Frames Xmitted OK */
+ GM_TXF_BC_OK = GM_MIB_CNT_BASE + 200,/* Broadcast Frames Xmitted OK */
+ GM_TXF_MPAUSE = GM_MIB_CNT_BASE + 208,/* Pause MAC Ctrl Frames Xmitted */
+ GM_TXF_MC_OK = GM_MIB_CNT_BASE + 216,/* Multicast Frames Xmitted OK */
+ GM_TXO_OK_LO = GM_MIB_CNT_BASE + 224,/* Octets Transmitted OK Low */
+ GM_TXO_OK_HI = GM_MIB_CNT_BASE + 232,/* Octets Transmitted OK High */
+ GM_TXF_64B = GM_MIB_CNT_BASE + 240,/* 64 Byte Tx Frame */
+ GM_TXF_127B = GM_MIB_CNT_BASE + 248,/* 65-127 Byte Tx Frame */
+ GM_TXF_255B = GM_MIB_CNT_BASE + 256,/* 128-255 Byte Tx Frame */
+ GM_TXF_511B = GM_MIB_CNT_BASE + 264,/* 256-511 Byte Tx Frame */
+ GM_TXF_1023B = GM_MIB_CNT_BASE + 272,/* 512-1023 Byte Tx Frame */
+ GM_TXF_1518B = GM_MIB_CNT_BASE + 280,/* 1024-1518 Byte Tx Frame */
+ GM_TXF_MAX_SZ = GM_MIB_CNT_BASE + 288,/* 1519-MaxSize Byte Tx Frame */
+
+ GM_TXF_COL = GM_MIB_CNT_BASE + 304,/* Tx Collision */
+ GM_TXF_LAT_COL = GM_MIB_CNT_BASE + 312,/* Tx Late Collision */
+ GM_TXF_ABO_COL = GM_MIB_CNT_BASE + 320,/* Tx aborted due to Exces. Col. */
+ GM_TXF_MUL_COL = GM_MIB_CNT_BASE + 328,/* Tx Multiple Collision */
+ GM_TXF_SNG_COL = GM_MIB_CNT_BASE + 336,/* Tx Single Collision */
+ GM_TXE_FIFO_UR = GM_MIB_CNT_BASE + 344,/* Tx FIFO Underrun Event */
};
/* GMAC Bit Definitions */
@@ -1805,7 +1804,7 @@ struct sky2_rx_le {
__le16 length;
u8 ctrl;
u8 opcode;
-} __attribute((packed));;
+} __attribute((packed));
struct sky2_status_le {
__le32 status; /* also checksum */
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c
index 01bdb233405..d4c0002b43d 100644
--- a/drivers/net/sun3lance.c
+++ b/drivers/net/sun3lance.c
@@ -71,7 +71,7 @@ static int lance_debug = LANCE_DEBUG;
#else
static int lance_debug = 1;
#endif
-MODULE_PARM(lance_debug, "i");
+module_param(lance_debug, int, 0);
MODULE_PARM_DESC(lance_debug, "SUN3 Lance debug level (0-3)");
MODULE_LICENSE("GPL");
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 88829eb9568..b5473325bff 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -69,8 +69,8 @@
#define DRV_MODULE_NAME "tg3"
#define PFX DRV_MODULE_NAME ": "
-#define DRV_MODULE_VERSION "3.53"
-#define DRV_MODULE_RELDATE "Mar 22, 2006"
+#define DRV_MODULE_VERSION "3.54"
+#define DRV_MODULE_RELDATE "Mar 23, 2006"
#define TG3_DEF_MAC_MODE 0
#define TG3_DEF_RX_MODE 0
@@ -225,6 +225,10 @@ static struct pci_device_id tg3_pci_tbl[] = {
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5754M,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
+ { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5755M,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
{ PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5787M,
@@ -4557,6 +4561,7 @@ static int tg3_chip_reset(struct tg3 *tp)
}
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
tw32(GRC_FASTBOOT_PC, 0);
@@ -6152,6 +6157,9 @@ static int tg3_reset_hw(struct tg3 *tp)
gpio_mask |= GRC_LCLCTRL_GPIO_OE3 |
GRC_LCLCTRL_GPIO_OUTPUT3;
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
+ gpio_mask |= GRC_LCLCTRL_GPIO_UART_SEL;
+
tp->grc_local_ctrl |= tr32(GRC_LOCAL_CTRL) & gpio_mask;
/* GPIO1 must be driven high for eeprom write protect */
@@ -6191,7 +6199,8 @@ static int tg3_reset_hw(struct tg3 *tp)
}
/* Enable host coalescing bug fix */
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
+ if ((GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755) ||
+ (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787))
val |= (1 << 29);
tw32_f(WDMAC_MODE, val);
@@ -6249,6 +6258,9 @@ static int tg3_reset_hw(struct tg3 *tp)
udelay(100);
tp->rx_mode = RX_MODE_ENABLE;
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
+ tp->rx_mode |= RX_MODE_IPV6_CSUM_ENABLE;
+
tw32_f(MAC_RX_MODE, tp->rx_mode);
udelay(10);
@@ -7907,7 +7919,8 @@ static int tg3_set_tx_csum(struct net_device *dev, u32 data)
return 0;
}
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
ethtool_op_set_tx_hw_csum(dev, data);
else
ethtool_op_set_tx_csum(dev, data);
@@ -8332,7 +8345,8 @@ static int tg3_test_memory(struct tg3 *tp)
int i;
if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) {
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
mem_tbl = mem_tbl_5755;
else
mem_tbl = mem_tbl_5705;
@@ -8924,6 +8938,47 @@ static void __devinit tg3_get_5752_nvram_info(struct tg3 *tp)
}
}
+static void __devinit tg3_get_5755_nvram_info(struct tg3 *tp)
+{
+ u32 nvcfg1;
+
+ nvcfg1 = tr32(NVRAM_CFG1);
+
+ /* NVRAM protection for TPM */
+ if (nvcfg1 & (1 << 27))
+ tp->tg3_flags2 |= TG3_FLG2_PROTECTED_NVRAM;
+
+ switch (nvcfg1 & NVRAM_CFG1_5752VENDOR_MASK) {
+ case FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ:
+ case FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ:
+ tp->nvram_jedecnum = JEDEC_ATMEL;
+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
+ tp->nvram_pagesize = ATMEL_AT24C512_CHIP_SIZE;
+
+ nvcfg1 &= ~NVRAM_CFG1_COMPAT_BYPASS;
+ tw32(NVRAM_CFG1, nvcfg1);
+ break;
+ case FLASH_5752VENDOR_ATMEL_FLASH_BUFFERED:
+ case FLASH_5755VENDOR_ATMEL_FLASH_1:
+ case FLASH_5755VENDOR_ATMEL_FLASH_2:
+ case FLASH_5755VENDOR_ATMEL_FLASH_3:
+ case FLASH_5755VENDOR_ATMEL_FLASH_4:
+ tp->nvram_jedecnum = JEDEC_ATMEL;
+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
+ tp->tg3_flags2 |= TG3_FLG2_FLASH;
+ tp->nvram_pagesize = 264;
+ break;
+ case FLASH_5752VENDOR_ST_M45PE10:
+ case FLASH_5752VENDOR_ST_M45PE20:
+ case FLASH_5752VENDOR_ST_M45PE40:
+ tp->nvram_jedecnum = JEDEC_ST;
+ tp->tg3_flags |= TG3_FLAG_NVRAM_BUFFERED;
+ tp->tg3_flags2 |= TG3_FLG2_FLASH;
+ tp->nvram_pagesize = 256;
+ break;
+ }
+}
+
static void __devinit tg3_get_5787_nvram_info(struct tg3 *tp)
{
u32 nvcfg1;
@@ -8997,6 +9052,8 @@ static void __devinit tg3_nvram_init(struct tg3 *tp)
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
tg3_get_5752_nvram_info(tp);
+ else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
+ tg3_get_5755_nvram_info(tp);
else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
tg3_get_5787_nvram_info(tp);
else
@@ -9310,6 +9367,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len,
nvram_cmd |= NVRAM_CMD_LAST;
if ((GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752) &&
+ (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) &&
(GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787) &&
(tp->nvram_jedecnum == JEDEC_ST) &&
(nvram_cmd & NVRAM_CMD_FIRST)) {
@@ -10044,6 +10102,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5750 ||
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787 ||
(tp->tg3_flags2 & TG3_FLG2_5780_CLASS))
tp->tg3_flags2 |= TG3_FLG2_5750_PLUS;
@@ -10053,7 +10112,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
tp->tg3_flags2 |= TG3_FLG2_5705_PLUS;
if (tp->tg3_flags2 & TG3_FLG2_5750_PLUS) {
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) {
tp->tg3_flags2 |= TG3_FLG2_HW_TSO_2;
tp->tg3_flags2 |= TG3_FLG2_1SHOT_MSI;
} else
@@ -10063,6 +10123,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
if (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5705 &&
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5750 &&
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5752 &&
+ GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755 &&
GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)
tp->tg3_flags2 |= TG3_FLG2_JUMBO_CAPABLE;
@@ -10219,6 +10280,9 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
else if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5752)
tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_OE3;
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755)
+ tp->grc_local_ctrl |= GRC_LCLCTRL_GPIO_UART_SEL;
+
/* Force the chip into D0. */
err = tg3_set_power_state(tp, PCI_D0);
if (err) {
@@ -10274,6 +10338,7 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG;
if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) &&
+ (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) &&
(GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787))
tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG;
@@ -10413,7 +10478,8 @@ static int __devinit tg3_get_invariants(struct tg3 *tp)
/* All chips before 5787 can get confused if TX buffers
* straddle the 4GB address boundary in some cases.
*/
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
tp->dev->hard_start_xmit = tg3_start_xmit;
else
tp->dev->hard_start_xmit = tg3_start_xmit_dma_bug;
@@ -11002,6 +11068,7 @@ static char * __devinit tg3_phy_string(struct tg3 *tp)
case PHY_ID_BCM5752: return "5752";
case PHY_ID_BCM5714: return "5714";
case PHY_ID_BCM5780: return "5780";
+ case PHY_ID_BCM5755: return "5755";
case PHY_ID_BCM5787: return "5787";
case PHY_ID_BCM8002: return "8002/serdes";
case 0: return "serdes";
@@ -11350,7 +11417,8 @@ static int __devinit tg3_init_one(struct pci_dev *pdev,
* checksumming.
*/
if ((tp->tg3_flags & TG3_FLAG_BROKEN_CHECKSUMS) == 0) {
- if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
+ if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 ||
+ GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787)
dev->features |= NETIF_F_HW_CSUM;
else
dev->features |= NETIF_F_IP_CSUM;
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h
index baa34c4721d..c43cc326420 100644
--- a/drivers/net/tg3.h
+++ b/drivers/net/tg3.h
@@ -138,6 +138,7 @@
#define ASIC_REV_5752 0x06
#define ASIC_REV_5780 0x08
#define ASIC_REV_5714 0x09
+#define ASIC_REV_5755 0x0a
#define ASIC_REV_5787 0x0b
#define GET_CHIP_REV(CHIP_REV_ID) ((CHIP_REV_ID) >> 8)
#define CHIPREV_5700_AX 0x70
@@ -456,6 +457,7 @@
#define RX_MODE_PROMISC 0x00000100
#define RX_MODE_NO_CRC_CHECK 0x00000200
#define RX_MODE_KEEP_VLAN_TAG 0x00000400
+#define RX_MODE_IPV6_CSUM_ENABLE 0x01000000
#define MAC_RX_STATUS 0x0000046c
#define RX_STATUS_REMOTE_TX_XOFFED 0x00000001
#define RX_STATUS_XOFF_RCVD 0x00000002
@@ -1340,6 +1342,7 @@
#define GRC_LCLCTRL_CLEARINT 0x00000002
#define GRC_LCLCTRL_SETINT 0x00000004
#define GRC_LCLCTRL_INT_ON_ATTN 0x00000008
+#define GRC_LCLCTRL_GPIO_UART_SEL 0x00000010 /* 5755 only */
#define GRC_LCLCTRL_USE_SIG_DETECT 0x00000010 /* 5714/5780 only */
#define GRC_LCLCTRL_USE_EXT_SIG_DETECT 0x00000020 /* 5714/5780 only */
#define GRC_LCLCTRL_GPIO_INPUT3 0x00000020
@@ -1441,6 +1444,9 @@
#define FLASH_5755VENDOR_ATMEL_FLASH_1 0x03400001
#define FLASH_5755VENDOR_ATMEL_FLASH_2 0x03400002
#define FLASH_5755VENDOR_ATMEL_FLASH_3 0x03400000
+#define FLASH_5755VENDOR_ATMEL_FLASH_4 0x00000003
+#define FLASH_5755VENDOR_ATMEL_EEPROM_64KHZ 0x03c00003
+#define FLASH_5755VENDOR_ATMEL_EEPROM_376KHZ 0x03c00002
#define FLASH_5787VENDOR_ATMEL_EEPROM_64KHZ 0x03000003
#define FLASH_5787VENDOR_ATMEL_EEPROM_376KHZ 0x03000002
#define FLASH_5787VENDOR_MICRO_EEPROM_64KHZ 0x03000000
@@ -2259,6 +2265,7 @@ struct tg3 {
#define PHY_ID_BCM5752 0x60008100
#define PHY_ID_BCM5714 0x60008340
#define PHY_ID_BCM5780 0x60008350
+#define PHY_ID_BCM5755 0xbc050cc0
#define PHY_ID_BCM5787 0xbc050ce0
#define PHY_ID_BCM8002 0x60010140
#define PHY_ID_INVALID 0xffffffff
@@ -2286,7 +2293,7 @@ struct tg3 {
(X) == PHY_ID_BCM5705 || (X) == PHY_ID_BCM5750 || \
(X) == PHY_ID_BCM5752 || (X) == PHY_ID_BCM5714 || \
(X) == PHY_ID_BCM5780 || (X) == PHY_ID_BCM5787 || \
- (X) == PHY_ID_BCM8002)
+ (X) == PHY_ID_BCM5755 || (X) == PHY_ID_BCM8002)
struct tg3_hw_stats *hw_stats;
dma_addr_t stats_mapping;
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 6299e186c73..e3dd144d326 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1327,11 +1327,11 @@ static void de_clean_rings (struct de_private *de)
struct sk_buff *skb = de->tx_skb[i].skb;
if ((skb) && (skb != DE_DUMMY_SKB)) {
if (skb != DE_SETUP_SKB) {
- dev_kfree_skb(skb);
de->net_stats.tx_dropped++;
pci_unmap_single(de->pdev,
de->tx_skb[i].mapping,
skb->len, PCI_DMA_TODEVICE);
+ dev_kfree_skb(skb);
} else {
pci_unmap_single(de->pdev,
de->tx_skb[i].mapping,
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index 5b0a19a5058..fd17aa8491b 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -25,6 +25,16 @@ config NET_RADIO
the tools from
<http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html>.
+config NET_WIRELESS_RTNETLINK
+ bool "Wireless Extension API over RtNetlink"
+ depends on NET_RADIO
+ ---help---
+ Support the Wireless Extension API over the RtNetlink socket
+ in addition to the traditional ioctl interface (selected above).
+
+ For now, few tools use this facility, but it might grow in the
+ future. The only downside is that it adds 4.5 kB to your kernel.
+
# Note : the cards are obsolete (can't buy them anymore), but the drivers
# are not, as people are still using them...
comment "Obsolete Wireless cards support (pre-802.11)"
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 864937a409e..108d9fed8f0 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -770,6 +770,11 @@ typedef struct {
} BSSListRid;
typedef struct {
+ BSSListRid bss;
+ struct list_head list;
+} BSSListElement;
+
+typedef struct {
u8 rssipct;
u8 rssidBm;
} tdsRssiEntry;
@@ -902,6 +907,7 @@ static char swversion[] = "2.1";
#define NUM_MODULES 2
#define MIC_MSGLEN_MAX 2400
#define EMMH32_MSGLEN_MAX MIC_MSGLEN_MAX
+#define AIRO_DEF_MTU 2312
typedef struct {
u32 size; // size
@@ -1119,6 +1125,8 @@ static int decapsulate(struct airo_info *ai, MICBuffer *mic, etherHead *pPacket,
static u8 airo_rssi_to_dbm (tdsRssiEntry *rssi_rid, u8 rssi);
static u8 airo_dbm_to_pct (tdsRssiEntry *rssi_rid, u8 dbm);
+static void airo_networks_free(struct airo_info *ai);
+
struct airo_info {
struct net_device_stats stats;
struct net_device *dev;
@@ -1150,7 +1158,7 @@ struct airo_info {
#define FLAG_COMMIT 13
#define FLAG_RESET 14
#define FLAG_FLASHING 15
-#define JOB_MASK 0x1ff0000
+#define JOB_MASK 0x2ff0000
#define JOB_DIE 16
#define JOB_XMIT 17
#define JOB_XMIT11 18
@@ -1160,6 +1168,7 @@ struct airo_info {
#define JOB_EVENT 22
#define JOB_AUTOWEP 23
#define JOB_WSTATS 24
+#define JOB_SCAN_RESULTS 25
int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen,
int whichbap);
unsigned short *flash;
@@ -1176,7 +1185,7 @@ struct airo_info {
} xmit, xmit11;
struct net_device *wifidev;
struct iw_statistics wstats; // wireless stats
- unsigned long scan_timestamp; /* Time started to scan */
+ unsigned long scan_timeout; /* Time scan should be read */
struct iw_spy_data spy_data;
struct iw_public_data wireless_data;
/* MIC stuff */
@@ -1198,6 +1207,10 @@ struct airo_info {
APListRid *APList;
#define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE
char proc_name[IFNAMSIZ];
+
+ struct list_head network_list;
+ struct list_head network_free_list;
+ BSSListElement *networks;
};
static inline int bap_read(struct airo_info *ai, u16 *pu16Dst, int bytelen,
@@ -1216,6 +1229,22 @@ static int flashgchar(struct airo_info *ai,int matchbyte,int dwelltime);
static int flashputbuf(struct airo_info *ai);
static int flashrestart(struct airo_info *ai,struct net_device *dev);
+#define airo_print(type, name, fmt, args...) \
+ { printk(type "airo(%s): " fmt "\n", name, ##args); }
+
+#define airo_print_info(name, fmt, args...) \
+ airo_print(KERN_INFO, name, fmt, ##args)
+
+#define airo_print_dbg(name, fmt, args...) \
+ airo_print(KERN_DEBUG, name, fmt, ##args)
+
+#define airo_print_warn(name, fmt, args...) \
+ airo_print(KERN_WARNING, name, fmt, ##args)
+
+#define airo_print_err(name, fmt, args...) \
+ airo_print(KERN_ERR, name, fmt, ##args)
+
+
/***********************************************************************
* MIC ROUTINES *
***********************************************************************
@@ -1294,7 +1323,7 @@ static int micsetup(struct airo_info *ai) {
ai->tfm = crypto_alloc_tfm("aes", CRYPTO_TFM_REQ_MAY_SLEEP);
if (ai->tfm == NULL) {
- printk(KERN_ERR "airo: failed to load transform for AES\n");
+ airo_print_err(ai->dev->name, "failed to load transform for AES");
return ERROR;
}
@@ -1726,11 +1755,11 @@ static int writeWepKeyRid(struct airo_info*ai, WepKeyRid *pwkr, int perm, int lo
wkr.kindex = cpu_to_le16(wkr.kindex);
wkr.klen = cpu_to_le16(wkr.klen);
rc = PC4500_writerid(ai, RID_WEP_TEMP, &wkr, sizeof(wkr), lock);
- if (rc!=SUCCESS) printk(KERN_ERR "airo: WEP_TEMP set %x\n", rc);
+ if (rc!=SUCCESS) airo_print_err(ai->dev->name, "WEP_TEMP set %x", rc);
if (perm) {
rc = PC4500_writerid(ai, RID_WEP_PERM, &wkr, sizeof(wkr), lock);
if (rc!=SUCCESS) {
- printk(KERN_ERR "airo: WEP_PERM set %x\n", rc);
+ airo_print_err(ai->dev->name, "WEP_PERM set %x", rc);
}
}
return rc;
@@ -1909,7 +1938,7 @@ static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) {
struct airo_info *ai = dev->priv;
if (!skb) {
- printk(KERN_ERR "airo: %s: skb==NULL\n",__FUNCTION__);
+ airo_print_err(dev->name, "%s: skb == NULL!",__FUNCTION__);
return 0;
}
npacks = skb_queue_len (&ai->txq);
@@ -1955,8 +1984,8 @@ static int mpi_send_packet (struct net_device *dev)
/* get a packet to send */
if ((skb = skb_dequeue(&ai->txq)) == 0) {
- printk (KERN_ERR
- "airo: %s: Dequeue'd zero in send_packet()\n",
+ airo_print_err(dev->name,
+ "%s: Dequeue'd zero in send_packet()",
__FUNCTION__);
return 0;
}
@@ -2108,7 +2137,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) {
u32 *fids = priv->fids;
if ( skb == NULL ) {
- printk( KERN_ERR "airo: skb == NULL!!!\n" );
+ airo_print_err(dev->name, "%s: skb == NULL!", __FUNCTION__);
return 0;
}
@@ -2179,7 +2208,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) {
}
if ( skb == NULL ) {
- printk( KERN_ERR "airo: skb == NULL!!!\n" );
+ airo_print_err(dev->name, "%s: skb == NULL!", __FUNCTION__);
return 0;
}
@@ -2364,6 +2393,8 @@ void stop_airo_card( struct net_device *dev, int freeres )
dev_kfree_skb(skb);
}
+ airo_networks_free (ai);
+
kfree(ai->flash);
kfree(ai->rssi);
kfree(ai->APList);
@@ -2434,7 +2465,7 @@ static int mpi_init_descriptors (struct airo_info *ai)
cmd.parm2 = MPI_MAX_FIDS;
rc=issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) {
- printk(KERN_ERR "airo: Couldn't allocate RX FID\n");
+ airo_print_err(ai->dev->name, "Couldn't allocate RX FID");
return rc;
}
@@ -2462,7 +2493,7 @@ static int mpi_init_descriptors (struct airo_info *ai)
rc=issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) {
- printk(KERN_ERR "airo: Couldn't allocate TX FID\n");
+ airo_print_err(ai->dev->name, "Couldn't allocate TX FID");
return rc;
}
@@ -2476,7 +2507,7 @@ static int mpi_init_descriptors (struct airo_info *ai)
cmd.parm2 = 1; /* Magic number... */
rc=issuecommand(ai, &cmd, &rsp);
if (rc != SUCCESS) {
- printk(KERN_ERR "airo: Couldn't allocate RID\n");
+ airo_print_err(ai->dev->name, "Couldn't allocate RID");
return rc;
}
@@ -2508,25 +2539,25 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
aux_len = AUXMEMSIZE;
if (!request_mem_region(mem_start, mem_len, name)) {
- printk(KERN_ERR "airo: Couldn't get region %x[%x] for %s\n",
+ airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s",
(int)mem_start, (int)mem_len, name);
goto out;
}
if (!request_mem_region(aux_start, aux_len, name)) {
- printk(KERN_ERR "airo: Couldn't get region %x[%x] for %s\n",
+ airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s",
(int)aux_start, (int)aux_len, name);
goto free_region1;
}
ai->pcimem = ioremap(mem_start, mem_len);
if (!ai->pcimem) {
- printk(KERN_ERR "airo: Couldn't map region %x[%x] for %s\n",
+ airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s",
(int)mem_start, (int)mem_len, name);
goto free_region2;
}
ai->pciaux = ioremap(aux_start, aux_len);
if (!ai->pciaux) {
- printk(KERN_ERR "airo: Couldn't map region %x[%x] for %s\n",
+ airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s",
(int)aux_start, (int)aux_len, name);
goto free_memmap;
}
@@ -2534,7 +2565,7 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci,
/* Reserve PKTSIZE for each fid and 2K for the Rids */
ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma);
if (!ai->shared) {
- printk(KERN_ERR "airo: Couldn't alloc_consistent %d\n",
+ airo_print_err(ai->dev->name, "Couldn't alloc_consistent %d",
PCI_SHARED_LEN);
goto free_auxmap;
}
@@ -2626,7 +2657,7 @@ static void wifi_setup(struct net_device *dev)
dev->type = ARPHRD_IEEE80211;
dev->hard_header_len = ETH_HLEN;
- dev->mtu = 2312;
+ dev->mtu = AIRO_DEF_MTU;
dev->addr_len = ETH_ALEN;
dev->tx_queue_len = 100;
@@ -2670,6 +2701,42 @@ static int reset_card( struct net_device *dev , int lock) {
return 0;
}
+#define MAX_NETWORK_COUNT 64
+static int airo_networks_allocate(struct airo_info *ai)
+{
+ if (ai->networks)
+ return 0;
+
+ ai->networks =
+ kzalloc(MAX_NETWORK_COUNT * sizeof(BSSListElement),
+ GFP_KERNEL);
+ if (!ai->networks) {
+ airo_print_warn(ai->dev->name, "Out of memory allocating beacons");
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void airo_networks_free(struct airo_info *ai)
+{
+ if (!ai->networks)
+ return;
+ kfree(ai->networks);
+ ai->networks = NULL;
+}
+
+static void airo_networks_initialize(struct airo_info *ai)
+{
+ int i;
+
+ INIT_LIST_HEAD(&ai->network_free_list);
+ INIT_LIST_HEAD(&ai->network_list);
+ for (i = 0; i < MAX_NETWORK_COUNT; i++)
+ list_add_tail(&ai->networks[i].list,
+ &ai->network_free_list);
+}
+
static struct net_device *_init_airo_card( unsigned short irq, int port,
int is_pcmcia, struct pci_dev *pci,
struct device *dmdev )
@@ -2681,22 +2748,22 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
/* Create the network device object. */
dev = alloc_etherdev(sizeof(*ai));
if (!dev) {
- printk(KERN_ERR "airo: Couldn't alloc_etherdev\n");
+ airo_print_err("", "Couldn't alloc_etherdev");
return NULL;
}
if (dev_alloc_name(dev, dev->name) < 0) {
- printk(KERN_ERR "airo: Couldn't get name!\n");
+ airo_print_err("", "Couldn't get name!");
goto err_out_free;
}
ai = dev->priv;
ai->wifidev = NULL;
ai->flags = 0;
+ ai->dev = dev;
if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) {
- printk(KERN_DEBUG "airo: Found an MPI350 card\n");
+ airo_print_dbg(dev->name, "Found an MPI350 card");
set_bit(FLAG_MPI, &ai->flags);
}
- ai->dev = dev;
spin_lock_init(&ai->aux_lock);
sema_init(&ai->sem, 1);
ai->config.len = 0;
@@ -2711,6 +2778,10 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
if (rc)
goto err_out_thr;
+ if (airo_networks_allocate (ai))
+ goto err_out_unlink;
+ airo_networks_initialize (ai);
+
/* The Airo-specific entries in the device structure. */
if (test_bit(FLAG_MPI,&ai->flags)) {
skb_queue_head_init (&ai->txq);
@@ -2732,33 +2803,33 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
SET_NETDEV_DEV(dev, dmdev);
-
reset_card (dev, 1);
msleep(400);
rc = request_irq( dev->irq, airo_interrupt, SA_SHIRQ, dev->name, dev );
if (rc) {
- printk(KERN_ERR "airo: register interrupt %d failed, rc %d\n", irq, rc );
+ airo_print_err(dev->name, "register interrupt %d failed, rc %d",
+ irq, rc);
goto err_out_unlink;
}
if (!is_pcmcia) {
if (!request_region( dev->base_addr, 64, dev->name )) {
rc = -EBUSY;
- printk(KERN_ERR "airo: Couldn't request region\n");
+ airo_print_err(dev->name, "Couldn't request region");
goto err_out_irq;
}
}
if (test_bit(FLAG_MPI,&ai->flags)) {
if (mpi_map_card(ai, pci, dev->name)) {
- printk(KERN_ERR "airo: Could not map memory\n");
+ airo_print_err(dev->name, "Could not map memory");
goto err_out_res;
}
}
if (probe) {
if ( setup_card( ai, dev->dev_addr, 1 ) != SUCCESS ) {
- printk( KERN_ERR "airo: MAC could not be enabled\n" );
+ airo_print_err(dev->name, "MAC could not be enabled" );
rc = -EIO;
goto err_out_map;
}
@@ -2769,21 +2840,20 @@ static struct net_device *_init_airo_card( unsigned short irq, int port,
rc = register_netdev(dev);
if (rc) {
- printk(KERN_ERR "airo: Couldn't register_netdev\n");
+ airo_print_err(dev->name, "Couldn't register_netdev");
goto err_out_map;
}
ai->wifidev = init_wifidev(ai, dev);
set_bit(FLAG_REGISTERED,&ai->flags);
- printk( KERN_INFO "airo: MAC enabled %s %x:%x:%x:%x:%x:%x\n",
- dev->name,
+ airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5] );
/* Allocate the transmit buffers */
if (probe && !test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ )
- ai->fids[i] = transmit_allocate(ai,2312,i>=MAX_FIDS/2);
+ ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
setup_proc_entry( dev, dev->priv ); /* XXX check for failure */
netif_start_queue(dev);
@@ -2840,16 +2910,16 @@ int reset_airo_card( struct net_device *dev )
return -1;
if ( setup_card(ai, dev->dev_addr, 1 ) != SUCCESS ) {
- printk( KERN_ERR "airo: MAC could not be enabled\n" );
+ airo_print_err(dev->name, "MAC could not be enabled");
return -1;
}
- printk( KERN_INFO "airo: MAC enabled %s %x:%x:%x:%x:%x:%x\n", dev->name,
+ airo_print_info(dev->name, "MAC enabled %x:%x:%x:%x:%x:%x",
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
/* Allocate the transmit buffers if needed */
if (!test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ )
- ai->fids[i] = transmit_allocate (ai,2312,i>=MAX_FIDS/2);
+ ai->fids[i] = transmit_allocate (ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);
enable_interrupts( ai );
netif_wake_queue(dev);
@@ -2875,6 +2945,65 @@ static void airo_send_event(struct net_device *dev) {
wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL);
}
+static void airo_process_scan_results (struct airo_info *ai) {
+ union iwreq_data wrqu;
+ BSSListRid BSSList;
+ int rc;
+ BSSListElement * loop_net;
+ BSSListElement * tmp_net;
+
+ /* Blow away current list of scan results */
+ list_for_each_entry_safe (loop_net, tmp_net, &ai->network_list, list) {
+ list_move_tail (&loop_net->list, &ai->network_free_list);
+ /* Don't blow away ->list, just BSS data */
+ memset (loop_net, 0, sizeof (loop_net->bss));
+ }
+
+ /* Try to read the first entry of the scan result */
+ rc = PC4500_readrid(ai, RID_BSSLISTFIRST, &BSSList, sizeof(BSSList), 0);
+ if((rc) || (BSSList.index == 0xffff)) {
+ /* No scan results */
+ goto out;
+ }
+
+ /* Read and parse all entries */
+ tmp_net = NULL;
+ while((!rc) && (BSSList.index != 0xffff)) {
+ /* Grab a network off the free list */
+ if (!list_empty(&ai->network_free_list)) {
+ tmp_net = list_entry(ai->network_free_list.next,
+ BSSListElement, list);
+ list_del(ai->network_free_list.next);
+ }
+
+ if (tmp_net != NULL) {
+ memcpy(tmp_net, &BSSList, sizeof(tmp_net->bss));
+ list_add_tail(&tmp_net->list, &ai->network_list);
+ tmp_net = NULL;
+ }
+
+ /* Read next entry */
+ rc = PC4500_readrid(ai, RID_BSSLISTNEXT,
+ &BSSList, sizeof(BSSList), 0);
+ }
+
+out:
+ ai->scan_timeout = 0;
+ clear_bit(JOB_SCAN_RESULTS, &ai->flags);
+ up(&ai->sem);
+
+ /* Send an empty event to user space.
+ * We don't send the received data on
+ * the event because it would require
+ * us to do complex transcoding, and
+ * we want to minimise the work done in
+ * the irq handler. Use a request to
+ * extract the data - Jean II */
+ wrqu.data.length = 0;
+ wrqu.data.flags = 0;
+ wireless_send_event(ai->dev, SIOCGIWSCAN, &wrqu, NULL);
+}
+
static int airo_thread(void *data) {
struct net_device *dev = data;
struct airo_info *ai = dev->priv;
@@ -2904,13 +3033,26 @@ static int airo_thread(void *data) {
set_current_state(TASK_INTERRUPTIBLE);
if (ai->flags & JOB_MASK)
break;
- if (ai->expires) {
- if (time_after_eq(jiffies,ai->expires)){
+ if (ai->expires || ai->scan_timeout) {
+ if (ai->scan_timeout &&
+ time_after_eq(jiffies,ai->scan_timeout)){
+ set_bit(JOB_SCAN_RESULTS,&ai->flags);
+ break;
+ } else if (ai->expires &&
+ time_after_eq(jiffies,ai->expires)){
set_bit(JOB_AUTOWEP,&ai->flags);
break;
}
if (!signal_pending(current)) {
- schedule_timeout(ai->expires - jiffies);
+ unsigned long wake_at;
+ if (!ai->expires || !ai->scan_timeout) {
+ wake_at = max(ai->expires,
+ ai->scan_timeout);
+ } else {
+ wake_at = min(ai->expires,
+ ai->scan_timeout);
+ }
+ schedule_timeout(wake_at - jiffies);
continue;
}
} else if (!signal_pending(current)) {
@@ -2953,6 +3095,10 @@ static int airo_thread(void *data) {
airo_send_event(dev);
else if (test_bit(JOB_AUTOWEP, &ai->flags))
timer_func(dev);
+ else if (test_bit(JOB_SCAN_RESULTS, &ai->flags))
+ airo_process_scan_results(ai);
+ else /* Shouldn't get here, but we make sure to unlock */
+ up(&ai->sem);
}
complete_and_exit (&ai->thr_exited, 0);
}
@@ -3047,19 +3193,15 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
* and reassociations as valid status
* Jean II */
if(newStatus == ASSOCIATED) {
- if (apriv->scan_timestamp) {
- /* Send an empty event to user space.
- * We don't send the received data on
- * the event because it would require
- * us to do complex transcoding, and
- * we want to minimise the work done in
- * the irq handler. Use a request to
- * extract the data - Jean II */
- wrqu.data.length = 0;
- wrqu.data.flags = 0;
- wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
- apriv->scan_timestamp = 0;
+#if 0
+ /* FIXME: Grabbing scan results here
+ * seems to be too early??? Just wait for
+ * timeout instead. */
+ if (apriv->scan_timeout > 0) {
+ set_bit(JOB_SCAN_RESULTS, &apriv->flags);
+ wake_up_interruptible(&apriv->thr_wait);
}
+#endif
if (down_trylock(&apriv->sem) != 0) {
set_bit(JOB_EVENT, &apriv->flags);
wake_up_interruptible(&apriv->thr_wait);
@@ -3117,8 +3259,8 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
}
len = le16_to_cpu(hdr.len);
- if (len > 2312) {
- printk( KERN_ERR "airo: Bad size %d\n", len );
+ if (len > AIRO_DEF_MTU) {
+ airo_print_err(apriv->dev->name, "Bad size %d", len);
goto badrx;
}
if (len == 0)
@@ -3161,10 +3303,12 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs)
bap_read (apriv, &gap, sizeof(gap), BAP0);
gap = le16_to_cpu(gap);
if (gap) {
- if (gap <= 8)
+ if (gap <= 8) {
bap_read (apriv, tmpbuf, gap, BAP0);
- else
- printk(KERN_ERR "airo: gaplen too big. Problems will follow...\n");
+ } else {
+ airo_print_err(apriv->dev->name, "gaplen too "
+ "big. Problems will follow...");
+ }
}
bap_read (apriv, buffer + hdrlen/2, len, BAP0);
} else {
@@ -3281,12 +3425,13 @@ exitrx:
}
} else {
OUT4500( apriv, EVACK, status & (EV_TX | EV_TXCPY | EV_TXEXC));
- printk( KERN_ERR "airo: Unallocated FID was used to xmit\n" );
+ airo_print_err(apriv->dev->name, "Unallocated FID was "
+ "used to xmit" );
}
}
exittx:
if ( status & ~STATUS_INTS & ~IGNORE_INTS )
- printk( KERN_WARNING "airo: Got weird status %x\n",
+ airo_print_warn(apriv->dev->name, "Got weird status %x",
status & ~STATUS_INTS & ~IGNORE_INTS );
}
@@ -3359,8 +3504,8 @@ static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) {
up(&ai->sem);
if (rc)
- printk(KERN_ERR "%s: Cannot enable MAC, err=%d\n",
- __FUNCTION__,rc);
+ airo_print_err(ai->dev->name, "%s: Cannot enable MAC, err=%d",
+ __FUNCTION__, rc);
return rc;
}
@@ -3489,8 +3634,8 @@ void mpi_receive_802_11 (struct airo_info *ai)
if (ai->wifidev == NULL)
hdr.len = 0;
len = le16_to_cpu(hdr.len);
- if (len > 2312) {
- printk( KERN_ERR "airo: Bad size %d\n", len );
+ if (len > AIRO_DEF_MTU) {
+ airo_print_err(ai->dev->name, "Bad size %d", len);
goto badrx;
}
if (len == 0)
@@ -3531,8 +3676,8 @@ void mpi_receive_802_11 (struct airo_info *ai)
if (gap <= 8)
ptr += gap;
else
- printk(KERN_ERR
- "airo: gaplen too big. Problems will follow...\n");
+ airo_print_err(ai->dev->name,
+ "gaplen too big. Problems will follow...");
}
memcpy ((char *)buffer + hdrlen, ptr, len);
ptr += len;
@@ -3604,15 +3749,15 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
if (issuecommand(ai, &cmd, &rsp) != SUCCESS) {
if (lock)
up(&ai->sem);
- printk(KERN_ERR "airo: Error checking for AUX port\n");
+ airo_print_err(ai->dev->name, "Error checking for AUX port");
return ERROR;
}
if (!aux_bap || rsp.status & 0xff00) {
ai->bap_read = fast_bap_read;
- printk(KERN_DEBUG "airo: Doing fast bap_reads\n");
+ airo_print_dbg(ai->dev->name, "Doing fast bap_reads");
} else {
ai->bap_read = aux_bap_read;
- printk(KERN_DEBUG "airo: Doing AUX bap_reads\n");
+ airo_print_dbg(ai->dev->name, "Doing AUX bap_reads");
}
}
if (lock)
@@ -3643,7 +3788,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
if (cap_rid.softCap & 8)
ai->config.rmode |= RXMODE_NORMALIZED_RSSI;
else
- printk(KERN_WARNING "airo: unknown received signal level scale\n");
+ airo_print_warn(ai->dev->name, "unknown received signal "
+ "level scale");
}
ai->config.opmode = adhoc ? MODE_STA_IBSS : MODE_STA_ESS;
ai->config.authType = AUTH_OPEN;
@@ -3706,7 +3852,8 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock)
status = enable_MAC(ai, &rsp, lock);
if ( status != SUCCESS || (rsp.status & 0xFF00) != 0) {
- printk( KERN_ERR "airo: Bad MAC enable reason = %x, rid = %x, offset = %d\n", rsp.rsp0, rsp.rsp1, rsp.rsp2 );
+ airo_print_err(ai->dev->name, "Bad MAC enable reason = %x, rid = %x,"
+ " offset = %d", rsp.rsp0, rsp.rsp1, rsp.rsp2 );
return ERROR;
}
@@ -3749,8 +3896,8 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
}
if ( max_tries == -1 ) {
- printk( KERN_ERR
- "airo: Max tries exceeded when issueing command\n" );
+ airo_print_err(ai->dev->name,
+ "Max tries exceeded when issueing command");
if (IN4500(ai, COMMAND) & COMMAND_BUSY)
OUT4500(ai, EVACK, EV_CLEARCOMMANDBUSY);
return ERROR;
@@ -3762,11 +3909,11 @@ static u16 issuecommand(struct airo_info *ai, Cmd *pCmd, Resp *pRsp) {
pRsp->rsp1 = IN4500(ai, RESP1);
pRsp->rsp2 = IN4500(ai, RESP2);
if ((pRsp->status & 0xff00)!=0 && pCmd->cmd != CMD_SOFTRESET) {
- printk (KERN_ERR "airo: cmd= %x\n", pCmd->cmd);
- printk (KERN_ERR "airo: status= %x\n", pRsp->status);
- printk (KERN_ERR "airo: Rsp0= %x\n", pRsp->rsp0);
- printk (KERN_ERR "airo: Rsp1= %x\n", pRsp->rsp1);
- printk (KERN_ERR "airo: Rsp2= %x\n", pRsp->rsp2);
+ airo_print_err(ai->dev->name, "cmd= %x\n", pCmd->cmd);
+ airo_print_err(ai->dev->name, "status= %x\n", pRsp->status);
+ airo_print_err(ai->dev->name, "Rsp0= %x\n", pRsp->rsp0);
+ airo_print_err(ai->dev->name, "Rsp1= %x\n", pRsp->rsp1);
+ airo_print_err(ai->dev->name, "Rsp2= %x\n", pRsp->rsp2);
}
// clear stuck command busy if necessary
@@ -3799,15 +3946,15 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap )
}
} else if ( status & BAP_ERR ) {
/* invalid rid or offset */
- printk( KERN_ERR "airo: BAP error %x %d\n",
+ airo_print_err(ai->dev->name, "BAP error %x %d",
status, whichbap );
return ERROR;
} else if (status & BAP_DONE) { // success
return SUCCESS;
}
if ( !(max_tries--) ) {
- printk( KERN_ERR
- "airo: BAP setup error too many retries\n" );
+ airo_print_err(ai->dev->name,
+ "airo: BAP setup error too many retries\n");
return ERROR;
}
// -- PC4500 missed it, try again
@@ -3962,8 +4109,8 @@ static int PC4500_readrid(struct airo_info *ai, u16 rid, void *pBuf, int len, in
len = min(len, (int)le16_to_cpu(*(u16*)pBuf)) - 2;
if ( len <= 2 ) {
- printk( KERN_ERR
- "airo: Rid %x has a length of %d which is too short\n",
+ airo_print_err(ai->dev->name,
+ "Rid %x has a length of %d which is too short",
(int)rid, (int)len );
rc = ERROR;
goto done;
@@ -3996,8 +4143,8 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
Resp rsp;
if (test_bit(FLAG_ENABLED, &ai->flags) && (RID_WEP_TEMP != rid))
- printk(KERN_ERR
- "%s: MAC should be disabled (rid=%04x)\n",
+ airo_print_err(ai->dev->name,
+ "%s: MAC should be disabled (rid=%04x)",
__FUNCTION__, rid);
memset(&cmd, 0, sizeof(cmd));
memset(&rsp, 0, sizeof(rsp));
@@ -4013,7 +4160,7 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
&ai->config_desc.rid_desc, sizeof(Rid));
if (len < 4 || len > 2047) {
- printk(KERN_ERR "%s: len=%d\n",__FUNCTION__,len);
+ airo_print_err(ai->dev->name, "%s: len=%d", __FUNCTION__, len);
rc = -1;
} else {
memcpy((char *)ai->config_desc.virtual_host_addr,
@@ -4021,10 +4168,10 @@ static int PC4500_writerid(struct airo_info *ai, u16 rid,
rc = issuecommand(ai, &cmd, &rsp);
if ((rc & 0xff00) != 0) {
- printk(KERN_ERR "%s: Write rid Error %d\n",
- __FUNCTION__,rc);
- printk(KERN_ERR "%s: Cmd=%04x\n",
- __FUNCTION__,cmd.cmd);
+ airo_print_err(ai->dev->name, "%s: Write rid Error %d",
+ __FUNCTION__, rc);
+ airo_print_err(ai->dev->name, "%s: Cmd=%04x",
+ __FUNCTION__, cmd.cmd);
}
if ((rsp.status & 0x7f00))
@@ -4123,7 +4270,7 @@ static int transmit_802_3_packet(struct airo_info *ai, int len, char *pPacket)
len >>= 16;
if (len <= ETH_ALEN * 2) {
- printk( KERN_WARNING "Short packet %d\n", len );
+ airo_print_warn(ai->dev->name, "Short packet %d", len);
return ERROR;
}
len -= ETH_ALEN * 2;
@@ -4187,7 +4334,7 @@ static int transmit_802_11_packet(struct airo_info *ai, int len, char *pPacket)
}
if (len < hdrlen) {
- printk( KERN_WARNING "Short packet %d\n", len );
+ airo_print_warn(ai->dev->name, "Short packet %d", len);
return ERROR;
}
@@ -4584,15 +4731,14 @@ static int proc_stats_rid_open( struct inode *inode,
i*4<stats.len; i++){
if (!statsLabels[i]) continue;
if (j+strlen(statsLabels[i])+16>4096) {
- printk(KERN_WARNING
- "airo: Potentially disasterous buffer overflow averted!\n");
+ airo_print_warn(apriv->dev->name,
+ "Potentially disasterous buffer overflow averted!");
break;
}
j+=sprintf(data->rbuffer+j, "%s: %u\n", statsLabels[i], vals[i]);
}
if (i*4>=stats.len){
- printk(KERN_WARNING
- "airo: Got a short rid\n");
+ airo_print_warn(apriv->dev->name, "Got a short rid");
}
data->readlen = j;
return 0;
@@ -4754,7 +4900,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
line += 14;
v = get_dec_u16(line, &i, 4);
- v = (v<0) ? 0 : ((v>2312) ? 2312 : v);
+ v = (v<0) ? 0 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
ai->config.rtsThres = (u16)v;
set_bit (FLAG_COMMIT, &ai->flags);
} else if ( !strncmp( line, "TXMSDULifetime: ", 16 ) ) {
@@ -4788,7 +4934,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
line += 15;
v = get_dec_u16(line, &i, 4);
- v = (v<256) ? 256 : ((v>2312) ? 2312 : v);
+ v = (v<256) ? 256 : ((v>AIRO_DEF_MTU) ? AIRO_DEF_MTU : v);
v = v & 0xfffe; /* Make sure its even */
ai->config.fragThresh = (u16)v;
set_bit (FLAG_COMMIT, &ai->flags);
@@ -4798,8 +4944,7 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
case 'd': ai->config.modulation=MOD_DEFAULT; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'c': ai->config.modulation=MOD_CCK; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'm': ai->config.modulation=MOD_MOK; set_bit(FLAG_COMMIT, &ai->flags); break;
- default:
- printk( KERN_WARNING "airo: Unknown modulation\n" );
+ default: airo_print_warn(ai->dev->name, "Unknown modulation");
}
} else if (!strncmp(line, "Preamble: ", 10)) {
line += 10;
@@ -4807,10 +4952,10 @@ static void proc_config_on_close( struct inode *inode, struct file *file ) {
case 'a': ai->config.preamble=PREAMBLE_AUTO; set_bit(FLAG_COMMIT, &ai->flags); break;
case 'l': ai->config.preamble=PREAMBLE_LONG; set_bit(FLAG_COMMIT, &ai->flags); break;
case 's': ai->config.preamble=PREAMBLE_SHORT; set_bit(FLAG_COMMIT, &ai->flags); break;
- default: printk(KERN_WARNING "airo: Unknown preamble\n");
+ default: airo_print_warn(ai->dev->name, "Unknown preamble");
}
} else {
- printk( KERN_WARNING "Couldn't figure out %s\n", line );
+ airo_print_warn(ai->dev->name, "Couldn't figure out %s", line);
}
while( line[0] && line[0] != '\n' ) line++;
if ( line[0] ) line++;
@@ -5076,7 +5221,7 @@ static void proc_wepkey_on_close( struct inode *inode, struct file *file ) {
}
j = 2;
} else {
- printk(KERN_ERR "airo: WepKey passed invalid key index\n");
+ airo_print_err(ai->dev->name, "WepKey passed invalid key index");
return;
}
@@ -5489,17 +5634,16 @@ static int __init airo_init_module( void )
airo_entry->gid = proc_gid;
for( i = 0; i < 4 && io[i] && irq[i]; i++ ) {
- printk( KERN_INFO
- "airo: Trying to configure ISA adapter at irq=%d io=0x%x\n",
- irq[i], io[i] );
+ airo_print_info("", "Trying to configure ISA adapter at irq=%d "
+ "io=0x%x", irq[i], io[i] );
if (init_airo_card( irq[i], io[i], 0, NULL ))
have_isa_dev = 1;
}
#ifdef CONFIG_PCI
- printk( KERN_INFO "airo: Probing for PCI adapters\n" );
+ airo_print_info("", "Probing for PCI adapters");
pci_register_driver(&airo_driver);
- printk( KERN_INFO "airo: Finished probing for PCI adapters\n" );
+ airo_print_info("", "Finished probing for PCI adapters");
#endif
/* Always exit with success, as we are a library module
@@ -5511,7 +5655,7 @@ static int __init airo_init_module( void )
static void __exit airo_cleanup_module( void )
{
while( airo_devices ) {
- printk( KERN_INFO "airo: Unregistering %s\n", airo_devices->dev->name );
+ airo_print_info(airo_devices->dev->name, "Unregistering...\n");
stop_airo_card( airo_devices->dev, 1 );
}
#ifdef CONFIG_PCI
@@ -5622,7 +5766,8 @@ static int airo_set_freq(struct net_device *dev,
/* We should do a better check than that,
* based on the card capability !!! */
if((channel < 1) || (channel > 14)) {
- printk(KERN_DEBUG "%s: New channel value of %d is invalid!\n", dev->name, fwrq->m);
+ airo_print_dbg(dev->name, "New channel value of %d is invalid!",
+ fwrq->m);
rc = -EINVAL;
} else {
readConfigRid(local, 1);
@@ -5946,8 +6091,8 @@ static int airo_set_rts(struct net_device *dev,
int rthr = vwrq->value;
if(vwrq->disabled)
- rthr = 2312;
- if((rthr < 0) || (rthr > 2312)) {
+ rthr = AIRO_DEF_MTU;
+ if((rthr < 0) || (rthr > AIRO_DEF_MTU)) {
return -EINVAL;
}
readConfigRid(local, 1);
@@ -5970,7 +6115,7 @@ static int airo_get_rts(struct net_device *dev,
readConfigRid(local, 1);
vwrq->value = local->config.rtsThres;
- vwrq->disabled = (vwrq->value >= 2312);
+ vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU);
vwrq->fixed = 1;
return 0;
@@ -5989,8 +6134,8 @@ static int airo_set_frag(struct net_device *dev,
int fthr = vwrq->value;
if(vwrq->disabled)
- fthr = 2312;
- if((fthr < 256) || (fthr > 2312)) {
+ fthr = AIRO_DEF_MTU;
+ if((fthr < 256) || (fthr > AIRO_DEF_MTU)) {
return -EINVAL;
}
fthr &= ~0x1; /* Get an even value - is it really needed ??? */
@@ -6014,7 +6159,7 @@ static int airo_get_frag(struct net_device *dev,
readConfigRid(local, 1);
vwrq->value = local->config.fragThresh;
- vwrq->disabled = (vwrq->value >= 2312);
+ vwrq->disabled = (vwrq->value >= AIRO_DEF_MTU);
vwrq->fixed = 1;
return 0;
@@ -6709,9 +6854,9 @@ static int airo_get_range(struct net_device *dev,
range->throughput = 1500 * 1000;
range->min_rts = 0;
- range->max_rts = 2312;
+ range->max_rts = AIRO_DEF_MTU;
range->min_frag = 256;
- range->max_frag = 2312;
+ range->max_frag = AIRO_DEF_MTU;
if(cap_rid.softCap & 2) {
// WEP: RC4 40 bits
@@ -6972,6 +7117,7 @@ static int airo_set_scan(struct net_device *dev,
struct airo_info *ai = dev->priv;
Cmd cmd;
Resp rsp;
+ int wake = 0;
/* Note : you may have realised that, as this is a SET operation,
* this is privileged and therefore a normal user can't
@@ -6981,17 +7127,25 @@ static int airo_set_scan(struct net_device *dev,
* Jean II */
if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN;
+ if (down_interruptible(&ai->sem))
+ return -ERESTARTSYS;
+
+ /* If there's already a scan in progress, don't
+ * trigger another one. */
+ if (ai->scan_timeout > 0)
+ goto out;
+
/* Initiate a scan command */
memset(&cmd, 0, sizeof(cmd));
cmd.cmd=CMD_LISTBSS;
- if (down_interruptible(&ai->sem))
- return -ERESTARTSYS;
issuecommand(ai, &cmd, &rsp);
- ai->scan_timestamp = jiffies;
- up(&ai->sem);
-
- /* At this point, just return to the user. */
+ ai->scan_timeout = RUN_AT(3*HZ);
+ wake = 1;
+out:
+ up(&ai->sem);
+ if (wake)
+ wake_up_interruptible(&ai->thr_wait);
return 0;
}
@@ -7111,59 +7265,38 @@ static int airo_get_scan(struct net_device *dev,
char *extra)
{
struct airo_info *ai = dev->priv;
- BSSListRid BSSList;
- int rc;
+ BSSListElement *net;
+ int err = 0;
char *current_ev = extra;
- /* When we are associated again, the scan has surely finished.
- * Just in case, let's make sure enough time has elapsed since
- * we started the scan. - Javier */
- if(ai->scan_timestamp && time_before(jiffies,ai->scan_timestamp+3*HZ)) {
- /* Important note : we don't want to block the caller
- * until results are ready for various reasons.
- * First, managing wait queues is complex and racy
- * (there may be multiple simultaneous callers).
- * Second, we grab some rtnetlink lock before comming
- * here (in dev_ioctl()).
- * Third, the caller can wait on the Wireless Event
- * - Jean II */
+ /* If a scan is in-progress, return -EAGAIN */
+ if (ai->scan_timeout > 0)
return -EAGAIN;
- }
- ai->scan_timestamp = 0;
- /* There's only a race with proc_BSSList_open(), but its
- * consequences are begnign. So I don't bother fixing it - Javier */
-
- /* Try to read the first entry of the scan result */
- rc = PC4500_readrid(ai, RID_BSSLISTFIRST, &BSSList, sizeof(BSSList), 1);
- if((rc) || (BSSList.index == 0xffff)) {
- /* Client error, no scan results...
- * The caller need to restart the scan. */
- return -ENODATA;
- }
+ if (down_interruptible(&ai->sem))
+ return -EAGAIN;
- /* Read and parse all entries */
- while((!rc) && (BSSList.index != 0xffff)) {
+ list_for_each_entry (net, &ai->network_list, list) {
/* Translate to WE format this entry */
current_ev = airo_translate_scan(dev, current_ev,
extra + dwrq->length,
- &BSSList);
+ &net->bss);
/* Check if there is space for one more entry */
if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
/* Ask user space to try again with a bigger buffer */
- return -E2BIG;
+ err = -E2BIG;
+ goto out;
}
-
- /* Read next entry */
- rc = PC4500_readrid(ai, RID_BSSLISTNEXT,
- &BSSList, sizeof(BSSList), 1);
}
+
/* Length of data */
dwrq->length = (current_ev - extra);
dwrq->flags = 0; /* todo */
- return 0;
+out:
+ up(&ai->sem);
+ return err;
}
/*------------------------------------------------------------------*/
@@ -7711,7 +7844,7 @@ static int cmdreset(struct airo_info *ai) {
disable_MAC(ai, 1);
if(!waitbusy (ai)){
- printk(KERN_INFO "Waitbusy hang before RESET\n");
+ airo_print_info(ai->dev->name, "Waitbusy hang before RESET");
return -EBUSY;
}
@@ -7720,7 +7853,7 @@ static int cmdreset(struct airo_info *ai) {
ssleep(1); /* WAS 600 12/7/00 */
if(!waitbusy (ai)){
- printk(KERN_INFO "Waitbusy hang AFTER RESET\n");
+ airo_print_info(ai->dev->name, "Waitbusy hang AFTER RESET");
return -EBUSY;
}
return 0;
@@ -7748,7 +7881,7 @@ static int setflashmode (struct airo_info *ai) {
if(!waitbusy(ai)) {
clear_bit (FLAG_FLASHING, &ai->flags);
- printk(KERN_INFO "Waitbusy hang after setflash mode\n");
+ airo_print_info(ai->dev->name, "Waitbusy hang after setflash mode");
return -EIO;
}
return 0;
@@ -7777,7 +7910,7 @@ static int flashpchar(struct airo_info *ai,int byte,int dwelltime) {
/* timeout for busy clear wait */
if(waittime <= 0 ){
- printk(KERN_INFO "flash putchar busywait timeout! \n");
+ airo_print_info(ai->dev->name, "flash putchar busywait timeout!");
return -EBUSY;
}
@@ -7866,7 +7999,7 @@ static int flashrestart(struct airo_info *ai,struct net_device *dev){
if (!test_bit(FLAG_MPI,&ai->flags))
for( i = 0; i < MAX_FIDS; i++ ) {
ai->fids[i] = transmit_allocate
- ( ai, 2312, i >= MAX_FIDS / 2 );
+ ( ai, AIRO_DEF_MTU, i >= MAX_FIDS / 2 );
}
ssleep(1); /* Added 12/7/00 */
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c
index 753a1de6664..06c3fa32b31 100644
--- a/drivers/net/wireless/hostap/hostap_ap.c
+++ b/drivers/net/wireless/hostap/hostap_ap.c
@@ -3141,7 +3141,7 @@ int hostap_add_sta(struct ap_data *ap, u8 *sta_addr)
if (ret == 1) {
sta = ap_add_sta(ap, sta_addr);
if (!sta)
- ret = -1;
+ return -1;
sta->flags = WLAN_STA_AUTH | WLAN_STA_ASSOC;
sta->ap = 1;
memset(sta->supported_rates, 0, sizeof(sta->supported_rates));
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index f8f4503475f..d335b250923 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -585,8 +585,6 @@ static int prism2_config(dev_link_t *link)
parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL);
hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
if (parse == NULL || hw_priv == NULL) {
- kfree(parse);
- kfree(hw_priv);
ret = -ENOMEM;
goto failed;
}
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c
index b1f142d9e23..328e9a1d13b 100644
--- a/drivers/net/wireless/hostap/hostap_hw.c
+++ b/drivers/net/wireless/hostap/hostap_hw.c
@@ -928,15 +928,15 @@ static int hfa384x_set_rid(struct net_device *dev, u16 rid, void *buf, int len)
res = hfa384x_cmd(dev, HFA384X_CMDCODE_ACCESS_WRITE, rid, NULL, NULL);
up(&local->rid_bap_sem);
+
if (res) {
printk(KERN_DEBUG "%s: hfa384x_set_rid: CMDCODE_ACCESS_WRITE "
"failed (res=%d, rid=%04x, len=%d)\n",
dev->name, res, rid, len);
- return res;
- }
- if (res == -ETIMEDOUT)
- prism2_hw_reset(dev);
+ if (res == -ETIMEDOUT)
+ prism2_hw_reset(dev);
+ }
return res;
}
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c
index f3e0ce1ee03..8b37e824dfc 100644
--- a/drivers/net/wireless/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/hostap/hostap_ioctl.c
@@ -3358,10 +3358,6 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev,
if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
if (!sta_ptr)
local->tx_keyidx = i;
- else if (i) {
- ret = -EINVAL;
- goto done;
- }
}
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 2e85bdced2d..194f0709758 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -307,7 +307,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
memset(hw_priv, 0, sizeof(*hw_priv));
if (pci_enable_device(pdev))
- return -EIO;
+ goto err_out_free;
phymem = pci_resource_start(pdev, 0);
@@ -368,6 +368,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
err_out_disable:
pci_disable_device(pdev);
prism2_free_local_data(dev);
+
+ err_out_free:
kfree(hw_priv);
return -ENODEV;
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 94fe2449f09..edaaa943eb8 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -368,7 +368,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
switch (cis[pos]) {
case CISTPL_CONFIG:
- if (cis[pos + 1] < 1)
+ if (cis[pos + 1] < 2)
goto cis_error;
rmsz = (cis[pos + 2] & 0x3c) >> 2;
rasz = cis[pos + 2] & 0x03;
@@ -390,7 +390,7 @@ static int prism2_plx_check_cis(void __iomem *attr_mem, int attr_len,
break;
case CISTPL_MANFID:
- if (cis[pos + 1] < 4)
+ if (cis[pos + 1] < 5)
goto cis_error;
manfid1 = cis[pos + 2] + (cis[pos + 3] << 8);
manfid2 = cis[pos + 4] + (cis[pos + 5] << 8);
@@ -452,7 +452,7 @@ static int prism2_plx_probe(struct pci_dev *pdev,
memset(hw_priv, 0, sizeof(*hw_priv));
if (pci_enable_device(pdev))
- return -EIO;
+ goto err_out_free;
/* National Datacomm NCP130 based on TMD7160, not PLX9052. */
tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);
@@ -567,9 +567,6 @@ static int prism2_plx_probe(struct pci_dev *pdev,
return hostap_hw_ready(dev);
fail:
- prism2_free_local_data(dev);
- kfree(hw_priv);
-
if (irq_registered && dev)
free_irq(dev->irq, dev);
@@ -577,6 +574,10 @@ static int prism2_plx_probe(struct pci_dev *pdev,
iounmap(attr_mem);
pci_disable_device(pdev);
+ prism2_free_local_data(dev);
+
+ err_out_free:
+ kfree(hw_priv);
return -ENODEV;
}
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c
index eea2f04c8c6..ebb23878583 100644
--- a/drivers/net/wireless/prism54/oid_mgt.c
+++ b/drivers/net/wireless/prism54/oid_mgt.c
@@ -332,7 +332,7 @@ mgt_le_to_cpu(int type, void *data)
case OID_TYPE_ATTACH:{
struct obj_attachment *attach = data;
attach->id = le16_to_cpu(attach->id);
- attach->size = le16_to_cpu(attach->size);;
+ attach->size = le16_to_cpu(attach->size);
break;
}
case OID_TYPE_SSID:
@@ -401,7 +401,7 @@ mgt_cpu_to_le(int type, void *data)
case OID_TYPE_ATTACH:{
struct obj_attachment *attach = data;
attach->id = cpu_to_le16(attach->id);
- attach->size = cpu_to_le16(attach->size);;
+ attach->size = cpu_to_le16(attach->size);
break;
}
case OID_TYPE_SSID:
diff --git a/drivers/net/wireless/spectrum_cs.c b/drivers/net/wireless/spectrum_cs.c
index fee4be1ce81..5fa6fbe35bb 100644
--- a/drivers/net/wireless/spectrum_cs.c
+++ b/drivers/net/wireless/spectrum_cs.c
@@ -147,7 +147,7 @@ struct pdi {
__le16 _len; /* length of ID and data, in words */
__le16 _id; /* record ID */
char data[0]; /* plug data */
-} __attribute__ ((packed));;
+} __attribute__ ((packed));
/* Functions for access to little-endian data */
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 76102160359..8037e5806d0 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -426,7 +426,7 @@ static void __devexit zorro8390_remove_one(struct zorro_dev *z)
static int __init zorro8390_init_module(void)
{
- return zorro_module_init(&zorro8390_driver);
+ return zorro_register_driver(&zorro8390_driver);
}
static void __exit zorro8390_cleanup_module(void)
diff --git a/drivers/oprofile/cpu_buffer.c b/drivers/oprofile/cpu_buffer.c
index 78193e4bbdb..330d3869b41 100644
--- a/drivers/oprofile/cpu_buffer.c
+++ b/drivers/oprofile/cpu_buffer.c
@@ -38,9 +38,8 @@ void free_cpu_buffers(void)
{
int i;
- for_each_online_cpu(i) {
+ for_each_online_cpu(i)
vfree(cpu_buffer[i].buffer);
- }
}
int alloc_cpu_buffers(void)
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index 5d47c5965c5..0821747e44c 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -1724,9 +1724,7 @@ printk("sba_hw_init(): mem_boot 0x%x 0x%x 0x%x 0x%x\n", PAGE0->mem_boot.hpa,
sba_dev->chip_resv.start = PCI_F_EXTEND | 0xfef00000UL;
sba_dev->chip_resv.end = PCI_F_EXTEND | (0xff000000UL - 1) ;
err = request_resource(&iomem_resource, &(sba_dev->chip_resv));
- if (err < 0) {
- BUG();
- }
+ BUG_ON(err < 0);
} else if (IS_PLUTO(sba_dev->iodc)) {
int err;
@@ -2185,8 +2183,7 @@ void sba_directed_lmmio(struct parisc_device *pci_hba, struct resource *r)
int i;
int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
- if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT))
- BUG();
+ BUG_ON((t!=HPHW_IOA) && (t!=HPHW_BCPORT));
r->start = r->end = 0;
@@ -2228,8 +2225,7 @@ void sba_distributed_lmmio(struct parisc_device *pci_hba, struct resource *r )
int base, size;
int rope = (pci_hba->hw_path & (ROPES_PER_IOC-1)); /* rope # */
- if ((t!=HPHW_IOA) && (t!=HPHW_BCPORT))
- BUG();
+ BUG_ON((t!=HPHW_IOA) && (t!=HPHW_BCPORT));
r->start = r->end = 0;
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index ba971fecd0d..ad6d3b28a3a 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -157,8 +157,8 @@ superio_init(struct pci_dev *pcidev)
if (sio->suckyio_irq_enabled)
return;
- if (!pdev) BUG();
- if (!sio->usb_pdev) BUG();
+ BUG_ON(!pdev);
+ BUG_ON(!sio->usb_pdev);
/* use the IRQ iosapic found for USB INT D... */
pdev->irq = sio->usb_pdev->irq;
@@ -474,8 +474,7 @@ superio_probe(struct pci_dev *dev, const struct pci_device_id *id)
dev->subsystem_vendor, dev->subsystem_device,
dev->class);
- if (!sio->suckyio_irq_enabled)
- BUG(); /* Enabled by PCI_FIXUP_FINAL */
+ BUG_ON(!sio->suckyio_irq_enabled); /* Enabled by PCI_FIXUP_FINAL */
if (dev->device == PCI_DEVICE_ID_NS_87560_LIO) { /* Function 1 */
superio_parport_init();
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 10845253c9e..d121644646b 100644
--- a/drivers/parport/parport_serial.c
+++ b/drivers/parport/parport_serial.c
@@ -31,14 +31,8 @@ enum parport_pc_pci_cards {
netmos_9xx5_combo,
netmos_9855,
avlab_1s1p,
- avlab_1s1p_650,
- avlab_1s1p_850,
avlab_1s2p,
- avlab_1s2p_650,
- avlab_1s2p_850,
avlab_2s1p,
- avlab_2s1p_650,
- avlab_2s1p_850,
siig_1s1p_10x,
siig_2s1p_10x,
siig_2p1s_20x,
@@ -85,14 +79,8 @@ static struct parport_pc_pci cards[] __devinitdata = {
/* netmos_9xx5_combo */ { 1, { { 2, -1 }, }, netmos_parallel_init },
/* netmos_9855 */ { 1, { { 0, -1 }, }, netmos_parallel_init },
/* avlab_1s1p */ { 1, { { 1, 2}, } },
- /* avlab_1s1p_650 */ { 1, { { 1, 2}, } },
- /* avlab_1s1p_850 */ { 1, { { 1, 2}, } },
/* avlab_1s2p */ { 2, { { 1, 2}, { 3, 4 },} },
- /* avlab_1s2p_650 */ { 2, { { 1, 2}, { 3, 4 },} },
- /* avlab_1s2p_850 */ { 2, { { 1, 2}, { 3, 4 },} },
/* avlab_2s1p */ { 1, { { 2, 3}, } },
- /* avlab_2s1p_650 */ { 1, { { 2, 3}, } },
- /* avlab_2s1p_850 */ { 1, { { 2, 3}, } },
/* siig_1s1p_10x */ { 1, { { 3, 4 }, } },
/* siig_2s1p_10x */ { 1, { { 4, 5 }, } },
/* siig_2p1s_20x */ { 2, { { 1, 2 }, { 3, 4 }, } },
@@ -119,15 +107,24 @@ static struct pci_device_id parport_serial_pci_tbl[] = {
{ PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9855,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, netmos_9855 },
/* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
- { 0x14db, 0x2110, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p},
- { 0x14db, 0x2111, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_650},
- { 0x14db, 0x2112, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p_850},
- { 0x14db, 0x2140, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p},
- { 0x14db, 0x2141, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_650},
- { 0x14db, 0x2142, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p_850},
- { 0x14db, 0x2160, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p},
- { 0x14db, 0x2161, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_650},
- { 0x14db, 0x2162, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p_850},
+ { PCI_VENDOR_ID_AFAVLAB, 0x2110,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2111,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2112,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s1p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2140,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2141,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2142,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1s2p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2160,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2161,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
+ { PCI_VENDOR_ID_AFAVLAB, 0x2162,
+ PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_2s1p },
{ PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_550,
PCI_ANY_ID, PCI_ANY_ID, 0, 0, siig_1s1p_10x },
{ PCI_VENDOR_ID_SIIG, PCI_DEVICE_ID_SIIG_1S1P_10x_650,
@@ -201,54 +198,18 @@ static struct pciserial_board pci_parport_serial_boards[] __devinitdata = {
.base_baud = 115200,
.uart_offset = 8,
},
- [avlab_1s1p_650] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 1,
- .base_baud = 115200,
- .uart_offset = 8,
- },
- [avlab_1s1p_850] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 1,
- .base_baud = 115200,
- .uart_offset = 8,
- },
[avlab_1s2p] = { /* n/t */
.flags = FL_BASE0 | FL_BASE_BARS,
.num_ports = 1,
.base_baud = 115200,
.uart_offset = 8,
},
- [avlab_1s2p_650] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 1,
- .base_baud = 115200,
- .uart_offset = 8,
- },
- [avlab_1s2p_850] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 1,
- .base_baud = 115200,
- .uart_offset = 8,
- },
[avlab_2s1p] = { /* n/t */
.flags = FL_BASE0 | FL_BASE_BARS,
.num_ports = 2,
.base_baud = 115200,
.uart_offset = 8,
},
- [avlab_2s1p_650] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 2,
- .base_baud = 115200,
- .uart_offset = 8,
- },
- [avlab_2s1p_850] = { /* nt */
- .flags = FL_BASE0 | FL_BASE_BARS,
- .num_ports = 2,
- .base_baud = 115200,
- .uart_offset = 8,
- },
[siig_1s1p_10x] = {
.flags = FL_BASE2,
.num_ports = 1,
diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig
index f187fd8aeed..4d762fc4878 100644
--- a/drivers/pci/Kconfig
+++ b/drivers/pci/Kconfig
@@ -11,24 +11,11 @@ config PCI_MSI
generate an interrupt using an inbound Memory Write on its
PCI bus instead of asserting a device IRQ pin.
- If you don't know what to do here, say N.
-
-config PCI_LEGACY_PROC
- bool "Legacy /proc/pci interface"
- depends on PCI
- ---help---
- This feature enables a procfs file -- /proc/pci -- that provides a
- summary of PCI devices in the system.
-
- This feature has been deprecated as of v2.5.53, in favor of using the
- tool lspci(8). This feature may be removed at a future date.
+ Use of PCI MSI interrupts can be disabled at kernel boot time
+ by using the 'pci=nomsi' option. This disables MSI for the
+ entire system.
- lspci can provide the same data, as well as much more. lspci is a part of
- the pci-utils package, which should be installed by your distribution.
- See <file:Documentation/Changes> for information on where to get the latest
- version.
-
- When in doubt, say N.
+ If you don't know what to do here, say N.
config PCI_DEBUG
bool "PCI Debugging"
diff --git a/drivers/pci/hotplug/Makefile b/drivers/pci/hotplug/Makefile
index 3c71e3077ff..421cfffb175 100644
--- a/drivers/pci/hotplug/Makefile
+++ b/drivers/pci/hotplug/Makefile
@@ -22,6 +22,9 @@ ifdef CONFIG_HOTPLUG_PCI_CPCI
pci_hotplug-objs += cpci_hotplug_core.o \
cpci_hotplug_pci.o
endif
+ifdef CONFIG_ACPI
+pci_hotplug-objs += acpi_pcihp.o
+endif
cpqphp-objs := cpqphp_core.o \
cpqphp_ctrl.o \
@@ -37,7 +40,8 @@ ibmphp-objs := ibmphp_core.o \
ibmphp_hpc.o
acpiphp-objs := acpiphp_core.o \
- acpiphp_glue.o
+ acpiphp_glue.o \
+ acpiphp_dock.o
rpaphp-objs := rpaphp_core.o \
rpaphp_pci.o \
@@ -50,23 +54,9 @@ pciehp-objs := pciehp_core.o \
pciehp_ctrl.o \
pciehp_pci.o \
pciehp_hpc.o
-ifdef CONFIG_ACPI
- pciehp-objs += pciehprm_acpi.o
-else
- pciehp-objs += pciehprm_nonacpi.o
-endif
shpchp-objs := shpchp_core.o \
shpchp_ctrl.o \
shpchp_pci.o \
shpchp_sysfs.o \
shpchp_hpc.o
-ifdef CONFIG_ACPI
- shpchp-objs += shpchprm_acpi.o
-else
- ifdef CONFIG_HOTPLUG_PCI_SHPC_PHPRM_LEGACY
- shpchp-objs += shpchprm_legacy.o
- else
- shpchp-objs += shpchprm_nonacpi.o
- endif
-endif
diff --git a/drivers/pci/hotplug/shpchprm_acpi.c b/drivers/pci/hotplug/acpi_pcihp.c
index 17145e52223..39af9c325f3 100644
--- a/drivers/pci/hotplug/shpchprm_acpi.c
+++ b/drivers/pci/hotplug/acpi_pcihp.c
@@ -1,7 +1,7 @@
/*
- * SHPCHPRM ACPI: PHP Resource Manager for ACPI platform
+ * Common ACPI functions for hot plug platforms
*
- * Copyright (C) 2003-2004 Intel Corporation
+ * Copyright (C) 2006 Intel Corporation
*
* All rights reserved.
*
@@ -31,26 +31,12 @@
#include <acpi/acpi.h>
#include <acpi/acpi_bus.h>
#include <acpi/actypes.h>
-#include "shpchp.h"
+#include "pci_hotplug.h"
#define METHOD_NAME__SUN "_SUN"
#define METHOD_NAME__HPP "_HPP"
#define METHOD_NAME_OSHP "OSHP"
-static u8 * acpi_path_name( acpi_handle handle)
-{
- acpi_status status;
- static u8 path_name[ACPI_PATHNAME_MAX];
- struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name };
-
- memset(path_name, 0, sizeof (path_name));
- status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf);
-
- if (ACPI_FAILURE(status))
- return NULL;
- else
- return path_name;
-}
static acpi_status
acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
@@ -58,18 +44,21 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
acpi_status status;
u8 nui[4];
struct acpi_buffer ret_buf = { 0, NULL};
+ struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *ext_obj, *package;
- u8 *path_name = acpi_path_name(handle);
int i, len = 0;
+ acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
+
/* get _hpp */
status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf);
switch (status) {
case AE_BUFFER_OVERFLOW:
ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
if (!ret_buf.pointer) {
- err ("%s:%s alloc for _HPP fail\n", __FUNCTION__,
- path_name);
+ printk(KERN_ERR "%s:%s alloc for _HPP fail\n",
+ __FUNCTION__, (char *)string.pointer);
+ acpi_os_free(string.pointer);
return AE_NO_MEMORY;
}
status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
@@ -78,16 +67,17 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
break;
default:
if (ACPI_FAILURE(status)) {
- dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
- path_name, status);
+ pr_debug("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
+ (char *)string.pointer, status);
+ acpi_os_free(string.pointer);
return status;
}
}
ext_obj = (union acpi_object *) ret_buf.pointer;
if (ext_obj->type != ACPI_TYPE_PACKAGE) {
- err ("%s:%s _HPP obj not a package\n", __FUNCTION__,
- path_name);
+ printk(KERN_ERR "%s:%s _HPP obj not a package\n", __FUNCTION__,
+ (char *)string.pointer);
status = AE_ERROR;
goto free_and_return;
}
@@ -101,8 +91,8 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
nui[i] = (u8)ext_obj->integer.value;
break;
default:
- err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__,
- path_name);
+ printk(KERN_ERR "%s:%s _HPP obj type incorrect\n",
+ __FUNCTION__, (char *)string.pointer);
status = AE_ERROR;
goto free_and_return;
}
@@ -113,54 +103,52 @@ acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
hpp->enable_serr = nui[2];
hpp->enable_perr = nui[3];
- dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size);
- dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer);
- dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr);
- dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
+ pr_debug(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size);
+ pr_debug(" _HPP: latency timer =0x%x\n", hpp->latency_timer);
+ pr_debug(" _HPP: enable SERR =0x%x\n", hpp->enable_serr);
+ pr_debug(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
free_and_return:
- kfree(ret_buf.pointer);
+ acpi_os_free(string.pointer);
+ acpi_os_free(ret_buf.pointer);
return status;
}
-static void acpi_run_oshp(acpi_handle handle)
+
+
+/* acpi_run_oshp - get control of hotplug from the firmware
+ *
+ * @handle - the handle of the hotplug controller.
+ */
+acpi_status acpi_run_oshp(acpi_handle handle)
{
acpi_status status;
- u8 *path_name = acpi_path_name(handle);
+ struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
/* run OSHP */
status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL);
- if (ACPI_FAILURE(status)) {
- err("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name,
- status);
- } else {
- dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name);
- }
-}
-
-int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
-{
- int offset = devnum - ctrl->slot_device_offset;
+ if (ACPI_FAILURE(status))
+ printk(KERN_ERR "%s:%s OSHP fails=0x%x\n", __FUNCTION__,
+ (char *)string.pointer, status);
+ else
+ pr_debug("%s:%s OSHP passes\n", __FUNCTION__,
+ (char *)string.pointer);
- dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset);
- *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset);
- return 0;
+ acpi_os_free(string.pointer);
+ return status;
}
+EXPORT_SYMBOL_GPL(acpi_run_oshp);
+
-void get_hp_hw_control_from_firmware(struct pci_dev *dev)
-{
- /*
- * OSHP is an optional ACPI firmware control method. If present,
- * we need to run it to inform BIOS that we will control SHPC
- * hardware from now on.
- */
- acpi_handle handle = DEVICE_ACPI_HANDLE(&(dev->dev));
- if (!handle)
- return;
- acpi_run_oshp(handle);
-}
-void get_hp_params_from_firmware(struct pci_dev *dev,
+/* acpi_get_hp_params_from_firmware
+ *
+ * @dev - the pci_dev of the newly added device
+ * @hpp - allocated by the caller
+ */
+acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev,
struct hotplug_params *hpp)
{
acpi_status status = AE_NOT_FOUND;
@@ -182,5 +170,42 @@ void get_hp_params_from_firmware(struct pci_dev *dev,
/* Check if a parent object supports _HPP */
pdev = pdev->bus->parent->self;
}
+ return status;
}
+EXPORT_SYMBOL_GPL(acpi_get_hp_params_from_firmware);
+
+/* acpi_root_bridge - check to see if this acpi object is a root bridge
+ *
+ * @handle - the acpi object in question.
+ */
+int acpi_root_bridge(acpi_handle handle)
+{
+ acpi_status status;
+ struct acpi_device_info *info;
+ struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+ int i;
+
+ status = acpi_get_object_info(handle, &buffer);
+ if (ACPI_SUCCESS(status)) {
+ info = buffer.pointer;
+ if ((info->valid & ACPI_VALID_HID) &&
+ !strcmp(PCI_ROOT_HID_STRING,
+ info->hardware_id.value)) {
+ acpi_os_free(buffer.pointer);
+ return 1;
+ }
+ if (info->valid & ACPI_VALID_CID) {
+ for (i=0; i < info->compatibility_id.count; i++) {
+ if (!strcmp(PCI_ROOT_HID_STRING,
+ info->compatibility_id.id[i].value)) {
+ acpi_os_free(buffer.pointer);
+ return 1;
+ }
+ }
+ }
+ acpi_os_free(buffer.pointer);
+ }
+ return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_root_bridge);
diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h
index 293603e1b7c..467ac70a46f 100644
--- a/drivers/pci/hotplug/acpiphp.h
+++ b/drivers/pci/hotplug/acpiphp.h
@@ -37,6 +37,7 @@
#include <linux/acpi.h>
#include <linux/kobject.h> /* for KOBJ_NAME_LEN */
+#include <linux/mutex.h>
#include "pci_hotplug.h"
#define dbg(format, arg...) \
@@ -59,26 +60,10 @@ struct acpiphp_slot;
* struct slot - slot information for each *physical* slot
*/
struct slot {
- u8 number;
struct hotplug_slot *hotplug_slot;
- struct list_head slot_list;
-
struct acpiphp_slot *acpi_slot;
};
-/**
- * struct hpp_param - ACPI 2.0 _HPP Hot Plug Parameters
- * @cache_line_size in DWORD
- * @latency_timer in PCI clock
- * @enable_SERR 0 or 1
- * @enable_PERR 0 or 1
- */
-struct hpp_param {
- u8 cache_line_size;
- u8 latency_timer;
- u8 enable_SERR;
- u8 enable_PERR;
-};
/**
@@ -102,7 +87,7 @@ struct acpiphp_bridge {
struct pci_dev *pci_dev;
/* ACPI 2.0 _HPP parameters */
- struct hpp_param hpp;
+ struct hotplug_params hpp;
spinlock_t res_lock;
};
@@ -118,9 +103,9 @@ struct acpiphp_slot {
struct acpiphp_bridge *bridge; /* parent */
struct list_head funcs; /* one slot may have different
objects (i.e. for each function) */
- struct semaphore crit_sect;
+ struct slot *slot;
+ struct mutex crit_sect;
- u32 id; /* slot id (serial #) for hotplug core */
u8 device; /* pci device# */
u32 sun; /* ACPI _SUN (slot unique number) */
@@ -160,6 +145,25 @@ struct acpiphp_attention_info
struct module *owner;
};
+
+struct dependent_device {
+ struct list_head device_list;
+ struct list_head pci_list;
+ acpi_handle handle;
+ struct acpiphp_func *func;
+};
+
+
+struct acpiphp_dock_station {
+ acpi_handle handle;
+ u32 last_dock_time;
+ u32 flags;
+ struct acpiphp_func *dock_bridge;
+ struct list_head dependent_devices;
+ struct list_head pci_dependent_devices;
+};
+
+
/* PCI bus bridge HID */
#define ACPI_PCI_HOST_HID "PNP0A03"
@@ -197,19 +201,27 @@ struct acpiphp_attention_info
#define FUNC_HAS_PS1 (0x00000020)
#define FUNC_HAS_PS2 (0x00000040)
#define FUNC_HAS_PS3 (0x00000080)
+#define FUNC_HAS_DCK (0x00000100)
+#define FUNC_IS_DD (0x00000200)
+
+/* dock station flags */
+#define DOCK_DOCKING (0x00000001)
+#define DOCK_HAS_BRIDGE (0x00000002)
/* function prototypes */
/* acpiphp_core.c */
extern int acpiphp_register_attention(struct acpiphp_attention_info*info);
extern int acpiphp_unregister_attention(struct acpiphp_attention_info *info);
+extern int acpiphp_register_hotplug_slot(struct acpiphp_slot *slot);
+extern void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *slot);
/* acpiphp_glue.c */
extern int acpiphp_glue_init (void);
extern void acpiphp_glue_exit (void);
extern int acpiphp_get_num_slots (void);
-extern struct acpiphp_slot *get_slot_from_id (int id);
typedef int (*acpiphp_callback)(struct acpiphp_slot *slot, void *data);
+void handle_hotplug_event_func(acpi_handle, u32, void*);
extern int acpiphp_enable_slot (struct acpiphp_slot *slot);
extern int acpiphp_disable_slot (struct acpiphp_slot *slot);
@@ -219,6 +231,16 @@ extern u8 acpiphp_get_latch_status (struct acpiphp_slot *slot);
extern u8 acpiphp_get_adapter_status (struct acpiphp_slot *slot);
extern u32 acpiphp_get_address (struct acpiphp_slot *slot);
+/* acpiphp_dock.c */
+extern int find_dock_station(void);
+extern void remove_dock_station(void);
+extern void add_dependent_device(struct dependent_device *new_dd);
+extern void add_pci_dependent_device(struct dependent_device *new_dd);
+extern struct dependent_device *get_dependent_device(acpi_handle handle);
+extern int is_dependent_device(acpi_handle handle);
+extern int detect_dependent_devices(acpi_handle *bridge_handle);
+extern struct dependent_device *alloc_dependent_device(acpi_handle handle);
+
/* variables */
extern int acpiphp_debug;
diff --git a/drivers/pci/hotplug/acpiphp_core.c b/drivers/pci/hotplug/acpiphp_core.c
index 60c4c38047a..4f1b0da8e47 100644
--- a/drivers/pci/hotplug/acpiphp_core.c
+++ b/drivers/pci/hotplug/acpiphp_core.c
@@ -44,8 +44,6 @@
#include "pci_hotplug.h"
#include "acpiphp.h"
-static LIST_HEAD(slot_list);
-
#define MY_NAME "acpiphp"
static int debug;
@@ -341,62 +339,53 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
kfree(slot);
}
-/**
- * init_slots - initialize 'struct slot' structures for each slot
- *
- */
-static int __init init_slots(void)
+/* callback routine to initialize 'struct slot' for each slot */
+int acpiphp_register_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
{
struct slot *slot;
+ struct hotplug_slot *hotplug_slot;
+ struct hotplug_slot_info *hotplug_slot_info;
int retval = -ENOMEM;
- int i;
-
- for (i = 0; i < num_slots; ++i) {
- slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
- if (!slot)
- goto error;
- memset(slot, 0, sizeof(struct slot));
-
- slot->hotplug_slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
- if (!slot->hotplug_slot)
- goto error_slot;
- memset(slot->hotplug_slot, 0, sizeof(struct hotplug_slot));
-
- slot->hotplug_slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
- if (!slot->hotplug_slot->info)
- goto error_hpslot;
- memset(slot->hotplug_slot->info, 0, sizeof(struct hotplug_slot_info));
-
- slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
- if (!slot->hotplug_slot->name)
- goto error_info;
-
- slot->number = i;
-
- slot->hotplug_slot->private = slot;
- slot->hotplug_slot->release = &release_slot;
- slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
-
- slot->acpi_slot = get_slot_from_id(i);
- slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
- slot->hotplug_slot->info->attention_status = 0;
- slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
- slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
- slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
- slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
-
- make_slot_name(slot);
-
- retval = pci_hp_register(slot->hotplug_slot);
- if (retval) {
- err("pci_hp_register failed with error %d\n", retval);
- goto error_name;
- }
-
- /* add slot to our internal list */
- list_add(&slot->slot_list, &slot_list);
- info("Slot [%s] registered\n", slot->hotplug_slot->name);
- }
+
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ if (!slot)
+ goto error;
+
+ slot->hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
+ if (!slot->hotplug_slot)
+ goto error_slot;
+
+ slot->hotplug_slot->info = kzalloc(sizeof(*hotplug_slot_info),
+ GFP_KERNEL);
+ if (!slot->hotplug_slot->info)
+ goto error_hpslot;
+
+ slot->hotplug_slot->name = kzalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+ if (!slot->hotplug_slot->name)
+ goto error_info;
+
+ slot->hotplug_slot->private = slot;
+ slot->hotplug_slot->release = &release_slot;
+ slot->hotplug_slot->ops = &acpi_hotplug_slot_ops;
+
+ slot->acpi_slot = acpiphp_slot;
+ slot->hotplug_slot->info->power_status = acpiphp_get_power_status(slot->acpi_slot);
+ slot->hotplug_slot->info->attention_status = 0;
+ slot->hotplug_slot->info->latch_status = acpiphp_get_latch_status(slot->acpi_slot);
+ slot->hotplug_slot->info->adapter_status = acpiphp_get_adapter_status(slot->acpi_slot);
+ slot->hotplug_slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
+ slot->hotplug_slot->info->cur_bus_speed = PCI_SPEED_UNKNOWN;
+
+ acpiphp_slot->slot = slot;
+ make_slot_name(slot);
+
+ retval = pci_hp_register(slot->hotplug_slot);
+ if (retval) {
+ err("pci_hp_register failed with error %d\n", retval);
+ goto error_name;
+ }
+
+ info("Slot [%s] registered\n", slot->hotplug_slot->name);
return 0;
error_name:
@@ -412,42 +401,51 @@ error:
}
-static void __exit cleanup_slots (void)
+void acpiphp_unregister_hotplug_slot(struct acpiphp_slot *acpiphp_slot)
{
- struct list_head *tmp, *n;
- struct slot *slot;
+ struct slot *slot = acpiphp_slot->slot;
+ int retval = 0;
- list_for_each_safe (tmp, n, &slot_list) {
- /* memory will be freed in release_slot callback */
- slot = list_entry(tmp, struct slot, slot_list);
- list_del(&slot->slot_list);
- pci_hp_deregister(slot->hotplug_slot);
- }
+ info ("Slot [%s] unregistered\n", slot->hotplug_slot->name);
+
+ retval = pci_hp_deregister(slot->hotplug_slot);
+ if (retval)
+ err("pci_hp_deregister failed with error %d\n", retval);
}
static int __init acpiphp_init(void)
{
int retval;
+ int docking_station;
info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
acpiphp_debug = debug;
+ docking_station = find_dock_station();
+
/* read all the ACPI info from the system */
retval = init_acpi();
- if (retval)
- return retval;
- return init_slots();
+ /* if we have found a docking station, we should
+ * go ahead and load even if init_acpi has found
+ * no slots. This handles the case when the _DCK
+ * method not defined under the actual dock bridge
+ */
+ if (docking_station)
+ return 0;
+ else
+ return retval;
}
static void __exit acpiphp_exit(void)
{
- cleanup_slots();
/* deallocate internal data structures etc. */
acpiphp_glue_exit();
+
+ remove_dock_station();
}
module_init(acpiphp_init);
diff --git a/drivers/pci/hotplug/acpiphp_dock.c b/drivers/pci/hotplug/acpiphp_dock.c
new file mode 100644
index 00000000000..4f1aaf12831
--- /dev/null
+++ b/drivers/pci/hotplug/acpiphp_dock.c
@@ -0,0 +1,438 @@
+/*
+ * ACPI PCI HotPlug dock functions to ACPI CA subsystem
+ *
+ * Copyright (C) 2006 Kristen Carlson Accardi (kristen.c.accardi@intel.com)
+ * Copyright (C) 2006 Intel Corporation
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Send feedback to <kristen.c.accardi@intel.com>
+ *
+ */
+#include <linux/init.h>
+#include <linux/module.h>
+
+#include <linux/kernel.h>
+#include <linux/pci.h>
+#include <linux/smp_lock.h>
+#include <linux/mutex.h>
+
+#include "../pci.h"
+#include "pci_hotplug.h"
+#include "acpiphp.h"
+
+static struct acpiphp_dock_station *ds;
+#define MY_NAME "acpiphp_dock"
+
+
+int is_dependent_device(acpi_handle handle)
+{
+ return (get_dependent_device(handle) ? 1 : 0);
+}
+
+
+static acpi_status
+find_dependent_device(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ int *count = (int *)context;
+
+ if (is_dependent_device(handle)) {
+ (*count)++;
+ return AE_CTRL_TERMINATE;
+ } else {
+ return AE_OK;
+ }
+}
+
+
+
+
+void add_dependent_device(struct dependent_device *new_dd)
+{
+ list_add_tail(&new_dd->device_list, &ds->dependent_devices);
+}
+
+
+void add_pci_dependent_device(struct dependent_device *new_dd)
+{
+ list_add_tail(&new_dd->pci_list, &ds->pci_dependent_devices);
+}
+
+
+
+struct dependent_device * get_dependent_device(acpi_handle handle)
+{
+ struct dependent_device *dd;
+
+ if (!ds)
+ return NULL;
+
+ list_for_each_entry(dd, &ds->dependent_devices, device_list) {
+ if (handle == dd->handle)
+ return dd;
+ }
+ return NULL;
+}
+
+
+
+struct dependent_device *alloc_dependent_device(acpi_handle handle)
+{
+ struct dependent_device *dd;
+
+ dd = kzalloc(sizeof(*dd), GFP_KERNEL);
+ if (dd) {
+ INIT_LIST_HEAD(&dd->pci_list);
+ INIT_LIST_HEAD(&dd->device_list);
+ dd->handle = handle;
+ }
+ return dd;
+}
+
+
+
+static int is_dock(acpi_handle handle)
+{
+ acpi_status status;
+ acpi_handle tmp;
+
+ status = acpi_get_handle(handle, "_DCK", &tmp);
+ if (ACPI_FAILURE(status)) {
+ return 0;
+ }
+ return 1;
+}
+
+
+
+static int dock_present(void)
+{
+ unsigned long sta;
+ acpi_status status;
+
+ if (ds) {
+ status = acpi_evaluate_integer(ds->handle, "_STA", NULL, &sta);
+ if (ACPI_SUCCESS(status) && sta)
+ return 1;
+ }
+ return 0;
+}
+
+
+
+static void eject_dock(void)
+{
+ struct acpi_object_list arg_list;
+ union acpi_object arg;
+
+ arg_list.count = 1;
+ arg_list.pointer = &arg;
+ arg.type = ACPI_TYPE_INTEGER;
+ arg.integer.value = 1;
+
+ if (ACPI_FAILURE(acpi_evaluate_object(ds->handle, "_EJ0",
+ &arg_list, NULL)) || dock_present())
+ warn("%s: failed to eject dock!\n", __FUNCTION__);
+
+ return;
+}
+
+
+
+
+static acpi_status handle_dock(int dock)
+{
+ acpi_status status;
+ struct acpi_object_list arg_list;
+ union acpi_object arg;
+ struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+
+ dbg("%s: %s\n", __FUNCTION__, dock ? "docking" : "undocking");
+
+ /* _DCK method has one argument */
+ arg_list.count = 1;
+ arg_list.pointer = &arg;
+ arg.type = ACPI_TYPE_INTEGER;
+ arg.integer.value = dock;
+ status = acpi_evaluate_object(ds->handle, "_DCK",
+ &arg_list, &buffer);
+ if (ACPI_FAILURE(status))
+ err("%s: failed to execute _DCK\n", __FUNCTION__);
+ acpi_os_free(buffer.pointer);
+
+ return status;
+}
+
+
+
+static inline void dock(void)
+{
+ handle_dock(1);
+}
+
+
+
+static inline void undock(void)
+{
+ handle_dock(0);
+}
+
+
+
+/*
+ * the _DCK method can do funny things... and sometimes not
+ * hah-hah funny.
+ *
+ * TBD - figure out a way to only call fixups for
+ * systems that require them.
+ */
+static void post_dock_fixups(void)
+{
+ struct pci_bus *bus;
+ u32 buses;
+ struct dependent_device *dd;
+
+ list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list) {
+ bus = dd->func->slot->bridge->pci_bus;
+
+ /* fixup bad _DCK function that rewrites
+ * secondary bridge on slot
+ */
+ pci_read_config_dword(bus->self,
+ PCI_PRIMARY_BUS,
+ &buses);
+
+ if (((buses >> 8) & 0xff) != bus->secondary) {
+ buses = (buses & 0xff000000)
+ | ((unsigned int)(bus->primary) << 0)
+ | ((unsigned int)(bus->secondary) << 8)
+ | ((unsigned int)(bus->subordinate) << 16);
+ pci_write_config_dword(bus->self,
+ PCI_PRIMARY_BUS,
+ buses);
+ }
+ }
+}
+
+
+
+static void hotplug_pci(u32 type)
+{
+ struct dependent_device *dd;
+
+ list_for_each_entry(dd, &ds->pci_dependent_devices, pci_list)
+ handle_hotplug_event_func(dd->handle, type, dd->func);
+}
+
+
+
+static inline void begin_dock(void)
+{
+ ds->flags |= DOCK_DOCKING;
+}
+
+
+static inline void complete_dock(void)
+{
+ ds->flags &= ~(DOCK_DOCKING);
+ ds->last_dock_time = jiffies;
+}
+
+
+static int dock_in_progress(void)
+{
+ if (ds->flags & DOCK_DOCKING ||
+ ds->last_dock_time == jiffies) {
+ dbg("dock in progress\n");
+ return 1;
+ }
+ return 0;
+}
+
+
+
+static void
+handle_hotplug_event_dock(acpi_handle handle, u32 type, void *context)
+{
+ dbg("%s: enter\n", __FUNCTION__);
+
+ switch (type) {
+ case ACPI_NOTIFY_BUS_CHECK:
+ dbg("BUS Check\n");
+ if (!dock_in_progress() && dock_present()) {
+ begin_dock();
+ dock();
+ if (!dock_present()) {
+ err("Unable to dock!\n");
+ break;
+ }
+ post_dock_fixups();
+ hotplug_pci(type);
+ complete_dock();
+ }
+ break;
+ case ACPI_NOTIFY_EJECT_REQUEST:
+ dbg("EJECT request\n");
+ if (!dock_in_progress() && dock_present()) {
+ hotplug_pci(type);
+ undock();
+ eject_dock();
+ if (dock_present())
+ err("Unable to undock!\n");
+ }
+ break;
+ }
+}
+
+
+
+
+static acpi_status
+find_dock_ejd(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ acpi_status status;
+ acpi_handle tmp;
+ acpi_handle dck_handle = (acpi_handle) context;
+ char objname[64];
+ struct acpi_buffer buffer = { .length = sizeof(objname),
+ .pointer = objname };
+ struct acpi_buffer ejd_buffer = {ACPI_ALLOCATE_BUFFER, NULL};
+ union acpi_object *ejd_obj;
+
+ status = acpi_get_handle(handle, "_EJD", &tmp);
+ if (ACPI_FAILURE(status))
+ return AE_OK;
+
+ /* make sure we are dependent on the dock device,
+ * by executing the _EJD method, then getting a handle
+ * to the device referenced by that name. If that
+ * device handle is the same handle as the dock station
+ * handle, then we are a device dependent on the dock station
+ */
+ acpi_get_name(dck_handle, ACPI_FULL_PATHNAME, &buffer);
+ status = acpi_evaluate_object(handle, "_EJD", NULL, &ejd_buffer);
+ if (ACPI_FAILURE(status)) {
+ err("Unable to execute _EJD!\n");
+ goto find_ejd_out;
+ }
+ ejd_obj = ejd_buffer.pointer;
+ status = acpi_get_handle(NULL, ejd_obj->string.pointer, &tmp);
+ if (ACPI_FAILURE(status))
+ goto find_ejd_out;
+
+ if (tmp == dck_handle) {
+ struct dependent_device *dd;
+ dbg("%s: found device dependent on dock\n", __FUNCTION__);
+ dd = alloc_dependent_device(handle);
+ if (!dd) {
+ err("Can't allocate memory for dependent device!\n");
+ goto find_ejd_out;
+ }
+ add_dependent_device(dd);
+ }
+
+find_ejd_out:
+ acpi_os_free(ejd_buffer.pointer);
+ return AE_OK;
+}
+
+
+
+int detect_dependent_devices(acpi_handle *bridge_handle)
+{
+ acpi_status status;
+ int count;
+
+ count = 0;
+
+ status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge_handle,
+ (u32)1, find_dependent_device,
+ (void *)&count, NULL);
+
+ return count;
+}
+
+
+
+
+
+static acpi_status
+find_dock(acpi_handle handle, u32 lvl, void *context, void **rv)
+{
+ int *count = (int *)context;
+
+ if (is_dock(handle)) {
+ dbg("%s: found dock\n", __FUNCTION__);
+ ds = kzalloc(sizeof(*ds), GFP_KERNEL);
+ ds->handle = handle;
+ INIT_LIST_HEAD(&ds->dependent_devices);
+ INIT_LIST_HEAD(&ds->pci_dependent_devices);
+
+ /* look for devices dependent on dock station */
+ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, find_dock_ejd, handle, NULL);
+
+ acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
+ handle_hotplug_event_dock, ds);
+ (*count)++;
+ }
+
+ return AE_OK;
+}
+
+
+
+
+int find_dock_station(void)
+{
+ int num = 0;
+
+ ds = NULL;
+
+ /* start from the root object, because some laptops define
+ * _DCK methods outside the scope of PCI (IBM x-series laptop)
+ */
+ acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
+ ACPI_UINT32_MAX, find_dock, &num, NULL);
+
+ return num;
+}
+
+
+
+void remove_dock_station(void)
+{
+ struct dependent_device *dd, *tmp;
+ if (ds) {
+ if (ACPI_FAILURE(acpi_remove_notify_handler(ds->handle,
+ ACPI_SYSTEM_NOTIFY, handle_hotplug_event_dock)))
+ err("failed to remove dock notify handler\n");
+
+ /* free all dependent devices */
+ list_for_each_entry_safe(dd, tmp, &ds->dependent_devices,
+ device_list)
+ kfree(dd);
+
+ /* no need to touch the pci_dependent_device list,
+ * cause all memory was freed above
+ */
+ kfree(ds);
+ }
+}
+
+
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index 509a5b3ae99..053ee843863 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -46,7 +46,7 @@
#include <linux/kernel.h>
#include <linux/pci.h>
#include <linux/smp_lock.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include "../pci.h"
#include "pci_hotplug.h"
@@ -57,7 +57,6 @@ static LIST_HEAD(bridge_list);
#define MY_NAME "acpiphp_glue"
static void handle_hotplug_event_bridge (acpi_handle, u32, void *);
-static void handle_hotplug_event_func (acpi_handle, u32, void *);
static void acpiphp_sanitize_bus(struct pci_bus *bus);
static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus);
@@ -125,11 +124,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
struct acpiphp_bridge *bridge = (struct acpiphp_bridge *)context;
struct acpiphp_slot *slot;
struct acpiphp_func *newfunc;
+ struct dependent_device *dd;
acpi_handle tmp;
acpi_status status = AE_OK;
unsigned long adr, sun;
- int device, function;
- static int num_slots = 0; /* XXX if we support I/O node hotplug... */
+ int device, function, retval;
status = acpi_evaluate_integer(handle, "_ADR", NULL, &adr);
@@ -138,21 +137,21 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
status = acpi_get_handle(handle, "_EJ0", &tmp);
- if (ACPI_FAILURE(status))
+ if (ACPI_FAILURE(status) && !(is_dependent_device(handle)))
return AE_OK;
device = (adr >> 16) & 0xffff;
function = adr & 0xffff;
- newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
if (!newfunc)
return AE_NO_MEMORY;
- memset(newfunc, 0, sizeof(struct acpiphp_func));
INIT_LIST_HEAD(&newfunc->sibling);
newfunc->handle = handle;
newfunc->function = function;
- newfunc->flags = FUNC_HAS_EJ0;
+ if (ACPI_SUCCESS(status))
+ newfunc->flags = FUNC_HAS_EJ0;
if (ACPI_SUCCESS(acpi_get_handle(handle, "_STA", &tmp)))
newfunc->flags |= FUNC_HAS_STA;
@@ -163,6 +162,19 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
if (ACPI_SUCCESS(acpi_get_handle(handle, "_PS3", &tmp)))
newfunc->flags |= FUNC_HAS_PS3;
+ if (ACPI_SUCCESS(acpi_get_handle(handle, "_DCK", &tmp))) {
+ newfunc->flags |= FUNC_HAS_DCK;
+ /* add to devices dependent on dock station,
+ * because this may actually be the dock bridge
+ */
+ dd = alloc_dependent_device(handle);
+ if (!dd)
+ err("Can't allocate memory for "
+ "new dependent device!\n");
+ else
+ add_dependent_device(dd);
+ }
+
status = acpi_evaluate_integer(handle, "_SUN", NULL, &sun);
if (ACPI_FAILURE(status))
sun = -1;
@@ -176,19 +188,17 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
}
if (!slot) {
- slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
if (!slot) {
kfree(newfunc);
return AE_NO_MEMORY;
}
- memset(slot, 0, sizeof(struct acpiphp_slot));
slot->bridge = bridge;
- slot->id = num_slots++;
slot->device = device;
slot->sun = sun;
INIT_LIST_HEAD(&slot->funcs);
- init_MUTEX(&slot->crit_sect);
+ mutex_init(&slot->crit_sect);
slot->next = bridge->slots;
bridge->slots = slot;
@@ -198,6 +208,11 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
dbg("found ACPI PCI Hotplug slot %d at PCI %04x:%02x:%02x\n",
slot->sun, pci_domain_nr(bridge->pci_bus),
bridge->pci_bus->number, slot->device);
+ retval = acpiphp_register_hotplug_slot(slot);
+ if (retval) {
+ warn("acpiphp_register_hotplug_slot failed(err code = 0x%x)\n", retval);
+ goto err_exit;
+ }
}
newfunc->slot = slot;
@@ -210,16 +225,41 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON);
}
+ /* if this is a device dependent on a dock station,
+ * associate the acpiphp_func to the dependent_device
+ * struct.
+ */
+ if ((dd = get_dependent_device(handle))) {
+ newfunc->flags |= FUNC_IS_DD;
+ /*
+ * we don't want any devices which is dependent
+ * on the dock to have it's _EJ0 method executed.
+ * because we need to run _DCK first.
+ */
+ newfunc->flags &= ~FUNC_HAS_EJ0;
+ dd->func = newfunc;
+ add_pci_dependent_device(dd);
+ }
+
/* install notify handler */
- status = acpi_install_notify_handler(handle,
+ if (!(newfunc->flags & FUNC_HAS_DCK)) {
+ status = acpi_install_notify_handler(handle,
ACPI_SYSTEM_NOTIFY,
handle_hotplug_event_func,
newfunc);
- if (ACPI_FAILURE(status)) {
- err("failed to register interrupt notify handler\n");
- return status;
- }
+ if (ACPI_FAILURE(status))
+ err("failed to register interrupt notify handler\n");
+ } else
+ status = AE_OK;
+
+ return status;
+
+ err_exit:
+ bridge->nr_slots--;
+ bridge->slots = slot->next;
+ kfree(slot);
+ kfree(newfunc);
return AE_OK;
}
@@ -245,57 +285,19 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle)
static void decode_hpp(struct acpiphp_bridge *bridge)
{
acpi_status status;
- struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER,
- .pointer = NULL};
- union acpi_object *package;
- int i;
-
- /* default numbers */
- bridge->hpp.cache_line_size = 0x10;
- bridge->hpp.latency_timer = 0x40;
- bridge->hpp.enable_SERR = 0;
- bridge->hpp.enable_PERR = 0;
-
- status = acpi_evaluate_object(bridge->handle, "_HPP", NULL, &buffer);
+ status = acpi_get_hp_params_from_firmware(bridge->pci_dev, &bridge->hpp);
if (ACPI_FAILURE(status)) {
- dbg("_HPP evaluation failed\n");
- return;
+ /* use default numbers */
+ bridge->hpp.cache_line_size = 0x10;
+ bridge->hpp.latency_timer = 0x40;
+ bridge->hpp.enable_serr = 0;
+ bridge->hpp.enable_perr = 0;
}
-
- package = (union acpi_object *) buffer.pointer;
-
- if (!package || package->type != ACPI_TYPE_PACKAGE ||
- package->package.count != 4 || !package->package.elements) {
- err("invalid _HPP object; ignoring\n");
- goto err_exit;
- }
-
- for (i = 0; i < 4; i++) {
- if (package->package.elements[i].type != ACPI_TYPE_INTEGER) {
- err("invalid _HPP parameter type; ignoring\n");
- goto err_exit;
- }
- }
-
- bridge->hpp.cache_line_size = package->package.elements[0].integer.value;
- bridge->hpp.latency_timer = package->package.elements[1].integer.value;
- bridge->hpp.enable_SERR = package->package.elements[2].integer.value;
- bridge->hpp.enable_PERR = package->package.elements[3].integer.value;
-
- dbg("_HPP parameter = (%02x, %02x, %02x, %02x)\n",
- bridge->hpp.cache_line_size,
- bridge->hpp.latency_timer,
- bridge->hpp.enable_SERR,
- bridge->hpp.enable_PERR);
-
- bridge->flags |= BRIDGE_HAS_HPP;
-
- err_exit:
- kfree(buffer.pointer);
}
+
/* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */
static void init_bridge_misc(struct acpiphp_bridge *bridge)
{
@@ -304,9 +306,16 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge)
/* decode ACPI 2.0 _HPP (hot plug parameters) */
decode_hpp(bridge);
+ /* must be added to the list prior to calling register_slot */
+ list_add(&bridge->list, &bridge_list);
+
/* register all slot objects under this bridge */
status = acpi_walk_namespace(ACPI_TYPE_DEVICE, bridge->handle, (u32)1,
register_slot, bridge, NULL);
+ if (ACPI_FAILURE(status)) {
+ list_del(&bridge->list);
+ return;
+ }
/* install notify handler */
if (bridge->type != BRIDGE_TYPE_HOST) {
@@ -319,8 +328,6 @@ static void init_bridge_misc(struct acpiphp_bridge *bridge)
err("failed to register interrupt notify handler\n");
}
}
-
- list_add(&bridge->list, &bridge_list);
}
@@ -329,12 +336,10 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
{
struct acpiphp_bridge *bridge;
- bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+ bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
if (bridge == NULL)
return;
- memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
bridge->type = BRIDGE_TYPE_HOST;
bridge->handle = handle;
@@ -351,14 +356,12 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
{
struct acpiphp_bridge *bridge;
- bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+ bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
if (bridge == NULL) {
err("out of memory\n");
return;
}
- memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
bridge->type = BRIDGE_TYPE_P2P;
bridge->handle = handle;
@@ -410,11 +413,18 @@ find_p2p_bridge(acpi_handle handle, u32 lvl, void *context, void **rv)
goto out;
/* check if this bridge has ejectable slots */
- if (detect_ejectable_slots(handle) > 0) {
+ if ((detect_ejectable_slots(handle) > 0) ||
+ (detect_dependent_devices(handle) > 0)) {
dbg("found PCI-to-PCI bridge at PCI %s\n", pci_name(dev));
add_p2p_bridge(handle, dev);
}
+ /* search P2P bridges under this p2p bridge */
+ status = acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, (u32)1,
+ find_p2p_bridge, dev->subordinate, NULL);
+ if (ACPI_FAILURE(status))
+ warn("find_p2p_bridge faied (error code = 0x%x)\n", status);
+
out:
pci_dev_put(dev);
return AE_OK;
@@ -512,15 +522,19 @@ static void cleanup_bridge(struct acpiphp_bridge *bridge)
list_for_each_safe (list, tmp, &slot->funcs) {
struct acpiphp_func *func;
func = list_entry(list, struct acpiphp_func, sibling);
- status = acpi_remove_notify_handler(func->handle,
+ if (!(func->flags & FUNC_HAS_DCK)) {
+ status = acpi_remove_notify_handler(func->handle,
ACPI_SYSTEM_NOTIFY,
handle_hotplug_event_func);
- if (ACPI_FAILURE(status))
- err("failed to remove notify handler\n");
+ if (ACPI_FAILURE(status))
+ err("failed to remove notify handler\n");
+ }
pci_dev_put(func->pci_dev);
list_del(list);
kfree(func);
}
+ acpiphp_unregister_hotplug_slot(slot);
+ list_del(&slot->funcs);
kfree(slot);
slot = next;
}
@@ -551,7 +565,8 @@ static void remove_bridge(acpi_handle handle)
} else {
/* clean-up p2p bridges under this host bridge */
acpi_walk_namespace(ACPI_TYPE_DEVICE, handle,
- (u32)1, cleanup_p2p_bridge, NULL, NULL);
+ ACPI_UINT32_MAX, cleanup_p2p_bridge,
+ NULL, NULL);
}
}
@@ -751,6 +766,113 @@ static int power_off_slot(struct acpiphp_slot *slot)
}
+
+/**
+ * acpiphp_max_busnr - return the highest reserved bus number under
+ * the given bus.
+ * @bus: bus to start search with
+ *
+ */
+static unsigned char acpiphp_max_busnr(struct pci_bus *bus)
+{
+ struct list_head *tmp;
+ unsigned char max, n;
+
+ /*
+ * pci_bus_max_busnr will return the highest
+ * reserved busnr for all these children.
+ * that is equivalent to the bus->subordinate
+ * value. We don't want to use the parent's
+ * bus->subordinate value because it could have
+ * padding in it.
+ */
+ max = bus->secondary;
+
+ list_for_each(tmp, &bus->children) {
+ n = pci_bus_max_busnr(pci_bus_b(tmp));
+ if (n > max)
+ max = n;
+ }
+ return max;
+}
+
+
+
+/**
+ * get_func - get a pointer to acpiphp_func given a slot, device
+ * @slot: slot to search
+ * @dev: pci_dev struct to match.
+ *
+ * This function will increase the reference count of pci_dev,
+ * so callers should call pci_dev_put when complete.
+ *
+ */
+static struct acpiphp_func *
+get_func(struct acpiphp_slot *slot, struct pci_dev *dev)
+{
+ struct acpiphp_func *func = NULL;
+ struct pci_bus *bus = slot->bridge->pci_bus;
+ struct pci_dev *pdev;
+
+ list_for_each_entry(func, &slot->funcs, sibling) {
+ pdev = pci_get_slot(bus, PCI_DEVFN(slot->device,
+ func->function));
+ if (pdev) {
+ if (pdev == dev)
+ break;
+ pci_dev_put(pdev);
+ }
+ }
+ return func;
+}
+
+
+/**
+ * acpiphp_bus_add - add a new bus to acpi subsystem
+ * @func: acpiphp_func of the bridge
+ *
+ */
+static int acpiphp_bus_add(struct acpiphp_func *func)
+{
+ acpi_handle phandle;
+ struct acpi_device *device, *pdevice;
+ int ret_val;
+
+ acpi_get_parent(func->handle, &phandle);
+ if (acpi_bus_get_device(phandle, &pdevice)) {
+ dbg("no parent device, assuming NULL\n");
+ pdevice = NULL;
+ }
+ if (!acpi_bus_get_device(func->handle, &device)) {
+ dbg("bus exists... trim\n");
+ /* this shouldn't be in here, so remove
+ * the bus then re-add it...
+ */
+ ret_val = acpi_bus_trim(device, 1);
+ dbg("acpi_bus_trim return %x\n", ret_val);
+ }
+
+ ret_val = acpi_bus_add(&device, pdevice, func->handle,
+ ACPI_BUS_TYPE_DEVICE);
+ if (ret_val) {
+ dbg("error adding bus, %x\n",
+ -ret_val);
+ goto acpiphp_bus_add_out;
+ }
+ /*
+ * try to start anyway. We could have failed to add
+ * simply because this bus had previously been added
+ * on another add. Don't bother with the return value
+ * we just keep going.
+ */
+ ret_val = acpi_bus_start(device);
+
+acpiphp_bus_add_out:
+ return ret_val;
+}
+
+
+
/**
* enable_device - enable, configure a slot
* @slot: slot to be enabled
@@ -788,7 +910,7 @@ static int enable_device(struct acpiphp_slot *slot)
goto err_exit;
}
- max = bus->secondary;
+ max = acpiphp_max_busnr(bus);
for (pass = 0; pass < 2; pass++) {
list_for_each_entry(dev, &bus->devices, bus_list) {
if (PCI_SLOT(dev->devfn) != slot->device)
@@ -796,8 +918,15 @@ static int enable_device(struct acpiphp_slot *slot)
if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
max = pci_scan_bridge(bus, dev, max, pass);
- if (pass && dev->subordinate)
+ if (pass && dev->subordinate) {
pci_bus_size_bridges(dev->subordinate);
+ func = get_func(slot, dev);
+ if (func) {
+ acpiphp_bus_add(func);
+ /* side effect of get_func */
+ pci_dev_put(dev);
+ }
+ }
}
}
}
@@ -806,8 +935,8 @@ static int enable_device(struct acpiphp_slot *slot)
acpiphp_sanitize_bus(bus);
pci_enable_bridges(bus);
pci_bus_add_devices(bus);
- acpiphp_set_hpp_values(DEVICE_ACPI_HANDLE(&bus->self->dev), bus);
- acpiphp_configure_ioapics(DEVICE_ACPI_HANDLE(&bus->self->dev));
+ acpiphp_set_hpp_values(slot->bridge->handle, bus);
+ acpiphp_configure_ioapics(slot->bridge->handle);
/* associate pci_dev to our representation */
list_for_each (l, &slot->funcs) {
@@ -987,11 +1116,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge)
pci_write_config_byte(dev, PCI_LATENCY_TIMER,
bridge->hpp.latency_timer);
pci_read_config_word(dev, PCI_COMMAND, &pci_cmd);
- if (bridge->hpp.enable_SERR)
+ if (bridge->hpp.enable_serr)
pci_cmd |= PCI_COMMAND_SERR;
else
pci_cmd &= ~PCI_COMMAND_SERR;
- if (bridge->hpp.enable_PERR)
+ if (bridge->hpp.enable_perr)
pci_cmd |= PCI_COMMAND_PARITY;
else
pci_cmd &= ~PCI_COMMAND_PARITY;
@@ -1002,11 +1131,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge)
pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER,
bridge->hpp.latency_timer);
pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl);
- if (bridge->hpp.enable_SERR)
+ if (bridge->hpp.enable_serr)
pci_bctl |= PCI_BRIDGE_CTL_SERR;
else
pci_bctl &= ~PCI_BRIDGE_CTL_SERR;
- if (bridge->hpp.enable_PERR)
+ if (bridge->hpp.enable_perr)
pci_bctl |= PCI_BRIDGE_CTL_PARITY;
else
pci_bctl &= ~PCI_BRIDGE_CTL_PARITY;
@@ -1026,6 +1155,7 @@ static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus)
memset(&bridge, 0, sizeof(bridge));
bridge.handle = handle;
+ bridge.pci_dev = bus->self;
decode_hpp(&bridge);
list_for_each_entry(dev, &bus->devices, bus_list)
program_hpp(dev, &bridge);
@@ -1200,7 +1330,7 @@ static void handle_hotplug_event_bridge(acpi_handle handle, u32 type, void *cont
* handles ACPI event notification on slots
*
*/
-static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
+void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context)
{
struct acpiphp_func *func;
char objname[64];
@@ -1242,41 +1372,13 @@ static void handle_hotplug_event_func(acpi_handle handle, u32 type, void *contex
}
}
-static int is_root_bridge(acpi_handle handle)
-{
- acpi_status status;
- struct acpi_device_info *info;
- struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
- int i;
-
- status = acpi_get_object_info(handle, &buffer);
- if (ACPI_SUCCESS(status)) {
- info = buffer.pointer;
- if ((info->valid & ACPI_VALID_HID) &&
- !strcmp(PCI_ROOT_HID_STRING,
- info->hardware_id.value)) {
- acpi_os_free(buffer.pointer);
- return 1;
- }
- if (info->valid & ACPI_VALID_CID) {
- for (i=0; i < info->compatibility_id.count; i++) {
- if (!strcmp(PCI_ROOT_HID_STRING,
- info->compatibility_id.id[i].value)) {
- acpi_os_free(buffer.pointer);
- return 1;
- }
- }
- }
- }
- return 0;
-}
static acpi_status
find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv)
{
int *count = (int *)context;
- if (is_root_bridge(handle)) {
+ if (acpi_root_bridge(handle)) {
acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY,
handle_hotplug_event_bridge, NULL);
(*count)++;
@@ -1373,26 +1475,6 @@ static int acpiphp_for_each_slot(acpiphp_callback fn, void *data)
}
#endif
-/* search matching slot from id */
-struct acpiphp_slot *get_slot_from_id(int id)
-{
- struct list_head *node;
- struct acpiphp_bridge *bridge;
- struct acpiphp_slot *slot;
-
- list_for_each (node, &bridge_list) {
- bridge = (struct acpiphp_bridge *)node;
- for (slot = bridge->slots; slot; slot = slot->next)
- if (slot->id == id)
- return slot;
- }
-
- /* should never happen! */
- err("%s: no object for id %d\n", __FUNCTION__, id);
- WARN_ON(1);
- return NULL;
-}
-
/**
* acpiphp_enable_slot - power on slot
@@ -1401,7 +1483,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
{
int retval;
- down(&slot->crit_sect);
+ mutex_lock(&slot->crit_sect);
/* wake up all functions */
retval = power_on_slot(slot);
@@ -1413,7 +1495,7 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot)
retval = enable_device(slot);
err_exit:
- up(&slot->crit_sect);
+ mutex_unlock(&slot->crit_sect);
return retval;
}
@@ -1424,7 +1506,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
{
int retval = 0;
- down(&slot->crit_sect);
+ mutex_lock(&slot->crit_sect);
/* unconfigure all functions */
retval = disable_device(slot);
@@ -1437,7 +1519,7 @@ int acpiphp_disable_slot(struct acpiphp_slot *slot)
goto err_exit;
err_exit:
- up(&slot->crit_sect);
+ mutex_unlock(&slot->crit_sect);
return retval;
}
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 30af105271a..037ce4c9168 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
* with the pci_hotplug subsystem.
*/
for (i = first; i <= last; ++i) {
- slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+ slot = kzalloc(sizeof (struct slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof (struct slot));
hotplug_slot =
- kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+ kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
if (!hotplug_slot)
goto error_slot;
- memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
slot->hotplug_slot = hotplug_slot;
- info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
+ info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
if (!info)
goto error_hpslot;
- memset(info, 0, sizeof (struct hotplug_slot_info));
hotplug_slot->info = info;
name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
diff --git a/drivers/pci/hotplug/cpqphp.h b/drivers/pci/hotplug/cpqphp.h
index cb88404c89f..c74e9e37e76 100644
--- a/drivers/pci/hotplug/cpqphp.h
+++ b/drivers/pci/hotplug/cpqphp.h
@@ -32,6 +32,7 @@
#include <linux/interrupt.h>
#include <asm/io.h> /* for read? and write? functions */
#include <linux/delay.h> /* for delays */
+#include <linux/mutex.h>
#define MY_NAME "cpqphp"
@@ -286,7 +287,7 @@ struct event_info {
struct controller {
struct controller *next;
u32 ctrl_int_comp;
- struct semaphore crit_sect; /* critical section semaphore */
+ struct mutex crit_sect; /* critical section mutex */
void __iomem *hpc_reg; /* cookie for our pci controller location */
struct pci_resource *mem_head;
struct pci_resource *p_mem_head;
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index b3659ffccac..9bc1deb8df5 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl,
slot_number = ctrl->first_slot;
while (number_of_slots) {
- slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(struct slot));
- slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
+ slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
hotplug_slot = slot->hotplug_slot;
- memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
hotplug_slot->info =
- kmalloc(sizeof(*(hotplug_slot->info)),
+ kzalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!hotplug_slot->info)
goto error_hpslot;
hotplug_slot_info = hotplug_slot->info;
- memset(hotplug_slot_info, 0,
- sizeof(struct hotplug_slot_info));
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!hotplug_slot->name)
@@ -599,7 +595,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
hp_slot = func->device - ctrl->slot_device_offset;
// Wait for exclusive access to hardware
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (status == 1) {
amber_LED_on (ctrl, hp_slot);
@@ -607,7 +603,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
amber_LED_off (ctrl, hp_slot);
} else {
// Done with exclusive hardware access
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return(1);
}
@@ -617,7 +613,7 @@ cpqhp_set_attention_status(struct controller *ctrl, struct pci_func *func,
wait_for_ctrl_irq (ctrl);
// Done with exclusive hardware access
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return(0);
}
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_disable_device;
}
- ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
+ ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
rc = -ENOMEM;
goto err_disable_device;
}
- memset(ctrl, 0, sizeof(struct controller));
rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
if (rc) {
@@ -1084,7 +1079,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dbg("bus device function rev: %d %d %d %d\n", ctrl->bus,
PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn), ctrl->rev);
- init_MUTEX(&ctrl->crit_sect);
+ mutex_init(&ctrl->crit_sect);
init_waitqueue_head(&ctrl->queue);
/* initialize our threads if they haven't already been started up */
@@ -1223,7 +1218,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
// turn off empty slots here unless command line option "ON" set
// Wait for exclusive access to hardware
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
num_of_slots = readb(ctrl->hpc_reg + SLOT_MASK) & 0x0F;
@@ -1270,12 +1265,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = init_SERR(ctrl);
if (rc) {
err("init_SERR failed\n");
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
goto err_free_irq;
}
// Done with exclusive hardware access
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
cpqhp_create_debugfs_files(ctrl);
diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c
index 771ed34b181..55d2dc7e39c 100644
--- a/drivers/pci/hotplug/cpqphp_ctrl.c
+++ b/drivers/pci/hotplug/cpqphp_ctrl.c
@@ -1282,9 +1282,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
u8 hp_slot;
u8 temp_byte;
u8 adapter_speed;
- u32 index;
u32 rc = 0;
- u32 src = 8;
hp_slot = func->device - ctrl->slot_device_offset;
@@ -1299,7 +1297,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
**********************************/
rc = CARD_FUNCTIONING;
} else {
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
/* turn on board without attaching to the bus */
enable_slot_power (ctrl, hp_slot);
@@ -1333,12 +1331,12 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
if (rc)
return rc;
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
slot_enable (ctrl, hp_slot);
green_LED_blink (ctrl, hp_slot);
@@ -1350,7 +1348,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
/* Wait for ~1 second because of hot plug spec */
long_delay(1*HZ);
@@ -1368,76 +1366,30 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
rc = cpqhp_configure_board(ctrl, func);
- if (rc || src) {
- /* If configuration fails, turn it off
- * Get slot won't work for devices behind
- * bridges, but in this case it will always be
- * called for the "base" bus/dev/func of an
- * adapter. */
+ /* If configuration fails, turn it off
+ * Get slot won't work for devices behind
+ * bridges, but in this case it will always be
+ * called for the "base" bus/dev/func of an
+ * adapter. */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
- amber_LED_on (ctrl, hp_slot);
- green_LED_off (ctrl, hp_slot);
- slot_disable (ctrl, hp_slot);
-
- set_SOGO(ctrl);
-
- /* Wait for SOBS to be unset */
- wait_for_ctrl_irq (ctrl);
-
- up(&ctrl->crit_sect);
-
- if (rc)
- return rc;
- else
- return 1;
- }
-
- func->status = 0;
- func->switch_save = 0x10;
-
- index = 1;
- while (((func = cpqhp_slot_find(func->bus, func->device, index)) != NULL) && !rc) {
- rc |= cpqhp_configure_board(ctrl, func);
- index++;
- }
-
- if (rc) {
- /* If configuration fails, turn it off
- * Get slot won't work for devices behind
- * bridges, but in this case it will always be
- * called for the "base" bus/dev/func of an
- * adapter. */
-
- down(&ctrl->crit_sect);
-
- amber_LED_on (ctrl, hp_slot);
- green_LED_off (ctrl, hp_slot);
- slot_disable (ctrl, hp_slot);
-
- set_SOGO(ctrl);
-
- /* Wait for SOBS to be unset */
- wait_for_ctrl_irq (ctrl);
-
- up(&ctrl->crit_sect);
-
- return rc;
- }
- /* Done configuring so turn LED on full time */
-
- down(&ctrl->crit_sect);
-
- green_LED_on (ctrl, hp_slot);
+ amber_LED_on (ctrl, hp_slot);
+ green_LED_off (ctrl, hp_slot);
+ slot_disable (ctrl, hp_slot);
set_SOGO(ctrl);
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
- rc = 0;
+ mutex_unlock(&ctrl->crit_sect);
+
+ if (rc)
+ return rc;
+ else
+ return 1;
+
} else {
/* Something is wrong
@@ -1445,7 +1397,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
* in this case it will always be called for the "base"
* bus/dev/func of an adapter. */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot);
green_LED_off (ctrl, hp_slot);
@@ -1456,7 +1408,7 @@ static u32 board_replaced(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
}
}
@@ -1488,7 +1440,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
dbg("%s: func->device, slot_offset, hp_slot = %d, %d ,%d\n",
__FUNCTION__, func->device, ctrl->slot_device_offset, hp_slot);
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
/* turn on board without attaching to the bus */
enable_slot_power(ctrl, hp_slot);
@@ -1522,7 +1474,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq(ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
if (rc)
return rc;
@@ -1532,7 +1484,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* turn on board and blink green LED */
dbg("%s: before down\n", __FUNCTION__);
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
dbg("%s: after down\n", __FUNCTION__);
dbg("%s: before slot_enable\n", __FUNCTION__);
@@ -1553,7 +1505,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
dbg("%s: after wait_for_ctrl_irq\n", __FUNCTION__);
dbg("%s: before up\n", __FUNCTION__);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
dbg("%s: after up\n", __FUNCTION__);
/* Wait for ~1 second because of hot plug spec */
@@ -1607,7 +1559,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
cpqhp_resource_sort_and_combine(&(ctrl->bus_head));
if (rc) {
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot);
green_LED_off (ctrl, hp_slot);
@@ -1618,7 +1570,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return rc;
} else {
cpqhp_save_slot_config(ctrl, func);
@@ -1640,7 +1592,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
}
} while (new_slot);
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
green_LED_on (ctrl, hp_slot);
@@ -1649,9 +1601,9 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
} else {
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
amber_LED_on (ctrl, hp_slot);
green_LED_off (ctrl, hp_slot);
@@ -1662,7 +1614,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return rc;
}
@@ -1721,7 +1673,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
func->status = 0x01;
func->configured = 0;
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
green_LED_off (ctrl, hp_slot);
slot_disable (ctrl, hp_slot);
@@ -1736,7 +1688,7 @@ static u32 remove_board(struct pci_func * func, u32 replace_flag, struct control
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
if (!replace_flag && ctrl->add_support) {
while (func) {
@@ -1899,7 +1851,7 @@ static void interrupt_event_handler(struct controller *ctrl)
dbg("button cancel\n");
del_timer(&p_slot->task_event);
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (p_slot->state == BLINKINGOFF_STATE) {
/* slot is on */
@@ -1922,7 +1874,7 @@ static void interrupt_event_handler(struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
}
/*** button Released (No action on press...) */
else if (ctrl->event_queue[loop].event_type == INT_BUTTON_RELEASE) {
@@ -1937,7 +1889,7 @@ static void interrupt_event_handler(struct controller *ctrl)
p_slot->state = BLINKINGON_STATE;
info(msg_button_on, p_slot->number);
}
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
dbg("blink green LED and turn off amber\n");
@@ -1949,7 +1901,7 @@ static void interrupt_event_handler(struct controller *ctrl)
/* Wait for SOBS to be unset */
wait_for_ctrl_irq (ctrl);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
init_timer(&p_slot->task_event);
p_slot->hp_slot = hp_slot;
p_slot->ctrl = ctrl;
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 060d74775d7..71b80c23e8c 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev)
struct hotplug_slot *slot;
int retval = -ENOMEM;
- slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(*slot));
- slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!slot->info)
goto error_slot;
- memset(slot->info, 0, sizeof(struct hotplug_slot_info));
slot->info->power_status = 1;
slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct pci_bus *bus)
{
unsigned int devfn;
struct pci_dev *dev;
- dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
if (!dev)
return;
- memset(dev, 0, sizeof(dev));
dev->bus = (struct pci_bus*)bus;
dev->sysdata = bus->sysdata;
for (devfn = 0; devfn < 0x100; devfn += 8) {
diff --git a/drivers/pci/hotplug/ibmphp.h b/drivers/pci/hotplug/ibmphp.h
index c22e0284d7b..dba6d8ca9bd 100644
--- a/drivers/pci/hotplug/ibmphp.h
+++ b/drivers/pci/hotplug/ibmphp.h
@@ -406,8 +406,6 @@ extern void ibmphp_hpc_stop_poll_thread (void);
//----------------------------------------------------------------------------
// HPC return codes
//----------------------------------------------------------------------------
-#define FALSE 0x00
-#define TRUE 0x01
#define HPC_ERROR 0xFF
//-----------------------------------------------------------------------------
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index dc59da675c0..e13d5b87241 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_slot *hs)
goto error_power;
}
- slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+ slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
if (!slot_cur->func) {
/* We cannot do update_slot_info here, since no memory for
* kmalloc n.e.ways, and update_slot_info allocates some */
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_slot *hs)
rc = -ENOMEM;
goto error_power;
}
- memset(slot_cur->func, 0, sizeof(struct pci_func));
slot_cur->func->busno = slot_cur->bus;
slot_cur->func->device = slot_cur->device;
for (i = 0; i < 4; i++)
@@ -1240,9 +1239,9 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)
}
flag = slot_cur->flag;
- slot_cur->flag = TRUE;
+ slot_cur->flag = 1;
- if (flag == TRUE) {
+ if (flag == 1) {
rc = validate(slot_cur, DISABLE);
/* checking if powered off already & valid slot # */
if (rc)
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)
if (slot_cur->func == NULL) {
/* We need this for fncs's that were there on bootup */
- slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+ slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
if (!slot_cur->func) {
err("out of system memory\n");
rc = -ENOMEM;
goto error;
}
- memset(slot_cur->func, 0, sizeof(struct pci_func));
slot_cur->func->busno = slot_cur->bus;
slot_cur->func->device = slot_cur->device;
}
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index aea1187c73a..05e4f5a1927 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -72,13 +72,7 @@ static int ebda_rio_table (void);
static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void)
{
- struct ebda_hpc_list *list;
-
- list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL);
- if (!list)
- return NULL;
- memset (list, 0, sizeof (*list));
- return list;
+ return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL);
}
static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count)
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count)
struct ebda_hpc_slot *slots;
struct ebda_hpc_bus *buses;
- controller = kmalloc (sizeof (struct controller), GFP_KERNEL);
+ controller = kzalloc(sizeof(struct controller), GFP_KERNEL);
if (!controller)
goto error;
- memset (controller, 0, sizeof (*controller));
- slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL);
+ slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL);
if (!slots)
goto error_contr;
- memset (slots, 0, sizeof (*slots) * slot_count);
controller->slots = slots;
- buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL);
+ buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL);
if (!buses)
goto error_slots;
- memset (buses, 0, sizeof (*buses) * bus_count);
controller->buses = buses;
return controller;
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller)
static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void)
{
- struct ebda_rsrc_list *list;
-
- list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL);
- if (!list)
- return NULL;
- memset (list, 0, sizeof (*list));
- return list;
+ return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL);
}
static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void)
{
- struct ebda_pci_rsrc *resource;
-
- resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL);
- if (!resource)
- return NULL;
- memset (resource, 0, sizeof (*resource));
- return resource;
+ return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL);
}
static void __init print_bus_info (void)
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void)
debug ("now enter io table ---\n");
debug ("rio blk id: %x\n", blk_id);
- rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL);
+ rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL);
if (!rio_table_ptr)
return -ENOMEM;
- memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) );
rio_table_ptr->ver_num = readb (io_mem + offset);
rio_table_ptr->scal_count = readb (io_mem + offset + 1);
rio_table_ptr->riodev_count = readb (io_mem + offset + 2);
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void)
// we do concern about rio details
for (i = 0; i < rio_table_ptr->riodev_count; i++) {
- rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL);
+ rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL);
if (!rio_detail_ptr)
return -ENOMEM;
- memset (rio_detail_ptr, 0, sizeof (struct rio_detail));
rio_detail_ptr->rio_node_id = readb (io_mem + offset);
rio_detail_ptr->bbar = readl (io_mem + offset + 1);
rio_detail_ptr->rio_type = readb (io_mem + offset + 5);
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void)
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num);
if (!opt_rio_ptr) {
- opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL);
+ opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
if (!opt_rio_ptr)
return -ENOMEM;
- memset (opt_rio_ptr, 0, sizeof (struct opt_rio));
opt_rio_ptr->rio_type = rio_detail_ptr->rio_type;
opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num;
opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void)
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num);
if (!opt_rio_lo_ptr) {
- opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL);
+ opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
if (!opt_rio_lo_ptr)
return -ENOMEM;
- memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo));
opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type;
opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num;
opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void)
bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num);
if (!bus_info_ptr2) {
- bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL);
+ bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
if (!bus_info_ptr1) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
- memset (bus_info_ptr1, 0, sizeof (struct bus_info));
bus_info_ptr1->slot_min = slot_ptr->slot_num;
bus_info_ptr1->slot_max = slot_ptr->slot_num;
bus_info_ptr1->slot_count += 1;
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (void)
// register slots with hpc core as well as create linked list of ibm slot
for (index = 0; index < hpc_ptr->slot_count; index++) {
- hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
+ hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
if (!hp_slot_ptr) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
- memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
- hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!hp_slot_ptr->info) {
rc = -ENOMEM;
goto error_no_hp_info;
}
- memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
if (!hp_slot_ptr->name) {
@@ -966,14 +938,13 @@ static int __init ebda_rsrc_controller (void)
goto error_no_hp_name;
}
- tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
+ tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
if (!tmp_slot) {
rc = -ENOMEM;
goto error_no_slot;
}
- memset(tmp_slot, 0, sizeof(*tmp_slot));
- tmp_slot->flag = TRUE;
+ tmp_slot->flag = 1;
tmp_slot->capabilities = hpc_ptr->slots[index].slot_cap;
if ((hpc_ptr->slots[index].slot_cap & EBDA_SLOT_133_MAX) == EBDA_SLOT_133_MAX)
diff --git a/drivers/pci/hotplug/ibmphp_hpc.c b/drivers/pci/hotplug/ibmphp_hpc.c
index 1a3eb8d3d4c..c3ac98a0a6a 100644
--- a/drivers/pci/hotplug/ibmphp_hpc.c
+++ b/drivers/pci/hotplug/ibmphp_hpc.c
@@ -34,9 +34,11 @@
#include <linux/pci.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
+#include <linux/mutex.h>
+
#include "ibmphp.h"
-static int to_debug = FALSE;
+static int to_debug = 0;
#define debug_polling(fmt, arg...) do { if (to_debug) debug (fmt, arg); } while (0)
//----------------------------------------------------------------------------
@@ -93,15 +95,15 @@ static int to_debug = FALSE;
//----------------------------------------------------------------------------
// macro utilities
//----------------------------------------------------------------------------
-// if bits 20,22,25,26,27,29,30 are OFF return TRUE
-#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? FALSE : TRUE))
+// if bits 20,22,25,26,27,29,30 are OFF return 1
+#define HPC_I2CSTATUS_CHECK(s) ((u8)((s & 0x00000A76) ? 0 : 1))
//----------------------------------------------------------------------------
// global variables
//----------------------------------------------------------------------------
static int ibmphp_shutdown;
static int tid_poll;
-static struct semaphore sem_hpcaccess; // lock access to HPC
+static struct mutex sem_hpcaccess; // lock access to HPC
static struct semaphore semOperations; // lock all operations and
// access to data structures
static struct semaphore sem_exit; // make sure polling thread goes away
@@ -131,11 +133,11 @@ void __init ibmphp_hpc_initvars (void)
{
debug ("%s - Entry\n", __FUNCTION__);
- init_MUTEX (&sem_hpcaccess);
+ mutex_init(&sem_hpcaccess);
init_MUTEX (&semOperations);
init_MUTEX_LOCKED (&sem_exit);
- to_debug = FALSE;
- ibmphp_shutdown = FALSE;
+ to_debug = 0;
+ ibmphp_shutdown = 0;
tid_poll = 0;
debug ("%s - Exit\n", __FUNCTION__);
@@ -737,21 +739,21 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
// check controller is still not working on the command
//--------------------------------------------------------------------
timeout = CMD_COMPLETE_TOUT_SEC;
- done = FALSE;
+ done = 0;
while (!done) {
rc = hpc_wait_ctlr_notworking (HPC_CTLR_WORKING_TOUT, ctlr_ptr, wpg_bbar,
&status);
if (!rc) {
if (NEEDTOCHECK_CMDSTATUS (cmd)) {
if (CTLR_FINISHED (status) == HPC_CTLR_FINISHED_YES)
- done = TRUE;
+ done = 1;
} else
- done = TRUE;
+ done = 1;
}
if (!done) {
msleep(1000);
if (timeout < 1) {
- done = TRUE;
+ done = 1;
err ("%s - Error command complete timeout\n", __FUNCTION__);
rc = -EFAULT;
} else
@@ -778,7 +780,7 @@ int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
*---------------------------------------------------------------------*/
static void get_hpc_access (void)
{
- down (&sem_hpcaccess);
+ mutex_lock(&sem_hpcaccess);
}
/*----------------------------------------------------------------------
@@ -786,7 +788,7 @@ static void get_hpc_access (void)
*---------------------------------------------------------------------*/
void free_hpc_access (void)
{
- up (&sem_hpcaccess);
+ mutex_unlock(&sem_hpcaccess);
}
/*----------------------------------------------------------------------
@@ -797,7 +799,7 @@ void free_hpc_access (void)
void ibmphp_lock_operations (void)
{
down (&semOperations);
- to_debug = TRUE;
+ to_debug = 1;
}
/*----------------------------------------------------------------------
@@ -807,7 +809,7 @@ void ibmphp_unlock_operations (void)
{
debug ("%s - Entry\n", __FUNCTION__);
up (&semOperations);
- to_debug = FALSE;
+ to_debug = 0;
debug ("%s - Exit\n", __FUNCTION__);
}
@@ -935,40 +937,40 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
{
u8 status;
int rc = 0;
- u8 disable = FALSE;
- u8 update = FALSE;
+ u8 disable = 0;
+ u8 update = 0;
debug ("process_changeinstatus - Entry pslot[%p], poldslot[%p]\n", pslot, poldslot);
// bit 0 - HPC_SLOT_POWER
if ((pslot->status & 0x01) != (poldslot->status & 0x01))
- update = TRUE;
+ update = 1;
// bit 1 - HPC_SLOT_CONNECT
// ignore
// bit 2 - HPC_SLOT_ATTN
if ((pslot->status & 0x04) != (poldslot->status & 0x04))
- update = TRUE;
+ update = 1;
// bit 3 - HPC_SLOT_PRSNT2
// bit 4 - HPC_SLOT_PRSNT1
if (((pslot->status & 0x08) != (poldslot->status & 0x08))
|| ((pslot->status & 0x10) != (poldslot->status & 0x10)))
- update = TRUE;
+ update = 1;
// bit 5 - HPC_SLOT_PWRGD
if ((pslot->status & 0x20) != (poldslot->status & 0x20))
// OFF -> ON: ignore, ON -> OFF: disable slot
if ((poldslot->status & 0x20) && (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status)))
- disable = TRUE;
+ disable = 1;
// bit 6 - HPC_SLOT_BUS_SPEED
// ignore
// bit 7 - HPC_SLOT_LATCH
if ((pslot->status & 0x80) != (poldslot->status & 0x80)) {
- update = TRUE;
+ update = 1;
// OPEN -> CLOSE
if (pslot->status & 0x80) {
if (SLOT_PWRGD (pslot->status)) {
@@ -977,7 +979,7 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
msleep(1000);
rc = ibmphp_hpc_readslot (pslot, READ_SLOTSTATUS, &status);
if (SLOT_PWRGD (status))
- update = TRUE;
+ update = 1;
else // overwrite power in pslot to OFF
pslot->status &= ~HPC_SLOT_POWER;
}
@@ -985,17 +987,17 @@ static int process_changeinstatus (struct slot *pslot, struct slot *poldslot)
// CLOSE -> OPEN
else if ((SLOT_PWRGD (poldslot->status) == HPC_SLOT_PWRGD_GOOD)
&& (SLOT_CONNECT (poldslot->status) == HPC_SLOT_CONNECTED) && (SLOT_PRESENT (poldslot->status))) {
- disable = TRUE;
+ disable = 1;
}
// else - ignore
}
// bit 4 - HPC_SLOT_BLINK_ATTN
if ((pslot->ext_status & 0x08) != (poldslot->ext_status & 0x08))
- update = TRUE;
+ update = 1;
if (disable) {
debug ("process_changeinstatus - disable slot\n");
- pslot->flag = FALSE;
+ pslot->flag = 0;
rc = ibmphp_do_disable_slot (pslot);
}
@@ -1100,7 +1102,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
{
debug ("%s - Entry\n", __FUNCTION__);
- ibmphp_shutdown = TRUE;
+ ibmphp_shutdown = 1;
debug ("before locking operations \n");
ibmphp_lock_operations ();
debug ("after locking operations \n");
@@ -1134,7 +1136,7 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
u8 * pstatus)
{
int rc = 0;
- u8 done = FALSE;
+ u8 done = 0;
debug_polling ("hpc_wait_ctlr_notworking - Entry timeout[%d]\n", timeout);
@@ -1142,14 +1144,14 @@ static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, v
*pstatus = ctrl_read (ctlr_ptr, wpg_bbar, WPG_CTLR_INDEX);
if (*pstatus == HPC_ERROR) {
rc = HPC_ERROR;
- done = TRUE;
+ done = 1;
}
if (CTLR_WORKING (*pstatus) == HPC_CTLR_WORKING_NO)
- done = TRUE;
+ done = 1;
if (!done) {
msleep(1000);
if (timeout < 1) {
- done = TRUE;
+ done = 1;
err ("HPCreadslot - Error ctlr timeout\n");
rc = HPC_ERROR;
} else
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 155133fe5c1..d87a9e3eaee 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cleanup_count = 6;
goto error;
}
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = cur_func->busno;
newfunc->device = device;
cur_func->next = newfunc;
@@ -200,15 +199,14 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
}
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
- flag = FALSE;
+ flag = 0;
for (i = 0; i < 32; i++) {
if (func->devices[i]) {
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = sec_number;
newfunc->device = (u8) i;
for (j = 0; j < 4; j++)
@@ -228,16 +226,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cleanup_count = 2;
goto error;
}
- flag = TRUE;
+ flag = 1;
}
}
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = cur_func->busno;
newfunc->device = device;
for (j = 0; j < 4; j++)
@@ -275,16 +272,15 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cur_func->busno, device, function);
pci_bus_read_config_byte (ibmphp_pci_bus, devfn, PCI_SECONDARY_BUS, &sec_number);
debug ("after configuring bridge..., sec_number = %x\n", sec_number);
- flag = FALSE;
+ flag = 0;
for (i = 0; i < 32; i++) {
if (func->devices[i]) {
debug ("inside for loop, device is %x\n", i);
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err (" out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = sec_number;
newfunc->device = (u8) i;
for (j = 0; j < 4; j++)
@@ -305,7 +301,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cleanup_count = 2;
goto error;
}
- flag = TRUE;
+ flag = 1;
}
}
@@ -405,13 +401,12 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in IO %x, count %d\n", len[count], count);
- io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!io[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io[count], 0, sizeof (struct resource_node));
io[count]->type = IO;
io[count]->busno = func->busno;
io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -444,29 +439,27 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in PFMEM %x, count %d\n", len[count], count);
- pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!pfmem[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem[count], 0, sizeof (struct resource_node));
pfmem[count]->type = PFMEM;
pfmem[count]->busno = func->busno;
pfmem[count]->devfunc = PCI_DEVFN(func->device,
func->function);
pfmem[count]->len = len[count];
- pfmem[count]->fromMem = FALSE;
+ pfmem[count]->fromMem = 0;
if (ibmphp_check_resource (pfmem[count], 0) == 0) {
ibmphp_add_resource (pfmem[count]);
func->pfmem[count] = pfmem[count];
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
kfree (pfmem[count]);
return -ENOMEM;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = pfmem[count]->busno;
mem_tmp->devfunc = pfmem[count]->devfunc;
@@ -474,7 +467,7 @@ static int configure_device (struct pci_func *func)
debug ("there's no pfmem... going into mem.\n");
if (ibmphp_check_resource (mem_tmp, 0) == 0) {
ibmphp_add_resource (mem_tmp);
- pfmem[count]->fromMem = TRUE;
+ pfmem[count]->fromMem = 1;
pfmem[count]->rangeno = mem_tmp->rangeno;
pfmem[count]->start = mem_tmp->start;
pfmem[count]->end = mem_tmp->end;
@@ -512,12 +505,11 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in Mem %x, count %d\n", len[count], count);
- mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem[count], 0, sizeof (struct resource_node));
mem[count]->type = MEM;
mem[count]->busno = func->busno;
mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -579,11 +571,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
u16 pfmem_base;
u32 bar[2];
u32 len[2];
- u8 flag_io = FALSE;
- u8 flag_mem = FALSE;
- u8 flag_pfmem = FALSE;
- u8 need_io_upper = FALSE;
- u8 need_pfmem_upper = FALSE;
+ u8 flag_io = 0;
+ u8 flag_mem = 0;
+ u8 flag_pfmem = 0;
+ u8 need_io_upper = 0;
+ u8 need_pfmem_upper = 0;
struct res_needed *amount_needed = NULL;
struct resource_node *io = NULL;
struct resource_node *bus_io[2] = {NULL, NULL};
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in IO = %x\n", len[count]);
- bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_io[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_io[count], 0, sizeof (struct resource_node));
bus_io[count]->type = IO;
bus_io[count]->busno = func->busno;
bus_io[count]->devfunc = PCI_DEVFN(func->device,
@@ -711,37 +702,35 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in PFMEM = %x\n", len[count]);
- bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_pfmem[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_pfmem[count], 0, sizeof (struct resource_node));
bus_pfmem[count]->type = PFMEM;
bus_pfmem[count]->busno = func->busno;
bus_pfmem[count]->devfunc = PCI_DEVFN(func->device,
func->function);
bus_pfmem[count]->len = len[count];
- bus_pfmem[count]->fromMem = FALSE;
+ bus_pfmem[count]->fromMem = 0;
if (ibmphp_check_resource (bus_pfmem[count], 0) == 0) {
ibmphp_add_resource (bus_pfmem[count]);
func->pfmem[count] = bus_pfmem[count];
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = bus_pfmem[count]->busno;
mem_tmp->devfunc = bus_pfmem[count]->devfunc;
mem_tmp->len = bus_pfmem[count]->len;
if (ibmphp_check_resource (mem_tmp, 0) == 0) {
ibmphp_add_resource (mem_tmp);
- bus_pfmem[count]->fromMem = TRUE;
+ bus_pfmem[count]->fromMem = 1;
bus_pfmem[count]->rangeno = mem_tmp->rangeno;
ibmphp_add_pfmem_from_mem (bus_pfmem[count]);
func->pfmem[count] = bus_pfmem[count];
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in Memory is %x\n", len[count]);
- bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_mem[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_mem[count], 0, sizeof (struct resource_node));
bus_mem[count]->type = MEM;
bus_mem[count]->busno = func->busno;
bus_mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -838,17 +826,16 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
if (!amount_needed->io) {
debug ("it doesn't want IO?\n");
- flag_io = TRUE;
+ flag_io = 1;
} else {
debug ("it wants %x IO behind the bridge\n", amount_needed->io);
- io = kmalloc(sizeof(*io), GFP_KERNEL);
+ io = kzalloc(sizeof(*io), GFP_KERNEL);
if (!io) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (io, 0, sizeof (struct resource_node));
io->type = IO;
io->busno = func->busno;
io->devfunc = PCI_DEVFN(func->device, func->function);
@@ -856,71 +843,68 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
if (ibmphp_check_resource (io, 1) == 0) {
debug ("were we able to add io\n");
ibmphp_add_resource (io);
- flag_io = TRUE;
+ flag_io = 1;
}
}
if (!amount_needed->mem) {
debug ("it doesn't want n.e.memory?\n");
- flag_mem = TRUE;
+ flag_mem = 1;
} else {
debug ("it wants %x memory behind the bridge\n", amount_needed->mem);
- mem = kmalloc(sizeof(*mem), GFP_KERNEL);
+ mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = func->busno;
mem->devfunc = PCI_DEVFN(func->device, func->function);
mem->len = amount_needed->mem;
if (ibmphp_check_resource (mem, 1) == 0) {
ibmphp_add_resource (mem);
- flag_mem = TRUE;
+ flag_mem = 1;
debug ("were we able to add mem\n");
}
}
if (!amount_needed->pfmem) {
debug ("it doesn't want n.e.pfmem mem?\n");
- flag_pfmem = TRUE;
+ flag_pfmem = 1;
} else {
debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
- pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL);
+ pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
if (!pfmem) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (pfmem, 0, sizeof (struct resource_node));
pfmem->type = PFMEM;
pfmem->busno = func->busno;
pfmem->devfunc = PCI_DEVFN(func->device, func->function);
pfmem->len = amount_needed->pfmem;
- pfmem->fromMem = FALSE;
+ pfmem->fromMem = 0;
if (ibmphp_check_resource (pfmem, 1) == 0) {
ibmphp_add_resource (pfmem);
- flag_pfmem = TRUE;
+ flag_pfmem = 1;
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = pfmem->busno;
mem_tmp->devfunc = pfmem->devfunc;
mem_tmp->len = pfmem->len;
if (ibmphp_check_resource (mem_tmp, 1) == 0) {
ibmphp_add_resource (mem_tmp);
- pfmem->fromMem = TRUE;
+ pfmem->fromMem = 1;
pfmem->rangeno = mem_tmp->rangeno;
ibmphp_add_pfmem_from_mem (pfmem);
- flag_pfmem = TRUE;
+ flag_pfmem = 1;
}
}
}
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
*/
bus = ibmphp_find_res_bus (sec_number);
if (!bus) {
- bus = kmalloc(sizeof(*bus), GFP_KERNEL);
+ bus = kzalloc(sizeof(*bus), GFP_KERNEL);
if (!bus) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus, 0, sizeof (struct bus_node));
bus->busno = sec_number;
debug ("b4 adding new bus\n");
rc = add_new_bus (bus, io, mem, pfmem, func->busno);
@@ -967,11 +950,11 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
if ((io_base & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) {
debug ("io 32\n");
- need_io_upper = TRUE;
+ need_io_upper = 1;
}
if ((pfmem_base & PCI_PREF_RANGE_TYPE_MASK) == PCI_PREF_RANGE_TYPE_64) {
debug ("pfmem 64\n");
- need_pfmem_upper = TRUE;
+ need_pfmem_upper = 1;
}
if (bus->noIORanges) {
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
};
struct res_needed *amount;
- amount = kmalloc(sizeof(*amount), GFP_KERNEL);
+ amount = kzalloc(sizeof(*amount), GFP_KERNEL);
if (amount == NULL)
return NULL;
- memset (amount, 0, sizeof (struct res_needed));
ibmphp_pci_bus->number = busno;
@@ -1137,7 +1119,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
debug ("hdr_type behind the bridge is %x\n", hdr_type);
if (hdr_type & PCI_HEADER_TYPE_BRIDGE) {
err ("embedded bridges not supported for hot-plugging.\n");
- amount->not_correct = TRUE;
+ amount->not_correct = 1;
return amount;
}
@@ -1145,12 +1127,12 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
if (class == PCI_CLASS_NOT_DEFINED_VGA) {
err ("The device %x is VGA compatible and as is not supported for hot plugging. "
"Please choose another device.\n", device);
- amount->not_correct = TRUE;
+ amount->not_correct = 1;
return amount;
} else if (class == PCI_CLASS_DISPLAY_VGA) {
err ("The device %x is not supported for hot plugging. "
"Please choose another device.\n", device);
- amount->not_correct = TRUE;
+ amount->not_correct = 1;
return amount;
}
@@ -1210,9 +1192,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
} /* end for */
if (!howmany)
- amount->not_correct = TRUE;
+ amount->not_correct = 1;
else
- amount->not_correct = FALSE;
+ amount->not_correct = 0;
if ((amount->io) && (amount->io < IOBRIDGE))
amount->io = IOBRIDGE;
if ((amount->mem) && (amount->mem < MEMBRIDGE))
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
list_add (&bus->bus_list, &cur_bus->bus_list);
}
if (io) {
- io_range = kmalloc(sizeof(*io_range), GFP_KERNEL);
+ io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
if (!io_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io_range, 0, sizeof (struct range_node));
io_range->start = io->start;
io_range->end = io->end;
io_range->rangeno = 1;
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeIO = io_range;
}
if (mem) {
- mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL);
+ mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
if (!mem_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem_range, 0, sizeof (struct range_node));
mem_range->start = mem->start;
mem_range->end = mem->end;
mem_range->rangeno = 1;
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeMem = mem_range;
}
if (pfmem) {
- pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL);
+ pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
if (!pfmem_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem_range, 0, sizeof (struct range_node));
pfmem_range->start = pfmem->start;
pfmem_range->end = pfmem->end;
pfmem_range->rangeno = 1;
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index 9c224c94d69..5636b1ac2a2 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8
return NULL;
}
- newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+ newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
if (!newbus) {
err ("out of system memory\n");
return NULL;
}
- memset (newbus, 0, sizeof (struct bus_node));
if (flag)
newbus->busno = busno;
else
@@ -79,12 +78,11 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * cur
return NULL;
}
- rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!rs) {
err ("out of system memory\n");
return NULL;
}
- memset (rs, 0, sizeof (struct resource_node));
rs->busno = curr->bus_num;
rs->devfunc = curr->dev_fun;
rs->start = curr->start_addr;
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
u8 num_ranges = 0;
if (first_bus) {
- newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+ newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
if (!newbus) {
err ("out of system memory.\n");
return -ENOMEM;
}
- memset (newbus, 0, sizeof (struct bus_node));
newbus->busno = curr->bus_num;
} else {
newbus = *new_bus;
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
}
}
- newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!newrange) {
if (first_bus)
kfree (newbus);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newrange, 0, sizeof (struct range_node));
newrange->start = curr->start_addr;
newrange->end = curr->end_addr;
@@ -329,7 +325,7 @@ int __init ibmphp_rsrc_init (void)
if (!new_pfmem)
return -ENOMEM;
new_pfmem->type = PFMEM;
- new_pfmem->fromMem = FALSE;
+ new_pfmem->fromMem = 0;
if (ibmphp_add_resource (new_pfmem) < 0) {
newbus = alloc_error_bus (curr, 0, 0);
if (!newbus)
@@ -466,7 +462,7 @@ static int add_range (int type, struct range_node *range, struct bus_node *bus_c
static void update_resources (struct bus_node *bus_cur, int type, int rangeno)
{
struct resource_node *res = NULL;
- u8 eol = FALSE; /* end of list indicator */
+ u8 eol = 0; /* end of list indicator */
switch (type) {
case MEM:
@@ -492,7 +488,7 @@ static void update_resources (struct bus_node *bus_cur, int type, int rangeno)
else if (res->nextRange)
res = res->nextRange;
else {
- eol = TRUE;
+ eol = 1;
break;
}
}
@@ -983,7 +979,7 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
int noranges = 0;
u32 tmp_start; /* this is to make sure start address is divisible by the length needed */
u32 tmp_divide;
- u8 flag = FALSE;
+ u8 flag = 0;
if (!res)
return -EINVAL;
@@ -1050,17 +1046,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if ((range->start % tmp_divide) == 0) {
/* just perfect, starting address is divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = range->start;
} else {
/* Needs adjusting */
tmp_start = range->start;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1089,17 +1085,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if (((res_cur->end + 1) % tmp_divide) == 0) {
/* just perfect, starting address is divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = res_cur->end + 1;
} else {
/* Needs adjusting */
tmp_start = res_cur->end + 1;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = range->end - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1127,17 +1123,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if ((len_tmp < len_cur) || (len_cur == 0)) {
if ((range->start % tmp_divide) == 0) {
/* just perfect, starting address is divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = range->start;
} else {
/* Needs adjusting */
tmp_start = range->start;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1162,17 +1158,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if ((len_tmp < len_cur) || (len_cur == 0)) {
if (((res_prev->end + 1) % tmp_divide) == 0) {
/* just perfect, starting address's divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = res_prev->end + 1;
} else {
/* Needs adjusting */
tmp_start = res_prev->end + 1;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = res_cur->start - 1 - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1221,17 +1217,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if ((len_tmp < len_cur) || (len_cur == 0)) {
if ((range->start % tmp_divide) == 0) {
/* just perfect, starting address's divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = range->start;
} else {
/* Needs adjusting */
tmp_start = range->start;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = range->end - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1285,17 +1281,17 @@ int ibmphp_check_resource (struct resource_node *res, u8 bridge)
if ((len_tmp < len_cur) || (len_cur == 0)) {
if ((range->start % tmp_divide) == 0) {
/* just perfect, starting address's divisible by length */
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = range->start;
} else {
/* Needs adjusting */
tmp_start = range->start;
- flag = FALSE;
+ flag = 0;
while ((len_tmp = range->end - tmp_start) >= res->len) {
if ((tmp_start % tmp_divide) == 0) {
- flag = TRUE;
+ flag = 1;
len_cur = len_tmp;
start_cur = tmp_start;
break;
@@ -1688,7 +1684,7 @@ static int __init once_over (void)
bus_cur = list_entry (tmp, struct bus_node, bus_list);
if ((!bus_cur->rangePFMem) && (bus_cur->firstPFMem)) {
for (pfmem_cur = bus_cur->firstPFMem, pfmem_prev = NULL; pfmem_cur; pfmem_prev = pfmem_cur, pfmem_cur = pfmem_cur->next) {
- pfmem_cur->fromMem = TRUE;
+ pfmem_cur->fromMem = 1;
if (pfmem_prev)
pfmem_prev->next = pfmem_cur->next;
else
@@ -1705,12 +1701,11 @@ static int __init once_over (void)
bus_cur->firstPFMemFromMem = pfmem_cur;
- mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = pfmem_cur->busno;
mem->devfunc = pfmem_cur->devfunc;
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
end_address |= (upper_io_end << 16);
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfff;
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) {
- io = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ io = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!io) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io, 0, sizeof (struct resource_node));
io->type = IO;
io->busno = bus_cur->busno;
io->devfunc = ((device << 3) | (function & 0x7));
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfffff;
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) {
- mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = bus_cur->busno;
mem->devfunc = ((device << 3) | (function & 0x7));
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfffff;
@@ -2127,20 +2117,19 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) {
- pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!pfmem) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem, 0, sizeof (struct resource_node));
pfmem->type = PFMEM;
pfmem->busno = bus_cur->busno;
pfmem->devfunc = ((device << 3) | (function & 0x7));
pfmem->start = start_address;
pfmem->end = end_address + 0xfffff;
pfmem->len = pfmem->end - pfmem->start + 1;
- pfmem->fromMem = FALSE;
+ pfmem->fromMem = 0;
ibmphp_add_resource (pfmem);
}
diff --git a/drivers/pci/hotplug/pci_hotplug.h b/drivers/pci/hotplug/pci_hotplug.h
index 88d44f7fef2..eb0d01d4723 100644
--- a/drivers/pci/hotplug/pci_hotplug.h
+++ b/drivers/pci/hotplug/pci_hotplug.h
@@ -176,5 +176,21 @@ extern int pci_hp_change_slot_info (struct hotplug_slot *slot,
struct hotplug_slot_info *info);
extern struct subsystem pci_hotplug_slots_subsys;
+struct hotplug_params {
+ u8 cache_line_size;
+ u8 latency_timer;
+ u8 enable_serr;
+ u8 enable_perr;
+};
+
+#ifdef CONFIG_ACPI
+#include <acpi/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+extern acpi_status acpi_run_oshp(acpi_handle handle);
+extern acpi_status acpi_get_hp_params_from_firmware(struct pci_dev *dev,
+ struct hotplug_params *hpp);
+int acpi_root_bridge(acpi_handle handle);
+#endif
#endif
diff --git a/drivers/pci/hotplug/pciehp.h b/drivers/pci/hotplug/pciehp.h
index 0aac6a61337..92c1f0f1e1a 100644
--- a/drivers/pci/hotplug/pciehp.h
+++ b/drivers/pci/hotplug/pciehp.h
@@ -34,6 +34,7 @@
#include <linux/delay.h>
#include <linux/sched.h> /* signal_pending() */
#include <linux/pcieport_if.h>
+#include <linux/mutex.h>
#include "pci_hotplug.h"
#define MY_NAME "pciehp"
@@ -49,12 +50,6 @@ extern int pciehp_force;
#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
-struct hotplug_params {
- u8 cache_line_size;
- u8 latency_timer;
- u8 enable_serr;
- u8 enable_perr;
-};
struct slot {
struct slot *next;
@@ -96,7 +91,7 @@ struct php_ctlr_state_s {
#define MAX_EVENTS 10
struct controller {
struct controller *next;
- struct semaphore crit_sect; /* critical section semaphore */
+ struct mutex crit_sect; /* critical section mutex */
struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
int num_slots; /* Number of slots on ctlr */
int slot_num_inc; /* 1 or -1 */
@@ -191,9 +186,6 @@ extern u8 pciehp_handle_power_fault (u8 hp_slot, void *inst_id);
/* pci functions */
extern int pciehp_configure_device (struct slot *p_slot);
extern int pciehp_unconfigure_device (struct slot *p_slot);
-extern int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev);
-extern void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp);
@@ -285,4 +277,19 @@ struct hpc_ops {
int (*check_lnk_status) (struct controller *ctrl);
};
+
+#ifdef CONFIG_ACPI
+#define pciehp_get_hp_hw_control_from_firmware(dev) \
+ pciehp_acpi_get_hp_hw_control_from_firmware(dev)
+static inline int pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
+ struct hotplug_params *hpp)
+{
+ if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp)))
+ return -ENODEV;
+ return 0;
+}
+#else
+#define pciehp_get_hp_hw_control_from_firmware(dev) 0
+#define pciehp_get_hp_params_from_firmware(dev, hpp) (-ENODEV)
+#endif /* CONFIG_ACPI */
#endif /* _PCIEHP_H */
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 4fb569018a2..601cf9045b2 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -117,27 +117,23 @@ static int init_slots(struct controller *ctrl)
slot_number = ctrl->first_slot;
while (number_of_slots) {
- slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(struct slot));
slot->hotplug_slot =
- kmalloc(sizeof(*(slot->hotplug_slot)),
+ kzalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
hotplug_slot = slot->hotplug_slot;
- memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
hotplug_slot->info =
- kmalloc(sizeof(*(hotplug_slot->info)),
+ kzalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!hotplug_slot->info)
goto error_hpslot;
hotplug_slot_info = hotplug_slot->info;
- memset(hotplug_slot_info, 0,
- sizeof(struct hotplug_slot_info));
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!hotplug_slot->name)
goto error_info;
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
u8 value;
struct pci_dev *pdev;
- ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
goto err_out_none;
}
- memset(ctrl, 0, sizeof(struct controller));
pdev = dev->port;
ctrl->pci_dev = pdev;
@@ -439,7 +434,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
}
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
t_slot->hpc_ops->get_adapter_status(t_slot, &value); /* Check if slot is occupied */
@@ -447,7 +442,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
rc = t_slot->hpc_ops->power_off_slot(t_slot); /* Power off slot if not occupied*/
if (rc) {
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
goto err_out_free_ctrl_slot;
} else
/* Wait for the command to complete */
@@ -455,7 +450,7 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return 0;
diff --git a/drivers/pci/hotplug/pciehp_ctrl.c b/drivers/pci/hotplug/pciehp_ctrl.c
index 83c4b865718..33d19876835 100644
--- a/drivers/pci/hotplug/pciehp_ctrl.c
+++ b/drivers/pci/hotplug/pciehp_ctrl.c
@@ -229,13 +229,13 @@ u8 pciehp_handle_power_fault(u8 hp_slot, void *inst_id)
static void set_slot_off(struct controller *ctrl, struct slot * pslot)
{
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
/* turn off slot, turn on Amber LED, turn off Green LED if supported*/
if (POWER_CTRL(ctrl->ctrlcap)) {
if (pslot->hpc_ops->power_off_slot(pslot)) {
err("%s: Issue of Slot Power Off command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return;
}
wait_for_ctrl_irq (ctrl);
@@ -249,14 +249,14 @@ static void set_slot_off(struct controller *ctrl, struct slot * pslot)
if (ATTN_LED(ctrl->ctrlcap)) {
if (pslot->hpc_ops->set_attention_status(pslot, 1)) {
err("%s: Issue of Set Attention Led command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return;
}
wait_for_ctrl_irq (ctrl);
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
}
/**
@@ -279,13 +279,13 @@ static int board_added(struct slot *p_slot)
ctrl->slot_device_offset, hp_slot);
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (POWER_CTRL(ctrl->ctrlcap)) {
/* Power on slot */
rc = p_slot->hpc_ops->power_on_slot(p_slot);
if (rc) {
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return -1;
}
@@ -301,7 +301,7 @@ static int board_added(struct slot *p_slot)
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
/* Wait for ~1 second */
wait_for_ctrl_irq (ctrl);
@@ -335,7 +335,7 @@ static int board_added(struct slot *p_slot)
pci_fixup_device(pci_fixup_final, ctrl->pci_dev);
if (PWR_LED(ctrl->ctrlcap)) {
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
p_slot->hpc_ops->green_led_on(p_slot);
@@ -343,7 +343,7 @@ static int board_added(struct slot *p_slot)
wait_for_ctrl_irq (ctrl);
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
}
return 0;
@@ -375,14 +375,14 @@ static int remove_board(struct slot *p_slot)
dbg("In %s, hp_slot = %d\n", __FUNCTION__, hp_slot);
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (POWER_CTRL(ctrl->ctrlcap)) {
/* power off slot */
rc = p_slot->hpc_ops->power_off_slot(p_slot);
if (rc) {
err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return rc;
}
/* Wait for the command to complete */
@@ -398,7 +398,7 @@ static int remove_board(struct slot *p_slot)
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
return 0;
}
@@ -445,7 +445,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
/* Wait for exclusive access to hardware */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
p_slot->hpc_ops->green_led_off(p_slot);
@@ -453,7 +453,7 @@ static void pciehp_pushbutton_thread(unsigned long slot)
wait_for_ctrl_irq (p_slot->ctrl);
/* Done with exclusive hardware access */
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
}
p_slot->state = STATIC_STATE;
}
@@ -495,7 +495,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
if (pciehp_enable_slot(p_slot) && PWR_LED(p_slot->ctrl->ctrlcap)) {
/* Wait for exclusive access to hardware */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
p_slot->hpc_ops->green_led_off(p_slot);
@@ -503,7 +503,7 @@ static void pciehp_surprise_rm_thread(unsigned long slot)
wait_for_ctrl_irq (p_slot->ctrl);
/* Done with exclusive hardware access */
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
}
p_slot->state = STATIC_STATE;
}
@@ -616,7 +616,7 @@ static void interrupt_event_handler(struct controller *ctrl)
switch (p_slot->state) {
case BLINKINGOFF_STATE:
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (PWR_LED(ctrl->ctrlcap)) {
p_slot->hpc_ops->green_led_on(p_slot);
@@ -630,11 +630,11 @@ static void interrupt_event_handler(struct controller *ctrl)
wait_for_ctrl_irq (ctrl);
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
break;
case BLINKINGON_STATE:
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (PWR_LED(ctrl->ctrlcap)) {
p_slot->hpc_ops->green_led_off(p_slot);
@@ -647,7 +647,7 @@ static void interrupt_event_handler(struct controller *ctrl)
wait_for_ctrl_irq (ctrl);
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
break;
default:
@@ -676,7 +676,7 @@ static void interrupt_event_handler(struct controller *ctrl)
}
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
/* blink green LED and turn off amber */
if (PWR_LED(ctrl->ctrlcap)) {
@@ -693,7 +693,7 @@ static void interrupt_event_handler(struct controller *ctrl)
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
init_timer(&p_slot->task_event);
p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
@@ -708,7 +708,7 @@ static void interrupt_event_handler(struct controller *ctrl)
if (POWER_CTRL(ctrl->ctrlcap)) {
dbg("power fault\n");
/* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
+ mutex_lock(&ctrl->crit_sect);
if (ATTN_LED(ctrl->ctrlcap)) {
p_slot->hpc_ops->set_attention_status(p_slot, 1);
@@ -721,7 +721,7 @@ static void interrupt_event_handler(struct controller *ctrl)
}
/* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ mutex_unlock(&ctrl->crit_sect);
}
}
/***********SURPRISE REMOVAL********************/
@@ -756,19 +756,19 @@ int pciehp_enable_slot(struct slot *p_slot)
int rc;
/* Check to see if (latch closed, card present, power off) */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (rc || !getstatus) {
info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
if (MRL_SENS(p_slot->ctrl->ctrlcap)) {
rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (rc || getstatus) {
info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
}
@@ -777,11 +777,11 @@ int pciehp_enable_slot(struct slot *p_slot)
rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (rc || getstatus) {
info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
}
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
@@ -806,13 +806,13 @@ int pciehp_disable_slot(struct slot *p_slot)
return 1;
/* Check to see if (latch closed, card present, power on) */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
if (!HP_SUPR_RM(p_slot->ctrl->ctrlcap)) {
ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (ret || !getstatus) {
info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
}
@@ -821,7 +821,7 @@ int pciehp_disable_slot(struct slot *p_slot)
ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (ret || getstatus) {
info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
}
@@ -830,12 +830,12 @@ int pciehp_disable_slot(struct slot *p_slot)
ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (ret || !getstatus) {
info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
return 1;
}
}
- up(&p_slot->ctrl->crit_sect);
+ mutex_unlock(&p_slot->ctrl->crit_sect);
ret = remove_board(p_slot);
update_slot_info(p_slot);
diff --git a/drivers/pci/hotplug/pciehp_hpc.c b/drivers/pci/hotplug/pciehp_hpc.c
index 77e530321de..6c14d9e46b2 100644
--- a/drivers/pci/hotplug/pciehp_hpc.c
+++ b/drivers/pci/hotplug/pciehp_hpc.c
@@ -38,7 +38,10 @@
#include "../pci.h"
#include "pciehp.h"
-
+#include <acpi/acpi.h>
+#include <acpi/acpi_bus.h>
+#include <acpi/actypes.h>
+#include <linux/pci-acpi.h>
#ifdef DEBUG
#define DBG_K_TRACE_ENTRY ((unsigned int)0x00000001) /* On function entry */
#define DBG_K_TRACE_EXIT ((unsigned int)0x00000002) /* On function exit */
@@ -1236,6 +1239,76 @@ static struct hpc_ops pciehp_hpc_ops = {
.check_lnk_status = hpc_check_lnk_status,
};
+#ifdef CONFIG_ACPI
+int pciehp_acpi_get_hp_hw_control_from_firmware(struct pci_dev *dev)
+{
+ acpi_status status;
+ acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
+ struct pci_dev *pdev = dev;
+ struct pci_bus *parent;
+ struct acpi_buffer string = { ACPI_ALLOCATE_BUFFER, NULL };
+
+ /*
+ * Per PCI firmware specification, we should run the ACPI _OSC
+ * method to get control of hotplug hardware before using it.
+ * If an _OSC is missing, we look for an OSHP to do the same thing.
+ * To handle different BIOS behavior, we look for _OSC and OSHP
+ * within the scope of the hotplug controller and its parents, upto
+ * the host bridge under which this controller exists.
+ */
+ while (!handle) {
+ /*
+ * This hotplug controller was not listed in the ACPI name
+ * space at all. Try to get acpi handle of parent pci bus.
+ */
+ if (!pdev || !pdev->bus->parent)
+ break;
+ parent = pdev->bus->parent;
+ dbg("Could not find %s in acpi namespace, trying parent\n",
+ pci_name(pdev));
+ if (!parent->self)
+ /* Parent must be a host bridge */
+ handle = acpi_get_pci_rootbridge_handle(
+ pci_domain_nr(parent),
+ parent->number);
+ else
+ handle = DEVICE_ACPI_HANDLE(
+ &(parent->self->dev));
+ pdev = parent->self;
+ }
+
+ while (handle) {
+ acpi_get_name(handle, ACPI_FULL_PATHNAME, &string);
+ dbg("Trying to get hotplug control for %s \n",
+ (char *)string.pointer);
+ status = pci_osc_control_set(handle,
+ OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
+ if (status == AE_NOT_FOUND)
+ status = acpi_run_oshp(handle);
+ if (ACPI_SUCCESS(status)) {
+ dbg("Gained control for hotplug HW for pci %s (%s)\n",
+ pci_name(dev), (char *)string.pointer);
+ acpi_os_free(string.pointer);
+ return 0;
+ }
+ if (acpi_root_bridge(handle))
+ break;
+ chandle = handle;
+ status = acpi_get_parent(chandle, &handle);
+ if (ACPI_FAILURE(status))
+ break;
+ }
+
+ err("Cannot get control of hotplug hardware for pci %s\n",
+ pci_name(dev));
+
+ acpi_os_free(string.pointer);
+ return -1;
+}
+#endif
+
+
+
int pcie_init(struct controller * ctrl, struct pcie_device *dev)
{
struct php_ctlr_state_s *php_ctlr, *p;
@@ -1334,7 +1407,7 @@ int pcie_init(struct controller * ctrl, struct pcie_device *dev)
if (pci_enable_device(pdev))
goto abort_free_ctlr;
- init_MUTEX(&ctrl->crit_sect);
+ mutex_init(&ctrl->crit_sect);
/* setup wait queue */
init_waitqueue_head(&ctrl->queue);
diff --git a/drivers/pci/hotplug/pciehprm_acpi.c b/drivers/pci/hotplug/pciehprm_acpi.c
deleted file mode 100644
index 2bdb30f68bf..00000000000
--- a/drivers/pci/hotplug/pciehprm_acpi.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * PCIEHPRM ACPI: PHP Resource Manager for ACPI platform
- *
- * Copyright (C) 2003-2004 Intel Corporation
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <kristen.c.accardi@intel.com>
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/acpi.h>
-#include <linux/pci-acpi.h>
-#include <acpi/acpi_bus.h>
-#include <acpi/actypes.h>
-#include "pciehp.h"
-
-#define METHOD_NAME__SUN "_SUN"
-#define METHOD_NAME__HPP "_HPP"
-#define METHOD_NAME_OSHP "OSHP"
-
-static u8 * acpi_path_name( acpi_handle handle)
-{
- acpi_status status;
- static u8 path_name[ACPI_PATHNAME_MAX];
- struct acpi_buffer ret_buf = { ACPI_PATHNAME_MAX, path_name };
-
- memset(path_name, 0, sizeof (path_name));
- status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &ret_buf);
-
- if (ACPI_FAILURE(status))
- return NULL;
- else
- return path_name;
-}
-
-static acpi_status
-acpi_run_hpp(acpi_handle handle, struct hotplug_params *hpp)
-{
- acpi_status status;
- u8 nui[4];
- struct acpi_buffer ret_buf = { 0, NULL};
- union acpi_object *ext_obj, *package;
- u8 *path_name = acpi_path_name(handle);
- int i, len = 0;
-
- /* get _hpp */
- status = acpi_evaluate_object(handle, METHOD_NAME__HPP, NULL, &ret_buf);
- switch (status) {
- case AE_BUFFER_OVERFLOW:
- ret_buf.pointer = kmalloc (ret_buf.length, GFP_KERNEL);
- if (!ret_buf.pointer) {
- err ("%s:%s alloc for _HPP fail\n", __FUNCTION__,
- path_name);
- return AE_NO_MEMORY;
- }
- status = acpi_evaluate_object(handle, METHOD_NAME__HPP,
- NULL, &ret_buf);
- if (ACPI_SUCCESS(status))
- break;
- default:
- if (ACPI_FAILURE(status)) {
- dbg("%s:%s _HPP fail=0x%x\n", __FUNCTION__,
- path_name, status);
- return status;
- }
- }
-
- ext_obj = (union acpi_object *) ret_buf.pointer;
- if (ext_obj->type != ACPI_TYPE_PACKAGE) {
- err ("%s:%s _HPP obj not a package\n", __FUNCTION__,
- path_name);
- status = AE_ERROR;
- goto free_and_return;
- }
-
- len = ext_obj->package.count;
- package = (union acpi_object *) ret_buf.pointer;
- for ( i = 0; (i < len) || (i < 4); i++) {
- ext_obj = (union acpi_object *) &package->package.elements[i];
- switch (ext_obj->type) {
- case ACPI_TYPE_INTEGER:
- nui[i] = (u8)ext_obj->integer.value;
- break;
- default:
- err ("%s:%s _HPP obj type incorrect\n", __FUNCTION__,
- path_name);
- status = AE_ERROR;
- goto free_and_return;
- }
- }
-
- hpp->cache_line_size = nui[0];
- hpp->latency_timer = nui[1];
- hpp->enable_serr = nui[2];
- hpp->enable_perr = nui[3];
-
- dbg(" _HPP: cache_line_size=0x%x\n", hpp->cache_line_size);
- dbg(" _HPP: latency timer =0x%x\n", hpp->latency_timer);
- dbg(" _HPP: enable SERR =0x%x\n", hpp->enable_serr);
- dbg(" _HPP: enable PERR =0x%x\n", hpp->enable_perr);
-
-free_and_return:
- kfree(ret_buf.pointer);
- return status;
-}
-
-static acpi_status acpi_run_oshp(acpi_handle handle)
-{
- acpi_status status;
- u8 *path_name = acpi_path_name(handle);
-
- /* run OSHP */
- status = acpi_evaluate_object(handle, METHOD_NAME_OSHP, NULL, NULL);
- if (ACPI_FAILURE(status)) {
- dbg("%s:%s OSHP fails=0x%x\n", __FUNCTION__, path_name,
- status);
- } else {
- dbg("%s:%s OSHP passes\n", __FUNCTION__, path_name);
- }
- return status;
-}
-
-static int is_root_bridge(acpi_handle handle)
-{
- acpi_status status;
- struct acpi_device_info *info;
- struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
- int i;
-
- status = acpi_get_object_info(handle, &buffer);
- if (ACPI_SUCCESS(status)) {
- info = buffer.pointer;
- if ((info->valid & ACPI_VALID_HID) &&
- !strcmp(PCI_ROOT_HID_STRING,
- info->hardware_id.value)) {
- acpi_os_free(buffer.pointer);
- return 1;
- }
- if (info->valid & ACPI_VALID_CID) {
- for (i=0; i < info->compatibility_id.count; i++) {
- if (!strcmp(PCI_ROOT_HID_STRING,
- info->compatibility_id.id[i].value)) {
- acpi_os_free(buffer.pointer);
- return 1;
- }
- }
- }
- }
- return 0;
-}
-
-int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
-{
- acpi_status status;
- acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
- struct pci_dev *pdev = dev;
- struct pci_bus *parent;
- u8 *path_name;
-
- /*
- * Per PCI firmware specification, we should run the ACPI _OSC
- * method to get control of hotplug hardware before using it.
- * If an _OSC is missing, we look for an OSHP to do the same thing.
- * To handle different BIOS behavior, we look for _OSC and OSHP
- * within the scope of the hotplug controller and its parents, upto
- * the host bridge under which this controller exists.
- */
- while (!handle) {
- /*
- * This hotplug controller was not listed in the ACPI name
- * space at all. Try to get acpi handle of parent pci bus.
- */
- if (!pdev || !pdev->bus->parent)
- break;
- parent = pdev->bus->parent;
- dbg("Could not find %s in acpi namespace, trying parent\n",
- pci_name(pdev));
- if (!parent->self)
- /* Parent must be a host bridge */
- handle = acpi_get_pci_rootbridge_handle(
- pci_domain_nr(parent),
- parent->number);
- else
- handle = DEVICE_ACPI_HANDLE(
- &(parent->self->dev));
- pdev = parent->self;
- }
-
- while (handle) {
- path_name = acpi_path_name(handle);
- dbg("Trying to get hotplug control for %s \n", path_name);
- status = pci_osc_control_set(handle,
- OSC_PCI_EXPRESS_NATIVE_HP_CONTROL);
- if (status == AE_NOT_FOUND)
- status = acpi_run_oshp(handle);
- if (ACPI_SUCCESS(status)) {
- dbg("Gained control for hotplug HW for pci %s (%s)\n",
- pci_name(dev), path_name);
- return 0;
- }
- if (is_root_bridge(handle))
- break;
- chandle = handle;
- status = acpi_get_parent(chandle, &handle);
- if (ACPI_FAILURE(status))
- break;
- }
-
- err("Cannot get control of hotplug hardware for pci %s\n",
- pci_name(dev));
- return -1;
-}
-
-void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp)
-{
- acpi_status status = AE_NOT_FOUND;
- struct pci_dev *pdev = dev;
-
- /*
- * _HPP settings apply to all child buses, until another _HPP is
- * encountered. If we don't find an _HPP for the input pci dev,
- * look for it in the parent device scope since that would apply to
- * this pci dev. If we don't find any _HPP, use hardcoded defaults
- */
- while (pdev && (ACPI_FAILURE(status))) {
- acpi_handle handle = DEVICE_ACPI_HANDLE(&(pdev->dev));
- if (!handle)
- break;
- status = acpi_run_hpp(handle, hpp);
- if (!(pdev->bus->parent))
- break;
- /* Check if a parent object supports _HPP */
- pdev = pdev->bus->parent->self;
- }
-}
-
diff --git a/drivers/pci/hotplug/pciehprm_nonacpi.c b/drivers/pci/hotplug/pciehprm_nonacpi.c
deleted file mode 100644
index 29180dfe849..00000000000
--- a/drivers/pci/hotplug/pciehprm_nonacpi.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * PCIEHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform
- *
- * Copyright (C) 1995,2001 Compaq Computer Corporation
- * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2001 IBM Corp.
- * Copyright (C) 2003-2004 Intel Corporation
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/sched.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-#include "pciehp.h"
-
-void pciehp_get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp)
-{
- return;
-}
-
-int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
-{
- return 0;
-}
diff --git a/drivers/pci/hotplug/pcihp_skeleton.c b/drivers/pci/hotplug/pcihp_skeleton.c
index 3194d51c6ec..0a46f549676 100644
--- a/drivers/pci/hotplug/pcihp_skeleton.c
+++ b/drivers/pci/hotplug/pcihp_skeleton.c
@@ -37,10 +37,12 @@
#include <linux/init.h>
#include "pci_hotplug.h"
+#define SLOT_NAME_SIZE 10
struct slot {
u8 number;
struct hotplug_slot *hotplug_slot;
struct list_head slot_list;
+ char name[SLOT_NAME_SIZE];
};
static LIST_HEAD(slot_list);
@@ -233,12 +235,10 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
kfree(slot->hotplug_slot->info);
- kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
-#define SLOT_NAME_SIZE 10
static void make_slot_name(struct slot *slot)
{
/*
@@ -257,7 +257,6 @@ static int __init init_slots(void)
struct slot *slot;
struct hotplug_slot *hotplug_slot;
struct hotplug_slot_info *info;
- char *name;
int retval = -ENOMEM;
int i;
@@ -266,31 +265,23 @@ static int __init init_slots(void)
* with the pci_hotplug subsystem.
*/
for (i = 0; i < num_slots; ++i) {
- slot = kmalloc(sizeof(struct slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(struct slot));
- hotplug_slot = kmalloc(sizeof(struct hotplug_slot),
- GFP_KERNEL);
+ hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
if (!hotplug_slot)
goto error_slot;
- memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
slot->hotplug_slot = hotplug_slot;
- info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
goto error_hpslot;
- memset(info, 0, sizeof (struct hotplug_slot_info));
hotplug_slot->info = info;
- name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
- if (!name)
- goto error_info;
- hotplug_slot->name = name;
-
slot->number = i;
+ hotplug_slot->name = slot->name;
hotplug_slot->private = slot;
hotplug_slot->release = &release_slot;
make_slot_name(slot);
@@ -300,16 +291,16 @@ static int __init init_slots(void)
* Initialize the slot info structure with some known
* good values.
*/
- info->power_status = get_power_status(slot);
- info->attention_status = get_attention_status(slot);
- info->latch_status = get_latch_status(slot);
- info->adapter_status = get_adapter_status(slot);
+ get_power_status(hotplug_slot, &info->power_status);
+ get_attention_status(hotplug_slot, &info->attention_status);
+ get_latch_status(hotplug_slot, &info->latch_status);
+ get_adapter_status(hotplug_slot, &info->adapter_status);
dbg("registering slot %d\n", i);
retval = pci_hp_register(slot->hotplug_slot);
if (retval) {
err("pci_hp_register failed with error %d\n", retval);
- goto error_name;
+ goto error_info;
}
/* add slot to our internal list */
@@ -317,8 +308,6 @@ static int __init init_slots(void)
}
return 0;
-error_name:
- kfree(name);
error_info:
kfree(info);
error_hpslot:
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 78943e064b5..b771196a654 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_
{
struct slot *slot;
- slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct slot), GFP_KERNEL);
if (!slot)
goto error_nomem;
- memset(slot, 0, sizeof (struct slot));
- slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+ slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
- memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
- slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info),
+ slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
GFP_KERNEL);
if (!slot->hotplug_slot->info)
goto error_hpslot;
- memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL);
if (!slot->hotplug_slot->name)
goto error_info;
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index a32ae82e592..c402da8e78a 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -3,7 +3,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
- * Copyright (C) 2005 Silicon Graphics, Inc. All rights reserved.
+ * Copyright (C) 2005-2006 Silicon Graphics, Inc. All rights reserved.
*
* This work was based on the 2.4/2.6 kernel development by Dick Reigner.
* Work to add BIOS PROM support was completed by Mike Habeck.
@@ -230,6 +230,13 @@ static void sn_bus_free_data(struct pci_dev *dev)
list_for_each_entry(child, &subordinate_bus->devices, bus_list)
sn_bus_free_data(child);
}
+ /*
+ * Some drivers may use dma accesses during the
+ * driver remove function. We release the sysdata
+ * areas after the driver remove functions have
+ * been called.
+ */
+ sn_bus_store_sysdata(dev);
sn_pci_unfixup_slot(dev);
}
@@ -429,13 +436,6 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
PCI_DEVFN(slot->device_num + 1,
PCI_FUNC(func)));
if (dev) {
- /*
- * Some drivers may use dma accesses during the
- * driver remove function. We release the sysdata
- * areas after the driver remove functions have
- * been called.
- */
- sn_bus_store_sysdata(dev);
sn_bus_free_data(dev);
pci_remove_bus_device(dev);
pci_dev_put(dev);
diff --git a/drivers/pci/hotplug/shpchp.h b/drivers/pci/hotplug/shpchp.h
index 7d6f521d02e..5c70f43908c 100644
--- a/drivers/pci/hotplug/shpchp.h
+++ b/drivers/pci/hotplug/shpchp.h
@@ -33,6 +33,7 @@
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/sched.h> /* signal_pending(), struct timer_list */
+#include <linux/mutex.h>
#include "pci_hotplug.h"
@@ -45,6 +46,7 @@
extern int shpchp_poll_mode;
extern int shpchp_poll_time;
extern int shpchp_debug;
+extern struct workqueue_struct *shpchp_wq;
/*#define dbg(format, arg...) do { if (shpchp_debug) printk(KERN_DEBUG "%s: " format, MY_NAME , ## arg); } while (0)*/
#define dbg(format, arg...) do { if (shpchp_debug) printk("%s: " format, MY_NAME , ## arg); } while (0)
@@ -52,10 +54,8 @@ extern int shpchp_debug;
#define info(format, arg...) printk(KERN_INFO "%s: " format, MY_NAME , ## arg)
#define warn(format, arg...) printk(KERN_WARNING "%s: " format, MY_NAME , ## arg)
-#define SLOT_MAGIC 0x67267321
+#define SLOT_NAME_SIZE 10
struct slot {
- u32 magic;
- struct slot *next;
u8 bus;
u8 device;
u16 status;
@@ -70,26 +70,27 @@ struct slot {
struct hpc_ops *hpc_ops;
struct hotplug_slot *hotplug_slot;
struct list_head slot_list;
+ char name[SLOT_NAME_SIZE];
+ struct work_struct work; /* work for button event */
+ struct mutex lock;
};
struct event_info {
u32 event_type;
- u8 hp_slot;
+ struct slot *p_slot;
+ struct work_struct work;
};
struct controller {
- struct controller *next;
- struct semaphore crit_sect; /* critical section semaphore */
+ struct mutex crit_sect; /* critical section mutex */
+ struct mutex cmd_lock; /* command lock */
struct php_ctlr_state_s *hpc_ctlr_handle; /* HPC controller handle */
int num_slots; /* Number of slots on ctlr */
int slot_num_inc; /* 1 or -1 */
struct pci_dev *pci_dev;
- struct pci_bus *pci_bus;
- struct event_info event_queue[10];
- struct slot *slot;
+ struct list_head slot_list;
struct hpc_ops *hpc_ops;
wait_queue_head_t queue; /* sleep & wake process */
- u8 next_event;
u8 bus;
u8 device;
u8 function;
@@ -105,12 +106,6 @@ struct controller {
volatile int cmd_busy;
};
-struct hotplug_params {
- u8 cache_line_size;
- u8 latency_timer;
- u8 enable_serr;
- u8 enable_perr;
-};
/* Define AMD SHPC ID */
#define PCI_DEVICE_ID_AMD_GOLAM_7450 0x7450
@@ -180,11 +175,8 @@ struct hotplug_params {
/* sysfs functions for the hotplug controller info */
extern void shpchp_create_ctrl_files (struct controller *ctrl);
-/* controller functions */
-extern int shpchp_event_start_thread(void);
-extern void shpchp_event_stop_thread(void);
-extern int shpchp_enable_slot(struct slot *slot);
-extern int shpchp_disable_slot(struct slot *slot);
+extern int shpchp_sysfs_enable_slot(struct slot *slot);
+extern int shpchp_sysfs_disable_slot(struct slot *slot);
extern u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id);
extern u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id);
@@ -195,16 +187,28 @@ extern u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id);
extern int shpchp_save_config(struct controller *ctrl, int busnumber, int num_ctlr_slots, int first_device_num);
extern int shpchp_configure_device(struct slot *p_slot);
extern int shpchp_unconfigure_device(struct slot *p_slot);
-extern void get_hp_hw_control_from_firmware(struct pci_dev *dev);
-extern void get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp);
-extern int shpchprm_get_physical_slot_number(struct controller *ctrl,
- u32 *sun, u8 busnum, u8 devnum);
extern void shpchp_remove_ctrl_files(struct controller *ctrl);
+extern void cleanup_slots(struct controller *ctrl);
+extern void queue_pushbutton_work(void *data);
-/* Global variables */
-extern struct controller *shpchp_ctrl_list;
+#ifdef CONFIG_ACPI
+static inline int get_hp_params_from_firmware(struct pci_dev *dev,
+ struct hotplug_params *hpp)
+{
+ if (ACPI_FAILURE(acpi_get_hp_params_from_firmware(dev, hpp)))
+ return -ENODEV;
+ return 0;
+}
+#define get_hp_hw_control_from_firmware(pdev) \
+ do { \
+ if (DEVICE_ACPI_HANDLE(&(pdev->dev))) \
+ acpi_run_oshp(DEVICE_ACPI_HANDLE(&(pdev->dev))); \
+ } while (0)
+#else
+#define get_hp_params_from_firmware(dev, hpp) (-ENODEV)
+#define get_hp_hw_control_from_firmware(dev) do { } while (0)
+#endif
struct ctrl_reg {
volatile u32 base_offset;
@@ -286,10 +290,6 @@ static inline int slot_paranoia_check (struct slot *slot, const char *function)
dbg("%s - slot == NULL", function);
return -1;
}
- if (slot->magic != SLOT_MAGIC) {
- dbg("%s - bad magic number for slot", function);
- return -1;
- }
if (!slot->hotplug_slot) {
dbg("%s - slot->hotplug_slot == NULL!", function);
return -1;
@@ -314,44 +314,19 @@ static inline struct slot *get_slot (struct hotplug_slot *hotplug_slot, const ch
static inline struct slot *shpchp_find_slot (struct controller *ctrl, u8 device)
{
- struct slot *p_slot, *tmp_slot = NULL;
+ struct slot *slot;
if (!ctrl)
return NULL;
- p_slot = ctrl->slot;
-
- while (p_slot && (p_slot->device != device)) {
- tmp_slot = p_slot;
- p_slot = p_slot->next;
+ list_for_each_entry(slot, &ctrl->slot_list, slot_list) {
+ if (slot->device == device)
+ return slot;
}
- if (p_slot == NULL) {
- err("ERROR: shpchp_find_slot device=0x%x\n", device);
- p_slot = tmp_slot;
- }
-
- return (p_slot);
-}
-
-static inline int wait_for_ctrl_irq (struct controller *ctrl)
-{
- DECLARE_WAITQUEUE(wait, current);
- int retval = 0;
-
- add_wait_queue(&ctrl->queue, &wait);
- if (!shpchp_poll_mode) {
- /* Sleep for up to 1 second */
- msleep_interruptible(1000);
- } else {
- /* Sleep for up to 2 seconds */
- msleep_interruptible(2000);
- }
- remove_wait_queue(&ctrl->queue, &wait);
- if (signal_pending(current))
- retval = -EINTR;
+ err("%s: slot (device=0x%x) not found\n", __FUNCTION__, device);
- return retval;
+ return NULL;
}
static inline void amd_pogo_errata_save_misc_reg(struct slot *p_slot)
@@ -427,13 +402,6 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, pcix_misc2_temp);
}
-#define SLOT_NAME_SIZE 10
-
-static inline void make_slot_name(char *buffer, int buffer_size, struct slot *slot)
-{
- snprintf(buffer, buffer_size, "%04d_%04d", slot->bus, slot->number);
-}
-
enum php_ctlr_type {
PCI,
ISA,
diff --git a/drivers/pci/hotplug/shpchp_core.c b/drivers/pci/hotplug/shpchp_core.c
index a2b3f0010ce..3be4d492ccc 100644
--- a/drivers/pci/hotplug/shpchp_core.c
+++ b/drivers/pci/hotplug/shpchp_core.c
@@ -32,13 +32,14 @@
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/pci.h>
+#include <linux/workqueue.h>
#include "shpchp.h"
/* Global variables */
int shpchp_debug;
int shpchp_poll_mode;
int shpchp_poll_time;
-struct controller *shpchp_ctrl_list; /* = NULL */
+struct workqueue_struct *shpchp_wq;
#define DRIVER_VERSION "0.4"
#define DRIVER_AUTHOR "Dan Zink <dan.zink@compaq.com>, Greg Kroah-Hartman <greg@kroah.com>, Dely Sy <dely.l.sy@intel.com>"
@@ -57,7 +58,6 @@ MODULE_PARM_DESC(shpchp_poll_time, "Polling mechanism frequency, in seconds");
#define SHPC_MODULE_NAME "shpchp"
-static int shpc_start_thread (void);
static int set_attention_status (struct hotplug_slot *slot, u8 value);
static int enable_slot (struct hotplug_slot *slot);
static int disable_slot (struct hotplug_slot *slot);
@@ -94,107 +94,120 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
kfree(slot->hotplug_slot->info);
- kfree(slot->hotplug_slot->name);
kfree(slot->hotplug_slot);
kfree(slot);
}
+static void make_slot_name(struct slot *slot)
+{
+ snprintf(slot->hotplug_slot->name, SLOT_NAME_SIZE, "%04d_%04d",
+ slot->bus, slot->number);
+}
+
+
+
+
+static int
+shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun,
+ u8 busnum, u8 devnum)
+{
+ int offset = devnum - ctrl->slot_device_offset;
+
+ dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__,
+ ctrl->slot_num_inc, offset);
+ *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc *offset);
+ return 0;
+}
+
+
+
static int init_slots(struct controller *ctrl)
{
- struct slot *new_slot;
- u8 number_of_slots;
- u8 slot_device;
- u32 slot_number, sun;
- int result = -ENOMEM;
-
- number_of_slots = ctrl->num_slots;
- slot_device = ctrl->slot_device_offset;
- slot_number = ctrl->first_slot;
-
- while (number_of_slots) {
- new_slot = (struct slot *) kmalloc(sizeof(struct slot), GFP_KERNEL);
- if (!new_slot)
+ struct slot *slot;
+ struct hotplug_slot *hotplug_slot;
+ struct hotplug_slot_info *info;
+ int retval = -ENOMEM;
+ int i;
+ u32 sun;
+
+ for (i = 0; i < ctrl->num_slots; i++) {
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ if (!slot)
goto error;
- memset(new_slot, 0, sizeof(struct slot));
- new_slot->hotplug_slot = kmalloc (sizeof (struct hotplug_slot), GFP_KERNEL);
- if (!new_slot->hotplug_slot)
+ hotplug_slot = kzalloc(sizeof(*hotplug_slot), GFP_KERNEL);
+ if (!hotplug_slot)
goto error_slot;
- memset(new_slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
+ slot->hotplug_slot = hotplug_slot;
- new_slot->hotplug_slot->info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL);
- if (!new_slot->hotplug_slot->info)
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
goto error_hpslot;
- memset(new_slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
- new_slot->hotplug_slot->name = kmalloc (SLOT_NAME_SIZE, GFP_KERNEL);
- if (!new_slot->hotplug_slot->name)
- goto error_info;
+ hotplug_slot->info = info;
+
+ hotplug_slot->name = slot->name;
- new_slot->magic = SLOT_MAGIC;
- new_slot->ctrl = ctrl;
- new_slot->bus = ctrl->slot_bus;
- new_slot->device = slot_device;
- new_slot->hpc_ops = ctrl->hpc_ops;
+ slot->hp_slot = i;
+ slot->ctrl = ctrl;
+ slot->bus = ctrl->slot_bus;
+ slot->device = ctrl->slot_device_offset + i;
+ slot->hpc_ops = ctrl->hpc_ops;
+ mutex_init(&slot->lock);
if (shpchprm_get_physical_slot_number(ctrl, &sun,
- new_slot->bus, new_slot->device))
- goto error_name;
+ slot->bus, slot->device))
+ goto error_info;
- new_slot->number = sun;
- new_slot->hp_slot = slot_device - ctrl->slot_device_offset;
+ slot->number = sun;
+ INIT_WORK(&slot->work, queue_pushbutton_work, slot);
/* register this slot with the hotplug pci core */
- new_slot->hotplug_slot->private = new_slot;
- new_slot->hotplug_slot->release = &release_slot;
- make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot);
- new_slot->hotplug_slot->ops = &shpchp_hotplug_slot_ops;
-
- new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status));
- new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status));
- new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status));
- new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status));
-
- dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", new_slot->bus,
- new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset);
- result = pci_hp_register (new_slot->hotplug_slot);
- if (result) {
- err ("pci_hp_register failed with error %d\n", result);
- goto error_name;
+ hotplug_slot->private = slot;
+ hotplug_slot->release = &release_slot;
+ make_slot_name(slot);
+ hotplug_slot->ops = &shpchp_hotplug_slot_ops;
+
+ get_power_status(hotplug_slot, &info->power_status);
+ get_attention_status(hotplug_slot, &info->attention_status);
+ get_latch_status(hotplug_slot, &info->latch_status);
+ get_adapter_status(hotplug_slot, &info->adapter_status);
+
+ dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x "
+ "slot_device_offset=%x\n", slot->bus, slot->device,
+ slot->hp_slot, slot->number, ctrl->slot_device_offset);
+ retval = pci_hp_register(slot->hotplug_slot);
+ if (retval) {
+ err("pci_hp_register failed with error %d\n", retval);
+ goto error_info;
}
- new_slot->next = ctrl->slot;
- ctrl->slot = new_slot;
-
- number_of_slots--;
- slot_device++;
- slot_number += ctrl->slot_num_inc;
+ list_add(&slot->slot_list, &ctrl->slot_list);
}
return 0;
-
-error_name:
- kfree(new_slot->hotplug_slot->name);
error_info:
- kfree(new_slot->hotplug_slot->info);
+ kfree(info);
error_hpslot:
- kfree(new_slot->hotplug_slot);
+ kfree(hotplug_slot);
error_slot:
- kfree(new_slot);
+ kfree(slot);
error:
- return result;
+ return retval;
}
-static void cleanup_slots(struct controller *ctrl)
+void cleanup_slots(struct controller *ctrl)
{
- struct slot *old_slot, *next_slot;
-
- old_slot = ctrl->slot;
- ctrl->slot = NULL;
-
- while (old_slot) {
- next_slot = old_slot->next;
- pci_hp_deregister(old_slot->hotplug_slot);
- old_slot = next_slot;
+ struct list_head *tmp;
+ struct list_head *next;
+ struct slot *slot;
+
+ list_for_each_safe(tmp, next, &ctrl->slot_list) {
+ slot = list_entry(tmp, struct slot, slot_list);
+ list_del(&slot->slot_list);
+ cancel_delayed_work(&slot->work);
+ flush_scheduled_work();
+ flush_workqueue(shpchp_wq);
+ pci_hp_deregister(slot->hotplug_slot);
}
}
@@ -207,9 +220,12 @@ static int get_ctlr_slot_config(struct controller *ctrl)
int rc;
int flags;
- rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots, &first_device_num, &physical_slot_num, &updown, &flags);
+ rc = shpc_get_ctlr_slot_config(ctrl, &num_ctlr_slots,
+ &first_device_num, &physical_slot_num,
+ &updown, &flags);
if (rc) {
- err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n", __FUNCTION__, ctrl->bus, ctrl->device);
+ err("%s: get_ctlr_slot_config fail for b:d (%x:%x)\n",
+ __FUNCTION__, ctrl->bus, ctrl->device);
return -1;
}
@@ -218,19 +234,19 @@ static int get_ctlr_slot_config(struct controller *ctrl)
ctrl->first_slot = physical_slot_num;
ctrl->slot_num_inc = updown; /* either -1 or 1 */
- dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d (%x:%x)\n",
- __FUNCTION__, num_ctlr_slots, first_device_num, physical_slot_num, updown, ctrl->bus, ctrl->device);
+ dbg("%s: num_slot(0x%x) 1st_dev(0x%x) psn(0x%x) updown(%d) for b:d "
+ "(%x:%x)\n", __FUNCTION__, num_ctlr_slots, first_device_num,
+ physical_slot_num, updown, ctrl->bus, ctrl->device);
return 0;
}
-
/*
* set_attention_status - Turns the Amber LED for a slot on, off or blink
*/
static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -240,29 +256,27 @@ static int set_attention_status (struct hotplug_slot *hotplug_slot, u8 status)
return 0;
}
-
static int enable_slot (struct hotplug_slot *hotplug_slot)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
- return shpchp_enable_slot(slot);
+ return shpchp_sysfs_enable_slot(slot);
}
-
static int disable_slot (struct hotplug_slot *hotplug_slot)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
- return shpchp_disable_slot(slot);
+ return shpchp_sysfs_disable_slot(slot);
}
static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -276,7 +290,7 @@ static int get_power_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -290,7 +304,7 @@ static int get_attention_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -304,7 +318,7 @@ static int get_latch_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -318,7 +332,7 @@ static int get_adapter_status (struct hotplug_slot *hotplug_slot, u8 *value)
static int get_address (struct hotplug_slot *hotplug_slot, u32 *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
struct pci_bus *bus = slot->ctrl->pci_dev->subordinate;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
@@ -330,11 +344,11 @@ static int get_address (struct hotplug_slot *hotplug_slot, u32 *value)
static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
-
+
retval = slot->hpc_ops->get_max_bus_speed(slot, value);
if (retval < 0)
*value = PCI_SPEED_UNKNOWN;
@@ -344,11 +358,11 @@ static int get_max_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_sp
static int get_cur_bus_speed (struct hotplug_slot *hotplug_slot, enum pci_bus_speed *value)
{
- struct slot *slot = get_slot (hotplug_slot, __FUNCTION__);
+ struct slot *slot = get_slot(hotplug_slot, __FUNCTION__);
int retval;
dbg("%s - physical_slot = %s\n", __FUNCTION__, hotplug_slot->name);
-
+
retval = slot->hpc_ops->get_cur_bus_speed(slot, value);
if (retval < 0)
*value = PCI_SPEED_UNKNOWN;
@@ -372,61 +386,54 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
int rc;
struct controller *ctrl;
struct slot *t_slot;
- int first_device_num; /* first PCI device number supported by this SHPC */
- int num_ctlr_slots; /* number of slots supported by this SHPC */
+ int first_device_num; /* first PCI device number */
+ int num_ctlr_slots; /* number of slots implemented */
if (!is_shpc_capable(pdev))
return -ENODEV;
- ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
+ ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
goto err_out_none;
}
- memset(ctrl, 0, sizeof(struct controller));
+ INIT_LIST_HEAD(&ctrl->slot_list);
rc = shpc_init(ctrl, pdev);
if (rc) {
- dbg("%s: controller initialization failed\n", SHPC_MODULE_NAME);
+ dbg("%s: controller initialization failed\n",
+ SHPC_MODULE_NAME);
goto err_out_free_ctrl;
}
pci_set_drvdata(pdev, ctrl);
- ctrl->pci_bus = kmalloc (sizeof (*ctrl->pci_bus), GFP_KERNEL);
- if (!ctrl->pci_bus) {
- err("out of memory\n");
- rc = -ENOMEM;
- goto err_out_unmap_mmio_region;
- }
-
- memcpy (ctrl->pci_bus, pdev->bus, sizeof (*ctrl->pci_bus));
ctrl->bus = pdev->bus->number;
ctrl->slot_bus = pdev->subordinate->number;
-
ctrl->device = PCI_SLOT(pdev->devfn);
ctrl->function = PCI_FUNC(pdev->devfn);
- dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n", ctrl->bus, ctrl->device, ctrl->function, pdev->irq);
+
+ dbg("ctrl bus=0x%x, device=%x, function=%x, irq=%x\n",
+ ctrl->bus, ctrl->device, ctrl->function, pdev->irq);
/*
- * Save configuration headers for this and subordinate PCI buses
+ * Save configuration headers for this and subordinate PCI buses
*/
-
rc = get_ctlr_slot_config(ctrl);
if (rc) {
err(msg_initialization_err, rc);
- goto err_out_free_ctrl_bus;
+ goto err_out_release_ctlr;
}
first_device_num = ctrl->slot_device_offset;
num_ctlr_slots = ctrl->num_slots;
ctrl->add_support = 1;
-
+
/* Setup the slot information structures */
rc = init_slots(ctrl);
if (rc) {
err(msg_initialization_err, 6);
- goto err_out_free_ctrl_slot;
+ goto err_out_release_ctlr;
}
/* Now hpc_functions (slot->hpc_ops->functions) are ready */
@@ -437,30 +444,16 @@ static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
dbg("%s: t_slot->hp_slot %x\n", __FUNCTION__,t_slot->hp_slot);
if (rc || ctrl->speed == PCI_SPEED_UNKNOWN) {
- err(SHPC_MODULE_NAME ": Can't get current bus speed. Set to 33MHz PCI.\n");
+ err(SHPC_MODULE_NAME ": Can't get current bus speed. "
+ "Set to 33MHz PCI.\n");
ctrl->speed = PCI_SPEED_33MHz;
}
- /* Finish setting up the hot plug ctrl device */
- ctrl->next_event = 0;
-
- if (!shpchp_ctrl_list) {
- shpchp_ctrl_list = ctrl;
- ctrl->next = NULL;
- } else {
- ctrl->next = shpchp_ctrl_list;
- shpchp_ctrl_list = ctrl;
- }
-
shpchp_create_ctrl_files(ctrl);
return 0;
-err_out_free_ctrl_slot:
- cleanup_slots(ctrl);
-err_out_free_ctrl_bus:
- kfree(ctrl->pci_bus);
-err_out_unmap_mmio_region:
+err_out_release_ctlr:
ctrl->hpc_ops->release_ctlr(ctrl);
err_out_free_ctrl:
kfree(ctrl);
@@ -468,74 +461,28 @@ err_out_none:
return -ENODEV;
}
-
-static int shpc_start_thread(void)
-{
- int retval = 0;
-
- dbg("Initialize + Start the notification/polling mechanism \n");
-
- retval = shpchp_event_start_thread();
- if (retval) {
- dbg("shpchp_event_start_thread() failed\n");
- return retval;
- }
-
- return retval;
-}
-
-static void __exit unload_shpchpd(void)
+static void shpc_remove(struct pci_dev *dev)
{
- struct controller *ctrl;
- struct controller *tctrl;
-
- ctrl = shpchp_ctrl_list;
-
- while (ctrl) {
- shpchp_remove_ctrl_files(ctrl);
- cleanup_slots(ctrl);
-
- kfree (ctrl->pci_bus);
- ctrl->hpc_ops->release_ctlr(ctrl);
-
- tctrl = ctrl;
- ctrl = ctrl->next;
-
- kfree(tctrl);
- }
-
- /* Stop the notification mechanism */
- shpchp_event_stop_thread();
+ struct controller *ctrl = pci_get_drvdata(dev);
+ shpchp_remove_ctrl_files(ctrl);
+ ctrl->hpc_ops->release_ctlr(ctrl);
+ kfree(ctrl);
}
-
static struct pci_device_id shpcd_pci_tbl[] = {
- {
- .class = ((PCI_CLASS_BRIDGE_PCI << 8) | 0x00),
- .class_mask = ~0,
- .vendor = PCI_ANY_ID,
- .device = PCI_ANY_ID,
- .subvendor = PCI_ANY_ID,
- .subdevice = PCI_ANY_ID,
- },
-
+ {PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_PCI << 8) | 0x00), ~0)},
{ /* end: all zeroes */ }
};
-
MODULE_DEVICE_TABLE(pci, shpcd_pci_tbl);
-
-
static struct pci_driver shpc_driver = {
.name = SHPC_MODULE_NAME,
.id_table = shpcd_pci_tbl,
.probe = shpc_probe,
- /* remove: shpc_remove_one, */
+ .remove = shpc_remove,
};
-
-
static int __init shpcd_init(void)
{
int retval = 0;
@@ -544,17 +491,15 @@ static int __init shpcd_init(void)
shpchp_poll_mode = 1;
#endif
- retval = shpc_start_thread();
- if (retval)
- goto error_hpc_init;
+ shpchp_wq = create_singlethread_workqueue("shpchpd");
+ if (!shpchp_wq)
+ return -ENOMEM;
retval = pci_register_driver(&shpc_driver);
dbg("%s: pci_register_driver = %d\n", __FUNCTION__, retval);
info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
-
-error_hpc_init:
if (retval) {
- shpchp_event_stop_thread();
+ destroy_workqueue(shpchp_wq);
}
return retval;
}
@@ -562,10 +507,8 @@ error_hpc_init:
static void __exit shpcd_cleanup(void)
{
dbg("unload_shpchpd()\n");
- unload_shpchpd();
-
pci_unregister_driver(&shpc_driver);
-
+ destroy_workqueue(shpchp_wq);
info(DRIVER_DESC " version: " DRIVER_VERSION " unloaded\n");
}
diff --git a/drivers/pci/hotplug/shpchp_ctrl.c b/drivers/pci/hotplug/shpchp_ctrl.c
index 643252d9bf3..4e6381481c5 100644
--- a/drivers/pci/hotplug/shpchp_ctrl.c
+++ b/drivers/pci/hotplug/shpchp_ctrl.c
@@ -32,65 +32,50 @@
#include <linux/types.h>
#include <linux/smp_lock.h>
#include <linux/pci.h>
+#include <linux/workqueue.h>
#include "../pci.h"
#include "shpchp.h"
-static void interrupt_event_handler(struct controller *ctrl);
+static void interrupt_event_handler(void *data);
+static int shpchp_enable_slot(struct slot *p_slot);
+static int shpchp_disable_slot(struct slot *p_slot);
-static struct semaphore event_semaphore; /* mutex for process loop (up if something to process) */
-static struct semaphore event_exit; /* guard ensure thread has exited before calling it quits */
-static int event_finished;
-static unsigned long pushbutton_pending; /* = 0 */
+static int queue_interrupt_event(struct slot *p_slot, u32 event_type)
+{
+ struct event_info *info;
+
+ info = kmalloc(sizeof(*info), GFP_ATOMIC);
+ if (!info)
+ return -ENOMEM;
+
+ info->event_type = event_type;
+ info->p_slot = p_slot;
+ INIT_WORK(&info->work, interrupt_event_handler, info);
+
+ schedule_work(&info->work);
+
+ return 0;
+}
u8 shpchp_handle_attention_button(u8 hp_slot, void *inst_id)
{
struct controller *ctrl = (struct controller *) inst_id;
struct slot *p_slot;
- u8 rc = 0;
- u8 getstatus;
- struct event_info *taskInfo;
+ u32 event_type;
/* Attention Button Change */
dbg("shpchp: Attention button interrupt received.\n");
- /* This is the structure that tells the worker thread what to do */
- taskInfo = &(ctrl->event_queue[ctrl->next_event]);
p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
-
p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
- p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
-
- ctrl->next_event = (ctrl->next_event + 1) % 10;
- taskInfo->hp_slot = hp_slot;
-
- rc++;
/*
* Button pressed - See if need to TAKE ACTION!!!
*/
info("Button pressed on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_BUTTON_PRESS;
-
- if ((p_slot->state == BLINKINGON_STATE)
- || (p_slot->state == BLINKINGOFF_STATE)) {
- /* Cancel if we are still blinking; this means that we press the
- * attention again before the 5 sec. limit expires to cancel hot-add
- * or hot-remove
- */
- taskInfo->event_type = INT_BUTTON_CANCEL;
- info("Button cancel on Slot(%d)\n", ctrl->first_slot + hp_slot);
- } else if ((p_slot->state == POWERON_STATE)
- || (p_slot->state == POWEROFF_STATE)) {
- /* Ignore if the slot is on power-on or power-off state; this
- * means that the previous attention button action to hot-add or
- * hot-remove is undergoing
- */
- taskInfo->event_type = INT_BUTTON_IGNORE;
- info("Button ignore on Slot(%d)\n", ctrl->first_slot + hp_slot);
- }
+ event_type = INT_BUTTON_PRESS;
- if (rc)
- up(&event_semaphore); /* signal event thread that new event is posted */
+ queue_interrupt_event(p_slot, event_type);
return 0;
@@ -100,21 +85,12 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
{
struct controller *ctrl = (struct controller *) inst_id;
struct slot *p_slot;
- u8 rc = 0;
u8 getstatus;
- struct event_info *taskInfo;
+ u32 event_type;
/* Switch Change */
dbg("shpchp: Switch interrupt received.\n");
- /* This is the structure that tells the worker thread
- * what to do
- */
- taskInfo = &(ctrl->event_queue[ctrl->next_event]);
- ctrl->next_event = (ctrl->next_event + 1) % 10;
- taskInfo->hp_slot = hp_slot;
-
- rc++;
p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
p_slot->hpc_ops->get_adapter_status(p_slot, &(p_slot->presence_save));
p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
@@ -126,9 +102,9 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
* Switch opened
*/
info("Latch open on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_SWITCH_OPEN;
+ event_type = INT_SWITCH_OPEN;
if (p_slot->pwr_save && p_slot->presence_save) {
- taskInfo->event_type = INT_POWER_FAULT;
+ event_type = INT_POWER_FAULT;
err("Surprise Removal of card\n");
}
} else {
@@ -136,34 +112,23 @@ u8 shpchp_handle_switch_change(u8 hp_slot, void *inst_id)
* Switch closed
*/
info("Latch close on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_SWITCH_CLOSE;
+ event_type = INT_SWITCH_CLOSE;
}
- if (rc)
- up(&event_semaphore); /* signal event thread that new event is posted */
+ queue_interrupt_event(p_slot, event_type);
- return rc;
+ return 1;
}
u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id)
{
struct controller *ctrl = (struct controller *) inst_id;
struct slot *p_slot;
- u8 rc = 0;
- /*u8 temp_byte;*/
- struct event_info *taskInfo;
+ u32 event_type;
/* Presence Change */
dbg("shpchp: Presence/Notify input change.\n");
- /* This is the structure that tells the worker thread
- * what to do
- */
- taskInfo = &(ctrl->event_queue[ctrl->next_event]);
- ctrl->next_event = (ctrl->next_event + 1) % 10;
- taskInfo->hp_slot = hp_slot;
-
- rc++;
p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
/*
@@ -175,39 +140,29 @@ u8 shpchp_handle_presence_change(u8 hp_slot, void *inst_id)
* Card Present
*/
info("Card present on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_PRESENCE_ON;
+ event_type = INT_PRESENCE_ON;
} else {
/*
* Not Present
*/
info("Card not present on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_PRESENCE_OFF;
+ event_type = INT_PRESENCE_OFF;
}
- if (rc)
- up(&event_semaphore); /* signal event thread that new event is posted */
+ queue_interrupt_event(p_slot, event_type);
- return rc;
+ return 1;
}
u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
{
struct controller *ctrl = (struct controller *) inst_id;
struct slot *p_slot;
- u8 rc = 0;
- struct event_info *taskInfo;
+ u32 event_type;
/* Power fault */
dbg("shpchp: Power fault interrupt received.\n");
- /* This is the structure that tells the worker thread
- * what to do
- */
- taskInfo = &(ctrl->event_queue[ctrl->next_event]);
- ctrl->next_event = (ctrl->next_event + 1) % 10;
- taskInfo->hp_slot = hp_slot;
-
- rc++;
p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
@@ -216,21 +171,21 @@ u8 shpchp_handle_power_fault(u8 hp_slot, void *inst_id)
*/
info("Power fault cleared on Slot(%d)\n", ctrl->first_slot + hp_slot);
p_slot->status = 0x00;
- taskInfo->event_type = INT_POWER_FAULT_CLEAR;
+ event_type = INT_POWER_FAULT_CLEAR;
} else {
/*
* Power fault
*/
info("Power fault on Slot(%d)\n", ctrl->first_slot + hp_slot);
- taskInfo->event_type = INT_POWER_FAULT;
+ event_type = INT_POWER_FAULT;
/* set power fault status for this board */
p_slot->status = 0xFF;
info("power fault bit %x set\n", hp_slot);
}
- if (rc)
- up(&event_semaphore); /* signal event thread that new event is posted */
- return rc;
+ queue_interrupt_event(p_slot, event_type);
+
+ return 1;
}
/* The following routines constitute the bulk of the
@@ -242,21 +197,11 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
int rc = 0;
dbg("%s: change to speed %d\n", __FUNCTION__, speed);
- down(&ctrl->crit_sect);
if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
- err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
+ err("%s: Issue of set bus speed mode command failed\n",
+ __FUNCTION__);
return WRONG_BUS_FREQUENCY;
}
-
- if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
- err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
- __FUNCTION__);
- err("%s: Error code (%d)\n", __FUNCTION__, rc);
- up(&ctrl->crit_sect);
- return WRONG_BUS_FREQUENCY;
- }
- up(&ctrl->crit_sect);
return rc;
}
@@ -265,33 +210,26 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot,
enum pci_bus_speed msp)
{
int rc = 0;
-
- if (flag != 0) { /* Other slots on the same bus are occupied */
- if ( asp < bsp ) {
- err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bsp, asp);
- return WRONG_BUS_FREQUENCY;
+
+ /*
+ * If other slots on the same bus are occupied, we cannot
+ * change the bus speed.
+ */
+ if (flag) {
+ if (asp < bsp) {
+ err("%s: speed of bus %x and adapter %x mismatch\n",
+ __FUNCTION__, bsp, asp);
+ rc = WRONG_BUS_FREQUENCY;
}
+ return rc;
+ }
+
+ if (asp < msp) {
+ if (bsp != asp)
+ rc = change_bus_speed(ctrl, pslot, asp);
} else {
- /* Other slots on the same bus are empty */
- if (msp == bsp) {
- /* if adapter_speed >= bus_speed, do nothing */
- if (asp < bsp) {
- /*
- * Try to lower bus speed to accommodate the adapter if other slots
- * on the same controller are empty
- */
- if ((rc = change_bus_speed(ctrl, pslot, asp)))
- return rc;
- }
- } else {
- if (asp < msp) {
- if ((rc = change_bus_speed(ctrl, pslot, asp)))
- return rc;
- } else {
- if ((rc = change_bus_speed(ctrl, pslot, msp)))
- return rc;
- }
- }
+ if (bsp != msp)
+ rc = change_bus_speed(ctrl, pslot, msp);
}
return rc;
}
@@ -308,8 +246,7 @@ static int board_added(struct slot *p_slot)
u8 hp_slot;
u8 slots_not_empty = 0;
int rc = 0;
- enum pci_bus_speed adapter_speed, bus_speed, max_bus_speed;
- u8 pi, mode;
+ enum pci_bus_speed asp, bsp, msp;
struct controller *ctrl = p_slot->ctrl;
hp_slot = p_slot->device - ctrl->slot_device_offset;
@@ -318,187 +255,68 @@ static int board_added(struct slot *p_slot)
__FUNCTION__, p_slot->device,
ctrl->slot_device_offset, hp_slot);
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
/* Power on slot without connecting to bus */
rc = p_slot->hpc_ops->power_on_slot(p_slot);
if (rc) {
err("%s: Failed to power on slot\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
return -1;
}
- rc = p_slot->hpc_ops->check_cmd_status(ctrl);
- if (rc) {
- err("%s: Failed to power on slot, error code(%d)\n", __FUNCTION__, rc);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
- return -1;
- }
-
-
if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
if (slots_not_empty)
return WRONG_BUS_FREQUENCY;
if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
err("%s: Issue of set bus speed mode command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
return WRONG_BUS_FREQUENCY;
}
- if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
- err("%s: Can't set bus speed/mode in the case of adapter & bus mismatch\n",
- __FUNCTION__);
- err("%s: Error code (%d)\n", __FUNCTION__, rc);
- up(&ctrl->crit_sect);
- return WRONG_BUS_FREQUENCY;
- }
/* turn on board, blink green LED, turn off Amber LED */
if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
return rc;
}
-
- if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
- err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
- up(&ctrl->crit_sect);
- return rc;
- }
}
- rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &adapter_speed);
- /* 0 = PCI 33Mhz, 1 = PCI 66 Mhz, 2 = PCI-X 66 PA, 4 = PCI-X 66 ECC, */
- /* 5 = PCI-X 133 PA, 7 = PCI-X 133 ECC, 0xa = PCI-X 133 Mhz 266, */
- /* 0xd = PCI-X 133 Mhz 533 */
- /* This encoding is different from the one used in cur_bus_speed & */
- /* max_bus_speed */
-
- if (rc || adapter_speed == PCI_SPEED_UNKNOWN) {
- err("%s: Can't get adapter speed or bus mode mismatch\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
+ rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp);
+ if (rc) {
+ err("%s: Can't get adapter speed or bus mode mismatch\n",
+ __FUNCTION__);
return WRONG_BUS_FREQUENCY;
}
- rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bus_speed);
- if (rc || bus_speed == PCI_SPEED_UNKNOWN) {
+ rc = p_slot->hpc_ops->get_cur_bus_speed(p_slot, &bsp);
+ if (rc) {
err("%s: Can't get bus operation speed\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
return WRONG_BUS_FREQUENCY;
}
- rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &max_bus_speed);
- if (rc || max_bus_speed == PCI_SPEED_UNKNOWN) {
+ rc = p_slot->hpc_ops->get_max_bus_speed(p_slot, &msp);
+ if (rc) {
err("%s: Can't get max bus operation speed\n", __FUNCTION__);
- max_bus_speed = bus_speed;
- }
-
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
- if ((rc = p_slot->hpc_ops->get_prog_int(p_slot, &pi))) {
- err("%s: Can't get controller programming interface, set it to 1\n", __FUNCTION__);
- pi = 1;
+ msp = bsp;
}
/* Check if there are other slots or devices on the same bus */
if (!list_empty(&ctrl->pci_dev->subordinate->devices))
slots_not_empty = 1;
- dbg("%s: slots_not_empty %d, pi %d\n", __FUNCTION__,
- slots_not_empty, pi);
- dbg("adapter_speed %d, bus_speed %d, max_bus_speed %d\n",
- adapter_speed, bus_speed, max_bus_speed);
-
- if (pi == 2) {
- dbg("%s: In PI = %d\n", __FUNCTION__, pi);
- if ((rc = p_slot->hpc_ops->get_mode1_ECC_cap(p_slot, &mode))) {
- err("%s: Can't get Mode1_ECC, set mode to 0\n", __FUNCTION__);
- mode = 0;
- }
+ dbg("%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, "
+ "max_bus_speed %d\n", __FUNCTION__, slots_not_empty, asp,
+ bsp, msp);
- switch (adapter_speed) {
- case PCI_SPEED_133MHz_PCIX_533:
- case PCI_SPEED_133MHz_PCIX_266:
- if ((bus_speed != adapter_speed) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- break;
- case PCI_SPEED_133MHz_PCIX_ECC:
- case PCI_SPEED_133MHz_PCIX:
- if (mode) { /* Bus - Mode 1 ECC */
- if ((bus_speed != 0x7) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- } else {
- if ((bus_speed != 0x4) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- }
- break;
- case PCI_SPEED_66MHz_PCIX_ECC:
- case PCI_SPEED_66MHz_PCIX:
- if (mode) { /* Bus - Mode 1 ECC */
- if ((bus_speed != 0x5) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- } else {
- if ((bus_speed != 0x2) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- }
- break;
- case PCI_SPEED_66MHz:
- if ((bus_speed != 0x1) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- break;
- case PCI_SPEED_33MHz:
- if (bus_speed > 0x0) {
- if (slots_not_empty == 0) {
- if ((rc = change_bus_speed(ctrl, p_slot, adapter_speed)))
- return rc;
- } else {
- err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
- return WRONG_BUS_FREQUENCY;
- }
- }
- break;
- default:
- err("%s: speed of bus %x and adapter %x mismatch\n", __FUNCTION__, bus_speed, adapter_speed);
- return WRONG_BUS_FREQUENCY;
- }
- } else {
- /* If adpater_speed == bus_speed, nothing to do here */
- dbg("%s: In PI = %d\n", __FUNCTION__, pi);
- if ((adapter_speed != bus_speed) &&
- ((rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, adapter_speed, bus_speed, max_bus_speed))))
- return rc;
- }
+ rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp);
+ if (rc)
+ return rc;
- down(&ctrl->crit_sect);
/* turn on board, blink green LED, turn off Amber LED */
if ((rc = p_slot->hpc_ops->slot_enable(p_slot))) {
err("%s: Issue of Slot Enable command failed\n", __FUNCTION__);
- up(&ctrl->crit_sect);
return rc;
}
- if ((rc = p_slot->hpc_ops->check_cmd_status(ctrl))) {
- err("%s: Failed to enable slot, error code(%d)\n", __FUNCTION__, rc);
- up(&ctrl->crit_sect);
- return rc;
- }
-
- up(&ctrl->crit_sect);
-
/* Wait for ~1 second */
- wait_for_ctrl_irq (ctrl);
+ msleep(1000);
dbg("%s: slot status = %x\n", __FUNCTION__, p_slot->status);
/* Check for a power fault */
@@ -520,40 +338,18 @@ static int board_added(struct slot *p_slot)
p_slot->is_a_board = 0x01;
p_slot->pwr_save = 1;
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
p_slot->hpc_ops->green_led_on(p_slot);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
return 0;
err_exit:
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
/* turn off slot, turn on Amber LED, turn off Green LED */
rc = p_slot->hpc_ops->slot_disable(p_slot);
if (rc) {
err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
- return rc;
- }
-
- rc = p_slot->hpc_ops->check_cmd_status(ctrl);
- if (rc) {
- err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
return rc;
}
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
return(rc);
}
@@ -580,37 +376,19 @@ static int remove_board(struct slot *p_slot)
if (p_slot->is_a_board)
p_slot->status = 0x01;
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
/* turn off slot, turn on Amber LED, turn off Green LED */
rc = p_slot->hpc_ops->slot_disable(p_slot);
if (rc) {
err("%s: Issue of Slot Disable command failed\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
return rc;
}
-
- rc = p_slot->hpc_ops->check_cmd_status(ctrl);
- if (rc) {
- err("%s: Failed to disable slot, error code(%d)\n", __FUNCTION__, rc);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
- return rc;
- }
rc = p_slot->hpc_ops->set_attention_status(p_slot, 0);
if (rc) {
err("%s: Issue of Set Attention command failed\n", __FUNCTION__);
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
return rc;
}
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
p_slot->pwr_save = 0;
p_slot->is_a_board = 0;
@@ -618,13 +396,10 @@ static int remove_board(struct slot *p_slot)
}
-static void pushbutton_helper_thread (unsigned long data)
-{
- pushbutton_pending = data;
-
- up(&event_semaphore);
-}
-
+struct pushbutton_work_info {
+ struct slot *p_slot;
+ struct work_struct work;
+};
/**
* shpchp_pushbutton_thread
@@ -633,96 +408,63 @@ static void pushbutton_helper_thread (unsigned long data)
* Handles all pending events and exits.
*
*/
-static void shpchp_pushbutton_thread (unsigned long slot)
+static void shpchp_pushbutton_thread(void *data)
{
- struct slot *p_slot = (struct slot *) slot;
- u8 getstatus;
-
- pushbutton_pending = 0;
-
- if (!p_slot) {
- dbg("%s: Error! slot NULL\n", __FUNCTION__);
- return;
- }
-
- p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
- if (getstatus) {
- p_slot->state = POWEROFF_STATE;
+ struct pushbutton_work_info *info = data;
+ struct slot *p_slot = info->p_slot;
+ mutex_lock(&p_slot->lock);
+ switch (p_slot->state) {
+ case POWEROFF_STATE:
+ mutex_unlock(&p_slot->lock);
shpchp_disable_slot(p_slot);
+ mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE;
- } else {
- p_slot->state = POWERON_STATE;
-
- if (shpchp_enable_slot(p_slot)) {
- /* Wait for exclusive access to hardware */
- down(&p_slot->ctrl->crit_sect);
-
+ break;
+ case POWERON_STATE:
+ mutex_unlock(&p_slot->lock);
+ if (shpchp_enable_slot(p_slot))
p_slot->hpc_ops->green_led_off(p_slot);
-
- /* Done with exclusive hardware access */
- up(&p_slot->ctrl->crit_sect);
- }
+ mutex_lock(&p_slot->lock);
p_slot->state = STATIC_STATE;
+ break;
+ default:
+ break;
}
+ mutex_unlock(&p_slot->lock);
- return;
-}
-
-
-/* this is the main worker thread */
-static int event_thread(void* data)
-{
- struct controller *ctrl;
- lock_kernel();
- daemonize("shpchpd_event");
- unlock_kernel();
-
- while (1) {
- dbg("!!!!event_thread sleeping\n");
- down_interruptible (&event_semaphore);
- dbg("event_thread woken finished = %d\n", event_finished);
- if (event_finished || signal_pending(current))
- break;
- /* Do stuff here */
- if (pushbutton_pending)
- shpchp_pushbutton_thread(pushbutton_pending);
- else
- for (ctrl = shpchp_ctrl_list; ctrl; ctrl=ctrl->next)
- interrupt_event_handler(ctrl);
- }
- dbg("event_thread signals exit\n");
- up(&event_exit);
- return 0;
+ kfree(info);
}
-int shpchp_event_start_thread (void)
+void queue_pushbutton_work(void *data)
{
- int pid;
+ struct slot *p_slot = data;
+ struct pushbutton_work_info *info;
- /* initialize our semaphores */
- init_MUTEX_LOCKED(&event_exit);
- event_finished=0;
-
- init_MUTEX_LOCKED(&event_semaphore);
- pid = kernel_thread(event_thread, NULL, 0);
-
- if (pid < 0) {
- err ("Can't start up our event thread\n");
- return -1;
+ info = kmalloc(sizeof(*info), GFP_KERNEL);
+ if (!info) {
+ err("%s: Cannot allocate memory\n", __FUNCTION__);
+ return;
}
- return 0;
-}
-
+ info->p_slot = p_slot;
+ INIT_WORK(&info->work, shpchp_pushbutton_thread, info);
-void shpchp_event_stop_thread (void)
-{
- event_finished = 1;
- up(&event_semaphore);
- down(&event_exit);
+ mutex_lock(&p_slot->lock);
+ switch (p_slot->state) {
+ case BLINKINGOFF_STATE:
+ p_slot->state = POWEROFF_STATE;
+ break;
+ case BLINKINGON_STATE:
+ p_slot->state = POWERON_STATE;
+ break;
+ default:
+ goto out;
+ }
+ queue_work(shpchp_wq, &info->work);
+ out:
+ mutex_unlock(&p_slot->lock);
}
-
static int update_slot_info (struct slot *slot)
{
struct hotplug_slot_info *info;
@@ -742,149 +484,110 @@ static int update_slot_info (struct slot *slot)
return result;
}
-static void interrupt_event_handler(struct controller *ctrl)
+/*
+ * Note: This function must be called with slot->lock held
+ */
+static void handle_button_press_event(struct slot *p_slot)
{
- int loop = 0;
- int change = 1;
- u8 hp_slot;
u8 getstatus;
- struct slot *p_slot;
- while (change) {
- change = 0;
-
- for (loop = 0; loop < 10; loop++) {
- if (ctrl->event_queue[loop].event_type != 0) {
- dbg("%s:loop %x event_type %x\n", __FUNCTION__, loop,
- ctrl->event_queue[loop].event_type);
- hp_slot = ctrl->event_queue[loop].hp_slot;
-
- p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
-
- if (ctrl->event_queue[loop].event_type == INT_BUTTON_CANCEL) {
- dbg("%s: button cancel\n", __FUNCTION__);
- del_timer(&p_slot->task_event);
-
- switch (p_slot->state) {
- case BLINKINGOFF_STATE:
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
- p_slot->hpc_ops->green_led_on(p_slot);
-
- p_slot->hpc_ops->set_attention_status(p_slot, 0);
-
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
- break;
- case BLINKINGON_STATE:
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
- p_slot->hpc_ops->green_led_off(p_slot);
-
- p_slot->hpc_ops->set_attention_status(p_slot, 0);
-
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
- break;
- default:
- warn("Not a valid state\n");
- return;
- }
- info(msg_button_cancel, p_slot->number);
- p_slot->state = STATIC_STATE;
- } else if (ctrl->event_queue[loop].event_type == INT_BUTTON_PRESS) {
- /* Button Pressed (No action on 1st press...) */
- dbg("%s: Button pressed\n", __FUNCTION__);
-
- p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
- if (getstatus) {
- /* slot is on */
- dbg("%s: slot is on\n", __FUNCTION__);
- p_slot->state = BLINKINGOFF_STATE;
- info(msg_button_off, p_slot->number);
- } else {
- /* slot is off */
- dbg("%s: slot is off\n", __FUNCTION__);
- p_slot->state = BLINKINGON_STATE;
- info(msg_button_on, p_slot->number);
- }
-
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
- /* blink green LED and turn off amber */
- p_slot->hpc_ops->green_led_blink(p_slot);
-
- p_slot->hpc_ops->set_attention_status(p_slot, 0);
-
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
-
- init_timer(&p_slot->task_event);
- p_slot->task_event.expires = jiffies + 5 * HZ; /* 5 second delay */
- p_slot->task_event.function = (void (*)(unsigned long)) pushbutton_helper_thread;
- p_slot->task_event.data = (unsigned long) p_slot;
-
- dbg("%s: add_timer p_slot = %p\n", __FUNCTION__,(void *) p_slot);
- add_timer(&p_slot->task_event);
- } else if (ctrl->event_queue[loop].event_type == INT_POWER_FAULT) {
- /***********POWER FAULT********************/
- dbg("%s: power fault\n", __FUNCTION__);
- /* Wait for exclusive access to hardware */
- down(&ctrl->crit_sect);
-
- p_slot->hpc_ops->set_attention_status(p_slot, 1);
-
- p_slot->hpc_ops->green_led_off(p_slot);
-
- /* Done with exclusive hardware access */
- up(&ctrl->crit_sect);
- } else {
- /* refresh notification */
- if (p_slot)
- update_slot_info(p_slot);
- }
-
- ctrl->event_queue[loop].event_type = 0;
-
- change = 1;
- }
- } /* End of FOR loop */
+ switch (p_slot->state) {
+ case STATIC_STATE:
+ p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+ if (getstatus) {
+ p_slot->state = BLINKINGOFF_STATE;
+ info(msg_button_off, p_slot->number);
+ } else {
+ p_slot->state = BLINKINGON_STATE;
+ info(msg_button_on, p_slot->number);
+ }
+ /* blink green LED and turn off amber */
+ p_slot->hpc_ops->green_led_blink(p_slot);
+ p_slot->hpc_ops->set_attention_status(p_slot, 0);
+
+ schedule_delayed_work(&p_slot->work, 5*HZ);
+ break;
+ case BLINKINGOFF_STATE:
+ case BLINKINGON_STATE:
+ /*
+ * Cancel if we are still blinking; this means that we
+ * press the attention again before the 5 sec. limit
+ * expires to cancel hot-add or hot-remove
+ */
+ info("Button cancel on Slot(%s)\n", p_slot->name);
+ dbg("%s: button cancel\n", __FUNCTION__);
+ cancel_delayed_work(&p_slot->work);
+ if (p_slot->state == BLINKINGOFF_STATE)
+ p_slot->hpc_ops->green_led_on(p_slot);
+ else
+ p_slot->hpc_ops->green_led_off(p_slot);
+ p_slot->hpc_ops->set_attention_status(p_slot, 0);
+ info(msg_button_cancel, p_slot->number);
+ p_slot->state = STATIC_STATE;
+ break;
+ case POWEROFF_STATE:
+ case POWERON_STATE:
+ /*
+ * Ignore if the slot is on power-on or power-off state;
+ * this means that the previous attention button action
+ * to hot-add or hot-remove is undergoing
+ */
+ info("Button ignore on Slot(%s)\n", p_slot->name);
+ update_slot_info(p_slot);
+ break;
+ default:
+ warn("Not a valid state\n");
+ break;
}
+}
+
+static void interrupt_event_handler(void *data)
+{
+ struct event_info *info = data;
+ struct slot *p_slot = info->p_slot;
+
+ mutex_lock(&p_slot->lock);
+ switch (info->event_type) {
+ case INT_BUTTON_PRESS:
+ handle_button_press_event(p_slot);
+ break;
+ case INT_POWER_FAULT:
+ dbg("%s: power fault\n", __FUNCTION__);
+ p_slot->hpc_ops->set_attention_status(p_slot, 1);
+ p_slot->hpc_ops->green_led_off(p_slot);
+ break;
+ default:
+ update_slot_info(p_slot);
+ break;
+ }
+ mutex_unlock(&p_slot->lock);
- return;
+ kfree(info);
}
-int shpchp_enable_slot (struct slot *p_slot)
+static int shpchp_enable_slot (struct slot *p_slot)
{
u8 getstatus = 0;
- int rc;
+ int rc, retval = -ENODEV;
/* Check to see if (latch closed, card present, power off) */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
if (rc || !getstatus) {
info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
if (rc || getstatus) {
info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
if (rc || getstatus) {
info("%s: already enabled on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
- up(&p_slot->ctrl->crit_sect);
p_slot->is_a_board = 1;
@@ -899,56 +602,119 @@ int shpchp_enable_slot (struct slot *p_slot)
&& p_slot->ctrl->num_slots == 1) {
/* handle amd pogo errata; this must be done before enable */
amd_pogo_errata_save_misc_reg(p_slot);
- rc = board_added(p_slot);
+ retval = board_added(p_slot);
/* handle amd pogo errata; this must be done after enable */
amd_pogo_errata_restore_misc_reg(p_slot);
} else
- rc = board_added(p_slot);
+ retval = board_added(p_slot);
- if (rc) {
+ if (retval) {
p_slot->hpc_ops->get_adapter_status(p_slot,
&(p_slot->presence_save));
p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
}
update_slot_info(p_slot);
- return rc;
+ out:
+ mutex_unlock(&p_slot->ctrl->crit_sect);
+ return retval;
}
-int shpchp_disable_slot (struct slot *p_slot)
+static int shpchp_disable_slot (struct slot *p_slot)
{
u8 getstatus = 0;
- int ret = 0;
+ int rc, retval = -ENODEV;
if (!p_slot->ctrl)
return -ENODEV;
/* Check to see if (latch closed, card present, power on) */
- down(&p_slot->ctrl->crit_sect);
+ mutex_lock(&p_slot->ctrl->crit_sect);
- ret = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
- if (ret || !getstatus) {
+ rc = p_slot->hpc_ops->get_adapter_status(p_slot, &getstatus);
+ if (rc || !getstatus) {
info("%s: no adapter on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
- ret = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
- if (ret || getstatus) {
+ rc = p_slot->hpc_ops->get_latch_status(p_slot, &getstatus);
+ if (rc || getstatus) {
info("%s: latch open on slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
- ret = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
- if (ret || !getstatus) {
+ rc = p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
+ if (rc || !getstatus) {
info("%s: already disabled slot(%x)\n", __FUNCTION__, p_slot->number);
- up(&p_slot->ctrl->crit_sect);
- return -ENODEV;
+ goto out;
}
- up(&p_slot->ctrl->crit_sect);
- ret = remove_board(p_slot);
+ retval = remove_board(p_slot);
update_slot_info(p_slot);
- return ret;
+ out:
+ mutex_unlock(&p_slot->ctrl->crit_sect);
+ return retval;
}
+int shpchp_sysfs_enable_slot(struct slot *p_slot)
+{
+ int retval = -ENODEV;
+
+ mutex_lock(&p_slot->lock);
+ switch (p_slot->state) {
+ case BLINKINGON_STATE:
+ cancel_delayed_work(&p_slot->work);
+ case STATIC_STATE:
+ p_slot->state = POWERON_STATE;
+ mutex_unlock(&p_slot->lock);
+ retval = shpchp_enable_slot(p_slot);
+ mutex_lock(&p_slot->lock);
+ p_slot->state = STATIC_STATE;
+ break;
+ case POWERON_STATE:
+ info("Slot %s is already in powering on state\n",
+ p_slot->name);
+ break;
+ case BLINKINGOFF_STATE:
+ case POWEROFF_STATE:
+ info("Already enabled on slot %s\n", p_slot->name);
+ break;
+ default:
+ err("Not a valid state on slot %s\n", p_slot->name);
+ break;
+ }
+ mutex_unlock(&p_slot->lock);
+
+ return retval;
+}
+
+int shpchp_sysfs_disable_slot(struct slot *p_slot)
+{
+ int retval = -ENODEV;
+
+ mutex_lock(&p_slot->lock);
+ switch (p_slot->state) {
+ case BLINKINGOFF_STATE:
+ cancel_delayed_work(&p_slot->work);
+ case STATIC_STATE:
+ p_slot->state = POWEROFF_STATE;
+ mutex_unlock(&p_slot->lock);
+ retval = shpchp_disable_slot(p_slot);
+ mutex_lock(&p_slot->lock);
+ p_slot->state = STATIC_STATE;
+ break;
+ case POWEROFF_STATE:
+ info("Slot %s is already in powering off state\n",
+ p_slot->name);
+ break;
+ case BLINKINGON_STATE:
+ case POWERON_STATE:
+ info("Already disabled on slot %s\n", p_slot->name);
+ break;
+ default:
+ err("Not a valid state on slot %s\n", p_slot->name);
+ break;
+ }
+ mutex_unlock(&p_slot->lock);
+
+ return retval;
+}
diff --git a/drivers/pci/hotplug/shpchp_hpc.c b/drivers/pci/hotplug/shpchp_hpc.c
index b4226ff3a85..66123cf4dea 100644
--- a/drivers/pci/hotplug/shpchp_hpc.c
+++ b/drivers/pci/hotplug/shpchp_hpc.c
@@ -82,31 +82,6 @@
#define SLOT_100MHZ_PCIX_533 0x0f000000
#define SLOT_133MHZ_PCIX_533 0xf0000000
-
-/* Secondary Bus Configuration Register */
-/* For PI = 1, Bits 0 to 2 have been encoded as follows to show current bus speed/mode */
-#define PCI_33MHZ 0x0
-#define PCI_66MHZ 0x1
-#define PCIX_66MHZ 0x2
-#define PCIX_100MHZ 0x3
-#define PCIX_133MHZ 0x4
-
-/* For PI = 2, Bits 0 to 3 have been encoded as follows to show current bus speed/mode */
-#define PCI_33MHZ 0x0
-#define PCI_66MHZ 0x1
-#define PCIX_66MHZ 0x2
-#define PCIX_100MHZ 0x3
-#define PCIX_133MHZ 0x4
-#define PCIX_66MHZ_ECC 0x5
-#define PCIX_100MHZ_ECC 0x6
-#define PCIX_133MHZ_ECC 0x7
-#define PCIX_66MHZ_266 0x9
-#define PCIX_100MHZ_266 0xa
-#define PCIX_133MHZ_266 0xb
-#define PCIX_66MHZ_533 0x11
-#define PCIX_100MHZ_533 0x12
-#define PCIX_133MHZ_533 0x13
-
/* Slot Configuration */
#define SLOT_NUM 0x0000001F
#define FIRST_DEV_NUM 0x00001F00
@@ -231,6 +206,7 @@ static spinlock_t list_lock;
static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs);
static void start_int_poll_timer(struct php_ctlr_state_s *php_ctlr, int seconds);
+static int hpc_check_cmd_status(struct controller *ctrl);
/* This is the interrupt polling timeout function. */
static void int_poll_timeout(unsigned long lphp_ctlr)
@@ -303,10 +279,13 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
int i;
DBG_ENTER_ROUTINE
-
+
+ mutex_lock(&slot->ctrl->cmd_lock);
+
if (!php_ctlr) {
err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
- return -1;
+ retval = -EINVAL;
+ goto out;
}
for (i = 0; i < 10; i++) {
@@ -323,7 +302,8 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
if (cmd_status & 0x1) {
/* After 1 sec and and the controller is still busy */
err("%s : Controller is still busy after 1 sec.\n", __FUNCTION__);
- return -1;
+ retval = -EBUSY;
+ goto out;
}
++t_slot;
@@ -340,6 +320,17 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
* Wait for command completion.
*/
retval = shpc_wait_cmd(slot->ctrl);
+ if (retval)
+ goto out;
+
+ cmd_status = hpc_check_cmd_status(slot->ctrl);
+ if (cmd_status) {
+ err("%s: Failed to issued command 0x%x (error code = %d)\n",
+ __FUNCTION__, cmd, cmd_status);
+ retval = -EIO;
+ }
+ out:
+ mutex_unlock(&slot->ctrl->cmd_lock);
DBG_LEAVE_ROUTINE
return retval;
@@ -532,81 +523,41 @@ static int hpc_get_prog_int(struct slot *slot, u8 *prog_int)
static int hpc_get_adapter_speed(struct slot *slot, enum pci_bus_speed *value)
{
- struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
- u32 slot_reg;
- u16 slot_status, sec_bus_status;
- u8 m66_cap, pcix_cap, pi;
int retval = 0;
+ struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
+ u32 slot_reg = readl(php_ctlr->creg + SLOT1 + 4 * slot->hp_slot);
+ u8 pcix_cap = (slot_reg >> 12) & 7;
+ u8 m66_cap = (slot_reg >> 9) & 1;
DBG_ENTER_ROUTINE
- if (!slot->ctrl->hpc_ctlr_handle) {
- err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
- return -1;
- }
-
- if (slot->hp_slot >= php_ctlr->num_slots) {
- err("%s: Invalid HPC slot number!\n", __FUNCTION__);
- return -1;
- }
-
- pi = readb(php_ctlr->creg + PROG_INTERFACE);
- slot_reg = readl(php_ctlr->creg + SLOT1 + 4*(slot->hp_slot));
- dbg("%s: pi = %d, slot_reg = %x\n", __FUNCTION__, pi, slot_reg);
- slot_status = (u16) slot_reg;
- dbg("%s: slot_status = %x\n", __FUNCTION__, slot_status);
- sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG);
-
- pcix_cap = (u8) ((slot_status & 0x3000) >> 12);
- dbg("%s: pcix_cap = %x\n", __FUNCTION__, pcix_cap);
- m66_cap = (u8) ((slot_status & 0x0200) >> 9);
- dbg("%s: m66_cap = %x\n", __FUNCTION__, m66_cap);
-
+ dbg("%s: slot_reg = %x, pcix_cap = %x, m66_cap = %x\n",
+ __FUNCTION__, slot_reg, pcix_cap, m66_cap);
- if (pi == 2) {
- switch (pcix_cap) {
- case 0:
- *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
- break;
- case 1:
- *value = PCI_SPEED_66MHz_PCIX;
- break;
- case 3:
- *value = PCI_SPEED_133MHz_PCIX;
- break;
- case 4:
- *value = PCI_SPEED_133MHz_PCIX_266;
- break;
- case 5:
- *value = PCI_SPEED_133MHz_PCIX_533;
- break;
- case 2: /* Reserved */
- default:
- *value = PCI_SPEED_UNKNOWN;
- retval = -ENODEV;
- break;
- }
- } else {
- switch (pcix_cap) {
- case 0:
- *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
- break;
- case 1:
- *value = PCI_SPEED_66MHz_PCIX;
- break;
- case 3:
- *value = PCI_SPEED_133MHz_PCIX;
- break;
- case 2: /* Reserved */
- default:
- *value = PCI_SPEED_UNKNOWN;
- retval = -ENODEV;
- break;
- }
+ switch (pcix_cap) {
+ case 0x0:
+ *value = m66_cap ? PCI_SPEED_66MHz : PCI_SPEED_33MHz;
+ break;
+ case 0x1:
+ *value = PCI_SPEED_66MHz_PCIX;
+ break;
+ case 0x3:
+ *value = PCI_SPEED_133MHz_PCIX;
+ break;
+ case 0x4:
+ *value = PCI_SPEED_133MHz_PCIX_266;
+ break;
+ case 0x5:
+ *value = PCI_SPEED_133MHz_PCIX_533;
+ break;
+ case 0x2:
+ default:
+ *value = PCI_SPEED_UNKNOWN;
+ retval = -ENODEV;
+ break;
}
dbg("Adapter speed = %d\n", *value);
-
DBG_LEAVE_ROUTINE
return retval;
}
@@ -797,6 +748,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
{
struct php_ctlr_state_s *php_ctlr = ctrl->hpc_ctlr_handle;
struct php_ctlr_state_s *p, *p_prev;
+ int i;
DBG_ENTER_ROUTINE
@@ -805,6 +757,14 @@ static void hpc_release_ctlr(struct controller *ctrl)
return ;
}
+ /*
+ * Mask all slot event interrupts
+ */
+ for (i = 0; i < ctrl->num_slots; i++)
+ writel(0xffff3fff, php_ctlr->creg + SLOT1 + (4 * i));
+
+ cleanup_slots(ctrl);
+
if (shpchp_poll_mode) {
del_timer(&php_ctlr->int_poll_timer);
} else {
@@ -814,6 +774,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
pci_disable_msi(php_ctlr->pci_dev);
}
}
+
if (php_ctlr->pci_dev) {
iounmap(php_ctlr->creg);
release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
@@ -939,98 +900,66 @@ static int hpc_slot_disable(struct slot * slot)
static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value)
{
- u8 slot_cmd;
- u8 pi;
- int retval = 0;
+ int retval;
struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
+ u8 pi, cmd;
DBG_ENTER_ROUTINE
-
- if (!slot->ctrl->hpc_ctlr_handle) {
- err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
- return -1;
- }
pi = readb(php_ctlr->creg + PROG_INTERFACE);
-
- if (pi == 1) {
- switch (value) {
- case 0:
- slot_cmd = SETA_PCI_33MHZ;
- break;
- case 1:
- slot_cmd = SETA_PCI_66MHZ;
- break;
- case 2:
- slot_cmd = SETA_PCIX_66MHZ;
- break;
- case 3:
- slot_cmd = SETA_PCIX_100MHZ;
- break;
- case 4:
- slot_cmd = SETA_PCIX_133MHZ;
- break;
- default:
- slot_cmd = PCI_SPEED_UNKNOWN;
- retval = -ENODEV;
- return retval;
- }
- } else {
- switch (value) {
- case 0:
- slot_cmd = SETB_PCI_33MHZ;
- break;
- case 1:
- slot_cmd = SETB_PCI_66MHZ;
- break;
- case 2:
- slot_cmd = SETB_PCIX_66MHZ_PM;
- break;
- case 3:
- slot_cmd = SETB_PCIX_100MHZ_PM;
- break;
- case 4:
- slot_cmd = SETB_PCIX_133MHZ_PM;
- break;
- case 5:
- slot_cmd = SETB_PCIX_66MHZ_EM;
- break;
- case 6:
- slot_cmd = SETB_PCIX_100MHZ_EM;
- break;
- case 7:
- slot_cmd = SETB_PCIX_133MHZ_EM;
- break;
- case 8:
- slot_cmd = SETB_PCIX_66MHZ_266;
- break;
- case 0x9:
- slot_cmd = SETB_PCIX_100MHZ_266;
- break;
- case 0xa:
- slot_cmd = SETB_PCIX_133MHZ_266;
- break;
- case 0xb:
- slot_cmd = SETB_PCIX_66MHZ_533;
- break;
- case 0xc:
- slot_cmd = SETB_PCIX_100MHZ_533;
- break;
- case 0xd:
- slot_cmd = SETB_PCIX_133MHZ_533;
- break;
- default:
- slot_cmd = PCI_SPEED_UNKNOWN;
- retval = -ENODEV;
- return retval;
- }
+ if ((pi == 1) && (value > PCI_SPEED_133MHz_PCIX))
+ return -EINVAL;
+ switch (value) {
+ case PCI_SPEED_33MHz:
+ cmd = SETA_PCI_33MHZ;
+ break;
+ case PCI_SPEED_66MHz:
+ cmd = SETA_PCI_66MHZ;
+ break;
+ case PCI_SPEED_66MHz_PCIX:
+ cmd = SETA_PCIX_66MHZ;
+ break;
+ case PCI_SPEED_100MHz_PCIX:
+ cmd = SETA_PCIX_100MHZ;
+ break;
+ case PCI_SPEED_133MHz_PCIX:
+ cmd = SETA_PCIX_133MHZ;
+ break;
+ case PCI_SPEED_66MHz_PCIX_ECC:
+ cmd = SETB_PCIX_66MHZ_EM;
+ break;
+ case PCI_SPEED_100MHz_PCIX_ECC:
+ cmd = SETB_PCIX_100MHZ_EM;
+ break;
+ case PCI_SPEED_133MHz_PCIX_ECC:
+ cmd = SETB_PCIX_133MHZ_EM;
+ break;
+ case PCI_SPEED_66MHz_PCIX_266:
+ cmd = SETB_PCIX_66MHZ_266;
+ break;
+ case PCI_SPEED_100MHz_PCIX_266:
+ cmd = SETB_PCIX_100MHZ_266;
+ break;
+ case PCI_SPEED_133MHz_PCIX_266:
+ cmd = SETB_PCIX_133MHZ_266;
+ break;
+ case PCI_SPEED_66MHz_PCIX_533:
+ cmd = SETB_PCIX_66MHZ_533;
+ break;
+ case PCI_SPEED_100MHz_PCIX_533:
+ cmd = SETB_PCIX_100MHZ_533;
+ break;
+ case PCI_SPEED_133MHz_PCIX_533:
+ cmd = SETB_PCIX_133MHZ_533;
+ break;
+ default:
+ return -EINVAL;
}
- retval = shpc_write_cmd(slot, 0, slot_cmd);
- if (retval) {
+
+ retval = shpc_write_cmd(slot, 0, cmd);
+ if (retval)
err("%s: Write command failed!\n", __FUNCTION__);
- return -1;
- }
DBG_LEAVE_ROUTINE
return retval;
@@ -1093,14 +1022,8 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
wake_up_interruptible(&ctrl->queue);
}
- if ((intr_loc = (intr_loc >> 1)) == 0) {
- /* Unmask Global Interrupt Mask */
- temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
- temp_dword &= 0xfffffffe;
- writel(temp_dword, php_ctlr->creg + SERR_INTR_ENABLE);
-
- return IRQ_NONE;
- }
+ if ((intr_loc = (intr_loc >> 1)) == 0)
+ goto out;
for (hp_slot = 0; hp_slot < ctrl->num_slots; hp_slot++) {
/* To find out which slot has interrupt pending */
@@ -1130,6 +1053,7 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
dbg("%s: intr_loc2 = %x\n",__FUNCTION__, intr_loc2);
}
}
+ out:
if (!shpchp_poll_mode) {
/* Unmask Global Interrupt Mask */
temp_dword = readl(php_ctlr->creg + SERR_INTR_ENABLE);
@@ -1142,64 +1066,43 @@ static irqreturn_t shpc_isr(int IRQ, void *dev_id, struct pt_regs *regs)
static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
{
+ int retval = 0;
struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
- int retval = 0;
- u8 pi;
- u32 slot_avail1, slot_avail2;
+ u8 pi = readb(php_ctlr->creg + PROG_INTERFACE);
+ u32 slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1);
+ u32 slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2);
DBG_ENTER_ROUTINE
- if (!slot->ctrl->hpc_ctlr_handle) {
- err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
- return -1;
- }
-
- if (slot->hp_slot >= php_ctlr->num_slots) {
- err("%s: Invalid HPC slot number!\n", __FUNCTION__);
- return -1;
- }
-
- pi = readb(php_ctlr->creg + PROG_INTERFACE);
- slot_avail1 = readl(php_ctlr->creg + SLOT_AVAIL1);
- slot_avail2 = readl(php_ctlr->creg + SLOT_AVAIL2);
-
if (pi == 2) {
if (slot_avail2 & SLOT_133MHZ_PCIX_533)
- bus_speed = PCIX_133MHZ_533;
+ bus_speed = PCI_SPEED_133MHz_PCIX_533;
else if (slot_avail2 & SLOT_100MHZ_PCIX_533)
- bus_speed = PCIX_100MHZ_533;
+ bus_speed = PCI_SPEED_100MHz_PCIX_533;
else if (slot_avail2 & SLOT_66MHZ_PCIX_533)
- bus_speed = PCIX_66MHZ_533;
+ bus_speed = PCI_SPEED_66MHz_PCIX_533;
else if (slot_avail2 & SLOT_133MHZ_PCIX_266)
- bus_speed = PCIX_133MHZ_266;
+ bus_speed = PCI_SPEED_133MHz_PCIX_266;
else if (slot_avail2 & SLOT_100MHZ_PCIX_266)
- bus_speed = PCIX_100MHZ_266;
+ bus_speed = PCI_SPEED_100MHz_PCIX_266;
else if (slot_avail2 & SLOT_66MHZ_PCIX_266)
- bus_speed = PCIX_66MHZ_266;
- else if (slot_avail1 & SLOT_133MHZ_PCIX)
- bus_speed = PCIX_133MHZ;
- else if (slot_avail1 & SLOT_100MHZ_PCIX)
- bus_speed = PCIX_100MHZ;
- else if (slot_avail1 & SLOT_66MHZ_PCIX)
- bus_speed = PCIX_66MHZ;
- else if (slot_avail2 & SLOT_66MHZ)
- bus_speed = PCI_66MHZ;
- else if (slot_avail1 & SLOT_33MHZ)
- bus_speed = PCI_33MHZ;
- else bus_speed = PCI_SPEED_UNKNOWN;
- } else {
+ bus_speed = PCI_SPEED_66MHz_PCIX_266;
+ }
+
+ if (bus_speed == PCI_SPEED_UNKNOWN) {
if (slot_avail1 & SLOT_133MHZ_PCIX)
- bus_speed = PCIX_133MHZ;
+ bus_speed = PCI_SPEED_133MHz_PCIX;
else if (slot_avail1 & SLOT_100MHZ_PCIX)
- bus_speed = PCIX_100MHZ;
+ bus_speed = PCI_SPEED_100MHz_PCIX;
else if (slot_avail1 & SLOT_66MHZ_PCIX)
- bus_speed = PCIX_66MHZ;
+ bus_speed = PCI_SPEED_66MHz_PCIX;
else if (slot_avail2 & SLOT_66MHZ)
- bus_speed = PCI_66MHZ;
+ bus_speed = PCI_SPEED_66MHz;
else if (slot_avail1 & SLOT_33MHZ)
- bus_speed = PCI_33MHZ;
- else bus_speed = PCI_SPEED_UNKNOWN;
+ bus_speed = PCI_SPEED_33MHz;
+ else
+ retval = -ENODEV;
}
*value = bus_speed;
@@ -1210,111 +1113,69 @@ static int hpc_get_max_bus_speed (struct slot *slot, enum pci_bus_speed *value)
static int hpc_get_cur_bus_speed (struct slot *slot, enum pci_bus_speed *value)
{
+ int retval = 0;
struct php_ctlr_state_s *php_ctlr = slot->ctrl->hpc_ctlr_handle;
enum pci_bus_speed bus_speed = PCI_SPEED_UNKNOWN;
- u16 sec_bus_status;
- int retval = 0;
- u8 pi;
+ u16 sec_bus_reg = readw(php_ctlr->creg + SEC_BUS_CONFIG);
+ u8 pi = readb(php_ctlr->creg + PROG_INTERFACE);
+ u8 speed_mode = (pi == 2) ? (sec_bus_reg & 0xF) : (sec_bus_reg & 0x7);
DBG_ENTER_ROUTINE
- if (!slot->ctrl->hpc_ctlr_handle) {
- err("%s: Invalid HPC controller handle!\n", __FUNCTION__);
- return -1;
- }
-
- if (slot->hp_slot >= php_ctlr->num_slots) {
- err("%s: Invalid HPC slot number!\n", __FUNCTION__);
- return -1;
+ if ((pi == 1) && (speed_mode > 4)) {
+ *value = PCI_SPEED_UNKNOWN;
+ return -ENODEV;
}
- pi = readb(php_ctlr->creg + PROG_INTERFACE);
- sec_bus_status = readw(php_ctlr->creg + SEC_BUS_CONFIG);
-
- if (pi == 2) {
- switch (sec_bus_status & 0x000f) {
- case 0:
- bus_speed = PCI_SPEED_33MHz;
- break;
- case 1:
- bus_speed = PCI_SPEED_66MHz;
- break;
- case 2:
- bus_speed = PCI_SPEED_66MHz_PCIX;
- break;
- case 3:
- bus_speed = PCI_SPEED_100MHz_PCIX;
- break;
- case 4:
- bus_speed = PCI_SPEED_133MHz_PCIX;
- break;
- case 5:
- bus_speed = PCI_SPEED_66MHz_PCIX_ECC;
- break;
- case 6:
- bus_speed = PCI_SPEED_100MHz_PCIX_ECC;
- break;
- case 7:
- bus_speed = PCI_SPEED_133MHz_PCIX_ECC;
- break;
- case 8:
- bus_speed = PCI_SPEED_66MHz_PCIX_266;
- break;
- case 9:
- bus_speed = PCI_SPEED_100MHz_PCIX_266;
- break;
- case 0xa:
- bus_speed = PCI_SPEED_133MHz_PCIX_266;
- break;
- case 0xb:
- bus_speed = PCI_SPEED_66MHz_PCIX_533;
- break;
- case 0xc:
- bus_speed = PCI_SPEED_100MHz_PCIX_533;
- break;
- case 0xd:
- bus_speed = PCI_SPEED_133MHz_PCIX_533;
- break;
- case 0xe:
- case 0xf:
- default:
- bus_speed = PCI_SPEED_UNKNOWN;
- break;
- }
- } else {
- /* In the case where pi is undefined, default it to 1 */
- switch (sec_bus_status & 0x0007) {
- case 0:
- bus_speed = PCI_SPEED_33MHz;
- break;
- case 1:
- bus_speed = PCI_SPEED_66MHz;
- break;
- case 2:
- bus_speed = PCI_SPEED_66MHz_PCIX;
- break;
- case 3:
- bus_speed = PCI_SPEED_100MHz_PCIX;
- break;
- case 4:
- bus_speed = PCI_SPEED_133MHz_PCIX;
- break;
- case 5:
- bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */
- break;
- case 6:
- bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */
- break;
- case 7:
- bus_speed = PCI_SPEED_UNKNOWN; /* Reserved */
- break;
- default:
- bus_speed = PCI_SPEED_UNKNOWN;
- break;
- }
+ switch (speed_mode) {
+ case 0x0:
+ *value = PCI_SPEED_33MHz;
+ break;
+ case 0x1:
+ *value = PCI_SPEED_66MHz;
+ break;
+ case 0x2:
+ *value = PCI_SPEED_66MHz_PCIX;
+ break;
+ case 0x3:
+ *value = PCI_SPEED_100MHz_PCIX;
+ break;
+ case 0x4:
+ *value = PCI_SPEED_133MHz_PCIX;
+ break;
+ case 0x5:
+ *value = PCI_SPEED_66MHz_PCIX_ECC;
+ break;
+ case 0x6:
+ *value = PCI_SPEED_100MHz_PCIX_ECC;
+ break;
+ case 0x7:
+ *value = PCI_SPEED_133MHz_PCIX_ECC;
+ break;
+ case 0x8:
+ *value = PCI_SPEED_66MHz_PCIX_266;
+ break;
+ case 0x9:
+ *value = PCI_SPEED_100MHz_PCIX_266;
+ break;
+ case 0xa:
+ *value = PCI_SPEED_133MHz_PCIX_266;
+ break;
+ case 0xb:
+ *value = PCI_SPEED_66MHz_PCIX_533;
+ break;
+ case 0xc:
+ *value = PCI_SPEED_100MHz_PCIX_533;
+ break;
+ case 0xd:
+ *value = PCI_SPEED_133MHz_PCIX_533;
+ break;
+ default:
+ *value = PCI_SPEED_UNKNOWN;
+ retval = -ENODEV;
+ break;
}
- *value = bus_speed;
dbg("Current bus speed = %d\n", bus_speed);
DBG_LEAVE_ROUTINE
return retval;
@@ -1343,7 +1204,6 @@ static struct hpc_ops shpchp_hpc_ops = {
.green_led_blink = hpc_set_green_led_blink,
.release_ctlr = hpc_release_ctlr,
- .check_cmd_status = hpc_check_cmd_status,
};
inline static int shpc_indirect_creg_read(struct controller *ctrl, int index,
@@ -1375,15 +1235,13 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
ctrl->pci_dev = pdev; /* pci_dev of the P2P bridge */
spin_lock_init(&list_lock);
- php_ctlr = (struct php_ctlr_state_s *) kmalloc(sizeof(struct php_ctlr_state_s), GFP_KERNEL);
+ php_ctlr = kzalloc(sizeof(*php_ctlr), GFP_KERNEL);
if (!php_ctlr) { /* allocate controller state data */
err("%s: HPC controller memory allocation error!\n", __FUNCTION__);
goto abort;
}
- memset(php_ctlr, 0, sizeof(struct php_ctlr_state_s));
-
php_ctlr->pci_dev = pdev; /* save pci_dev in context */
if ((pdev->vendor == PCI_VENDOR_ID_AMD) || (pdev->device ==
@@ -1454,7 +1312,9 @@ int shpc_init(struct controller * ctrl, struct pci_dev * pdev)
}
dbg("%s: php_ctlr->creg %p\n", __FUNCTION__, php_ctlr->creg);
- init_MUTEX(&ctrl->crit_sect);
+ mutex_init(&ctrl->crit_sect);
+ mutex_init(&ctrl->cmd_lock);
+
/* Setup wait queue */
init_waitqueue_head(&ctrl->queue);
diff --git a/drivers/pci/hotplug/shpchp_pci.c b/drivers/pci/hotplug/shpchp_pci.c
index 19e1a5e1e30..257adc23399 100644
--- a/drivers/pci/hotplug/shpchp_pci.c
+++ b/drivers/pci/hotplug/shpchp_pci.c
@@ -38,7 +38,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
{
u16 pci_cmd, pci_bctl;
struct pci_dev *cdev;
- struct hotplug_params hpp = {0x8, 0x40, 0, 0}; /* defaults */
+ struct hotplug_params hpp;
/* Program hpp values for this device */
if (!(dev->hdr_type == PCI_HEADER_TYPE_NORMAL ||
@@ -46,7 +46,13 @@ static void program_fw_provided_values(struct pci_dev *dev)
(dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
return;
- get_hp_params_from_firmware(dev, &hpp);
+ /* use default values if we can't get them from firmware */
+ if (get_hp_params_from_firmware(dev, &hpp)) {
+ hpp.cache_line_size = 8;
+ hpp.latency_timer = 0x40;
+ hpp.enable_serr = 0;
+ hpp.enable_perr = 0;
+ }
pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, hpp.cache_line_size);
pci_write_config_byte(dev, PCI_LATENCY_TIMER, hpp.latency_timer);
diff --git a/drivers/pci/hotplug/shpchprm_legacy.c b/drivers/pci/hotplug/shpchprm_legacy.c
deleted file mode 100644
index ed6c1254bf6..00000000000
--- a/drivers/pci/hotplug/shpchprm_legacy.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SHPCHPRM Legacy: PHP Resource Manager for Non-ACPI/Legacy platform
- *
- * Copyright (C) 1995,2001 Compaq Computer Corporation
- * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2001 IBM Corp.
- * Copyright (C) 2003-2004 Intel Corporation
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <greg@kroah.com>,<kristen.c.accardi@intel.com>
- *
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include "shpchp.h"
-
-int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
-{
- int offset = devnum - ctrl->slot_device_offset;
-
- *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset);
- return 0;
-}
-
-void get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp)
-{
- return;
-}
-
-void get_hp_hw_control_from_firmware(struct pci_dev *dev)
-{
- return;
-}
-
diff --git a/drivers/pci/hotplug/shpchprm_nonacpi.c b/drivers/pci/hotplug/shpchprm_nonacpi.c
deleted file mode 100644
index c6b40998eeb..00000000000
--- a/drivers/pci/hotplug/shpchprm_nonacpi.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SHPCHPRM NONACPI: PHP Resource Manager for Non-ACPI/Legacy platform
- *
- * Copyright (C) 1995,2001 Compaq Computer Corporation
- * Copyright (C) 2001 Greg Kroah-Hartman (greg@kroah.com)
- * Copyright (C) 2001 IBM Corp.
- * Copyright (C) 2003-2004 Intel Corporation
- *
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Send feedback to <greg@kroah.com>, <kristen.c.accardi@intel.com>
- *
- */
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/pci.h>
-#include <linux/slab.h>
-
-#include "shpchp.h"
-
-int shpchprm_get_physical_slot_number(struct controller *ctrl, u32 *sun, u8 busnum, u8 devnum)
-{
- int offset = devnum - ctrl->slot_device_offset;
-
- dbg("%s: ctrl->slot_num_inc %d, offset %d\n", __FUNCTION__, ctrl->slot_num_inc, offset);
- *sun = (u8) (ctrl->first_slot + ctrl->slot_num_inc * offset);
- return 0;
-}
-
-void get_hp_params_from_firmware(struct pci_dev *dev,
- struct hotplug_params *hpp)
-{
- return;
-}
-
-void get_hp_hw_control_from_firmware(struct pci_dev *dev)
-{
- return;
-}
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 48723d6fa60..a77e79c8c82 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -103,9 +103,9 @@ static void set_msi_affinity(unsigned int vector, cpumask_t cpu_mask)
switch (entry->msi_attrib.type) {
case PCI_CAP_ID_MSI:
{
- int pos;
+ int pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI);
- if (!(pos = pci_find_capability(entry->dev, PCI_CAP_ID_MSI)))
+ if (!pos)
return;
pci_read_config_dword(entry->dev, msi_lower_address_reg(pos),
@@ -347,9 +347,9 @@ static int assign_msi_vector(void)
static int get_new_vector(void)
{
- int vector;
+ int vector = assign_msi_vector();
- if ((vector = assign_msi_vector()) > 0)
+ if (vector > 0)
set_intr_gate(vector, interrupt[vector]);
return vector;
@@ -369,7 +369,8 @@ static int msi_init(void)
return status;
}
- if ((status = msi_cache_init()) < 0) {
+ status = msi_cache_init();
+ if (status < 0) {
pci_msi_enable = 0;
printk(KERN_WARNING "PCI: MSI cache init failed\n");
return status;
@@ -523,10 +524,12 @@ static int msi_capability_init(struct pci_dev *dev)
pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
pci_read_config_word(dev, msi_control_reg(pos), &control);
/* MSI Entry Initialization */
- if (!(entry = alloc_msi_entry()))
+ entry = alloc_msi_entry();
+ if (!entry)
return -ENOMEM;
- if ((vector = get_msi_vector(dev)) < 0) {
+ vector = get_msi_vector(dev);
+ if (vector < 0) {
kmem_cache_free(msi_cachep, entry);
return -EBUSY;
}
@@ -597,7 +600,8 @@ static int msix_capability_init(struct pci_dev *dev,
struct msg_address address;
struct msg_data data;
int vector, pos, i, j, nr_entries, temp = 0;
- u32 phys_addr, table_offset;
+ unsigned long phys_addr;
+ u32 table_offset;
u16 control;
u8 bir;
void __iomem *base;
@@ -606,11 +610,11 @@ static int msix_capability_init(struct pci_dev *dev,
/* Request & Map MSI-X table region */
pci_read_config_word(dev, msi_control_reg(pos), &control);
nr_entries = multi_msix_capable(control);
- pci_read_config_dword(dev, msix_table_offset_reg(pos),
- &table_offset);
+
+ pci_read_config_dword(dev, msix_table_offset_reg(pos), &table_offset);
bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
- phys_addr = pci_resource_start (dev, bir);
- phys_addr += (u32)(table_offset & ~PCI_MSIX_FLAGS_BIRMASK);
+ table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
+ phys_addr = pci_resource_start (dev, bir) + table_offset;
base = ioremap_nocache(phys_addr, nr_entries * PCI_MSIX_ENTRY_SIZE);
if (base == NULL)
return -ENOMEM;
@@ -620,7 +624,8 @@ static int msix_capability_init(struct pci_dev *dev,
entry = alloc_msi_entry();
if (!entry)
break;
- if ((vector = get_msi_vector(dev)) < 0)
+ vector = get_msi_vector(dev);
+ if (vector < 0)
break;
j = entries[i].entry;
@@ -699,12 +704,17 @@ int pci_enable_msi(struct pci_dev* dev)
if (dev->no_msi)
return status;
+ if (dev->bus->bus_flags & PCI_BUS_FLAGS_NO_MSI)
+ return -EINVAL;
+
temp = dev->irq;
- if ((status = msi_init()) < 0)
+ status = msi_init();
+ if (status < 0)
return status;
- if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSI)))
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
+ if (!pos)
return -EINVAL;
pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -728,8 +738,8 @@ int pci_enable_msi(struct pci_dev* dev)
dev->irq = temp;
}
/* Check whether driver already requested for MSI-X vectors */
- if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 &&
- !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+ if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
printk(KERN_INFO "PCI: %s: Can't enable MSI. "
"Device already has MSI-X vectors assigned\n",
pci_name(dev));
@@ -755,7 +765,13 @@ void pci_disable_msi(struct pci_dev* dev)
u16 control;
unsigned long flags;
- if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSI)))
+ if (!pci_msi_enable)
+ return;
+ if (!dev)
+ return;
+
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
+ if (!pos)
return;
pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -826,8 +842,10 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign)
* Detect last MSI-X vector to be released.
* Release the MSI-X memory-mapped table.
*/
+#if 0
int pos, nr_entries;
- u32 phys_addr, table_offset;
+ unsigned long phys_addr;
+ u32 table_offset;
u16 control;
u8 bir;
@@ -838,9 +856,12 @@ static int msi_free_vector(struct pci_dev* dev, int vector, int reassign)
pci_read_config_dword(dev, msix_table_offset_reg(pos),
&table_offset);
bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
- phys_addr = pci_resource_start (dev, bir);
- phys_addr += (u32)(table_offset &
- ~PCI_MSIX_FLAGS_BIRMASK);
+ table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
+ phys_addr = pci_resource_start(dev, bir) + table_offset;
+/*
+ * FIXME! and what did you want to do with phys_addr?
+ */
+#endif
iounmap(base);
}
}
@@ -924,10 +945,12 @@ int pci_enable_msix(struct pci_dev* dev, struct msix_entry *entries, int nvec)
if (!pci_msi_enable || !dev || !entries)
return -EINVAL;
- if ((status = msi_init()) < 0)
+ status = msi_init();
+ if (status < 0)
return status;
- if (!(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)))
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+ if (!pos)
return -EINVAL;
pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -1006,7 +1029,13 @@ void pci_disable_msix(struct pci_dev* dev)
int pos, temp;
u16 control;
- if (!dev || !(pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)))
+ if (!pci_msi_enable)
+ return;
+ if (!dev)
+ return;
+
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+ if (!pos)
return;
pci_read_config_word(dev, msi_control_reg(pos), &control);
@@ -1066,8 +1095,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
return;
temp = dev->irq; /* Save IOAPIC IRQ */
- if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) > 0 &&
- !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) {
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
+ if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSI)) {
spin_lock_irqsave(&msi_lock, flags);
state = msi_desc[dev->irq]->msi_attrib.state;
spin_unlock_irqrestore(&msi_lock, flags);
@@ -1080,8 +1109,8 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
msi_free_vector(dev, dev->irq, 0);
dev->irq = temp; /* Restore IOAPIC IRQ */
}
- if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSIX)) > 0 &&
- !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
+ pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
+ if (pos > 0 && !msi_lookup_vector(dev, PCI_CAP_ID_MSIX)) {
int vector, head, tail = 0, warning = 0;
void __iomem *base = NULL;
@@ -1101,7 +1130,9 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
msi_free_vector(dev, vector, 0);
if (warning) {
/* Force to release the MSI-X memory-mapped table */
- u32 phys_addr, table_offset;
+#if 0
+ unsigned long phys_addr;
+ u32 table_offset;
u16 control;
u8 bir;
@@ -1110,9 +1141,12 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
pci_read_config_dword(dev, msix_table_offset_reg(pos),
&table_offset);
bir = (u8)(table_offset & PCI_MSIX_FLAGS_BIRMASK);
- phys_addr = pci_resource_start (dev, bir);
- phys_addr += (u32)(table_offset &
- ~PCI_MSIX_FLAGS_BIRMASK);
+ table_offset &= ~PCI_MSIX_FLAGS_BIRMASK;
+ phys_addr = pci_resource_start(dev, bir) + table_offset;
+/*
+ * FIXME! and what did you want to do with phys_addr?
+ */
+#endif
iounmap(base);
printk(KERN_WARNING "PCI: %s: msi_remove_pci_irq_vectors() "
"called without free_irq() on all MSI-X vectors\n",
@@ -1123,6 +1157,11 @@ void msi_remove_pci_irq_vectors(struct pci_dev* dev)
}
}
+void pci_no_msi(void)
+{
+ pci_msi_enable = 0;
+}
+
EXPORT_SYMBOL(pci_enable_msi);
EXPORT_SYMBOL(pci_disable_msi);
EXPORT_SYMBOL(pci_enable_msix);
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index 0aa14c92b57..f22f69ac644 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -53,11 +53,10 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
if (fields < 0)
return -EINVAL;
- dynid = kmalloc(sizeof(*dynid), GFP_KERNEL);
+ dynid = kzalloc(sizeof(*dynid), GFP_KERNEL);
if (!dynid)
return -ENOMEM;
- memset(dynid, 0, sizeof(*dynid));
INIT_LIST_HEAD(&dynid->node);
dynid->id.vendor = vendor;
dynid->id.device = device;
@@ -380,14 +379,6 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner)
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &pci_bus_type;
- /* FIXME, once all of the existing PCI drivers have been fixed to set
- * the pci shutdown function, this test can go away. */
- if (!drv->driver.shutdown)
- drv->driver.shutdown = pci_device_shutdown;
- else
- printk(KERN_WARNING "Warning: PCI driver %s has a struct "
- "device_driver shutdown method, please update!\n",
- drv->name);
drv->driver.owner = owner;
drv->driver.kobj.ktype = &pci_driver_kobj_type;
@@ -514,6 +505,7 @@ struct bus_type pci_bus_type = {
.probe = pci_device_probe,
.remove = pci_device_remove,
.suspend = pci_device_suspend,
+ .shutdown = pci_device_shutdown,
.resume = pci_device_resume,
.dev_attrs = pci_dev_attrs,
};
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 965a5934623..56ac2bc003c 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -501,9 +501,8 @@ int pci_create_sysfs_dev_files (struct pci_dev *pdev)
if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) {
struct bin_attribute *rom_attr;
- rom_attr = kmalloc(sizeof(*rom_attr), GFP_ATOMIC);
+ rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC);
if (rom_attr) {
- memset(rom_attr, 0x00, sizeof(*rom_attr));
pdev->rom_attr = rom_attr;
rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
rom_attr->attr.name = "rom";
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d2d18791664..bea1ad1ad5b 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -19,7 +19,6 @@
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"
-#if 0
/**
* pci_bus_max_busnr - returns maximum PCI bus number of given bus' children
@@ -34,7 +33,7 @@ pci_bus_max_busnr(struct pci_bus* bus)
struct list_head *tmp;
unsigned char max, n;
- max = bus->number;
+ max = bus->subordinate;
list_for_each(tmp, &bus->children) {
n = pci_bus_max_busnr(pci_bus_b(tmp));
if(n > max)
@@ -42,7 +41,9 @@ pci_bus_max_busnr(struct pci_bus* bus)
}
return max;
}
+EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
+#if 0
/**
* pci_max_busnr - returns maximum PCI bus number
*
@@ -495,9 +496,8 @@ pci_enable_device_bars(struct pci_dev *dev, int bars)
int
pci_enable_device(struct pci_dev *dev)
{
- int err;
-
- if ((err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1)))
+ int err = pci_enable_device_bars(dev, (1 << PCI_NUM_RESOURCES) - 1);
+ if (err)
return err;
pci_fixup_device(pci_fixup_enable, dev);
dev->is_enabled = 1;
@@ -639,7 +639,7 @@ void pci_release_region(struct pci_dev *pdev, int bar)
* Returns 0 on success, or %EBUSY on error. A warning
* message is also printed on failure.
*/
-int pci_request_region(struct pci_dev *pdev, int bar, char *res_name)
+int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
{
if (pci_resource_len(pdev, bar) == 0)
return 0;
@@ -697,7 +697,7 @@ void pci_release_regions(struct pci_dev *pdev)
* Returns 0 on success, or %EBUSY on error. A warning
* message is also printed on failure.
*/
-int pci_request_regions(struct pci_dev *pdev, char *res_name)
+int pci_request_regions(struct pci_dev *pdev, const char *res_name)
{
int i;
@@ -900,8 +900,12 @@ static int __devinit pci_setup(char *str)
if (k)
*k++ = 0;
if (*str && (str = pcibios_setup(str)) && *str) {
- /* PCI layer options should be handled here */
- printk(KERN_ERR "PCI: Unknown option `%s'\n", str);
+ if (!strcmp(str, "nomsi")) {
+ pci_no_msi();
+ } else {
+ printk(KERN_ERR "PCI: Unknown option `%s'\n",
+ str);
+ }
}
str = k;
}
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index a6dfee2f6d2..8f3fb47ea67 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -50,8 +50,10 @@ extern int pci_msi_quirk;
#ifdef CONFIG_PCI_MSI
void disable_msi_mode(struct pci_dev *dev, int pos, int type);
+void pci_no_msi(void);
#else
static inline void disable_msi_mode(struct pci_dev *dev, int pos, int type) { }
+static inline void pci_no_msi(void) { }
#endif
extern int pcie_mch_quirk;
diff --git a/drivers/pci/pcie/portdrv.h b/drivers/pci/pcie/portdrv.h
index a63bd8f7260..1d317d22ee8 100644
--- a/drivers/pci/pcie/portdrv.h
+++ b/drivers/pci/pcie/portdrv.h
@@ -29,7 +29,6 @@
struct pcie_port_device_ext {
int interrupt_mode; /* [0:INTx | 1:MSI | 2:MSI-X] */
- unsigned int saved_msi_config_space[5];
};
extern struct bus_type pcie_port_bus_type;
diff --git a/drivers/pci/pcie/portdrv_core.c b/drivers/pci/pcie/portdrv_core.c
index e4e5f1e8d81..55c66226786 100644
--- a/drivers/pci/pcie/portdrv_core.c
+++ b/drivers/pci/pcie/portdrv_core.c
@@ -248,11 +248,10 @@ static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
{
struct pcie_device *device;
- device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL);
+ device = kzalloc(sizeof(struct pcie_device), GFP_KERNEL);
if (!device)
return NULL;
- memset(device, 0, sizeof(struct pcie_device));
pcie_device_init(parent, device, port_type, service_type, irq,irq_mode);
printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id);
return device;
diff --git a/drivers/pci/pcie/portdrv_pci.c b/drivers/pci/pcie/portdrv_pci.c
index 02260141dc8..50bfc1b2f3b 100644
--- a/drivers/pci/pcie/portdrv_pci.c
+++ b/drivers/pci/pcie/portdrv_pci.c
@@ -30,75 +30,16 @@ MODULE_LICENSE("GPL");
/* global data */
static const char device_name[] = "pcieport-driver";
-static void pci_save_msi_state(struct pci_dev *dev)
+static int pcie_portdrv_save_config(struct pci_dev *dev)
{
- struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
- int i = 0, pos;
- u16 control;
-
- if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
- return;
-
- pci_read_config_dword(dev, pos, &p_ext->saved_msi_config_space[i++]);
- control = p_ext->saved_msi_config_space[0] >> 16;
- pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
- &p_ext->saved_msi_config_space[i++]);
- if (control & PCI_MSI_FLAGS_64BIT) {
- pci_read_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
- &p_ext->saved_msi_config_space[i++]);
- pci_read_config_dword(dev, pos + PCI_MSI_DATA_64,
- &p_ext->saved_msi_config_space[i++]);
- } else
- pci_read_config_dword(dev, pos + PCI_MSI_DATA_32,
- &p_ext->saved_msi_config_space[i++]);
- if (control & PCI_MSI_FLAGS_MASKBIT)
- pci_read_config_dword(dev, pos + PCI_MSI_MASK_BIT,
- &p_ext->saved_msi_config_space[i++]);
-}
-
-static void pci_restore_msi_state(struct pci_dev *dev)
-{
- struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
- int i = 0, pos;
- u16 control;
-
- if ((pos = pci_find_capability(dev, PCI_CAP_ID_MSI)) <= 0)
- return;
-
- control = p_ext->saved_msi_config_space[i++] >> 16;
- pci_write_config_word(dev, pos + PCI_MSI_FLAGS, control);
- pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_LO,
- p_ext->saved_msi_config_space[i++]);
- if (control & PCI_MSI_FLAGS_64BIT) {
- pci_write_config_dword(dev, pos + PCI_MSI_ADDRESS_HI,
- p_ext->saved_msi_config_space[i++]);
- pci_write_config_dword(dev, pos + PCI_MSI_DATA_64,
- p_ext->saved_msi_config_space[i++]);
- } else
- pci_write_config_dword(dev, pos + PCI_MSI_DATA_32,
- p_ext->saved_msi_config_space[i++]);
- if (control & PCI_MSI_FLAGS_MASKBIT)
- pci_write_config_dword(dev, pos + PCI_MSI_MASK_BIT,
- p_ext->saved_msi_config_space[i++]);
-}
-
-static void pcie_portdrv_save_config(struct pci_dev *dev)
-{
- struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
-
- pci_save_state(dev);
- if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
- pci_save_msi_state(dev);
+ return pci_save_state(dev);
}
static int pcie_portdrv_restore_config(struct pci_dev *dev)
{
- struct pcie_port_device_ext *p_ext = pci_get_drvdata(dev);
int retval;
pci_restore_state(dev);
- if (p_ext->interrupt_mode == PCIE_PORT_MSI_MODE)
- pci_restore_msi_state(dev);
retval = pci_enable_device(dev);
if (retval)
return retval;
@@ -149,7 +90,8 @@ static int pcie_portdrv_suspend (struct pci_dev *dev, pm_message_t state)
{
int ret = pcie_port_device_suspend(dev, state);
- pcie_portdrv_save_config(dev);
+ if (!ret)
+ ret = pcie_portdrv_save_config(dev);
return ret;
}
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index adfad4fd6a1..a10ed9dab2c 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -33,10 +33,9 @@ LIST_HEAD(pci_devices);
*/
static void pci_create_legacy_files(struct pci_bus *b)
{
- b->legacy_io = kmalloc(sizeof(struct bin_attribute) * 2,
+ b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2,
GFP_ATOMIC);
if (b->legacy_io) {
- memset(b->legacy_io, 0, sizeof(struct bin_attribute) * 2);
b->legacy_io->attr.name = "legacy_io";
b->legacy_io->size = 0xffff;
b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;
@@ -320,9 +319,8 @@ static struct pci_bus * __devinit pci_alloc_bus(void)
{
struct pci_bus *b;
- b = kmalloc(sizeof(*b), GFP_KERNEL);
+ b = kzalloc(sizeof(*b), GFP_KERNEL);
if (b) {
- memset(b, 0, sizeof(*b));
INIT_LIST_HEAD(&b->node);
INIT_LIST_HEAD(&b->children);
INIT_LIST_HEAD(&b->devices);
@@ -347,6 +345,7 @@ pci_alloc_child_bus(struct pci_bus *parent, struct pci_dev *bridge, int busnr)
child->parent = parent;
child->ops = parent->ops;
child->sysdata = parent->sysdata;
+ child->bus_flags = parent->bus_flags;
child->bridge = get_device(&bridge->dev);
child->class_dev.class = &pcibus_class;
@@ -456,7 +455,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
* pass and just note the configuration.
*/
if (pass)
- return max;
+ goto out;
busnr = (buses >> 8) & 0xFF;
/*
@@ -466,12 +465,12 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
if (pci_find_bus(pci_domain_nr(bus), busnr)) {
printk(KERN_INFO "PCI: Bus %04x:%02x already known\n",
pci_domain_nr(bus), busnr);
- return max;
+ goto out;
}
child = pci_add_new_bus(bus, dev, busnr);
if (!child)
- return max;
+ goto out;
child->primary = buses & 0xFF;
child->subordinate = (buses >> 16) & 0xFF;
child->bridge_ctl = bctl;
@@ -496,7 +495,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
bus ranges. */
pci_write_config_dword(dev, PCI_PRIMARY_BUS,
buses & ~0xffffff);
- return max;
+ goto out;
}
/* Clear errors */
@@ -505,7 +504,7 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
/* Prevent assigning a bus number that already exists.
* This can happen when a bridge is hot-plugged */
if (pci_find_bus(pci_domain_nr(bus), max+1))
- return max;
+ goto out;
child = pci_add_new_bus(bus, dev, ++max);
buses = (buses & 0xff000000)
| ((unsigned int)(child->primary) << 0)
@@ -537,6 +536,11 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
pci_fixup_parent_subordinate_busnr(child, max);
/* Now we can scan all subordinate buses... */
max = pci_scan_child_bus(child);
+ /*
+ * now fix it up again since we have found
+ * the real value of max.
+ */
+ pci_fixup_parent_subordinate_busnr(child, max);
} else {
/*
* For CardBus bridges, we leave 4 bus numbers
@@ -576,8 +580,6 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
pci_write_config_byte(dev, PCI_SUBORDINATE_BUS, max);
}
- pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl);
-
sprintf(child->name, (is_cardbus ? "PCI CardBus #%02x" : "PCI Bus #%02x"), child->number);
while (bus->parent) {
@@ -585,17 +587,22 @@ int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max
(child->number > bus->subordinate) ||
(child->number < bus->number) ||
(child->subordinate < bus->number)) {
- printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) may be "
+ printk(KERN_WARNING "PCI: Bus #%02x (-#%02x) is "
"hidden behind%s bridge #%02x (-#%02x)%s\n",
child->number, child->subordinate,
bus->self->transparent ? " transparent" : " ",
bus->number, bus->subordinate,
pcibios_assign_all_busses() ? " " :
" (try 'pci=assign-busses')");
+ printk(KERN_WARNING "Please report the result to "
+ "linux-kernel to fix this permanently\n");
}
bus = bus->parent;
}
+out:
+ pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl);
+
return max;
}
@@ -788,11 +795,10 @@ pci_scan_device(struct pci_bus *bus, int devfn)
if (pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type))
return NULL;
- dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
if (!dev)
return NULL;
- memset(dev, 0, sizeof(struct pci_dev));
dev->bus = bus;
dev->sysdata = bus->sysdata;
dev->dev.parent = bus->bridge;
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 92a88576083..54b2ebc9c91 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -458,131 +458,6 @@ int pci_proc_detach_bus(struct pci_bus* bus)
return 0;
}
-#ifdef CONFIG_PCI_LEGACY_PROC
-
-/*
- * Backward compatible /proc/pci interface.
- */
-
-/*
- * Convert some of the configuration space registers of the device at
- * address (bus,devfn) into a string (possibly several lines each).
- * The configuration string is stored starting at buf[len]. If the
- * string would exceed the size of the buffer (SIZE), 0 is returned.
- */
-static int show_dev_config(struct seq_file *m, void *v)
-{
- struct pci_dev *dev = v;
- struct pci_dev *first_dev;
- struct pci_driver *drv;
- u32 class_rev;
- unsigned char latency, min_gnt, max_lat;
- int reg;
-
- first_dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL);
- if (dev == first_dev)
- seq_puts(m, "PCI devices found:\n");
- pci_dev_put(first_dev);
-
- drv = pci_dev_driver(dev);
-
- pci_user_read_config_dword(dev, PCI_CLASS_REVISION, &class_rev);
- pci_user_read_config_byte (dev, PCI_LATENCY_TIMER, &latency);
- pci_user_read_config_byte (dev, PCI_MIN_GNT, &min_gnt);
- pci_user_read_config_byte (dev, PCI_MAX_LAT, &max_lat);
- seq_printf(m, " Bus %2d, device %3d, function %2d:\n",
- dev->bus->number, PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn));
- seq_printf(m, " Class %04x", class_rev >> 16);
- seq_printf(m, ": PCI device %04x:%04x", dev->vendor, dev->device);
- seq_printf(m, " (rev %d).\n", class_rev & 0xff);
-
- if (dev->irq)
- seq_printf(m, " IRQ %d.\n", dev->irq);
-
- if (latency || min_gnt || max_lat) {
- seq_printf(m, " Master Capable. ");
- if (latency)
- seq_printf(m, "Latency=%d. ", latency);
- else
- seq_puts(m, "No bursts. ");
- if (min_gnt)
- seq_printf(m, "Min Gnt=%d.", min_gnt);
- if (max_lat)
- seq_printf(m, "Max Lat=%d.", max_lat);
- seq_putc(m, '\n');
- }
-
- for (reg = 0; reg < 6; reg++) {
- struct resource *res = dev->resource + reg;
- unsigned long base, end, flags;
-
- base = res->start;
- end = res->end;
- flags = res->flags;
- if (!end)
- continue;
-
- if (flags & PCI_BASE_ADDRESS_SPACE_IO) {
- seq_printf(m, " I/O at 0x%lx [0x%lx].\n",
- base, end);
- } else {
- const char *pref, *type = "unknown";
-
- if (flags & PCI_BASE_ADDRESS_MEM_PREFETCH)
- pref = "P";
- else
- pref = "Non-p";
- switch (flags & PCI_BASE_ADDRESS_MEM_TYPE_MASK) {
- case PCI_BASE_ADDRESS_MEM_TYPE_32:
- type = "32 bit"; break;
- case PCI_BASE_ADDRESS_MEM_TYPE_1M:
- type = "20 bit"; break;
- case PCI_BASE_ADDRESS_MEM_TYPE_64:
- type = "64 bit"; break;
- }
- seq_printf(m, " %srefetchable %s memory at "
- "0x%lx [0x%lx].\n", pref, type,
- base,
- end);
- }
- }
- return 0;
-}
-
-static struct seq_operations proc_pci_op = {
- .start = pci_seq_start,
- .next = pci_seq_next,
- .stop = pci_seq_stop,
- .show = show_dev_config
-};
-
-static int proc_pci_open(struct inode *inode, struct file *file)
-{
- return seq_open(file, &proc_pci_op);
-}
-static struct file_operations proc_pci_operations = {
- .open = proc_pci_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
-};
-
-static void legacy_proc_init(void)
-{
- struct proc_dir_entry * entry = create_proc_entry("pci", 0, NULL);
- if (entry)
- entry->proc_fops = &proc_pci_operations;
-}
-
-#else
-
-static void legacy_proc_init(void)
-{
-
-}
-
-#endif /* CONFIG_PCI_LEGACY_PROC */
-
static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
{
return seq_open(file, &proc_bus_pci_devices_op);
@@ -606,7 +481,6 @@ static int __init pci_proc_init(void)
while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) {
pci_proc_attach_device(dev);
}
- legacy_proc_init();
return 0;
}
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
index dda6099903c..4970f47be72 100644
--- a/drivers/pci/quirks.c
+++ b/drivers/pci/quirks.c
@@ -575,8 +575,11 @@ static void __init quirk_amd_8131_ioapic(struct pci_dev *dev)
{
unsigned char revid, tmp;
- pci_msi_quirk = 1;
- printk(KERN_WARNING "PCI: MSI quirk detected. pci_msi_quirk set.\n");
+ if (dev->subordinate) {
+ printk(KERN_WARNING "PCI: MSI quirk detected. "
+ "PCI_BUS_FLAGS_NO_MSI set for subordinate bus.\n");
+ dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
+ }
if (nr_ioapics == 0)
return;
@@ -934,6 +937,12 @@ static void __init asus_hides_smbus_hostbridge(struct pci_dev *dev)
case 0x12bd: /* HP D530 */
asus_hides_smbus = 1;
}
+ if (dev->device == PCI_DEVICE_ID_INTEL_82915GM_HB) {
+ switch (dev->subsystem_device) {
+ case 0x099c: /* HP Compaq nx6110 */
+ asus_hides_smbus = 1;
+ }
+ }
} else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_TOSHIBA)) {
if (dev->device == PCI_DEVICE_ID_INTEL_82855GM_HB)
switch(dev->subsystem_device) {
@@ -1068,6 +1077,37 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_651, quirk_sis_96x_
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_735, quirk_sis_96x_compatible );
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_503, quirk_sis_503 );
+/*
+ * On ASUS A8V and A8V Deluxe boards, the onboard AC97 audio controller
+ * and MC97 modem controller are disabled when a second PCI soundcard is
+ * present. This patch, tweaking the VT8237 ISA bridge, enables them.
+ * -- bjd
+ */
+static void __init asus_hides_ac97_lpc(struct pci_dev *dev)
+{
+ u8 val;
+ int asus_hides_ac97 = 0;
+
+ if (likely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {
+ if (dev->device == PCI_DEVICE_ID_VIA_8237)
+ asus_hides_ac97 = 1;
+ }
+
+ if (!asus_hides_ac97)
+ return;
+
+ pci_read_config_byte(dev, 0x50, &val);
+ if (val & 0xc0) {
+ pci_write_config_byte(dev, 0x50, val & (~0xc0));
+ pci_read_config_byte(dev, 0x50, &val);
+ if (val & 0xc0)
+ printk(KERN_INFO "PCI: onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", val);
+ else
+ printk(KERN_INFO "PCI: enabled onboard AC97/MC97 devices\n");
+ }
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, asus_hides_ac97_lpc );
+
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_961, quirk_sis_96x_smbus );
DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_962, quirk_sis_96x_smbus );
@@ -1242,6 +1282,33 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXH_1, quirk_pc
DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PXHV, quirk_pcie_pxh);
+/*
+ * Fixup the cardbus bridges on the IBM Dock II docking station
+ */
+static void __devinit quirk_ibm_dock2_cardbus(struct pci_dev *dev)
+{
+ u32 val;
+
+ /*
+ * tie the 2 interrupt pins to INTA, and configure the
+ * multifunction routing register to handle this.
+ */
+ if ((dev->subsystem_vendor == PCI_VENDOR_ID_IBM) &&
+ (dev->subsystem_device == 0x0148)) {
+ printk(KERN_INFO "PCI: Found IBM Dock II Cardbus Bridge "
+ "applying quirk\n");
+ pci_read_config_dword(dev, 0x8c, &val);
+ val = ((val & 0xffffff00) | 0x1002);
+ pci_write_config_dword(dev, 0x8c, val);
+ pci_read_config_dword(dev, 0x80, &val);
+ val = ((val & 0x00ffff00) | 0x2864c077);
+ pci_write_config_dword(dev, 0x80, val);
+ }
+}
+
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, PCI_DEVICE_ID_TI_1420,
+ quirk_ibm_dock2_cardbus);
+
static void __devinit quirk_netmos(struct pci_dev *dev)
{
unsigned int num_parallel = (dev->subsystem_device & 0xf0) >> 4;
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 05fa91a31c6..ce7dd6e7be6 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -246,9 +246,9 @@ pci_get_subsys(unsigned int vendor, unsigned int device,
}
dev = NULL;
exit:
- pci_dev_put(from);
dev = pci_dev_get(dev);
spin_unlock(&pci_bus_lock);
+ pci_dev_put(from);
return dev;
}
@@ -339,9 +339,9 @@ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
}
dev = NULL;
exit:
- pci_dev_put(from);
dev = pci_dev_get(dev);
spin_unlock(&pci_bus_lock);
+ pci_dev_put(from);
return dev;
}
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 57fd60314d5..b1b4b683cbd 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -646,8 +646,10 @@ static int __init isapnp_create_device(struct pnp_card *card,
size = 0;
skip = 0;
option = pnp_register_independent_option(dev);
- if (!option)
+ if (!option) {
+ kfree(dev);
return 1;
+ }
pnp_add_card_device(card,dev);
} else {
skip = 1;
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 5e38cd7335f..c89c98a2cca 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -448,11 +448,7 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
break;
case SMALL_TAG_END:
- if (option_independent != option)
- printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_ENDDEP tag\n");
- p = p + 2;
- return (unsigned char *)p;
- break;
+ return p + 2;
default: /* an unkown tag */
len_err:
diff --git a/drivers/s390/Kconfig b/drivers/s390/Kconfig
index 721787cc5a1..4d36208ff8d 100644
--- a/drivers/s390/Kconfig
+++ b/drivers/s390/Kconfig
@@ -183,7 +183,13 @@ config S390_TAPE_34XX
tape subsystems and 100% compatibles.
It is safe to say "Y" here.
-
+config S390_TAPE_3590
+ tristate "Support for 3590 tape hardware"
+ depends on S390_TAPE
+ help
+ Select this option if you want to access IBM 3590 magnetic
+ tape subsystems and 100% compatibles.
+ It is safe to say "Y" here.
config VMLOGRDR
tristate "Support for the z/VM recording system services (VM only)"
diff --git a/drivers/s390/block/Kconfig b/drivers/s390/block/Kconfig
index 6f50cc9323d..929d6fff615 100644
--- a/drivers/s390/block/Kconfig
+++ b/drivers/s390/block/Kconfig
@@ -49,20 +49,18 @@ config DASD_FBA
config DASD_DIAG
tristate "Support for DIAG access to Disks"
- depends on DASD && ( 64BIT = 'n' || EXPERIMENTAL)
+ depends on DASD
help
Select this option if you want to use Diagnose250 command to access
Disks under VM. If you are not running under VM or unsure what it is,
say "N".
-config DASD_CMB
- tristate "Compatibility interface for DASD channel measurement blocks"
+config DASD_EER
+ bool "Extended error reporting (EER)"
depends on DASD
help
- This driver provides an additional interface to the channel measurement
- facility, which is normally accessed though sysfs, with a set of
- ioctl functions specific to the dasd driver.
- This is only needed if you want to use applications written for
- linux-2.4 dasd channel measurement facility interface.
+ This driver provides a character device interface to the
+ DASD extended error reporting. This is only needed if you want to
+ use applications written for the EER facility.
endif
diff --git a/drivers/s390/block/Makefile b/drivers/s390/block/Makefile
index 58c6780134f..be9f22d52fd 100644
--- a/drivers/s390/block/Makefile
+++ b/drivers/s390/block/Makefile
@@ -7,11 +7,13 @@ dasd_fba_mod-objs := dasd_fba.o dasd_3370_erp.o dasd_9336_erp.o
dasd_diag_mod-objs := dasd_diag.o
dasd_mod-objs := dasd.o dasd_ioctl.o dasd_proc.o dasd_devmap.o \
dasd_genhd.o dasd_erp.o
+ifdef CONFIG_DASD_EER
+dasd_mod-objs += dasd_eer.o
+endif
obj-$(CONFIG_DASD) += dasd_mod.o
obj-$(CONFIG_DASD_DIAG) += dasd_diag_mod.o
obj-$(CONFIG_DASD_ECKD) += dasd_eckd_mod.o
obj-$(CONFIG_DASD_FBA) += dasd_fba_mod.o
-obj-$(CONFIG_DASD_CMB) += dasd_cmb.o
obj-$(CONFIG_BLK_DEV_XPRAM) += xpram.o
obj-$(CONFIG_DCSSBLK) += dcssblk.o
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 33157c84d1d..0a9f12c4e91 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -43,7 +43,6 @@ MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
" Copyright 2000 IBM Corporation");
MODULE_SUPPORTED_DEVICE("dasd");
-MODULE_PARM(dasd, "1-" __MODULE_STRING(256) "s");
MODULE_LICENSE("GPL");
/*
@@ -71,10 +70,9 @@ dasd_alloc_device(void)
{
struct dasd_device *device;
- device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC);
+ device = kzalloc(sizeof (struct dasd_device), GFP_ATOMIC);
if (device == NULL)
return ERR_PTR(-ENOMEM);
- memset(device, 0, sizeof (struct dasd_device));
/* open_count = 0 means device online but not in use */
atomic_set(&device->open_count, -1);
@@ -151,6 +149,8 @@ dasd_state_new_to_known(struct dasd_device *device)
static inline void
dasd_state_known_to_new(struct dasd_device * device)
{
+ /* Disable extended error reporting for this device. */
+ dasd_eer_disable(device);
/* Forget the discipline information. */
if (device->discipline)
module_put(device->discipline->owner);
@@ -541,33 +541,29 @@ dasd_kmalloc_request(char *magic, int cplength, int datasize,
struct dasd_ccw_req *cqr;
/* Sanity checks */
- if ( magic == NULL || datasize > PAGE_SIZE ||
- (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
- BUG();
+ BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
+ (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
- cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
+ cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
if (cqr == NULL)
return ERR_PTR(-ENOMEM);
- memset(cqr, 0, sizeof(struct dasd_ccw_req));
cqr->cpaddr = NULL;
if (cplength > 0) {
- cqr->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
+ cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
GFP_ATOMIC | GFP_DMA);
if (cqr->cpaddr == NULL) {
kfree(cqr);
return ERR_PTR(-ENOMEM);
}
- memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
}
cqr->data = NULL;
if (datasize > 0) {
- cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
+ cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
if (cqr->data == NULL) {
kfree(cqr->cpaddr);
kfree(cqr);
return ERR_PTR(-ENOMEM);
}
- memset(cqr->data, 0, datasize);
}
strncpy((char *) &cqr->magic, magic, 4);
ASCEBC((char *) &cqr->magic, 4);
@@ -586,9 +582,8 @@ dasd_smalloc_request(char *magic, int cplength, int datasize,
int size;
/* Sanity checks */
- if ( magic == NULL || datasize > PAGE_SIZE ||
- (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
- BUG();
+ BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
+ (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
if (cplength > 0)
@@ -892,6 +887,9 @@ dasd_handle_state_change_pending(struct dasd_device *device)
struct dasd_ccw_req *cqr;
struct list_head *l, *n;
+ /* First of all start sense subsystem status request. */
+ dasd_eer_snss(device);
+
device->stopped &= ~DASD_STOPPED_PENDING;
/* restart all 'running' IO on queue */
@@ -1111,6 +1109,19 @@ restart:
}
goto restart;
}
+
+ /* First of all call extended error reporting. */
+ if (dasd_eer_enabled(device) &&
+ cqr->status == DASD_CQR_FAILED) {
+ dasd_eer_write(device, cqr, DASD_EER_FATALERROR);
+
+ /* restart request */
+ cqr->status = DASD_CQR_QUEUED;
+ cqr->retries = 255;
+ device->stopped |= DASD_STOPPED_QUIESCE;
+ goto restart;
+ }
+
/* Process finished ERP request. */
if (cqr->refers) {
__dasd_process_erp(device, cqr);
@@ -1248,7 +1259,8 @@ __dasd_start_head(struct dasd_device * device)
cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
/* check FAILFAST */
if (device->stopped & ~DASD_STOPPED_PENDING &&
- test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags)) {
+ test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
+ (!dasd_eer_enabled(device))) {
cqr->status = DASD_CQR_FAILED;
dasd_schedule_bh(device);
}
@@ -1807,7 +1819,7 @@ dasd_exit(void)
#ifdef CONFIG_PROC_FS
dasd_proc_exit();
#endif
- dasd_ioctl_exit();
+ dasd_eer_exit();
if (dasd_page_cache != NULL) {
kmem_cache_destroy(dasd_page_cache);
dasd_page_cache = NULL;
@@ -2004,6 +2016,9 @@ dasd_generic_notify(struct ccw_device *cdev, int event)
switch (event) {
case CIO_GONE:
case CIO_NO_PATH:
+ /* First of all call extended error reporting. */
+ dasd_eer_write(device, NULL, DASD_EER_NOPATH);
+
if (device->state < DASD_STATE_BASIC)
break;
/* Device is active. We want to keep it. */
@@ -2061,6 +2076,7 @@ dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
put_driver(drv);
}
+
static int __init
dasd_init(void)
{
@@ -2093,7 +2109,7 @@ dasd_init(void)
rc = dasd_parse();
if (rc)
goto failed;
- rc = dasd_ioctl_init();
+ rc = dasd_eer_init();
if (rc)
goto failed;
#ifdef CONFIG_PROC_FS
diff --git a/drivers/s390/block/dasd_3990_erp.c b/drivers/s390/block/dasd_3990_erp.c
index 4ee0f934e32..2ed51562319 100644
--- a/drivers/s390/block/dasd_3990_erp.c
+++ b/drivers/s390/block/dasd_3990_erp.c
@@ -1108,6 +1108,9 @@ dasd_3990_handle_env_data(struct dasd_ccw_req * erp, char *sense)
case 0x0B:
DEV_MESSAGE(KERN_WARNING, device, "%s",
"FORMAT F - Volume is suspended duplex");
+ /* call extended error reporting (EER) */
+ dasd_eer_write(device, erp->refers,
+ DASD_EER_PPRCSUSPEND);
break;
case 0x0C:
DEV_MESSAGE(KERN_WARNING, device, "%s",
diff --git a/drivers/s390/block/dasd_cmb.c b/drivers/s390/block/dasd_cmb.c
deleted file mode 100644
index e88f73ee72c..00000000000
--- a/drivers/s390/block/dasd_cmb.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Linux on zSeries Channel Measurement Facility support
- * (dasd device driver interface)
- *
- * Copyright 2000,2003 IBM Corporation
- *
- * Author: Arnd Bergmann <arndb@de.ibm.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-#include <linux/init.h>
-#include <linux/module.h>
-#include <asm/ccwdev.h>
-#include <asm/cmb.h>
-
-#include "dasd_int.h"
-
-static int
-dasd_ioctl_cmf_enable(struct block_device *bdev, int no, long args)
-{
- struct dasd_device *device;
-
- device = bdev->bd_disk->private_data;
- if (!device)
- return -EINVAL;
-
- return enable_cmf(device->cdev);
-}
-
-static int
-dasd_ioctl_cmf_disable(struct block_device *bdev, int no, long args)
-{
- struct dasd_device *device;
-
- device = bdev->bd_disk->private_data;
- if (!device)
- return -EINVAL;
-
- return disable_cmf(device->cdev);
-}
-
-static int
-dasd_ioctl_readall_cmb(struct block_device *bdev, int no, long args)
-{
- struct dasd_device *device;
- struct cmbdata __user *udata;
- struct cmbdata data;
- size_t size;
- int ret;
-
- device = bdev->bd_disk->private_data;
- if (!device)
- return -EINVAL;
- udata = (void __user *) args;
- size = _IOC_SIZE(no);
-
- if (!access_ok(VERIFY_WRITE, udata, size))
- return -EFAULT;
- ret = cmf_readall(device->cdev, &data);
- if (ret)
- return ret;
- if (copy_to_user(udata, &data, min(size, sizeof(*udata))))
- return -EFAULT;
- return 0;
-}
-
-/* module initialization below here. dasd already provides a mechanism
- * to dynamically register ioctl functions, so we simply use this. */
-static inline int
-ioctl_reg(unsigned int no, dasd_ioctl_fn_t handler)
-{
- return dasd_ioctl_no_register(THIS_MODULE, no, handler);
-}
-
-static inline void
-ioctl_unreg(unsigned int no, dasd_ioctl_fn_t handler)
-{
- dasd_ioctl_no_unregister(THIS_MODULE, no, handler);
-}
-
-static void
-dasd_cmf_exit(void)
-{
- ioctl_unreg(BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
- ioctl_unreg(BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
- ioctl_unreg(BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
-}
-
-static int __init
-dasd_cmf_init(void)
-{
- int ret;
- ret = ioctl_reg (BIODASDCMFENABLE, dasd_ioctl_cmf_enable);
- if (ret)
- goto err;
- ret = ioctl_reg (BIODASDCMFDISABLE, dasd_ioctl_cmf_disable);
- if (ret)
- goto err;
- ret = ioctl_reg (BIODASDREADALLCMB, dasd_ioctl_readall_cmb);
- if (ret)
- goto err;
-
- return 0;
-err:
- dasd_cmf_exit();
-
- return ret;
-}
-
-module_init(dasd_cmf_init);
-module_exit(dasd_cmf_exit);
-
-MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION("channel measurement facility interface for dasd\n"
- "Copyright 2003 IBM Corporation\n");
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index 1629b27c48a..2f720108a7e 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -16,6 +16,7 @@
#include <linux/config.h>
#include <linux/ctype.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <asm/debug.h>
#include <asm/uaccess.h>
@@ -69,6 +70,8 @@ int dasd_autodetect = 0; /* is true, when autodetection is active */
* strings when running as a module.
*/
static char *dasd[256];
+module_param_array(dasd, charp, NULL, 0);
+
/*
* Single spinlock to protect devmap structures and lists.
*/
@@ -715,10 +718,51 @@ dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *bu
static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL);
+/*
+ * extended error-reporting
+ */
+static ssize_t
+dasd_eer_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct dasd_devmap *devmap;
+ int eer_flag;
+
+ devmap = dasd_find_busid(dev->bus_id);
+ if (!IS_ERR(devmap) && devmap->device)
+ eer_flag = dasd_eer_enabled(devmap->device);
+ else
+ eer_flag = 0;
+ return snprintf(buf, PAGE_SIZE, eer_flag ? "1\n" : "0\n");
+}
+
+static ssize_t
+dasd_eer_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct dasd_devmap *devmap;
+ int rc;
+
+ devmap = dasd_devmap_from_cdev(to_ccwdev(dev));
+ if (IS_ERR(devmap))
+ return PTR_ERR(devmap);
+ if (!devmap->device)
+ return count;
+ if (buf[0] == '1') {
+ rc = dasd_eer_enable(devmap->device);
+ if (rc)
+ return rc;
+ } else
+ dasd_eer_disable(devmap->device);
+ return count;
+}
+
+static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store);
+
static struct attribute * dasd_attrs[] = {
&dev_attr_readonly.attr,
&dev_attr_discipline.attr,
&dev_attr_use_diag.attr,
+ &dev_attr_eer_enabled.attr,
NULL,
};
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 822e2a26557..ee09ef33d08 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -1227,19 +1227,14 @@ dasd_eckd_fill_info(struct dasd_device * device,
* (see dasd_eckd_reserve) device.
*/
static int
-dasd_eckd_release(struct block_device *bdev, int no, long args)
+dasd_eckd_release(struct dasd_device *device)
{
- struct dasd_device *device;
struct dasd_ccw_req *cqr;
int rc;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1, 32, device);
if (IS_ERR(cqr)) {
@@ -1272,19 +1267,14 @@ dasd_eckd_release(struct block_device *bdev, int no, long args)
* the interrupt is outstanding for a certain time.
*/
static int
-dasd_eckd_reserve(struct block_device *bdev, int no, long args)
+dasd_eckd_reserve(struct dasd_device *device)
{
- struct dasd_device *device;
struct dasd_ccw_req *cqr;
int rc;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1, 32, device);
if (IS_ERR(cqr)) {
@@ -1316,19 +1306,14 @@ dasd_eckd_reserve(struct block_device *bdev, int no, long args)
* (unconditional reserve)
*/
static int
-dasd_eckd_steal_lock(struct block_device *bdev, int no, long args)
+dasd_eckd_steal_lock(struct dasd_device *device)
{
- struct dasd_device *device;
struct dasd_ccw_req *cqr;
int rc;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1, 32, device);
if (IS_ERR(cqr)) {
@@ -1358,19 +1343,14 @@ dasd_eckd_steal_lock(struct block_device *bdev, int no, long args)
* Read performance statistics
*/
static int
-dasd_eckd_performance(struct block_device *bdev, int no, long args)
+dasd_eckd_performance(struct dasd_device *device, void __user *argp)
{
- struct dasd_device *device;
struct dasd_psf_prssd_data *prssdp;
struct dasd_rssd_perf_stats_t *stats;
struct dasd_ccw_req *cqr;
struct ccw1 *ccw;
int rc;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1 /* PSF */ + 1 /* RSSD */ ,
(sizeof (struct dasd_psf_prssd_data) +
@@ -1414,8 +1394,9 @@ dasd_eckd_performance(struct block_device *bdev, int no, long args)
/* Prepare for Read Subsystem Data */
prssdp = (struct dasd_psf_prssd_data *) cqr->data;
stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
- rc = copy_to_user((long __user *) args, (long *) stats,
- sizeof(struct dasd_rssd_perf_stats_t));
+ if (copy_to_user(argp, stats,
+ sizeof(struct dasd_rssd_perf_stats_t)))
+ rc = -EFAULT;
}
dasd_sfree_request(cqr, cqr->device);
return rc;
@@ -1426,27 +1407,22 @@ dasd_eckd_performance(struct block_device *bdev, int no, long args)
* Returnes the cache attributes used in Define Extend (DE).
*/
static int
-dasd_eckd_get_attrib (struct block_device *bdev, int no, long args)
+dasd_eckd_get_attrib(struct dasd_device *device, void __user *argp)
{
- struct dasd_device *device;
- struct dasd_eckd_private *private;
- struct attrib_data_t attrib;
+ struct dasd_eckd_private *private =
+ (struct dasd_eckd_private *)device->private;
+ struct attrib_data_t attrib = private->attrib;
int rc;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!args)
+ if (!argp)
return -EINVAL;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
- private = (struct dasd_eckd_private *) device->private;
- attrib = private->attrib;
-
- rc = copy_to_user((long __user *) args, (long *) &attrib,
- sizeof (struct attrib_data_t));
+ rc = 0;
+ if (copy_to_user(argp, (long *) &attrib,
+ sizeof (struct attrib_data_t)))
+ rc = -EFAULT;
return rc;
}
@@ -1456,26 +1432,19 @@ dasd_eckd_get_attrib (struct block_device *bdev, int no, long args)
* Stores the attributes for cache operation to be used in Define Extend (DE).
*/
static int
-dasd_eckd_set_attrib(struct block_device *bdev, int no, long args)
+dasd_eckd_set_attrib(struct dasd_device *device, void __user *argp)
{
- struct dasd_device *device;
- struct dasd_eckd_private *private;
+ struct dasd_eckd_private *private =
+ (struct dasd_eckd_private *)device->private;
struct attrib_data_t attrib;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!args)
+ if (!argp)
return -EINVAL;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
- if (copy_from_user(&attrib, (void __user *) args,
- sizeof (struct attrib_data_t))) {
+ if (copy_from_user(&attrib, argp, sizeof(struct attrib_data_t)))
return -EFAULT;
- }
- private = (struct dasd_eckd_private *) device->private;
private->attrib = attrib;
DEV_MESSAGE(KERN_INFO, device,
@@ -1484,6 +1453,27 @@ dasd_eckd_set_attrib(struct block_device *bdev, int no, long args)
return 0;
}
+static int
+dasd_eckd_ioctl(struct dasd_device *device, unsigned int cmd, void __user *argp)
+{
+ switch (cmd) {
+ case BIODASDGATTR:
+ return dasd_eckd_get_attrib(device, argp);
+ case BIODASDSATTR:
+ return dasd_eckd_set_attrib(device, argp);
+ case BIODASDPSRD:
+ return dasd_eckd_performance(device, argp);
+ case BIODASDRLSE:
+ return dasd_eckd_release(device);
+ case BIODASDRSRV:
+ return dasd_eckd_reserve(device);
+ case BIODASDSLCK:
+ return dasd_eckd_steal_lock(device);
+ default:
+ return -ENOIOCTLCMD;
+ }
+}
+
/*
* Print sense data and related channel program.
* Parts are printed because printk buffer is only 1024 bytes.
@@ -1642,6 +1632,7 @@ static struct dasd_discipline dasd_eckd_discipline = {
.free_cp = dasd_eckd_free_cp,
.dump_sense = dasd_eckd_dump_sense,
.fill_info = dasd_eckd_fill_info,
+ .ioctl = dasd_eckd_ioctl,
};
static int __init
@@ -1649,59 +1640,18 @@ dasd_eckd_init(void)
{
int ret;
- dasd_ioctl_no_register(THIS_MODULE, BIODASDGATTR,
- dasd_eckd_get_attrib);
- dasd_ioctl_no_register(THIS_MODULE, BIODASDSATTR,
- dasd_eckd_set_attrib);
- dasd_ioctl_no_register(THIS_MODULE, BIODASDPSRD,
- dasd_eckd_performance);
- dasd_ioctl_no_register(THIS_MODULE, BIODASDRLSE,
- dasd_eckd_release);
- dasd_ioctl_no_register(THIS_MODULE, BIODASDRSRV,
- dasd_eckd_reserve);
- dasd_ioctl_no_register(THIS_MODULE, BIODASDSLCK,
- dasd_eckd_steal_lock);
-
ASCEBC(dasd_eckd_discipline.ebcname, 4);
ret = ccw_driver_register(&dasd_eckd_driver);
- if (ret) {
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR,
- dasd_eckd_get_attrib);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
- dasd_eckd_set_attrib);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
- dasd_eckd_performance);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRLSE,
- dasd_eckd_release);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRSRV,
- dasd_eckd_reserve);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSLCK,
- dasd_eckd_steal_lock);
- return ret;
- }
-
- dasd_generic_auto_online(&dasd_eckd_driver);
- return 0;
+ if (!ret)
+ dasd_generic_auto_online(&dasd_eckd_driver);
+ return ret;
}
static void __exit
dasd_eckd_cleanup(void)
{
ccw_driver_unregister(&dasd_eckd_driver);
-
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDGATTR,
- dasd_eckd_get_attrib);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSATTR,
- dasd_eckd_set_attrib);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDPSRD,
- dasd_eckd_performance);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRLSE,
- dasd_eckd_release);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDRSRV,
- dasd_eckd_reserve);
- dasd_ioctl_no_unregister(THIS_MODULE, BIODASDSLCK,
- dasd_eckd_steal_lock);
}
module_init(dasd_eckd_init);
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h
index bc3823d3522..ad8524bb7bb 100644
--- a/drivers/s390/block/dasd_eckd.h
+++ b/drivers/s390/block/dasd_eckd.h
@@ -29,6 +29,7 @@
#define DASD_ECKD_CCW_PSF 0x27
#define DASD_ECKD_CCW_RSSD 0x3e
#define DASD_ECKD_CCW_LOCATE_RECORD 0x47
+#define DASD_ECKD_CCW_SNSS 0x54
#define DASD_ECKD_CCW_DEFINE_EXTENT 0x63
#define DASD_ECKD_CCW_WRITE_MT 0x85
#define DASD_ECKD_CCW_READ_MT 0x86
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c
new file mode 100644
index 00000000000..2d946b6ca07
--- /dev/null
+++ b/drivers/s390/block/dasd_eer.c
@@ -0,0 +1,682 @@
+/*
+ * Character device driver for extended error reporting.
+ *
+ * Copyright (C) 2005 IBM Corporation
+ * extended error reporting for DASD ECKD devices
+ * Author(s): Stefan Weinhuber <wein@de.ibm.com>
+ */
+
+#include <linux/init.h>
+#include <linux/fs.h>
+#include <linux/kernel.h>
+#include <linux/miscdevice.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/device.h>
+#include <linux/poll.h>
+
+#include <asm/uaccess.h>
+#include <asm/semaphore.h>
+#include <asm/atomic.h>
+#include <asm/ebcdic.h>
+
+#include "dasd_int.h"
+#include "dasd_eckd.h"
+
+#ifdef PRINTK_HEADER
+#undef PRINTK_HEADER
+#endif /* PRINTK_HEADER */
+#define PRINTK_HEADER "dasd(eer):"
+
+/*
+ * SECTION: the internal buffer
+ */
+
+/*
+ * The internal buffer is meant to store obaque blobs of data, so it does
+ * not know of higher level concepts like triggers.
+ * It consists of a number of pages that are used as a ringbuffer. Each data
+ * blob is stored in a simple record that consists of an integer, which
+ * contains the size of the following data, and the data bytes themselfes.
+ *
+ * To allow for multiple independent readers we create one internal buffer
+ * each time the device is opened and destroy the buffer when the file is
+ * closed again. The number of pages used for this buffer is determined by
+ * the module parmeter eer_pages.
+ *
+ * One record can be written to a buffer by using the functions
+ * - dasd_eer_start_record (one time per record to write the size to the
+ * buffer and reserve the space for the data)
+ * - dasd_eer_write_buffer (one or more times per record to write the data)
+ * The data can be written in several steps but you will have to compute
+ * the total size up front for the invocation of dasd_eer_start_record.
+ * If the ringbuffer is full, dasd_eer_start_record will remove the required
+ * number of old records.
+ *
+ * A record is typically read in two steps, first read the integer that
+ * specifies the size of the following data, then read the data.
+ * Both can be done by
+ * - dasd_eer_read_buffer
+ *
+ * For all mentioned functions you need to get the bufferlock first and keep
+ * it until a complete record is written or read.
+ *
+ * All information necessary to keep track of an internal buffer is kept in
+ * a struct eerbuffer. The buffer specific to a file pointer is strored in
+ * the private_data field of that file. To be able to write data to all
+ * existing buffers, each buffer is also added to the bufferlist.
+ * If the user does not want to read a complete record in one go, we have to
+ * keep track of the rest of the record. residual stores the number of bytes
+ * that are still to deliver. If the rest of the record is invalidated between
+ * two reads then residual will be set to -1 so that the next read will fail.
+ * All entries in the eerbuffer structure are protected with the bufferlock.
+ * To avoid races between writing to a buffer on the one side and creating
+ * and destroying buffers on the other side, the bufferlock must also be used
+ * to protect the bufferlist.
+ */
+
+static int eer_pages = 5;
+module_param(eer_pages, int, S_IRUGO|S_IWUSR);
+
+struct eerbuffer {
+ struct list_head list;
+ char **buffer;
+ int buffersize;
+ int buffer_page_count;
+ int head;
+ int tail;
+ int residual;
+};
+
+static LIST_HEAD(bufferlist);
+static spinlock_t bufferlock = SPIN_LOCK_UNLOCKED;
+static DECLARE_WAIT_QUEUE_HEAD(dasd_eer_read_wait_queue);
+
+/*
+ * How many free bytes are available on the buffer.
+ * Needs to be called with bufferlock held.
+ */
+static int dasd_eer_get_free_bytes(struct eerbuffer *eerb)
+{
+ if (eerb->head < eerb->tail)
+ return eerb->tail - eerb->head - 1;
+ return eerb->buffersize - eerb->head + eerb->tail -1;
+}
+
+/*
+ * How many bytes of buffer space are used.
+ * Needs to be called with bufferlock held.
+ */
+static int dasd_eer_get_filled_bytes(struct eerbuffer *eerb)
+{
+
+ if (eerb->head >= eerb->tail)
+ return eerb->head - eerb->tail;
+ return eerb->buffersize - eerb->tail + eerb->head;
+}
+
+/*
+ * The dasd_eer_write_buffer function just copies count bytes of data
+ * to the buffer. Make sure to call dasd_eer_start_record first, to
+ * make sure that enough free space is available.
+ * Needs to be called with bufferlock held.
+ */
+static void dasd_eer_write_buffer(struct eerbuffer *eerb,
+ char *data, int count)
+{
+
+ unsigned long headindex,localhead;
+ unsigned long rest, len;
+ char *nextdata;
+
+ nextdata = data;
+ rest = count;
+ while (rest > 0) {
+ headindex = eerb->head / PAGE_SIZE;
+ localhead = eerb->head % PAGE_SIZE;
+ len = min(rest, PAGE_SIZE - localhead);
+ memcpy(eerb->buffer[headindex]+localhead, nextdata, len);
+ nextdata += len;
+ rest -= len;
+ eerb->head += len;
+ if (eerb->head == eerb->buffersize)
+ eerb->head = 0; /* wrap around */
+ BUG_ON(eerb->head > eerb->buffersize);
+ }
+}
+
+/*
+ * Needs to be called with bufferlock held.
+ */
+static int dasd_eer_read_buffer(struct eerbuffer *eerb, char *data, int count)
+{
+
+ unsigned long tailindex,localtail;
+ unsigned long rest, len, finalcount;
+ char *nextdata;
+
+ finalcount = min(count, dasd_eer_get_filled_bytes(eerb));
+ nextdata = data;
+ rest = finalcount;
+ while (rest > 0) {
+ tailindex = eerb->tail / PAGE_SIZE;
+ localtail = eerb->tail % PAGE_SIZE;
+ len = min(rest, PAGE_SIZE - localtail);
+ memcpy(nextdata, eerb->buffer[tailindex] + localtail, len);
+ nextdata += len;
+ rest -= len;
+ eerb->tail += len;
+ if (eerb->tail == eerb->buffersize)
+ eerb->tail = 0; /* wrap around */
+ BUG_ON(eerb->tail > eerb->buffersize);
+ }
+ return finalcount;
+}
+
+/*
+ * Whenever you want to write a blob of data to the internal buffer you
+ * have to start by using this function first. It will write the number
+ * of bytes that will be written to the buffer. If necessary it will remove
+ * old records to make room for the new one.
+ * Needs to be called with bufferlock held.
+ */
+static int dasd_eer_start_record(struct eerbuffer *eerb, int count)
+{
+ int tailcount;
+
+ if (count + sizeof(count) > eerb->buffersize)
+ return -ENOMEM;
+ while (dasd_eer_get_free_bytes(eerb) < count + sizeof(count)) {
+ if (eerb->residual > 0) {
+ eerb->tail += eerb->residual;
+ if (eerb->tail >= eerb->buffersize)
+ eerb->tail -= eerb->buffersize;
+ eerb->residual = -1;
+ }
+ dasd_eer_read_buffer(eerb, (char *) &tailcount,
+ sizeof(tailcount));
+ eerb->tail += tailcount;
+ if (eerb->tail >= eerb->buffersize)
+ eerb->tail -= eerb->buffersize;
+ }
+ dasd_eer_write_buffer(eerb, (char*) &count, sizeof(count));
+
+ return 0;
+};
+
+/*
+ * Release pages that are not used anymore.
+ */
+static void dasd_eer_free_buffer_pages(char **buf, int no_pages)
+{
+ int i;
+
+ for (i = 0; i < no_pages; i++)
+ free_page((unsigned long) buf[i]);
+}
+
+/*
+ * Allocate a new set of memory pages.
+ */
+static int dasd_eer_allocate_buffer_pages(char **buf, int no_pages)
+{
+ int i;
+
+ for (i = 0; i < no_pages; i++) {
+ buf[i] = (char *) get_zeroed_page(GFP_KERNEL);
+ if (!buf[i]) {
+ dasd_eer_free_buffer_pages(buf, i);
+ return -ENOMEM;
+ }
+ }
+ return 0;
+}
+
+/*
+ * SECTION: The extended error reporting functionality
+ */
+
+/*
+ * When a DASD device driver wants to report an error, it calls the
+ * function dasd_eer_write and gives the respective trigger ID as
+ * parameter. Currently there are four kinds of triggers:
+ *
+ * DASD_EER_FATALERROR: all kinds of unrecoverable I/O problems
+ * DASD_EER_PPRCSUSPEND: PPRC was suspended
+ * DASD_EER_NOPATH: There is no path to the device left.
+ * DASD_EER_STATECHANGE: The state of the device has changed.
+ *
+ * For the first three triggers all required information can be supplied by
+ * the caller. For these triggers a record is written by the function
+ * dasd_eer_write_standard_trigger.
+ *
+ * The DASD_EER_STATECHANGE trigger is special since a sense subsystem
+ * status ccw need to be executed to gather the necessary sense data first.
+ * The dasd_eer_snss function will queue the SNSS request and the request
+ * callback will then call dasd_eer_write with the DASD_EER_STATCHANGE
+ * trigger.
+ *
+ * To avoid memory allocations at runtime, the necessary memory is allocated
+ * when the extended error reporting is enabled for a device (by
+ * dasd_eer_probe). There is one sense subsystem status request for each
+ * eer enabled DASD device. The presence of the cqr in device->eer_cqr
+ * indicates that eer is enable for the device. The use of the snss request
+ * is protected by the DASD_FLAG_EER_IN_USE bit. When this flag indicates
+ * that the cqr is currently in use, dasd_eer_snss cannot start a second
+ * request but sets the DASD_FLAG_EER_SNSS flag instead. The callback of
+ * the SNSS request will check the bit and call dasd_eer_snss again.
+ */
+
+#define SNSS_DATA_SIZE 44
+
+#define DASD_EER_BUSID_SIZE 10
+struct dasd_eer_header {
+ __u32 total_size;
+ __u32 trigger;
+ __u64 tv_sec;
+ __u64 tv_usec;
+ char busid[DASD_EER_BUSID_SIZE];
+};
+
+/*
+ * The following function can be used for those triggers that have
+ * all necessary data available when the function is called.
+ * If the parameter cqr is not NULL, the chain of requests will be searched
+ * for valid sense data, and all valid sense data sets will be added to
+ * the triggers data.
+ */
+static void dasd_eer_write_standard_trigger(struct dasd_device *device,
+ struct dasd_ccw_req *cqr,
+ int trigger)
+{
+ struct dasd_ccw_req *temp_cqr;
+ int data_size;
+ struct timeval tv;
+ struct dasd_eer_header header;
+ unsigned long flags;
+ struct eerbuffer *eerb;
+
+ /* go through cqr chain and count the valid sense data sets */
+ data_size = 0;
+ for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers)
+ if (temp_cqr->irb.esw.esw0.erw.cons)
+ data_size += 32;
+
+ header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
+ header.trigger = trigger;
+ do_gettimeofday(&tv);
+ header.tv_sec = tv.tv_sec;
+ header.tv_usec = tv.tv_usec;
+ strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
+
+ spin_lock_irqsave(&bufferlock, flags);
+ list_for_each_entry(eerb, &bufferlist, list) {
+ dasd_eer_start_record(eerb, header.total_size);
+ dasd_eer_write_buffer(eerb, (char *) &header, sizeof(header));
+ for (temp_cqr = cqr; temp_cqr; temp_cqr = temp_cqr->refers)
+ if (temp_cqr->irb.esw.esw0.erw.cons)
+ dasd_eer_write_buffer(eerb, cqr->irb.ecw, 32);
+ dasd_eer_write_buffer(eerb, "EOR", 4);
+ }
+ spin_unlock_irqrestore(&bufferlock, flags);
+ wake_up_interruptible(&dasd_eer_read_wait_queue);
+}
+
+/*
+ * This function writes a DASD_EER_STATECHANGE trigger.
+ */
+static void dasd_eer_write_snss_trigger(struct dasd_device *device,
+ struct dasd_ccw_req *cqr,
+ int trigger)
+{
+ int data_size;
+ int snss_rc;
+ struct timeval tv;
+ struct dasd_eer_header header;
+ unsigned long flags;
+ struct eerbuffer *eerb;
+
+ snss_rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
+ if (snss_rc)
+ data_size = 0;
+ else
+ data_size = SNSS_DATA_SIZE;
+
+ header.total_size = sizeof(header) + data_size + 4; /* "EOR" */
+ header.trigger = DASD_EER_STATECHANGE;
+ do_gettimeofday(&tv);
+ header.tv_sec = tv.tv_sec;
+ header.tv_usec = tv.tv_usec;
+ strncpy(header.busid, device->cdev->dev.bus_id, DASD_EER_BUSID_SIZE);
+
+ spin_lock_irqsave(&bufferlock, flags);
+ list_for_each_entry(eerb, &bufferlist, list) {
+ dasd_eer_start_record(eerb, header.total_size);
+ dasd_eer_write_buffer(eerb, (char *) &header , sizeof(header));
+ if (!snss_rc)
+ dasd_eer_write_buffer(eerb, cqr->data, SNSS_DATA_SIZE);
+ dasd_eer_write_buffer(eerb, "EOR", 4);
+ }
+ spin_unlock_irqrestore(&bufferlock, flags);
+ wake_up_interruptible(&dasd_eer_read_wait_queue);
+}
+
+/*
+ * This function is called for all triggers. It calls the appropriate
+ * function that writes the actual trigger records.
+ */
+void dasd_eer_write(struct dasd_device *device, struct dasd_ccw_req *cqr,
+ unsigned int id)
+{
+ if (!device->eer_cqr)
+ return;
+ switch (id) {
+ case DASD_EER_FATALERROR:
+ case DASD_EER_PPRCSUSPEND:
+ dasd_eer_write_standard_trigger(device, cqr, id);
+ break;
+ case DASD_EER_NOPATH:
+ dasd_eer_write_standard_trigger(device, NULL, id);
+ break;
+ case DASD_EER_STATECHANGE:
+ dasd_eer_write_snss_trigger(device, cqr, id);
+ break;
+ default: /* unknown trigger, so we write it without any sense data */
+ dasd_eer_write_standard_trigger(device, NULL, id);
+ break;
+ }
+}
+EXPORT_SYMBOL(dasd_eer_write);
+
+/*
+ * Start a sense subsystem status request.
+ * Needs to be called with the device held.
+ */
+void dasd_eer_snss(struct dasd_device *device)
+{
+ struct dasd_ccw_req *cqr;
+
+ cqr = device->eer_cqr;
+ if (!cqr) /* Device not eer enabled. */
+ return;
+ if (test_and_set_bit(DASD_FLAG_EER_IN_USE, &device->flags)) {
+ /* Sense subsystem status request in use. */
+ set_bit(DASD_FLAG_EER_SNSS, &device->flags);
+ return;
+ }
+ clear_bit(DASD_FLAG_EER_SNSS, &device->flags);
+ cqr->status = DASD_CQR_QUEUED;
+ list_add(&cqr->list, &device->ccw_queue);
+ dasd_schedule_bh(device);
+}
+
+/*
+ * Callback function for use with sense subsystem status request.
+ */
+static void dasd_eer_snss_cb(struct dasd_ccw_req *cqr, void *data)
+{
+ struct dasd_device *device = cqr->device;
+ unsigned long flags;
+
+ dasd_eer_write(device, cqr, DASD_EER_STATECHANGE);
+ spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
+ if (device->eer_cqr == cqr) {
+ clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
+ if (test_bit(DASD_FLAG_EER_SNSS, &device->flags))
+ /* Another SNSS has been requested in the meantime. */
+ dasd_eer_snss(device);
+ cqr = NULL;
+ }
+ spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
+ if (cqr)
+ /*
+ * Extended error recovery has been switched off while
+ * the SNSS request was running. It could even have
+ * been switched off and on again in which case there
+ * is a new ccw in device->eer_cqr. Free the "old"
+ * snss request now.
+ */
+ dasd_kfree_request(cqr, device);
+}
+
+/*
+ * Enable error reporting on a given device.
+ */
+int dasd_eer_enable(struct dasd_device *device)
+{
+ struct dasd_ccw_req *cqr;
+ unsigned long flags;
+
+ if (device->eer_cqr)
+ return 0;
+
+ if (!device->discipline || strcmp(device->discipline->name, "ECKD"))
+ return -EPERM; /* FIXME: -EMEDIUMTYPE ? */
+
+ cqr = dasd_kmalloc_request("ECKD", 1 /* SNSS */,
+ SNSS_DATA_SIZE, device);
+ if (!cqr)
+ return -ENOMEM;
+
+ cqr->device = device;
+ cqr->retries = 255;
+ cqr->expires = 10 * HZ;
+
+ cqr->cpaddr->cmd_code = DASD_ECKD_CCW_SNSS;
+ cqr->cpaddr->count = SNSS_DATA_SIZE;
+ cqr->cpaddr->flags = 0;
+ cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
+
+ cqr->buildclk = get_clock();
+ cqr->status = DASD_CQR_FILLED;
+ cqr->callback = dasd_eer_snss_cb;
+
+ spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
+ if (!device->eer_cqr) {
+ device->eer_cqr = cqr;
+ cqr = NULL;
+ }
+ spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
+ if (cqr)
+ dasd_kfree_request(cqr, device);
+ return 0;
+}
+
+/*
+ * Disable error reporting on a given device.
+ */
+void dasd_eer_disable(struct dasd_device *device)
+{
+ struct dasd_ccw_req *cqr;
+ unsigned long flags;
+ int in_use;
+
+ if (!device->eer_cqr)
+ return;
+ spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
+ cqr = device->eer_cqr;
+ device->eer_cqr = NULL;
+ clear_bit(DASD_FLAG_EER_SNSS, &device->flags);
+ in_use = test_and_clear_bit(DASD_FLAG_EER_IN_USE, &device->flags);
+ spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
+ if (cqr && !in_use)
+ dasd_kfree_request(cqr, device);
+}
+
+/*
+ * SECTION: the device operations
+ */
+
+/*
+ * On the one side we need a lock to access our internal buffer, on the
+ * other side a copy_to_user can sleep. So we need to copy the data we have
+ * to transfer in a readbuffer, which is protected by the readbuffer_mutex.
+ */
+static char readbuffer[PAGE_SIZE];
+static DECLARE_MUTEX(readbuffer_mutex);
+
+static int dasd_eer_open(struct inode *inp, struct file *filp)
+{
+ struct eerbuffer *eerb;
+ unsigned long flags;
+
+ eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL);
+ eerb->buffer_page_count = eer_pages;
+ if (eerb->buffer_page_count < 1 ||
+ eerb->buffer_page_count > INT_MAX / PAGE_SIZE) {
+ kfree(eerb);
+ MESSAGE(KERN_WARNING, "can't open device since module "
+ "parameter eer_pages is smaller then 1 or"
+ " bigger then %d", (int)(INT_MAX / PAGE_SIZE));
+ return -EINVAL;
+ }
+ eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
+ eerb->buffer = kmalloc(eerb->buffer_page_count * sizeof(char *),
+ GFP_KERNEL);
+ if (!eerb->buffer) {
+ kfree(eerb);
+ return -ENOMEM;
+ }
+ if (dasd_eer_allocate_buffer_pages(eerb->buffer,
+ eerb->buffer_page_count)) {
+ kfree(eerb->buffer);
+ kfree(eerb);
+ return -ENOMEM;
+ }
+ filp->private_data = eerb;
+ spin_lock_irqsave(&bufferlock, flags);
+ list_add(&eerb->list, &bufferlist);
+ spin_unlock_irqrestore(&bufferlock, flags);
+
+ return nonseekable_open(inp,filp);
+}
+
+static int dasd_eer_close(struct inode *inp, struct file *filp)
+{
+ struct eerbuffer *eerb;
+ unsigned long flags;
+
+ eerb = (struct eerbuffer *) filp->private_data;
+ spin_lock_irqsave(&bufferlock, flags);
+ list_del(&eerb->list);
+ spin_unlock_irqrestore(&bufferlock, flags);
+ dasd_eer_free_buffer_pages(eerb->buffer, eerb->buffer_page_count);
+ kfree(eerb->buffer);
+ kfree(eerb);
+
+ return 0;
+}
+
+static ssize_t dasd_eer_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ int tc,rc;
+ int tailcount,effective_count;
+ unsigned long flags;
+ struct eerbuffer *eerb;
+
+ eerb = (struct eerbuffer *) filp->private_data;
+ if (down_interruptible(&readbuffer_mutex))
+ return -ERESTARTSYS;
+
+ spin_lock_irqsave(&bufferlock, flags);
+
+ if (eerb->residual < 0) { /* the remainder of this record */
+ /* has been deleted */
+ eerb->residual = 0;
+ spin_unlock_irqrestore(&bufferlock, flags);
+ up(&readbuffer_mutex);
+ return -EIO;
+ } else if (eerb->residual > 0) {
+ /* OK we still have a second half of a record to deliver */
+ effective_count = min(eerb->residual, (int) count);
+ eerb->residual -= effective_count;
+ } else {
+ tc = 0;
+ while (!tc) {
+ tc = dasd_eer_read_buffer(eerb, (char *) &tailcount,
+ sizeof(tailcount));
+ if (!tc) {
+ /* no data available */
+ spin_unlock_irqrestore(&bufferlock, flags);
+ up(&readbuffer_mutex);
+ if (filp->f_flags & O_NONBLOCK)
+ return -EAGAIN;
+ rc = wait_event_interruptible(
+ dasd_eer_read_wait_queue,
+ eerb->head != eerb->tail);
+ if (rc)
+ return rc;
+ if (down_interruptible(&readbuffer_mutex))
+ return -ERESTARTSYS;
+ spin_lock_irqsave(&bufferlock, flags);
+ }
+ }
+ WARN_ON(tc != sizeof(tailcount));
+ effective_count = min(tailcount,(int)count);
+ eerb->residual = tailcount - effective_count;
+ }
+
+ tc = dasd_eer_read_buffer(eerb, readbuffer, effective_count);
+ WARN_ON(tc != effective_count);
+
+ spin_unlock_irqrestore(&bufferlock, flags);
+
+ if (copy_to_user(buf, readbuffer, effective_count)) {
+ up(&readbuffer_mutex);
+ return -EFAULT;
+ }
+
+ up(&readbuffer_mutex);
+ return effective_count;
+}
+
+static unsigned int dasd_eer_poll(struct file *filp, poll_table *ptable)
+{
+ unsigned int mask;
+ unsigned long flags;
+ struct eerbuffer *eerb;
+
+ eerb = (struct eerbuffer *) filp->private_data;
+ poll_wait(filp, &dasd_eer_read_wait_queue, ptable);
+ spin_lock_irqsave(&bufferlock, flags);
+ if (eerb->head != eerb->tail)
+ mask = POLLIN | POLLRDNORM ;
+ else
+ mask = 0;
+ spin_unlock_irqrestore(&bufferlock, flags);
+ return mask;
+}
+
+static struct file_operations dasd_eer_fops = {
+ .open = &dasd_eer_open,
+ .release = &dasd_eer_close,
+ .read = &dasd_eer_read,
+ .poll = &dasd_eer_poll,
+ .owner = THIS_MODULE,
+};
+
+static struct miscdevice dasd_eer_dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "dasd_eer",
+ .fops = &dasd_eer_fops,
+};
+
+int __init dasd_eer_init(void)
+{
+ int rc;
+
+ rc = misc_register(&dasd_eer_dev);
+ if (rc) {
+ MESSAGE(KERN_ERR, "%s", "dasd_eer_init could not "
+ "register misc device");
+ return rc;
+ }
+
+ return 0;
+}
+
+void __exit dasd_eer_exit(void)
+{
+ WARN_ON(misc_deregister(&dasd_eer_dev) != 0);
+}
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 7cb0b9e78a6..4293ba82752 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -69,15 +69,6 @@
*/
struct dasd_device;
-typedef int (*dasd_ioctl_fn_t) (struct block_device *bdev, int no, long args);
-
-struct dasd_ioctl {
- struct list_head list;
- struct module *owner;
- int no;
- dasd_ioctl_fn_t handler;
-};
-
typedef enum {
dasd_era_fatal = -1, /* no chance to recover */
dasd_era_none = 0, /* don't recover, everything alright */
@@ -272,10 +263,28 @@ struct dasd_discipline {
/* i/o control functions. */
int (*fill_geometry) (struct dasd_device *, struct hd_geometry *);
int (*fill_info) (struct dasd_device *, struct dasd_information2_t *);
+ int (*ioctl) (struct dasd_device *, unsigned int, void __user *);
};
extern struct dasd_discipline *dasd_diag_discipline_pointer;
+
+/*
+ * Notification numbers for extended error reporting notifications:
+ * The DASD_EER_DISABLE notification is sent before a dasd_device (and it's
+ * eer pointer) is freed. The error reporting module needs to do all necessary
+ * cleanup steps.
+ * The DASD_EER_TRIGGER notification sends the actual error reports (triggers).
+ */
+#define DASD_EER_DISABLE 0
+#define DASD_EER_TRIGGER 1
+
+/* Trigger IDs for extended error reporting DASD_EER_TRIGGER notification */
+#define DASD_EER_FATALERROR 1
+#define DASD_EER_NOPATH 2
+#define DASD_EER_STATECHANGE 3
+#define DASD_EER_PPRCSUSPEND 4
+
struct dasd_device {
/* Block device stuff. */
struct gendisk *gdp;
@@ -289,6 +298,9 @@ struct dasd_device {
unsigned long flags; /* per device flags */
unsigned short features; /* copy of devmap-features (read-only!) */
+ /* extended error reporting stuff (eer) */
+ struct dasd_ccw_req *eer_cqr;
+
/* Device discipline stuff. */
struct dasd_discipline *discipline;
struct dasd_discipline *base_discipline;
@@ -334,6 +346,8 @@ struct dasd_device {
/* per device flags */
#define DASD_FLAG_DSC_ERROR 2 /* return -EIO when disconnected */
#define DASD_FLAG_OFFLINE 3 /* device is in offline processing */
+#define DASD_FLAG_EER_SNSS 4 /* A SNSS is required */
+#define DASD_FLAG_EER_IN_USE 5 /* A SNSS request is running */
void dasd_put_device_wake(struct dasd_device *);
@@ -523,10 +537,6 @@ int dasd_scan_partitions(struct dasd_device *);
void dasd_destroy_partitions(struct dasd_device *);
/* externals in dasd_ioctl.c */
-int dasd_ioctl_init(void);
-void dasd_ioctl_exit(void);
-int dasd_ioctl_no_register(struct module *, int, dasd_ioctl_fn_t);
-int dasd_ioctl_no_unregister(struct module *, int, dasd_ioctl_fn_t);
int dasd_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
long dasd_compat_ioctl(struct file *, unsigned int, unsigned long);
@@ -557,6 +567,30 @@ dasd_era_t dasd_9336_erp_examine(struct dasd_ccw_req *, struct irb *);
dasd_era_t dasd_9343_erp_examine(struct dasd_ccw_req *, struct irb *);
struct dasd_ccw_req *dasd_9343_erp_action(struct dasd_ccw_req *);
+/* externals in dasd_eer.c */
+#ifdef CONFIG_DASD_EER
+int dasd_eer_init(void);
+void dasd_eer_exit(void);
+int dasd_eer_enable(struct dasd_device *);
+void dasd_eer_disable(struct dasd_device *);
+void dasd_eer_write(struct dasd_device *, struct dasd_ccw_req *cqr,
+ unsigned int id);
+void dasd_eer_snss(struct dasd_device *);
+
+static inline int dasd_eer_enabled(struct dasd_device *device)
+{
+ return device->eer_cqr != NULL;
+}
+#else
+#define dasd_eer_init() (0)
+#define dasd_eer_exit() do { } while (0)
+#define dasd_eer_enable(d) (0)
+#define dasd_eer_disable(d) do { } while (0)
+#define dasd_eer_write(d,c,i) do { } while (0)
+#define dasd_eer_snss(d) do { } while (0)
+#define dasd_eer_enabled(d) (0)
+#endif /* CONFIG_DASD_ERR */
+
#endif /* __KERNEL__ */
#endif /* DASD_H */
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index fafeeae5267..b8c80d28df4 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -16,6 +16,7 @@
#include <linux/blkpg.h>
#include <asm/ccwdev.h>
+#include <asm/cmb.h>
#include <asm/uaccess.h>
/* This is ugly... */
@@ -23,116 +24,12 @@
#include "dasd_int.h"
-/*
- * SECTION: ioctl functions.
- */
-static struct list_head dasd_ioctl_list = LIST_HEAD_INIT(dasd_ioctl_list);
-
-/*
- * Find the ioctl with number no.
- */
-static struct dasd_ioctl *
-dasd_find_ioctl(int no)
-{
- struct dasd_ioctl *ioctl;
-
- list_for_each_entry (ioctl, &dasd_ioctl_list, list)
- if (ioctl->no == no)
- return ioctl;
- return NULL;
-}
-
-/*
- * Register ioctl with number no.
- */
-int
-dasd_ioctl_no_register(struct module *owner, int no, dasd_ioctl_fn_t handler)
-{
- struct dasd_ioctl *new;
- if (dasd_find_ioctl(no))
- return -EBUSY;
- new = kmalloc(sizeof (struct dasd_ioctl), GFP_KERNEL);
- if (new == NULL)
- return -ENOMEM;
- new->owner = owner;
- new->no = no;
- new->handler = handler;
- list_add(&new->list, &dasd_ioctl_list);
- return 0;
-}
-
-/*
- * Deregister ioctl with number no.
- */
-int
-dasd_ioctl_no_unregister(struct module *owner, int no, dasd_ioctl_fn_t handler)
-{
- struct dasd_ioctl *old = dasd_find_ioctl(no);
- if (old == NULL)
- return -ENOENT;
- if (old->no != no || old->handler != handler || owner != old->owner)
- return -EINVAL;
- list_del(&old->list);
- kfree(old);
- return 0;
-}
-
-int
-dasd_ioctl(struct inode *inp, struct file *filp,
- unsigned int no, unsigned long data)
-{
- struct block_device *bdev = inp->i_bdev;
- struct dasd_device *device = bdev->bd_disk->private_data;
- struct dasd_ioctl *ioctl;
- const char *dir;
- int rc;
-
- if ((_IOC_DIR(no) != _IOC_NONE) && (data == 0)) {
- PRINT_DEBUG("empty data ptr");
- return -EINVAL;
- }
- dir = _IOC_DIR (no) == _IOC_NONE ? "0" :
- _IOC_DIR (no) == _IOC_READ ? "r" :
- _IOC_DIR (no) == _IOC_WRITE ? "w" :
- _IOC_DIR (no) == (_IOC_READ | _IOC_WRITE) ? "rw" : "u";
- DBF_DEV_EVENT(DBF_DEBUG, device,
- "ioctl 0x%08x %s'0x%x'%d(%d) with data %8lx", no,
- dir, _IOC_TYPE(no), _IOC_NR(no), _IOC_SIZE(no), data);
- /* Search for ioctl no in the ioctl list. */
- list_for_each_entry(ioctl, &dasd_ioctl_list, list) {
- if (ioctl->no == no) {
- /* Found a matching ioctl. Call it. */
- if (!try_module_get(ioctl->owner))
- continue;
- rc = ioctl->handler(bdev, no, data);
- module_put(ioctl->owner);
- return rc;
- }
- }
- /* No ioctl with number no. */
- DBF_DEV_EVENT(DBF_INFO, device,
- "unknown ioctl 0x%08x=%s'0x%x'%d(%d) data %8lx", no,
- dir, _IOC_TYPE(no), _IOC_NR(no), _IOC_SIZE(no), data);
- return -EINVAL;
-}
-
-long
-dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
-{
- int rval;
-
- lock_kernel();
- rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
- unlock_kernel();
-
- return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
-}
static int
-dasd_ioctl_api_version(struct block_device *bdev, int no, long args)
+dasd_ioctl_api_version(void __user *argp)
{
int ver = DASD_API_VERSION;
- return put_user(ver, (int __user *) args);
+ return put_user(ver, (int __user *)argp);
}
/*
@@ -140,20 +37,18 @@ dasd_ioctl_api_version(struct block_device *bdev, int no, long args)
* used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection
*/
static int
-dasd_ioctl_enable(struct block_device *bdev, int no, long args)
+dasd_ioctl_enable(struct block_device *bdev)
{
- struct dasd_device *device;
+ struct dasd_device *device = bdev->bd_disk->private_data;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
+
dasd_enable_device(device);
/* Formatting the dasd device can change the capacity. */
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9);
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return 0;
}
@@ -162,15 +57,13 @@ dasd_ioctl_enable(struct block_device *bdev, int no, long args)
* Used by dasdfmt. Disable I/O operations but allow ioctls.
*/
static int
-dasd_ioctl_disable(struct block_device *bdev, int no, long args)
+dasd_ioctl_disable(struct block_device *bdev)
{
- struct dasd_device *device;
+ struct dasd_device *device = bdev->bd_disk->private_data;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
+
/*
* Man this is sick. We don't do a real disable but only downgrade
* the device to DASD_STATE_BASIC. The reason is that dasdfmt uses
@@ -184,9 +77,9 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args)
* Set i_size to zero, since read, write, etc. check against this
* value.
*/
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
i_size_write(bdev->bd_inode, 0);
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
return 0;
}
@@ -194,18 +87,13 @@ dasd_ioctl_disable(struct block_device *bdev, int no, long args)
* Quiesce device.
*/
static int
-dasd_ioctl_quiesce(struct block_device *bdev, int no, long args)
+dasd_ioctl_quiesce(struct dasd_device *device)
{
- struct dasd_device *device;
unsigned long flags;
if (!capable (CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
DEV_MESSAGE (KERN_DEBUG, device, "%s",
"Quiesce IO on device");
spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
@@ -219,18 +107,13 @@ dasd_ioctl_quiesce(struct block_device *bdev, int no, long args)
* Quiesce device.
*/
static int
-dasd_ioctl_resume(struct block_device *bdev, int no, long args)
+dasd_ioctl_resume(struct dasd_device *device)
{
- struct dasd_device *device;
unsigned long flags;
if (!capable (CAP_SYS_ADMIN))
return -EACCES;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
DEV_MESSAGE (KERN_DEBUG, device, "%s",
"resume IO on device");
@@ -302,25 +185,19 @@ dasd_format(struct dasd_device * device, struct format_data_t * fdata)
* Format device.
*/
static int
-dasd_ioctl_format(struct block_device *bdev, int no, long args)
+dasd_ioctl_format(struct block_device *bdev, void __user *argp)
{
- struct dasd_device *device;
+ struct dasd_device *device = bdev->bd_disk->private_data;
struct format_data_t fdata;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
- if (!args)
+ if (!argp)
return -EINVAL;
- /* fdata == NULL is no longer a valid arg to dasd_format ! */
- device = bdev->bd_disk->private_data;
-
- if (device == NULL)
- return -ENODEV;
if (device->features & DASD_FEATURE_READONLY)
return -EROFS;
- if (copy_from_user(&fdata, (void __user *) args,
- sizeof (struct format_data_t)))
+ if (copy_from_user(&fdata, argp, sizeof(struct format_data_t)))
return -EFAULT;
if (bdev != bdev->bd_contains) {
DEV_MESSAGE(KERN_WARNING, device, "%s",
@@ -335,17 +212,8 @@ dasd_ioctl_format(struct block_device *bdev, int no, long args)
* Reset device profile information
*/
static int
-dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args)
+dasd_ioctl_reset_profile(struct dasd_device *device)
{
- struct dasd_device *device;
-
- if (!capable(CAP_SYS_ADMIN))
- return -EACCES;
-
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
memset(&device->profile, 0, sizeof (struct dasd_profile_info_t));
return 0;
}
@@ -354,31 +222,24 @@ dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args)
* Return device profile information
*/
static int
-dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
+dasd_ioctl_read_profile(struct dasd_device *device, void __user *argp)
{
- struct dasd_device *device;
-
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
if (dasd_profile_level == DASD_PROFILE_OFF)
return -EIO;
-
- if (copy_to_user((long __user *) args, (long *) &device->profile,
+ if (copy_to_user(argp, &device->profile,
sizeof (struct dasd_profile_info_t)))
return -EFAULT;
return 0;
}
#else
static int
-dasd_ioctl_reset_profile(struct block_device *bdev, int no, long args)
+dasd_ioctl_reset_profile(struct dasd_device *device)
{
return -ENOSYS;
}
static int
-dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
+dasd_ioctl_read_profile(struct dasd_device *device, void __user *argp)
{
return -ENOSYS;
}
@@ -388,22 +249,18 @@ dasd_ioctl_read_profile(struct block_device *bdev, int no, long args)
* Return dasd information. Used for BIODASDINFO and BIODASDINFO2.
*/
static int
-dasd_ioctl_information(struct block_device *bdev, int no, long args)
+dasd_ioctl_information(struct dasd_device *device,
+ unsigned int cmd, void __user *argp)
{
- struct dasd_device *device;
struct dasd_information2_t *dasd_info;
unsigned long flags;
int rc;
struct ccw_device *cdev;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
-
if (!device->discipline->fill_info)
return -EINVAL;
- dasd_info = kmalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
+ dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL);
if (dasd_info == NULL)
return -ENOMEM;
@@ -446,8 +303,7 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
memcpy(dasd_info->type, device->discipline->name, 4);
else
memcpy(dasd_info->type, "none", 4);
- dasd_info->req_queue_len = 0;
- dasd_info->chanq_len = 0;
+
if (device->request_queue->request_fn) {
struct list_head *l;
#ifdef DASD_EXTENDED_PROFILING
@@ -467,8 +323,8 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
}
rc = 0;
- if (copy_to_user((long __user *) args, (long *) dasd_info,
- ((no == (unsigned int) BIODASDINFO2) ?
+ if (copy_to_user(argp, dasd_info,
+ ((cmd == (unsigned int) BIODASDINFO2) ?
sizeof (struct dasd_information2_t) :
sizeof (struct dasd_information_t))))
rc = -EFAULT;
@@ -480,69 +336,103 @@ dasd_ioctl_information(struct block_device *bdev, int no, long args)
* Set read only
*/
static int
-dasd_ioctl_set_ro(struct block_device *bdev, int no, long args)
+dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp)
{
- struct dasd_device *device;
- int intval, rc;
+ struct dasd_device *device = bdev->bd_disk->private_data;
+ int intval;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
if (bdev != bdev->bd_contains)
// ro setting is not allowed for partitions
return -EINVAL;
- if (get_user(intval, (int __user *) args))
+ if (get_user(intval, (int *)argp))
return -EFAULT;
- device = bdev->bd_disk->private_data;
- if (device == NULL)
- return -ENODEV;
set_disk_ro(bdev->bd_disk, intval);
- rc = dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval);
-
- return rc;
+ return dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval);
}
-/*
- * List of static ioctls.
- */
-static struct { int no; dasd_ioctl_fn_t fn; } dasd_ioctls[] =
+static int
+dasd_ioctl_readall_cmb(struct dasd_device *device, unsigned int cmd,
+ unsigned long arg)
{
- { BIODASDDISABLE, dasd_ioctl_disable },
- { BIODASDENABLE, dasd_ioctl_enable },
- { BIODASDQUIESCE, dasd_ioctl_quiesce },
- { BIODASDRESUME, dasd_ioctl_resume },
- { BIODASDFMT, dasd_ioctl_format },
- { BIODASDINFO, dasd_ioctl_information },
- { BIODASDINFO2, dasd_ioctl_information },
- { BIODASDPRRD, dasd_ioctl_read_profile },
- { BIODASDPRRST, dasd_ioctl_reset_profile },
- { BLKROSET, dasd_ioctl_set_ro },
- { DASDAPIVER, dasd_ioctl_api_version },
- { -1, NULL }
-};
+ struct cmbdata __user *argp = (void __user *) arg;
+ size_t size = _IOC_SIZE(cmd);
+ struct cmbdata data;
+ int ret;
+
+ ret = cmf_readall(device->cdev, &data);
+ if (!ret && copy_to_user(argp, &data, min(size, sizeof(*argp))))
+ return -EFAULT;
+ return ret;
+}
int
-dasd_ioctl_init(void)
+dasd_ioctl(struct inode *inode, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
- int i;
+ struct block_device *bdev = inode->i_bdev;
+ struct dasd_device *device = bdev->bd_disk->private_data;
+ void __user *argp = (void __user *)arg;
- for (i = 0; dasd_ioctls[i].no != -1; i++)
- dasd_ioctl_no_register(NULL, dasd_ioctls[i].no,
- dasd_ioctls[i].fn);
- return 0;
+ if (!device)
+ return -ENODEV;
+
+ if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) {
+ PRINT_DEBUG("empty data ptr");
+ return -EINVAL;
+ }
+ switch (cmd) {
+ case BIODASDDISABLE:
+ return dasd_ioctl_disable(bdev);
+ case BIODASDENABLE:
+ return dasd_ioctl_enable(bdev);
+ case BIODASDQUIESCE:
+ return dasd_ioctl_quiesce(device);
+ case BIODASDRESUME:
+ return dasd_ioctl_resume(device);
+ case BIODASDFMT:
+ return dasd_ioctl_format(bdev, argp);
+ case BIODASDINFO:
+ return dasd_ioctl_information(device, cmd, argp);
+ case BIODASDINFO2:
+ return dasd_ioctl_information(device, cmd, argp);
+ case BIODASDPRRD:
+ return dasd_ioctl_read_profile(device, argp);
+ case BIODASDPRRST:
+ return dasd_ioctl_reset_profile(device);
+ case BLKROSET:
+ return dasd_ioctl_set_ro(bdev, argp);
+ case DASDAPIVER:
+ return dasd_ioctl_api_version(argp);
+ case BIODASDCMFENABLE:
+ return enable_cmf(device->cdev);
+ case BIODASDCMFDISABLE:
+ return disable_cmf(device->cdev);
+ case BIODASDREADALLCMB:
+ return dasd_ioctl_readall_cmb(device, cmd, arg);
+ default:
+ /* if the discipline has an ioctl method try it. */
+ if (device->discipline->ioctl) {
+ int rval = device->discipline->ioctl(device, cmd, argp);
+ if (rval != -ENOIOCTLCMD)
+ return rval;
+ }
+
+ return -EINVAL;
+ }
}
-void
-dasd_ioctl_exit(void)
+long
+dasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
- int i;
+ int rval;
- for (i = 0; dasd_ioctls[i].no != -1; i++)
- dasd_ioctl_no_unregister(NULL, dasd_ioctls[i].no,
- dasd_ioctls[i].fn);
+ lock_kernel();
+ rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg);
+ unlock_kernel();
+ return (rval == -EINVAL) ? -ENOIOCTLCMD : rval;
}
-
-EXPORT_SYMBOL(dasd_ioctl_no_register);
-EXPORT_SYMBOL(dasd_ioctl_no_unregister);
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c
index 44133250da2..be9b05347b4 100644
--- a/drivers/s390/block/dcssblk.c
+++ b/drivers/s390/block/dcssblk.c
@@ -388,12 +388,11 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
/*
* get a struct dcssblk_dev_info
*/
- dev_info = kmalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);
+ dev_info = kzalloc(sizeof(struct dcssblk_dev_info), GFP_KERNEL);
if (dev_info == NULL) {
rc = -ENOMEM;
goto out;
}
- memset(dev_info, 0, sizeof(struct dcssblk_dev_info));
strcpy(dev_info->segment_name, local_buf);
strlcpy(dev_info->dev.bus_id, local_buf, BUS_ID_SIZE);
diff --git a/drivers/s390/char/Makefile b/drivers/s390/char/Makefile
index 6377a96735d..0c0162ff6c0 100644
--- a/drivers/s390/char/Makefile
+++ b/drivers/s390/char/Makefile
@@ -26,4 +26,5 @@ tape-$(CONFIG_PROC_FS) += tape_proc.o
tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y)
obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o
obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o
+obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o
obj-$(CONFIG_MONREADER) += monreader.o
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c
index 5f6fa4c6784..a6415377bc7 100644
--- a/drivers/s390/char/fs3270.c
+++ b/drivers/s390/char/fs3270.c
@@ -368,10 +368,9 @@ fs3270_alloc_view(void)
{
struct fs3270 *fp;
- fp = (struct fs3270 *) kmalloc(sizeof(struct fs3270),GFP_KERNEL);
+ fp = kzalloc(sizeof(struct fs3270),GFP_KERNEL);
if (!fp)
return ERR_PTR(-ENOMEM);
- memset(fp, 0, sizeof(struct fs3270));
fp->init = raw3270_request_alloc(0);
if (IS_ERR(fp->init)) {
kfree(fp);
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c
index a317a123dab..6badd840340 100644
--- a/drivers/s390/char/keyboard.c
+++ b/drivers/s390/char/keyboard.c
@@ -50,14 +50,12 @@ kbd_alloc(void) {
struct kbd_data *kbd;
int i, len;
- kbd = kmalloc(sizeof(struct kbd_data), GFP_KERNEL);
+ kbd = kzalloc(sizeof(struct kbd_data), GFP_KERNEL);
if (!kbd)
goto out;
- memset(kbd, 0, sizeof(struct kbd_data));
- kbd->key_maps = kmalloc(sizeof(key_maps), GFP_KERNEL);
+ kbd->key_maps = kzalloc(sizeof(key_maps), GFP_KERNEL);
if (!key_maps)
goto out_kbd;
- memset(kbd->key_maps, 0, sizeof(key_maps));
for (i = 0; i < ARRAY_SIZE(key_maps); i++) {
if (key_maps[i]) {
kbd->key_maps[i] =
@@ -68,10 +66,9 @@ kbd_alloc(void) {
sizeof(u_short)*NR_KEYS);
}
}
- kbd->func_table = kmalloc(sizeof(func_table), GFP_KERNEL);
+ kbd->func_table = kzalloc(sizeof(func_table), GFP_KERNEL);
if (!kbd->func_table)
goto out_maps;
- memset(kbd->func_table, 0, sizeof(func_table));
for (i = 0; i < ARRAY_SIZE(func_table); i++) {
if (func_table[i]) {
len = strlen(func_table[i]) + 1;
@@ -82,10 +79,9 @@ kbd_alloc(void) {
}
}
kbd->fn_handler =
- kmalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
+ kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
if (!kbd->fn_handler)
goto out_func;
- memset(kbd->fn_handler, 0, sizeof(fn_handler_fn *) * NR_FN_HANDLER);
kbd->accent_table =
kmalloc(sizeof(struct kbdiacr)*MAX_DIACR, GFP_KERNEL);
if (!kbd->accent_table)
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c
index 5fd3ad86738..fb7bc9e5eeb 100644
--- a/drivers/s390/char/monreader.c
+++ b/drivers/s390/char/monreader.c
@@ -257,14 +257,13 @@ mon_alloc_mem(void)
int i,j;
struct mon_private *monpriv;
- monpriv = kmalloc(sizeof(struct mon_private), GFP_KERNEL);
+ monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL);
if (!monpriv) {
P_ERROR("no memory for monpriv\n");
return NULL;
}
- memset(monpriv, 0, sizeof(struct mon_private));
for (i = 0; i < MON_MSGLIM; i++) {
- monpriv->msg_array[i] = kmalloc(sizeof(struct mon_msg),
+ monpriv->msg_array[i] = kzalloc(sizeof(struct mon_msg),
GFP_KERNEL);
if (!monpriv->msg_array[i]) {
P_ERROR("open, no memory for msg_array\n");
@@ -272,7 +271,6 @@ mon_alloc_mem(void)
kfree(monpriv->msg_array[j]);
return NULL;
}
- memset(monpriv->msg_array[i], 0, sizeof(struct mon_msg));
}
return monpriv;
}
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c
index 1026f2bc318..bd06607a5dc 100644
--- a/drivers/s390/char/raw3270.c
+++ b/drivers/s390/char/raw3270.c
@@ -115,10 +115,9 @@ raw3270_request_alloc(size_t size)
struct raw3270_request *rq;
/* Allocate request structure */
- rq = kmalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
+ rq = kzalloc(sizeof(struct raw3270_request), GFP_KERNEL | GFP_DMA);
if (!rq)
return ERR_PTR(-ENOMEM);
- memset(rq, 0, sizeof(struct raw3270_request));
/* alloc output buffer. */
if (size > 0) {
diff --git a/drivers/s390/char/tape.h b/drivers/s390/char/tape.h
index 01d865d9379..cd51ace8b61 100644
--- a/drivers/s390/char/tape.h
+++ b/drivers/s390/char/tape.h
@@ -250,6 +250,7 @@ extern void tape_free_request(struct tape_request *);
extern int tape_do_io(struct tape_device *, struct tape_request *);
extern int tape_do_io_async(struct tape_device *, struct tape_request *);
extern int tape_do_io_interruptible(struct tape_device *, struct tape_request *);
+extern int tape_cancel_io(struct tape_device *, struct tape_request *);
void tape_hotplug_event(struct tape_device *, int major, int action);
static inline int
diff --git a/drivers/s390/char/tape_34xx.c b/drivers/s390/char/tape_34xx.c
index 682039cac15..d4f2da73807 100644
--- a/drivers/s390/char/tape_34xx.c
+++ b/drivers/s390/char/tape_34xx.c
@@ -2,8 +2,7 @@
* drivers/s390/char/tape_34xx.c
* tape device discipline for 3480/3490 tapes.
*
- * S390 and zSeries version
- * Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Copyright (C) IBM Corp. 2001,2006
* Author(s): Carsten Otte <cotte@de.ibm.com>
* Tuan Ngo-Anh <ngoanh@de.ibm.com>
* Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -28,11 +27,6 @@
debug_info_t *TAPE_DBF_AREA = NULL;
EXPORT_SYMBOL(TAPE_DBF_AREA);
-enum tape_34xx_type {
- tape_3480,
- tape_3490,
-};
-
#define TAPE34XX_FMT_3480 0
#define TAPE34XX_FMT_3480_2_XF 1
#define TAPE34XX_FMT_3480_XF 2
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
new file mode 100644
index 00000000000..c3915f60a3a
--- /dev/null
+++ b/drivers/s390/char/tape_3590.c
@@ -0,0 +1,1301 @@
+/*
+ * drivers/s390/char/tape_3590.c
+ * tape device discipline for 3590 tapes.
+ *
+ * Copyright (C) IBM Corp. 2001,2006
+ * Author(s): Stefan Bader <shbader@de.ibm.com>
+ * Michael Holzheu <holzheu@de.ibm.com>
+ * Martin Schwidefsky <schwidefsky@de.ibm.com>
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/bio.h>
+
+#define TAPE_DBF_AREA tape_3590_dbf
+
+#include "tape.h"
+#include "tape_std.h"
+#include "tape_3590.h"
+
+/*
+ * Pointer to debug area.
+ */
+debug_info_t *TAPE_DBF_AREA = NULL;
+EXPORT_SYMBOL(TAPE_DBF_AREA);
+
+/*******************************************************************
+ * Error Recovery fuctions:
+ * - Read Opposite: implemented
+ * - Read Device (buffered) log: BRA
+ * - Read Library log: BRA
+ * - Swap Devices: BRA
+ * - Long Busy: BRA
+ * - Special Intercept: BRA
+ * - Read Alternate: implemented
+ *******************************************************************/
+
+#define PRINTK_HEADER "TAPE_3590: "
+
+static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = {
+ [0x00] = "",
+ [0x10] = "Lost Sense",
+ [0x11] = "Assigned Elsewhere",
+ [0x12] = "Allegiance Reset",
+ [0x13] = "Shared Access Violation",
+ [0x20] = "Command Reject",
+ [0x21] = "Configuration Error",
+ [0x22] = "Protection Exception",
+ [0x23] = "Write Protect",
+ [0x24] = "Write Length",
+ [0x25] = "Read-Only Format",
+ [0x31] = "Beginning of Partition",
+ [0x33] = "End of Partition",
+ [0x34] = "End of Data",
+ [0x35] = "Block not found",
+ [0x40] = "Device Intervention",
+ [0x41] = "Loader Intervention",
+ [0x42] = "Library Intervention",
+ [0x50] = "Write Error",
+ [0x51] = "Erase Error",
+ [0x52] = "Formatting Error",
+ [0x53] = "Read Error",
+ [0x54] = "Unsupported Format",
+ [0x55] = "No Formatting",
+ [0x56] = "Positioning lost",
+ [0x57] = "Read Length",
+ [0x60] = "Unsupported Medium",
+ [0x61] = "Medium Length Error",
+ [0x62] = "Medium removed",
+ [0x64] = "Load Check",
+ [0x65] = "Unload Check",
+ [0x70] = "Equipment Check",
+ [0x71] = "Bus out Check",
+ [0x72] = "Protocol Error",
+ [0x73] = "Interface Error",
+ [0x74] = "Overrun",
+ [0x75] = "Halt Signal",
+ [0x90] = "Device fenced",
+ [0x91] = "Device Path fenced",
+ [0xa0] = "Volume misplaced",
+ [0xa1] = "Volume inaccessible",
+ [0xa2] = "Volume in input",
+ [0xa3] = "Volume ejected",
+ [0xa4] = "All categories reserved",
+ [0xa5] = "Duplicate Volume",
+ [0xa6] = "Library Manager Offline",
+ [0xa7] = "Library Output Station full",
+ [0xa8] = "Vision System non-operational",
+ [0xa9] = "Library Manager Equipment Check",
+ [0xaa] = "Library Equipment Check",
+ [0xab] = "All Library Cells full",
+ [0xac] = "No Cleaner Volumes in Library",
+ [0xad] = "I/O Station door open",
+ [0xae] = "Subsystem environmental alert",
+};
+
+/*
+ * 3590 IOCTL Overload
+ */
+static int
+tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg)
+{
+ switch (cmd) {
+ case TAPE390_DISPLAY: {
+ struct display_struct disp;
+
+ if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)))
+ return -EFAULT;
+
+ return tape_std_display(device, &disp);
+ }
+ default:
+ return -EINVAL; /* no additional ioctls */
+ }
+}
+
+/*
+ * SENSE Medium: Get Sense data about medium state
+ */
+static int
+tape_3590_sense_medium(struct tape_device *device)
+{
+ struct tape_request *request;
+
+ request = tape_alloc_request(1, 128);
+ if (IS_ERR(request))
+ return PTR_ERR(request);
+ request->op = TO_MSEN;
+ tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata);
+ return tape_do_io_free(device, request);
+}
+
+/*
+ * MTTELL: Tell block. Return the number of block relative to current file.
+ */
+static int
+tape_3590_mttell(struct tape_device *device, int mt_count)
+{
+ __u64 block_id;
+ int rc;
+
+ rc = tape_std_read_block_id(device, &block_id);
+ if (rc)
+ return rc;
+ return block_id >> 32;
+}
+
+/*
+ * MTSEEK: seek to the specified block.
+ */
+static int
+tape_3590_mtseek(struct tape_device *device, int count)
+{
+ struct tape_request *request;
+
+ DBF_EVENT(6, "xsee id: %x\n", count);
+ request = tape_alloc_request(3, 4);
+ if (IS_ERR(request))
+ return PTR_ERR(request);
+ request->op = TO_LBL;
+ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
+ *(__u32 *) request->cpdata = count;
+ tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
+ tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
+ return tape_do_io_free(device, request);
+}
+
+/*
+ * Read Opposite Error Recovery Function:
+ * Used, when Read Forward does not work
+ */
+static void
+tape_3590_read_opposite(struct tape_device *device,
+ struct tape_request *request)
+{
+ struct tape_3590_disc_data *data;
+
+ /*
+ * We have allocated 4 ccws in tape_std_read, so we can now
+ * transform the request to a read backward, followed by a
+ * forward space block.
+ */
+ request->op = TO_RBA;
+ tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte);
+ data = device->discdata;
+ tape_ccw_cc_idal(request->cpaddr + 1, data->read_back_op,
+ device->char_data.idal_buf);
+ tape_ccw_cc(request->cpaddr + 2, FORSPACEBLOCK, 0, NULL);
+ tape_ccw_end(request->cpaddr + 3, NOP, 0, NULL);
+ DBF_EVENT(6, "xrop ccwg\n");
+}
+
+/*
+ * Read Attention Msg
+ * This should be done after an interrupt with attention bit (0x80)
+ * in device state.
+ *
+ * After a "read attention message" request there are two possible
+ * results:
+ *
+ * 1. A unit check is presented, when attention sense is present (e.g. when
+ * a medium has been unloaded). The attention sense comes then
+ * together with the unit check. The recovery action is either "retry"
+ * (in case there is an attention message pending) or "permanent error".
+ *
+ * 2. The attention msg is written to the "read subsystem data" buffer.
+ * In this case we probably should print it to the console.
+ */
+static int
+tape_3590_read_attmsg(struct tape_device *device)
+{
+ struct tape_request *request;
+ char *buf;
+
+ request = tape_alloc_request(3, 4096);
+ if (IS_ERR(request))
+ return PTR_ERR(request);
+ request->op = TO_READ_ATTMSG;
+ buf = request->cpdata;
+ buf[0] = PREP_RD_SS_DATA;
+ buf[6] = RD_ATTMSG; /* read att msg */
+ tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf);
+ tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12);
+ tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL);
+ return tape_do_io_free(device, request);
+}
+
+/*
+ * These functions are used to schedule follow-up actions from within an
+ * interrupt context (like unsolicited interrupts).
+ */
+static void
+tape_3590_work_handler(void *data)
+{
+ struct {
+ struct tape_device *device;
+ enum tape_op op;
+ struct work_struct work;
+ } *p = data;
+
+ switch (p->op) {
+ case TO_MSEN:
+ tape_3590_sense_medium(p->device);
+ break;
+ case TO_READ_ATTMSG:
+ tape_3590_read_attmsg(p->device);
+ break;
+ default:
+ DBF_EVENT(3, "T3590: work handler undefined for "
+ "operation 0x%02x\n", p->op);
+ }
+ tape_put_device(p->device);
+ kfree(p);
+}
+
+static int
+tape_3590_schedule_work(struct tape_device *device, enum tape_op op)
+{
+ struct {
+ struct tape_device *device;
+ enum tape_op op;
+ struct work_struct work;
+ } *p;
+
+ if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL)
+ return -ENOMEM;
+
+ INIT_WORK(&p->work, tape_3590_work_handler, p);
+
+ p->device = tape_get_device_reference(device);
+ p->op = op;
+
+ schedule_work(&p->work);
+ return 0;
+}
+
+#ifdef CONFIG_S390_TAPE_BLOCK
+/*
+ * Tape Block READ
+ */
+static struct tape_request *
+tape_3590_bread(struct tape_device *device, struct request *req)
+{
+ struct tape_request *request;
+ struct ccw1 *ccw;
+ int count = 0, start_block, i;
+ unsigned off;
+ char *dst;
+ struct bio_vec *bv;
+ struct bio *bio;
+
+ DBF_EVENT(6, "xBREDid:");
+ start_block = req->sector >> TAPEBLOCK_HSEC_S2B;
+ DBF_EVENT(6, "start_block = %i\n", start_block);
+
+ rq_for_each_bio(bio, req) {
+ bio_for_each_segment(bv, bio, i) {
+ count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B + 9);
+ }
+ }
+ request = tape_alloc_request(2 + count + 1, 4);
+ if (IS_ERR(request))
+ return request;
+ request->op = TO_BLOCK;
+ *(__u32 *) request->cpdata = start_block;
+ ccw = request->cpaddr;
+ ccw = tape_ccw_cc(ccw, MODE_SET_DB, 1, device->modeset_byte);
+
+ /*
+ * We always setup a nop after the mode set ccw. This slot is
+ * used in tape_std_check_locate to insert a locate ccw if the
+ * current tape position doesn't match the start block to be read.
+ */
+ ccw = tape_ccw_cc(ccw, NOP, 0, NULL);
+
+ rq_for_each_bio(bio, req) {
+ bio_for_each_segment(bv, bio, i) {
+ dst = kmap(bv->bv_page) + bv->bv_offset;
+ for (off = 0; off < bv->bv_len;
+ off += TAPEBLOCK_HSEC_SIZE) {
+ ccw->flags = CCW_FLAG_CC;
+ ccw->cmd_code = READ_FORWARD;
+ ccw->count = TAPEBLOCK_HSEC_SIZE;
+ set_normalized_cda(ccw, (void *) __pa(dst));
+ ccw++;
+ dst += TAPEBLOCK_HSEC_SIZE;
+ }
+ if (off > bv->bv_len)
+ BUG();
+ }
+ }
+ ccw = tape_ccw_end(ccw, NOP, 0, NULL);
+ DBF_EVENT(6, "xBREDccwg\n");
+ return request;
+}
+
+static void
+tape_3590_free_bread(struct tape_request *request)
+{
+ struct ccw1 *ccw;
+
+ /* Last ccw is a nop and doesn't need clear_normalized_cda */
+ for (ccw = request->cpaddr; ccw->flags & CCW_FLAG_CC; ccw++)
+ if (ccw->cmd_code == READ_FORWARD)
+ clear_normalized_cda(ccw);
+ tape_free_request(request);
+}
+
+/*
+ * check_locate is called just before the tape request is passed to
+ * the common io layer for execution. It has to check the current
+ * tape position and insert a locate ccw if it doesn't match the
+ * start block for the request.
+ */
+static void
+tape_3590_check_locate(struct tape_device *device, struct tape_request *request)
+{
+ __u32 *start_block;
+
+ start_block = (__u32 *) request->cpdata;
+ if (*start_block != device->blk_data.block_position) {
+ /* Add the start offset of the file to get the real block. */
+ *start_block += device->bof;
+ tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata);
+ }
+}
+#endif
+
+/*
+ * The done handler is called at device/channel end and wakes up the sleeping
+ * process
+ */
+static int
+tape_3590_done(struct tape_device *device, struct tape_request *request)
+{
+ struct tape_3590_med_sense *sense;
+
+ DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]);
+
+ switch (request->op) {
+ case TO_BSB:
+ case TO_BSF:
+ case TO_DSE:
+ case TO_FSB:
+ case TO_FSF:
+ case TO_LBL:
+ case TO_RFO:
+ case TO_RBA:
+ case TO_REW:
+ case TO_WRI:
+ case TO_WTM:
+ case TO_BLOCK:
+ case TO_LOAD:
+ tape_med_state_set(device, MS_LOADED);
+ break;
+ case TO_RUN:
+ tape_med_state_set(device, MS_UNLOADED);
+ break;
+ case TO_MSEN:
+ sense = (struct tape_3590_med_sense *) request->cpdata;
+ if (sense->masst == MSENSE_UNASSOCIATED)
+ tape_med_state_set(device, MS_UNLOADED);
+ if (sense->masst == MSENSE_ASSOCIATED_MOUNT)
+ tape_med_state_set(device, MS_LOADED);
+ break;
+ case TO_RBI: /* RBI seems to succeed even without medium loaded. */
+ case TO_NOP: /* Same to NOP. */
+ case TO_READ_CONFIG:
+ case TO_READ_ATTMSG:
+ case TO_DIS:
+ case TO_ASSIGN:
+ case TO_UNASSIGN:
+ break;
+ case TO_SIZE:
+ break;
+ }
+ return TAPE_IO_SUCCESS;
+}
+
+/*
+ * This fuction is called, when error recovery was successfull
+ */
+static inline int
+tape_3590_erp_succeded(struct tape_device *device, struct tape_request *request)
+{
+ DBF_EVENT(3, "Error Recovery successfull for %s\n",
+ tape_op_verbose[request->op]);
+ return tape_3590_done(device, request);
+}
+
+/*
+ * This fuction is called, when error recovery was not successfull
+ */
+static inline int
+tape_3590_erp_failed(struct tape_device *device, struct tape_request *request,
+ struct irb *irb, int rc)
+{
+ DBF_EVENT(3, "Error Recovery failed for %s\n",
+ tape_op_verbose[request->op]);
+ tape_dump_sense_dbf(device, request, irb);
+ return rc;
+}
+
+/*
+ * Error Recovery do retry
+ */
+static inline int
+tape_3590_erp_retry(struct tape_device *device, struct tape_request *request,
+ struct irb *irb)
+{
+ DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]);
+ tape_dump_sense_dbf(device, request, irb);
+ return TAPE_IO_RETRY;
+}
+
+/*
+ * Handle unsolicited interrupts
+ */
+static int
+tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb)
+{
+ if (irb->scsw.dstat == DEV_STAT_CHN_END)
+ /* Probably result of halt ssch */
+ return TAPE_IO_PENDING;
+ else if (irb->scsw.dstat == 0x85)
+ /* Device Ready -> check medium state */
+ tape_3590_schedule_work(device, TO_MSEN);
+ else if (irb->scsw.dstat & DEV_STAT_ATTENTION)
+ tape_3590_schedule_work(device, TO_READ_ATTMSG);
+ else {
+ DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id);
+ PRINT_WARN("Unsolicited IRQ (Device End) caught.\n");
+ tape_dump_sense(device, NULL, irb);
+ }
+ return TAPE_IO_SUCCESS;
+}
+
+/*
+ * Basic Recovery routine
+ */
+static int
+tape_3590_erp_basic(struct tape_device *device, struct tape_request *request,
+ struct irb *irb, int rc)
+{
+ struct tape_3590_sense *sense;
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+
+ switch (sense->bra) {
+ case SENSE_BRA_PER:
+ return tape_3590_erp_failed(device, request, irb, rc);
+ case SENSE_BRA_CONT:
+ return tape_3590_erp_succeded(device, request);
+ case SENSE_BRA_RE:
+ return tape_3590_erp_retry(device, request, irb);
+ case SENSE_BRA_DRE:
+ return tape_3590_erp_failed(device, request, irb, rc);
+ default:
+ PRINT_ERR("Unknown BRA %x - This should not happen!\n",
+ sense->bra);
+ BUG();
+ return TAPE_IO_STOP;
+ }
+}
+
+/*
+ * RDL: Read Device (buffered) log
+ */
+static int
+tape_3590_erp_read_buf_log(struct tape_device *device,
+ struct tape_request *request, struct irb *irb)
+{
+ /*
+ * We just do the basic error recovery at the moment (retry).
+ * Perhaps in the future, we read the log and dump it somewhere...
+ */
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+}
+
+/*
+ * SWAP: Swap Devices
+ */
+static int
+tape_3590_erp_swap(struct tape_device *device, struct tape_request *request,
+ struct irb *irb)
+{
+ /*
+ * This error recovery should swap the tapes
+ * if the original has a problem. The operation
+ * should proceed with the new tape... this
+ * should probably be done in user space!
+ */
+ PRINT_WARN("(%s): Swap Tape Device!\n", device->cdev->dev.bus_id);
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+}
+
+/*
+ * LBY: Long Busy
+ */
+static int
+tape_3590_erp_long_busy(struct tape_device *device,
+ struct tape_request *request, struct irb *irb)
+{
+ /* FIXME: how about WAITING for a minute ? */
+ PRINT_WARN("(%s): Device is busy! Please wait a minute!\n",
+ device->cdev->dev.bus_id);
+ return tape_3590_erp_basic(device, request, irb, -EBUSY);
+}
+
+/*
+ * SPI: Special Intercept
+ */
+static int
+tape_3590_erp_special_interrupt(struct tape_device *device,
+ struct tape_request *request, struct irb *irb)
+{
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+}
+
+/*
+ * RDA: Read Alternate
+ */
+static int
+tape_3590_erp_read_alternate(struct tape_device *device,
+ struct tape_request *request, struct irb *irb)
+{
+ struct tape_3590_disc_data *data;
+
+ /*
+ * The issued Read Backward or Read Previous command is not
+ * supported by the device
+ * The recovery action should be to issue another command:
+ * Read Revious: if Read Backward is not supported
+ * Read Backward: if Read Previous is not supported
+ */
+ data = device->discdata;
+ if (data->read_back_op == READ_PREVIOUS) {
+ DBF_EVENT(2, "(%08x): No support for READ_PREVIOUS command\n",
+ device->cdev_id);
+ data->read_back_op = READ_BACKWARD;
+ } else {
+ DBF_EVENT(2, "(%08x): No support for READ_BACKWARD command\n",
+ device->cdev_id);
+ data->read_back_op = READ_PREVIOUS;
+ }
+ tape_3590_read_opposite(device, request);
+ return tape_3590_erp_retry(device, request, irb);
+}
+
+/*
+ * Error Recovery read opposite
+ */
+static int
+tape_3590_erp_read_opposite(struct tape_device *device,
+ struct tape_request *request, struct irb *irb)
+{
+ switch (request->op) {
+ case TO_RFO:
+ /*
+ * We did read forward, but the data could not be read.
+ * We will read backward and then skip forward again.
+ */
+ tape_3590_read_opposite(device, request);
+ return tape_3590_erp_retry(device, request, irb);
+ case TO_RBA:
+ /* We tried to read forward and backward, but hat no success */
+ return tape_3590_erp_failed(device, request, irb, -EIO);
+ break;
+ default:
+ PRINT_WARN("read_opposite_recovery_called_with_op: %s\n",
+ tape_op_verbose[request->op]);
+ return tape_3590_erp_failed(device, request, irb, -EIO);
+ }
+}
+
+/*
+ * Print an MIM (Media Information Message) (message code f0)
+ */
+static void
+tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb)
+{
+ struct tape_3590_sense *sense;
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+ /* Exception Message */
+ switch (sense->fmt.f70.emc) {
+ case 0x02:
+ PRINT_WARN("(%s): Data degraded\n", device->cdev->dev.bus_id);
+ break;
+ case 0x03:
+ PRINT_WARN("(%s): Data degraded in partion %i\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.mp);
+ break;
+ case 0x04:
+ PRINT_WARN("(%s): Medium degraded\n", device->cdev->dev.bus_id);
+ break;
+ case 0x05:
+ PRINT_WARN("(%s): Medium degraded in partition %i\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.mp);
+ break;
+ case 0x06:
+ PRINT_WARN("(%s): Block 0 Error\n", device->cdev->dev.bus_id);
+ break;
+ case 0x07:
+ PRINT_WARN("(%s): Medium Exception 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.md);
+ break;
+ default:
+ PRINT_WARN("(%s): MIM ExMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.emc);
+ break;
+ }
+ /* Service Message */
+ switch (sense->fmt.f70.smc) {
+ case 0x02:
+ PRINT_WARN("(%s): Reference Media maintenance procedure %i\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.md);
+ break;
+ default:
+ PRINT_WARN("(%s): MIM ServiceMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f70.smc);
+ break;
+ }
+}
+
+/*
+ * Print an I/O Subsystem Service Information Message (message code f1)
+ */
+static void
+tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb)
+{
+ struct tape_3590_sense *sense;
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+ /* Exception Message */
+ switch (sense->fmt.f71.emc) {
+ case 0x01:
+ PRINT_WARN("(%s): Effect of failure is unknown\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x02:
+ PRINT_WARN("(%s): CU Exception - no performance impact\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x03:
+ PRINT_WARN("(%s): CU Exception on channel interface 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x04:
+ PRINT_WARN("(%s): CU Exception on device path 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x05:
+ PRINT_WARN("(%s): CU Exception on library path 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x06:
+ PRINT_WARN("(%s): CU Exception on node 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x07:
+ PRINT_WARN("(%s): CU Exception on partition 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ default:
+ PRINT_WARN("(%s): SIM ExMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.emc);
+ }
+ /* Service Message */
+ switch (sense->fmt.f71.smc) {
+ case 0x01:
+ PRINT_WARN("(%s): Repair impact is unknown\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x02:
+ PRINT_WARN("(%s): Repair will not impact cu performance\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x03:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable node "
+ "0x%x on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable nodes "
+ "(0x%x-0x%x) on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x04:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable cannel path "
+ "0x%x on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable cannel paths "
+ "(0x%x-0x%x) on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x05:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable device path "
+ "0x%x on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable device paths "
+ "(0x%x-0x%x) on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x06:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable library path "
+ "0x%x on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable library paths "
+ "(0x%x-0x%x) on CU\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x07:
+ PRINT_WARN("(%s): Repair will disable access to CU\n",
+ device->cdev->dev.bus_id);
+ break;
+ default:
+ PRINT_WARN("(%s): SIM ServiceMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.smc);
+ }
+}
+
+/*
+ * Print an Device Subsystem Service Information Message (message code f2)
+ */
+static void
+tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb)
+{
+ struct tape_3590_sense *sense;
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+ /* Exception Message */
+ switch (sense->fmt.f71.emc) {
+ case 0x01:
+ PRINT_WARN("(%s): Effect of failure is unknown\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x02:
+ PRINT_WARN("(%s): DV Exception - no performance impact\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x03:
+ PRINT_WARN("(%s): DV Exception on channel interface 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x04:
+ PRINT_WARN("(%s): DV Exception on loader 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x05:
+ PRINT_WARN("(%s): DV Exception on message display 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.md[0]);
+ break;
+ case 0x06:
+ PRINT_WARN("(%s): DV Exception in tape path\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x07:
+ PRINT_WARN("(%s): DV Exception in drive\n",
+ device->cdev->dev.bus_id);
+ break;
+ default:
+ PRINT_WARN("(%s): DSIM ExMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.emc);
+ }
+ /* Service Message */
+ switch (sense->fmt.f71.smc) {
+ case 0x01:
+ PRINT_WARN("(%s): Repair impact is unknown\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x02:
+ PRINT_WARN("(%s): Repair will not impact device performance\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x03:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable channel path "
+ "0x%x on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable channel path "
+ "(0x%x-0x%x) on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x04:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable interface 0x%x "
+ "on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable interfaces "
+ "(0x%x-0x%x) on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x05:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable loader 0x%x "
+ "on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable loader "
+ "(0x%x-0x%x) on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x07:
+ PRINT_WARN("(%s): Repair will disable access to DV\n",
+ device->cdev->dev.bus_id);
+ break;
+ case 0x08:
+ if (sense->fmt.f71.mdf == 0)
+ PRINT_WARN("(%s): Repair will disable message "
+ "display 0x%x on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1]);
+ else
+ PRINT_WARN("(%s): Repair will disable message "
+ "displays (0x%x-0x%x) on DV\n",
+ device->cdev->dev.bus_id,
+ sense->fmt.f71.md[1], sense->fmt.f71.md[2]);
+ break;
+ case 0x09:
+ PRINT_WARN("(%s): Clean DV\n", device->cdev->dev.bus_id);
+ break;
+ default:
+ PRINT_WARN("(%s): DSIM ServiceMsg: 0x%02x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.smc);
+ }
+}
+
+/*
+ * Print standard ERA Message
+ */
+static void
+tape_3590_print_era_msg(struct tape_device *device, struct irb *irb)
+{
+ struct tape_3590_sense *sense;
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+ if (sense->mc == 0)
+ return;
+ if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) {
+ if (tape_3590_msg[sense->mc] != NULL)
+ PRINT_WARN("(%s): %s\n", device->cdev->dev.bus_id,
+ tape_3590_msg[sense->mc]);
+ else {
+ PRINT_WARN("(%s): Message Code 0x%x\n",
+ device->cdev->dev.bus_id, sense->mc);
+ }
+ return;
+ }
+ if (sense->mc == 0xf0) {
+ /* Standard Media Information Message */
+ PRINT_WARN("(%s): MIM SEV=%i, MC=%02x, ES=%x/%x, "
+ "RC=%02x-%04x-%02x\n", device->cdev->dev.bus_id,
+ sense->fmt.f70.sev, sense->mc,
+ sense->fmt.f70.emc, sense->fmt.f70.smc,
+ sense->fmt.f70.refcode, sense->fmt.f70.mid,
+ sense->fmt.f70.fid);
+ tape_3590_print_mim_msg_f0(device, irb);
+ return;
+ }
+ if (sense->mc == 0xf1) {
+ /* Standard I/O Subsystem Service Information Message */
+ PRINT_WARN("(%s): IOSIM SEV=%i, DEVTYPE=3590/%02x, "
+ "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.sev,
+ device->cdev->id.dev_model,
+ sense->mc, sense->fmt.f71.emc,
+ sense->fmt.f71.smc, sense->fmt.f71.refcode1,
+ sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
+ tape_3590_print_io_sim_msg_f1(device, irb);
+ return;
+ }
+ if (sense->mc == 0xf2) {
+ /* Standard Device Service Information Message */
+ PRINT_WARN("(%s): DEVSIM SEV=%i, DEVTYPE=3590/%02x, "
+ "MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n",
+ device->cdev->dev.bus_id, sense->fmt.f71.sev,
+ device->cdev->id.dev_model,
+ sense->mc, sense->fmt.f71.emc,
+ sense->fmt.f71.smc, sense->fmt.f71.refcode1,
+ sense->fmt.f71.refcode2, sense->fmt.f71.refcode3);
+ tape_3590_print_dev_sim_msg_f2(device, irb);
+ return;
+ }
+ if (sense->mc == 0xf3) {
+ /* Standard Library Service Information Message */
+ return;
+ }
+ PRINT_WARN("(%s): Device Message(%x)\n",
+ device->cdev->dev.bus_id, sense->mc);
+}
+
+/*
+ * 3590 error Recovery routine:
+ * If possible, it tries to recover from the error. If this is not possible,
+ * inform the user about the problem.
+ */
+static int
+tape_3590_unit_check(struct tape_device *device, struct tape_request *request,
+ struct irb *irb)
+{
+ struct tape_3590_sense *sense;
+ int rc;
+
+#ifdef CONFIG_S390_TAPE_BLOCK
+ if (request->op == TO_BLOCK) {
+ /*
+ * Recovery for block device requests. Set the block_position
+ * to something invalid and retry.
+ */
+ device->blk_data.block_position = -1;
+ if (request->retries-- <= 0)
+ return tape_3590_erp_failed(device, request, irb, -EIO);
+ else
+ return tape_3590_erp_retry(device, request, irb);
+ }
+#endif
+
+ sense = (struct tape_3590_sense *) irb->ecw;
+
+ /*
+ * First check all RC-QRCs where we want to do something special
+ * - "break": basic error recovery is done
+ * - "goto out:": just print error message if available
+ */
+ rc = -EIO;
+ switch (sense->rc_rqc) {
+
+ case 0x1110:
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_read_buf_log(device, request, irb);
+
+ case 0x2011:
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_read_alternate(device, request, irb);
+
+ case 0x2230:
+ case 0x2231:
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_special_interrupt(device, request, irb);
+
+ case 0x3010:
+ DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n",
+ device->cdev_id);
+ return tape_3590_erp_basic(device, request, irb, -ENOSPC);
+ case 0x3012:
+ DBF_EVENT(2, "(%08x): Forward at End of Partition\n",
+ device->cdev_id);
+ return tape_3590_erp_basic(device, request, irb, -ENOSPC);
+ case 0x3020:
+ DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id);
+ return tape_3590_erp_basic(device, request, irb, -ENOSPC);
+
+ case 0x3122:
+ DBF_EVENT(2, "(%08x): Rewind Unload initiated\n",
+ device->cdev_id);
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+ case 0x3123:
+ DBF_EVENT(2, "(%08x): Rewind Unload complete\n",
+ device->cdev_id);
+ tape_med_state_set(device, MS_UNLOADED);
+ return tape_3590_erp_basic(device, request, irb, 0);
+
+ case 0x4010:
+ /*
+ * print additional msg since default msg
+ * "device intervention" is not very meaningfull
+ */
+ PRINT_WARN("(%s): Tape operation when medium not loaded\n",
+ device->cdev->dev.bus_id);
+ tape_med_state_set(device, MS_UNLOADED);
+ return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
+ case 0x4012: /* Device Long Busy */
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_long_busy(device, request, irb);
+
+ case 0x5010:
+ if (sense->rac == 0xd0) {
+ /* Swap */
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_swap(device, request, irb);
+ }
+ if (sense->rac == 0x26) {
+ /* Read Opposite */
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_read_opposite(device, request,
+ irb);
+ }
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+ case 0x5020:
+ case 0x5021:
+ case 0x5022:
+ case 0x5040:
+ case 0x5041:
+ case 0x5042:
+ tape_3590_print_era_msg(device, irb);
+ return tape_3590_erp_swap(device, request, irb);
+
+ case 0x5110:
+ case 0x5111:
+ return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
+
+ case 0x5120:
+ case 0x1120:
+ tape_med_state_set(device, MS_UNLOADED);
+ return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM);
+
+ case 0x6020:
+ PRINT_WARN("(%s): Cartridge of wrong type ?\n",
+ device->cdev->dev.bus_id);
+ return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE);
+
+ case 0x8011:
+ PRINT_WARN("(%s): Another host has reserved the tape device\n",
+ device->cdev->dev.bus_id);
+ return tape_3590_erp_basic(device, request, irb, -EPERM);
+ case 0x8013:
+ PRINT_WARN("(%s): Another host has priviliged access to the "
+ "tape device\n", device->cdev->dev.bus_id);
+ PRINT_WARN("(%s): To solve the problem unload the current "
+ "cartridge!\n", device->cdev->dev.bus_id);
+ return tape_3590_erp_basic(device, request, irb, -EPERM);
+ default:
+ return tape_3590_erp_basic(device, request, irb, -EIO);
+ }
+}
+
+/*
+ * 3590 interrupt handler:
+ */
+static int
+tape_3590_irq(struct tape_device *device, struct tape_request *request,
+ struct irb *irb)
+{
+ if (request == NULL)
+ return tape_3590_unsolicited_irq(device, irb);
+
+ if ((irb->scsw.dstat & DEV_STAT_UNIT_EXCEP) &&
+ (irb->scsw.dstat & DEV_STAT_DEV_END) && (request->op == TO_WRI)) {
+ /* Write at end of volume */
+ DBF_EVENT(2, "End of volume\n");
+ return tape_3590_erp_failed(device, request, irb, -ENOSPC);
+ }
+
+ if (irb->scsw.dstat & DEV_STAT_UNIT_CHECK)
+ return tape_3590_unit_check(device, request, irb);
+
+ if (irb->scsw.dstat & DEV_STAT_DEV_END) {
+ if (irb->scsw.dstat == DEV_STAT_UNIT_EXCEP) {
+ if (request->op == TO_FSB || request->op == TO_BSB)
+ request->rescnt++;
+ else
+ DBF_EVENT(5, "Unit Exception!\n");
+ }
+
+ return tape_3590_done(device, request);
+ }
+
+ if (irb->scsw.dstat & DEV_STAT_CHN_END) {
+ DBF_EVENT(2, "cannel end\n");
+ return TAPE_IO_PENDING;
+ }
+
+ if (irb->scsw.dstat & DEV_STAT_ATTENTION) {
+ DBF_EVENT(2, "Unit Attention when busy..\n");
+ return TAPE_IO_PENDING;
+ }
+
+ DBF_EVENT(6, "xunknownirq\n");
+ PRINT_ERR("Unexpected interrupt.\n");
+ PRINT_ERR("Current op is: %s", tape_op_verbose[request->op]);
+ tape_dump_sense(device, request, irb);
+ return TAPE_IO_STOP;
+}
+
+/*
+ * Setup device function
+ */
+static int
+tape_3590_setup_device(struct tape_device *device)
+{
+ int rc;
+ struct tape_3590_disc_data *data;
+
+ DBF_EVENT(6, "3590 device setup\n");
+ data = kmalloc(sizeof(struct tape_3590_disc_data),
+ GFP_KERNEL | GFP_DMA);
+ if (data == NULL)
+ return -ENOMEM;
+ data->read_back_op = READ_PREVIOUS;
+ device->discdata = data;
+
+ if ((rc = tape_std_assign(device)) == 0) {
+ /* Try to find out if medium is loaded */
+ if ((rc = tape_3590_sense_medium(device)) != 0)
+ DBF_LH(3, "3590 medium sense returned %d\n", rc);
+ }
+
+ return rc;
+}
+
+/*
+ * Cleanup device function
+ */
+static void
+tape_3590_cleanup_device(struct tape_device *device)
+{
+ tape_std_unassign(device);
+
+ kfree(device->discdata);
+ device->discdata = NULL;
+}
+
+/*
+ * List of 3590 magnetic tape commands.
+ */
+static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = {
+ [MTRESET] = tape_std_mtreset,
+ [MTFSF] = tape_std_mtfsf,
+ [MTBSF] = tape_std_mtbsf,
+ [MTFSR] = tape_std_mtfsr,
+ [MTBSR] = tape_std_mtbsr,
+ [MTWEOF] = tape_std_mtweof,
+ [MTREW] = tape_std_mtrew,
+ [MTOFFL] = tape_std_mtoffl,
+ [MTNOP] = tape_std_mtnop,
+ [MTRETEN] = tape_std_mtreten,
+ [MTBSFM] = tape_std_mtbsfm,
+ [MTFSFM] = tape_std_mtfsfm,
+ [MTEOM] = tape_std_mteom,
+ [MTERASE] = tape_std_mterase,
+ [MTRAS1] = NULL,
+ [MTRAS2] = NULL,
+ [MTRAS3] = NULL,
+ [MTSETBLK] = tape_std_mtsetblk,
+ [MTSETDENSITY] = NULL,
+ [MTSEEK] = tape_3590_mtseek,
+ [MTTELL] = tape_3590_mttell,
+ [MTSETDRVBUFFER] = NULL,
+ [MTFSS] = NULL,
+ [MTBSS] = NULL,
+ [MTWSM] = NULL,
+ [MTLOCK] = NULL,
+ [MTUNLOCK] = NULL,
+ [MTLOAD] = tape_std_mtload,
+ [MTUNLOAD] = tape_std_mtunload,
+ [MTCOMPRESSION] = tape_std_mtcompression,
+ [MTSETPART] = NULL,
+ [MTMKPART] = NULL
+};
+
+/*
+ * Tape discipline structure for 3590.
+ */
+static struct tape_discipline tape_discipline_3590 = {
+ .owner = THIS_MODULE,
+ .setup_device = tape_3590_setup_device,
+ .cleanup_device = tape_3590_cleanup_device,
+ .process_eov = tape_std_process_eov,
+ .irq = tape_3590_irq,
+ .read_block = tape_std_read_block,
+ .write_block = tape_std_write_block,
+#ifdef CONFIG_S390_TAPE_BLOCK
+ .bread = tape_3590_bread,
+ .free_bread = tape_3590_free_bread,
+ .check_locate = tape_3590_check_locate,
+#endif
+ .ioctl_fn = tape_3590_ioctl,
+ .mtop_array = tape_3590_mtop
+};
+
+static struct ccw_device_id tape_3590_ids[] = {
+ {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590},
+ { /* end of list */ }
+};
+
+static int
+tape_3590_online(struct ccw_device *cdev)
+{
+ return tape_generic_online(cdev->dev.driver_data,
+ &tape_discipline_3590);
+}
+
+static int
+tape_3590_offline(struct ccw_device *cdev)
+{
+ return tape_generic_offline(cdev->dev.driver_data);
+}
+
+static struct ccw_driver tape_3590_driver = {
+ .name = "tape_3590",
+ .owner = THIS_MODULE,
+ .ids = tape_3590_ids,
+ .probe = tape_generic_probe,
+ .remove = tape_generic_remove,
+ .set_offline = tape_3590_offline,
+ .set_online = tape_3590_online,
+};
+
+/*
+ * Setup discipline structure.
+ */
+static int
+tape_3590_init(void)
+{
+ int rc;
+
+ TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long));
+ debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view);
+#ifdef DBF_LIKE_HELL
+ debug_set_level(TAPE_DBF_AREA, 6);
+#endif
+
+ DBF_EVENT(3, "3590 init\n");
+ /* Register driver for 3590 tapes. */
+ rc = ccw_driver_register(&tape_3590_driver);
+ if (rc)
+ DBF_EVENT(3, "3590 init failed\n");
+ else
+ DBF_EVENT(3, "3590 registered\n");
+ return rc;
+}
+
+static void
+tape_3590_exit(void)
+{
+ ccw_driver_unregister(&tape_3590_driver);
+
+ debug_unregister(TAPE_DBF_AREA);
+}
+
+MODULE_DEVICE_TABLE(ccw, tape_3590_ids);
+MODULE_AUTHOR("(C) 2001,2006 IBM Corporation");
+MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver");
+MODULE_LICENSE("GPL");
+
+module_init(tape_3590_init);
+module_exit(tape_3590_exit);
diff --git a/drivers/s390/char/tape_3590.h b/drivers/s390/char/tape_3590.h
new file mode 100644
index 00000000000..cf274b9445a
--- /dev/null
+++ b/drivers/s390/char/tape_3590.h
@@ -0,0 +1,124 @@
+/*
+ * drivers/s390/char/tape_3590.h
+ * tape device discipline for 3590 tapes.
+ *
+ * Copyright (C) IBM Corp. 2001,2006
+ * Author(s): Stefan Bader <shbader@de.ibm.com>
+ * Michael Holzheu <holzheu@de.ibm.com>
+ * Martin Schwidefsky <schwidefsky@de.ibm.com>
+ */
+
+#ifndef _TAPE_3590_H
+#define _TAPE_3590_H
+
+#define MEDIUM_SENSE 0xc2
+#define READ_PREVIOUS 0x0a
+#define MODE_SENSE 0xcf
+#define PERFORM_SS_FUNC 0x77
+#define READ_SS_DATA 0x3e
+
+#define PREP_RD_SS_DATA 0x18
+#define RD_ATTMSG 0x3
+
+#define SENSE_BRA_PER 0
+#define SENSE_BRA_CONT 1
+#define SENSE_BRA_RE 2
+#define SENSE_BRA_DRE 3
+
+#define SENSE_FMT_LIBRARY 0x23
+#define SENSE_FMT_UNSOLICITED 0x40
+#define SENSE_FMT_COMMAND_REJ 0x41
+#define SENSE_FMT_COMMAND_EXEC0 0x50
+#define SENSE_FMT_COMMAND_EXEC1 0x51
+#define SENSE_FMT_EVENT0 0x60
+#define SENSE_FMT_EVENT1 0x61
+#define SENSE_FMT_MIM 0x70
+#define SENSE_FMT_SIM 0x71
+
+#define MSENSE_UNASSOCIATED 0x00
+#define MSENSE_ASSOCIATED_MOUNT 0x01
+#define MSENSE_ASSOCIATED_UMOUNT 0x02
+
+#define TAPE_3590_MAX_MSG 0xb0
+
+/* Datatypes */
+
+struct tape_3590_disc_data {
+ unsigned char modeset_byte;
+ int read_back_op;
+};
+
+struct tape_3590_sense {
+
+ unsigned int command_rej:1;
+ unsigned int interv_req:1;
+ unsigned int bus_out_check:1;
+ unsigned int eq_check:1;
+ unsigned int data_check:1;
+ unsigned int overrun:1;
+ unsigned int def_unit_check:1;
+ unsigned int assgnd_elsew:1;
+
+ unsigned int locate_fail:1;
+ unsigned int inst_online:1;
+ unsigned int reserved:1;
+ unsigned int blk_seq_err:1;
+ unsigned int begin_part:1;
+ unsigned int wr_mode:1;
+ unsigned int wr_prot:1;
+ unsigned int not_cap:1;
+
+ unsigned int bra:2;
+ unsigned int lc:3;
+ unsigned int vlf_active:1;
+ unsigned int stm:1;
+ unsigned int med_pos:1;
+
+ unsigned int rac:8;
+
+ unsigned int rc_rqc:16;
+
+ unsigned int mc:8;
+
+ unsigned int sense_fmt:8;
+
+ union {
+ struct {
+ unsigned int emc:4;
+ unsigned int smc:4;
+ unsigned int sev:2;
+ unsigned int reserved:6;
+ unsigned int md:8;
+ unsigned int refcode:8;
+ unsigned int mid:16;
+ unsigned int mp:16;
+ unsigned char volid[6];
+ unsigned int fid:8;
+ } f70;
+ struct {
+ unsigned int emc:4;
+ unsigned int smc:4;
+ unsigned int sev:2;
+ unsigned int reserved1:5;
+ unsigned int mdf:1;
+ unsigned char md[3];
+ unsigned int simid:8;
+ unsigned int uid:16;
+ unsigned int refcode1:16;
+ unsigned int refcode2:16;
+ unsigned int refcode3:16;
+ unsigned int reserved2:8;
+ } f71;
+ unsigned char data[14];
+ } fmt;
+ unsigned char pad[10];
+
+} __attribute__ ((packed));
+
+struct tape_3590_med_sense {
+ unsigned int macst:4;
+ unsigned int masst:4;
+ char pad[127];
+} __attribute__ ((packed));
+
+#endif /* _TAPE_3590_H */
diff --git a/drivers/s390/char/tape_class.c b/drivers/s390/char/tape_class.c
index b3569c82bb1..a5c68e60fcf 100644
--- a/drivers/s390/char/tape_class.c
+++ b/drivers/s390/char/tape_class.c
@@ -44,11 +44,10 @@ struct tape_class_device *register_tape_dev(
int rc;
char * s;
- tcd = kmalloc(sizeof(struct tape_class_device), GFP_KERNEL);
+ tcd = kzalloc(sizeof(struct tape_class_device), GFP_KERNEL);
if (!tcd)
return ERR_PTR(-ENOMEM);
- memset(tcd, 0, sizeof(struct tape_class_device));
strncpy(tcd->device_name, device_name, TAPECLASS_NAME_LEN);
for (s = strchr(tcd->device_name, '/'); s; s = strchr(s, '/'))
*s = '!';
diff --git a/drivers/s390/char/tape_core.c b/drivers/s390/char/tape_core.c
index 4ea438c749c..389ee2c0f44 100644
--- a/drivers/s390/char/tape_core.c
+++ b/drivers/s390/char/tape_core.c
@@ -453,16 +453,14 @@ tape_alloc_device(void)
{
struct tape_device *device;
- device = (struct tape_device *)
- kmalloc(sizeof(struct tape_device), GFP_KERNEL);
+ device = kzalloc(sizeof(struct tape_device), GFP_KERNEL);
if (device == NULL) {
DBF_EXCEPTION(2, "ti:no mem\n");
PRINT_INFO ("can't allocate memory for "
"tape info structure\n");
return ERR_PTR(-ENOMEM);
}
- memset(device, 0, sizeof(struct tape_device));
- device->modeset_byte = (char *) kmalloc(1, GFP_KERNEL | GFP_DMA);
+ device->modeset_byte = kmalloc(1, GFP_KERNEL | GFP_DMA);
if (device->modeset_byte == NULL) {
DBF_EXCEPTION(2, "ti:no mem\n");
PRINT_INFO("can't allocate memory for modeset byte\n");
@@ -659,34 +657,30 @@ tape_alloc_request(int cplength, int datasize)
DBF_LH(6, "tape_alloc_request(%d, %d)\n", cplength, datasize);
- request = (struct tape_request *) kmalloc(sizeof(struct tape_request),
- GFP_KERNEL);
+ request = kzalloc(sizeof(struct tape_request), GFP_KERNEL);
if (request == NULL) {
DBF_EXCEPTION(1, "cqra nomem\n");
return ERR_PTR(-ENOMEM);
}
- memset(request, 0, sizeof(struct tape_request));
/* allocate channel program */
if (cplength > 0) {
- request->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
+ request->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
GFP_ATOMIC | GFP_DMA);
if (request->cpaddr == NULL) {
DBF_EXCEPTION(1, "cqra nomem\n");
kfree(request);
return ERR_PTR(-ENOMEM);
}
- memset(request->cpaddr, 0, cplength*sizeof(struct ccw1));
}
/* alloc small kernel buffer */
if (datasize > 0) {
- request->cpdata = kmalloc(datasize, GFP_KERNEL | GFP_DMA);
+ request->cpdata = kzalloc(datasize, GFP_KERNEL | GFP_DMA);
if (request->cpdata == NULL) {
DBF_EXCEPTION(1, "cqra nomem\n");
kfree(request->cpaddr);
kfree(request);
return ERR_PTR(-ENOMEM);
}
- memset(request->cpdata, 0, datasize);
}
DBF_LH(6, "New request %p(%p/%p)\n", request, request->cpaddr,
request->cpdata);
@@ -761,6 +755,13 @@ __tape_start_next_request(struct tape_device *device)
*/
if (request->status == TAPE_REQUEST_IN_IO)
return;
+ /*
+ * Request has already been stopped. We have to wait until
+ * the request is removed from the queue in the interrupt
+ * handling.
+ */
+ if (request->status == TAPE_REQUEST_DONE)
+ return;
/*
* We wanted to cancel the request but the common I/O layer
@@ -1015,7 +1016,7 @@ tape_do_io_interruptible(struct tape_device *device,
wq,
(request->callback == NULL)
);
- } while (rc != -ERESTARTSYS);
+ } while (rc == -ERESTARTSYS);
DBF_EVENT(3, "IO stopped on %08x\n", device->cdev_id);
rc = -ERESTARTSYS;
@@ -1024,6 +1025,20 @@ tape_do_io_interruptible(struct tape_device *device,
}
/*
+ * Stop running ccw.
+ */
+int
+tape_cancel_io(struct tape_device *device, struct tape_request *request)
+{
+ int rc;
+
+ spin_lock_irq(get_ccwdev_lock(device->cdev));
+ rc = __tape_cancel_io(device, request);
+ spin_unlock_irq(get_ccwdev_lock(device->cdev));
+ return rc;
+}
+
+/*
* Tape interrupt routine, called from the ccw_device layer
*/
static void
@@ -1064,15 +1079,16 @@ __tape_do_irq (struct ccw_device *cdev, unsigned long intparm, struct irb *irb)
/*
* If the condition code is not zero and the start function bit is
* still set, this is an deferred error and the last start I/O did
- * not succeed. Restart the request now.
+ * not succeed. At this point the condition that caused the deferred
+ * error might still apply. So we just schedule the request to be
+ * started later.
*/
- if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC)) {
- PRINT_WARN("(%s): deferred cc=%i. restaring\n",
- cdev->dev.bus_id,
- irb->scsw.cc);
- rc = __tape_start_io(device, request);
- if (rc)
- __tape_end_request(device, request, rc);
+ if (irb->scsw.cc != 0 && (irb->scsw.fctl & SCSW_FCTL_START_FUNC) &&
+ (request->status == TAPE_REQUEST_IN_IO)) {
+ DBF_EVENT(3,"(%08x): deferred cc=%i, fctl=%i. restarting\n",
+ device->cdev_id, irb->scsw.cc, irb->scsw.fctl);
+ request->status = TAPE_REQUEST_QUEUED;
+ schedule_delayed_work(&device->tape_dnr, HZ);
return;
}
@@ -1286,4 +1302,5 @@ EXPORT_SYMBOL(tape_dump_sense_dbf);
EXPORT_SYMBOL(tape_do_io);
EXPORT_SYMBOL(tape_do_io_async);
EXPORT_SYMBOL(tape_do_io_interruptible);
+EXPORT_SYMBOL(tape_cancel_io);
EXPORT_SYMBOL(tape_mtop);
diff --git a/drivers/s390/char/tape_std.c b/drivers/s390/char/tape_std.c
index 2f9fe30989a..99cf881f41d 100644
--- a/drivers/s390/char/tape_std.c
+++ b/drivers/s390/char/tape_std.c
@@ -37,20 +37,19 @@ tape_std_assign_timeout(unsigned long data)
{
struct tape_request * request;
struct tape_device * device;
+ int rc;
request = (struct tape_request *) data;
if ((device = request->device) == NULL)
BUG();
- spin_lock_irq(get_ccwdev_lock(device->cdev));
- if (request->callback != NULL) {
- DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
+ DBF_EVENT(3, "%08x: Assignment timeout. Device busy.\n",
device->cdev_id);
- PRINT_ERR("%s: Assignment timeout. Device busy.\n",
- device->cdev->dev.bus_id);
- ccw_device_clear(device->cdev, (long) request);
- }
- spin_unlock_irq(get_ccwdev_lock(device->cdev));
+ rc = tape_cancel_io(device, request);
+ if(rc)
+ PRINT_ERR("(%s): Assign timeout: Cancel failed with rc = %i\n",
+ device->cdev->dev.bus_id, rc);
+
}
int
diff --git a/drivers/s390/char/tape_std.h b/drivers/s390/char/tape_std.h
index 3ab6aafb734..2d311798edf 100644
--- a/drivers/s390/char/tape_std.h
+++ b/drivers/s390/char/tape_std.h
@@ -1,9 +1,8 @@
/*
- * drivers/s390/char/tape_34xx.h
+ * drivers/s390/char/tape_std.h
* standard tape device functions for ibm tapes.
*
- * S390 and zSeries version
- * Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Copyright (C) IBM Corp. 2001,2006
* Author(s): Carsten Otte <cotte@de.ibm.com>
* Tuan Ngo-Anh <ngoanh@de.ibm.com>
* Martin Schwidefsky <schwidefsky@de.ibm.com>
@@ -149,4 +148,11 @@ void tape_std_error_recovery_do_retry(struct tape_device *);
void tape_std_error_recovery_read_opposite(struct tape_device *);
void tape_std_error_recovery_HWBUG(struct tape_device *, int condno);
+/* S390 tape types */
+enum s390_tape_type {
+ tape_3480,
+ tape_3490,
+ tape_3590,
+};
+
#endif // _TAPE_STD_H
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c
index 4b906937038..9a141776873 100644
--- a/drivers/s390/char/tty3270.c
+++ b/drivers/s390/char/tty3270.c
@@ -691,10 +691,9 @@ tty3270_alloc_view(void)
struct tty3270 *tp;
int pages;
- tp = kmalloc(sizeof(struct tty3270),GFP_KERNEL);
+ tp = kzalloc(sizeof(struct tty3270), GFP_KERNEL);
if (!tp)
goto out_err;
- memset(tp, 0, sizeof(struct tty3270));
tp->freemem_pages =
kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
if (!tp->freemem_pages)
@@ -767,16 +766,14 @@ tty3270_alloc_screen(struct tty3270 *tp)
int lines;
size = sizeof(struct tty3270_line) * (tp->view.rows - 2);
- tp->screen = kmalloc(size, GFP_KERNEL);
+ tp->screen = kzalloc(size, GFP_KERNEL);
if (!tp->screen)
goto out_err;
- memset(tp->screen, 0, size);
for (lines = 0; lines < tp->view.rows - 2; lines++) {
size = sizeof(struct tty3270_cell) * tp->view.cols;
- tp->screen[lines].cells = kmalloc(size, GFP_KERNEL);
+ tp->screen[lines].cells = kzalloc(size, GFP_KERNEL);
if (!tp->screen[lines].cells)
goto out_screen;
- memset(tp->screen[lines].cells, 0, size);
}
return 0;
out_screen:
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c
index b2d75de144c..c625b69ebd1 100644
--- a/drivers/s390/char/vmlogrdr.c
+++ b/drivers/s390/char/vmlogrdr.c
@@ -759,9 +759,8 @@ vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
struct device *dev;
int ret;
- dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (dev) {
- memset(dev, 0, sizeof(struct device));
snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
priv->internal_name);
dev->bus = &iucv_bus;
diff --git a/drivers/s390/cio/ccwgroup.c b/drivers/s390/cio/ccwgroup.c
index 8013c8eb76f..bdfee7fbaa2 100644
--- a/drivers/s390/cio/ccwgroup.c
+++ b/drivers/s390/cio/ccwgroup.c
@@ -157,11 +157,10 @@ ccwgroup_create(struct device *root,
if (argc > 256) /* disallow dumb users */
return -EINVAL;
- gdev = kmalloc(sizeof(*gdev) + argc*sizeof(gdev->cdev[0]), GFP_KERNEL);
+ gdev = kzalloc(sizeof(*gdev) + argc*sizeof(gdev->cdev[0]), GFP_KERNEL);
if (!gdev)
return -ENOMEM;
- memset(gdev, 0, sizeof(*gdev) + argc*sizeof(gdev->cdev[0]));
atomic_set(&gdev->onoff, 0);
del_drvdata = 0;
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index f4183d66025..6412b2c3edd 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -98,10 +98,8 @@ chsc_get_sch_desc_irq(struct subchannel *sch, void *page)
ssd_area = page;
- ssd_area->request = (struct chsc_header) {
- .length = 0x0010,
- .code = 0x0004,
- };
+ ssd_area->request.length = 0x0010;
+ ssd_area->request.code = 0x0004;
ssd_area->ssid = sch->schid.ssid;
ssd_area->f_sch = sch->schid.sch_no;
@@ -517,10 +515,8 @@ chsc_process_crw(void)
struct device *dev;
memset(sei_area, 0, sizeof(*sei_area));
memset(&res_data, 0, sizeof(struct res_acc_data));
- sei_area->request = (struct chsc_header) {
- .length = 0x0010,
- .code = 0x000e,
- };
+ sei_area->request.length = 0x0010;
+ sei_area->request.code = 0x000e;
ccode = chsc(sei_area);
if (ccode > 0)
@@ -875,6 +871,264 @@ s390_vary_chpid( __u8 chpid, int on)
}
/*
+ * Channel measurement related functions
+ */
+static ssize_t
+chp_measurement_chars_read(struct kobject *kobj, char *buf, loff_t off,
+ size_t count)
+{
+ struct channel_path *chp;
+ unsigned int size;
+
+ chp = to_channelpath(container_of(kobj, struct device, kobj));
+ if (!chp->cmg_chars)
+ return 0;
+
+ size = sizeof(struct cmg_chars);
+
+ if (off > size)
+ return 0;
+ if (off + count > size)
+ count = size - off;
+ memcpy(buf, chp->cmg_chars + off, count);
+ return count;
+}
+
+static struct bin_attribute chp_measurement_chars_attr = {
+ .attr = {
+ .name = "measurement_chars",
+ .mode = S_IRUSR,
+ .owner = THIS_MODULE,
+ },
+ .size = sizeof(struct cmg_chars),
+ .read = chp_measurement_chars_read,
+};
+
+static void
+chp_measurement_copy_block(struct cmg_entry *buf,
+ struct channel_subsystem *css, int chpid)
+{
+ void *area;
+ struct cmg_entry *entry, reference_buf;
+ int idx;
+
+ if (chpid < 128) {
+ area = css->cub_addr1;
+ idx = chpid;
+ } else {
+ area = css->cub_addr2;
+ idx = chpid - 128;
+ }
+ entry = area + (idx * sizeof(struct cmg_entry));
+ do {
+ memcpy(buf, entry, sizeof(*entry));
+ memcpy(&reference_buf, entry, sizeof(*entry));
+ } while (reference_buf.values[0] != buf->values[0]);
+}
+
+static ssize_t
+chp_measurement_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
+{
+ struct channel_path *chp;
+ struct channel_subsystem *css;
+ unsigned int size;
+
+ chp = to_channelpath(container_of(kobj, struct device, kobj));
+ css = to_css(chp->dev.parent);
+
+ size = sizeof(struct cmg_chars);
+
+ /* Only allow single reads. */
+ if (off || count < size)
+ return 0;
+ chp_measurement_copy_block((struct cmg_entry *)buf, css, chp->id);
+ return count;
+}
+
+static struct bin_attribute chp_measurement_attr = {
+ .attr = {
+ .name = "measurement",
+ .mode = S_IRUSR,
+ .owner = THIS_MODULE,
+ },
+ .size = sizeof(struct cmg_entry),
+ .read = chp_measurement_read,
+};
+
+static void
+chsc_remove_chp_cmg_attr(struct channel_path *chp)
+{
+ sysfs_remove_bin_file(&chp->dev.kobj, &chp_measurement_chars_attr);
+ sysfs_remove_bin_file(&chp->dev.kobj, &chp_measurement_attr);
+}
+
+static int
+chsc_add_chp_cmg_attr(struct channel_path *chp)
+{
+ int ret;
+
+ ret = sysfs_create_bin_file(&chp->dev.kobj,
+ &chp_measurement_chars_attr);
+ if (ret)
+ return ret;
+ ret = sysfs_create_bin_file(&chp->dev.kobj, &chp_measurement_attr);
+ if (ret)
+ sysfs_remove_bin_file(&chp->dev.kobj,
+ &chp_measurement_chars_attr);
+ return ret;
+}
+
+static void
+chsc_remove_cmg_attr(struct channel_subsystem *css)
+{
+ int i;
+
+ for (i = 0; i <= __MAX_CHPID; i++) {
+ if (!css->chps[i])
+ continue;
+ chsc_remove_chp_cmg_attr(css->chps[i]);
+ }
+}
+
+static int
+chsc_add_cmg_attr(struct channel_subsystem *css)
+{
+ int i, ret;
+
+ ret = 0;
+ for (i = 0; i <= __MAX_CHPID; i++) {
+ if (!css->chps[i])
+ continue;
+ ret = chsc_add_chp_cmg_attr(css->chps[i]);
+ if (ret)
+ goto cleanup;
+ }
+ return ret;
+cleanup:
+ for (--i; i >= 0; i--) {
+ if (!css->chps[i])
+ continue;
+ chsc_remove_chp_cmg_attr(css->chps[i]);
+ }
+ return ret;
+}
+
+
+static int
+__chsc_do_secm(struct channel_subsystem *css, int enable, void *page)
+{
+ struct {
+ struct chsc_header request;
+ u32 operation_code : 2;
+ u32 : 30;
+ u32 key : 4;
+ u32 : 28;
+ u32 zeroes1;
+ u32 cub_addr1;
+ u32 zeroes2;
+ u32 cub_addr2;
+ u32 reserved[13];
+ struct chsc_header response;
+ u32 status : 8;
+ u32 : 4;
+ u32 fmt : 4;
+ u32 : 16;
+ } *secm_area;
+ int ret, ccode;
+
+ secm_area = page;
+ secm_area->request.length = 0x0050;
+ secm_area->request.code = 0x0016;
+
+ secm_area->key = PAGE_DEFAULT_KEY;
+ secm_area->cub_addr1 = (u64)(unsigned long)css->cub_addr1;
+ secm_area->cub_addr2 = (u64)(unsigned long)css->cub_addr2;
+
+ secm_area->operation_code = enable ? 0 : 1;
+
+ ccode = chsc(secm_area);
+ if (ccode > 0)
+ return (ccode == 3) ? -ENODEV : -EBUSY;
+
+ switch (secm_area->response.code) {
+ case 0x0001: /* Success. */
+ ret = 0;
+ break;
+ case 0x0003: /* Invalid block. */
+ case 0x0007: /* Invalid format. */
+ case 0x0008: /* Other invalid block. */
+ CIO_CRW_EVENT(2, "Error in chsc request block!\n");
+ ret = -EINVAL;
+ break;
+ case 0x0004: /* Command not provided in model. */
+ CIO_CRW_EVENT(2, "Model does not provide secm\n");
+ ret = -EOPNOTSUPP;
+ break;
+ case 0x0102: /* cub adresses incorrect */
+ CIO_CRW_EVENT(2, "Invalid addresses in chsc request block\n");
+ ret = -EINVAL;
+ break;
+ case 0x0103: /* key error */
+ CIO_CRW_EVENT(2, "Access key error in secm\n");
+ ret = -EINVAL;
+ break;
+ case 0x0105: /* error while starting */
+ CIO_CRW_EVENT(2, "Error while starting channel measurement\n");
+ ret = -EIO;
+ break;
+ default:
+ CIO_CRW_EVENT(2, "Unknown CHSC response %d\n",
+ secm_area->response.code);
+ ret = -EIO;
+ }
+ return ret;
+}
+
+int
+chsc_secm(struct channel_subsystem *css, int enable)
+{
+ void *secm_area;
+ int ret;
+
+ secm_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ if (!secm_area)
+ return -ENOMEM;
+
+ mutex_lock(&css->mutex);
+ if (enable && !css->cm_enabled) {
+ css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ if (!css->cub_addr1 || !css->cub_addr2) {
+ free_page((unsigned long)css->cub_addr1);
+ free_page((unsigned long)css->cub_addr2);
+ free_page((unsigned long)secm_area);
+ mutex_unlock(&css->mutex);
+ return -ENOMEM;
+ }
+ }
+ ret = __chsc_do_secm(css, enable, secm_area);
+ if (!ret) {
+ css->cm_enabled = enable;
+ if (css->cm_enabled) {
+ ret = chsc_add_cmg_attr(css);
+ if (ret) {
+ memset(secm_area, 0, PAGE_SIZE);
+ __chsc_do_secm(css, 0, secm_area);
+ css->cm_enabled = 0;
+ }
+ } else
+ chsc_remove_cmg_attr(css);
+ }
+ if (enable && !css->cm_enabled) {
+ free_page((unsigned long)css->cub_addr1);
+ free_page((unsigned long)css->cub_addr2);
+ }
+ mutex_unlock(&css->mutex);
+ free_page((unsigned long)secm_area);
+ return ret;
+}
+
+/*
* Files for the channel path entries.
*/
static ssize_t
@@ -925,9 +1179,39 @@ chp_type_show(struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR(type, 0444, chp_type_show, NULL);
+static ssize_t
+chp_cmg_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct channel_path *chp = to_channelpath(dev);
+
+ if (!chp)
+ return 0;
+ if (chp->cmg == -1) /* channel measurements not available */
+ return sprintf(buf, "unknown\n");
+ return sprintf(buf, "%x\n", chp->cmg);
+}
+
+static DEVICE_ATTR(cmg, 0444, chp_cmg_show, NULL);
+
+static ssize_t
+chp_shared_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct channel_path *chp = to_channelpath(dev);
+
+ if (!chp)
+ return 0;
+ if (chp->shared == -1) /* channel measurements not available */
+ return sprintf(buf, "unknown\n");
+ return sprintf(buf, "%x\n", chp->shared);
+}
+
+static DEVICE_ATTR(shared, 0444, chp_shared_show, NULL);
+
static struct attribute * chp_attrs[] = {
&dev_attr_status.attr,
&dev_attr_type.attr,
+ &dev_attr_cmg.attr,
+ &dev_attr_shared.attr,
NULL,
};
@@ -966,10 +1250,8 @@ chsc_determine_channel_path_description(int chpid,
if (!scpd_area)
return -ENOMEM;
- scpd_area->request = (struct chsc_header) {
- .length = 0x0010,
- .code = 0x0002,
- };
+ scpd_area->request.length = 0x0010;
+ scpd_area->request.code = 0x0002;
scpd_area->first_chpid = chpid;
scpd_area->last_chpid = chpid;
@@ -1006,6 +1288,111 @@ out:
return ret;
}
+static void
+chsc_initialize_cmg_chars(struct channel_path *chp, u8 cmcv,
+ struct cmg_chars *chars)
+{
+ switch (chp->cmg) {
+ case 2:
+ case 3:
+ chp->cmg_chars = kmalloc(sizeof(struct cmg_chars),
+ GFP_KERNEL);
+ if (chp->cmg_chars) {
+ int i, mask;
+ struct cmg_chars *cmg_chars;
+
+ cmg_chars = chp->cmg_chars;
+ for (i = 0; i < NR_MEASUREMENT_CHARS; i++) {
+ mask = 0x80 >> (i + 3);
+ if (cmcv & mask)
+ cmg_chars->values[i] = chars->values[i];
+ else
+ cmg_chars->values[i] = 0;
+ }
+ }
+ break;
+ default:
+ /* No cmg-dependent data. */
+ break;
+ }
+}
+
+static int
+chsc_get_channel_measurement_chars(struct channel_path *chp)
+{
+ int ccode, ret;
+
+ struct {
+ struct chsc_header request;
+ u32 : 24;
+ u32 first_chpid : 8;
+ u32 : 24;
+ u32 last_chpid : 8;
+ u32 zeroes1;
+ struct chsc_header response;
+ u32 zeroes2;
+ u32 not_valid : 1;
+ u32 shared : 1;
+ u32 : 22;
+ u32 chpid : 8;
+ u32 cmcv : 5;
+ u32 : 11;
+ u32 cmgq : 8;
+ u32 cmg : 8;
+ u32 zeroes3;
+ u32 data[NR_MEASUREMENT_CHARS];
+ } *scmc_area;
+
+ scmc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
+ if (!scmc_area)
+ return -ENOMEM;
+
+ scmc_area->request.length = 0x0010;
+ scmc_area->request.code = 0x0022;
+
+ scmc_area->first_chpid = chp->id;
+ scmc_area->last_chpid = chp->id;
+
+ ccode = chsc(scmc_area);
+ if (ccode > 0) {
+ ret = (ccode == 3) ? -ENODEV : -EBUSY;
+ goto out;
+ }
+
+ switch (scmc_area->response.code) {
+ case 0x0001: /* Success. */
+ if (!scmc_area->not_valid) {
+ chp->cmg = scmc_area->cmg;
+ chp->shared = scmc_area->shared;
+ chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
+ (struct cmg_chars *)
+ &scmc_area->data);
+ } else {
+ chp->cmg = -1;
+ chp->shared = -1;
+ }
+ ret = 0;
+ break;
+ case 0x0003: /* Invalid block. */
+ case 0x0007: /* Invalid format. */
+ case 0x0008: /* Invalid bit combination. */
+ CIO_CRW_EVENT(2, "Error in chsc request block!\n");
+ ret = -EINVAL;
+ break;
+ case 0x0004: /* Command not provided. */
+ CIO_CRW_EVENT(2, "Model does not provide scmc\n");
+ ret = -EOPNOTSUPP;
+ break;
+ default:
+ CIO_CRW_EVENT(2, "Unknown CHSC response %d\n",
+ scmc_area->response.code);
+ ret = -EIO;
+ }
+out:
+ free_page((unsigned long)scmc_area);
+ return ret;
+}
+
/*
* Entries for chpids on the system bus.
* This replaces /proc/chpids.
@@ -1016,10 +1403,9 @@ new_channel_path(int chpid)
struct channel_path *chp;
int ret;
- chp = kmalloc(sizeof(struct channel_path), GFP_KERNEL);
+ chp = kzalloc(sizeof(struct channel_path), GFP_KERNEL);
if (!chp)
return -ENOMEM;
- memset(chp, 0, sizeof(struct channel_path));
/* fill in status, etc. */
chp->id = chpid;
@@ -1034,6 +1420,22 @@ new_channel_path(int chpid)
ret = chsc_determine_channel_path_description(chpid, &chp->desc);
if (ret)
goto out_free;
+ /* Get channel-measurement characteristics. */
+ if (css_characteristics_avail && css_chsc_characteristics.scmc
+ && css_chsc_characteristics.secm) {
+ ret = chsc_get_channel_measurement_chars(chp);
+ if (ret)
+ goto out_free;
+ } else {
+ static int msg_done;
+
+ if (!msg_done) {
+ printk(KERN_WARNING "cio: Channel measurements not "
+ "available, continuing.\n");
+ msg_done = 1;
+ }
+ chp->cmg = -1;
+ }
/* make it known to the system */
ret = device_register(&chp->dev);
@@ -1046,8 +1448,19 @@ new_channel_path(int chpid)
if (ret) {
device_unregister(&chp->dev);
goto out_free;
- } else
- css[0]->chps[chpid] = chp;
+ }
+ mutex_lock(&css[0]->mutex);
+ if (css[0]->cm_enabled) {
+ ret = chsc_add_chp_cmg_attr(chp);
+ if (ret) {
+ sysfs_remove_group(&chp->dev.kobj, &chp_attr_group);
+ device_unregister(&chp->dev);
+ mutex_unlock(&css[0]->mutex);
+ goto out_free;
+ }
+ }
+ css[0]->chps[chpid] = chp;
+ mutex_unlock(&css[0]->mutex);
return ret;
out_free:
kfree(chp);
@@ -1103,10 +1516,8 @@ chsc_enable_facility(int operation_code)
sda_area = (void *)get_zeroed_page(GFP_KERNEL|GFP_DMA);
if (!sda_area)
return -ENOMEM;
- sda_area->request = (struct chsc_header) {
- .length = 0x0400,
- .code = 0x0031,
- };
+ sda_area->request.length = 0x0400;
+ sda_area->request.code = 0x0031;
sda_area->operation_code = operation_code;
ret = chsc(sda_area);
@@ -1161,10 +1572,8 @@ chsc_determine_css_characteristics(void)
return -ENOMEM;
}
- scsc_area->request = (struct chsc_header) {
- .length = 0x0010,
- .code = 0x0010,
- };
+ scsc_area->request.length = 0x0010;
+ scsc_area->request.code = 0x0010;
result = chsc(scsc_area);
if (result) {
diff --git a/drivers/s390/cio/chsc.h b/drivers/s390/cio/chsc.h
index 3e75095f35d..a259245780a 100644
--- a/drivers/s390/cio/chsc.h
+++ b/drivers/s390/cio/chsc.h
@@ -12,6 +12,16 @@ struct chsc_header {
u16 code;
};
+#define NR_MEASUREMENT_CHARS 5
+struct cmg_chars {
+ u32 values[NR_MEASUREMENT_CHARS];
+};
+
+#define NR_MEASUREMENT_ENTRIES 8
+struct cmg_entry {
+ u32 values[NR_MEASUREMENT_ENTRIES];
+};
+
struct channel_path_desc {
u8 flags;
u8 lsn;
@@ -27,6 +37,10 @@ struct channel_path {
int id;
int state;
struct channel_path_desc desc;
+ /* Channel-measurement related stuff: */
+ int cmg;
+ int shared;
+ void *cmg_chars;
struct device dev;
};
@@ -52,7 +66,11 @@ struct css_general_char {
struct css_chsc_char {
u64 res;
- u64 : 43;
+ u64 : 20;
+ u32 secm : 1; /* bit 84 */
+ u32 : 1;
+ u32 scmc : 1; /* bit 86 */
+ u32 : 20;
u32 scssc : 1; /* bit 107 */
u32 scsscf : 1; /* bit 108 */
u32 : 19;
@@ -67,6 +85,8 @@ extern int css_characteristics_avail;
extern void *chsc_get_chp_desc(struct subchannel*, int);
extern int chsc_enable_facility(int);
+struct channel_subsystem;
+extern int chsc_secm(struct channel_subsystem *, int);
#define to_channelpath(device) container_of(device, struct channel_path, dev)
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 3c77d65960d..74ea8aac4b7 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -452,15 +452,50 @@ channel_subsystem_release(struct device *dev)
struct channel_subsystem *css;
css = to_css(dev);
+ mutex_destroy(&css->mutex);
kfree(css);
}
+static ssize_t
+css_cm_enable_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct channel_subsystem *css = to_css(dev);
+
+ if (!css)
+ return 0;
+ return sprintf(buf, "%x\n", css->cm_enabled);
+}
+
+static ssize_t
+css_cm_enable_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct channel_subsystem *css = to_css(dev);
+ int ret;
+
+ switch (buf[0]) {
+ case '0':
+ ret = css->cm_enabled ? chsc_secm(css, 0) : 0;
+ break;
+ case '1':
+ ret = css->cm_enabled ? 0 : chsc_secm(css, 1);
+ break;
+ default:
+ ret = -EINVAL;
+ }
+ return ret < 0 ? ret : count;
+}
+
+static DEVICE_ATTR(cm_enable, 0644, css_cm_enable_show, css_cm_enable_store);
+
static inline void __init
setup_css(int nr)
{
u32 tod_high;
memset(css[nr], 0, sizeof(struct channel_subsystem));
+ mutex_init(&css[nr]->mutex);
css[nr]->valid = 1;
css[nr]->cssid = nr;
sprintf(css[nr]->device.bus_id, "css%x", nr);
@@ -507,6 +542,9 @@ init_channel_subsystem (void)
ret = device_register(&css[i]->device);
if (ret)
goto out_free;
+ if (css_characteristics_avail && css_chsc_characteristics.secm)
+ device_create_file(&css[i]->device,
+ &dev_attr_cm_enable);
}
css_init_done = 1;
@@ -519,6 +557,9 @@ out_free:
out_unregister:
while (i > 0) {
i--;
+ if (css_characteristics_avail && css_chsc_characteristics.secm)
+ device_remove_file(&css[i]->device,
+ &dev_attr_cm_enable);
device_unregister(&css[i]->device);
}
out_bus:
@@ -589,10 +630,9 @@ css_enqueue_subchannel_slow(struct subchannel_id schid)
struct slow_subchannel *new_slow_sch;
unsigned long flags;
- new_slow_sch = kmalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
+ new_slow_sch = kzalloc(sizeof(struct slow_subchannel), GFP_ATOMIC);
if (!new_slow_sch)
return -ENOMEM;
- memset(new_slow_sch, 0, sizeof(struct slow_subchannel));
new_slow_sch->schid = schid;
spin_lock_irqsave(&slow_subchannel_lock, flags);
list_add_tail(&new_slow_sch->slow_list, &slow_subchannels_head);
diff --git a/drivers/s390/cio/css.h b/drivers/s390/cio/css.h
index b6375861cb3..74a257b2338 100644
--- a/drivers/s390/cio/css.h
+++ b/drivers/s390/cio/css.h
@@ -1,6 +1,7 @@
#ifndef _CSS_H
#define _CSS_H
+#include <linux/mutex.h>
#include <linux/wait.h>
#include <linux/workqueue.h>
@@ -150,6 +151,11 @@ struct channel_subsystem {
struct channel_path *chps[__MAX_CHPID + 1];
struct device device;
struct pgid global_pgid;
+ struct mutex mutex;
+ /* channel measurement related */
+ int cm_enabled;
+ void *cub_addr1;
+ void *cub_addr2;
};
#define to_css(dev) container_of(dev, struct channel_subsystem, device)
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index afc4e88551a..8e3053c2a45 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -826,17 +826,15 @@ io_subchannel_probe (struct subchannel *sch)
get_device(&cdev->dev);
return 0;
}
- cdev = kmalloc (sizeof(*cdev), GFP_KERNEL);
+ cdev = kzalloc (sizeof(*cdev), GFP_KERNEL);
if (!cdev)
return -ENOMEM;
- memset(cdev, 0, sizeof(struct ccw_device));
- cdev->private = kmalloc(sizeof(struct ccw_device_private),
+ cdev->private = kzalloc(sizeof(struct ccw_device_private),
GFP_KERNEL | GFP_DMA);
if (!cdev->private) {
kfree(cdev);
return -ENOMEM;
}
- memset(cdev->private, 0, sizeof(struct ccw_device_private));
atomic_set(&cdev->private->onoff, 0);
cdev->dev = (struct device) {
.parent = &sch->dev,
diff --git a/drivers/s390/cio/device_fsm.c b/drivers/s390/cio/device_fsm.c
index b302779e7cf..180b3bf8b90 100644
--- a/drivers/s390/cio/device_fsm.c
+++ b/drivers/s390/cio/device_fsm.c
@@ -827,6 +827,17 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
}
return;
}
+ /*
+ * Check if a halt or clear has been issued in the meanwhile. If yes,
+ * only deliver the halt/clear interrupt to the device driver as if it
+ * had killed the original request.
+ */
+ if (irb->scsw.fctl & (SCSW_FCTL_CLEAR_FUNC | SCSW_FCTL_HALT_FUNC)) {
+ cdev->private->flags.dosense = 0;
+ memset(&cdev->private->irb, 0, sizeof(struct irb));
+ ccw_device_accumulate_irb(cdev, irb);
+ goto call_handler;
+ }
/* Add basic sense info to irb. */
ccw_device_accumulate_basic_sense(cdev, irb);
if (cdev->private->flags.dosense) {
@@ -834,6 +845,7 @@ ccw_device_w4sense(struct ccw_device *cdev, enum dev_event dev_event)
ccw_device_do_sense(cdev, irb);
return;
}
+call_handler:
cdev->private->state = DEV_STATE_ONLINE;
/* Call the handler. */
if (ccw_device_call_handler(cdev) && cdev->private->flags.doverify)
diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
index 3a50b190328..795abb5a65b 100644
--- a/drivers/s390/cio/device_ops.c
+++ b/drivers/s390/cio/device_ops.c
@@ -359,10 +359,9 @@ read_dev_chars (struct ccw_device *cdev, void **buffer, int length)
CIO_TRACE_EVENT (4, "rddevch");
CIO_TRACE_EVENT (4, sch->dev.bus_id);
- rdc_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
+ rdc_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
if (!rdc_ccw)
return -ENOMEM;
- memset(rdc_ccw, 0, sizeof(struct ccw1));
rdc_ccw->cmd_code = CCW_CMD_RDC;
rdc_ccw->count = length;
rdc_ccw->flags = CCW_FLAG_SLI;
@@ -426,16 +425,14 @@ read_conf_data_lpm (struct ccw_device *cdev, void **buffer, int *length, __u8 lp
if (!ciw || ciw->cmd == 0)
return -EOPNOTSUPP;
- rcd_ccw = kmalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
+ rcd_ccw = kzalloc(sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
if (!rcd_ccw)
return -ENOMEM;
- memset(rcd_ccw, 0, sizeof(struct ccw1));
- rcd_buf = kmalloc(ciw->count, GFP_KERNEL | GFP_DMA);
+ rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
if (!rcd_buf) {
kfree(rcd_ccw);
return -ENOMEM;
}
- memset (rcd_buf, 0, ciw->count);
rcd_ccw->cmd_code = ciw->cmd;
rcd_ccw->cda = (__u32) __pa (rcd_buf);
rcd_ccw->count = ciw->count;
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c
index 9ed37dc9a1b..814f9258ce0 100644
--- a/drivers/s390/cio/qdio.c
+++ b/drivers/s390/cio/qdio.c
@@ -1686,16 +1686,14 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,
int result=-ENOMEM;
for (i=0;i<no_input_qs;i++) {
- q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
+ q = kzalloc(sizeof(struct qdio_q), GFP_KERNEL);
if (!q) {
QDIO_PRINT_ERR("kmalloc of q failed!\n");
goto out;
}
- memset(q,0,sizeof(struct qdio_q));
-
- q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
+ q->slib = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!q->slib) {
QDIO_PRINT_ERR("kmalloc of slib failed!\n");
goto out;
@@ -1705,14 +1703,12 @@ qdio_alloc_qs(struct qdio_irq *irq_ptr,
}
for (i=0;i<no_output_qs;i++) {
- q=kmalloc(sizeof(struct qdio_q),GFP_KERNEL);
+ q = kzalloc(sizeof(struct qdio_q), GFP_KERNEL);
if (!q) {
goto out;
}
- memset(q,0,sizeof(struct qdio_q));
-
q->slib=kmalloc(PAGE_SIZE,GFP_KERNEL);
if (!q->slib) {
QDIO_PRINT_ERR("kmalloc of slib failed!\n");
@@ -2984,7 +2980,7 @@ qdio_allocate(struct qdio_initialize *init_data)
qdio_allocate_do_dbf(init_data);
/* create irq */
- irq_ptr=kmalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
+ irq_ptr = kzalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA);
QDIO_DBF_TEXT0(0,setup,"irq_ptr:");
QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*));
@@ -2994,8 +2990,6 @@ qdio_allocate(struct qdio_initialize *init_data)
return -ENOMEM;
}
- memset(irq_ptr,0,sizeof(struct qdio_irq));
-
init_MUTEX(&irq_ptr->setting_up_sema);
/* QDR must be in DMA area since CCW data address is only 32 bit */
@@ -3686,10 +3680,10 @@ qdio_get_qdio_memory(void)
for (i=1;i<INDICATORS_PER_CACHELINE;i++)
indicator_used[i]=0;
- indicators=(__u32*)kmalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
+ indicators = kzalloc(sizeof(__u32)*(INDICATORS_PER_CACHELINE),
GFP_KERNEL);
- if (!indicators) return -ENOMEM;
- memset(indicators,0,sizeof(__u32)*(INDICATORS_PER_CACHELINE));
+ if (!indicators)
+ return -ENOMEM;
return 0;
}
diff --git a/drivers/s390/crypto/z90hardware.c b/drivers/s390/crypto/z90hardware.c
index 4141919da80..be60795f4a7 100644
--- a/drivers/s390/crypto/z90hardware.c
+++ b/drivers/s390/crypto/z90hardware.c
@@ -2214,7 +2214,7 @@ ICACRT_msg_to_type50CRT_msg(struct ica_rsa_modexpo_crt *icaMsg_p,
long_len = 128;
}
- tmp_size = ((mod_len <= 128) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) +
+ tmp_size = ((long_len <= 64) ? TYPE50_CRB1_LEN : TYPE50_CRB2_LEN) +
CALLER_HEADER;
memset(z90cMsg_p, 0, tmp_size);
@@ -2479,8 +2479,16 @@ convert_response(unsigned char *response, unsigned char *buffer,
if (reply_code)
switch (reply_code) {
+ case REP82_ERROR_MACHINE_FAILURE:
+ if (errh_p->type == TYPE82_RSP_CODE)
+ PRINTKW("Machine check failure\n");
+ else
+ PRINTKW("Module failure\n");
+ return REC_HARDWAR_ERR;
case REP82_ERROR_OPERAND_INVALID:
+ return REC_OPERAND_INV;
case REP88_ERROR_MESSAGE_MALFORMD:
+ PRINTKW("Message malformed\n");
return REC_OPERAND_INV;
case REP82_ERROR_OPERAND_SIZE:
return REC_OPERAND_SIZE;
diff --git a/drivers/s390/crypto/z90main.c b/drivers/s390/crypto/z90main.c
index 7d6f19030ef..982acc7303e 100644
--- a/drivers/s390/crypto/z90main.c
+++ b/drivers/s390/crypto/z90main.c
@@ -1,9 +1,9 @@
/*
* linux/drivers/s390/crypto/z90main.c
*
- * z90crypt 1.3.2
+ * z90crypt 1.3.3
*
- * Copyright (C) 2001, 2004 IBM Corporation
+ * Copyright (C) 2001, 2005 IBM Corporation
* Author(s): Robert Burroughs (burrough@us.ibm.com)
* Eric Rossman (edrossma@us.ibm.com)
*
@@ -707,13 +707,12 @@ z90crypt_open(struct inode *inode, struct file *filp)
if (quiesce_z90crypt)
return -EQUIESCE;
- private_data_p = kmalloc(sizeof(struct priv_data), GFP_KERNEL);
+ private_data_p = kzalloc(sizeof(struct priv_data), GFP_KERNEL);
if (!private_data_p) {
PRINTK("Memory allocate failed\n");
return -ENOMEM;
}
- memset((void *)private_data_p, 0, sizeof(struct priv_data));
private_data_p->status = STAT_OPEN;
private_data_p->opener_pid = PID();
filp->private_data = private_data_p;
@@ -991,6 +990,7 @@ remove_device(struct device *device_p)
* PCIXCC_MCL2 512-2048 ----- (applying any GA LIC will make an MCL3 card)
* PCIXCC_MCL3 ----- 128-2048
* CEX2C 512-2048 128-2048
+ * CEX2A ??-2048 same (the lower limit is less than 128 bit...)
*
* ext_bitlens (extended bitlengths) is a global, since you should not apply an
* MCL to just one card in a machine. We assume, at first, that all cards have
@@ -2736,13 +2736,11 @@ create_z90crypt(int *cdx_p)
z90crypt.max_count = Z90CRYPT_NUM_DEVS;
z90crypt.cdx = *cdx_p;
- hdware_blk_p = (struct hdware_block *)
- kmalloc(sizeof(struct hdware_block), GFP_ATOMIC);
+ hdware_blk_p = kzalloc(sizeof(struct hdware_block), GFP_ATOMIC);
if (!hdware_blk_p) {
PDEBUG("kmalloc for hardware block failed\n");
return ENOMEM;
}
- memset(hdware_blk_p, 0x00, sizeof(struct hdware_block));
z90crypt.hdware_info = hdware_blk_p;
return 0;
@@ -2977,12 +2975,11 @@ create_crypto_device(int index)
total_size = sizeof(struct device) +
z90crypt.q_depth_array[index] * sizeof(int);
- dev_ptr = (struct device *) kmalloc(total_size, GFP_ATOMIC);
+ dev_ptr = kzalloc(total_size, GFP_ATOMIC);
if (!dev_ptr) {
PRINTK("kmalloc device %d failed\n", index);
return ENOMEM;
}
- memset(dev_ptr, 0, total_size);
dev_ptr->dev_resp_p = kmalloc(MAX_RESPONSE_SIZE, GFP_ATOMIC);
if (!dev_ptr->dev_resp_p) {
kfree(dev_ptr);
diff --git a/drivers/s390/net/claw.c b/drivers/s390/net/claw.c
index acd2a3f005f..23d53bf9daf 100644
--- a/drivers/s390/net/claw.c
+++ b/drivers/s390/net/claw.c
@@ -310,7 +310,7 @@ claw_probe(struct ccwgroup_device *cgdev)
printk(KERN_INFO "claw: variable cgdev =\n");
dumpit((char *)cgdev, sizeof(struct ccwgroup_device));
#endif
- privptr = kmalloc(sizeof(struct claw_privbk), GFP_KERNEL);
+ privptr = kzalloc(sizeof(struct claw_privbk), GFP_KERNEL);
if (privptr == NULL) {
probe_error(cgdev);
put_device(&cgdev->dev);
@@ -319,7 +319,6 @@ claw_probe(struct ccwgroup_device *cgdev)
CLAW_DBF_TEXT_(2,setup,"probex%d",-ENOMEM);
return -ENOMEM;
}
- memset(privptr,0x00,sizeof(struct claw_privbk));
privptr->p_mtc_envelope= kmalloc( MAX_ENVELOPE_SIZE, GFP_KERNEL);
privptr->p_env = kmalloc(sizeof(struct claw_env), GFP_KERNEL);
if ((privptr->p_mtc_envelope==NULL) || (privptr->p_env==NULL)) {
diff --git a/drivers/s390/net/fsm.c b/drivers/s390/net/fsm.c
index 6caf5fa6a3b..7145e2134cf 100644
--- a/drivers/s390/net/fsm.c
+++ b/drivers/s390/net/fsm.c
@@ -21,38 +21,34 @@ init_fsm(char *name, const char **state_names, const char **event_names, int nr_
fsm_function_t *m;
fsm *f;
- this = (fsm_instance *)kmalloc(sizeof(fsm_instance), order);
+ this = kzalloc(sizeof(fsm_instance), order);
if (this == NULL) {
printk(KERN_WARNING
"fsm(%s): init_fsm: Couldn't alloc instance\n", name);
return NULL;
}
- memset(this, 0, sizeof(fsm_instance));
strlcpy(this->name, name, sizeof(this->name));
- f = (fsm *)kmalloc(sizeof(fsm), order);
+ f = kzalloc(sizeof(fsm), order);
if (f == NULL) {
printk(KERN_WARNING
"fsm(%s): init_fsm: Couldn't alloc fsm\n", name);
kfree_fsm(this);
return NULL;
}
- memset(f, 0, sizeof(fsm));
f->nr_events = nr_events;
f->nr_states = nr_states;
f->event_names = event_names;
f->state_names = state_names;
this->f = f;
- m = (fsm_function_t *)kmalloc(
- sizeof(fsm_function_t) * nr_states * nr_events, order);
+ m = kcalloc(nr_states*nr_events, sizeof(fsm_function_t), order);
if (m == NULL) {
printk(KERN_WARNING
"fsm(%s): init_fsm: Couldn't alloc jumptable\n", name);
kfree_fsm(this);
return NULL;
}
- memset(m, 0, sizeof(fsm_function_t) * f->nr_states * f->nr_events);
f->jumpmatrix = m;
for (i = 0; i < tmpl_len; i++) {
diff --git a/drivers/s390/net/iucv.c b/drivers/s390/net/iucv.c
index 760e77ec5a1..6190be9dca9 100644
--- a/drivers/s390/net/iucv.c
+++ b/drivers/s390/net/iucv.c
@@ -386,7 +386,7 @@ iucv_init(void)
}
/* Note: GFP_DMA used used to get memory below 2G */
- iucv_external_int_buffer = kmalloc(sizeof(iucv_GeneralInterrupt),
+ iucv_external_int_buffer = kzalloc(sizeof(iucv_GeneralInterrupt),
GFP_KERNEL|GFP_DMA);
if (!iucv_external_int_buffer) {
printk(KERN_WARNING
@@ -396,10 +396,9 @@ iucv_init(void)
bus_unregister(&iucv_bus);
return -ENOMEM;
}
- memset(iucv_external_int_buffer, 0, sizeof(iucv_GeneralInterrupt));
/* Initialize parameter pool */
- iucv_param_pool = kmalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
+ iucv_param_pool = kzalloc(sizeof(iucv_param) * PARAM_POOL_SIZE,
GFP_KERNEL|GFP_DMA);
if (!iucv_param_pool) {
printk(KERN_WARNING "%s: Could not allocate param pool\n",
@@ -410,7 +409,6 @@ iucv_init(void)
bus_unregister(&iucv_bus);
return -ENOMEM;
}
- memset(iucv_param_pool, 0, sizeof(iucv_param) * PARAM_POOL_SIZE);
/* Initialize irq queue */
INIT_LIST_HEAD(&iucv_irq_queue);
@@ -793,15 +791,14 @@ iucv_register_program (__u8 pgmname[16],
}
max_connections = iucv_query_maxconn();
- iucv_pathid_table = kmalloc(max_connections * sizeof(handler *),
- GFP_ATOMIC);
+ iucv_pathid_table = kcalloc(max_connections, sizeof(handler *),
+ GFP_ATOMIC);
if (iucv_pathid_table == NULL) {
printk(KERN_WARNING "%s: iucv_pathid_table storage "
"allocation failed\n", __FUNCTION__);
kfree(new_handler);
return NULL;
}
- memset (iucv_pathid_table, 0, max_connections * sizeof(handler *));
}
memset(new_handler, 0, sizeof (handler));
memcpy(new_handler->id.user_data, pgmname,
diff --git a/drivers/s390/net/lcs.c b/drivers/s390/net/lcs.c
index 9cf88d7201d..edcf05d5d56 100644
--- a/drivers/s390/net/lcs.c
+++ b/drivers/s390/net/lcs.c
@@ -115,11 +115,10 @@ lcs_alloc_channel(struct lcs_channel *channel)
LCS_DBF_TEXT(2, setup, "ichalloc");
for (cnt = 0; cnt < LCS_NUM_BUFFS; cnt++) {
/* alloc memory fo iobuffer */
- channel->iob[cnt].data = (void *)
- kmalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
+ channel->iob[cnt].data =
+ kzalloc(LCS_IOBUFFERSIZE, GFP_DMA | GFP_KERNEL);
if (channel->iob[cnt].data == NULL)
break;
- memset(channel->iob[cnt].data, 0, LCS_IOBUFFERSIZE);
channel->iob[cnt].state = BUF_STATE_EMPTY;
}
if (cnt < LCS_NUM_BUFFS) {
@@ -182,10 +181,9 @@ lcs_alloc_card(void)
LCS_DBF_TEXT(2, setup, "alloclcs");
- card = kmalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
+ card = kzalloc(sizeof(struct lcs_card), GFP_KERNEL | GFP_DMA);
if (card == NULL)
return NULL;
- memset(card, 0, sizeof(struct lcs_card));
card->lan_type = LCS_FRAME_TYPE_AUTO;
card->pkt_seq = 0;
card->lancmd_timeout = LCS_LANCMD_TIMEOUT_DEFAULT;
@@ -793,10 +791,9 @@ lcs_alloc_reply(struct lcs_cmd *cmd)
LCS_DBF_TEXT(4, trace, "getreply");
- reply = kmalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
+ reply = kzalloc(sizeof(struct lcs_reply), GFP_ATOMIC);
if (!reply)
return NULL;
- memset(reply,0,sizeof(struct lcs_reply));
atomic_set(&reply->refcnt,1);
reply->sequence_no = cmd->sequence_no;
reply->received = 0;
diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c
index 71d3853e868..260a93c8c44 100644
--- a/drivers/s390/net/netiucv.c
+++ b/drivers/s390/net/netiucv.c
@@ -1728,14 +1728,13 @@ static int
netiucv_register_device(struct net_device *ndev)
{
struct netiucv_priv *priv = ndev->priv;
- struct device *dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
int ret;
IUCV_DBF_TEXT(trace, 3, __FUNCTION__);
if (dev) {
- memset(dev, 0, sizeof(struct device));
snprintf(dev->bus_id, BUS_ID_SIZE, "net%s", ndev->name);
dev->bus = &iucv_bus;
dev->parent = iucv_root;
@@ -1784,11 +1783,9 @@ netiucv_new_connection(struct net_device *dev, char *username)
{
struct iucv_connection **clist = &iucv_connections;
struct iucv_connection *conn =
- (struct iucv_connection *)
- kmalloc(sizeof(struct iucv_connection), GFP_KERNEL);
+ kzalloc(sizeof(struct iucv_connection), GFP_KERNEL);
if (conn) {
- memset(conn, 0, sizeof(struct iucv_connection));
skb_queue_head_init(&conn->collect_queue);
skb_queue_head_init(&conn->commit_queue);
conn->max_buffsize = NETIUCV_BUFSIZE_DEFAULT;
diff --git a/drivers/s390/net/qeth_eddp.c b/drivers/s390/net/qeth_eddp.c
index 82cb4af2f0e..44e226f211e 100644
--- a/drivers/s390/net/qeth_eddp.c
+++ b/drivers/s390/net/qeth_eddp.c
@@ -389,9 +389,8 @@ qeth_eddp_create_eddp_data(struct qeth_hdr *qh, u8 *nh, u8 nhl, u8 *th, u8 thl)
struct qeth_eddp_data *eddp;
QETH_DBF_TEXT(trace, 5, "eddpcrda");
- eddp = kmalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
+ eddp = kzalloc(sizeof(struct qeth_eddp_data), GFP_ATOMIC);
if (eddp){
- memset(eddp, 0, sizeof(struct qeth_eddp_data));
eddp->nhl = nhl;
eddp->thl = thl;
memcpy(&eddp->qh, qh, sizeof(struct qeth_hdr));
@@ -542,12 +541,11 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
QETH_DBF_TEXT(trace, 5, "creddpcg");
/* create the context and allocate pages */
- ctx = kmalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
+ ctx = kzalloc(sizeof(struct qeth_eddp_context), GFP_ATOMIC);
if (ctx == NULL){
QETH_DBF_TEXT(trace, 2, "ceddpcn1");
return NULL;
}
- memset(ctx, 0, sizeof(struct qeth_eddp_context));
ctx->type = QETH_LARGE_SEND_EDDP;
qeth_eddp_calc_num_pages(ctx, skb, hdr_len);
if (ctx->elements_per_skb > QETH_MAX_BUFFER_ELEMENTS(card)){
@@ -555,13 +553,12 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
kfree(ctx);
return NULL;
}
- ctx->pages = kmalloc(ctx->num_pages * sizeof(u8 *), GFP_ATOMIC);
+ ctx->pages = kcalloc(ctx->num_pages, sizeof(u8 *), GFP_ATOMIC);
if (ctx->pages == NULL){
QETH_DBF_TEXT(trace, 2, "ceddpcn2");
kfree(ctx);
return NULL;
}
- memset(ctx->pages, 0, ctx->num_pages * sizeof(u8 *));
for (i = 0; i < ctx->num_pages; ++i){
addr = (u8 *)__get_free_page(GFP_ATOMIC);
if (addr == NULL){
@@ -573,15 +570,13 @@ qeth_eddp_create_context_generic(struct qeth_card *card, struct sk_buff *skb,
memset(addr, 0, PAGE_SIZE);
ctx->pages[i] = addr;
}
- ctx->elements = kmalloc(ctx->num_elements *
+ ctx->elements = kcalloc(ctx->num_elements,
sizeof(struct qeth_eddp_element), GFP_ATOMIC);
if (ctx->elements == NULL){
QETH_DBF_TEXT(trace, 2, "ceddpcn4");
qeth_eddp_free_context(ctx);
return NULL;
}
- memset(ctx->elements, 0,
- ctx->num_elements * sizeof(struct qeth_eddp_element));
/* reset num_elements; will be incremented again in fill_buffer to
* reflect number of actually used elements */
ctx->num_elements = 0;
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c
index dba7f7f02e7..b3c6e790779 100644
--- a/drivers/s390/net/qeth_main.c
+++ b/drivers/s390/net/qeth_main.c
@@ -297,12 +297,10 @@ qeth_alloc_card(void)
struct qeth_card *card;
QETH_DBF_TEXT(setup, 2, "alloccrd");
- card = (struct qeth_card *) kmalloc(sizeof(struct qeth_card),
- GFP_DMA|GFP_KERNEL);
+ card = kzalloc(sizeof(struct qeth_card), GFP_DMA|GFP_KERNEL);
if (!card)
return NULL;
QETH_DBF_HEX(setup, 2, &card, sizeof(void *));
- memset(card, 0, sizeof(struct qeth_card));
if (qeth_setup_channel(&card->read)) {
kfree(card);
return NULL;
@@ -1364,7 +1362,7 @@ qeth_wait_for_buffer(struct qeth_channel *channel)
static void
qeth_clear_cmd_buffers(struct qeth_channel *channel)
{
- int cnt = 0;
+ int cnt;
for (cnt=0; cnt < QETH_CMD_BUFFER_NO; cnt++)
qeth_release_buffer(channel,&channel->iob[cnt]);
@@ -1632,9 +1630,8 @@ qeth_alloc_reply(struct qeth_card *card)
{
struct qeth_reply *reply;
- reply = kmalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
+ reply = kzalloc(sizeof(struct qeth_reply), GFP_ATOMIC);
if (reply){
- memset(reply, 0, sizeof(struct qeth_reply));
atomic_set(&reply->refcnt, 1);
reply->card = card;
};
@@ -2814,11 +2811,11 @@ qeth_handle_send_error(struct qeth_card *card,
QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
return QETH_SEND_ERROR_LINK_FAILURE;
case 3:
+ default:
QETH_DBF_TEXT(trace, 1, "SIGAcc3");
QETH_DBF_TEXT_(trace,1,"%s",CARD_BUS_ID(card));
return QETH_SEND_ERROR_KICK_IT;
}
- return QETH_SEND_ERROR_LINK_FAILURE;
}
void
@@ -3348,13 +3345,11 @@ qeth_qdio_establish(struct qeth_card *card)
QETH_DBF_TEXT(setup, 2, "qdioest");
- qib_param_field = kmalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
+ qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
GFP_KERNEL);
if (!qib_param_field)
return -ENOMEM;
- memset(qib_param_field, 0, QDIO_MAX_BUFFERS_PER_Q * sizeof(char));
-
qeth_create_qib_param_field(card, qib_param_field);
qeth_create_qib_param_field_blkt(card, qib_param_field);
@@ -3865,6 +3860,7 @@ qeth_get_cast_type(struct qeth_card *card, struct sk_buff *skb)
if ((hdr_mac == QETH_TR_MAC_NC) ||
(hdr_mac == QETH_TR_MAC_C))
return RTN_MULTICAST;
+ break;
/* eth or so multicast? */
default:
if ((hdr_mac == QETH_ETH_MAC_V4) ||
@@ -4419,6 +4415,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
int elements_needed = 0;
enum qeth_large_send_types large_send = QETH_LARGE_SEND_NO;
struct qeth_eddp_context *ctx = NULL;
+ int tx_bytes = skb->len;
int rc;
QETH_DBF_TEXT(trace, 6, "sendpkt");
@@ -4499,7 +4496,7 @@ qeth_send_packet(struct qeth_card *card, struct sk_buff *skb)
elements_needed, ctx);
if (!rc){
card->stats.tx_packets++;
- card->stats.tx_bytes += skb->len;
+ card->stats.tx_bytes += tx_bytes;
#ifdef CONFIG_QETH_PERF_STATS
if (skb_shinfo(skb)->tso_size &&
!(large_send == QETH_LARGE_SEND_NO)) {
@@ -4585,38 +4582,11 @@ qeth_mdio_read(struct net_device *dev, int phy_id, int regnum)
case MII_NCONFIG: /* network interface config */
break;
default:
- rc = 0;
break;
}
return rc;
}
-static void
-qeth_mdio_write(struct net_device *dev, int phy_id, int regnum, int value)
-{
- switch(regnum){
- case MII_BMCR: /* Basic mode control register */
- case MII_BMSR: /* Basic mode status register */
- case MII_PHYSID1: /* PHYS ID 1 */
- case MII_PHYSID2: /* PHYS ID 2 */
- case MII_ADVERTISE: /* Advertisement control reg */
- case MII_LPA: /* Link partner ability reg */
- case MII_EXPANSION: /* Expansion register */
- case MII_DCOUNTER: /* disconnect counter */
- case MII_FCSCOUNTER: /* false carrier counter */
- case MII_NWAYTEST: /* N-way auto-neg test register */
- case MII_RERRCOUNTER: /* rx error counter */
- case MII_SREVISION: /* silicon revision */
- case MII_RESV1: /* reserved 1 */
- case MII_LBRERROR: /* loopback, rx, bypass error */
- case MII_PHYADDR: /* physical address */
- case MII_RESV2: /* reserved 2 */
- case MII_TPISTATUS: /* TPI status for 10mbps */
- case MII_NCONFIG: /* network interface config */
- default:
- break;
- }
-}
static inline const char *
qeth_arp_get_error_cause(int *rc)
@@ -4844,9 +4814,8 @@ qeth_arp_query(struct qeth_card *card, char *udata)
/* get size of userspace buffer and mask_bits -> 6 bytes */
if (copy_from_user(&qinfo, udata, 6))
return -EFAULT;
- if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL)))
+ if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL)))
return -ENOMEM;
- memset(qinfo.udata, 0, qinfo.udata_len);
qinfo.udata_offset = QETH_QARP_ENTRIES_OFFSET;
iob = qeth_get_setassparms_cmd(card, IPA_ARP_PROCESSING,
IPA_CMD_ASS_ARP_QUERY_INFO,
@@ -4994,11 +4963,10 @@ qeth_snmp_command(struct qeth_card *card, char *udata)
return -EFAULT;
}
qinfo.udata_len = ureq->hdr.data_len;
- if (!(qinfo.udata = kmalloc(qinfo.udata_len, GFP_KERNEL))){
+ if (!(qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL))){
kfree(ureq);
return -ENOMEM;
}
- memset(qinfo.udata, 0, qinfo.udata_len);
qinfo.udata_offset = sizeof(struct qeth_snmp_ureq_hdr);
iob = qeth_get_adapter_cmd(card, IPA_SETADP_SET_SNMP_CONTROL,
@@ -5236,21 +5204,6 @@ qeth_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
mii_data->val_out = qeth_mdio_read(dev,mii_data->phy_id,
mii_data->reg_num);
break;
- case SIOCSMIIREG:
- rc = -EOPNOTSUPP;
- break;
- /* TODO: remove return if qeth_mdio_write does something */
- if (!capable(CAP_NET_ADMIN)){
- rc = -EPERM;
- break;
- }
- mii_data = if_mii(rq);
- if (mii_data->phy_id != 0)
- rc = -EINVAL;
- else
- qeth_mdio_write(dev, mii_data->phy_id, mii_data->reg_num,
- mii_data->val_in);
- break;
default:
rc = -EOPNOTSUPP;
}
@@ -5604,12 +5557,11 @@ qeth_get_addr_buffer(enum qeth_prot_versions prot)
{
struct qeth_ipaddr *addr;
- addr = kmalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
+ addr = kzalloc(sizeof(struct qeth_ipaddr), GFP_ATOMIC);
if (addr == NULL) {
PRINT_WARN("Not enough memory to add address\n");
return NULL;
}
- memset(addr,0,sizeof(struct qeth_ipaddr));
addr->type = QETH_IP_TYPE_NORMAL;
addr->proto = prot;
return addr;
@@ -6900,7 +6852,7 @@ qeth_send_setassparms(struct qeth_card *card, struct qeth_cmd_buffer *iob,
cmd = (struct qeth_ipa_cmd *)(iob->data+IPA_PDU_HEADER_SIZE);
if (len <= sizeof(__u32))
cmd->data.setassparms.data.flags_32bit = (__u32) data;
- else if (len > sizeof(__u32))
+ else /* (len > sizeof(__u32)) */
memcpy(&cmd->data.setassparms.data, (void *) data, len);
rc = qeth_send_ipa_cmd(card, iob, reply_cb, reply_param);
@@ -7379,11 +7331,6 @@ qeth_setrouting_v6(struct qeth_card *card)
qeth_correct_routing_type(card, &card->options.route6.type,
QETH_PROT_IPV6);
- if ((card->options.route6.type == NO_ROUTER) ||
- ((card->info.type == QETH_CARD_TYPE_OSAE) &&
- (card->options.route6.type == MULTICAST_ROUTER) &&
- !qeth_is_supported6(card,IPA_OSA_MC_ROUTER)))
- return 0;
rc = qeth_send_setrouting(card, card->options.route6.type,
QETH_PROT_IPV6);
if (rc) {
diff --git a/drivers/s390/net/qeth_proc.c b/drivers/s390/net/qeth_proc.c
index 3c6339df879..360d782c7ad 100644
--- a/drivers/s390/net/qeth_proc.c
+++ b/drivers/s390/net/qeth_proc.c
@@ -74,7 +74,7 @@ qeth_procfile_seq_next(struct seq_file *s, void *it, loff_t *offset)
static inline const char *
qeth_get_router_str(struct qeth_card *card, int ipv)
{
- int routing_type = 0;
+ enum qeth_routing_types routing_type = NO_ROUTER;
if (ipv == 4) {
routing_type = card->options.route4.type;
@@ -86,26 +86,26 @@ qeth_get_router_str(struct qeth_card *card, int ipv)
#endif /* CONFIG_QETH_IPV6 */
}
- if (routing_type == PRIMARY_ROUTER)
+ switch (routing_type){
+ case PRIMARY_ROUTER:
return "pri";
- else if (routing_type == SECONDARY_ROUTER)
+ case SECONDARY_ROUTER:
return "sec";
- else if (routing_type == MULTICAST_ROUTER) {
+ case MULTICAST_ROUTER:
if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
return "mc+";
return "mc";
- } else if (routing_type == PRIMARY_CONNECTOR) {
+ case PRIMARY_CONNECTOR:
if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
return "p+c";
return "p.c";
- } else if (routing_type == SECONDARY_CONNECTOR) {
+ case SECONDARY_CONNECTOR:
if (card->info.broadcast_capable == QETH_BROADCAST_WITHOUT_ECHO)
return "s+c";
return "s.c";
- } else if (routing_type == NO_ROUTER)
+ default: /* NO_ROUTER */
return "no";
- else
- return "unk";
+ }
}
static int
@@ -192,27 +192,27 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
CARD_DDEV_ID(card),
QETH_CARD_IFNAME(card)
);
- seq_printf(s, " Skb's/buffers received : %li/%i\n"
- " Skb's/buffers sent : %li/%i\n\n",
+ seq_printf(s, " Skb's/buffers received : %lu/%u\n"
+ " Skb's/buffers sent : %lu/%u\n\n",
card->stats.rx_packets, card->perf_stats.bufs_rec,
card->stats.tx_packets, card->perf_stats.bufs_sent
);
- seq_printf(s, " Skb's/buffers sent without packing : %li/%i\n"
- " Skb's/buffers sent with packing : %i/%i\n\n",
+ seq_printf(s, " Skb's/buffers sent without packing : %lu/%u\n"
+ " Skb's/buffers sent with packing : %u/%u\n\n",
card->stats.tx_packets - card->perf_stats.skbs_sent_pack,
card->perf_stats.bufs_sent - card->perf_stats.bufs_sent_pack,
card->perf_stats.skbs_sent_pack,
card->perf_stats.bufs_sent_pack
);
- seq_printf(s, " Skbs sent in SG mode : %i\n"
- " Skb fragments sent in SG mode : %i\n\n",
+ seq_printf(s, " Skbs sent in SG mode : %u\n"
+ " Skb fragments sent in SG mode : %u\n\n",
card->perf_stats.sg_skbs_sent,
card->perf_stats.sg_frags_sent);
- seq_printf(s, " large_send tx (in Kbytes) : %i\n"
- " large_send count : %i\n\n",
+ seq_printf(s, " large_send tx (in Kbytes) : %u\n"
+ " large_send count : %u\n\n",
card->perf_stats.large_send_bytes >> 10,
card->perf_stats.large_send_cnt);
- seq_printf(s, " Packing state changes no pkg.->packing : %i/%i\n"
+ seq_printf(s, " Packing state changes no pkg.->packing : %u/%u\n"
" Watermarks L/H : %i/%i\n"
" Current buffer usage (outbound q's) : "
"%i/%i/%i/%i\n\n",
@@ -229,16 +229,16 @@ qeth_perf_procfile_seq_show(struct seq_file *s, void *it)
atomic_read(&card->qdio.out_qs[3]->used_buffers)
: 0
);
- seq_printf(s, " Inbound handler time (in us) : %i\n"
- " Inbound handler count : %i\n"
- " Inbound do_QDIO time (in us) : %i\n"
- " Inbound do_QDIO count : %i\n\n"
- " Outbound handler time (in us) : %i\n"
- " Outbound handler count : %i\n\n"
- " Outbound time (in us, incl QDIO) : %i\n"
- " Outbound count : %i\n"
- " Outbound do_QDIO time (in us) : %i\n"
- " Outbound do_QDIO count : %i\n\n",
+ seq_printf(s, " Inbound handler time (in us) : %u\n"
+ " Inbound handler count : %u\n"
+ " Inbound do_QDIO time (in us) : %u\n"
+ " Inbound do_QDIO count : %u\n\n"
+ " Outbound handler time (in us) : %u\n"
+ " Outbound handler count : %u\n\n"
+ " Outbound time (in us, incl QDIO) : %u\n"
+ " Outbound count : %u\n"
+ " Outbound do_QDIO time (in us) : %u\n"
+ " Outbound do_QDIO count : %u\n\n",
card->perf_stats.inbound_time,
card->perf_stats.inbound_cnt,
card->perf_stats.inbound_do_qdio_time,
diff --git a/drivers/s390/net/qeth_sys.c b/drivers/s390/net/qeth_sys.c
index c1831f57258..882d419e416 100644
--- a/drivers/s390/net/qeth_sys.c
+++ b/drivers/s390/net/qeth_sys.c
@@ -115,7 +115,7 @@ qeth_dev_portno_store(struct device *dev, struct device_attribute *attr, const c
return -EPERM;
portno = simple_strtoul(buf, &tmp, 16);
- if ((portno < 0) || (portno > MAX_PORTNO)){
+ if (portno > MAX_PORTNO){
PRINT_WARN("portno 0x%X is out of range\n", portno);
return -EINVAL;
}
@@ -1145,11 +1145,10 @@ qeth_dev_ipato_add_store(const char *buf, size_t count,
if ((rc = qeth_parse_ipatoe(buf, proto, addr, &mask_bits)))
return rc;
- if (!(ipatoe = kmalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){
+ if (!(ipatoe = kzalloc(sizeof(struct qeth_ipato_entry), GFP_KERNEL))){
PRINT_WARN("No memory to allocate ipato entry\n");
return -ENOMEM;
}
- memset(ipatoe, 0, sizeof(struct qeth_ipato_entry));
ipatoe->proto = proto;
memcpy(ipatoe->addr, addr, (proto == QETH_PROT_IPV4)? 4:16);
ipatoe->mask_bits = mask_bits;
diff --git a/drivers/s390/s390_rdev.c b/drivers/s390/s390_rdev.c
index e3f64716982..3c7145d9f9a 100644
--- a/drivers/s390/s390_rdev.c
+++ b/drivers/s390/s390_rdev.c
@@ -27,10 +27,9 @@ s390_root_dev_register(const char *name)
if (!strlen(name))
return ERR_PTR(-EINVAL);
- dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct device), GFP_KERNEL);
if (!dev)
return ERR_PTR(-ENOMEM);
- memset(dev, 0, sizeof(struct device));
strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
dev->release = s390_root_dev_release;
ret = device_register(dev);
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index 5c94a5d4efc..4035920ce3d 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -595,10 +595,10 @@ config SCSI_SATA_VIA
If unsure, say N.
config SCSI_SATA_VITESSE
- tristate "VITESSE VSC-7174 SATA support"
+ tristate "VITESSE VSC-7174 / INTEL 31244 SATA support"
depends on SCSI_SATA && PCI
help
- This option enables support for Vitesse VSC7174 Serial ATA.
+ This option enables support for Vitesse VSC7174 and Intel 31244 Serial ATA.
If unsure, say N.
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 15dc2e00e1b..e513c3158ad 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -117,7 +117,6 @@ obj-$(CONFIG_SCSI_PPA) += ppa.o
obj-$(CONFIG_SCSI_IMM) += imm.o
obj-$(CONFIG_JAZZ_ESP) += NCR53C9x.o jazz_esp.o
obj-$(CONFIG_SUN3X_ESP) += NCR53C9x.o sun3x_esp.o
-obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
obj-$(CONFIG_SCSI_FCAL) += fcal.o
obj-$(CONFIG_SCSI_LASI700) += 53c700.o lasi700.o
obj-$(CONFIG_SCSI_NSP32) += nsp32.o
@@ -148,6 +147,9 @@ obj-$(CONFIG_BLK_DEV_SR) += sr_mod.o
obj-$(CONFIG_CHR_DEV_SG) += sg.o
obj-$(CONFIG_CHR_DEV_SCH) += ch.o
+# This goes last, so that "real" scsi devices probe earlier
+obj-$(CONFIG_SCSI_DEBUG) += scsi_debug.o
+
scsi_mod-y += scsi.o hosts.o scsi_ioctl.o constants.o \
scsicam.o scsi_error.o scsi_lib.o \
scsi_scan.o scsi_sysfs.o \
diff --git a/drivers/scsi/ahci.c b/drivers/scsi/ahci.c
index a1ddbba2cbd..ffba65656a8 100644
--- a/drivers/scsi/ahci.c
+++ b/drivers/scsi/ahci.c
@@ -513,6 +513,138 @@ static void ahci_fill_cmd_slot(struct ahci_port_priv *pp, u32 opts)
pp->cmd_slot[0].tbl_addr_hi = cpu_to_le32((pp->cmd_tbl_dma >> 16) >> 16);
}
+static int ahci_poll_register(void __iomem *reg, u32 mask, u32 val,
+ unsigned long interval_msec,
+ unsigned long timeout_msec)
+{
+ unsigned long timeout;
+ u32 tmp;
+
+ timeout = jiffies + (timeout_msec * HZ) / 1000;
+ do {
+ tmp = readl(reg);
+ if ((tmp & mask) == val)
+ return 0;
+ msleep(interval_msec);
+ } while (time_before(jiffies, timeout));
+
+ return -1;
+}
+
+static int ahci_softreset(struct ata_port *ap, int verbose, unsigned int *class)
+{
+ struct ahci_host_priv *hpriv = ap->host_set->private_data;
+ struct ahci_port_priv *pp = ap->private_data;
+ void __iomem *mmio = ap->host_set->mmio_base;
+ void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+ const u32 cmd_fis_len = 5; /* five dwords */
+ const char *reason = NULL;
+ struct ata_taskfile tf;
+ u8 *fis;
+ int rc;
+
+ DPRINTK("ENTER\n");
+
+ /* prepare for SRST (AHCI-1.1 10.4.1) */
+ rc = ahci_stop_engine(ap);
+ if (rc) {
+ reason = "failed to stop engine";
+ goto fail_restart;
+ }
+
+ /* check BUSY/DRQ, perform Command List Override if necessary */
+ ahci_tf_read(ap, &tf);
+ if (tf.command & (ATA_BUSY | ATA_DRQ)) {
+ u32 tmp;
+
+ if (!(hpriv->cap & HOST_CAP_CLO)) {
+ rc = -EIO;
+ reason = "port busy but no CLO";
+ goto fail_restart;
+ }
+
+ tmp = readl(port_mmio + PORT_CMD);
+ tmp |= PORT_CMD_CLO;
+ writel(tmp, port_mmio + PORT_CMD);
+ readl(port_mmio + PORT_CMD); /* flush */
+
+ if (ahci_poll_register(port_mmio + PORT_CMD, PORT_CMD_CLO, 0x0,
+ 1, 500)) {
+ rc = -EIO;
+ reason = "CLO failed";
+ goto fail_restart;
+ }
+ }
+
+ /* restart engine */
+ ahci_start_engine(ap);
+
+ ata_tf_init(ap, &tf, 0);
+ fis = pp->cmd_tbl;
+
+ /* issue the first D2H Register FIS */
+ ahci_fill_cmd_slot(pp, cmd_fis_len | AHCI_CMD_RESET | AHCI_CMD_CLR_BUSY);
+
+ tf.ctl |= ATA_SRST;
+ ata_tf_to_fis(&tf, fis, 0);
+ fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
+
+ writel(1, port_mmio + PORT_CMD_ISSUE);
+ readl(port_mmio + PORT_CMD_ISSUE); /* flush */
+
+ if (ahci_poll_register(port_mmio + PORT_CMD_ISSUE, 0x1, 0x0, 1, 500)) {
+ rc = -EIO;
+ reason = "1st FIS failed";
+ goto fail;
+ }
+
+ /* spec says at least 5us, but be generous and sleep for 1ms */
+ msleep(1);
+
+ /* issue the second D2H Register FIS */
+ ahci_fill_cmd_slot(pp, cmd_fis_len);
+
+ tf.ctl &= ~ATA_SRST;
+ ata_tf_to_fis(&tf, fis, 0);
+ fis[1] &= ~(1 << 7); /* turn off Command FIS bit */
+
+ writel(1, port_mmio + PORT_CMD_ISSUE);
+ readl(port_mmio + PORT_CMD_ISSUE); /* flush */
+
+ /* spec mandates ">= 2ms" before checking status.
+ * We wait 150ms, because that was the magic delay used for
+ * ATAPI devices in Hale Landis's ATADRVR, for the period of time
+ * between when the ATA command register is written, and then
+ * status is checked. Because waiting for "a while" before
+ * checking status is fine, post SRST, we perform this magic
+ * delay here as well.
+ */
+ msleep(150);
+
+ *class = ATA_DEV_NONE;
+ if (sata_dev_present(ap)) {
+ if (ata_busy_sleep(ap, ATA_TMOUT_BOOT_QUICK, ATA_TMOUT_BOOT)) {
+ rc = -EIO;
+ reason = "device not ready";
+ goto fail;
+ }
+ *class = ahci_dev_classify(ap);
+ }
+
+ DPRINTK("EXIT, class=%u\n", *class);
+ return 0;
+
+ fail_restart:
+ ahci_start_engine(ap);
+ fail:
+ if (verbose)
+ printk(KERN_ERR "ata%u: softreset failed (%s)\n",
+ ap->id, reason);
+ else
+ DPRINTK("EXIT, rc=%d reason=\"%s\"\n", rc, reason);
+ return rc;
+}
+
static int ahci_hardreset(struct ata_port *ap, int verbose, unsigned int *class)
{
int rc;
@@ -553,7 +685,8 @@ static void ahci_postreset(struct ata_port *ap, unsigned int *class)
static int ahci_probe_reset(struct ata_port *ap, unsigned int *classes)
{
- return ata_drive_probe_reset(ap, NULL, NULL, ahci_hardreset,
+ return ata_drive_probe_reset(ap, ata_std_probeinit,
+ ahci_softreset, ahci_hardreset,
ahci_postreset, classes);
}
diff --git a/drivers/scsi/arm/cumana_2.c b/drivers/scsi/arm/cumana_2.c
index 583d2d8c833..fad2109268b 100644
--- a/drivers/scsi/arm/cumana_2.c
+++ b/drivers/scsi/arm/cumana_2.c
@@ -550,6 +550,6 @@ module_exit(cumanascsi2_exit);
MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("Cumana SCSI-2 driver for Acorn machines");
-MODULE_PARM(term, "1-8i");
+module_param_array(term, int, NULL, 0);
MODULE_PARM_DESC(term, "SCSI bus termination");
MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/arm/eesox.c b/drivers/scsi/arm/eesox.c
index 3ffec7efc9d..dcbb4b2b3fe 100644
--- a/drivers/scsi/arm/eesox.c
+++ b/drivers/scsi/arm/eesox.c
@@ -674,6 +674,6 @@ module_exit(eesox_exit);
MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("EESOX 'Fast' SCSI driver for Acorn machines");
-MODULE_PARM(term, "1-8i");
+module_param_array(term, int, NULL, 0);
MODULE_PARM_DESC(term, "SCSI bus termination");
MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/arm/powertec.c b/drivers/scsi/arm/powertec.c
index 3113bdcedb1..3d69f6c45a6 100644
--- a/drivers/scsi/arm/powertec.c
+++ b/drivers/scsi/arm/powertec.c
@@ -466,6 +466,6 @@ module_exit(powertecscsi_exit);
MODULE_AUTHOR("Russell King");
MODULE_DESCRIPTION("Powertec SCSI driver");
-MODULE_PARM(term, "1-8i");
+module_param_array(term, int, NULL, 0);
MODULE_PARM_DESC(term, "SCSI bus termination");
MODULE_LICENSE("GPL");
diff --git a/drivers/scsi/ata_piix.c b/drivers/scsi/ata_piix.c
index a74e23d39ba..2d5be84d8bd 100644
--- a/drivers/scsi/ata_piix.c
+++ b/drivers/scsi/ata_piix.c
@@ -742,7 +742,7 @@ static int piix_disable_ahci(struct pci_dev *pdev)
/**
* piix_check_450nx_errata - Check for problem 450NX setup
* @ata_dev: the PCI device to check
- *
+ *
* Check for the present of 450NX errata #19 and errata #25. If
* they are found return an error code so we can turn off DMA
*/
@@ -753,7 +753,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
u16 cfg;
u8 rev;
int no_piix_dma = 0;
-
+
while((pdev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev)) != NULL)
{
/* Look for 450NX PXB. Check for problem configurations
@@ -772,7 +772,7 @@ static int __devinit piix_check_450nx_errata(struct pci_dev *ata_dev)
if(no_piix_dma == 2)
dev_printk(KERN_WARNING, &ata_dev->dev, "A BIOS update may resolve this.\n");
return no_piix_dma;
-}
+}
static void __devinit piix_init_sata_map(struct pci_dev *pdev,
struct ata_port_info *pinfo)
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index f4c1ca7c157..f677c5a32a6 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -239,17 +239,17 @@ static int atari_read_overruns = 0;
#endif
static int setup_can_queue = -1;
-MODULE_PARM(setup_can_queue, "i");
+module_param(setup_can_queue, int, 0);
static int setup_cmd_per_lun = -1;
-MODULE_PARM(setup_cmd_per_lun, "i");
+module_param(setup_cmd_per_lun, int, 0);
static int setup_sg_tablesize = -1;
-MODULE_PARM(setup_sg_tablesize, "i");
+module_param(setup_sg_tablesize, int, 0);
#ifdef SUPPORT_TAGS
static int setup_use_tagged_queuing = -1;
-MODULE_PARM(setup_use_tagged_queuing, "i");
+module_param(setup_use_tagged_queuing, int, 0);
#endif
static int setup_hostid = -1;
-MODULE_PARM(setup_hostid, "i");
+module_param(setup_hostid, int, 0);
#if defined(CONFIG_TT_DMA_EMUL)
diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c
index 45756fa9077..e6bcfe94934 100644
--- a/drivers/scsi/g_NCR5380.c
+++ b/drivers/scsi/g_NCR5380.c
@@ -127,7 +127,7 @@ static int ncr_53c400a = NCR_NOT_SET;
static int dtc_3181e = NCR_NOT_SET;
static struct override {
- NCR5380_implementation_fields;
+ NCR5380_map_type NCR5380_map_name;
int irq;
int dma;
int board; /* Use NCR53c400, Ricoh, etc. extensions ? */
@@ -299,6 +299,10 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
};
int flags = 0;
struct Scsi_Host *instance;
+#ifdef CONFIG_SCSI_G_NCR5380_MEM
+ unsigned long base;
+ void __iomem *iomem;
+#endif
if (ncr_irq != NCR_NOT_SET)
overrides[0].irq = ncr_irq;
@@ -424,15 +428,22 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
region_size = NCR5380_region_size;
}
#else
- if(!request_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size, "ncr5380"))
+ base = overrides[current_override].NCR5380_map_name;
+ if (!request_mem_region(base, NCR5380_region_size, "ncr5380"))
+ continue;
+ iomem = ioremap(base, NCR5380_region_size);
+ if (!iomem) {
+ release_mem_region(base, NCR5380_region_size);
continue;
+ }
#endif
instance = scsi_register(tpnt, sizeof(struct NCR5380_hostdata));
if (instance == NULL) {
#ifndef CONFIG_SCSI_G_NCR5380_MEM
release_region(overrides[current_override].NCR5380_map_name, region_size);
#else
- release_mem_region(overrides[current_override].NCR5380_map_name, NCR5380_region_size);
+ iounmap(iomem);
+ release_mem_region(base, NCR5380_region_size);
#endif
continue;
}
@@ -440,6 +451,8 @@ int __init generic_NCR5380_detect(struct scsi_host_template * tpnt)
instance->NCR5380_instance_name = overrides[current_override].NCR5380_map_name;
#ifndef CONFIG_SCSI_G_NCR5380_MEM
instance->n_io_port = region_size;
+#else
+ ((struct NCR5380_hostdata *)instance->hostdata).iomem = iomem;
#endif
NCR5380_init(instance, flags);
@@ -509,6 +522,7 @@ int generic_NCR5380_release_resources(struct Scsi_Host *instance)
#ifndef CONFIG_SCSI_G_NCR5380_MEM
release_region(instance->NCR5380_instance_name, instance->n_io_port);
#else
+ iounmap(((struct NCR5380_hostdata *)instance->hostdata).iomem);
release_mem_region(instance->NCR5380_instance_name, NCR5380_region_size);
#endif
@@ -586,7 +600,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
}
#else
/* implies CONFIG_SCSI_G_NCR5380_MEM */
- isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128);
+ memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
#endif
start += 128;
blocks--;
@@ -606,7 +620,7 @@ static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *dst,
}
#else
/* implies CONFIG_SCSI_G_NCR5380_MEM */
- isa_memcpy_fromio(dst + start, NCR53C400_host_buffer + NCR5380_map_name, 128);
+ memcpy_fromio(dst + start, iomem + NCR53C400_host_buffer, 128);
#endif
start += 128;
blocks--;
@@ -671,7 +685,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
}
#else
/* implies CONFIG_SCSI_G_NCR5380_MEM */
- isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128);
+ memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
#endif
start += 128;
blocks--;
@@ -687,7 +701,7 @@ static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *src,
}
#else
/* implies CONFIG_SCSI_G_NCR5380_MEM */
- isa_memcpy_toio(NCR53C400_host_buffer + NCR5380_map_name, src + start, 128);
+ memcpy_toio(iomem + NCR53C400_host_buffer, src + start, 128);
#endif
start += 128;
blocks--;
diff --git a/drivers/scsi/g_NCR5380.h b/drivers/scsi/g_NCR5380.h
index 656fbe2f91f..d60a89cb805 100644
--- a/drivers/scsi/g_NCR5380.h
+++ b/drivers/scsi/g_NCR5380.h
@@ -82,6 +82,15 @@ static const char* generic_NCR5380_info(struct Scsi_Host *);
#define NCR5380_read(reg) (inb(NCR5380_map_name + (reg)))
#define NCR5380_write(reg, value) (outb((value), (NCR5380_map_name + (reg))))
+#define NCR5380_implementation_fields \
+ NCR5380_map_type NCR5380_map_name
+
+#define NCR5380_local_declare() \
+ register NCR5380_implementation_fields
+
+#define NCR5380_setup(instance) \
+ NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name)
+
#else
/* therefore CONFIG_SCSI_G_NCR5380_MEM */
@@ -95,18 +104,20 @@ static const char* generic_NCR5380_info(struct Scsi_Host *);
#define NCR53C400_host_buffer 0x3900
#define NCR5380_region_size 0x3a00
-#define NCR5380_read(reg) isa_readb(NCR5380_map_name + NCR53C400_mem_base + (reg))
-#define NCR5380_write(reg, value) isa_writeb(value, NCR5380_map_name + NCR53C400_mem_base + (reg))
-#endif
+#define NCR5380_read(reg) readb(iomem + NCR53C400_mem_base + (reg))
+#define NCR5380_write(reg, value) writeb(value, iomem + NCR53C400_mem_base + (reg))
#define NCR5380_implementation_fields \
- NCR5380_map_type NCR5380_map_name
+ NCR5380_map_type NCR5380_map_name; \
+ void __iomem *iomem;
#define NCR5380_local_declare() \
- register NCR5380_implementation_fields
+ register void __iomem *iomem
#define NCR5380_setup(instance) \
- NCR5380_map_name = (NCR5380_map_type)((instance)->NCR5380_instance_name)
+ iomem = (((struct NCR5380_hostdata *)(instance)->hostdata).iomem)
+
+#endif
#define NCR5380_intr generic_NCR5380_intr
#define NCR5380_queue_command generic_NCR5380_queue_command
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 0cf0e4c7ac0..39b760a2424 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -47,6 +47,7 @@
#include <linux/ide.h>
#include <linux/scatterlist.h>
#include <linux/delay.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/bitops.h>
@@ -109,7 +110,7 @@ typedef struct ide_scsi_obj {
unsigned long log; /* log flags */
} idescsi_scsi_t;
-static DECLARE_MUTEX(idescsi_ref_sem);
+static DEFINE_MUTEX(idescsi_ref_mutex);
#define ide_scsi_g(disk) \
container_of((disk)->private_data, struct ide_scsi_obj, driver)
@@ -118,19 +119,19 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
{
struct ide_scsi_obj *scsi = NULL;
- down(&idescsi_ref_sem);
+ mutex_lock(&idescsi_ref_mutex);
scsi = ide_scsi_g(disk);
if (scsi)
scsi_host_get(scsi->host);
- up(&idescsi_ref_sem);
+ mutex_unlock(&idescsi_ref_mutex);
return scsi;
}
static void ide_scsi_put(struct ide_scsi_obj *scsi)
{
- down(&idescsi_ref_sem);
+ mutex_lock(&idescsi_ref_mutex);
scsi_host_put(scsi->host);
- up(&idescsi_ref_sem);
+ mutex_unlock(&idescsi_ref_mutex);
}
static inline idescsi_scsi_t *scsihost_to_idescsi(struct Scsi_Host *host)
diff --git a/drivers/scsi/in2000.c b/drivers/scsi/in2000.c
index 34daa3e068d..9c519876f8a 100644
--- a/drivers/scsi/in2000.c
+++ b/drivers/scsi/in2000.c
@@ -1898,6 +1898,21 @@ static int int_tab[] in2000__INITDATA = {
10
};
+static int probe_bios(u32 addr, u32 *s1, uchar *switches)
+{
+ void __iomem *p = ioremap(addr, 0x34);
+ if (!p)
+ return 0;
+ *s1 = readl(p + 0x10);
+ if (*s1 == 0x41564f4e || readl(p + 0x30) == 0x61776c41) {
+ /* Read the switch image that's mapped into EPROM space */
+ *switches = ~readb(p + 0x20);
+ iounmap(p);
+ return 1;
+ }
+ iounmap(p);
+ return 0;
+}
static int __init in2000_detect(struct scsi_host_template * tpnt)
{
@@ -1930,6 +1945,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
detect_count = 0;
for (bios = 0; bios_tab[bios]; bios++) {
+ u32 s1 = 0;
if (check_setup_args("ioport", &val, buf)) {
base = val;
switches = ~inb(base + IO_SWITCHES) & 0xff;
@@ -1941,13 +1957,9 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
* for the obvious ID strings. We look for the 2 most common ones and
* hope that they cover all the cases...
*/
- else if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e || isa_readl(bios_tab[bios] + 0x30) == 0x61776c41) {
+ else if (probe_bios(bios_tab[bios], &s1, &switches)) {
printk("Found IN2000 BIOS at 0x%x ", (unsigned int) bios_tab[bios]);
-/* Read the switch image that's mapped into EPROM space */
-
- switches = ~((isa_readb(bios_tab[bios] + 0x20) & 0xff));
-
/* Find out where the IO space is */
x = switches & (SW_ADDR0 | SW_ADDR1);
@@ -2037,7 +2049,7 @@ static int __init in2000_detect(struct scsi_host_template * tpnt)
/* Older BIOS's had a 'sync on/off' switch - use its setting */
- if (isa_readl(bios_tab[bios] + 0x10) == 0x41564f4e && (switches & SW_SYNC_DOS5))
+ if (s1 == 0x41564f4e && (switches & SW_SYNC_DOS5))
hostdata->sync_off = 0x00; /* sync defaults to on */
else
hostdata->sync_off = 0xff; /* sync defaults to off */
diff --git a/drivers/scsi/libata-bmdma.c b/drivers/scsi/libata-bmdma.c
index a93336adcd2..95d81d86d8b 100644
--- a/drivers/scsi/libata-bmdma.c
+++ b/drivers/scsi/libata-bmdma.c
@@ -214,6 +214,8 @@ static void ata_exec_command_pio(struct ata_port *ap, const struct ata_taskfile
* Issues MMIO write to ATA command register, with proper
* synchronization with interrupt handler / other threads.
*
+ * FIXME: missing write posting for 400nS delay enforcement
+ *
* LOCKING:
* spin_lock_irqsave(host_set lock)
*/
@@ -416,6 +418,240 @@ u8 ata_altstatus(struct ata_port *ap)
return inb(ap->ioaddr.altstatus_addr);
}
+/**
+ * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
+ * @qc: Info associated with this ATA transaction.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
+ u8 dmactl;
+ void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
+
+ /* load PRD table addr. */
+ mb(); /* make sure PRD table writes are visible to controller */
+ writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
+
+ /* specify data direction, triple-check start bit is clear */
+ dmactl = readb(mmio + ATA_DMA_CMD);
+ dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
+ if (!rw)
+ dmactl |= ATA_DMA_WR;
+ writeb(dmactl, mmio + ATA_DMA_CMD);
+
+ /* issue r/w command */
+ ap->ops->exec_command(ap, &qc->tf);
+}
+
+/**
+ * ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
+ * @qc: Info associated with this ATA transaction.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
+ u8 dmactl;
+
+ /* start host DMA transaction */
+ dmactl = readb(mmio + ATA_DMA_CMD);
+ writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
+
+ /* Strictly, one may wish to issue a readb() here, to
+ * flush the mmio write. However, control also passes
+ * to the hardware at this point, and it will interrupt
+ * us when we are to resume control. So, in effect,
+ * we don't care when the mmio write flushes.
+ * Further, a read of the DMA status register _immediately_
+ * following the write may not be what certain flaky hardware
+ * is expected, so I think it is best to not add a readb()
+ * without first all the MMIO ATA cards/mobos.
+ * Or maybe I'm just being paranoid.
+ */
+}
+
+/**
+ * ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
+ * @qc: Info associated with this ATA transaction.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
+ u8 dmactl;
+
+ /* load PRD table addr. */
+ outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
+
+ /* specify data direction, triple-check start bit is clear */
+ dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+ dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
+ if (!rw)
+ dmactl |= ATA_DMA_WR;
+ outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+
+ /* issue r/w command */
+ ap->ops->exec_command(ap, &qc->tf);
+}
+
+/**
+ * ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
+ * @qc: Info associated with this ATA transaction.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ u8 dmactl;
+
+ /* start host DMA transaction */
+ dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+ outb(dmactl | ATA_DMA_START,
+ ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+}
+
+
+/**
+ * ata_bmdma_start - Start a PCI IDE BMDMA transaction
+ * @qc: Info associated with this ATA transaction.
+ *
+ * Writes the ATA_DMA_START flag to the DMA command register.
+ *
+ * May be used as the bmdma_start() entry in ata_port_operations.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+void ata_bmdma_start(struct ata_queued_cmd *qc)
+{
+ if (qc->ap->flags & ATA_FLAG_MMIO)
+ ata_bmdma_start_mmio(qc);
+ else
+ ata_bmdma_start_pio(qc);
+}
+
+
+/**
+ * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
+ * @qc: Info associated with this ATA transaction.
+ *
+ * Writes address of PRD table to device's PRD Table Address
+ * register, sets the DMA control register, and calls
+ * ops->exec_command() to start the transfer.
+ *
+ * May be used as the bmdma_setup() entry in ata_port_operations.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+void ata_bmdma_setup(struct ata_queued_cmd *qc)
+{
+ if (qc->ap->flags & ATA_FLAG_MMIO)
+ ata_bmdma_setup_mmio(qc);
+ else
+ ata_bmdma_setup_pio(qc);
+}
+
+
+/**
+ * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
+ * @ap: Port associated with this ATA transaction.
+ *
+ * Clear interrupt and error flags in DMA status register.
+ *
+ * May be used as the irq_clear() entry in ata_port_operations.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+void ata_bmdma_irq_clear(struct ata_port *ap)
+{
+ if (!ap->ioaddr.bmdma_addr)
+ return;
+
+ if (ap->flags & ATA_FLAG_MMIO) {
+ void __iomem *mmio =
+ ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
+ writeb(readb(mmio), mmio);
+ } else {
+ unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
+ outb(inb(addr), addr);
+ }
+}
+
+
+/**
+ * ata_bmdma_status - Read PCI IDE BMDMA status
+ * @ap: Port associated with this ATA transaction.
+ *
+ * Read and return BMDMA status register.
+ *
+ * May be used as the bmdma_status() entry in ata_port_operations.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+u8 ata_bmdma_status(struct ata_port *ap)
+{
+ u8 host_stat;
+ if (ap->flags & ATA_FLAG_MMIO) {
+ void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
+ host_stat = readb(mmio + ATA_DMA_STATUS);
+ } else
+ host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
+ return host_stat;
+}
+
+
+/**
+ * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
+ * @qc: Command we are ending DMA for
+ *
+ * Clears the ATA_DMA_START flag in the dma control register
+ *
+ * May be used as the bmdma_stop() entry in ata_port_operations.
+ *
+ * LOCKING:
+ * spin_lock_irqsave(host_set lock)
+ */
+
+void ata_bmdma_stop(struct ata_queued_cmd *qc)
+{
+ struct ata_port *ap = qc->ap;
+ if (ap->flags & ATA_FLAG_MMIO) {
+ void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
+
+ /* clear start/stop bit */
+ writeb(readb(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
+ mmio + ATA_DMA_CMD);
+ } else {
+ /* clear start/stop bit */
+ outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
+ ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
+ }
+
+ /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
+ ata_altstatus(ap); /* dummy read */
+}
+
#ifdef CONFIG_PCI
static struct ata_probe_ent *
ata_probe_ent_alloc(struct device *dev, const struct ata_port_info *port)
@@ -648,6 +884,7 @@ int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info,
goto err_out_regions;
}
+ /* FIXME: If we get no DMA mask we should fall back to PIO */
rc = pci_set_dma_mask(pdev, ATA_DMA_MASK);
if (rc)
goto err_out_regions;
@@ -699,5 +936,41 @@ err_out:
return rc;
}
+/**
+ * ata_pci_clear_simplex - attempt to kick device out of simplex
+ * @pdev: PCI device
+ *
+ * Some PCI ATA devices report simplex mode but in fact can be told to
+ * enter non simplex mode. This implements the neccessary logic to
+ * perform the task on such devices. Calling it on other devices will
+ * have -undefined- behaviour.
+ */
+
+int ata_pci_clear_simplex(struct pci_dev *pdev)
+{
+ unsigned long bmdma = pci_resource_start(pdev, 4);
+ u8 simplex;
+
+ if (bmdma == 0)
+ return -ENOENT;
+
+ simplex = inb(bmdma + 0x02);
+ outb(simplex & 0x60, bmdma + 0x02);
+ simplex = inb(bmdma + 0x02);
+ if (simplex & 0x80)
+ return -EOPNOTSUPP;
+ return 0;
+}
+
+unsigned long ata_pci_default_filter(const struct ata_port *ap, struct ata_device *adev, unsigned long xfer_mask)
+{
+ /* Filter out DMA modes if the device has been configured by
+ the BIOS as PIO only */
+
+ if (ap->ioaddr.bmdma_addr == 0)
+ xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
+ return xfer_mask;
+}
+
#endif /* CONFIG_PCI */
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index 64dce00e9c4..d279666dcb3 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -64,9 +64,9 @@
static unsigned int ata_dev_init_params(struct ata_port *ap,
struct ata_device *dev);
static void ata_set_mode(struct ata_port *ap);
-static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev);
-static unsigned int ata_dev_xfermask(struct ata_port *ap,
- struct ata_device *dev);
+static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
+ struct ata_device *dev);
+static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev);
static unsigned int ata_unique_id = 1;
static struct workqueue_struct *ata_wq;
@@ -190,7 +190,7 @@ static const u8 ata_rw_cmds[] = {
* ata_rwcmd_protocol - set taskfile r/w commands and protocol
* @qc: command to examine and configure
*
- * Examine the device configuration and tf->flags to calculate
+ * Examine the device configuration and tf->flags to calculate
* the proper read/write commands and protocol to use.
*
* LOCKING:
@@ -203,7 +203,7 @@ int ata_rwcmd_protocol(struct ata_queued_cmd *qc)
u8 cmd;
int index, fua, lba48, write;
-
+
fua = (tf->flags & ATA_TFLAG_FUA) ? 4 : 0;
lba48 = (tf->flags & ATA_TFLAG_LBA48) ? 2 : 0;
write = (tf->flags & ATA_TFLAG_WRITE) ? 1 : 0;
@@ -252,6 +252,29 @@ static unsigned int ata_pack_xfermask(unsigned int pio_mask,
((udma_mask << ATA_SHIFT_UDMA) & ATA_MASK_UDMA);
}
+/**
+ * ata_unpack_xfermask - Unpack xfer_mask into pio, mwdma and udma masks
+ * @xfer_mask: xfer_mask to unpack
+ * @pio_mask: resulting pio_mask
+ * @mwdma_mask: resulting mwdma_mask
+ * @udma_mask: resulting udma_mask
+ *
+ * Unpack @xfer_mask into @pio_mask, @mwdma_mask and @udma_mask.
+ * Any NULL distination masks will be ignored.
+ */
+static void ata_unpack_xfermask(unsigned int xfer_mask,
+ unsigned int *pio_mask,
+ unsigned int *mwdma_mask,
+ unsigned int *udma_mask)
+{
+ if (pio_mask)
+ *pio_mask = (xfer_mask & ATA_MASK_PIO) >> ATA_SHIFT_PIO;
+ if (mwdma_mask)
+ *mwdma_mask = (xfer_mask & ATA_MASK_MWDMA) >> ATA_SHIFT_MWDMA;
+ if (udma_mask)
+ *udma_mask = (xfer_mask & ATA_MASK_UDMA) >> ATA_SHIFT_UDMA;
+}
+
static const struct ata_xfer_ent {
unsigned int shift, bits;
u8 base;
@@ -372,6 +395,15 @@ static const char *ata_mode_string(unsigned int xfer_mask)
return "<n/a>";
}
+static void ata_dev_disable(struct ata_port *ap, struct ata_device *dev)
+{
+ if (ata_dev_present(dev)) {
+ printk(KERN_WARNING "ata%u: dev %u disabled\n",
+ ap->id, dev->devno);
+ dev->class++;
+ }
+}
+
/**
* ata_pio_devchk - PATA device presence detection
* @ap: ATA channel to examine
@@ -962,6 +994,8 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
spin_unlock_irqrestore(&ap->host_set->lock, flags);
if (!wait_for_completion_timeout(&wait, ATA_TMOUT_INTERNAL)) {
+ ata_port_flush_task(ap);
+
spin_lock_irqsave(&ap->host_set->lock, flags);
/* We're racing with irq here. If we lose, the
@@ -985,6 +1019,22 @@ ata_exec_internal(struct ata_port *ap, struct ata_device *dev,
ata_qc_free(qc);
+ /* XXX - Some LLDDs (sata_mv) disable port on command failure.
+ * Until those drivers are fixed, we detect the condition
+ * here, fail the command with AC_ERR_SYSTEM and reenable the
+ * port.
+ *
+ * Note that this doesn't change any behavior as internal
+ * command failure results in disabling the device in the
+ * higher layer for LLDDs without new reset/EH callbacks.
+ *
+ * Kill the following code as soon as those drivers are fixed.
+ */
+ if (ap->flags & ATA_FLAG_PORT_DISABLED) {
+ err_mask |= AC_ERR_SYSTEM;
+ ata_port_probe(ap);
+ }
+
return err_mask;
}
@@ -1005,7 +1055,7 @@ unsigned int ata_pio_need_iordy(const struct ata_device *adev)
return 0;
if (speed > 2)
return 1;
-
+
/* If we have no drive specific rule, then PIO 2 is non IORDY */
if (adev->id[ATA_ID_FIELD_VALID] & 2) { /* EIDE */
@@ -1219,13 +1269,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
* common ATA, ATAPI feature tests
*/
- /* we require DMA support (bits 8 of word 49) */
- if (!ata_id_has_dma(id)) {
- printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
- rc = -EINVAL;
- goto err_out_nosup;
- }
-
/* find max transfer mode; for printk only */
xfer_mask = ata_id_xfermask(id);
@@ -1310,7 +1353,7 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
if (print_info)
printk(KERN_INFO "ata%u(%u): applying bridge limits\n",
ap->id, dev->devno);
- ap->udma_mask &= ATA_UDMA5;
+ dev->udma_mask &= ATA_UDMA5;
dev->max_sectors = ATA_MAX_SECTORS;
}
@@ -1321,8 +1364,6 @@ static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev,
return 0;
err_out_nosup:
- printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",
- ap->id, dev->devno);
DPRINTK("EXIT, err\n");
return rc;
}
@@ -1389,7 +1430,7 @@ static int ata_bus_probe(struct ata_port *ap)
}
if (ata_dev_configure(ap, dev, 1)) {
- dev->class++; /* disable device */
+ ata_dev_disable(ap, dev);
continue;
}
@@ -1535,6 +1576,23 @@ void sata_phy_reset(struct ata_port *ap)
}
/**
+ * ata_dev_pair - return other device on cable
+ * @ap: port
+ * @adev: device
+ *
+ * Obtain the other device on the same cable, or if none is
+ * present NULL is returned
+ */
+
+struct ata_device *ata_dev_pair(struct ata_port *ap, struct ata_device *adev)
+{
+ struct ata_device *pair = &ap->device[1 - adev->devno];
+ if (!ata_dev_present(pair))
+ return NULL;
+ return pair;
+}
+
+/**
* ata_port_disable - Disable port.
* @ap: Port to be disabled.
*
@@ -1562,7 +1620,7 @@ void ata_port_disable(struct ata_port *ap)
* PIO 0-5, MWDMA 0-2 and UDMA 0-6 timings (in nanoseconds).
* These were taken from ATA/ATAPI-6 standard, rev 0a, except
* for PIO 5, which is a nonstandard extension and UDMA6, which
- * is currently supported only by Maxtor drives.
+ * is currently supported only by Maxtor drives.
*/
static const struct ata_timing ata_timing[] = {
@@ -1577,11 +1635,11 @@ static const struct ata_timing ata_timing[] = {
{ XFER_UDMA_0, 0, 0, 0, 0, 0, 0, 0, 120 },
/* { XFER_UDMA_SLOW, 0, 0, 0, 0, 0, 0, 0, 150 }, */
-
+
{ XFER_MW_DMA_2, 25, 0, 0, 0, 70, 25, 120, 0 },
{ XFER_MW_DMA_1, 45, 0, 0, 0, 80, 50, 150, 0 },
{ XFER_MW_DMA_0, 60, 0, 0, 0, 215, 215, 480, 0 },
-
+
{ XFER_SW_DMA_2, 60, 0, 0, 0, 120, 120, 240, 0 },
{ XFER_SW_DMA_1, 90, 0, 0, 0, 240, 240, 480, 0 },
{ XFER_SW_DMA_0, 120, 0, 0, 0, 480, 480, 960, 0 },
@@ -1634,7 +1692,7 @@ static const struct ata_timing* ata_timing_find_mode(unsigned short speed)
for (t = ata_timing; t->mode != speed; t++)
if (t->mode == 0xFF)
return NULL;
- return t;
+ return t;
}
int ata_timing_compute(struct ata_device *adev, unsigned short speed,
@@ -1644,7 +1702,7 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
struct ata_timing p;
/*
- * Find the mode.
+ * Find the mode.
*/
if (!(s = ata_timing_find_mode(speed)))
@@ -1702,20 +1760,28 @@ int ata_timing_compute(struct ata_device *adev, unsigned short speed,
return 0;
}
-static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
+static int ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
{
- if (!ata_dev_present(dev) || (ap->flags & ATA_FLAG_PORT_DISABLED))
- return;
+ unsigned int err_mask;
+ int rc;
if (dev->xfer_shift == ATA_SHIFT_PIO)
dev->flags |= ATA_DFLAG_PIO;
- ata_dev_set_xfermode(ap, dev);
+ err_mask = ata_dev_set_xfermode(ap, dev);
+ if (err_mask) {
+ printk(KERN_ERR
+ "ata%u: failed to set xfermode (err_mask=0x%x)\n",
+ ap->id, err_mask);
+ return -EIO;
+ }
- if (ata_dev_revalidate(ap, dev, 0)) {
- printk(KERN_ERR "ata%u: failed to revalidate after set "
- "xfermode, disabled\n", ap->id);
- ata_port_disable(ap);
+ rc = ata_dev_revalidate(ap, dev, 0);
+ if (rc) {
+ printk(KERN_ERR
+ "ata%u: failed to revalidate after set xfermode\n",
+ ap->id);
+ return rc;
}
DPRINTK("xfer_shift=%u, xfer_mode=0x%x\n",
@@ -1724,6 +1790,7 @@ static void ata_dev_set_mode(struct ata_port *ap, struct ata_device *dev)
printk(KERN_INFO "ata%u: dev %u configured for %s\n",
ap->id, dev->devno,
ata_mode_string(ata_xfer_mode2mask(dev->xfer_mode)));
+ return 0;
}
static int ata_host_set_pio(struct ata_port *ap)
@@ -1737,7 +1804,7 @@ static int ata_host_set_pio(struct ata_port *ap)
continue;
if (!dev->pio_mode) {
- printk(KERN_WARNING "ata%u: no PIO support\n", ap->id);
+ printk(KERN_WARNING "ata%u: no PIO support for device %d.\n", ap->id, i);
return -1;
}
@@ -1783,16 +1850,19 @@ static void ata_set_mode(struct ata_port *ap)
/* step 1: calculate xfer_mask */
for (i = 0; i < ATA_MAX_DEVICES; i++) {
struct ata_device *dev = &ap->device[i];
- unsigned int xfer_mask;
+ unsigned int pio_mask, dma_mask;
if (!ata_dev_present(dev))
continue;
- xfer_mask = ata_dev_xfermask(ap, dev);
+ ata_dev_xfermask(ap, dev);
+
+ /* TODO: let LLDD filter dev->*_mask here */
- dev->pio_mode = ata_xfer_mask2mode(xfer_mask & ATA_MASK_PIO);
- dev->dma_mode = ata_xfer_mask2mode(xfer_mask & (ATA_MASK_MWDMA |
- ATA_MASK_UDMA));
+ pio_mask = ata_pack_xfermask(dev->pio_mask, 0, 0);
+ dma_mask = ata_pack_xfermask(0, dev->mwdma_mask, dev->udma_mask);
+ dev->pio_mode = ata_xfer_mask2mode(pio_mask);
+ dev->dma_mode = ata_xfer_mask2mode(dma_mask);
}
/* step 2: always set host PIO timings */
@@ -1804,11 +1874,15 @@ static void ata_set_mode(struct ata_port *ap)
ata_host_set_dma(ap);
/* step 4: update devices' xfer mode */
- for (i = 0; i < ATA_MAX_DEVICES; i++)
- ata_dev_set_mode(ap, &ap->device[i]);
+ for (i = 0; i < ATA_MAX_DEVICES; i++) {
+ struct ata_device *dev = &ap->device[i];
- if (ap->flags & ATA_FLAG_PORT_DISABLED)
- return;
+ if (!ata_dev_present(dev))
+ continue;
+
+ if (ata_dev_set_mode(ap, dev))
+ goto err_out;
+ }
if (ap->ops->post_set_mode)
ap->ops->post_set_mode(ap);
@@ -1999,9 +2073,19 @@ static unsigned int ata_bus_softreset(struct ata_port *ap,
* status is checked. Because waiting for "a while" before
* checking status is fine, post SRST, we perform this magic
* delay here as well.
+ *
+ * Old drivers/ide uses the 2mS rule and then waits for ready
*/
msleep(150);
+
+ /* Before we perform post reset processing we want to see if
+ the bus shows 0xFF because the odd clown forgets the D7 pulldown
+ resistor */
+
+ if (ata_check_status(ap) == 0xFF)
+ return 1; /* Positive is failure for some reason */
+
ata_bus_post_reset(ap, devmask);
return 0;
@@ -2551,48 +2635,72 @@ int ata_dev_revalidate(struct ata_port *ap, struct ata_device *dev,
}
static const char * const ata_dma_blacklist [] = {
- "WDC AC11000H",
- "WDC AC22100H",
- "WDC AC32500H",
- "WDC AC33100H",
- "WDC AC31600H",
- "WDC AC32100H",
- "WDC AC23200L",
- "Compaq CRD-8241B",
- "CRD-8400B",
- "CRD-8480B",
- "CRD-8482B",
- "CRD-84",
- "SanDisk SDP3B",
- "SanDisk SDP3B-64",
- "SANYO CD-ROM CRD",
- "HITACHI CDR-8",
- "HITACHI CDR-8335",
- "HITACHI CDR-8435",
- "Toshiba CD-ROM XM-6202B",
- "TOSHIBA CD-ROM XM-1702BC",
- "CD-532E-A",
- "E-IDE CD-ROM CR-840",
- "CD-ROM Drive/F5A",
- "WPI CDD-820",
- "SAMSUNG CD-ROM SC-148C",
- "SAMSUNG CD-ROM SC",
- "SanDisk SDP3B-64",
- "ATAPI CD-ROM DRIVE 40X MAXIMUM",
- "_NEC DV5800A",
+ "WDC AC11000H", NULL,
+ "WDC AC22100H", NULL,
+ "WDC AC32500H", NULL,
+ "WDC AC33100H", NULL,
+ "WDC AC31600H", NULL,
+ "WDC AC32100H", "24.09P07",
+ "WDC AC23200L", "21.10N21",
+ "Compaq CRD-8241B", NULL,
+ "CRD-8400B", NULL,
+ "CRD-8480B", NULL,
+ "CRD-8482B", NULL,
+ "CRD-84", NULL,
+ "SanDisk SDP3B", NULL,
+ "SanDisk SDP3B-64", NULL,
+ "SANYO CD-ROM CRD", NULL,
+ "HITACHI CDR-8", NULL,
+ "HITACHI CDR-8335", NULL,
+ "HITACHI CDR-8435", NULL,
+ "Toshiba CD-ROM XM-6202B", NULL,
+ "TOSHIBA CD-ROM XM-1702BC", NULL,
+ "CD-532E-A", NULL,
+ "E-IDE CD-ROM CR-840", NULL,
+ "CD-ROM Drive/F5A", NULL,
+ "WPI CDD-820", NULL,
+ "SAMSUNG CD-ROM SC-148C", NULL,
+ "SAMSUNG CD-ROM SC", NULL,
+ "SanDisk SDP3B-64", NULL,
+ "ATAPI CD-ROM DRIVE 40X MAXIMUM",NULL,
+ "_NEC DV5800A", NULL,
+ "SAMSUNG CD-ROM SN-124", "N001"
};
+static int ata_strim(char *s, size_t len)
+{
+ len = strnlen(s, len);
+
+ /* ATAPI specifies that empty space is blank-filled; remove blanks */
+ while ((len > 0) && (s[len - 1] == ' ')) {
+ len--;
+ s[len] = 0;
+ }
+ return len;
+}
+
static int ata_dma_blacklisted(const struct ata_device *dev)
{
- unsigned char model_num[41];
+ unsigned char model_num[40];
+ unsigned char model_rev[16];
+ unsigned int nlen, rlen;
int i;
- ata_id_c_string(dev->id, model_num, ATA_ID_PROD_OFS, sizeof(model_num));
-
- for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i++)
- if (!strcmp(ata_dma_blacklist[i], model_num))
- return 1;
+ ata_id_string(dev->id, model_num, ATA_ID_PROD_OFS,
+ sizeof(model_num));
+ ata_id_string(dev->id, model_rev, ATA_ID_FW_REV_OFS,
+ sizeof(model_rev));
+ nlen = ata_strim(model_num, sizeof(model_num));
+ rlen = ata_strim(model_rev, sizeof(model_rev));
+ for (i = 0; i < ARRAY_SIZE(ata_dma_blacklist); i += 2) {
+ if (!strncmp(ata_dma_blacklist[i], model_num, nlen)) {
+ if (ata_dma_blacklist[i+1] == NULL)
+ return 1;
+ if (!strncmp(ata_dma_blacklist[i], model_rev, rlen))
+ return 1;
+ }
+ }
return 0;
}
@@ -2601,18 +2709,15 @@ static int ata_dma_blacklisted(const struct ata_device *dev)
* @ap: Port on which the device to compute xfermask for resides
* @dev: Device to compute xfermask for
*
- * Compute supported xfermask of @dev. This function is
- * responsible for applying all known limits including host
- * controller limits, device blacklist, etc...
+ * Compute supported xfermask of @dev and store it in
+ * dev->*_mask. This function is responsible for applying all
+ * known limits including host controller limits, device
+ * blacklist, etc...
*
* LOCKING:
* None.
- *
- * RETURNS:
- * Computed xfermask.
*/
-static unsigned int ata_dev_xfermask(struct ata_port *ap,
- struct ata_device *dev)
+static void ata_dev_xfermask(struct ata_port *ap, struct ata_device *dev)
{
unsigned long xfer_mask;
int i;
@@ -2625,6 +2730,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
struct ata_device *d = &ap->device[i];
if (!ata_dev_present(d))
continue;
+ xfer_mask &= ata_pack_xfermask(d->pio_mask, d->mwdma_mask,
+ d->udma_mask);
xfer_mask &= ata_id_xfermask(d->id);
if (ata_dma_blacklisted(d))
xfer_mask &= ~(ATA_MASK_MWDMA | ATA_MASK_UDMA);
@@ -2634,7 +2741,8 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
printk(KERN_WARNING "ata%u: dev %u is on DMA blacklist, "
"disabling DMA\n", ap->id, dev->devno);
- return xfer_mask;
+ ata_unpack_xfermask(xfer_mask, &dev->pio_mask, &dev->mwdma_mask,
+ &dev->udma_mask);
}
/**
@@ -2647,11 +2755,16 @@ static unsigned int ata_dev_xfermask(struct ata_port *ap,
*
* LOCKING:
* PCI/etc. bus probe sem.
+ *
+ * RETURNS:
+ * 0 on success, AC_ERR_* mask otherwise.
*/
-static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
+static unsigned int ata_dev_set_xfermode(struct ata_port *ap,
+ struct ata_device *dev)
{
struct ata_taskfile tf;
+ unsigned int err_mask;
/* set up set-features taskfile */
DPRINTK("set features - xfer mode\n");
@@ -2663,13 +2776,10 @@ static void ata_dev_set_xfermode(struct ata_port *ap, struct ata_device *dev)
tf.protocol = ATA_PROT_NODATA;
tf.nsect = dev->xfer_mode;
- if (ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0)) {
- printk(KERN_ERR "ata%u: failed to set xfermode, disabled\n",
- ap->id);
- ata_port_disable(ap);
- }
+ err_mask = ata_exec_internal(ap, dev, &tf, DMA_NONE, NULL, 0);
- DPRINTK("EXIT\n");
+ DPRINTK("EXIT, err_mask=%x\n", err_mask);
+ return err_mask;
}
/**
@@ -2746,7 +2856,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
if (qc->flags & ATA_QCFLAG_SG) {
if (qc->n_elem)
- dma_unmap_sg(ap->host_set->dev, sg, qc->n_elem, dir);
+ dma_unmap_sg(ap->dev, sg, qc->n_elem, dir);
/* restore last sg */
sg[qc->orig_n_elem - 1].length += qc->pad_len;
if (pad_buf) {
@@ -2757,7 +2867,7 @@ static void ata_sg_clean(struct ata_queued_cmd *qc)
}
} else {
if (qc->n_elem)
- dma_unmap_single(ap->host_set->dev,
+ dma_unmap_single(ap->dev,
sg_dma_address(&sg[0]), sg_dma_len(&sg[0]),
dir);
/* restore sg */
@@ -2863,6 +2973,8 @@ void ata_qc_prep(struct ata_queued_cmd *qc)
ata_fill_sg(qc);
}
+void ata_noop_qc_prep(struct ata_queued_cmd *qc) { }
+
/**
* ata_sg_init_one - Associate command with memory buffer
* @qc: Command to be associated
@@ -2966,7 +3078,7 @@ static int ata_sg_setup_one(struct ata_queued_cmd *qc)
goto skip_map;
}
- dma_address = dma_map_single(ap->host_set->dev, qc->buf_virt,
+ dma_address = dma_map_single(ap->dev, qc->buf_virt,
sg->length, dir);
if (dma_mapping_error(dma_address)) {
/* restore sg */
@@ -3054,7 +3166,7 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
}
dir = qc->dma_dir;
- n_elem = dma_map_sg(ap->host_set->dev, sg, pre_n_elem, dir);
+ n_elem = dma_map_sg(ap->dev, sg, pre_n_elem, dir);
if (n_elem < 1) {
/* restore last sg */
lsg->length += qc->pad_len;
@@ -3585,7 +3697,7 @@ static void ata_pio_error(struct ata_port *ap)
if (qc->tf.command != ATA_CMD_PACKET)
printk(KERN_WARNING "ata%u: PIO error\n", ap->id);
- /* make sure qc->err_mask is available to
+ /* make sure qc->err_mask is available to
* know what's wrong and recover
*/
WARN_ON(qc->err_mask == 0);
@@ -3907,7 +4019,6 @@ static inline int ata_should_dma_map(struct ata_queued_cmd *qc)
case ATA_PROT_ATAPI:
case ATA_PROT_PIO:
- case ATA_PROT_PIO_MULT:
if (ap->flags & ATA_FLAG_PIO_DMA)
return 1;
@@ -4035,237 +4146,6 @@ unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc)
}
/**
- * ata_bmdma_setup_mmio - Set up PCI IDE BMDMA transaction
- * @qc: Info associated with this ATA transaction.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-static void ata_bmdma_setup_mmio (struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
- u8 dmactl;
- void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
-
- /* load PRD table addr. */
- mb(); /* make sure PRD table writes are visible to controller */
- writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
-
- /* specify data direction, triple-check start bit is clear */
- dmactl = readb(mmio + ATA_DMA_CMD);
- dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
- if (!rw)
- dmactl |= ATA_DMA_WR;
- writeb(dmactl, mmio + ATA_DMA_CMD);
-
- /* issue r/w command */
- ap->ops->exec_command(ap, &qc->tf);
-}
-
-/**
- * ata_bmdma_start_mmio - Start a PCI IDE BMDMA transaction
- * @qc: Info associated with this ATA transaction.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-static void ata_bmdma_start_mmio (struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
- u8 dmactl;
-
- /* start host DMA transaction */
- dmactl = readb(mmio + ATA_DMA_CMD);
- writeb(dmactl | ATA_DMA_START, mmio + ATA_DMA_CMD);
-
- /* Strictly, one may wish to issue a readb() here, to
- * flush the mmio write. However, control also passes
- * to the hardware at this point, and it will interrupt
- * us when we are to resume control. So, in effect,
- * we don't care when the mmio write flushes.
- * Further, a read of the DMA status register _immediately_
- * following the write may not be what certain flaky hardware
- * is expected, so I think it is best to not add a readb()
- * without first all the MMIO ATA cards/mobos.
- * Or maybe I'm just being paranoid.
- */
-}
-
-/**
- * ata_bmdma_setup_pio - Set up PCI IDE BMDMA transaction (PIO)
- * @qc: Info associated with this ATA transaction.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-static void ata_bmdma_setup_pio (struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- unsigned int rw = (qc->tf.flags & ATA_TFLAG_WRITE);
- u8 dmactl;
-
- /* load PRD table addr. */
- outl(ap->prd_dma, ap->ioaddr.bmdma_addr + ATA_DMA_TABLE_OFS);
-
- /* specify data direction, triple-check start bit is clear */
- dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
- dmactl &= ~(ATA_DMA_WR | ATA_DMA_START);
- if (!rw)
- dmactl |= ATA_DMA_WR;
- outb(dmactl, ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-
- /* issue r/w command */
- ap->ops->exec_command(ap, &qc->tf);
-}
-
-/**
- * ata_bmdma_start_pio - Start a PCI IDE BMDMA transaction (PIO)
- * @qc: Info associated with this ATA transaction.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-static void ata_bmdma_start_pio (struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- u8 dmactl;
-
- /* start host DMA transaction */
- dmactl = inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
- outb(dmactl | ATA_DMA_START,
- ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
-}
-
-
-/**
- * ata_bmdma_start - Start a PCI IDE BMDMA transaction
- * @qc: Info associated with this ATA transaction.
- *
- * Writes the ATA_DMA_START flag to the DMA command register.
- *
- * May be used as the bmdma_start() entry in ata_port_operations.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-void ata_bmdma_start(struct ata_queued_cmd *qc)
-{
- if (qc->ap->flags & ATA_FLAG_MMIO)
- ata_bmdma_start_mmio(qc);
- else
- ata_bmdma_start_pio(qc);
-}
-
-
-/**
- * ata_bmdma_setup - Set up PCI IDE BMDMA transaction
- * @qc: Info associated with this ATA transaction.
- *
- * Writes address of PRD table to device's PRD Table Address
- * register, sets the DMA control register, and calls
- * ops->exec_command() to start the transfer.
- *
- * May be used as the bmdma_setup() entry in ata_port_operations.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-void ata_bmdma_setup(struct ata_queued_cmd *qc)
-{
- if (qc->ap->flags & ATA_FLAG_MMIO)
- ata_bmdma_setup_mmio(qc);
- else
- ata_bmdma_setup_pio(qc);
-}
-
-
-/**
- * ata_bmdma_irq_clear - Clear PCI IDE BMDMA interrupt.
- * @ap: Port associated with this ATA transaction.
- *
- * Clear interrupt and error flags in DMA status register.
- *
- * May be used as the irq_clear() entry in ata_port_operations.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-void ata_bmdma_irq_clear(struct ata_port *ap)
-{
- if (ap->flags & ATA_FLAG_MMIO) {
- void __iomem *mmio = ((void __iomem *) ap->ioaddr.bmdma_addr) + ATA_DMA_STATUS;
- writeb(readb(mmio), mmio);
- } else {
- unsigned long addr = ap->ioaddr.bmdma_addr + ATA_DMA_STATUS;
- outb(inb(addr), addr);
- }
-
-}
-
-
-/**
- * ata_bmdma_status - Read PCI IDE BMDMA status
- * @ap: Port associated with this ATA transaction.
- *
- * Read and return BMDMA status register.
- *
- * May be used as the bmdma_status() entry in ata_port_operations.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-u8 ata_bmdma_status(struct ata_port *ap)
-{
- u8 host_stat;
- if (ap->flags & ATA_FLAG_MMIO) {
- void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
- host_stat = readb(mmio + ATA_DMA_STATUS);
- } else
- host_stat = inb(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
- return host_stat;
-}
-
-
-/**
- * ata_bmdma_stop - Stop PCI IDE BMDMA transfer
- * @qc: Command we are ending DMA for
- *
- * Clears the ATA_DMA_START flag in the dma control register
- *
- * May be used as the bmdma_stop() entry in ata_port_operations.
- *
- * LOCKING:
- * spin_lock_irqsave(host_set lock)
- */
-
-void ata_bmdma_stop(struct ata_queued_cmd *qc)
-{
- struct ata_port *ap = qc->ap;
- if (ap->flags & ATA_FLAG_MMIO) {
- void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
-
- /* clear start/stop bit */
- writeb(readb(mmio + ATA_DMA_CMD) & ~ATA_DMA_START,
- mmio + ATA_DMA_CMD);
- } else {
- /* clear start/stop bit */
- outb(inb(ap->ioaddr.bmdma_addr + ATA_DMA_CMD) & ~ATA_DMA_START,
- ap->ioaddr.bmdma_addr + ATA_DMA_CMD);
- }
-
- /* one-PIO-cycle guaranteed wait, per spec, for HDMA1:0 transition */
- ata_altstatus(ap); /* dummy read */
-}
-
-/**
* ata_host_intr - Handle host interrupt for given (port, task)
* @ap: Port on which interrupt arrived (possibly...)
* @qc: Taskfile currently active in engine
@@ -4337,9 +4217,9 @@ idle_irq:
#ifdef ATA_IRQ_TRAP
if ((ap->stats.idle_irq % 1000) == 0) {
- handled = 1;
ata_irq_ack(ap, 0); /* debug trap */
printk(KERN_WARNING "ata%d: irq trap\n", ap->id);
+ return 1;
}
#endif
return 0; /* irq not handled */
@@ -4473,14 +4353,15 @@ int ata_device_resume(struct ata_port *ap, struct ata_device *dev)
* Flush the cache on the drive, if appropriate, then issue a
* standbynow command.
*/
-int ata_device_suspend(struct ata_port *ap, struct ata_device *dev)
+int ata_device_suspend(struct ata_port *ap, struct ata_device *dev, pm_message_t state)
{
if (!ata_dev_present(dev))
return 0;
if (dev->class == ATA_DEV_ATA)
ata_flush_cache(ap, dev);
- ata_standby_drive(ap, dev);
+ if (state.event != PM_EVENT_FREEZE)
+ ata_standby_drive(ap, dev);
ap->flags |= ATA_FLAG_SUSPENDED;
return 0;
}
@@ -4500,7 +4381,7 @@ int ata_device_suspend(struct ata_port *ap, struct ata_device *dev)
int ata_port_start (struct ata_port *ap)
{
- struct device *dev = ap->host_set->dev;
+ struct device *dev = ap->dev;
int rc;
ap->prd = dma_alloc_coherent(dev, ATA_PRD_TBL_SZ, &ap->prd_dma, GFP_KERNEL);
@@ -4533,7 +4414,7 @@ int ata_port_start (struct ata_port *ap)
void ata_port_stop (struct ata_port *ap)
{
- struct device *dev = ap->host_set->dev;
+ struct device *dev = ap->dev;
dma_free_coherent(dev, ATA_PRD_TBL_SZ, ap->prd, ap->prd_dma);
ata_pad_free(ap, dev);
@@ -4599,6 +4480,7 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
ap->host = host;
ap->ctl = ATA_DEVCTL_OBS;
ap->host_set = host_set;
+ ap->dev = ent->dev;
ap->port_no = port_no;
ap->hard_port_no =
ent->legacy_mode ? ent->hard_port_no : port_no;
@@ -4614,8 +4496,13 @@ static void ata_host_init(struct ata_port *ap, struct Scsi_Host *host,
INIT_WORK(&ap->port_task, NULL, NULL);
INIT_LIST_HEAD(&ap->eh_done_q);
- for (i = 0; i < ATA_MAX_DEVICES; i++)
- ap->device[i].devno = i;
+ for (i = 0; i < ATA_MAX_DEVICES; i++) {
+ struct ata_device *dev = &ap->device[i];
+ dev->devno = i;
+ dev->pio_mask = UINT_MAX;
+ dev->mwdma_mask = UINT_MAX;
+ dev->udma_mask = UINT_MAX;
+ }
#ifdef ATA_IRQ_TRAP
ap->stats.unhandled_irq = 1;
@@ -4809,7 +4696,7 @@ err_free_ret:
* ata_host_set_remove - PCI layer callback for device removal
* @host_set: ATA host set that was removed
*
- * Unregister all objects associated with this host set. Free those
+ * Unregister all objects associated with this host set. Free those
* objects.
*
* LOCKING:
@@ -5064,6 +4951,7 @@ EXPORT_SYMBOL_GPL(ata_port_stop);
EXPORT_SYMBOL_GPL(ata_host_stop);
EXPORT_SYMBOL_GPL(ata_interrupt);
EXPORT_SYMBOL_GPL(ata_qc_prep);
+EXPORT_SYMBOL_GPL(ata_noop_qc_prep);
EXPORT_SYMBOL_GPL(ata_bmdma_setup);
EXPORT_SYMBOL_GPL(ata_bmdma_start);
EXPORT_SYMBOL_GPL(ata_bmdma_irq_clear);
@@ -5080,6 +4968,8 @@ EXPORT_SYMBOL_GPL(ata_std_postreset);
EXPORT_SYMBOL_GPL(ata_std_probe_reset);
EXPORT_SYMBOL_GPL(ata_drive_probe_reset);
EXPORT_SYMBOL_GPL(ata_dev_revalidate);
+EXPORT_SYMBOL_GPL(ata_dev_classify);
+EXPORT_SYMBOL_GPL(ata_dev_pair);
EXPORT_SYMBOL_GPL(ata_port_disable);
EXPORT_SYMBOL_GPL(ata_ratelimit);
EXPORT_SYMBOL_GPL(ata_busy_sleep);
@@ -5090,7 +4980,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_error);
EXPORT_SYMBOL_GPL(ata_scsi_slave_config);
EXPORT_SYMBOL_GPL(ata_scsi_release);
EXPORT_SYMBOL_GPL(ata_host_intr);
-EXPORT_SYMBOL_GPL(ata_dev_classify);
EXPORT_SYMBOL_GPL(ata_id_string);
EXPORT_SYMBOL_GPL(ata_id_c_string);
EXPORT_SYMBOL_GPL(ata_scsi_simulate);
@@ -5109,6 +4998,8 @@ EXPORT_SYMBOL_GPL(ata_pci_init_one);
EXPORT_SYMBOL_GPL(ata_pci_remove_one);
EXPORT_SYMBOL_GPL(ata_pci_device_suspend);
EXPORT_SYMBOL_GPL(ata_pci_device_resume);
+EXPORT_SYMBOL_GPL(ata_pci_default_filter);
+EXPORT_SYMBOL_GPL(ata_pci_clear_simplex);
#endif /* CONFIG_PCI */
EXPORT_SYMBOL_GPL(ata_device_suspend);
diff --git a/drivers/scsi/libata-scsi.c b/drivers/scsi/libata-scsi.c
index bd9f2176f79..628191bfd99 100644
--- a/drivers/scsi/libata-scsi.c
+++ b/drivers/scsi/libata-scsi.c
@@ -256,7 +256,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
scsi_cmd[14] = args[0];
/* Good values for timeout and retries? Values below
- from scsi_ioctl_send_command() for default case... */
+ from scsi_ioctl_send_command() for default case... */
if (scsi_execute_req(scsidev, scsi_cmd, DMA_NONE, NULL, 0, &sshdr,
(10*HZ), 5))
rc = -EIO;
@@ -267,20 +267,8 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
{
- struct ata_port *ap;
- struct ata_device *dev;
int val = -EINVAL, rc = -EINVAL;
- ap = (struct ata_port *) &scsidev->host->hostdata[0];
- if (!ap)
- goto out;
-
- dev = ata_scsi_find_dev(ap, scsidev);
- if (!dev) {
- rc = -ENODEV;
- goto out;
- }
-
switch (cmd) {
case ATA_IOC_GET_IO32:
val = 0;
@@ -309,7 +297,6 @@ int ata_scsi_ioctl(struct scsi_device *scsidev, int cmd, void __user *arg)
break;
}
-out:
return rc;
}
@@ -414,12 +401,12 @@ int ata_scsi_device_resume(struct scsi_device *sdev)
return ata_device_resume(ap, dev);
}
-int ata_scsi_device_suspend(struct scsi_device *sdev)
+int ata_scsi_device_suspend(struct scsi_device *sdev, pm_message_t state)
{
struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0];
struct ata_device *dev = &ap->device[sdev->id];
- return ata_device_suspend(ap, dev);
+ return ata_device_suspend(ap, dev, state);
}
/**
@@ -438,7 +425,7 @@ int ata_scsi_device_suspend(struct scsi_device *sdev)
* LOCKING:
* spin_lock_irqsave(host_set lock)
*/
-void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
+void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
u8 *ascq)
{
int i;
@@ -495,7 +482,7 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
/* Look for drv_err */
for (i = 0; sense_table[i][0] != 0xFF; i++) {
/* Look for best matches first */
- if ((sense_table[i][0] & drv_err) ==
+ if ((sense_table[i][0] & drv_err) ==
sense_table[i][0]) {
*sk = sense_table[i][1];
*asc = sense_table[i][2];
@@ -518,16 +505,14 @@ void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc,
}
}
/* No error? Undecoded? */
- printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
+ printk(KERN_WARNING "ata%u: no sense translation for status: 0x%02x\n",
id, drv_stat);
- /* For our last chance pick, use medium read error because
- * it's much more common than an ATA drive telling you a write
- * has failed.
- */
- *sk = MEDIUM_ERROR;
- *asc = 0x11; /* "unrecovered read error" */
- *ascq = 0x04; /* "auto-reallocation failed" */
+ /* We need a sensible error return here, which is tricky, and one
+ that won't cause people to do things like return a disk wrongly */
+ *sk = ABORTED_COMMAND;
+ *asc = 0x00;
+ *ascq = 0x00;
translate_done:
printk(KERN_ERR "ata%u: translated ATA stat/err 0x%02x/%02x to "
@@ -672,6 +657,41 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
}
}
+static void ata_scsi_sdev_config(struct scsi_device *sdev)
+{
+ sdev->use_10_for_rw = 1;
+ sdev->use_10_for_ms = 1;
+}
+
+static void ata_scsi_dev_config(struct scsi_device *sdev,
+ struct ata_device *dev)
+{
+ unsigned int max_sectors;
+
+ /* TODO: 2048 is an arbitrary number, not the
+ * hardware maximum. This should be increased to
+ * 65534 when Jens Axboe's patch for dynamically
+ * determining max_sectors is merged.
+ */
+ max_sectors = ATA_MAX_SECTORS;
+ if (dev->flags & ATA_DFLAG_LBA48)
+ max_sectors = 2048;
+ if (dev->max_sectors)
+ max_sectors = dev->max_sectors;
+
+ blk_queue_max_sectors(sdev->request_queue, max_sectors);
+
+ /*
+ * SATA DMA transfers must be multiples of 4 byte, so
+ * we need to pad ATAPI transfers using an extra sg.
+ * Decrement max hw segments accordingly.
+ */
+ if (dev->class == ATA_DEV_ATAPI) {
+ request_queue_t *q = sdev->request_queue;
+ blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
+ }
+}
+
/**
* ata_scsi_slave_config - Set SCSI device attributes
* @sdev: SCSI device to examine
@@ -686,41 +706,18 @@ void ata_gen_fixed_sense(struct ata_queued_cmd *qc)
int ata_scsi_slave_config(struct scsi_device *sdev)
{
- sdev->use_10_for_rw = 1;
- sdev->use_10_for_ms = 1;
+ ata_scsi_sdev_config(sdev);
blk_queue_max_phys_segments(sdev->request_queue, LIBATA_MAX_PRD);
if (sdev->id < ATA_MAX_DEVICES) {
struct ata_port *ap;
struct ata_device *dev;
- unsigned int max_sectors;
ap = (struct ata_port *) &sdev->host->hostdata[0];
dev = &ap->device[sdev->id];
- /* TODO: 2048 is an arbitrary number, not the
- * hardware maximum. This should be increased to
- * 65534 when Jens Axboe's patch for dynamically
- * determining max_sectors is merged.
- */
- max_sectors = ATA_MAX_SECTORS;
- if (dev->flags & ATA_DFLAG_LBA48)
- max_sectors = 2048;
- if (dev->max_sectors)
- max_sectors = dev->max_sectors;
-
- blk_queue_max_sectors(sdev->request_queue, max_sectors);
-
- /*
- * SATA DMA transfers must be multiples of 4 byte, so
- * we need to pad ATAPI transfers using an extra sg.
- * Decrement max hw segments accordingly.
- */
- if (dev->class == ATA_DEV_ATAPI) {
- request_queue_t *q = sdev->request_queue;
- blk_queue_max_hw_segments(q, q->max_hw_segments - 1);
- }
+ ata_scsi_dev_config(sdev, dev);
}
return 0; /* scsi layer doesn't check return value, sigh */
@@ -1140,14 +1137,14 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc, const u8 *sc
DPRINTK("block %u track %u cyl %u head %u sect %u\n",
(u32)block, track, cyl, head, sect);
-
- /* Check whether the converted CHS can fit.
- Cylinder: 0-65535
+
+ /* Check whether the converted CHS can fit.
+ Cylinder: 0-65535
Head: 0-15
Sector: 1-255*/
- if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
+ if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
goto out_of_range;
-
+
tf->command = ATA_CMD_VERIFY;
tf->nsect = n_block & 0xff; /* Sector count 0 means 256 sectors */
tf->lbal = sect;
@@ -1279,7 +1276,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
tf->lbal = block & 0xff;
tf->device |= ATA_LBA;
- } else {
+ } else {
/* CHS */
u32 sect, head, cyl, track;
@@ -1299,8 +1296,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc, const u8 *scsicm
DPRINTK("block %u track %u cyl %u head %u sect %u\n",
(u32)block, track, cyl, head, sect);
- /* Check whether the converted CHS can fit.
- Cylinder: 0-65535
+ /* Check whether the converted CHS can fit.
+ Cylinder: 0-65535
Head: 0-15
Sector: 1-255*/
if ((cyl >> 16) || (head >> 4) || (sect >> 8) || (!sect))
@@ -1552,7 +1549,7 @@ void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
* @buflen: Response buffer length.
*
* Returns standard device identification data associated
- * with non-EVPD INQUIRY command output.
+ * with non-VPD INQUIRY command output.
*
* LOCKING:
* spin_lock_irqsave(host_set lock)
@@ -1603,12 +1600,12 @@ unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf,
}
/**
- * ata_scsiop_inq_00 - Simulate INQUIRY EVPD page 0, list of pages
+ * ata_scsiop_inq_00 - Simulate INQUIRY VPD page 0, list of pages
* @args: device IDENTIFY data / SCSI command of interest.
* @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
* @buflen: Response buffer length.
*
- * Returns list of inquiry EVPD pages available.
+ * Returns list of inquiry VPD pages available.
*
* LOCKING:
* spin_lock_irqsave(host_set lock)
@@ -1622,7 +1619,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
0x80, /* page 0x80, unit serial no page */
0x83 /* page 0x83, device ident page */
};
- rbuf[3] = sizeof(pages); /* number of supported EVPD pages */
+ rbuf[3] = sizeof(pages); /* number of supported VPD pages */
if (buflen > 6)
memcpy(rbuf + 4, pages, sizeof(pages));
@@ -1631,7 +1628,7 @@ unsigned int ata_scsiop_inq_00(struct ata_scsi_args *args, u8 *rbuf,
}
/**
- * ata_scsiop_inq_80 - Simulate INQUIRY EVPD page 80, device serial number
+ * ata_scsiop_inq_80 - Simulate INQUIRY VPD page 80, device serial number
* @args: device IDENTIFY data / SCSI command of interest.
* @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
* @buflen: Response buffer length.
@@ -1660,16 +1657,16 @@ unsigned int ata_scsiop_inq_80(struct ata_scsi_args *args, u8 *rbuf,
return 0;
}
-static const char * const inq_83_str = "Linux ATA-SCSI simulator";
-
/**
- * ata_scsiop_inq_83 - Simulate INQUIRY EVPD page 83, device identity
+ * ata_scsiop_inq_83 - Simulate INQUIRY VPD page 83, device identity
* @args: device IDENTIFY data / SCSI command of interest.
* @rbuf: Response buffer, to which simulated SCSI cmd output is sent.
* @buflen: Response buffer length.
*
- * Returns device identification. Currently hardcoded to
- * return "Linux ATA-SCSI simulator".
+ * Yields two logical unit device identification designators:
+ * - vendor specific ASCII containing the ATA serial number
+ * - SAT defined "t10 vendor id based" containing ASCII vendor
+ * name ("ATA "), model and serial numbers.
*
* LOCKING:
* spin_lock_irqsave(host_set lock)
@@ -1678,16 +1675,39 @@ static const char * const inq_83_str = "Linux ATA-SCSI simulator";
unsigned int ata_scsiop_inq_83(struct ata_scsi_args *args, u8 *rbuf,
unsigned int buflen)
{
- rbuf[1] = 0x83; /* this page code */
- rbuf[3] = 4 + strlen(inq_83_str); /* page len */
+ int num;
+ const int sat_model_serial_desc_len = 68;
+ const int ata_model_byte_len = 40;
- /* our one and only identification descriptor (vendor-specific) */
- if (buflen > (strlen(inq_83_str) + 4 + 4 - 1)) {
- rbuf[4 + 0] = 2; /* code set: ASCII */
- rbuf[4 + 3] = strlen(inq_83_str);
- memcpy(rbuf + 4 + 4, inq_83_str, strlen(inq_83_str));
+ rbuf[1] = 0x83; /* this page code */
+ num = 4;
+
+ if (buflen > (ATA_SERNO_LEN + num + 3)) {
+ /* piv=0, assoc=lu, code_set=ACSII, designator=vendor */
+ rbuf[num + 0] = 2;
+ rbuf[num + 3] = ATA_SERNO_LEN;
+ num += 4;
+ ata_id_string(args->id, (unsigned char *) rbuf + num,
+ ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+ num += ATA_SERNO_LEN;
}
-
+ if (buflen > (sat_model_serial_desc_len + num + 3)) {
+ /* SAT defined lu model and serial numbers descriptor */
+ /* piv=0, assoc=lu, code_set=ACSII, designator=t10 vendor id */
+ rbuf[num + 0] = 2;
+ rbuf[num + 1] = 1;
+ rbuf[num + 3] = sat_model_serial_desc_len;
+ num += 4;
+ memcpy(rbuf + num, "ATA ", 8);
+ num += 8;
+ ata_id_string(args->id, (unsigned char *) rbuf + num,
+ ATA_ID_PROD_OFS, ata_model_byte_len);
+ num += ata_model_byte_len;
+ ata_id_string(args->id, (unsigned char *) rbuf + num,
+ ATA_ID_SERNO_OFS, ATA_SERNO_LEN);
+ num += ATA_SERNO_LEN;
+ }
+ rbuf[3] = num - 4; /* page len (assume less than 256 bytes) */
return 0;
}
@@ -2366,9 +2386,6 @@ ata_scsi_map_proto(u8 byte1)
case 4: /* PIO Data-in */
case 5: /* PIO Data-out */
- if (byte1 & 0xe0) {
- return ATA_PROT_PIO_MULT;
- }
return ATA_PROT_PIO;
case 10: /* Device Reset */
@@ -2407,6 +2424,10 @@ ata_scsi_pass_thru(struct ata_queued_cmd *qc, const u8 *scsicmd)
if ((tf->protocol = ata_scsi_map_proto(scsicmd[1])) == ATA_PROT_UNKNOWN)
goto invalid_fld;
+ if (scsicmd[1] & 0xe0)
+ /* PIO multi not supported yet */
+ goto invalid_fld;
+
/*
* 12 and 16 byte CDBs use different offsets to
* provide the various register values.
@@ -2563,6 +2584,21 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap,
#endif
}
+static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
+ struct ata_port *ap, struct ata_device *dev)
+{
+ if (dev->class == ATA_DEV_ATA) {
+ ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
+ cmd->cmnd[0]);
+
+ if (xlat_func)
+ ata_scsi_translate(ap, dev, cmd, done, xlat_func);
+ else
+ ata_scsi_simulate(ap, dev, cmd, done);
+ } else
+ ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
+}
+
/**
* ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
* @cmd: SCSI command to be sent
@@ -2597,24 +2633,13 @@ int ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
ata_scsi_dump_cdb(ap, cmd);
dev = ata_scsi_find_dev(ap, scsidev);
- if (unlikely(!dev)) {
+ if (likely(dev))
+ __ata_scsi_queuecmd(cmd, done, ap, dev);
+ else {
cmd->result = (DID_BAD_TARGET << 16);
done(cmd);
- goto out_unlock;
}
- if (dev->class == ATA_DEV_ATA) {
- ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
- cmd->cmnd[0]);
-
- if (xlat_func)
- ata_scsi_translate(ap, dev, cmd, done, xlat_func);
- else
- ata_scsi_simulate(ap, dev, cmd, done);
- } else
- ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
-
-out_unlock:
spin_unlock(&ap->host_set->lock);
spin_lock(shost->host_lock);
return 0;
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index bf9f7f7ba35..c11e5ce6865 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -2797,7 +2797,7 @@ mbox_post_sync_cmd(adapter_t *adapter, uint8_t raw_mbox[])
// available within 1 second, assume FW is initializing and wait
// for an extended amount of time
if (mbox->numstatus == 0xFF) { // status not yet available
- udelay(25);;
+ udelay(25);
for (i = 0; mbox->numstatus == 0xFF && i < 1000; i++) {
rmb();
diff --git a/drivers/scsi/pdc_adma.c b/drivers/scsi/pdc_adma.c
index b3dc5f85ae0..3c85c4b66e1 100644
--- a/drivers/scsi/pdc_adma.c
+++ b/drivers/scsi/pdc_adma.c
@@ -321,7 +321,7 @@ static int adma_fill_sg(struct ata_queued_cmd *qc)
= (pFLAGS & pEND) ? 0 : cpu_to_le32(pp->pkt_dma + i + 4);
i += 4;
- VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", nelem,
+ VPRINTK("PRD[%u] = (0x%lX, 0x%X)\n", i/4,
(unsigned long)addr, len);
}
return i;
diff --git a/drivers/scsi/sata_mv.c b/drivers/scsi/sata_mv.c
index 874c5be0843..275ed9bd898 100644
--- a/drivers/scsi/sata_mv.c
+++ b/drivers/scsi/sata_mv.c
@@ -1262,6 +1262,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
void __iomem *port_mmio = mv_ap_base(ap);
struct mv_port_priv *pp = ap->private_data;
u32 out_ptr;
+ u8 ata_status;
out_ptr = readl(port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
@@ -1269,6 +1270,8 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
WARN_ON(((out_ptr >> EDMA_RSP_Q_PTR_SHIFT) & MV_MAX_Q_DEPTH_MASK) !=
pp->rsp_consumer);
+ ata_status = pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT;
+
/* increment our consumer index... */
pp->rsp_consumer = mv_inc_q_index(&pp->rsp_consumer);
@@ -1283,7 +1286,7 @@ static u8 mv_get_crpb_status(struct ata_port *ap)
writelfl(out_ptr, port_mmio + EDMA_RSP_Q_OUT_PTR_OFS);
/* Return ATA status register for completed CRPB */
- return (pp->crpb[pp->rsp_consumer].flags >> CRPB_FLAG_STATUS_SHIFT);
+ return ata_status;
}
/**
diff --git a/drivers/scsi/sata_nv.c b/drivers/scsi/sata_nv.c
index e5b20c6afc1..f77bf183dfa 100644
--- a/drivers/scsi/sata_nv.c
+++ b/drivers/scsi/sata_nv.c
@@ -29,34 +29,6 @@
* NV-specific details such as register offsets, SATA phy location,
* hotplug info, etc.
*
- * 0.10
- * - Fixed spurious interrupts issue seen with the Maxtor 6H500F0 500GB
- * drive. Also made the check_hotplug() callbacks return whether there
- * was a hotplug interrupt or not. This was not the source of the
- * spurious interrupts, but is the right thing to do anyway.
- *
- * 0.09
- * - Fixed bug introduced by 0.08's MCP51 and MCP55 support.
- *
- * 0.08
- * - Added support for MCP51 and MCP55.
- *
- * 0.07
- * - Added support for RAID class code.
- *
- * 0.06
- * - Added generic SATA support by using a pci_device_id that filters on
- * the IDE storage class code.
- *
- * 0.03
- * - Fixed a bug where the hotplug handlers for non-CK804/MCP04 were using
- * mmio_base, which is only set for the CK804/MCP04 case.
- *
- * 0.02
- * - Added support for CK804 SATA controller.
- *
- * 0.01
- * - Initial revision.
*/
#include <linux/config.h>
@@ -74,53 +46,55 @@
#define DRV_NAME "sata_nv"
#define DRV_VERSION "0.8"
-#define NV_PORTS 2
-#define NV_PIO_MASK 0x1f
-#define NV_MWDMA_MASK 0x07
-#define NV_UDMA_MASK 0x7f
-#define NV_PORT0_SCR_REG_OFFSET 0x00
-#define NV_PORT1_SCR_REG_OFFSET 0x40
-
-#define NV_INT_STATUS 0x10
-#define NV_INT_STATUS_CK804 0x440
-#define NV_INT_STATUS_PDEV_INT 0x01
-#define NV_INT_STATUS_PDEV_PM 0x02
-#define NV_INT_STATUS_PDEV_ADDED 0x04
-#define NV_INT_STATUS_PDEV_REMOVED 0x08
-#define NV_INT_STATUS_SDEV_INT 0x10
-#define NV_INT_STATUS_SDEV_PM 0x20
-#define NV_INT_STATUS_SDEV_ADDED 0x40
-#define NV_INT_STATUS_SDEV_REMOVED 0x80
-#define NV_INT_STATUS_PDEV_HOTPLUG (NV_INT_STATUS_PDEV_ADDED | \
- NV_INT_STATUS_PDEV_REMOVED)
-#define NV_INT_STATUS_SDEV_HOTPLUG (NV_INT_STATUS_SDEV_ADDED | \
- NV_INT_STATUS_SDEV_REMOVED)
-#define NV_INT_STATUS_HOTPLUG (NV_INT_STATUS_PDEV_HOTPLUG | \
- NV_INT_STATUS_SDEV_HOTPLUG)
-
-#define NV_INT_ENABLE 0x11
-#define NV_INT_ENABLE_CK804 0x441
-#define NV_INT_ENABLE_PDEV_MASK 0x01
-#define NV_INT_ENABLE_PDEV_PM 0x02
-#define NV_INT_ENABLE_PDEV_ADDED 0x04
-#define NV_INT_ENABLE_PDEV_REMOVED 0x08
-#define NV_INT_ENABLE_SDEV_MASK 0x10
-#define NV_INT_ENABLE_SDEV_PM 0x20
-#define NV_INT_ENABLE_SDEV_ADDED 0x40
-#define NV_INT_ENABLE_SDEV_REMOVED 0x80
-#define NV_INT_ENABLE_PDEV_HOTPLUG (NV_INT_ENABLE_PDEV_ADDED | \
- NV_INT_ENABLE_PDEV_REMOVED)
-#define NV_INT_ENABLE_SDEV_HOTPLUG (NV_INT_ENABLE_SDEV_ADDED | \
- NV_INT_ENABLE_SDEV_REMOVED)
-#define NV_INT_ENABLE_HOTPLUG (NV_INT_ENABLE_PDEV_HOTPLUG | \
- NV_INT_ENABLE_SDEV_HOTPLUG)
-
-#define NV_INT_CONFIG 0x12
-#define NV_INT_CONFIG_METHD 0x01 // 0 = INT, 1 = SMI
-
-// For PCI config register 20
-#define NV_MCP_SATA_CFG_20 0x50
-#define NV_MCP_SATA_CFG_20_SATA_SPACE_EN 0x04
+enum {
+ NV_PORTS = 2,
+ NV_PIO_MASK = 0x1f,
+ NV_MWDMA_MASK = 0x07,
+ NV_UDMA_MASK = 0x7f,
+ NV_PORT0_SCR_REG_OFFSET = 0x00,
+ NV_PORT1_SCR_REG_OFFSET = 0x40,
+
+ NV_INT_STATUS = 0x10,
+ NV_INT_STATUS_CK804 = 0x440,
+ NV_INT_STATUS_PDEV_INT = 0x01,
+ NV_INT_STATUS_PDEV_PM = 0x02,
+ NV_INT_STATUS_PDEV_ADDED = 0x04,
+ NV_INT_STATUS_PDEV_REMOVED = 0x08,
+ NV_INT_STATUS_SDEV_INT = 0x10,
+ NV_INT_STATUS_SDEV_PM = 0x20,
+ NV_INT_STATUS_SDEV_ADDED = 0x40,
+ NV_INT_STATUS_SDEV_REMOVED = 0x80,
+ NV_INT_STATUS_PDEV_HOTPLUG = (NV_INT_STATUS_PDEV_ADDED |
+ NV_INT_STATUS_PDEV_REMOVED),
+ NV_INT_STATUS_SDEV_HOTPLUG = (NV_INT_STATUS_SDEV_ADDED |
+ NV_INT_STATUS_SDEV_REMOVED),
+ NV_INT_STATUS_HOTPLUG = (NV_INT_STATUS_PDEV_HOTPLUG |
+ NV_INT_STATUS_SDEV_HOTPLUG),
+
+ NV_INT_ENABLE = 0x11,
+ NV_INT_ENABLE_CK804 = 0x441,
+ NV_INT_ENABLE_PDEV_MASK = 0x01,
+ NV_INT_ENABLE_PDEV_PM = 0x02,
+ NV_INT_ENABLE_PDEV_ADDED = 0x04,
+ NV_INT_ENABLE_PDEV_REMOVED = 0x08,
+ NV_INT_ENABLE_SDEV_MASK = 0x10,
+ NV_INT_ENABLE_SDEV_PM = 0x20,
+ NV_INT_ENABLE_SDEV_ADDED = 0x40,
+ NV_INT_ENABLE_SDEV_REMOVED = 0x80,
+ NV_INT_ENABLE_PDEV_HOTPLUG = (NV_INT_ENABLE_PDEV_ADDED |
+ NV_INT_ENABLE_PDEV_REMOVED),
+ NV_INT_ENABLE_SDEV_HOTPLUG = (NV_INT_ENABLE_SDEV_ADDED |
+ NV_INT_ENABLE_SDEV_REMOVED),
+ NV_INT_ENABLE_HOTPLUG = (NV_INT_ENABLE_PDEV_HOTPLUG |
+ NV_INT_ENABLE_SDEV_HOTPLUG),
+
+ NV_INT_CONFIG = 0x12,
+ NV_INT_CONFIG_METHD = 0x01, // 0 = INT, 1 = SMI
+
+ // For PCI config register 20
+ NV_MCP_SATA_CFG_20 = 0x50,
+ NV_MCP_SATA_CFG_20_SATA_SPACE_EN = 0x04,
+};
static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
static irqreturn_t nv_interrupt (int irq, void *dev_instance,
@@ -175,8 +149,6 @@ static const struct pci_device_id nv_pci_tbl[] = {
{ 0, } /* terminate list */
};
-#define NV_HOST_FLAGS_SCR_MMIO 0x00000001
-
struct nv_host_desc
{
enum nv_host_type host_type;
@@ -332,36 +304,23 @@ static irqreturn_t nv_interrupt (int irq, void *dev_instance,
static u32 nv_scr_read (struct ata_port *ap, unsigned int sc_reg)
{
- struct ata_host_set *host_set = ap->host_set;
- struct nv_host *host = host_set->private_data;
-
if (sc_reg > SCR_CONTROL)
return 0xffffffffU;
- if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
- return readl((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
- else
- return inl(ap->ioaddr.scr_addr + (sc_reg * 4));
+ return ioread32((void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
}
static void nv_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val)
{
- struct ata_host_set *host_set = ap->host_set;
- struct nv_host *host = host_set->private_data;
-
if (sc_reg > SCR_CONTROL)
return;
- if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
- writel(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
- else
- outl(val, ap->ioaddr.scr_addr + (sc_reg * 4));
+ iowrite32(val, (void __iomem *)ap->ioaddr.scr_addr + (sc_reg * 4));
}
static void nv_host_stop (struct ata_host_set *host_set)
{
struct nv_host *host = host_set->private_data;
- struct pci_dev *pdev = to_pci_dev(host_set->dev);
// Disable hotplug event interrupts.
if (host->host_desc->disable_hotplug)
@@ -369,8 +328,7 @@ static void nv_host_stop (struct ata_host_set *host_set)
kfree(host);
- if (host_set->mmio_base)
- pci_iounmap(pdev, host_set->mmio_base);
+ ata_pci_host_stop(host_set);
}
static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -382,6 +340,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
int pci_dev_busy = 0;
int rc;
u32 bar;
+ unsigned long base;
// Make sure this is a SATA controller by counting the number of bars
// (NVIDIA SATA controllers will always have six bars). Otherwise,
@@ -426,31 +385,16 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->private_data = host;
- if (pci_resource_flags(pdev, 5) & IORESOURCE_MEM)
- host->host_flags |= NV_HOST_FLAGS_SCR_MMIO;
-
- if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO) {
- unsigned long base;
-
- probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
- if (probe_ent->mmio_base == NULL) {
- rc = -EIO;
- goto err_out_free_host;
- }
-
- base = (unsigned long)probe_ent->mmio_base;
+ probe_ent->mmio_base = pci_iomap(pdev, 5, 0);
+ if (!probe_ent->mmio_base) {
+ rc = -EIO;
+ goto err_out_free_host;
+ }
- probe_ent->port[0].scr_addr =
- base + NV_PORT0_SCR_REG_OFFSET;
- probe_ent->port[1].scr_addr =
- base + NV_PORT1_SCR_REG_OFFSET;
- } else {
+ base = (unsigned long)probe_ent->mmio_base;
- probe_ent->port[0].scr_addr =
- pci_resource_start(pdev, 5) | NV_PORT0_SCR_REG_OFFSET;
- probe_ent->port[1].scr_addr =
- pci_resource_start(pdev, 5) | NV_PORT1_SCR_REG_OFFSET;
- }
+ probe_ent->port[0].scr_addr = base + NV_PORT0_SCR_REG_OFFSET;
+ probe_ent->port[1].scr_addr = base + NV_PORT1_SCR_REG_OFFSET;
pci_set_master(pdev);
@@ -467,8 +411,7 @@ static int nv_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
err_out_iounmap:
- if (host->host_flags & NV_HOST_FLAGS_SCR_MMIO)
- pci_iounmap(pdev, probe_ent->mmio_base);
+ pci_iounmap(pdev, probe_ent->mmio_base);
err_out_free_host:
kfree(host);
err_out_free_ent:
diff --git a/drivers/scsi/sata_sil.c b/drivers/scsi/sata_sil.c
index 3e75d673323..18c296c5689 100644
--- a/drivers/scsi/sata_sil.c
+++ b/drivers/scsi/sata_sil.c
@@ -371,7 +371,7 @@ static void sil_dev_config(struct ata_port *ap, struct ata_device *dev)
if (quirks & SIL_QUIRK_UDMA5MAX) {
printk(KERN_INFO "ata%u(%u): applying Maxtor errata fix %s\n",
ap->id, dev->devno, model_num);
- ap->udma_mask &= ATA_UDMA5;
+ dev->udma_mask &= ATA_UDMA5;
return;
}
}
diff --git a/drivers/scsi/sata_sil24.c b/drivers/scsi/sata_sil24.c
index 5d01e5ce5ac..068c98a4111 100644
--- a/drivers/scsi/sata_sil24.c
+++ b/drivers/scsi/sata_sil24.c
@@ -342,7 +342,7 @@ static struct ata_port_info sil24_port_info[] = {
.udma_mask = 0x3f, /* udma0-5 */
.port_ops = &sil24_ops,
},
- /* sil_3132 */
+ /* sil_3132 */
{
.sht = &sil24_sht,
.host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY |
@@ -842,9 +842,10 @@ static void sil24_port_stop(struct ata_port *ap)
static void sil24_host_stop(struct ata_host_set *host_set)
{
struct sil24_host_priv *hpriv = host_set->private_data;
+ struct pci_dev *pdev = to_pci_dev(host_set->dev);
- iounmap(hpriv->host_base);
- iounmap(hpriv->port_base);
+ pci_iounmap(pdev, hpriv->host_base);
+ pci_iounmap(pdev, hpriv->port_base);
kfree(hpriv);
}
@@ -871,26 +872,23 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
goto out_disable;
rc = -ENOMEM;
- /* ioremap mmio registers */
- host_base = ioremap(pci_resource_start(pdev, 0),
- pci_resource_len(pdev, 0));
+ /* map mmio registers */
+ host_base = pci_iomap(pdev, 0, 0);
if (!host_base)
goto out_free;
- port_base = ioremap(pci_resource_start(pdev, 2),
- pci_resource_len(pdev, 2));
+ port_base = pci_iomap(pdev, 2, 0);
if (!port_base)
goto out_free;
/* allocate & init probe_ent and hpriv */
- probe_ent = kmalloc(sizeof(*probe_ent), GFP_KERNEL);
+ probe_ent = kzalloc(sizeof(*probe_ent), GFP_KERNEL);
if (!probe_ent)
goto out_free;
- hpriv = kmalloc(sizeof(*hpriv), GFP_KERNEL);
+ hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
if (!hpriv)
goto out_free;
- memset(probe_ent, 0, sizeof(*probe_ent));
probe_ent->dev = pci_dev_to_dev(pdev);
INIT_LIST_HEAD(&probe_ent->node);
@@ -907,7 +905,6 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->mmio_base = port_base;
probe_ent->private_data = hpriv;
- memset(hpriv, 0, sizeof(*hpriv));
hpriv->host_base = host_base;
hpriv->port_base = port_base;
@@ -1011,9 +1008,9 @@ static int sil24_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
out_free:
if (host_base)
- iounmap(host_base);
+ pci_iounmap(pdev, host_base);
if (port_base)
- iounmap(port_base);
+ pci_iounmap(pdev, port_base);
kfree(probe_ent);
kfree(hpriv);
pci_release_regions(pdev);
diff --git a/drivers/scsi/sata_svw.c b/drivers/scsi/sata_svw.c
index 051e47d975c..724f0ed6a52 100644
--- a/drivers/scsi/sata_svw.c
+++ b/drivers/scsi/sata_svw.c
@@ -56,33 +56,35 @@
#define DRV_NAME "sata_svw"
#define DRV_VERSION "1.07"
-/* Taskfile registers offsets */
-#define K2_SATA_TF_CMD_OFFSET 0x00
-#define K2_SATA_TF_DATA_OFFSET 0x00
-#define K2_SATA_TF_ERROR_OFFSET 0x04
-#define K2_SATA_TF_NSECT_OFFSET 0x08
-#define K2_SATA_TF_LBAL_OFFSET 0x0c
-#define K2_SATA_TF_LBAM_OFFSET 0x10
-#define K2_SATA_TF_LBAH_OFFSET 0x14
-#define K2_SATA_TF_DEVICE_OFFSET 0x18
-#define K2_SATA_TF_CMDSTAT_OFFSET 0x1c
-#define K2_SATA_TF_CTL_OFFSET 0x20
-
-/* DMA base */
-#define K2_SATA_DMA_CMD_OFFSET 0x30
-
-/* SCRs base */
-#define K2_SATA_SCR_STATUS_OFFSET 0x40
-#define K2_SATA_SCR_ERROR_OFFSET 0x44
-#define K2_SATA_SCR_CONTROL_OFFSET 0x48
-
-/* Others */
-#define K2_SATA_SICR1_OFFSET 0x80
-#define K2_SATA_SICR2_OFFSET 0x84
-#define K2_SATA_SIM_OFFSET 0x88
-
-/* Port stride */
-#define K2_SATA_PORT_OFFSET 0x100
+enum {
+ /* Taskfile registers offsets */
+ K2_SATA_TF_CMD_OFFSET = 0x00,
+ K2_SATA_TF_DATA_OFFSET = 0x00,
+ K2_SATA_TF_ERROR_OFFSET = 0x04,
+ K2_SATA_TF_NSECT_OFFSET = 0x08,
+ K2_SATA_TF_LBAL_OFFSET = 0x0c,
+ K2_SATA_TF_LBAM_OFFSET = 0x10,
+ K2_SATA_TF_LBAH_OFFSET = 0x14,
+ K2_SATA_TF_DEVICE_OFFSET = 0x18,
+ K2_SATA_TF_CMDSTAT_OFFSET = 0x1c,
+ K2_SATA_TF_CTL_OFFSET = 0x20,
+
+ /* DMA base */
+ K2_SATA_DMA_CMD_OFFSET = 0x30,
+
+ /* SCRs base */
+ K2_SATA_SCR_STATUS_OFFSET = 0x40,
+ K2_SATA_SCR_ERROR_OFFSET = 0x44,
+ K2_SATA_SCR_CONTROL_OFFSET = 0x48,
+
+ /* Others */
+ K2_SATA_SICR1_OFFSET = 0x80,
+ K2_SATA_SICR2_OFFSET = 0x84,
+ K2_SATA_SIM_OFFSET = 0x88,
+
+ /* Port stride */
+ K2_SATA_PORT_OFFSET = 0x100,
+};
static u8 k2_stat_check_status(struct ata_port *ap);
diff --git a/drivers/scsi/sata_uli.c b/drivers/scsi/sata_uli.c
index 8f5025733de..7ac5a5f5a90 100644
--- a/drivers/scsi/sata_uli.c
+++ b/drivers/scsi/sata_uli.c
@@ -44,6 +44,8 @@ enum {
uli_5287 = 1,
uli_5281 = 2,
+ uli_max_ports = 4,
+
/* PCI configuration registers */
ULI5287_BASE = 0x90, /* sata0 phy SCR registers */
ULI5287_OFFS = 0x10, /* offset from sata0->sata1 phy regs */
@@ -51,6 +53,10 @@ enum {
ULI5281_OFFS = 0x60, /* offset from sata0->sata1 phy regs */
};
+struct uli_priv {
+ unsigned int scr_cfg_addr[uli_max_ports];
+};
+
static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent);
static u32 uli_scr_read (struct ata_port *ap, unsigned int sc_reg);
static void uli_scr_write (struct ata_port *ap, unsigned int sc_reg, u32 val);
@@ -137,7 +143,8 @@ MODULE_VERSION(DRV_VERSION);
static unsigned int get_scr_cfg_addr(struct ata_port *ap, unsigned int sc_reg)
{
- return ap->ioaddr.scr_addr + (4 * sc_reg);
+ struct uli_priv *hpriv = ap->host_set->private_data;
+ return hpriv->scr_cfg_addr[ap->port_no] + (4 * sc_reg);
}
static u32 uli_scr_cfg_read (struct ata_port *ap, unsigned int sc_reg)
@@ -182,6 +189,7 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
int rc;
unsigned int board_idx = (unsigned int) ent->driver_data;
int pci_dev_busy = 0;
+ struct uli_priv *hpriv;
if (!printed_version++)
dev_printk(KERN_INFO, &pdev->dev, "version " DRV_VERSION "\n");
@@ -210,10 +218,18 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_out_regions;
}
+ hpriv = kzalloc(sizeof(*hpriv), GFP_KERNEL);
+ if (!hpriv) {
+ rc = -ENOMEM;
+ goto err_out_probe_ent;
+ }
+
+ probe_ent->private_data = hpriv;
+
switch (board_idx) {
case uli_5287:
- probe_ent->port[0].scr_addr = ULI5287_BASE;
- probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS;
+ hpriv->scr_cfg_addr[0] = ULI5287_BASE;
+ hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
probe_ent->n_ports = 4;
probe_ent->port[2].cmd_addr = pci_resource_start(pdev, 0) + 8;
@@ -221,27 +237,27 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
probe_ent->port[2].ctl_addr =
(pci_resource_start(pdev, 1) | ATA_PCI_CTL_OFS) + 4;
probe_ent->port[2].bmdma_addr = pci_resource_start(pdev, 4) + 16;
- probe_ent->port[2].scr_addr = ULI5287_BASE + ULI5287_OFFS*4;
+ hpriv->scr_cfg_addr[2] = ULI5287_BASE + ULI5287_OFFS*4;
probe_ent->port[3].cmd_addr = pci_resource_start(pdev, 2) + 8;
probe_ent->port[3].altstatus_addr =
probe_ent->port[3].ctl_addr =
(pci_resource_start(pdev, 3) | ATA_PCI_CTL_OFS) + 4;
probe_ent->port[3].bmdma_addr = pci_resource_start(pdev, 4) + 24;
- probe_ent->port[3].scr_addr = ULI5287_BASE + ULI5287_OFFS*5;
+ hpriv->scr_cfg_addr[3] = ULI5287_BASE + ULI5287_OFFS*5;
ata_std_ports(&probe_ent->port[2]);
ata_std_ports(&probe_ent->port[3]);
break;
case uli_5289:
- probe_ent->port[0].scr_addr = ULI5287_BASE;
- probe_ent->port[1].scr_addr = ULI5287_BASE + ULI5287_OFFS;
+ hpriv->scr_cfg_addr[0] = ULI5287_BASE;
+ hpriv->scr_cfg_addr[1] = ULI5287_BASE + ULI5287_OFFS;
break;
case uli_5281:
- probe_ent->port[0].scr_addr = ULI5281_BASE;
- probe_ent->port[1].scr_addr = ULI5281_BASE + ULI5281_OFFS;
+ hpriv->scr_cfg_addr[0] = ULI5281_BASE;
+ hpriv->scr_cfg_addr[1] = ULI5281_BASE + ULI5281_OFFS;
break;
default:
@@ -258,9 +274,10 @@ static int uli_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
return 0;
+err_out_probe_ent:
+ kfree(probe_ent);
err_out_regions:
pci_release_regions(pdev);
-
err_out:
if (!pci_dev_busy)
pci_disable_device(pdev);
diff --git a/drivers/scsi/sata_vsc.c b/drivers/scsi/sata_vsc.c
index ee75b9b38ae..836bbbb26ff 100644
--- a/drivers/scsi/sata_vsc.c
+++ b/drivers/scsi/sata_vsc.c
@@ -47,52 +47,58 @@
#include <linux/libata.h>
#define DRV_NAME "sata_vsc"
-#define DRV_VERSION "1.1"
-
-/* Interrupt register offsets (from chip base address) */
-#define VSC_SATA_INT_STAT_OFFSET 0x00
-#define VSC_SATA_INT_MASK_OFFSET 0x04
-
-/* Taskfile registers offsets */
-#define VSC_SATA_TF_CMD_OFFSET 0x00
-#define VSC_SATA_TF_DATA_OFFSET 0x00
-#define VSC_SATA_TF_ERROR_OFFSET 0x04
-#define VSC_SATA_TF_FEATURE_OFFSET 0x06
-#define VSC_SATA_TF_NSECT_OFFSET 0x08
-#define VSC_SATA_TF_LBAL_OFFSET 0x0c
-#define VSC_SATA_TF_LBAM_OFFSET 0x10
-#define VSC_SATA_TF_LBAH_OFFSET 0x14
-#define VSC_SATA_TF_DEVICE_OFFSET 0x18
-#define VSC_SATA_TF_STATUS_OFFSET 0x1c
-#define VSC_SATA_TF_COMMAND_OFFSET 0x1d
-#define VSC_SATA_TF_ALTSTATUS_OFFSET 0x28
-#define VSC_SATA_TF_CTL_OFFSET 0x29
-
-/* DMA base */
-#define VSC_SATA_UP_DESCRIPTOR_OFFSET 0x64
-#define VSC_SATA_UP_DATA_BUFFER_OFFSET 0x6C
-#define VSC_SATA_DMA_CMD_OFFSET 0x70
-
-/* SCRs base */
-#define VSC_SATA_SCR_STATUS_OFFSET 0x100
-#define VSC_SATA_SCR_ERROR_OFFSET 0x104
-#define VSC_SATA_SCR_CONTROL_OFFSET 0x108
-
-/* Port stride */
-#define VSC_SATA_PORT_OFFSET 0x200
-
-/* Error interrupt status bit offsets */
-#define VSC_SATA_INT_ERROR_E_OFFSET 2
-#define VSC_SATA_INT_ERROR_P_OFFSET 4
-#define VSC_SATA_INT_ERROR_T_OFFSET 5
-#define VSC_SATA_INT_ERROR_M_OFFSET 1
+#define DRV_VERSION "1.2"
+
+enum {
+ /* Interrupt register offsets (from chip base address) */
+ VSC_SATA_INT_STAT_OFFSET = 0x00,
+ VSC_SATA_INT_MASK_OFFSET = 0x04,
+
+ /* Taskfile registers offsets */
+ VSC_SATA_TF_CMD_OFFSET = 0x00,
+ VSC_SATA_TF_DATA_OFFSET = 0x00,
+ VSC_SATA_TF_ERROR_OFFSET = 0x04,
+ VSC_SATA_TF_FEATURE_OFFSET = 0x06,
+ VSC_SATA_TF_NSECT_OFFSET = 0x08,
+ VSC_SATA_TF_LBAL_OFFSET = 0x0c,
+ VSC_SATA_TF_LBAM_OFFSET = 0x10,
+ VSC_SATA_TF_LBAH_OFFSET = 0x14,
+ VSC_SATA_TF_DEVICE_OFFSET = 0x18,
+ VSC_SATA_TF_STATUS_OFFSET = 0x1c,
+ VSC_SATA_TF_COMMAND_OFFSET = 0x1d,
+ VSC_SATA_TF_ALTSTATUS_OFFSET = 0x28,
+ VSC_SATA_TF_CTL_OFFSET = 0x29,
+
+ /* DMA base */
+ VSC_SATA_UP_DESCRIPTOR_OFFSET = 0x64,
+ VSC_SATA_UP_DATA_BUFFER_OFFSET = 0x6C,
+ VSC_SATA_DMA_CMD_OFFSET = 0x70,
+
+ /* SCRs base */
+ VSC_SATA_SCR_STATUS_OFFSET = 0x100,
+ VSC_SATA_SCR_ERROR_OFFSET = 0x104,
+ VSC_SATA_SCR_CONTROL_OFFSET = 0x108,
+
+ /* Port stride */
+ VSC_SATA_PORT_OFFSET = 0x200,
+
+ /* Error interrupt status bit offsets */
+ VSC_SATA_INT_ERROR_CRC = 0x40,
+ VSC_SATA_INT_ERROR_T = 0x20,
+ VSC_SATA_INT_ERROR_P = 0x10,
+ VSC_SATA_INT_ERROR_R = 0x8,
+ VSC_SATA_INT_ERROR_E = 0x4,
+ VSC_SATA_INT_ERROR_M = 0x2,
+ VSC_SATA_INT_PHY_CHANGE = 0x1,
+ VSC_SATA_INT_ERROR = (VSC_SATA_INT_ERROR_CRC | VSC_SATA_INT_ERROR_T | \
+ VSC_SATA_INT_ERROR_P | VSC_SATA_INT_ERROR_R | \
+ VSC_SATA_INT_ERROR_E | VSC_SATA_INT_ERROR_M | \
+ VSC_SATA_INT_PHY_CHANGE),
+};
+
+
#define is_vsc_sata_int_err(port_idx, int_status) \
- (int_status & ((1 << (VSC_SATA_INT_ERROR_E_OFFSET + (8 * port_idx))) | \
- (1 << (VSC_SATA_INT_ERROR_P_OFFSET + (8 * port_idx))) | \
- (1 << (VSC_SATA_INT_ERROR_T_OFFSET + (8 * port_idx))) | \
- (1 << (VSC_SATA_INT_ERROR_M_OFFSET + (8 * port_idx))) \
- )\
- )
+ (int_status & (VSC_SATA_INT_ERROR << (8 * port_idx)))
static u32 vsc_sata_scr_read (struct ata_port *ap, unsigned int sc_reg)
@@ -215,14 +221,6 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
ap = host_set->ports[i];
- if (is_vsc_sata_int_err(i, int_status)) {
- u32 err_status;
- printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
- err_status = ap ? vsc_sata_scr_read(ap, SCR_ERROR) : 0;
- vsc_sata_scr_write(ap, SCR_ERROR, err_status);
- handled++;
- }
-
if (ap && !(ap->flags &
(ATA_FLAG_PORT_DISABLED|ATA_FLAG_NOINTR))) {
struct ata_queued_cmd *qc;
@@ -230,12 +228,26 @@ static irqreturn_t vsc_sata_interrupt (int irq, void *dev_instance,
qc = ata_qc_from_tag(ap, ap->active_tag);
if (qc && (!(qc->tf.ctl & ATA_NIEN))) {
handled += ata_host_intr(ap, qc);
- } else {
- printk(KERN_DEBUG "%s: ignoring interrupt(s)\n", __FUNCTION__);
+ } else if (is_vsc_sata_int_err(i, int_status)) {
+ /*
+ * On some chips (i.e. Intel 31244), an error
+ * interrupt will sneak in at initialization
+ * time (phy state changes). Clearing the SCR
+ * error register is not required, but it prevents
+ * the phy state change interrupts from recurring
+ * later.
+ */
+ u32 err_status;
+ err_status = vsc_sata_scr_read(ap, SCR_ERROR);
+ printk(KERN_DEBUG "%s: clearing interrupt, "
+ "status %x; sata err status %x\n",
+ __FUNCTION__,
+ int_status, err_status);
+ vsc_sata_scr_write(ap, SCR_ERROR, err_status);
+ /* Clear interrupt status */
ata_chk_status(ap);
handled++;
}
-
}
}
}
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 89055494dfe..a6fde52946d 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -286,7 +286,7 @@ static int scsi_bus_suspend(struct device * dev, pm_message_t state)
return err;
if (sht->suspend)
- err = sht->suspend(sdev);
+ err = sht->suspend(sdev, state);
return err;
}
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 024ef86c524..c647d85d97d 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -190,7 +190,7 @@ static ssize_t sd_store_cache_type(struct class_device *cdev, const char *buf,
if (scsi_mode_sense(sdp, 0x08, 8, buffer, sizeof(buffer), SD_TIMEOUT,
SD_MAX_RETRIES, &data, NULL))
return -EINVAL;
- len = min(sizeof(buffer), data.length - data.header_length -
+ len = min_t(size_t, sizeof(buffer), data.length - data.header_length -
data.block_descriptor_length);
buffer_data = buffer + data.header_length +
data.block_descriptor_length;
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index f9c1192dc15..7c80711e18e 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -71,7 +71,7 @@ MODULE_ALIAS_BLOCKDEV_MAJOR(SCSI_CDROM_MAJOR);
#define SR_CAPABILITIES \
(CDC_CLOSE_TRAY|CDC_OPEN_TRAY|CDC_LOCK|CDC_SELECT_SPEED| \
CDC_SELECT_DISC|CDC_MULTI_SESSION|CDC_MCN|CDC_MEDIA_CHANGED| \
- CDC_PLAY_AUDIO|CDC_RESET|CDC_IOCTLS|CDC_DRIVE_STATUS| \
+ CDC_PLAY_AUDIO|CDC_RESET|CDC_DRIVE_STATUS| \
CDC_CD_R|CDC_CD_RW|CDC_DVD|CDC_DVD_R|CDC_DVD_RAM|CDC_GENERIC_PACKET| \
CDC_MRW|CDC_MRW_W|CDC_RAM)
@@ -118,7 +118,6 @@ static struct cdrom_device_ops sr_dops = {
.get_mcn = sr_get_mcn,
.reset = sr_reset,
.audio_ioctl = sr_audio_ioctl,
- .dev_ioctl = sr_dev_ioctl,
.capability = SR_CAPABILITIES,
.generic_packet = sr_packet,
};
@@ -456,17 +455,33 @@ static int sr_block_ioctl(struct inode *inode, struct file *file, unsigned cmd,
{
struct scsi_cd *cd = scsi_cd(inode->i_bdev->bd_disk);
struct scsi_device *sdev = cd->device;
+ void __user *argp = (void __user *)arg;
+ int ret;
- /*
- * Send SCSI addressing ioctls directly to mid level, send other
- * ioctls to cdrom/block level.
- */
- switch (cmd) {
- case SCSI_IOCTL_GET_IDLUN:
- case SCSI_IOCTL_GET_BUS_NUMBER:
- return scsi_ioctl(sdev, cmd, (void __user *)arg);
+ /*
+ * Send SCSI addressing ioctls directly to mid level, send other
+ * ioctls to cdrom/block level.
+ */
+ switch (cmd) {
+ case SCSI_IOCTL_GET_IDLUN:
+ case SCSI_IOCTL_GET_BUS_NUMBER:
+ return scsi_ioctl(sdev, cmd, argp);
}
- return cdrom_ioctl(file, &cd->cdi, inode, cmd, arg);
+
+ ret = cdrom_ioctl(file, &cd->cdi, inode, cmd, arg);
+ if (ret != ENOSYS)
+ return ret;
+
+ /*
+ * ENODEV means that we didn't recognise the ioctl, or that we
+ * cannot execute it in the current device state. In either
+ * case fall through to scsi_ioctl, which will return ENDOEV again
+ * if it doesn't recognise the ioctl
+ */
+ ret = scsi_nonblockable_ioctl(sdev, cmd, argp, NULL);
+ if (ret != -ENODEV)
+ return ret;
+ return scsi_ioctl(sdev, cmd, argp);
}
static int sr_block_media_changed(struct gendisk *disk)
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
index d2bcd99c272..d65de9621b2 100644
--- a/drivers/scsi/sr.h
+++ b/drivers/scsi/sr.h
@@ -55,7 +55,6 @@ int sr_get_mcn(struct cdrom_device_info *, struct cdrom_mcn *);
int sr_reset(struct cdrom_device_info *);
int sr_select_speed(struct cdrom_device_info *cdi, int speed);
int sr_audio_ioctl(struct cdrom_device_info *, unsigned int, void *);
-int sr_dev_ioctl(struct cdrom_device_info *, unsigned int, unsigned long);
int sr_is_xa(Scsi_CD *);
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c
index b65462f7648..d1268cb4683 100644
--- a/drivers/scsi/sr_ioctl.c
+++ b/drivers/scsi/sr_ioctl.c
@@ -562,22 +562,3 @@ int sr_is_xa(Scsi_CD *cd)
#endif
return is_xa;
}
-
-int sr_dev_ioctl(struct cdrom_device_info *cdi,
- unsigned int cmd, unsigned long arg)
-{
- Scsi_CD *cd = cdi->handle;
- int ret;
-
- ret = scsi_nonblockable_ioctl(cd->device, cmd,
- (void __user *)arg, NULL);
- /*
- * ENODEV means that we didn't recognise the ioctl, or that we
- * cannot execute it in the current device state. In either
- * case fall through to scsi_ioctl, which will return ENDOEV again
- * if it doesn't recognise the ioctl
- */
- if (ret != -ENODEV)
- return ret;
- return scsi_ioctl(cd->device, cmd, (void __user *)arg);
-}
diff --git a/drivers/serial/21285.c b/drivers/serial/21285.c
index 8c5c276c557..7572665a885 100644
--- a/drivers/serial/21285.c
+++ b/drivers/serial/21285.c
@@ -375,23 +375,18 @@ static void serial21285_setup_ports(void)
}
#ifdef CONFIG_SERIAL_21285_CONSOLE
+static void serial21285_console_putchar(struct uart_port *port, int ch)
+{
+ while (*CSR_UARTFLG & 0x20)
+ barrier();
+ *CSR_UARTDR = ch;
+}
static void
serial21285_console_write(struct console *co, const char *s,
unsigned int count)
{
- int i;
-
- for (i = 0; i < count; i++) {
- while (*CSR_UARTFLG & 0x20)
- barrier();
- *CSR_UARTDR = s[i];
- if (s[i] == '\n') {
- while (*CSR_UARTFLG & 0x20)
- barrier();
- *CSR_UARTDR = '\r';
- }
- }
+ uart_console_write(&serial21285_port, s, count, serial21285_console_putchar);
}
static void __init
diff --git a/drivers/serial/68328serial.c b/drivers/serial/68328serial.c
index 7f0f35a05dc..b88a7c1158a 100644
--- a/drivers/serial/68328serial.c
+++ b/drivers/serial/68328serial.c
@@ -101,8 +101,6 @@ struct tty_driver *serial_driver;
#define RS_ISR_PASS_LIMIT 256
-#define _INLINE_ inline
-
static void change_speed(struct m68k_serial *info);
/*
@@ -262,7 +260,7 @@ static void batten_down_hatches(void)
/* Drop into the debugger */
}
-static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status)
+static void status_handle(struct m68k_serial *info, unsigned short status)
{
#if 0
if(status & DCD) {
@@ -289,7 +287,8 @@ static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short stat
return;
}
-static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx)
+static void receive_chars(struct m68k_serial *info, struct pt_regs *regs,
+ unsigned short rx)
{
struct tty_struct *tty = info->tty;
m68328_uart *uart = &uart_addr[info->line];
@@ -359,7 +358,7 @@ clear_and_exit:
return;
}
-static _INLINE_ void transmit_chars(struct m68k_serial *info)
+static void transmit_chars(struct m68k_serial *info)
{
m68328_uart *uart = &uart_addr[info->line];
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 7aca22c9976..5996d3cd0ed 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2182,6 +2182,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up, int bits)
}
}
+static void serial8250_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ wait_for_xmitr(up, UART_LSR_THRE);
+ serial_out(up, UART_TX, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -2193,7 +2201,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_8250_port *up = &serial8250_ports[co->index];
unsigned int ier;
- int i;
touch_nmi_watchdog();
@@ -2207,22 +2214,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
else
serial_out(up, UART_IER, 0);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up, UART_LSR_THRE);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- serial_out(up, UART_TX, *s);
- if (*s == 10) {
- wait_for_xmitr(up, UART_LSR_THRE);
- serial_out(up, UART_TX, 13);
- }
- }
+ uart_console_write(&up->port, s, count, serial8250_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/8250_early.c b/drivers/serial/8250_early.c
index 59ba5d993b4..7e511199b4c 100644
--- a/drivers/serial/8250_early.c
+++ b/drivers/serial/8250_early.c
@@ -74,7 +74,7 @@ static void __init wait_for_xmitr(struct uart_port *port)
}
}
-static void __init putc(struct uart_port *port, unsigned char c)
+static void __init putc(struct uart_port *port, int c)
{
wait_for_xmitr(port);
serial_out(port, UART_TX, c);
@@ -89,12 +89,7 @@ static void __init early_uart_write(struct console *console, const char *s, unsi
ier = serial_in(port, UART_IER);
serial_out(port, UART_IER, 0);
- while (*s && count-- > 0) {
- putc(port, *s);
- if (*s == '\n')
- putc(port, '\r');
- s++;
- }
+ uart_console_write(port, s, count, putc);
/* Wait for transmitter to become empty and restore the IER */
wait_for_xmitr(port);
diff --git a/drivers/serial/8250_hp300.c b/drivers/serial/8250_hp300.c
index 4315afe9c08..53e81a44c1a 100644
--- a/drivers/serial/8250_hp300.c
+++ b/drivers/serial/8250_hp300.c
@@ -55,6 +55,8 @@ static struct dio_driver hpdca_driver = {
#endif
+static unsigned int num_ports;
+
extern int hp300_uart_scode;
/* Offset to UART registers from base of DCA */
@@ -199,6 +201,8 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
udelay(100);
+ num_ports++;
+
return 0;
}
#endif
@@ -206,7 +210,6 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
static int __init hp300_8250_init(void)
{
static int called = 0;
- int num_ports;
#ifdef CONFIG_HPAPCI
int line;
unsigned long base;
@@ -221,11 +224,8 @@ static int __init hp300_8250_init(void)
if (!MACH_IS_HP300)
return -ENODEV;
- num_ports = 0;
-
#ifdef CONFIG_HPDCA
- if (dio_module_init(&hpdca_driver) == 0)
- num_ports++;
+ dio_register_driver(&hpdca_driver);
#endif
#ifdef CONFIG_HPAPCI
if (hp300_model < HP_400) {
diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c
index 321a3b3a572..e04d5e82d9a 100644
--- a/drivers/serial/amba-pl010.c
+++ b/drivers/serial/amba-pl010.c
@@ -591,12 +591,18 @@ static struct uart_amba_port amba_ports[UART_NR] = {
#ifdef CONFIG_SERIAL_AMBA_PL010_CONSOLE
+static void pl010_console_putchar(struct uart_port *port, int ch)
+{
+ while (!UART_TX_READY(UART_GET_FR(port)))
+ barrier();
+ UART_PUT_CHAR(port, ch);
+}
+
static void
pl010_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_port *port = &amba_ports[co->index].port;
unsigned int status, old_cr;
- int i;
/*
* First save the CR then disable the interrupts
@@ -604,21 +610,7 @@ pl010_console_write(struct console *co, const char *s, unsigned int count)
old_cr = UART_GET_CR(port);
UART_PUT_CR(port, UART01x_CR_UARTEN);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- do {
- status = UART_GET_FR(port);
- } while (!UART_TX_READY(status));
- UART_PUT_CHAR(port, s[i]);
- if (s[i] == '\n') {
- do {
- status = UART_GET_FR(port);
- } while (!UART_TX_READY(status));
- UART_PUT_CHAR(port, '\r');
- }
- }
+ uart_console_write(port, s, count, pl010_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c
index 034a029e356..3d966cfc9a3 100644
--- a/drivers/serial/amba-pl011.c
+++ b/drivers/serial/amba-pl011.c
@@ -587,14 +587,12 @@ static struct uart_amba_port *amba_ports[UART_NR];
#ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
-static inline void
-pl011_console_write_char(struct uart_amba_port *uap, char ch)
+static void pl011_console_putchar(struct uart_port *port, int ch)
{
- unsigned int status;
+ struct uart_amba_port *uap = (struct uart_amba_port *)port;
- do {
- status = readw(uap->port.membase + UART01x_FR);
- } while (status & UART01x_FR_TXFF);
+ while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
+ barrier();
writew(ch, uap->port.membase + UART01x_DR);
}
@@ -603,7 +601,6 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_amba_port *uap = amba_ports[co->index];
unsigned int status, old_cr, new_cr;
- int i;
clk_enable(uap->clk);
@@ -615,14 +612,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
writew(new_cr, uap->port.membase + UART011_CR);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- pl011_console_write_char(uap, s[i]);
- if (s[i] == '\n')
- pl011_console_write_char(uap, '\r');
- }
+ uart_console_write(&uap->port, s, count, pl011_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/at91_serial.c b/drivers/serial/at91_serial.c
index 2113feb75c3..6547fe0cef9 100644
--- a/drivers/serial/at91_serial.c
+++ b/drivers/serial/at91_serial.c
@@ -711,6 +711,12 @@ void __init at91_register_uart(int idx, int port)
}
#ifdef CONFIG_SERIAL_AT91_CONSOLE
+static void at91_console_putchar(struct uart_port *port, int ch)
+{
+ while (!(UART_GET_CSR(port) & AT91_US_TXRDY))
+ barrier();
+ UART_PUT_CHAR(port, ch);
+}
/*
* Interrupts are disabled on entering
@@ -718,7 +724,7 @@ void __init at91_register_uart(int idx, int port)
static void at91_console_write(struct console *co, const char *s, u_int count)
{
struct uart_port *port = at91_ports + co->index;
- unsigned int status, i, imr;
+ unsigned int status, imr;
/*
* First, save IMR and then disable interrupts
@@ -726,21 +732,7 @@ static void at91_console_write(struct console *co, const char *s, u_int count)
imr = UART_GET_IMR(port); /* get interrupt mask */
UART_PUT_IDR(port, AT91_US_RXRDY | AT91_US_TXRDY);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- do {
- status = UART_GET_CSR(port);
- } while (!(status & AT91_US_TXRDY));
- UART_PUT_CHAR(port, s[i]);
- if (s[i] == '\n') {
- do {
- status = UART_GET_CSR(port);
- } while (!(status & AT91_US_TXRDY));
- UART_PUT_CHAR(port, '\r');
- }
- }
+ uart_console_write(port, s, count, at91_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/au1x00_uart.c b/drivers/serial/au1x00_uart.c
index 344022fe53e..948880ac587 100644
--- a/drivers/serial/au1x00_uart.c
+++ b/drivers/serial/au1x00_uart.c
@@ -133,13 +133,12 @@ static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
{ "AU1X00_UART",16, UART_CLEAR_FIFO | UART_USE_FIFO },
};
-static _INLINE_ unsigned int serial_in(struct uart_8250_port *up, int offset)
+static unsigned int serial_in(struct uart_8250_port *up, int offset)
{
return au_readl((unsigned long)up->port.membase + offset);
}
-static _INLINE_ void
-serial_out(struct uart_8250_port *up, int offset, int value)
+static void serial_out(struct uart_8250_port *up, int offset, int value)
{
au_writel(value, (unsigned long)up->port.membase + offset);
}
@@ -237,7 +236,7 @@ static void serial8250_enable_ms(struct uart_port *port)
serial_out(up, UART_IER, up->ier);
}
-static _INLINE_ void
+static void
receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
{
struct tty_struct *tty = up->port.info->tty;
@@ -312,7 +311,7 @@ receive_chars(struct uart_8250_port *up, int *status, struct pt_regs *regs)
spin_lock(&up->port.lock);
}
-static _INLINE_ void transmit_chars(struct uart_8250_port *up)
+static void transmit_chars(struct uart_8250_port *up)
{
struct circ_buf *xmit = &up->port.info->xmit;
int count;
@@ -346,7 +345,7 @@ static _INLINE_ void transmit_chars(struct uart_8250_port *up)
serial8250_stop_tx(&up->port);
}
-static _INLINE_ void check_modem_status(struct uart_8250_port *up)
+static void check_modem_status(struct uart_8250_port *up)
{
int status;
@@ -1121,6 +1120,14 @@ static inline void wait_for_xmitr(struct uart_8250_port *up)
}
}
+static void au1x00_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_8250_port *up = (struct uart_8250_port *)port;
+
+ wait_for_xmitr(up);
+ serial_out(up, UART_TX, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -1132,7 +1139,6 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_8250_port *up = &serial8250_ports[co->index];
unsigned int ier;
- int i;
/*
* First save the UER then disable the interrupts
@@ -1140,22 +1146,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
ier = serial_in(up, UART_IER);
serial_out(up, UART_IER, 0);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- serial_out(up, UART_TX, *s);
- if (*s == 10) {
- wait_for_xmitr(up);
- serial_out(up, UART_TX, 13);
- }
- }
+ uart_console_write(&up->port, s, count, au1x00_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/clps711x.c b/drivers/serial/clps711x.c
index ce7b2e4ecd1..2691112c84a 100644
--- a/drivers/serial/clps711x.c
+++ b/drivers/serial/clps711x.c
@@ -424,6 +424,13 @@ static struct uart_port clps711x_ports[UART_NR] = {
};
#ifdef CONFIG_SERIAL_CLPS711X_CONSOLE
+static void clps711xuart_console_putchar(struct uart_port *port, int ch)
+{
+ while (clps_readl(SYSFLG(port)) & SYSFLG_UTXFF)
+ barrier();
+ clps_writel(ch, UARTDR(port));
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -438,7 +445,6 @@ clps711xuart_console_write(struct console *co, const char *s,
{
struct uart_port *port = clps711x_ports + co->index;
unsigned int status, syscon;
- int i;
/*
* Ensure that the port is enabled.
@@ -446,21 +452,7 @@ clps711xuart_console_write(struct console *co, const char *s,
syscon = clps_readl(SYSCON(port));
clps_writel(syscon | SYSCON_UARTEN, SYSCON(port));
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- do {
- status = clps_readl(SYSFLG(port));
- } while (status & SYSFLG_UTXFF);
- clps_writel(s[i], UARTDR(port));
- if (s[i] == '\n') {
- do {
- status = clps_readl(SYSFLG(port));
- } while (status & SYSFLG_UTXFF);
- clps_writel('\r', UARTDR(port));
- }
- }
+ uart_console_write(port, s, count, clps711xuart_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/crisv10.c b/drivers/serial/crisv10.c
index be12623d854..89700141f87 100644
--- a/drivers/serial/crisv10.c
+++ b/drivers/serial/crisv10.c
@@ -481,8 +481,6 @@ static char *serial_version = "$Revision: 1.25 $";
#include "serial_compat.h"
#endif
-#define _INLINE_ inline
-
struct tty_driver *serial_driver;
/* serial subtype definitions */
@@ -591,8 +589,6 @@ static void rs_throttle(struct tty_struct * tty);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
static int rs_write(struct tty_struct * tty, int from_user,
const unsigned char *buf, int count);
-extern _INLINE_ int rs_raw_write(struct tty_struct * tty, int from_user,
- const unsigned char *buf, int count);
#ifdef CONFIG_ETRAX_RS485
static int e100_write_rs485(struct tty_struct * tty, int from_user,
const unsigned char *buf, int count);
@@ -1538,8 +1534,7 @@ e100_enable_rxdma_irq(struct e100_serial *info)
/* the tx DMA uses only dma_descr interrupt */
-static _INLINE_ void
-e100_disable_txdma_irq(struct e100_serial *info)
+static void e100_disable_txdma_irq(struct e100_serial *info)
{
#ifdef SERIAL_DEBUG_INTR
printk("txdma_irq(%d): 0\n",info->line);
@@ -1548,8 +1543,7 @@ e100_disable_txdma_irq(struct e100_serial *info)
*R_IRQ_MASK2_CLR = info->irq;
}
-static _INLINE_ void
-e100_enable_txdma_irq(struct e100_serial *info)
+static void e100_enable_txdma_irq(struct e100_serial *info)
{
#ifdef SERIAL_DEBUG_INTR
printk("txdma_irq(%d): 1\n",info->line);
@@ -1558,8 +1552,7 @@ e100_enable_txdma_irq(struct e100_serial *info)
*R_IRQ_MASK2_SET = info->irq;
}
-static _INLINE_ void
-e100_disable_txdma_channel(struct e100_serial *info)
+static void e100_disable_txdma_channel(struct e100_serial *info)
{
unsigned long flags;
@@ -1599,8 +1592,7 @@ e100_disable_txdma_channel(struct e100_serial *info)
}
-static _INLINE_ void
-e100_enable_txdma_channel(struct e100_serial *info)
+static void e100_enable_txdma_channel(struct e100_serial *info)
{
unsigned long flags;
@@ -1625,8 +1617,7 @@ e100_enable_txdma_channel(struct e100_serial *info)
restore_flags(flags);
}
-static _INLINE_ void
-e100_disable_rxdma_channel(struct e100_serial *info)
+static void e100_disable_rxdma_channel(struct e100_serial *info)
{
unsigned long flags;
@@ -1665,8 +1656,7 @@ e100_disable_rxdma_channel(struct e100_serial *info)
}
-static _INLINE_ void
-e100_enable_rxdma_channel(struct e100_serial *info)
+static void e100_enable_rxdma_channel(struct e100_serial *info)
{
unsigned long flags;
@@ -1913,9 +1903,7 @@ rs_start(struct tty_struct *tty)
* This routine is used by the interrupt handler to schedule
* processing in the software interrupt portion of the driver.
*/
-static _INLINE_ void
-rs_sched_event(struct e100_serial *info,
- int event)
+static void rs_sched_event(struct e100_serial *info, int event)
{
if (info->event & (1 << event))
return;
@@ -2155,8 +2143,9 @@ add_char_and_flag(struct e100_serial *info, unsigned char data, unsigned char fl
return 1;
}
-extern _INLINE_ unsigned int
-handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsigned int recvl)
+static unsigned int handle_descr_data(struct e100_serial *info,
+ struct etrax_dma_descr *descr,
+ unsigned int recvl)
{
struct etrax_recv_buffer *buffer = phys_to_virt(descr->buf) - sizeof *buffer;
@@ -2182,8 +2171,7 @@ handle_descr_data(struct e100_serial *info, struct etrax_dma_descr *descr, unsig
return recvl;
}
-static _INLINE_ unsigned int
-handle_all_descr_data(struct e100_serial *info)
+static unsigned int handle_all_descr_data(struct e100_serial *info)
{
struct etrax_dma_descr *descr;
unsigned int recvl;
@@ -2230,8 +2218,7 @@ handle_all_descr_data(struct e100_serial *info)
return ret;
}
-static _INLINE_ void
-receive_chars_dma(struct e100_serial *info)
+static void receive_chars_dma(struct e100_serial *info)
{
struct tty_struct *tty;
unsigned char rstat;
@@ -2292,8 +2279,7 @@ receive_chars_dma(struct e100_serial *info)
*info->icmdadr = IO_STATE(R_DMA_CH6_CMD, cmd, restart);
}
-static _INLINE_ int
-start_recv_dma(struct e100_serial *info)
+static int start_recv_dma(struct e100_serial *info)
{
struct etrax_dma_descr *descr = info->rec_descr;
struct etrax_recv_buffer *buffer;
@@ -2348,11 +2334,6 @@ start_receive(struct e100_serial *info)
}
-static _INLINE_ void
-status_handle(struct e100_serial *info, unsigned short status)
-{
-}
-
/* the bits in the MASK2 register are laid out like this:
DMAI_EOP DMAI_DESCR DMAO_EOP DMAO_DESCR
where I is the input channel and O is the output channel for the port.
@@ -2454,8 +2435,7 @@ rec_interrupt(int irq, void *dev_id, struct pt_regs * regs)
return IRQ_RETVAL(handled);
} /* rec_interrupt */
-static _INLINE_ int
-force_eop_if_needed(struct e100_serial *info)
+static int force_eop_if_needed(struct e100_serial *info)
{
/* We check data_avail bit to determine if data has
* arrived since last time
@@ -2499,8 +2479,7 @@ force_eop_if_needed(struct e100_serial *info)
return 1;
}
-extern _INLINE_ void
-flush_to_flip_buffer(struct e100_serial *info)
+static void flush_to_flip_buffer(struct e100_serial *info)
{
struct tty_struct *tty;
struct etrax_recv_buffer *buffer;
@@ -2611,8 +2590,7 @@ flush_to_flip_buffer(struct e100_serial *info)
tty_flip_buffer_push(tty);
}
-static _INLINE_ void
-check_flush_timeout(struct e100_serial *info)
+static void check_flush_timeout(struct e100_serial *info)
{
/* Flip what we've got (if we can) */
flush_to_flip_buffer(info);
@@ -2741,7 +2719,7 @@ TODO: The break will be delayed until an F or V character is received.
*/
-extern _INLINE_
+static
struct e100_serial * handle_ser_rx_interrupt_no_dma(struct e100_serial *info)
{
unsigned long data_read;
@@ -2875,8 +2853,7 @@ more_data:
return info;
}
-extern _INLINE_
-struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
+static struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
{
unsigned char rstat;
@@ -2995,7 +2972,7 @@ struct e100_serial* handle_ser_rx_interrupt(struct e100_serial *info)
return info;
} /* handle_ser_rx_interrupt */
-extern _INLINE_ void handle_ser_tx_interrupt(struct e100_serial *info)
+static void handle_ser_tx_interrupt(struct e100_serial *info)
{
unsigned long flags;
@@ -3621,9 +3598,8 @@ rs_flush_chars(struct tty_struct *tty)
restore_flags(flags);
}
-extern _INLINE_ int
-rs_raw_write(struct tty_struct * tty, int from_user,
- const unsigned char *buf, int count)
+static int rs_raw_write(struct tty_struct * tty, int from_user,
+ const unsigned char *buf, int count)
{
int c, ret = 0;
struct e100_serial *info = (struct e100_serial *)tty->driver_data;
@@ -4710,7 +4686,7 @@ rs_open(struct tty_struct *tty, struct file * filp)
* /proc fs routines....
*/
-extern _INLINE_ int line_info(char *buf, struct e100_serial *info)
+static int line_info(char *buf, struct e100_serial *info)
{
char stat_buf[30];
int ret;
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index ba5541de673..bf71bad5c34 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -674,11 +674,12 @@ static void dz_reset(struct dz_port *dport)
}
#ifdef CONFIG_SERIAL_DZ_CONSOLE
-static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
+static void dz_console_putchar(struct uart_port *port, int ch)
{
+ struct dz_port *dport = (struct dz_port *)uport;
unsigned long flags;
int loops = 2500;
- unsigned short tmp = ch;
+ unsigned short tmp = (unsigned char)ch;
/* this code sends stuff out to serial device - spinning its
wheels and waiting. */
@@ -694,6 +695,7 @@ static void dz_console_put_char(struct dz_port *dport, unsigned char ch)
spin_unlock_irqrestore(&dport->port.lock, flags);
}
+
/*
* -------------------------------------------------------------------
* dz_console_print ()
@@ -710,11 +712,7 @@ static void dz_console_print(struct console *cons,
#ifdef DEBUG_DZ
prom_printf((char *) str);
#endif
- while (count--) {
- if (*str == '\n')
- dz_console_put_char(dport, '\r');
- dz_console_put_char(dport, *str++);
- }
+ uart_console_write(&dport->port, str, count, dz_console_putchar);
}
static int __init dz_console_setup(struct console *co, char *options)
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 4d53fb5ca87..c3b7a6673e9 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -743,6 +743,13 @@ static void __init imx_init_ports(void)
}
#ifdef CONFIG_SERIAL_IMX_CONSOLE
+static void imx_console_putchar(struct uart_port *port, int ch)
+{
+ struct imx_port *sport = (struct imx_port *)port;
+ while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
+ barrier();
+ URTX0((u32)sport->port.membase) = ch;
+}
/*
* Interrupts are disabled on entering
@@ -751,7 +758,7 @@ static void
imx_console_write(struct console *co, const char *s, unsigned int count)
{
struct imx_port *sport = &imx_ports[co->index];
- unsigned int old_ucr1, old_ucr2, i;
+ unsigned int old_ucr1, old_ucr2;
/*
* First, save UCR1/2 and then disable interrupts
@@ -764,22 +771,7 @@ imx_console_write(struct console *co, const char *s, unsigned int count)
& ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN);
UCR2((u32)sport->port.membase) = old_ucr2 | UCR2_TXEN;
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
-
- while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
- barrier();
-
- URTX0((u32)sport->port.membase) = s[i];
-
- if (s[i] == '\n') {
- while ((UTS((u32)sport->port.membase) & UTS_TXFULL))
- barrier();
- URTX0((u32)sport->port.membase) = '\r';
- }
- }
+ uart_console_write(&sport->port, s, count, imx_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/ioc4_serial.c b/drivers/serial/ioc4_serial.c
index a37579ce6d7..c620209d7b9 100644
--- a/drivers/serial/ioc4_serial.c
+++ b/drivers/serial/ioc4_serial.c
@@ -3,7 +3,7 @@
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
- * Copyright (C) 2003-2005 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (C) 2003-2006 Silicon Graphics, Inc. All Rights Reserved.
*/
@@ -323,9 +323,12 @@ static unsigned int Num_of_ioc4_cards;
#define IOC4_FIFO_CHARS 255
/* Device name we're using */
-#define DEVICE_NAME "ttyIOC"
-#define DEVICE_MAJOR 204
-#define DEVICE_MINOR 50
+#define DEVICE_NAME_RS232 "ttyIOC"
+#define DEVICE_NAME_RS422 "ttyAIOC"
+#define DEVICE_MAJOR 204
+#define DEVICE_MINOR_RS232 50
+#define DEVICE_MINOR_RS422 84
+
/* register offsets */
#define IOC4_SERIAL_OFFSET 0x300
@@ -341,10 +344,8 @@ static unsigned int Num_of_ioc4_cards;
#define MAX_BAUD_SUPPORTED 115200
/* protocol types supported */
-enum sio_proto {
- PROTO_RS232,
- PROTO_RS422
-};
+#define PROTO_RS232 3
+#define PROTO_RS422 7
/* Notification types */
#define N_DATA_READY 0x01
@@ -395,11 +396,17 @@ enum sio_proto {
/*
* This is the entry saved by the driver - one per card
*/
+
+#define UART_PORT_MIN 0
+#define UART_PORT_RS232 UART_PORT_MIN
+#define UART_PORT_RS422 1
+#define UART_PORT_COUNT 2 /* one for each mode */
+
struct ioc4_control {
int ic_irq;
struct {
- /* uart ports are allocated here */
- struct uart_port icp_uart_port;
+ /* uart ports are allocated here - 1 for rs232, 1 for rs422 */
+ struct uart_port icp_uart_port[UART_PORT_COUNT];
/* Handy reference material */
struct ioc4_port *icp_port;
} ic_port[IOC4_NUM_SERIAL_PORTS];
@@ -443,7 +450,9 @@ struct ioc4_soft {
/* Local port info for each IOC4 serial ports */
struct ioc4_port {
- struct uart_port *ip_port;
+ struct uart_port *ip_port; /* current active port ptr */
+ /* Ptrs for all ports */
+ struct uart_port *ip_all_ports[UART_PORT_COUNT];
/* Back ptrs for this port */
struct ioc4_control *ip_control;
struct pci_dev *ip_pdev;
@@ -502,6 +511,9 @@ struct ioc4_port {
#define DCD_ON 0x02
#define LOWAT_WRITTEN 0x04
#define READ_ABORTED 0x08
+#define PORT_ACTIVE 0x10
+#define PORT_INACTIVE 0 /* This is the value when "off" */
+
/* Since each port has different register offsets and bitmasks
* for everything, we'll store those that we need in tables so we
@@ -623,6 +635,23 @@ struct ring_buffer {
static void receive_chars(struct uart_port *);
static void handle_intr(void *arg, uint32_t sio_ir);
+/*
+ * port_is_active - determines if this port is currently active
+ * @port: ptr to soft struct for this port
+ * @uart_port: uart port to test for
+ */
+static inline int port_is_active(struct ioc4_port *port,
+ struct uart_port *uart_port)
+{
+ if (port) {
+ if ((port->ip_flags & PORT_ACTIVE)
+ && (port->ip_port == uart_port))
+ return 1;
+ }
+ return 0;
+}
+
+
/**
* write_ireg - write the interrupt regs
* @ioc4_soft: ptr to soft struct for this port
@@ -708,19 +737,33 @@ static int set_baud(struct ioc4_port *port, int baud)
/**
* get_ioc4_port - given a uart port, return the control structure
* @port: uart port
+ * @set: set this port as current
*/
-static struct ioc4_port *get_ioc4_port(struct uart_port *the_port)
+static struct ioc4_port *get_ioc4_port(struct uart_port *the_port, int set)
{
struct ioc4_driver_data *idd = dev_get_drvdata(the_port->dev);
struct ioc4_control *control = idd->idd_serial_data;
- int ii;
+ struct ioc4_port *port;
+ int port_num, port_type;
if (control) {
- for ( ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++ ) {
- if (!control->ic_port[ii].icp_port)
+ for ( port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS;
+ port_num++ ) {
+ port = control->ic_port[port_num].icp_port;
+ if (!port)
continue;
- if (the_port == control->ic_port[ii].icp_port->ip_port)
- return control->ic_port[ii].icp_port;
+ for (port_type = UART_PORT_MIN;
+ port_type < UART_PORT_COUNT;
+ port_type++) {
+ if (the_port == port->ip_all_ports
+ [port_type]) {
+ /* set local copy */
+ if (set) {
+ port->ip_port = the_port;
+ }
+ return port;
+ }
+ }
}
}
return NULL;
@@ -946,6 +989,7 @@ intr_connect(struct ioc4_soft *soft, int type,
* @arg: handler arg
* @regs: registers
*/
+
static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
{
struct ioc4_soft *soft;
@@ -953,7 +997,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
int xx, num_intrs = 0;
int intr_type;
int handled = 0;
- struct ioc4_intr_info *ii;
+ struct ioc4_intr_info *intr_info;
soft = arg;
for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
@@ -966,13 +1010,13 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
* which interrupt bits are set.
*/
for (xx = 0; xx < num_intrs; xx++) {
- ii = &soft->is_intr_type[intr_type].is_intr_info[xx];
- if ((this_mir = this_ir & ii->sd_bits)) {
+ intr_info = &soft->is_intr_type[intr_type].is_intr_info[xx];
+ if ((this_mir = this_ir & intr_info->sd_bits)) {
/* Disable owned interrupts, call handler */
handled++;
- write_ireg(soft, ii->sd_bits, IOC4_W_IEC,
+ write_ireg(soft, intr_info->sd_bits, IOC4_W_IEC,
intr_type);
- ii->sd_intr(ii->sd_info, this_mir);
+ intr_info->sd_intr(intr_info->sd_info, this_mir);
this_ir &= ~this_mir;
}
}
@@ -980,7 +1024,6 @@ static irqreturn_t ioc4_intr(int irq, void *arg, struct pt_regs *regs)
#ifdef DEBUG_INTERRUPTS
{
struct ioc4_misc_regs __iomem *mem = soft->is_ioc4_misc_addr;
- spinlock_t *lp = &soft->is_ir_lock;
unsigned long flag;
spin_lock_irqsave(&soft->is_ir_lock, flag);
@@ -1177,7 +1220,7 @@ static inline int local_open(struct ioc4_port *port)
{
int spiniter = 0;
- port->ip_flags = 0;
+ port->ip_flags = PORT_ACTIVE;
/* Pause the DMA interface if necessary */
if (port->ip_sscr & IOC4_SSCR_DMA_EN) {
@@ -1187,6 +1230,7 @@ static inline int local_open(struct ioc4_port *port)
& IOC4_SSCR_PAUSE_STATE) == 0) {
spiniter++;
if (spiniter > MAXITER) {
+ port->ip_flags = PORT_INACTIVE;
return -1;
}
}
@@ -1506,14 +1550,13 @@ static int set_notification(struct ioc4_port *port, int mask, int set_on)
/**
* set_mcr - set the master control reg
* @the_port: port to use
- * @set: set ?
* @mask1: mcr mask
* @mask2: shadow mask
*/
-static inline int set_mcr(struct uart_port *the_port, int set,
+static inline int set_mcr(struct uart_port *the_port,
int mask1, int mask2)
{
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
uint32_t shadow;
int spiniter = 0;
char mcr;
@@ -1536,13 +1579,9 @@ static inline int set_mcr(struct uart_port *the_port, int set,
mcr = (shadow & 0xff000000) >> 24;
/* Set new value */
- if (set) {
- mcr |= mask1;
- shadow |= mask2;
- } else {
- mcr &= ~mask1;
- shadow &= ~mask2;
- }
+ mcr |= mask1;
+ shadow |= mask2;
+
writeb(mcr, &port->ip_uart_regs->i4u_mcr);
writel(shadow, &port->ip_serial_regs->shadow);
@@ -1558,7 +1597,7 @@ static inline int set_mcr(struct uart_port *the_port, int set,
* @port: port to use
* @proto: protocol to use
*/
-static int ioc4_set_proto(struct ioc4_port *port, enum sio_proto proto)
+static int ioc4_set_proto(struct ioc4_port *port, int proto)
{
struct hooks *hooks = port->ip_hooks;
@@ -1589,7 +1628,7 @@ static void transmit_chars(struct uart_port *the_port)
int result;
char *start;
struct tty_struct *tty;
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
struct uart_info *info;
if (!the_port)
@@ -1645,7 +1684,7 @@ static void
ioc4_change_speed(struct uart_port *the_port,
struct termios *new_termios, struct termios *old_termios)
{
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
int baud, bits;
unsigned cflag;
int new_parity = 0, new_parity_enable = 0, new_stop = 0, new_data = 8;
@@ -1752,7 +1791,7 @@ static inline int ic4_startup_local(struct uart_port *the_port)
if (!the_port)
return -1;
- port = get_ioc4_port(the_port);
+ port = get_ioc4_port(the_port, 0);
if (!port)
return -1;
@@ -1760,6 +1799,9 @@ static inline int ic4_startup_local(struct uart_port *the_port)
local_open(port);
+ /* set the protocol - mapbase has the port type */
+ ioc4_set_proto(port, the_port->mapbase);
+
/* set the speed of the serial port */
ioc4_change_speed(the_port, info->tty->termios, (struct termios *)0);
@@ -1768,17 +1810,17 @@ static inline int ic4_startup_local(struct uart_port *the_port)
/*
* ioc4_cb_output_lowat - called when the output low water mark is hit
- * @port: port to output
+ * @the_port: port to output
*/
-static void ioc4_cb_output_lowat(struct ioc4_port *port)
+static void ioc4_cb_output_lowat(struct uart_port *the_port)
{
unsigned long pflags;
/* ip_lock is set on the call here */
- if (port->ip_port) {
- spin_lock_irqsave(&port->ip_port->lock, pflags);
- transmit_chars(port->ip_port);
- spin_unlock_irqrestore(&port->ip_port->lock, pflags);
+ if (the_port) {
+ spin_lock_irqsave(&the_port->lock, pflags);
+ transmit_chars(the_port);
+ spin_unlock_irqrestore(&the_port->lock, pflags);
}
}
@@ -1923,7 +1965,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
&port->ip_mem->sio_ir.raw);
if (port->ip_notify & N_OUTPUT_LOWAT)
- ioc4_cb_output_lowat(port);
+ ioc4_cb_output_lowat(port->ip_port);
}
/* Handle tx_mt. Must come after tx_explicit. */
@@ -1936,7 +1978,7 @@ static void handle_intr(void *arg, uint32_t sio_ir)
* So send the notification now.
*/
if (port->ip_notify & N_OUTPUT_LOWAT) {
- ioc4_cb_output_lowat(port);
+ ioc4_cb_output_lowat(port->ip_port);
/* We need to reload the sio_ir since the lowat
* call may have caused another write to occur,
@@ -2023,7 +2065,7 @@ static inline int do_read(struct uart_port *the_port, unsigned char *buf,
int len)
{
int prod_ptr, cons_ptr, total;
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
struct ring *inring;
struct ring_entry *entry;
struct hooks *hooks = port->ip_hooks;
@@ -2335,17 +2377,27 @@ static void receive_chars(struct uart_port *the_port)
*/
static const char *ic4_type(struct uart_port *the_port)
{
- return "SGI IOC4 Serial";
+ if (the_port->mapbase == PROTO_RS232)
+ return "SGI IOC4 Serial [rs232]";
+ else
+ return "SGI IOC4 Serial [rs422]";
}
/**
- * ic4_tx_empty - Is the transmitter empty? We pretend we're always empty
- * @port: Port to operate on (we ignore since we always return 1)
+ * ic4_tx_empty - Is the transmitter empty?
+ * @port: Port to operate on
*
*/
static unsigned int ic4_tx_empty(struct uart_port *the_port)
{
- return 1;
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
+ unsigned int ret = 0;
+
+ if (port_is_active(port, the_port)) {
+ if (readl(&port->ip_serial_regs->shadow) & IOC4_SHADOW_TEMT)
+ ret = TIOCSER_TEMT;
+ }
+ return ret;
}
/**
@@ -2355,6 +2407,10 @@ static unsigned int ic4_tx_empty(struct uart_port *the_port)
*/
static void ic4_stop_tx(struct uart_port *the_port)
{
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
+
+ if (port_is_active(port, the_port))
+ set_notification(port, N_OUTPUT_LOWAT, 0);
}
/**
@@ -2377,11 +2433,12 @@ static void ic4_shutdown(struct uart_port *the_port)
struct ioc4_port *port;
struct uart_info *info;
- port = get_ioc4_port(the_port);
+ port = get_ioc4_port(the_port, 0);
if (!port)
return;
info = the_port->info;
+ port->ip_port = NULL;
wake_up_interruptible(&info->delta_msr_wait);
@@ -2390,6 +2447,7 @@ static void ic4_shutdown(struct uart_port *the_port)
spin_lock_irqsave(&the_port->lock, port_flags);
set_notification(port, N_ALL, 0);
+ port->ip_flags = PORT_INACTIVE;
spin_unlock_irqrestore(&the_port->lock, port_flags);
}
@@ -2402,6 +2460,11 @@ static void ic4_shutdown(struct uart_port *the_port)
static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
{
unsigned char mcr = 0;
+ struct ioc4_port *port;
+
+ port = get_ioc4_port(the_port, 0);
+ if (!port_is_active(port, the_port))
+ return;
if (mctrl & TIOCM_RTS)
mcr |= UART_MCR_RTS;
@@ -2414,7 +2477,7 @@ static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
if (mctrl & TIOCM_LOOP)
mcr |= UART_MCR_LOOP;
- set_mcr(the_port, 1, mcr, IOC4_SHADOW_DTR);
+ set_mcr(the_port, mcr, IOC4_SHADOW_DTR);
}
/**
@@ -2424,11 +2487,11 @@ static void ic4_set_mctrl(struct uart_port *the_port, unsigned int mctrl)
*/
static unsigned int ic4_get_mctrl(struct uart_port *the_port)
{
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
uint32_t shadow;
unsigned int ret = 0;
- if (!port)
+ if (!port_is_active(port, the_port))
return 0;
shadow = readl(&port->ip_serial_regs->shadow);
@@ -2448,9 +2511,9 @@ static unsigned int ic4_get_mctrl(struct uart_port *the_port)
*/
static void ic4_start_tx(struct uart_port *the_port)
{
- struct ioc4_port *port = get_ioc4_port(the_port);
+ struct ioc4_port *port = get_ioc4_port(the_port, 0);
- if (port) {
+ if (port_is_active(port, the_port)) {
set_notification(port, N_OUTPUT_LOWAT, 1);
enable_intrs(port, port->ip_hooks->intr_tx_mt);
}
@@ -2467,7 +2530,7 @@ static void ic4_break_ctl(struct uart_port *the_port, int break_state)
}
/**
- * ic4_startup - Start up the serial port - always return 0 (We're always on)
+ * ic4_startup - Start up the serial port
* @port: Port to operate on
*
*/
@@ -2479,17 +2542,16 @@ static int ic4_startup(struct uart_port *the_port)
struct uart_info *info;
unsigned long port_flags;
- if (!the_port) {
+ if (!the_port)
return -ENODEV;
- }
- port = get_ioc4_port(the_port);
- if (!port) {
+ port = get_ioc4_port(the_port, 1);
+ if (!port)
return -ENODEV;
- }
info = the_port->info;
control = port->ip_control;
if (!control) {
+ port->ip_port = NULL;
return -ENODEV;
}
@@ -2551,28 +2613,104 @@ static struct uart_ops ioc4_ops = {
* Boot-time initialization code
*/
-static struct uart_driver ioc4_uart = {
+static struct uart_driver ioc4_uart_rs232 = {
.owner = THIS_MODULE,
- .driver_name = "ioc4_serial",
- .dev_name = DEVICE_NAME,
+ .driver_name = "ioc4_serial_rs232",
+ .dev_name = DEVICE_NAME_RS232,
.major = DEVICE_MAJOR,
- .minor = DEVICE_MINOR,
+ .minor = DEVICE_MINOR_RS232,
.nr = IOC4_NUM_CARDS * IOC4_NUM_SERIAL_PORTS,
};
+static struct uart_driver ioc4_uart_rs422 = {
+ .owner = THIS_MODULE,
+ .driver_name = "ioc4_serial_rs422",
+ .dev_name = DEVICE_NAME_RS422,
+ .major = DEVICE_MAJOR,
+ .minor = DEVICE_MINOR_RS422,
+ .nr = IOC4_NUM_CARDS * IOC4_NUM_SERIAL_PORTS,
+};
+
+
/**
- * ioc4_serial_core_attach - register with serial core
+ * ioc4_serial_remove_one - detach function
+ *
+ * @idd: IOC4 master module data for this IOC4
+ */
+
+static int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
+{
+ int port_num, port_type;
+ struct ioc4_control *control;
+ struct uart_port *the_port;
+ struct ioc4_port *port;
+ struct ioc4_soft *soft;
+
+ control = idd->idd_serial_data;
+
+ for (port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS; port_num++) {
+ for (port_type = UART_PORT_MIN;
+ port_type < UART_PORT_COUNT;
+ port_type++) {
+ the_port = &control->ic_port[port_num].icp_uart_port
+ [port_type];
+ if (the_port) {
+ switch (port_type) {
+ case UART_PORT_RS422:
+ uart_remove_one_port(&ioc4_uart_rs422,
+ the_port);
+ break;
+ default:
+ case UART_PORT_RS232:
+ uart_remove_one_port(&ioc4_uart_rs232,
+ the_port);
+ break;
+ }
+ }
+ }
+ port = control->ic_port[port_num].icp_port;
+ /* we allocate in pairs */
+ if (!(port_num & 1) && port) {
+ pci_free_consistent(port->ip_pdev,
+ TOTAL_RING_BUF_SIZE,
+ port->ip_cpu_ringbuf,
+ port->ip_dma_ringbuf);
+ kfree(port);
+ }
+ }
+ soft = control->ic_soft;
+ if (soft) {
+ free_irq(control->ic_irq, soft);
+ if (soft->is_ioc4_serial_addr) {
+ release_region((unsigned long)
+ soft->is_ioc4_serial_addr,
+ sizeof(struct ioc4_serial));
+ }
+ kfree(soft);
+ }
+ kfree(control);
+ idd->idd_serial_data = NULL;
+
+ return 0;
+}
+
+
+/**
+ * ioc4_serial_core_attach_rs232 - register with serial core
* This is done during pci probing
* @pdev: handle for this card
*/
static inline int
-ioc4_serial_core_attach(struct pci_dev *pdev)
+ioc4_serial_core_attach(struct pci_dev *pdev, int port_type)
{
struct ioc4_port *port;
struct uart_port *the_port;
struct ioc4_driver_data *idd = pci_get_drvdata(pdev);
struct ioc4_control *control = idd->idd_serial_data;
- int ii;
+ int port_num;
+ int port_type_idx;
+ struct uart_driver *u_driver;
+
DPRINT_CONFIG(("%s: attach pdev 0x%p - control 0x%p\n",
__FUNCTION__, pdev, (void *)control));
@@ -2580,28 +2718,36 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
if (!control)
return -ENODEV;
+ port_type_idx = (port_type == PROTO_RS232) ? UART_PORT_RS232
+ : UART_PORT_RS422;
+
+ u_driver = (port_type == PROTO_RS232) ? &ioc4_uart_rs232
+ : &ioc4_uart_rs422;
+
/* once around for each port on this card */
- for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) {
- the_port = &control->ic_port[ii].icp_uart_port;
- port = control->ic_port[ii].icp_port;
- port->ip_port = the_port;
+ for (port_num = 0; port_num < IOC4_NUM_SERIAL_PORTS; port_num++) {
+ the_port = &control->ic_port[port_num].icp_uart_port
+ [port_type_idx];
+ port = control->ic_port[port_num].icp_port;
+ port->ip_all_ports[port_type_idx] = the_port;
- DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p\n",
+ DPRINT_CONFIG(("%s: attach the_port 0x%p / port 0x%p : type %s\n",
__FUNCTION__, (void *)the_port,
- (void *)port));
+ (void *)port,
+ port_type == PROTO_RS232 ? "rs232" : "rs422"));
/* membase, iobase and mapbase just need to be non-0 */
the_port->membase = (unsigned char __iomem *)1;
- the_port->iobase = (pdev->bus->number << 16) | ii;
- the_port->line = (Num_of_ioc4_cards << 2) | ii;
- the_port->mapbase = 1;
+ the_port->iobase = (pdev->bus->number << 16) | port_num;
+ the_port->line = (Num_of_ioc4_cards << 2) | port_num;
+ the_port->mapbase = port_type;
the_port->type = PORT_16550A;
the_port->fifosize = IOC4_FIFO_CHARS;
the_port->ops = &ioc4_ops;
the_port->irq = control->ic_irq;
the_port->dev = &pdev->dev;
spin_lock_init(&the_port->lock);
- if (uart_add_one_port(&ioc4_uart, the_port) < 0) {
+ if (uart_add_one_port(u_driver, the_port) < 0) {
printk(KERN_WARNING
"%s: unable to add port %d bus %d\n",
__FUNCTION__, the_port->line, pdev->bus->number);
@@ -2610,8 +2756,6 @@ ioc4_serial_core_attach(struct pci_dev *pdev)
("IOC4 serial port %d irq = %d, bus %d\n",
the_port->line, the_port->irq, pdev->bus->number));
}
- /* all ports are rs232 for now */
- ioc4_set_proto(port, PROTO_RS232);
}
return 0;
}
@@ -2631,7 +2775,8 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
int ret = 0;
- DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev, idd->idd_pci_id));
+ DPRINT_CONFIG(("%s (0x%p, 0x%p)\n", __FUNCTION__, idd->idd_pdev,
+ idd->idd_pci_id));
/* request serial registers */
tmp_addr1 = idd->idd_bar0 + IOC4_SERIAL_OFFSET;
@@ -2653,11 +2798,11 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
goto out2;
}
DPRINT_CONFIG(("%s : mem 0x%p, serial 0x%p\n",
- __FUNCTION__, (void *)idd->idd_misc_regs, (void *)serial));
+ __FUNCTION__, (void *)idd->idd_misc_regs,
+ (void *)serial));
/* Get memory for the new card */
- control = kmalloc(sizeof(struct ioc4_control) * IOC4_NUM_SERIAL_PORTS,
- GFP_KERNEL);
+ control = kmalloc(sizeof(struct ioc4_control), GFP_KERNEL);
if (!control) {
printk(KERN_WARNING "ioc4_attach_one"
@@ -2702,7 +2847,7 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
/* Hook up interrupt handler */
if (!request_irq(idd->idd_pdev->irq, ioc4_intr, SA_SHIRQ,
- "sgi-ioc4serial", (void *)soft)) {
+ "sgi-ioc4serial", soft)) {
control->ic_irq = idd->idd_pdev->irq;
} else {
printk(KERN_WARNING
@@ -2713,16 +2858,21 @@ ioc4_serial_attach_one(struct ioc4_driver_data *idd)
if (ret)
goto out4;
- /* register port with the serial core */
+ /* register port with the serial core - 1 rs232, 1 rs422 */
- if ((ret = ioc4_serial_core_attach(idd->idd_pdev)))
+ if ((ret = ioc4_serial_core_attach(idd->idd_pdev, PROTO_RS232)))
goto out4;
+ if ((ret = ioc4_serial_core_attach(idd->idd_pdev, PROTO_RS422)))
+ goto out5;
+
Num_of_ioc4_cards++;
return ret;
/* error exits that give back resources */
+out5:
+ ioc4_serial_remove_one(idd);
out4:
kfree(soft);
out3:
@@ -2735,52 +2885,6 @@ out1:
}
-/**
- * ioc4_serial_remove_one - detach function
- *
- * @idd: IOC4 master module data for this IOC4
- */
-
-int ioc4_serial_remove_one(struct ioc4_driver_data *idd)
-{
- int ii;
- struct ioc4_control *control;
- struct uart_port *the_port;
- struct ioc4_port *port;
- struct ioc4_soft *soft;
-
- control = idd->idd_serial_data;
-
- for (ii = 0; ii < IOC4_NUM_SERIAL_PORTS; ii++) {
- the_port = &control->ic_port[ii].icp_uart_port;
- if (the_port) {
- uart_remove_one_port(&ioc4_uart, the_port);
- }
- port = control->ic_port[ii].icp_port;
- if (!(ii & 1) && port) {
- pci_free_consistent(port->ip_pdev,
- TOTAL_RING_BUF_SIZE,
- (void *)port->ip_cpu_ringbuf,
- port->ip_dma_ringbuf);
- kfree(port);
- }
- }
- soft = control->ic_soft;
- if (soft) {
- free_irq(control->ic_irq, (void *)soft);
- if (soft->is_ioc4_serial_addr) {
- release_region((unsigned long)
- soft->is_ioc4_serial_addr,
- sizeof(struct ioc4_serial));
- }
- kfree(soft);
- }
- kfree(control);
- idd->idd_serial_data = NULL;
-
- return 0;
-}
-
static struct ioc4_submodule ioc4_serial_submodule = {
.is_name = "IOC4_serial",
.is_owner = THIS_MODULE,
@@ -2796,9 +2900,15 @@ int ioc4_serial_init(void)
int ret;
/* register with serial core */
- if ((ret = uart_register_driver(&ioc4_uart)) < 0) {
+ if ((ret = uart_register_driver(&ioc4_uart_rs232)) < 0) {
+ printk(KERN_WARNING
+ "%s: Couldn't register rs232 IOC4 serial driver\n",
+ __FUNCTION__);
+ return ret;
+ }
+ if ((ret = uart_register_driver(&ioc4_uart_rs422)) < 0) {
printk(KERN_WARNING
- "%s: Couldn't register IOC4 serial driver\n",
+ "%s: Couldn't register rs422 IOC4 serial driver\n",
__FUNCTION__);
return ret;
}
@@ -2810,7 +2920,8 @@ int ioc4_serial_init(void)
static void __devexit ioc4_serial_exit(void)
{
ioc4_unregister_submodule(&ioc4_serial_submodule);
- uart_unregister_driver(&ioc4_uart);
+ uart_unregister_driver(&ioc4_uart_rs232);
+ uart_unregister_driver(&ioc4_uart_rs422);
}
module_init(ioc4_serial_init);
diff --git a/drivers/serial/ip22zilog.c b/drivers/serial/ip22zilog.c
index 193722d680c..651772474ac 100644
--- a/drivers/serial/ip22zilog.c
+++ b/drivers/serial/ip22zilog.c
@@ -967,8 +967,9 @@ static struct zilog_layout * __init get_zs(int chip)
#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
#ifdef CONFIG_SERIAL_IP22_ZILOG_CONSOLE
-static void ip22zilog_put_char(struct zilog_channel *channel, unsigned char ch)
+static void ip22zilog_put_char(struct uart_port *port, int ch)
{
+ struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
int loops = ZS_PUT_CHAR_MAX_DELAY;
/* This is a timed polling loop so do not switch the explicit
@@ -992,16 +993,10 @@ static void
ip22zilog_console_write(struct console *con, const char *s, unsigned int count)
{
struct uart_ip22zilog_port *up = &ip22zilog_port_table[con->index];
- struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
unsigned long flags;
- int i;
spin_lock_irqsave(&up->port.lock, flags);
- for (i = 0; i < count; i++, s++) {
- ip22zilog_put_char(channel, *s);
- if (*s == 10)
- ip22zilog_put_char(channel, 13);
- }
+ uart_console_write(&up->port, s, count, ip22zilog_put_char);
udelay(2);
spin_unlock_irqrestore(&up->port.lock, flags);
}
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c
index 242a0410439..e9c10c0a30f 100644
--- a/drivers/serial/m32r_sio.c
+++ b/drivers/serial/m32r_sio.c
@@ -248,17 +248,17 @@ static void sio_error(int *status)
#endif /* CONFIG_SERIAL_M32R_PLDSIO */
-static _INLINE_ unsigned int sio_in(struct uart_sio_port *up, int offset)
+static unsigned int sio_in(struct uart_sio_port *up, int offset)
{
return __sio_in(up->port.iobase + offset);
}
-static _INLINE_ void sio_out(struct uart_sio_port *up, int offset, int value)
+static void sio_out(struct uart_sio_port *up, int offset, int value)
{
__sio_out(value, up->port.iobase + offset);
}
-static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
+static unsigned int serial_in(struct uart_sio_port *up, int offset)
{
if (!offset)
return 0;
@@ -266,8 +266,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sio_port *up, int offset)
return __sio_in(offset);
}
-static _INLINE_ void
-serial_out(struct uart_sio_port *up, int offset, int value)
+static void serial_out(struct uart_sio_port *up, int offset, int value)
{
if (!offset)
return;
@@ -326,8 +325,8 @@ static void m32r_sio_enable_ms(struct uart_port *port)
serial_out(up, UART_IER, up->ier);
}
-static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
- struct pt_regs *regs)
+static void receive_chars(struct uart_sio_port *up, int *status,
+ struct pt_regs *regs)
{
struct tty_struct *tty = up->port.info->tty;
unsigned char ch;
@@ -400,7 +399,7 @@ static _INLINE_ void receive_chars(struct uart_sio_port *up, int *status,
tty_flip_buffer_push(tty);
}
-static _INLINE_ void transmit_chars(struct uart_sio_port *up)
+static void transmit_chars(struct uart_sio_port *up)
{
struct circ_buf *xmit = &up->port.info->xmit;
int count;
@@ -1039,6 +1038,14 @@ static inline void wait_for_xmitr(struct uart_sio_port *up)
}
}
+static void m32r_sio_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_sio_port *up = (struct uart_sio_port *)port;
+
+ wait_for_xmitr(up);
+ sio_out(up, SIOTXB, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -1058,23 +1065,7 @@ static void m32r_sio_console_write(struct console *co, const char *s,
ier = sio_in(up, SIOTRCR);
sio_out(up, SIOTRCR, 0);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- sio_out(up, SIOTXB, *s);
-
- if (*s == 10) {
- wait_for_xmitr(up);
- sio_out(up, SIOTXB, 13);
- }
- }
+ uart_console_write(&up->port, s, count, m32r_sio_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
index 61dd17d7bac..6459edc7f5c 100644
--- a/drivers/serial/mpc52xx_uart.c
+++ b/drivers/serial/mpc52xx_uart.c
@@ -40,7 +40,7 @@
* and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
* so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
* fpr the console code : without this 1:1 mapping, at early boot time, when we
- * are parsing the kernel args console=ttyPSC?, we wouldn't know wich PSC it
+ * are parsing the kernel args console=ttyPSC?, we wouldn't know which PSC it
* will be mapped to.
*/
@@ -603,15 +603,14 @@ mpc52xx_console_write(struct console *co, const char *s, unsigned int count)
udelay(1);
/* Write all the chars */
- for ( i=0 ; i<count ; i++ ) {
-
- /* Send the char */
- out_8(&psc->mpc52xx_psc_buffer_8, *s);
-
+ for (i = 0; i < count; i++, s++) {
/* Line return handling */
- if ( *s++ == '\n' )
+ if (*s == '\n')
out_8(&psc->mpc52xx_psc_buffer_8, '\r');
+ /* Send the char */
+ out_8(&psc->mpc52xx_psc_buffer_8, *s);
+
/* Wait the TX buffer to be empty */
j = 20000; /* Maximum wait */
while (!(in_be16(&psc->mpc52xx_psc_status) &
diff --git a/drivers/serial/mpsc.c b/drivers/serial/mpsc.c
index 0ca83ac31d0..94681922ea0 100644
--- a/drivers/serial/mpsc.c
+++ b/drivers/serial/mpsc.c
@@ -1,6 +1,4 @@
/*
- * drivers/serial/mpsc.c
- *
* Generic driver for the MPSC (UART mode) on Marvell parts (e.g., GT64240,
* GT64260, MV64340, MV64360, GT96100, ... ).
*
@@ -52,9 +50,263 @@
* 4) AFAICT, hardware flow control isn't supported by the controller --MAG.
*/
+#include <linux/config.h>
+
+#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/ioport.h>
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/sysrq.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/dma-mapping.h>
+#include <linux/mv643xx.h>
#include <linux/platform_device.h>
-#include "mpsc.h"
+#include <asm/io.h>
+#include <asm/irq.h>
+
+#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
+#define SUPPORT_SYSRQ
+#endif
+
+#define MPSC_NUM_CTLRS 2
+
+/*
+ * Descriptors and buffers must be cache line aligned.
+ * Buffers lengths must be multiple of cache line size.
+ * Number of Tx & Rx descriptors must be powers of 2.
+ */
+#define MPSC_RXR_ENTRIES 32
+#define MPSC_RXRE_SIZE dma_get_cache_alignment()
+#define MPSC_RXR_SIZE (MPSC_RXR_ENTRIES * MPSC_RXRE_SIZE)
+#define MPSC_RXBE_SIZE dma_get_cache_alignment()
+#define MPSC_RXB_SIZE (MPSC_RXR_ENTRIES * MPSC_RXBE_SIZE)
+
+#define MPSC_TXR_ENTRIES 32
+#define MPSC_TXRE_SIZE dma_get_cache_alignment()
+#define MPSC_TXR_SIZE (MPSC_TXR_ENTRIES * MPSC_TXRE_SIZE)
+#define MPSC_TXBE_SIZE dma_get_cache_alignment()
+#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
+
+#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \
+ MPSC_TXR_SIZE + MPSC_TXB_SIZE + \
+ dma_get_cache_alignment() /* for alignment */)
+
+/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
+struct mpsc_rx_desc {
+ u16 bufsize;
+ u16 bytecnt;
+ u32 cmdstat;
+ u32 link;
+ u32 buf_ptr;
+} __attribute((packed));
+
+struct mpsc_tx_desc {
+ u16 bytecnt;
+ u16 shadow;
+ u32 cmdstat;
+ u32 link;
+ u32 buf_ptr;
+} __attribute((packed));
+
+/*
+ * Some regs that have the erratum that you can't read them are are shared
+ * between the two MPSC controllers. This struct contains those shared regs.
+ */
+struct mpsc_shared_regs {
+ phys_addr_t mpsc_routing_base_p;
+ phys_addr_t sdma_intr_base_p;
+
+ void __iomem *mpsc_routing_base;
+ void __iomem *sdma_intr_base;
+
+ u32 MPSC_MRR_m;
+ u32 MPSC_RCRR_m;
+ u32 MPSC_TCRR_m;
+ u32 SDMA_INTR_CAUSE_m;
+ u32 SDMA_INTR_MASK_m;
+};
+
+/* The main driver data structure */
+struct mpsc_port_info {
+ struct uart_port port; /* Overlay uart_port structure */
+
+ /* Internal driver state for this ctlr */
+ u8 ready;
+ u8 rcv_data;
+ tcflag_t c_iflag; /* save termios->c_iflag */
+ tcflag_t c_cflag; /* save termios->c_cflag */
+
+ /* Info passed in from platform */
+ u8 mirror_regs; /* Need to mirror regs? */
+ u8 cache_mgmt; /* Need manual cache mgmt? */
+ u8 brg_can_tune; /* BRG has baud tuning? */
+ u32 brg_clk_src;
+ u16 mpsc_max_idle;
+ int default_baud;
+ int default_bits;
+ int default_parity;
+ int default_flow;
+
+ /* Physical addresses of various blocks of registers (from platform) */
+ phys_addr_t mpsc_base_p;
+ phys_addr_t sdma_base_p;
+ phys_addr_t brg_base_p;
+
+ /* Virtual addresses of various blocks of registers (from platform) */
+ void __iomem *mpsc_base;
+ void __iomem *sdma_base;
+ void __iomem *brg_base;
+
+ /* Descriptor ring and buffer allocations */
+ void *dma_region;
+ dma_addr_t dma_region_p;
+
+ dma_addr_t rxr; /* Rx descriptor ring */
+ dma_addr_t rxr_p; /* Phys addr of rxr */
+ u8 *rxb; /* Rx Ring I/O buf */
+ u8 *rxb_p; /* Phys addr of rxb */
+ u32 rxr_posn; /* First desc w/ Rx data */
+
+ dma_addr_t txr; /* Tx descriptor ring */
+ dma_addr_t txr_p; /* Phys addr of txr */
+ u8 *txb; /* Tx Ring I/O buf */
+ u8 *txb_p; /* Phys addr of txb */
+ int txr_head; /* Where new data goes */
+ int txr_tail; /* Where sent data comes off */
+
+ /* Mirrored values of regs we can't read (if 'mirror_regs' set) */
+ u32 MPSC_MPCR_m;
+ u32 MPSC_CHR_1_m;
+ u32 MPSC_CHR_2_m;
+ u32 MPSC_CHR_10_m;
+ u32 BRG_BCR_m;
+ struct mpsc_shared_regs *shared_regs;
+};
+
+/* Hooks to platform-specific code */
+int mpsc_platform_register_driver(void);
+void mpsc_platform_unregister_driver(void);
+
+/* Hooks back in to mpsc common to be called by platform-specific code */
+struct mpsc_port_info *mpsc_device_probe(int index);
+struct mpsc_port_info *mpsc_device_remove(int index);
+
+/* Main MPSC Configuration Register Offsets */
+#define MPSC_MMCRL 0x0000
+#define MPSC_MMCRH 0x0004
+#define MPSC_MPCR 0x0008
+#define MPSC_CHR_1 0x000c
+#define MPSC_CHR_2 0x0010
+#define MPSC_CHR_3 0x0014
+#define MPSC_CHR_4 0x0018
+#define MPSC_CHR_5 0x001c
+#define MPSC_CHR_6 0x0020
+#define MPSC_CHR_7 0x0024
+#define MPSC_CHR_8 0x0028
+#define MPSC_CHR_9 0x002c
+#define MPSC_CHR_10 0x0030
+#define MPSC_CHR_11 0x0034
+
+#define MPSC_MPCR_FRZ (1 << 9)
+#define MPSC_MPCR_CL_5 0
+#define MPSC_MPCR_CL_6 1
+#define MPSC_MPCR_CL_7 2
+#define MPSC_MPCR_CL_8 3
+#define MPSC_MPCR_SBL_1 0
+#define MPSC_MPCR_SBL_2 1
+
+#define MPSC_CHR_2_TEV (1<<1)
+#define MPSC_CHR_2_TA (1<<7)
+#define MPSC_CHR_2_TTCS (1<<9)
+#define MPSC_CHR_2_REV (1<<17)
+#define MPSC_CHR_2_RA (1<<23)
+#define MPSC_CHR_2_CRD (1<<25)
+#define MPSC_CHR_2_EH (1<<31)
+#define MPSC_CHR_2_PAR_ODD 0
+#define MPSC_CHR_2_PAR_SPACE 1
+#define MPSC_CHR_2_PAR_EVEN 2
+#define MPSC_CHR_2_PAR_MARK 3
+
+/* MPSC Signal Routing */
+#define MPSC_MRR 0x0000
+#define MPSC_RCRR 0x0004
+#define MPSC_TCRR 0x0008
+
+/* Serial DMA Controller Interface Registers */
+#define SDMA_SDC 0x0000
+#define SDMA_SDCM 0x0008
+#define SDMA_RX_DESC 0x0800
+#define SDMA_RX_BUF_PTR 0x0808
+#define SDMA_SCRDP 0x0810
+#define SDMA_TX_DESC 0x0c00
+#define SDMA_SCTDP 0x0c10
+#define SDMA_SFTDP 0x0c14
+
+#define SDMA_DESC_CMDSTAT_PE (1<<0)
+#define SDMA_DESC_CMDSTAT_CDL (1<<1)
+#define SDMA_DESC_CMDSTAT_FR (1<<3)
+#define SDMA_DESC_CMDSTAT_OR (1<<6)
+#define SDMA_DESC_CMDSTAT_BR (1<<9)
+#define SDMA_DESC_CMDSTAT_MI (1<<10)
+#define SDMA_DESC_CMDSTAT_A (1<<11)
+#define SDMA_DESC_CMDSTAT_AM (1<<12)
+#define SDMA_DESC_CMDSTAT_CT (1<<13)
+#define SDMA_DESC_CMDSTAT_C (1<<14)
+#define SDMA_DESC_CMDSTAT_ES (1<<15)
+#define SDMA_DESC_CMDSTAT_L (1<<16)
+#define SDMA_DESC_CMDSTAT_F (1<<17)
+#define SDMA_DESC_CMDSTAT_P (1<<18)
+#define SDMA_DESC_CMDSTAT_EI (1<<23)
+#define SDMA_DESC_CMDSTAT_O (1<<31)
+
+#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \
+ SDMA_DESC_CMDSTAT_EI)
+
+#define SDMA_SDC_RFT (1<<0)
+#define SDMA_SDC_SFM (1<<1)
+#define SDMA_SDC_BLMR (1<<6)
+#define SDMA_SDC_BLMT (1<<7)
+#define SDMA_SDC_POVR (1<<8)
+#define SDMA_SDC_RIFB (1<<9)
+
+#define SDMA_SDCM_ERD (1<<7)
+#define SDMA_SDCM_AR (1<<15)
+#define SDMA_SDCM_STD (1<<16)
+#define SDMA_SDCM_TXD (1<<23)
+#define SDMA_SDCM_AT (1<<31)
+
+#define SDMA_0_CAUSE_RXBUF (1<<0)
+#define SDMA_0_CAUSE_RXERR (1<<1)
+#define SDMA_0_CAUSE_TXBUF (1<<2)
+#define SDMA_0_CAUSE_TXEND (1<<3)
+#define SDMA_1_CAUSE_RXBUF (1<<8)
+#define SDMA_1_CAUSE_RXERR (1<<9)
+#define SDMA_1_CAUSE_TXBUF (1<<10)
+#define SDMA_1_CAUSE_TXEND (1<<11)
+
+#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \
+ SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
+#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \
+ SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
+
+/* SDMA Interrupt registers */
+#define SDMA_INTR_CAUSE 0x0000
+#define SDMA_INTR_MASK 0x0080
+
+/* Baud Rate Generator Interface Registers */
+#define BRG_BCR 0x0000
+#define BRG_BTR 0x0004
/*
* Define how this driver is known to the outside (we've been assigned a
@@ -1165,7 +1417,7 @@ mpsc_startup(struct uart_port *port)
flag = SA_SHIRQ;
if (request_irq(pi->port.irq, mpsc_sdma_intr, flag,
- "mpsc/sdma", pi))
+ "mpsc-sdma", pi))
printk(KERN_ERR "MPSC: Can't get SDMA IRQ %d\n",
pi->port.irq);
diff --git a/drivers/serial/mpsc.h b/drivers/serial/mpsc.h
deleted file mode 100644
index 678dbcf06c8..00000000000
--- a/drivers/serial/mpsc.h
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * drivers/serial/mpsc.h
- *
- * Author: Mark A. Greer <mgreer@mvista.com>
- *
- * 2004 (c) MontaVista, Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __MPSC_H__
-#define __MPSC_H__
-
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/tty.h>
-#include <linux/tty_flip.h>
-#include <linux/ioport.h>
-#include <linux/init.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/serial.h>
-#include <linux/serial_core.h>
-#include <linux/delay.h>
-#include <linux/device.h>
-#include <linux/dma-mapping.h>
-#include <linux/mv643xx.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-
-#if defined(CONFIG_SERIAL_MPSC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
-#define SUPPORT_SYSRQ
-#endif
-
-#define MPSC_NUM_CTLRS 2
-
-/*
- * Descriptors and buffers must be cache line aligned.
- * Buffers lengths must be multiple of cache line size.
- * Number of Tx & Rx descriptors must be powers of 2.
- */
-#define MPSC_RXR_ENTRIES 32
-#define MPSC_RXRE_SIZE dma_get_cache_alignment()
-#define MPSC_RXR_SIZE (MPSC_RXR_ENTRIES * MPSC_RXRE_SIZE)
-#define MPSC_RXBE_SIZE dma_get_cache_alignment()
-#define MPSC_RXB_SIZE (MPSC_RXR_ENTRIES * MPSC_RXBE_SIZE)
-
-#define MPSC_TXR_ENTRIES 32
-#define MPSC_TXRE_SIZE dma_get_cache_alignment()
-#define MPSC_TXR_SIZE (MPSC_TXR_ENTRIES * MPSC_TXRE_SIZE)
-#define MPSC_TXBE_SIZE dma_get_cache_alignment()
-#define MPSC_TXB_SIZE (MPSC_TXR_ENTRIES * MPSC_TXBE_SIZE)
-
-#define MPSC_DMA_ALLOC_SIZE (MPSC_RXR_SIZE + MPSC_RXB_SIZE + \
- MPSC_TXR_SIZE + MPSC_TXB_SIZE + \
- dma_get_cache_alignment() /* for alignment */)
-
-/* Rx and Tx Ring entry descriptors -- assume entry size is <= cacheline size */
-struct mpsc_rx_desc {
- u16 bufsize;
- u16 bytecnt;
- u32 cmdstat;
- u32 link;
- u32 buf_ptr;
-} __attribute((packed));
-
-struct mpsc_tx_desc {
- u16 bytecnt;
- u16 shadow;
- u32 cmdstat;
- u32 link;
- u32 buf_ptr;
-} __attribute((packed));
-
-/*
- * Some regs that have the erratum that you can't read them are are shared
- * between the two MPSC controllers. This struct contains those shared regs.
- */
-struct mpsc_shared_regs {
- phys_addr_t mpsc_routing_base_p;
- phys_addr_t sdma_intr_base_p;
-
- void __iomem *mpsc_routing_base;
- void __iomem *sdma_intr_base;
-
- u32 MPSC_MRR_m;
- u32 MPSC_RCRR_m;
- u32 MPSC_TCRR_m;
- u32 SDMA_INTR_CAUSE_m;
- u32 SDMA_INTR_MASK_m;
-};
-
-/* The main driver data structure */
-struct mpsc_port_info {
- struct uart_port port; /* Overlay uart_port structure */
-
- /* Internal driver state for this ctlr */
- u8 ready;
- u8 rcv_data;
- tcflag_t c_iflag; /* save termios->c_iflag */
- tcflag_t c_cflag; /* save termios->c_cflag */
-
- /* Info passed in from platform */
- u8 mirror_regs; /* Need to mirror regs? */
- u8 cache_mgmt; /* Need manual cache mgmt? */
- u8 brg_can_tune; /* BRG has baud tuning? */
- u32 brg_clk_src;
- u16 mpsc_max_idle;
- int default_baud;
- int default_bits;
- int default_parity;
- int default_flow;
-
- /* Physical addresses of various blocks of registers (from platform) */
- phys_addr_t mpsc_base_p;
- phys_addr_t sdma_base_p;
- phys_addr_t brg_base_p;
-
- /* Virtual addresses of various blocks of registers (from platform) */
- void __iomem *mpsc_base;
- void __iomem *sdma_base;
- void __iomem *brg_base;
-
- /* Descriptor ring and buffer allocations */
- void *dma_region;
- dma_addr_t dma_region_p;
-
- dma_addr_t rxr; /* Rx descriptor ring */
- dma_addr_t rxr_p; /* Phys addr of rxr */
- u8 *rxb; /* Rx Ring I/O buf */
- u8 *rxb_p; /* Phys addr of rxb */
- u32 rxr_posn; /* First desc w/ Rx data */
-
- dma_addr_t txr; /* Tx descriptor ring */
- dma_addr_t txr_p; /* Phys addr of txr */
- u8 *txb; /* Tx Ring I/O buf */
- u8 *txb_p; /* Phys addr of txb */
- int txr_head; /* Where new data goes */
- int txr_tail; /* Where sent data comes off */
-
- /* Mirrored values of regs we can't read (if 'mirror_regs' set) */
- u32 MPSC_MPCR_m;
- u32 MPSC_CHR_1_m;
- u32 MPSC_CHR_2_m;
- u32 MPSC_CHR_10_m;
- u32 BRG_BCR_m;
- struct mpsc_shared_regs *shared_regs;
-};
-
-/* Hooks to platform-specific code */
-int mpsc_platform_register_driver(void);
-void mpsc_platform_unregister_driver(void);
-
-/* Hooks back in to mpsc common to be called by platform-specific code */
-struct mpsc_port_info *mpsc_device_probe(int index);
-struct mpsc_port_info *mpsc_device_remove(int index);
-
-/*
- *****************************************************************************
- *
- * Multi-Protocol Serial Controller Interface Registers
- *
- *****************************************************************************
- */
-
-/* Main Configuratino Register Offsets */
-#define MPSC_MMCRL 0x0000
-#define MPSC_MMCRH 0x0004
-#define MPSC_MPCR 0x0008
-#define MPSC_CHR_1 0x000c
-#define MPSC_CHR_2 0x0010
-#define MPSC_CHR_3 0x0014
-#define MPSC_CHR_4 0x0018
-#define MPSC_CHR_5 0x001c
-#define MPSC_CHR_6 0x0020
-#define MPSC_CHR_7 0x0024
-#define MPSC_CHR_8 0x0028
-#define MPSC_CHR_9 0x002c
-#define MPSC_CHR_10 0x0030
-#define MPSC_CHR_11 0x0034
-
-#define MPSC_MPCR_FRZ (1 << 9)
-#define MPSC_MPCR_CL_5 0
-#define MPSC_MPCR_CL_6 1
-#define MPSC_MPCR_CL_7 2
-#define MPSC_MPCR_CL_8 3
-#define MPSC_MPCR_SBL_1 0
-#define MPSC_MPCR_SBL_2 1
-
-#define MPSC_CHR_2_TEV (1<<1)
-#define MPSC_CHR_2_TA (1<<7)
-#define MPSC_CHR_2_TTCS (1<<9)
-#define MPSC_CHR_2_REV (1<<17)
-#define MPSC_CHR_2_RA (1<<23)
-#define MPSC_CHR_2_CRD (1<<25)
-#define MPSC_CHR_2_EH (1<<31)
-#define MPSC_CHR_2_PAR_ODD 0
-#define MPSC_CHR_2_PAR_SPACE 1
-#define MPSC_CHR_2_PAR_EVEN 2
-#define MPSC_CHR_2_PAR_MARK 3
-
-/* MPSC Signal Routing */
-#define MPSC_MRR 0x0000
-#define MPSC_RCRR 0x0004
-#define MPSC_TCRR 0x0008
-
-/*
- *****************************************************************************
- *
- * Serial DMA Controller Interface Registers
- *
- *****************************************************************************
- */
-
-#define SDMA_SDC 0x0000
-#define SDMA_SDCM 0x0008
-#define SDMA_RX_DESC 0x0800
-#define SDMA_RX_BUF_PTR 0x0808
-#define SDMA_SCRDP 0x0810
-#define SDMA_TX_DESC 0x0c00
-#define SDMA_SCTDP 0x0c10
-#define SDMA_SFTDP 0x0c14
-
-#define SDMA_DESC_CMDSTAT_PE (1<<0)
-#define SDMA_DESC_CMDSTAT_CDL (1<<1)
-#define SDMA_DESC_CMDSTAT_FR (1<<3)
-#define SDMA_DESC_CMDSTAT_OR (1<<6)
-#define SDMA_DESC_CMDSTAT_BR (1<<9)
-#define SDMA_DESC_CMDSTAT_MI (1<<10)
-#define SDMA_DESC_CMDSTAT_A (1<<11)
-#define SDMA_DESC_CMDSTAT_AM (1<<12)
-#define SDMA_DESC_CMDSTAT_CT (1<<13)
-#define SDMA_DESC_CMDSTAT_C (1<<14)
-#define SDMA_DESC_CMDSTAT_ES (1<<15)
-#define SDMA_DESC_CMDSTAT_L (1<<16)
-#define SDMA_DESC_CMDSTAT_F (1<<17)
-#define SDMA_DESC_CMDSTAT_P (1<<18)
-#define SDMA_DESC_CMDSTAT_EI (1<<23)
-#define SDMA_DESC_CMDSTAT_O (1<<31)
-
-#define SDMA_DESC_DFLT (SDMA_DESC_CMDSTAT_O | \
- SDMA_DESC_CMDSTAT_EI)
-
-#define SDMA_SDC_RFT (1<<0)
-#define SDMA_SDC_SFM (1<<1)
-#define SDMA_SDC_BLMR (1<<6)
-#define SDMA_SDC_BLMT (1<<7)
-#define SDMA_SDC_POVR (1<<8)
-#define SDMA_SDC_RIFB (1<<9)
-
-#define SDMA_SDCM_ERD (1<<7)
-#define SDMA_SDCM_AR (1<<15)
-#define SDMA_SDCM_STD (1<<16)
-#define SDMA_SDCM_TXD (1<<23)
-#define SDMA_SDCM_AT (1<<31)
-
-#define SDMA_0_CAUSE_RXBUF (1<<0)
-#define SDMA_0_CAUSE_RXERR (1<<1)
-#define SDMA_0_CAUSE_TXBUF (1<<2)
-#define SDMA_0_CAUSE_TXEND (1<<3)
-#define SDMA_1_CAUSE_RXBUF (1<<8)
-#define SDMA_1_CAUSE_RXERR (1<<9)
-#define SDMA_1_CAUSE_TXBUF (1<<10)
-#define SDMA_1_CAUSE_TXEND (1<<11)
-
-#define SDMA_CAUSE_RX_MASK (SDMA_0_CAUSE_RXBUF | SDMA_0_CAUSE_RXERR | \
- SDMA_1_CAUSE_RXBUF | SDMA_1_CAUSE_RXERR)
-#define SDMA_CAUSE_TX_MASK (SDMA_0_CAUSE_TXBUF | SDMA_0_CAUSE_TXEND | \
- SDMA_1_CAUSE_TXBUF | SDMA_1_CAUSE_TXEND)
-
-/* SDMA Interrupt registers */
-#define SDMA_INTR_CAUSE 0x0000
-#define SDMA_INTR_MASK 0x0080
-
-/*
- *****************************************************************************
- *
- * Baud Rate Generator Interface Registers
- *
- *****************************************************************************
- */
-
-#define BRG_BCR 0x0000
-#define BRG_BTR 0x0004
-
-#endif /* __MPSC_H__ */
diff --git a/drivers/serial/pmac_zilog.c b/drivers/serial/pmac_zilog.c
index 9b7ed58cb53..513ff859770 100644
--- a/drivers/serial/pmac_zilog.c
+++ b/drivers/serial/pmac_zilog.c
@@ -1916,6 +1916,16 @@ static void __exit exit_pmz(void)
#ifdef CONFIG_SERIAL_PMACZILOG_CONSOLE
+static void pmz_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_pmac_port *uap = (struct uart_pmac_port *)port;
+
+ /* Wait for the transmit buffer to empty. */
+ while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
+ udelay(5);
+ write_zsdata(uap, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -1924,7 +1934,6 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
{
struct uart_pmac_port *uap = &pmz_ports[con->index];
unsigned long flags;
- int i;
if (ZS_IS_ASLEEP(uap))
return;
@@ -1934,17 +1943,7 @@ static void pmz_console_write(struct console *con, const char *s, unsigned int c
write_zsreg(uap, R1, uap->curregs[1] & ~TxINT_ENAB);
write_zsreg(uap, R5, uap->curregs[5] | TxENABLE | RTS | DTR);
- for (i = 0; i < count; i++) {
- /* Wait for the transmit buffer to empty. */
- while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
- udelay(5);
- write_zsdata(uap, s[i]);
- if (s[i] == 10) {
- while ((read_zsreg(uap, R0) & Tx_BUF_EMP) == 0)
- udelay(5);
- write_zsdata(uap, R13);
- }
- }
+ uart_console_write(&uap->port, s, count, pmz_console_putchar);
/* Restore the values in the registers. */
write_zsreg(uap, R1, uap->curregs[1]);
diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c
index 10535f00301..77d4568ccc3 100644
--- a/drivers/serial/pxa.c
+++ b/drivers/serial/pxa.c
@@ -619,6 +619,14 @@ static inline void wait_for_xmitr(struct uart_pxa_port *up)
}
}
+static void serial_pxa_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_pxa_port *up = (struct uart_pxa_port *)port;
+
+ wait_for_xmitr(up);
+ serial_out(up, UART_TX, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -630,7 +638,6 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_pxa_port *up = &serial_pxa_ports[co->index];
unsigned int ier;
- int i;
/*
* First save the IER then disable the interrupts
@@ -638,22 +645,7 @@ serial_pxa_console_write(struct console *co, const char *s, unsigned int count)
ier = serial_in(up, UART_IER);
serial_out(up, UART_IER, UART_IER_UUE);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- serial_out(up, UART_TX, *s);
- if (*s == 10) {
- wait_for_xmitr(up);
- serial_out(up, UART_TX, 13);
- }
- }
+ uart_console_write(&up->port, s, count, serial_pxa_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 00d7c0ad8cb..f5aac92fb79 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -1586,25 +1586,19 @@ s3c24xx_serial_console_txrdy(struct uart_port *port, unsigned int ufcon)
}
static void
-s3c24xx_serial_console_write(struct console *co, const char *s,
- unsigned int count)
+s3c24xx_serial_console_putchar(struct uart_port *port, int ch)
{
- int i;
unsigned int ufcon = rd_regl(cons_uart, S3C2410_UFCON);
+ while (!s3c24xx_serial_console_txrdy(port, ufcon))
+ barrier();
+ wr_regb(cons_uart, S3C2410_UTXH, ch);
+}
- for (i = 0; i < count; i++) {
- while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
- barrier();
-
- wr_regb(cons_uart, S3C2410_UTXH, s[i]);
-
- if (s[i] == '\n') {
- while (!s3c24xx_serial_console_txrdy(cons_uart, ufcon))
- barrier();
-
- wr_regb(cons_uart, S3C2410_UTXH, '\r');
- }
- }
+static void
+s3c24xx_serial_console_write(struct console *co, const char *s,
+ unsigned int count)
+{
+ uart_console_write(cons_uart, s, count, s3c24xx_serial_console_putchar);
}
static void __init
diff --git a/drivers/serial/sa1100.c b/drivers/serial/sa1100.c
index 2c00b862585..c2d9068b491 100644
--- a/drivers/serial/sa1100.c
+++ b/drivers/serial/sa1100.c
@@ -689,6 +689,14 @@ void __init sa1100_register_uart(int idx, int port)
#ifdef CONFIG_SERIAL_SA1100_CONSOLE
+static void sa1100_console_putchar(struct uart_port *port, int ch)
+{
+ struct sa1100_port *sport = (struct sa1100_port *)port;
+
+ while (!(UART_GET_UTSR1(sport) & UTSR1_TNF))
+ barrier();
+ UART_PUT_CHAR(sport, ch);
+}
/*
* Interrupts are disabled on entering
@@ -697,7 +705,7 @@ static void
sa1100_console_write(struct console *co, const char *s, unsigned int count)
{
struct sa1100_port *sport = &sa1100_ports[co->index];
- unsigned int old_utcr3, status, i;
+ unsigned int old_utcr3, status;
/*
* First, save UTCR3 and then disable interrupts
@@ -706,21 +714,7 @@ sa1100_console_write(struct console *co, const char *s, unsigned int count)
UART_PUT_UTCR3(sport, (old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE)) |
UTCR3_TXE);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++) {
- do {
- status = UART_GET_UTSR1(sport);
- } while (!(status & UTSR1_TNF));
- UART_PUT_CHAR(sport, s[i]);
- if (s[i] == '\n') {
- do {
- status = UART_GET_UTSR1(sport);
- } while (!(status & UTSR1_TNF));
- UART_PUT_CHAR(sport, '\r');
- }
- }
+ uart_console_write(&sport->port, s, count, sa1100_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index cc1faa31d12..fcd7744c425 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1755,6 +1755,27 @@ static int uart_read_proc(char *page, char **start, off_t off,
#ifdef CONFIG_SERIAL_CORE_CONSOLE
/*
+ * uart_console_write - write a console message to a serial port
+ * @port: the port to write the message
+ * @s: array of characters
+ * @count: number of characters in string to write
+ * @write: function to write character to port
+ */
+void uart_console_write(struct uart_port *port, const char *s,
+ unsigned int count,
+ void (*putchar)(struct uart_port *, int))
+{
+ unsigned int i;
+
+ for (i = 0; i < count; i++, s++) {
+ if (*s == '\n')
+ putchar(port, '\r');
+ putchar(port, *s);
+ }
+}
+EXPORT_SYMBOL_GPL(uart_console_write);
+
+/*
* Check whether an invalid uart number has been specified, and
* if so, search for the first available port that does have
* console support.
diff --git a/drivers/serial/serial_lh7a40x.c b/drivers/serial/serial_lh7a40x.c
index 04186eaae22..aa521b8e0d4 100644
--- a/drivers/serial/serial_lh7a40x.c
+++ b/drivers/serial/serial_lh7a40x.c
@@ -543,6 +543,12 @@ static struct uart_port_lh7a40x lh7a40x_ports[DEV_NR] = {
#else
# define LH7A40X_CONSOLE &lh7a40x_console
+static void lh7a40xuart_console_putchar(struct uart_port *port, int ch)
+{
+ while (UR(port, UART_R_STATUS) & nTxRdy)
+ ;
+ UR(port, UART_R_DATA) = ch;
+}
static void lh7a40xuart_console_write (struct console* co,
const char* s,
@@ -556,16 +562,7 @@ static void lh7a40xuart_console_write (struct console* co,
UR (port, UART_R_INTEN) = 0; /* Disable all interrupts */
BIT_SET (port, UART_R_CON, UARTEN | SIRDIS); /* Enable UART */
- for (; count-- > 0; ++s) {
- while (UR (port, UART_R_STATUS) & nTxRdy)
- ;
- UR (port, UART_R_DATA) = *s;
- if (*s == '\n') {
- while ((UR (port, UART_R_STATUS) & TxBusy))
- ;
- UR (port, UART_R_DATA) = '\r';
- }
- }
+ uart_console_write(port, s, count, lh7a40xuart_console_putchar);
/* Wait until all characters are sent */
while (UR (port, UART_R_STATUS) & TxBusy)
diff --git a/drivers/serial/serial_txx9.c b/drivers/serial/serial_txx9.c
index 141173efd46..b848b7d9441 100644
--- a/drivers/serial/serial_txx9.c
+++ b/drivers/serial/serial_txx9.c
@@ -863,6 +863,14 @@ static inline void wait_for_xmitr(struct uart_txx9_port *up)
}
}
+static void serial_txx9_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_txx9_port *up = (struct uart_txx9_port *)port;
+
+ wait_for_xmitr(up);
+ sio_out(up, TXX9_SITFIFO, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -874,7 +882,6 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_txx9_port *up = &serial_txx9_ports[co->index];
unsigned int ier, flcr;
- int i;
/*
* First save the UER then disable the interrupts
@@ -888,22 +895,7 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)
if (!(up->port.flags & UPF_CONS_FLOW) && (flcr & TXX9_SIFLCR_TES))
sio_out(up, TXX9_SIFLCR, flcr & ~TXX9_SIFLCR_TES);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- sio_out(up, TXX9_SITFIFO, *s);
- if (*s == 10) {
- wait_for_xmitr(up);
- sio_out(up, TXX9_SITFIFO, 13);
- }
- }
+ uart_console_write(&up->port, s, count, serial_txx9_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunsab.c b/drivers/serial/sunsab.c
index a2fb0c2fb12..bfbe9dc90cc 100644
--- a/drivers/serial/sunsab.c
+++ b/drivers/serial/sunsab.c
@@ -861,8 +861,9 @@ static int num_channels;
#ifdef CONFIG_SERIAL_SUNSAB_CONSOLE
-static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char c)
+static void sunsab_console_putchar(struct uart_port *port, int c)
{
+ struct uart_sunsab_port *up = (struct uart_sunsab_port *)port;
unsigned long flags;
spin_lock_irqsave(&up->port.lock, flags);
@@ -876,13 +877,8 @@ static __inline__ void sunsab_console_putchar(struct uart_sunsab_port *up, char
static void sunsab_console_write(struct console *con, const char *s, unsigned n)
{
struct uart_sunsab_port *up = &sunsab_ports[con->index];
- int i;
- for (i = 0; i < n; i++) {
- if (*s == '\n')
- sunsab_console_putchar(up, '\r');
- sunsab_console_putchar(up, *s++);
- }
+ uart_console_write(&up->port, s, n, sunsab_console_putchar);
sunsab_tec_wait(up);
}
diff --git a/drivers/serial/sunsu.c b/drivers/serial/sunsu.c
index 46c44b83f57..9fe2283d91e 100644
--- a/drivers/serial/sunsu.c
+++ b/drivers/serial/sunsu.c
@@ -102,9 +102,7 @@ struct uart_sunsu_port {
#endif
};
-#define _INLINE_
-
-static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset)
+static unsigned int serial_in(struct uart_sunsu_port *up, int offset)
{
offset <<= up->port.regshift;
@@ -121,8 +119,7 @@ static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset)
}
}
-static _INLINE_ void
-serial_out(struct uart_sunsu_port *up, int offset, int value)
+static void serial_out(struct uart_sunsu_port *up, int offset, int value)
{
#ifndef CONFIG_SPARC64
/*
@@ -316,7 +313,7 @@ static void sunsu_enable_ms(struct uart_port *port)
spin_unlock_irqrestore(&up->port.lock, flags);
}
-static _INLINE_ struct tty_struct *
+static struct tty_struct *
receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs)
{
struct tty_struct *tty = up->port.info->tty;
@@ -395,7 +392,7 @@ receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs
return tty;
}
-static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
+static void transmit_chars(struct uart_sunsu_port *up)
{
struct circ_buf *xmit = &up->port.info->xmit;
int count;
@@ -431,7 +428,7 @@ static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
__stop_tx(up);
}
-static _INLINE_ void check_modem_status(struct uart_sunsu_port *up)
+static void check_modem_status(struct uart_sunsu_port *up)
{
int status;
@@ -1377,6 +1374,14 @@ static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)
}
}
+static void sunsu_console_putchar(struct uart_port *port, int ch)
+{
+ struct uart_sunsu_port *up = (struct uart_sunsu_port *)port;
+
+ wait_for_xmitr(up);
+ serial_out(up, UART_TX, ch);
+}
+
/*
* Print a string to the serial port trying not to disturb
* any possible real use of the port...
@@ -1386,7 +1391,6 @@ static void sunsu_console_write(struct console *co, const char *s,
{
struct uart_sunsu_port *up = &sunsu_ports[co->index];
unsigned int ier;
- int i;
/*
* First save the UER then disable the interrupts
@@ -1394,22 +1398,7 @@ static void sunsu_console_write(struct console *co, const char *s,
ier = serial_in(up, UART_IER);
serial_out(up, UART_IER, 0);
- /*
- * Now, do each character
- */
- for (i = 0; i < count; i++, s++) {
- wait_for_xmitr(up);
-
- /*
- * Send the character out.
- * If a LF, also do CR...
- */
- serial_out(up, UART_TX, *s);
- if (*s == 10) {
- wait_for_xmitr(up);
- serial_out(up, UART_TX, 13);
- }
- }
+ uart_console_write(&up->port, s, count, sunsu_console_putchar);
/*
* Finally, wait for transmitter to become empty
diff --git a/drivers/serial/sunzilog.c b/drivers/serial/sunzilog.c
index 10b35c6f287..cd49ebbf4a4 100644
--- a/drivers/serial/sunzilog.c
+++ b/drivers/serial/sunzilog.c
@@ -1252,8 +1252,9 @@ static struct zilog_layout __iomem * __init get_zs(int chip, int node)
#define ZS_PUT_CHAR_MAX_DELAY 2000 /* 10 ms */
-static void sunzilog_put_char(struct zilog_channel __iomem *channel, unsigned char ch)
+static void sunzilog_putchar(struct uart_port *port, int ch)
{
+ struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(port);
int loops = ZS_PUT_CHAR_MAX_DELAY;
/* This is a timed polling loop so do not switch the explicit
@@ -1284,7 +1285,7 @@ static int sunzilog_serio_write(struct serio *serio, unsigned char ch)
spin_lock_irqsave(&sunzilog_serio_lock, flags);
- sunzilog_put_char(ZILOG_CHANNEL_FROM_PORT(&up->port), ch);
+ sunzilog_putchar(&up->port, ch);
spin_unlock_irqrestore(&sunzilog_serio_lock, flags);
@@ -1325,16 +1326,10 @@ static void
sunzilog_console_write(struct console *con, const char *s, unsigned int count)
{
struct uart_sunzilog_port *up = &sunzilog_port_table[con->index];
- struct zilog_channel *channel = ZILOG_CHANNEL_FROM_PORT(&up->port);
unsigned long flags;
- int i;
spin_lock_irqsave(&up->port.lock, flags);
- for (i = 0; i < count; i++, s++) {
- sunzilog_put_char(channel, *s);
- if (*s == 10)
- sunzilog_put_char(channel, 13);
- }
+ uart_console_write(&up->port, s, count, sunzilog_putchar);
udelay(2);
spin_unlock_irqrestore(&up->port.lock, flags);
}
diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c
index bd6294132c1..df5e8713fa3 100644
--- a/drivers/serial/vr41xx_siu.c
+++ b/drivers/serial/vr41xx_siu.c
@@ -821,25 +821,23 @@ static void wait_for_xmitr(struct uart_port *port)
}
}
+static void siu_console_putchar(struct uart_port *port, int ch)
+{
+ wait_for_xmitr(port);
+ siu_write(port, UART_TX, ch);
+}
+
static void siu_console_write(struct console *con, const char *s, unsigned count)
{
struct uart_port *port;
uint8_t ier;
- unsigned i;
port = &siu_uart_ports[con->index];
ier = siu_read(port, UART_IER);
siu_write(port, UART_IER, 0);
- for (i = 0; i < count && *s != '\0'; i++, s++) {
- wait_for_xmitr(port);
- siu_write(port, UART_TX, *s);
- if (*s == '\n') {
- wait_for_xmitr(port);
- siu_write(port, UART_TX, '\r');
- }
- }
+ uart_console_write(port, s, count, siu_console_putchar);
wait_for_xmitr(port);
siu_write(port, UART_IER, ier);
diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c
index 6756d0fab6f..2dffa8e303b 100644
--- a/drivers/tc/zs.c
+++ b/drivers/tc/zs.c
@@ -186,8 +186,6 @@ static struct tty_driver *serial_driver;
#define RS_STROBE_TIME 10
#define RS_ISR_PASS_LIMIT 256
-#define _INLINE_ inline
-
static void probe_sccs(void);
static void change_speed(struct dec_serial *info);
static void rs_wait_until_sent(struct tty_struct *tty, int timeout);
@@ -344,14 +342,13 @@ static inline void rs_recv_clear(struct dec_zschannel *zsc)
* This routine is used by the interrupt handler to schedule
* processing in the software interrupt portion of the driver.
*/
-static _INLINE_ void rs_sched_event(struct dec_serial *info, int event)
+static void rs_sched_event(struct dec_serial *info, int event)
{
info->event |= 1 << event;
tasklet_schedule(&info->tlet);
}
-static _INLINE_ void receive_chars(struct dec_serial *info,
- struct pt_regs *regs)
+static void receive_chars(struct dec_serial *info, struct pt_regs *regs)
{
struct tty_struct *tty = info->tty;
unsigned char ch, stat, flag;
@@ -441,7 +438,7 @@ static void transmit_chars(struct dec_serial *info)
rs_sched_event(info, RS_EVENT_WRITE_WAKEUP);
}
-static _INLINE_ void status_handle(struct dec_serial *info)
+static void status_handle(struct dec_serial *info)
{
unsigned char stat;
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index b1222cd4aa4..7fdbc5dad5f 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -87,8 +87,6 @@ source "drivers/usb/input/Kconfig"
source "drivers/usb/image/Kconfig"
-source "drivers/usb/media/Kconfig"
-
source "drivers/usb/net/Kconfig"
source "drivers/usb/mon/Kconfig"
diff --git a/drivers/usb/Makefile b/drivers/usb/Makefile
index bb36a1c1dbb..9b7d9769fdc 100644
--- a/drivers/usb/Makefile
+++ b/drivers/usb/Makefile
@@ -35,20 +35,6 @@ obj-$(CONFIG_USB_WACOM) += input/
obj-$(CONFIG_USB_ACECAD) += input/
obj-$(CONFIG_USB_XPAD) += input/
-obj-$(CONFIG_USB_DABUSB) += media/
-obj-$(CONFIG_USB_DSBR) += media/
-obj-$(CONFIG_USB_ET61X251) += media/
-obj-$(CONFIG_USB_IBMCAM) += media/
-obj-$(CONFIG_USB_KONICAWC) += media/
-obj-$(CONFIG_USB_OV511) += media/
-obj-$(CONFIG_USB_PWC) += media/
-obj-$(CONFIG_USB_SE401) += media/
-obj-$(CONFIG_USB_SN9C102) += media/
-obj-$(CONFIG_USB_STV680) += media/
-obj-$(CONFIG_USB_VICAM) += media/
-obj-$(CONFIG_USB_W9968CF) += media/
-obj-$(CONFIG_USB_ZC0301) += media/
-
obj-$(CONFIG_USB_CATC) += net/
obj-$(CONFIG_USB_KAWETH) += net/
obj-$(CONFIG_USB_PEGASUS) += net/
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 28538db9eaf..2a0e18a4874 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -360,7 +360,7 @@ static int mts_scsi_host_reset (Scsi_Cmnd *srb)
rc = usb_lock_device_for_reset(desc->usb_dev, desc->usb_intf);
if (rc < 0)
return FAILED;
- result = usb_reset_device(desc->usb_dev);;
+ result = usb_reset_device(desc->usb_dev);
if (rc)
usb_unlock_device(desc->usb_dev);
return result ? FAILED : SUCCESS;
diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 58b59f6e988..d4bf1701046 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1215,7 +1215,7 @@ static void hid_irq_out(struct urb *urb, struct pt_regs *regs)
if (hid->outhead != hid->outtail) {
if (hid_submit_out(hid)) {
- clear_bit(HID_OUT_RUNNING, &hid->iofl);;
+ clear_bit(HID_OUT_RUNNING, &hid->iofl);
wake_up(&hid->wait);
}
spin_unlock_irqrestore(&hid->outlock, flags);
diff --git a/drivers/usb/media/Kconfig b/drivers/usb/media/Kconfig
deleted file mode 100644
index 189d40f96be..00000000000
--- a/drivers/usb/media/Kconfig
+++ /dev/null
@@ -1,241 +0,0 @@
-#
-# USB Multimedia device configuration
-#
-comment "USB Multimedia devices"
- depends on USB
-
-config USB_DABUSB
- tristate "DABUSB driver"
- depends on USB
- ---help---
- A Digital Audio Broadcasting (DAB) Receiver for USB and Linux
- brought to you by the DAB-Team
- <http://wwwbode.cs.tum.edu/Par/arch/dab/>. This driver can be taken
- as an example for URB-based bulk, control, and isochronous
- transactions. URB's are explained in
- <file:Documentation/usb/URB.txt>.
-
- To compile this driver as a module, choose M here: the
- module will be called dabusb.
-
-comment "Video4Linux support is needed for USB Multimedia device support"
- depends on USB && VIDEO_DEV=n
-
-config USB_VICAM
- tristate "USB 3com HomeConnect (aka vicam) support (EXPERIMENTAL)"
- depends on USB && VIDEO_DEV && EXPERIMENTAL
- ---help---
- Say Y here if you have 3com homeconnect camera (vicam).
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" (under Multimedia Devices) to use this driver.
- Information on this API and pointers to "v4l" programs may be found
- at <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called vicam.
-
-config USB_DSBR
- tristate "D-Link USB FM radio support (EXPERIMENTAL)"
- depends on USB && VIDEO_DEV && EXPERIMENTAL
- ---help---
- Say Y here if you want to connect this type of radio to your
- computer's USB port. Note that the audio is not digital, and
- you must connect the line out connector to a sound card or a
- set of speakers.
-
- This driver uses the Video For Linux API. You must enable
- (Y or M in config) Video For Linux (under Character Devices)
- to use this driver. Information on this API and pointers to
- "v4l" programs may be found at
- <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called dsbr100.
-
-config USB_ET61X251
- tristate "USB ET61X[12]51 PC Camera Controller support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want support for cameras based on Etoms ET61X151
- or ET61X251 PC Camera Controllers.
-
- See <file:Documentation/usb/et61x251.txt> for more informations.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" to use this driver.
-
- To compile this driver as a module, choose M here: the
- module will be called et61x251.
-
-config USB_IBMCAM
- tristate "USB IBM (Xirlink) C-it Camera support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want to connect a IBM "C-It" camera, also known as
- "Xirlink PC Camera" to your computer's USB port. For more
- information, read <file:Documentation/usb/ibmcam.txt>.
-
- This driver uses the Video For Linux API. You must enable
- (Y or M in config) Video For Linux (under Character Devices)
- to use this driver. Information on this API and pointers to
- "v4l" programs may be found at
- <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called ibmcam.
-
- This camera has several configuration options which
- can be specified when you load the module. Read
- <file:Documentation/usb/ibmcam.txt> to learn more.
-
-config USB_KONICAWC
- tristate "USB Konica Webcam support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want support for webcams based on a Konica
- chipset. This is known to work with the Intel YC76 webcam.
-
- This driver uses the Video For Linux API. You must enable
- (Y or M in config) Video For Linux (under Character Devices)
- to use this driver. Information on this API and pointers to
- "v4l" programs may be found at
- <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called konicawc.
-
-config USB_OV511
- tristate "USB OV511 Camera support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want to connect this type of camera to your
- computer's USB port. See <file:Documentation/usb/ov511.txt> for more
- information and for a list of supported cameras.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" (under Character Devices) to use this driver.
- Information on this API and pointers to "v4l" programs may be found
- at <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called ov511.
-
-config USB_SE401
- tristate "USB SE401 Camera support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want to connect this type of camera to your
- computer's USB port. See <file:Documentation/usb/se401.txt> for more
- information and for a list of supported cameras.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" (under Multimedia Devices) to use this driver.
- Information on this API and pointers to "v4l" programs may be found
- at <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called se401.
-
-config USB_SN9C102
- tristate "USB SN9C10x PC Camera Controller support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want support for cameras based on SONiX SN9C101,
- SN9C102 or SN9C103 PC Camera Controllers.
-
- See <file:Documentation/usb/sn9c102.txt> for more informations.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" to use this driver.
-
- To compile this driver as a module, choose M here: the
- module will be called sn9c102.
-
-config USB_STV680
- tristate "USB STV680 (Pencam) Camera support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want to connect this type of camera to your
- computer's USB port. This includes the Pencam line of cameras.
- See <file:Documentation/usb/stv680.txt> for more information and for
- a list of supported cameras.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" (under Multimedia Devices) to use this driver.
- Information on this API and pointers to "v4l" programs may be found
- at <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called stv680.
-
-config USB_W9968CF
- tristate "USB W996[87]CF JPEG Dual Mode Camera support"
- depends on USB && VIDEO_DEV && I2C && VIDEO_OVCAMCHIP
- ---help---
- Say Y here if you want support for cameras based on OV681 or
- Winbond W9967CF/W9968CF JPEG USB Dual Mode Camera Chips.
-
- This driver has an optional plugin, which is distributed as a
- separate module only (released under GPL). It allows to use higher
- resolutions and framerates, but cannot be included in the official
- Linux kernel for performance purposes.
-
- See <file:Documentation/usb/w9968cf.txt> for more informations.
-
- This driver uses the Video For Linux and the I2C APIs. It needs the
- OmniVision Camera Chip support as well. You must say Y or M to
- "Video For Linux", "I2C Support" and "OmniVision Camera Chip
- support" to use this driver.
-
- To compile this driver as a module, choose M here: the
- module will be called w9968cf.
-
-config USB_ZC0301
- tristate "USB ZC0301 Image Processor and Control Chip support"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y here if you want support for cameras based on the ZC0301
- Image Processor and Control Chip.
-
- See <file:Documentation/usb/zc0301.txt> for more informations.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" to use this driver.
-
- To compile this driver as a module, choose M here: the
- module will be called zc0301.
-
-config USB_PWC
- tristate "USB Philips Cameras"
- depends on USB && VIDEO_DEV
- ---help---
- Say Y or M here if you want to use one of these Philips & OEM
- webcams:
- * Philips PCA645, PCA646
- * Philips PCVC675, PCVC680, PCVC690
- * Philips PCVC720/40, PCVC730, PCVC740, PCVC750
- * Askey VC010
- * Logitech QuickCam Pro 3000, 4000, 'Zoom', 'Notebook Pro'
- and 'Orbit'/'Sphere'
- * Samsung MPC-C10, MPC-C30
- * Creative Webcam 5, Pro Ex
- * SOTEC Afina Eye
- * Visionite VCS-UC300, VCS-UM100
-
- The PCA635, PCVC665 and PCVC720/20 are not supported by this driver
- and never will be, but the 665 and 720/20 are supported by other
- drivers.
-
- See <file:Documentation/usb/philips.txt> for more information and
- installation instructions.
-
- The built-in microphone is enabled by selecting USB Audio support.
-
- This driver uses the Video For Linux API. You must say Y or M to
- "Video For Linux" (under Character Devices) to use this driver.
- Information on this API and pointers to "v4l" programs may be found
- at <file:Documentation/video4linux/API.html>.
-
- To compile this driver as a module, choose M here: the
- module will be called pwc.
diff --git a/drivers/usb/media/Makefile b/drivers/usb/media/Makefile
deleted file mode 100644
index 50e89a33b85..00000000000
--- a/drivers/usb/media/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Makefile for USB Media drivers
-#
-
-sn9c102-objs := sn9c102_core.o sn9c102_hv7131d.o sn9c102_mi0343.o \
- sn9c102_ov7630.o sn9c102_pas106b.o sn9c102_pas202bca.o \
- sn9c102_pas202bcb.o sn9c102_tas5110c1b.o \
- sn9c102_tas5130d1b.o
-et61x251-objs := et61x251_core.o et61x251_tas5130d1b.o
-zc0301-objs := zc0301_core.o zc0301_pas202bcb.o
-
-obj-$(CONFIG_USB_DABUSB) += dabusb.o
-obj-$(CONFIG_USB_DSBR) += dsbr100.o
-obj-$(CONFIG_USB_ET61X251) += et61x251.o
-obj-$(CONFIG_USB_IBMCAM) += ibmcam.o usbvideo.o ultracam.o
-obj-$(CONFIG_USB_KONICAWC) += konicawc.o usbvideo.o
-obj-$(CONFIG_USB_OV511) += ov511.o
-obj-$(CONFIG_USB_SE401) += se401.o
-obj-$(CONFIG_USB_SN9C102) += sn9c102.o
-obj-$(CONFIG_USB_STV680) += stv680.o
-obj-$(CONFIG_USB_VICAM) += vicam.o usbvideo.o
-obj-$(CONFIG_USB_W9968CF) += w9968cf.o
-obj-$(CONFIG_USB_ZC0301) += zc0301.o
-obj-$(CONFIG_USB_PWC) += pwc/
diff --git a/drivers/usb/media/pwc/pwc-kiara.c b/drivers/usb/media/pwc/pwc-kiara.c
deleted file mode 100644
index c498c68bace..00000000000
--- a/drivers/usb/media/pwc/pwc-kiara.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* Linux driver for Philips webcam
- (C) 2004 Luc Saillard (luc@saillard.org)
-
- NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
- driver and thus may have bugs that are not present in the original version.
- Please send bug reports and support requests to <luc@saillard.org>.
- The decompression routines have been implemented by reverse-engineering the
- Nemosoft binary pwcx module. Caveat emptor.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-
-/* This tables contains entries for the 730/740/750 (Kiara) camera, with
- 4 different qualities (no compression, low, medium, high).
- It lists the bandwidth requirements for said mode by its alternate interface
- number. An alternate of 0 means that the mode is unavailable.
-
- There are 6 * 4 * 4 entries:
- 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
- 6 framerates: 5, 10, 15, 20, 25, 30
- 4 compression modi: none, low, medium, high
-
- When an uncompressed mode is not available, the next available compressed mode
- will be chosen (unless the decompressor is absent). Sometimes there are only
- 1 or 2 compressed modes available; in that case entries are duplicated.
-*/
-
-
-#include "pwc-kiara.h"
-#include "pwc-uncompress.h"
-
-const struct Kiara_table_entry Kiara_table[PSZ_MAX][6][4] =
-{
- /* SQCIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* QSIF */
- {
- /* 5 fps */
- {
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- {1, 146, 0, {0x1D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0x00, 0x80}},
- },
- /* 10 fps */
- {
- {2, 291, 0, {0x1C, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0x01, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- {1, 192, 630, {0x14, 0xF4, 0x30, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xC0, 0x00, 0x80}},
- },
- /* 15 fps */
- {
- {3, 437, 0, {0x1B, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x01, 0x80}},
- {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
- {2, 292, 640, {0x13, 0xF4, 0x30, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x20, 0x24, 0x01, 0x80}},
- {1, 192, 420, {0x13, 0xF4, 0x30, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
- },
- /* 20 fps */
- {
- {4, 589, 0, {0x1A, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4D, 0x02, 0x80}},
- {3, 448, 730, {0x12, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xC0, 0x01, 0x80}},
- {2, 292, 476, {0x12, 0xF4, 0x30, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0x01, 0x80}},
- {1, 192, 312, {0x12, 0xF4, 0x50, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0x00, 0x80}},
- },
- /* 25 fps */
- {
- {5, 703, 0, {0x19, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x02, 0x80}},
- {3, 447, 610, {0x11, 0xF4, 0x30, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x28, 0xBF, 0x01, 0x80}},
- {2, 292, 398, {0x11, 0xF4, 0x50, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x28, 0x24, 0x01, 0x80}},
- {1, 193, 262, {0x11, 0xF4, 0x50, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x28, 0xC1, 0x00, 0x80}},
- },
- /* 30 fps */
- {
- {8, 874, 0, {0x18, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x6A, 0x03, 0x80}},
- {5, 704, 730, {0x10, 0xF4, 0x30, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x28, 0xC0, 0x02, 0x80}},
- {3, 448, 492, {0x10, 0xF4, 0x30, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x28, 0xC0, 0x01, 0x80}},
- {2, 292, 320, {0x10, 0xF4, 0x50, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x28, 0x24, 0x01, 0x80}},
- },
- },
- /* QCIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* SIF */
- {
- /* 5 fps */
- {
- {4, 582, 0, {0x0D, 0xF4, 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x02, 0x80}},
- {3, 387, 1276, {0x05, 0xF4, 0x30, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x01, 0x80}},
- {2, 291, 960, {0x05, 0xF4, 0x30, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0x01, 0x80}},
- {1, 191, 630, {0x05, 0xF4, 0x50, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x18, 0xBF, 0x00, 0x80}},
- },
- /* 10 fps */
- {
- {0, },
- {6, 775, 1278, {0x04, 0xF4, 0x30, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x03, 0x80}},
- {3, 447, 736, {0x04, 0xF4, 0x30, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x28, 0xBF, 0x01, 0x80}},
- {2, 292, 480, {0x04, 0xF4, 0x70, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x28, 0x24, 0x01, 0x80}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 955, 1050, {0x03, 0xF4, 0x30, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x03, 0x80}},
- {4, 592, 650, {0x03, 0xF4, 0x30, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x50, 0x02, 0x80}},
- {3, 448, 492, {0x03, 0xF4, 0x50, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x38, 0xC0, 0x01, 0x80}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 958, 782, {0x02, 0xF4, 0x30, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x03, 0x80}},
- {5, 703, 574, {0x02, 0xF4, 0x50, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x02, 0x80}},
- {3, 446, 364, {0x02, 0xF4, 0x90, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x38, 0xBE, 0x01, 0x80}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 958, 654, {0x01, 0xF4, 0x30, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x03, 0x80}},
- {6, 776, 530, {0x01, 0xF4, 0x50, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x03, 0x80}},
- {4, 592, 404, {0x01, 0xF4, 0x70, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x48, 0x50, 0x02, 0x80}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 957, 526, {0x00, 0xF4, 0x50, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x03, 0x80}},
- {6, 775, 426, {0x00, 0xF4, 0x70, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x03, 0x80}},
- {4, 590, 324, {0x00, 0x7A, 0x88, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x50, 0x4E, 0x02, 0x80}},
- },
- },
- /* CIF */
- {
- /* 5 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 10 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 15 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
- /* VGA */
- {
- /* 5 fps */
- {
- {0, },
- {6, 773, 1272, {0x25, 0xF4, 0x30, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x03, 0x80}},
- {4, 592, 976, {0x25, 0xF4, 0x50, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x02, 0x80}},
- {3, 448, 738, {0x25, 0xF4, 0x90, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x01, 0x80}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 956, 788, {0x24, 0xF4, 0x70, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x03, 0x80}},
- {6, 776, 640, {0x24, 0xF4, 0xB0, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x03, 0x80}},
- {4, 592, 488, {0x24, 0x7A, 0xE8, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x02, 0x80}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
- {9, 957, 526, {0x23, 0x7A, 0xE8, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x03, 0x80}},
- {8, 895, 492, {0x23, 0x7A, 0xE8, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x03, 0x80}},
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
-};
-
diff --git a/drivers/usb/media/pwc/pwc-timon.c b/drivers/usb/media/pwc/pwc-timon.c
deleted file mode 100644
index dee967173d6..00000000000
--- a/drivers/usb/media/pwc/pwc-timon.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/* Linux driver for Philips webcam
- (C) 2004 Luc Saillard (luc@saillard.org)
-
- NOTE: this version of pwc is an unofficial (modified) release of pwc & pcwx
- driver and thus may have bugs that are not present in the original version.
- Please send bug reports and support requests to <luc@saillard.org>.
- The decompression routines have been implemented by reverse-engineering the
- Nemosoft binary pwcx module. Caveat emptor.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-
-/* This tables contains entries for the 675/680/690 (Timon) camera, with
- 4 different qualities (no compression, low, medium, high).
- It lists the bandwidth requirements for said mode by its alternate interface
- number. An alternate of 0 means that the mode is unavailable.
-
- There are 6 * 4 * 4 entries:
- 6 different resolutions subqcif, qsif, qcif, sif, cif, vga
- 6 framerates: 5, 10, 15, 20, 25, 30
- 4 compression modi: none, low, medium, high
-
- When an uncompressed mode is not available, the next available compressed mode
- will be chosen (unless the decompressor is absent). Sometimes there are only
- 1 or 2 compressed modes available; in that case entries are duplicated.
-*/
-
-#include "pwc-timon.h"
-
-const struct Timon_table_entry Timon_table[PSZ_MAX][6][4] =
-{
- /* SQCIF */
- {
- /* 5 fps */
- {
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- {1, 140, 0, {0x05, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x8C, 0xFC, 0x80, 0x02}},
- },
- /* 10 fps */
- {
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- {2, 280, 0, {0x04, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x18, 0xA9, 0x80, 0x02}},
- },
- /* 15 fps */
- {
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- {3, 410, 0, {0x03, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x9A, 0x71, 0x80, 0x02}},
- },
- /* 20 fps */
- {
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- {4, 559, 0, {0x02, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x2F, 0x56, 0x80, 0x02}},
- },
- /* 25 fps */
- {
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- {5, 659, 0, {0x01, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x93, 0x46, 0x80, 0x02}},
- },
- /* 30 fps */
- {
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- {7, 838, 0, {0x00, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x46, 0x3B, 0x80, 0x02}},
- },
- },
- /* QSIF */
- {
- /* 5 fps */
- {
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- {1, 146, 0, {0x2D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x92, 0xFC, 0xC0, 0x02}},
- },
- /* 10 fps */
- {
- {2, 291, 0, {0x2C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- {1, 191, 630, {0x2C, 0xF4, 0x05, 0x13, 0xA9, 0x12, 0xE1, 0x17, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- },
- /* 15 fps */
- {
- {3, 437, 0, {0x2B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xB5, 0x6D, 0xC0, 0x02}},
- {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {2, 291, 640, {0x2B, 0xF4, 0x05, 0x13, 0xF7, 0x13, 0x2F, 0x13, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 191, 420, {0x2B, 0xF4, 0x0D, 0x0D, 0x1B, 0x0C, 0x53, 0x1E, 0x08, 0xBF, 0xF4, 0xC0, 0x02}},
- },
- /* 20 fps */
- {
- {4, 588, 0, {0x2A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x4C, 0x52, 0xC0, 0x02}},
- {3, 447, 730, {0x2A, 0xF4, 0x05, 0x16, 0xC9, 0x16, 0x01, 0x0E, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 476, {0x2A, 0xF4, 0x0D, 0x0E, 0xD8, 0x0E, 0x10, 0x19, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 192, 312, {0x2A, 0xF4, 0x1D, 0x09, 0xB3, 0x08, 0xEB, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
- },
- /* 25 fps */
- {
- {5, 703, 0, {0x29, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0xBF, 0x42, 0xC0, 0x02}},
- {3, 447, 610, {0x29, 0xF4, 0x05, 0x13, 0x0B, 0x12, 0x43, 0x14, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 398, {0x29, 0xF4, 0x0D, 0x0C, 0x6C, 0x0B, 0xA4, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 192, 262, {0x29, 0xF4, 0x25, 0x08, 0x23, 0x07, 0x5B, 0x1E, 0x18, 0xC0, 0xF4, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {8, 873, 0, {0x28, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x69, 0x37, 0xC0, 0x02}},
- {5, 704, 774, {0x28, 0xF4, 0x05, 0x18, 0x21, 0x17, 0x59, 0x0F, 0x18, 0xC0, 0x42, 0xC0, 0x02}},
- {3, 448, 492, {0x28, 0xF4, 0x05, 0x0F, 0x5D, 0x0E, 0x95, 0x15, 0x18, 0xC0, 0x69, 0xC0, 0x02}},
- {2, 291, 320, {0x28, 0xF4, 0x1D, 0x09, 0xFB, 0x09, 0x33, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
- },
- },
- /* QCIF */
- {
- /* 5 fps */
- {
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- {1, 193, 0, {0x0D, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xC1, 0xF4, 0xC0, 0x02}},
- },
- /* 10 fps */
- {
- {3, 385, 0, {0x0C, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x81, 0x79, 0xC0, 0x02}},
- {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {2, 291, 800, {0x0C, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x11, 0x08, 0x23, 0xA1, 0xC0, 0x02}},
- {1, 194, 532, {0x0C, 0xF4, 0x05, 0x10, 0x9A, 0x0F, 0xBE, 0x1B, 0x08, 0xC2, 0xF0, 0xC0, 0x02}},
- },
- /* 15 fps */
- {
- {4, 577, 0, {0x0B, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x41, 0x52, 0xC0, 0x02}},
- {3, 447, 818, {0x0B, 0xF4, 0x05, 0x19, 0x89, 0x18, 0xAD, 0x0F, 0x10, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 534, {0x0B, 0xF4, 0x05, 0x10, 0xA3, 0x0F, 0xC7, 0x19, 0x10, 0x24, 0xA1, 0xC0, 0x02}},
- {1, 195, 356, {0x0B, 0xF4, 0x15, 0x0B, 0x11, 0x0A, 0x35, 0x1E, 0x10, 0xC3, 0xF0, 0xC0, 0x02}},
- },
- /* 20 fps */
- {
- {6, 776, 0, {0x0A, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0x08, 0x3F, 0xC0, 0x02}},
- {4, 591, 804, {0x0A, 0xF4, 0x05, 0x19, 0x1E, 0x18, 0x42, 0x0F, 0x18, 0x4F, 0x4E, 0xC0, 0x02}},
- {3, 447, 608, {0x0A, 0xF4, 0x05, 0x12, 0xFD, 0x12, 0x21, 0x15, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 291, 396, {0x0A, 0xF4, 0x15, 0x0C, 0x5E, 0x0B, 0x82, 0x1E, 0x18, 0x23, 0xA1, 0xC0, 0x02}},
- },
- /* 25 fps */
- {
- {9, 928, 0, {0x09, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x12, 0x00, 0xA0, 0x33, 0xC0, 0x02}},
- {5, 703, 800, {0x09, 0xF4, 0x05, 0x18, 0xF4, 0x18, 0x18, 0x10, 0x18, 0xBF, 0x42, 0xC0, 0x02}},
- {3, 447, 508, {0x09, 0xF4, 0x0D, 0x0F, 0xD2, 0x0E, 0xF6, 0x1B, 0x18, 0xBF, 0x69, 0xC0, 0x02}},
- {2, 292, 332, {0x09, 0xF4, 0x1D, 0x0A, 0x5A, 0x09, 0x7E, 0x1E, 0x18, 0x24, 0xA1, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 956, 876, {0x08, 0xF4, 0x05, 0x1B, 0x58, 0x1A, 0x7C, 0x0E, 0x20, 0xBC, 0x33, 0x10, 0x02}},
- {4, 592, 542, {0x08, 0xF4, 0x05, 0x10, 0xE4, 0x10, 0x08, 0x17, 0x20, 0x50, 0x4E, 0x10, 0x02}},
- {2, 291, 266, {0x08, 0xF4, 0x25, 0x08, 0x48, 0x07, 0x6C, 0x1E, 0x20, 0x23, 0xA1, 0x10, 0x02}},
- },
- },
- /* SIF */
- {
- /* 5 fps */
- {
- {4, 582, 0, {0x35, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x46, 0x52, 0x60, 0x02}},
- {3, 387, 1276, {0x35, 0xF4, 0x05, 0x27, 0xD8, 0x26, 0x48, 0x03, 0x10, 0x83, 0x79, 0x60, 0x02}},
- {2, 291, 960, {0x35, 0xF4, 0x0D, 0x1D, 0xF2, 0x1C, 0x62, 0x04, 0x10, 0x23, 0xA1, 0x60, 0x02}},
- {1, 191, 630, {0x35, 0xF4, 0x1D, 0x13, 0xA9, 0x12, 0x19, 0x05, 0x08, 0xBF, 0xF4, 0x60, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {6, 775, 1278, {0x34, 0xF4, 0x05, 0x27, 0xE8, 0x26, 0x58, 0x05, 0x30, 0x07, 0x3F, 0x10, 0x02}},
- {3, 447, 736, {0x34, 0xF4, 0x15, 0x16, 0xFB, 0x15, 0x6B, 0x05, 0x18, 0xBF, 0x69, 0x10, 0x02}},
- {2, 291, 480, {0x34, 0xF4, 0x2D, 0x0E, 0xF9, 0x0D, 0x69, 0x09, 0x18, 0x23, 0xA1, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 955, 1050, {0x33, 0xF4, 0x05, 0x20, 0xCF, 0x1F, 0x3F, 0x06, 0x48, 0xBB, 0x33, 0x10, 0x02}},
- {4, 591, 650, {0x33, 0xF4, 0x15, 0x14, 0x44, 0x12, 0xB4, 0x08, 0x30, 0x4F, 0x4E, 0x10, 0x02}},
- {3, 448, 492, {0x33, 0xF4, 0x25, 0x0F, 0x52, 0x0D, 0xC2, 0x09, 0x28, 0xC0, 0x69, 0x10, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 958, 782, {0x32, 0xF4, 0x0D, 0x18, 0x6A, 0x16, 0xDA, 0x0B, 0x58, 0xBE, 0x33, 0xD0, 0x02}},
- {5, 703, 574, {0x32, 0xF4, 0x1D, 0x11, 0xE7, 0x10, 0x57, 0x0B, 0x40, 0xBF, 0x42, 0xD0, 0x02}},
- {3, 446, 364, {0x32, 0xF4, 0x3D, 0x0B, 0x5C, 0x09, 0xCC, 0x0E, 0x30, 0xBE, 0x69, 0xD0, 0x02}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 958, 654, {0x31, 0xF4, 0x15, 0x14, 0x66, 0x12, 0xD6, 0x0B, 0x50, 0xBE, 0x33, 0x90, 0x02}},
- {6, 776, 530, {0x31, 0xF4, 0x25, 0x10, 0x8C, 0x0E, 0xFC, 0x0C, 0x48, 0x08, 0x3F, 0x90, 0x02}},
- {4, 592, 404, {0x31, 0xF4, 0x35, 0x0C, 0x96, 0x0B, 0x06, 0x0B, 0x38, 0x50, 0x4E, 0x90, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 957, 526, {0x30, 0xF4, 0x25, 0x10, 0x68, 0x0E, 0xD8, 0x0D, 0x58, 0xBD, 0x33, 0x60, 0x02}},
- {6, 775, 426, {0x30, 0xF4, 0x35, 0x0D, 0x48, 0x0B, 0xB8, 0x0F, 0x50, 0x07, 0x3F, 0x60, 0x02}},
- {4, 590, 324, {0x30, 0x7A, 0x4B, 0x0A, 0x1C, 0x08, 0xB4, 0x0E, 0x40, 0x4E, 0x52, 0x60, 0x02}},
- },
- },
- /* CIF */
- {
- /* 5 fps */
- {
- {6, 771, 0, {0x15, 0xF4, 0x04, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x3F, 0x80, 0x02}},
- {4, 465, 1278, {0x15, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x03, 0x18, 0xD1, 0x65, 0x80, 0x02}},
- {2, 291, 800, {0x15, 0xF4, 0x15, 0x18, 0xF4, 0x17, 0x3C, 0x05, 0x18, 0x23, 0xA1, 0x80, 0x02}},
- {1, 193, 528, {0x15, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x18, 0xC1, 0xF4, 0x80, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 932, 1278, {0x14, 0xF4, 0x05, 0x27, 0xEE, 0x26, 0x36, 0x04, 0x30, 0xA4, 0x33, 0x10, 0x02}},
- {4, 591, 812, {0x14, 0xF4, 0x15, 0x19, 0x56, 0x17, 0x9E, 0x06, 0x28, 0x4F, 0x4E, 0x10, 0x02}},
- {2, 291, 400, {0x14, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x28, 0x23, 0xA1, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 956, 876, {0x13, 0xF4, 0x0D, 0x1B, 0x58, 0x19, 0xA0, 0x05, 0x38, 0xBC, 0x33, 0x60, 0x02}},
- {5, 703, 644, {0x13, 0xF4, 0x1D, 0x14, 0x1C, 0x12, 0x64, 0x08, 0x38, 0xBF, 0x42, 0x60, 0x02}},
- {3, 448, 410, {0x13, 0xF4, 0x3D, 0x0C, 0xC4, 0x0B, 0x0C, 0x0E, 0x38, 0xC0, 0x69, 0x60, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {9, 956, 650, {0x12, 0xF4, 0x1D, 0x14, 0x4A, 0x12, 0x92, 0x09, 0x48, 0xBC, 0x33, 0x10, 0x03}},
- {6, 776, 528, {0x12, 0xF4, 0x2D, 0x10, 0x7E, 0x0E, 0xC6, 0x0A, 0x40, 0x08, 0x3F, 0x10, 0x03}},
- {4, 591, 402, {0x12, 0xF4, 0x3D, 0x0C, 0x8F, 0x0A, 0xD7, 0x0E, 0x40, 0x4F, 0x4E, 0x10, 0x03}},
- },
- /* 25 fps */
- {
- {0, },
- {9, 956, 544, {0x11, 0xF4, 0x25, 0x10, 0xF4, 0x0F, 0x3C, 0x0A, 0x48, 0xBC, 0x33, 0xC0, 0x02}},
- {7, 840, 478, {0x11, 0xF4, 0x2D, 0x0E, 0xEB, 0x0D, 0x33, 0x0B, 0x48, 0x48, 0x3B, 0xC0, 0x02}},
- {5, 703, 400, {0x11, 0xF4, 0x3D, 0x0C, 0x7A, 0x0A, 0xC2, 0x0E, 0x48, 0xBF, 0x42, 0xC0, 0x02}},
- },
- /* 30 fps */
- {
- {0, },
- {9, 956, 438, {0x10, 0xF4, 0x35, 0x0D, 0xAC, 0x0B, 0xF4, 0x0D, 0x50, 0xBC, 0x33, 0x10, 0x02}},
- {7, 838, 384, {0x10, 0xF4, 0x45, 0x0B, 0xFD, 0x0A, 0x45, 0x0F, 0x50, 0x46, 0x3B, 0x10, 0x02}},
- {6, 773, 354, {0x10, 0x7A, 0x4B, 0x0B, 0x0C, 0x09, 0x80, 0x10, 0x50, 0x05, 0x3F, 0x10, 0x02}},
- },
- },
- /* VGA */
- {
- /* 5 fps */
- {
- {0, },
- {6, 773, 1272, {0x1D, 0xF4, 0x15, 0x27, 0xB6, 0x24, 0x96, 0x02, 0x30, 0x05, 0x3F, 0x10, 0x02}},
- {4, 592, 976, {0x1D, 0xF4, 0x25, 0x1E, 0x78, 0x1B, 0x58, 0x03, 0x30, 0x50, 0x4E, 0x10, 0x02}},
- {3, 448, 738, {0x1D, 0xF4, 0x3D, 0x17, 0x0C, 0x13, 0xEC, 0x04, 0x30, 0xC0, 0x69, 0x10, 0x02}},
- },
- /* 10 fps */
- {
- {0, },
- {9, 956, 788, {0x1C, 0xF4, 0x35, 0x18, 0x9C, 0x15, 0x7C, 0x03, 0x48, 0xBC, 0x33, 0x10, 0x02}},
- {6, 776, 640, {0x1C, 0x7A, 0x53, 0x13, 0xFC, 0x11, 0x2C, 0x04, 0x48, 0x08, 0x3F, 0x10, 0x02}},
- {4, 592, 488, {0x1C, 0x7A, 0x6B, 0x0F, 0x3C, 0x0C, 0x6C, 0x06, 0x48, 0x50, 0x4E, 0x10, 0x02}},
- },
- /* 15 fps */
- {
- {0, },
- {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
- {9, 957, 526, {0x1B, 0x7A, 0x63, 0x10, 0x68, 0x0D, 0x98, 0x06, 0x58, 0xBD, 0x33, 0x80, 0x02}},
- {8, 895, 492, {0x1B, 0x7A, 0x6B, 0x0F, 0x5D, 0x0C, 0x8D, 0x06, 0x58, 0x7F, 0x37, 0x80, 0x02}},
- },
- /* 20 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 25 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- /* 30 fps */
- {
- {0, },
- {0, },
- {0, },
- {0, },
- },
- },
-};
-
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index a8455c9e79d..495db5755df 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -102,7 +102,7 @@ static struct usb_driver option_driver = {
.no_dynamic_id = 1,
};
-/* The card has three separate interfaces, wich the serial driver
+/* The card has three separate interfaces, which the serial driver
* recognizes separately, thus num_port=1.
*/
static struct usb_serial_driver option_3port_device = {
diff --git a/drivers/video/aty/radeon_pm.c b/drivers/video/aty/radeon_pm.c
index 1f8d805c61e..5886a2f1323 100644
--- a/drivers/video/aty/radeon_pm.c
+++ b/drivers/video/aty/radeon_pm.c
@@ -2080,7 +2080,7 @@ static void radeon_reinitialize_M9P(struct radeonfb_info *rinfo)
OUTREG(0x2ec, 0x6332a3f0);
mdelay(17);
- OUTPLL(pllPPLL_REF_DIV, rinfo->pll.ref_div);;
+ OUTPLL(pllPPLL_REF_DIV, rinfo->pll.ref_div);
OUTPLL(pllPPLL_DIV_0, rinfo->save_regs[92]);
mdelay(40);
diff --git a/drivers/video/backlight/locomolcd.c b/drivers/video/backlight/locomolcd.c
index ada6e75eb04..60831bb2368 100644
--- a/drivers/video/backlight/locomolcd.c
+++ b/drivers/video/backlight/locomolcd.c
@@ -20,14 +20,10 @@
#include <asm/hardware/locomo.h>
#include <asm/irq.h>
+#include <asm/mach/sharpsl_param.h>
+#include <asm/mach-types.h>
-#ifdef CONFIG_SA1100_COLLIE
-#include <asm/arch/collie.h>
-#else
-#include <asm/arch/poodle.h>
-#endif
-
-extern void (*sa1100fb_lcd_power)(int on);
+#include "../../../arch/arm/mach-sa1100/generic.h"
static struct locomo_dev *locomolcd_dev;
@@ -82,7 +78,7 @@ static void locomolcd_off(int comadj)
void locomolcd_power(int on)
{
- int comadj = 118;
+ int comadj = sharpsl_param.comadj;
unsigned long flags;
local_irq_save(flags);
@@ -93,11 +89,12 @@ void locomolcd_power(int on)
}
/* read comadj */
-#ifdef CONFIG_MACH_POODLE
- comadj = 118;
-#else
- comadj = 128;
-#endif
+ if (comadj == -1) {
+ if (machine_is_poodle())
+ comadj = 118;
+ if (machine_is_collie())
+ comadj = 128;
+ }
if (on)
locomolcd_on(comadj);
diff --git a/drivers/video/bw2.c b/drivers/video/bw2.c
index c029db4646f..6577fdfdfc1 100644
--- a/drivers/video/bw2.c
+++ b/drivers/video/bw2.c
@@ -327,8 +327,7 @@ static void bw2_init_one(struct sbus_dev *sdev)
} else
#else
{
- if (!sdev)
- BUG();
+ BUG_ON(!sdev);
all->par.physbase = sdev->reg_addrs[0].phys_addr;
resp = &sdev->resource[0];
sbusfb_fill_var(&all->info.var, (sdev ? sdev->prom_node : 0), 1);
diff --git a/drivers/video/cirrusfb.c b/drivers/video/cirrusfb.c
index e0dbdfc0c8b..66d6f2f0a21 100644
--- a/drivers/video/cirrusfb.c
+++ b/drivers/video/cirrusfb.c
@@ -2622,7 +2622,7 @@ static int __init cirrusfb_init(void)
#endif
#ifdef CONFIG_ZORRO
- error |= zorro_module_init(&cirrusfb_zorro_driver);
+ error |= zorro_register_driver(&cirrusfb_zorro_driver);
#endif
#ifdef CONFIG_PCI
error |= pci_register_driver(&cirrusfb_pci_driver);
diff --git a/drivers/video/ffb.c b/drivers/video/ffb.c
index 9c9b21d469a..7633e41adda 100644
--- a/drivers/video/ffb.c
+++ b/drivers/video/ffb.c
@@ -466,8 +466,7 @@ static void ffb_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
unsigned long flags;
u32 fg;
- if (rect->rop != ROP_COPY && rect->rop != ROP_XOR)
- BUG();
+ BUG_ON(rect->rop != ROP_COPY && rect->rop != ROP_XOR);
fg = ((u32 *)info->pseudo_palette)[rect->color];
diff --git a/drivers/video/hpfb.c b/drivers/video/hpfb.c
index bebdac59d23..abd920a663a 100644
--- a/drivers/video/hpfb.c
+++ b/drivers/video/hpfb.c
@@ -386,7 +386,9 @@ int __init hpfb_init(void)
if (fb_get_options("hpfb", NULL))
return -ENODEV;
- dio_module_init(&hpfb_driver);
+ err = dio_register_driver(&hpfb_driver);
+ if (err)
+ return err;
fs = get_fs();
set_fs(KERNEL_DS);
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 0fbd9b5149f..a456e67a5b0 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -12,7 +12,6 @@
*
*/
-/* make checkconfig does not walk through include tree :-( */
#include <linux/config.h>
#include "matroxfb_DAC1064.h"
diff --git a/drivers/video/matrox/matroxfb_DAC1064.h b/drivers/video/matrox/matroxfb_DAC1064.h
index a6a47012728..2e7238aa243 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.h
+++ b/drivers/video/matrox/matroxfb_DAC1064.h
@@ -1,7 +1,6 @@
#ifndef __MATROXFB_DAC1064_H__
#define __MATROXFB_DAC1064_H__
-/* make checkconfig does not walk through include tree */
#include <linux/config.h>
#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c
index 537ade5d8b2..23ebad0a12d 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.c
+++ b/drivers/video/matrox/matroxfb_Ti3026.c
@@ -78,7 +78,6 @@
*
*/
-/* make checkconfig does not verify included files... */
#include <linux/config.h>
#include "matroxfb_Ti3026.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.h b/drivers/video/matrox/matroxfb_Ti3026.h
index 541933d7e4e..536e5f69de9 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.h
+++ b/drivers/video/matrox/matroxfb_Ti3026.h
@@ -1,7 +1,6 @@
#ifndef __MATROXFB_TI3026_H__
#define __MATROXFB_TI3026_H__
-/* make checkconfig does not walk through whole include tree */
#include <linux/config.h>
#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 4055ff6f5a8..951c9974a1d 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -99,7 +99,6 @@
*
*/
-/* make checkconfig does not check included files... */
#include <linux/config.h>
#include <linux/version.h>
diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c
index 455a46ce840..263d801ef78 100644
--- a/drivers/video/matrox/matroxfb_misc.c
+++ b/drivers/video/matrox/matroxfb_misc.c
@@ -84,7 +84,6 @@
*
*/
-/* make checkconfig does not check includes for this... */
#include <linux/config.h>
#include "matroxfb_misc.h"
diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c
index 0e78ddc8158..52c18a35fb4 100644
--- a/drivers/video/pm3fb.c
+++ b/drivers/video/pm3fb.c
@@ -3532,26 +3532,26 @@ int __init pm3fb_init(void)
MODULE_AUTHOR("Romain Dolbeau");
MODULE_DESCRIPTION("Permedia3 framebuffer device driver");
static char *mode[PM3_MAX_BOARD];
-MODULE_PARM(mode,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
+module_param_array(mode, charp, NULL, 0);
MODULE_PARM_DESC(mode,"video mode");
-MODULE_PARM(disable,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
+module_param_array(disable, short, NULL, 0);
MODULE_PARM_DESC(disable,"disable board");
static short off[PM3_MAX_BOARD];
-MODULE_PARM(off,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
+module_param_array(off, short, NULL, 0);
MODULE_PARM_DESC(off,"disable board");
static char *pciid[PM3_MAX_BOARD];
-MODULE_PARM(pciid,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
+module_param_array(pciid, charp, NULL, 0);
MODULE_PARM_DESC(pciid,"board PCI Id");
-MODULE_PARM(noaccel,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
+module_param_array(noaccel, short, NULL, 0);
MODULE_PARM_DESC(noaccel,"disable accel");
static char *font[PM3_MAX_BOARD];
-MODULE_PARM(font,PM3_MAX_BOARD_MODULE_ARRAY_STRING);
+module_param_array(font, charp, NULL, 0);
MODULE_PARM_DESC(font,"choose font");
-MODULE_PARM(depth,PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
+module_param(depth, short, NULL, 0);
MODULE_PARM_DESC(depth,"boot-time depth");
-MODULE_PARM(printtimings, "h");
+module_param(printtimings, short, NULL, 0);
MODULE_PARM_DESC(printtimings, "print the memory timings of the card(s)");
-MODULE_PARM(forcesize, PM3_MAX_BOARD_MODULE_ARRAY_SHORT);
+module_param(forcesize, short, NULL, 0);
MODULE_PARM_DESC(forcesize, "force specified memory size");
/*
MODULE_SUPPORTED_DEVICE("Permedia3 PCI boards")
diff --git a/drivers/video/sstfb.c b/drivers/video/sstfb.c
index 99921df3547..8c1a8b5135c 100644
--- a/drivers/video/sstfb.c
+++ b/drivers/video/sstfb.c
@@ -32,7 +32,7 @@
-TODO: at one time or another test that the mode is acceptable by the monitor
-ASK: Can I choose different ordering for the color bitfields (rgba argb ...)
- wich one should i use ? is there any preferred one ? It seems ARGB is
+ which one should i use ? is there any preferred one ? It seems ARGB is
the one ...
-TODO: in set_var check the validity of timings (hsync vsync)...
-TODO: check and recheck the use of sst_wait_idle : we don't flush the fifo via
diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig
index 4baf61a2232..5e61ed59a41 100644
--- a/drivers/w1/Kconfig
+++ b/drivers/w1/Kconfig
@@ -11,63 +11,7 @@ config W1
This W1 support can also be built as a module. If so, the module
will be called wire.ko.
-config W1_MATROX
- tristate "Matrox G400 transport layer for 1-wire"
- depends on W1 && PCI
- help
- Say Y here if you want to communicate with your 1-wire devices
- using Matrox's G400 GPIO pins.
-
- This support is also available as a module. If so, the module
- will be called matrox_w1.ko.
-
-config W1_DS9490
- tristate "DS9490R transport layer driver"
- depends on W1 && USB
- help
- Say Y here if you want to have a driver for DS9490R UWB <-> W1 bridge.
-
- This support is also available as a module. If so, the module
- will be called ds9490r.ko.
-
-config W1_DS9490_BRIDGE
- tristate "DS9490R USB <-> W1 transport layer for 1-wire"
- depends on W1_DS9490
- help
- Say Y here if you want to communicate with your 1-wire devices
- using DS9490R USB bridge.
-
- This support is also available as a module. If so, the module
- will be called ds_w1_bridge.ko.
-
-config W1_THERM
- tristate "Thermal family implementation"
- depends on W1
- help
- Say Y here if you want to connect 1-wire thermal sensors to you
- wire.
-
-config W1_SMEM
- tristate "Simple 64bit memory family implementation"
- depends on W1
- help
- Say Y here if you want to connect 1-wire
- simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire.
-
-config W1_DS2433
- tristate "4kb EEPROM family support (DS2433)"
- depends on W1
- help
- Say Y here if you want to use a 1-wire
- 4kb EEPROM family device (DS2433).
-
-config W1_DS2433_CRC
- bool "Protect DS2433 data with a CRC16"
- depends on W1_DS2433
- select CRC16
- help
- Say Y here to protect DS2433 data with a CRC16.
- Each block has 30 bytes of data and a two byte CRC16.
- Full block writes are only allowed if the CRC is valid.
+source drivers/w1/masters/Kconfig
+source drivers/w1/slaves/Kconfig
endmenu
diff --git a/drivers/w1/Makefile b/drivers/w1/Makefile
index 01fb5439147..0c2aa22d8c0 100644
--- a/drivers/w1/Makefile
+++ b/drivers/w1/Makefile
@@ -13,13 +13,5 @@ endif
obj-$(CONFIG_W1) += wire.o
wire-objs := w1.o w1_int.o w1_family.o w1_netlink.o w1_io.o
-obj-$(CONFIG_W1_MATROX) += matrox_w1.o
-obj-$(CONFIG_W1_THERM) += w1_therm.o
-obj-$(CONFIG_W1_SMEM) += w1_smem.o
+obj-y += masters/ slaves/
-obj-$(CONFIG_W1_DS9490) += ds9490r.o
-ds9490r-objs := dscore.o
-
-obj-$(CONFIG_W1_DS9490_BRIDGE) += ds_w1_bridge.o
-
-obj-$(CONFIG_W1_DS2433) += w1_ds2433.o
diff --git a/drivers/w1/masters/Kconfig b/drivers/w1/masters/Kconfig
new file mode 100644
index 00000000000..c6bad4dbdc6
--- /dev/null
+++ b/drivers/w1/masters/Kconfig
@@ -0,0 +1,48 @@
+#
+# 1-wire bus master configuration
+#
+
+menu "1-wire Bus Masters"
+ depends on W1
+
+config W1_MASTER_MATROX
+ tristate "Matrox G400 transport layer for 1-wire"
+ depends on W1 && PCI
+ help
+ Say Y here if you want to communicate with your 1-wire devices
+ using Matrox's G400 GPIO pins.
+
+ This support is also available as a module. If so, the module
+ will be called matrox_w1.ko.
+
+config W1_MASTER_DS9490
+ tristate "DS9490R transport layer driver"
+ depends on W1 && USB
+ help
+ Say Y here if you want to have a driver for DS9490R UWB <-> W1 bridge.
+
+ This support is also available as a module. If so, the module
+ will be called ds9490r.ko.
+
+config W1_MASTER_DS9490_BRIDGE
+ tristate "DS9490R USB <-> W1 transport layer for 1-wire"
+ depends on W1_MASTER_DS9490
+ help
+ Say Y here if you want to communicate with your 1-wire devices
+ using DS9490R USB bridge.
+
+ This support is also available as a module. If so, the module
+ will be called ds_w1_bridge.ko.
+
+config W1_MASTER_DS2482
+ tristate "Maxim DS2482 I2C to 1-Wire bridge"
+ depends on I2C && W1 && EXPERIMENTAL
+ help
+ If you say yes here you get support for the Maxim DS2482
+ I2C to 1-Wire bridge.
+
+ This driver can also be built as a module. If so, the module
+ will be called ds2482.
+
+endmenu
+
diff --git a/drivers/w1/masters/Makefile b/drivers/w1/masters/Makefile
new file mode 100644
index 00000000000..1f3c8b983dc
--- /dev/null
+++ b/drivers/w1/masters/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile for 1-wire bus master drivers.
+#
+
+obj-$(CONFIG_W1_MASTER_MATROX) += matrox_w1.o
+
+obj-$(CONFIG_W1_MASTER_DS9490) += ds9490r.o
+ds9490r-objs := dscore.o
+
+obj-$(CONFIG_W1_MASTER_DS9490_BRIDGE) += ds_w1_bridge.o
+
+obj-$(CONFIG_W1_MASTER_DS2482) += ds2482.o
+
diff --git a/drivers/w1/masters/ds2482.c b/drivers/w1/masters/ds2482.c
new file mode 100644
index 00000000000..d1cacd23576
--- /dev/null
+++ b/drivers/w1/masters/ds2482.c
@@ -0,0 +1,564 @@
+/**
+ * ds2482.c - provides i2c to w1-master bridge(s)
+ * Copyright (C) 2005 Ben Gardner <bgardner@wabtec.com>
+ *
+ * The DS2482 is a sensor chip made by Dallas Semiconductor (Maxim).
+ * It is a I2C to 1-wire bridge.
+ * There are two variations: -100 and -800, which have 1 or 8 1-wire ports.
+ * The complete datasheet can be obtained from MAXIM's website at:
+ * http://www.maxim-ic.com/quick_view2.cfm/qv_pk/4382
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <asm/delay.h>
+
+#include "../w1.h"
+#include "../w1_int.h"
+
+/**
+ * Address is selected using 2 pins, resulting in 4 possible addresses.
+ * 0x18, 0x19, 0x1a, 0x1b
+ * However, the chip cannot be detected without doing an i2c write,
+ * so use the force module parameter.
+ */
+static unsigned short normal_i2c[] = {I2C_CLIENT_END};
+
+/**
+ * Insmod parameters
+ */
+I2C_CLIENT_INSMOD_1(ds2482);
+
+/**
+ * The DS2482 registers - there are 3 registers that are addressed by a read
+ * pointer. The read pointer is set by the last command executed.
+ *
+ * To read the data, issue a register read for any address
+ */
+#define DS2482_CMD_RESET 0xF0 /* No param */
+#define DS2482_CMD_SET_READ_PTR 0xE1 /* Param: DS2482_PTR_CODE_xxx */
+#define DS2482_CMD_CHANNEL_SELECT 0xC3 /* Param: Channel byte - DS2482-800 only */
+#define DS2482_CMD_WRITE_CONFIG 0xD2 /* Param: Config byte */
+#define DS2482_CMD_1WIRE_RESET 0xB4 /* Param: None */
+#define DS2482_CMD_1WIRE_SINGLE_BIT 0x87 /* Param: Bit byte (bit7) */
+#define DS2482_CMD_1WIRE_WRITE_BYTE 0xA5 /* Param: Data byte */
+#define DS2482_CMD_1WIRE_READ_BYTE 0x96 /* Param: None */
+/* Note to read the byte, Set the ReadPtr to Data then read (any addr) */
+#define DS2482_CMD_1WIRE_TRIPLET 0x78 /* Param: Dir byte (bit7) */
+
+/* Values for DS2482_CMD_SET_READ_PTR */
+#define DS2482_PTR_CODE_STATUS 0xF0
+#define DS2482_PTR_CODE_DATA 0xE1
+#define DS2482_PTR_CODE_CHANNEL 0xD2 /* DS2482-800 only */
+#define DS2482_PTR_CODE_CONFIG 0xC3
+
+/**
+ * Configure Register bit definitions
+ * The top 4 bits always read 0.
+ * To write, the top nibble must be the 1's compl. of the low nibble.
+ */
+#define DS2482_REG_CFG_1WS 0x08
+#define DS2482_REG_CFG_SPU 0x04
+#define DS2482_REG_CFG_PPM 0x02
+#define DS2482_REG_CFG_APU 0x01
+
+
+/**
+ * Write and verify codes for the CHANNEL_SELECT command (DS2482-800 only).
+ * To set the channel, write the value at the index of the channel.
+ * Read and compare against the corresponding value to verify the change.
+ */
+static const u8 ds2482_chan_wr[8] =
+ { 0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87 };
+static const u8 ds2482_chan_rd[8] =
+ { 0xB8, 0xB1, 0xAA, 0xA3, 0x9C, 0x95, 0x8E, 0x87 };
+
+
+/**
+ * Status Register bit definitions (read only)
+ */
+#define DS2482_REG_STS_DIR 0x80
+#define DS2482_REG_STS_TSB 0x40
+#define DS2482_REG_STS_SBR 0x20
+#define DS2482_REG_STS_RST 0x10
+#define DS2482_REG_STS_LL 0x08
+#define DS2482_REG_STS_SD 0x04
+#define DS2482_REG_STS_PPD 0x02
+#define DS2482_REG_STS_1WB 0x01
+
+
+static int ds2482_attach_adapter(struct i2c_adapter *adapter);
+static int ds2482_detect(struct i2c_adapter *adapter, int address, int kind);
+static int ds2482_detach_client(struct i2c_client *client);
+
+
+/**
+ * Driver data (common to all clients)
+ */
+static struct i2c_driver ds2482_driver = {
+ .driver = {
+ .owner = THIS_MODULE,
+ .name = "ds2482",
+ },
+ .attach_adapter = ds2482_attach_adapter,
+ .detach_client = ds2482_detach_client,
+};
+
+/*
+ * Client data (each client gets its own)
+ */
+
+struct ds2482_data;
+
+struct ds2482_w1_chan {
+ struct ds2482_data *pdev;
+ u8 channel;
+ struct w1_bus_master w1_bm;
+};
+
+struct ds2482_data {
+ struct i2c_client client;
+ struct semaphore access_lock;
+
+ /* 1-wire interface(s) */
+ int w1_count; /* 1 or 8 */
+ struct ds2482_w1_chan w1_ch[8];
+
+ /* per-device values */
+ u8 channel;
+ u8 read_prt; /* see DS2482_PTR_CODE_xxx */
+ u8 reg_config;
+};
+
+
+/**
+ * Sets the read pointer.
+ * @param pdev The ds2482 client pointer
+ * @param read_ptr see DS2482_PTR_CODE_xxx above
+ * @return -1 on failure, 0 on success
+ */
+static inline int ds2482_select_register(struct ds2482_data *pdev, u8 read_ptr)
+{
+ if (pdev->read_prt != read_ptr) {
+ if (i2c_smbus_write_byte_data(&pdev->client,
+ DS2482_CMD_SET_READ_PTR,
+ read_ptr) < 0)
+ return -1;
+
+ pdev->read_prt = read_ptr;
+ }
+ return 0;
+}
+
+/**
+ * Sends a command without a parameter
+ * @param pdev The ds2482 client pointer
+ * @param cmd DS2482_CMD_RESET,
+ * DS2482_CMD_1WIRE_RESET,
+ * DS2482_CMD_1WIRE_READ_BYTE
+ * @return -1 on failure, 0 on success
+ */
+static inline int ds2482_send_cmd(struct ds2482_data *pdev, u8 cmd)
+{
+ if (i2c_smbus_write_byte(&pdev->client, cmd) < 0)
+ return -1;
+
+ pdev->read_prt = DS2482_PTR_CODE_STATUS;
+ return 0;
+}
+
+/**
+ * Sends a command with a parameter
+ * @param pdev The ds2482 client pointer
+ * @param cmd DS2482_CMD_WRITE_CONFIG,
+ * DS2482_CMD_1WIRE_SINGLE_BIT,
+ * DS2482_CMD_1WIRE_WRITE_BYTE,
+ * DS2482_CMD_1WIRE_TRIPLET
+ * @param byte The data to send
+ * @return -1 on failure, 0 on success
+ */
+static inline int ds2482_send_cmd_data(struct ds2482_data *pdev,
+ u8 cmd, u8 byte)
+{
+ if (i2c_smbus_write_byte_data(&pdev->client, cmd, byte) < 0)
+ return -1;
+
+ /* all cmds leave in STATUS, except CONFIG */
+ pdev->read_prt = (cmd != DS2482_CMD_WRITE_CONFIG) ?
+ DS2482_PTR_CODE_STATUS : DS2482_PTR_CODE_CONFIG;
+ return 0;
+}
+
+
+/*
+ * 1-Wire interface code
+ */
+
+#define DS2482_WAIT_IDLE_TIMEOUT 100
+
+/**
+ * Waits until the 1-wire interface is idle (not busy)
+ *
+ * @param pdev Pointer to the device structure
+ * @return the last value read from status or -1 (failure)
+ */
+static int ds2482_wait_1wire_idle(struct ds2482_data *pdev)
+{
+ int temp = -1;
+ int retries = 0;
+
+ if (!ds2482_select_register(pdev, DS2482_PTR_CODE_STATUS)) {
+ do {
+ temp = i2c_smbus_read_byte(&pdev->client);
+ } while ((temp >= 0) && (temp & DS2482_REG_STS_1WB) &&
+ (++retries > DS2482_WAIT_IDLE_TIMEOUT));
+ }
+
+ if (retries > DS2482_WAIT_IDLE_TIMEOUT)
+ printk(KERN_ERR "%s: timeout on channel %d\n",
+ __func__, pdev->channel);
+
+ return temp;
+}
+
+/**
+ * Selects a w1 channel.
+ * The 1-wire interface must be idle before calling this function.
+ *
+ * @param pdev The ds2482 client pointer
+ * @param channel 0-7
+ * @return -1 (failure) or 0 (success)
+ */
+static int ds2482_set_channel(struct ds2482_data *pdev, u8 channel)
+{
+ if (i2c_smbus_write_byte_data(&pdev->client, DS2482_CMD_CHANNEL_SELECT,
+ ds2482_chan_wr[channel]) < 0)
+ return -1;
+
+ pdev->read_prt = DS2482_PTR_CODE_CHANNEL;
+ pdev->channel = -1;
+ if (i2c_smbus_read_byte(&pdev->client) == ds2482_chan_rd[channel]) {
+ pdev->channel = channel;
+ return 0;
+ }
+ return -1;
+}
+
+
+/**
+ * Performs the touch-bit function, which writes a 0 or 1 and reads the level.
+ *
+ * @param data The ds2482 channel pointer
+ * @param bit The level to write: 0 or non-zero
+ * @return The level read: 0 or 1
+ */
+static u8 ds2482_w1_touch_bit(void *data, u8 bit)
+{
+ struct ds2482_w1_chan *pchan = data;
+ struct ds2482_data *pdev = pchan->pdev;
+ int status = -1;
+
+ down(&pdev->access_lock);
+
+ /* Select the channel */
+ ds2482_wait_1wire_idle(pdev);
+ if (pdev->w1_count > 1)
+ ds2482_set_channel(pdev, pchan->channel);
+
+ /* Send the touch command, wait until 1WB == 0, return the status */
+ if (!ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_SINGLE_BIT,
+ bit ? 0xFF : 0))
+ status = ds2482_wait_1wire_idle(pdev);
+
+ up(&pdev->access_lock);
+
+ return (status & DS2482_REG_STS_SBR) ? 1 : 0;
+}
+
+/**
+ * Performs the triplet function, which reads two bits and writes a bit.
+ * The bit written is determined by the two reads:
+ * 00 => dbit, 01 => 0, 10 => 1
+ *
+ * @param data The ds2482 channel pointer
+ * @param dbit The direction to choose if both branches are valid
+ * @return b0=read1 b1=read2 b3=bit written
+ */
+static u8 ds2482_w1_triplet(void *data, u8 dbit)
+{
+ struct ds2482_w1_chan *pchan = data;
+ struct ds2482_data *pdev = pchan->pdev;
+ int status = (3 << 5);
+
+ down(&pdev->access_lock);
+
+ /* Select the channel */
+ ds2482_wait_1wire_idle(pdev);
+ if (pdev->w1_count > 1)
+ ds2482_set_channel(pdev, pchan->channel);
+
+ /* Send the triplet command, wait until 1WB == 0, return the status */
+ if (!ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_TRIPLET,
+ dbit ? 0xFF : 0))
+ status = ds2482_wait_1wire_idle(pdev);
+
+ up(&pdev->access_lock);
+
+ /* Decode the status */
+ return (status >> 5);
+}
+
+/**
+ * Performs the write byte function.
+ *
+ * @param data The ds2482 channel pointer
+ * @param byte The value to write
+ */
+static void ds2482_w1_write_byte(void *data, u8 byte)
+{
+ struct ds2482_w1_chan *pchan = data;
+ struct ds2482_data *pdev = pchan->pdev;
+
+ down(&pdev->access_lock);
+
+ /* Select the channel */
+ ds2482_wait_1wire_idle(pdev);
+ if (pdev->w1_count > 1)
+ ds2482_set_channel(pdev, pchan->channel);
+
+ /* Send the write byte command */
+ ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_WRITE_BYTE, byte);
+
+ up(&pdev->access_lock);
+}
+
+/**
+ * Performs the read byte function.
+ *
+ * @param data The ds2482 channel pointer
+ * @return The value read
+ */
+static u8 ds2482_w1_read_byte(void *data)
+{
+ struct ds2482_w1_chan *pchan = data;
+ struct ds2482_data *pdev = pchan->pdev;
+ int result;
+
+ down(&pdev->access_lock);
+
+ /* Select the channel */
+ ds2482_wait_1wire_idle(pdev);
+ if (pdev->w1_count > 1)
+ ds2482_set_channel(pdev, pchan->channel);
+
+ /* Send the read byte command */
+ ds2482_send_cmd(pdev, DS2482_CMD_1WIRE_READ_BYTE);
+
+ /* Wait until 1WB == 0 */
+ ds2482_wait_1wire_idle(pdev);
+
+ /* Select the data register */
+ ds2482_select_register(pdev, DS2482_PTR_CODE_DATA);
+
+ /* Read the data byte */
+ result = i2c_smbus_read_byte(&pdev->client);
+
+ up(&pdev->access_lock);
+
+ return result;
+}
+
+
+/**
+ * Sends a reset on the 1-wire interface
+ *
+ * @param data The ds2482 channel pointer
+ * @return 0=Device present, 1=No device present or error
+ */
+static u8 ds2482_w1_reset_bus(void *data)
+{
+ struct ds2482_w1_chan *pchan = data;
+ struct ds2482_data *pdev = pchan->pdev;
+ int err;
+ u8 retval = 1;
+
+ down(&pdev->access_lock);
+
+ /* Select the channel */
+ ds2482_wait_1wire_idle(pdev);
+ if (pdev->w1_count > 1)
+ ds2482_set_channel(pdev, pchan->channel);
+
+ /* Send the reset command */
+ err = ds2482_send_cmd(pdev, DS2482_CMD_1WIRE_RESET);
+ if (err >= 0) {
+ /* Wait until the reset is complete */
+ err = ds2482_wait_1wire_idle(pdev);
+ retval = !(err & DS2482_REG_STS_PPD);
+
+ /* If the chip did reset since detect, re-config it */
+ if (err & DS2482_REG_STS_RST)
+ ds2482_send_cmd_data(pdev, DS2482_CMD_WRITE_CONFIG,
+ 0xF0);
+ }
+
+ up(&pdev->access_lock);
+
+ return retval;
+}
+
+
+/**
+ * Called to see if the device exists on an i2c bus.
+ */
+static int ds2482_attach_adapter(struct i2c_adapter *adapter)
+{
+ return i2c_probe(adapter, &addr_data, ds2482_detect);
+}
+
+
+/*
+ * The following function does more than just detection. If detection
+ * succeeds, it also registers the new chip.
+ */
+static int ds2482_detect(struct i2c_adapter *adapter, int address, int kind)
+{
+ struct ds2482_data *data;
+ struct i2c_client *new_client;
+ int err = 0;
+ int temp1;
+ int idx;
+
+ if (!i2c_check_functionality(adapter,
+ I2C_FUNC_SMBUS_WRITE_BYTE_DATA |
+ I2C_FUNC_SMBUS_BYTE))
+ goto exit;
+
+ if (!(data = kzalloc(sizeof(struct ds2482_data), GFP_KERNEL))) {
+ err = -ENOMEM;
+ goto exit;
+ }
+
+ new_client = &data->client;
+ i2c_set_clientdata(new_client, data);
+ new_client->addr = address;
+ new_client->driver = &ds2482_driver;
+ new_client->adapter = adapter;
+
+ /* Reset the device (sets the read_ptr to status) */
+ if (ds2482_send_cmd(data, DS2482_CMD_RESET) < 0) {
+ dev_dbg(&adapter->dev, "DS2482 reset failed at 0x%02x.\n",
+ address);
+ goto exit_free;
+ }
+
+ /* Sleep at least 525ns to allow the reset to complete */
+ ndelay(525);
+
+ /* Read the status byte - only reset bit and line should be set */
+ temp1 = i2c_smbus_read_byte(new_client);
+ if (temp1 != (DS2482_REG_STS_LL | DS2482_REG_STS_RST)) {
+ dev_dbg(&adapter->dev, "DS2482 (0x%02x) reset status "
+ "0x%02X - not a DS2482\n", address, temp1);
+ goto exit_free;
+ }
+
+ /* Detect the 8-port version */
+ data->w1_count = 1;
+ if (ds2482_set_channel(data, 7) == 0)
+ data->w1_count = 8;
+
+ /* Set all config items to 0 (off) */
+ ds2482_send_cmd_data(data, DS2482_CMD_WRITE_CONFIG, 0xF0);
+
+ /* We can fill in the remaining client fields */
+ snprintf(new_client->name, sizeof(new_client->name), "ds2482-%d00",
+ data->w1_count);
+
+ init_MUTEX(&data->access_lock);
+
+ /* Tell the I2C layer a new client has arrived */
+ if ((err = i2c_attach_client(new_client)))
+ goto exit_free;
+
+ /* Register 1-wire interface(s) */
+ for (idx = 0; idx < data->w1_count; idx++) {
+ data->w1_ch[idx].pdev = data;
+ data->w1_ch[idx].channel = idx;
+
+ /* Populate all the w1 bus master stuff */
+ data->w1_ch[idx].w1_bm.data = &data->w1_ch[idx];
+ data->w1_ch[idx].w1_bm.read_byte = ds2482_w1_read_byte;
+ data->w1_ch[idx].w1_bm.write_byte = ds2482_w1_write_byte;
+ data->w1_ch[idx].w1_bm.touch_bit = ds2482_w1_touch_bit;
+ data->w1_ch[idx].w1_bm.triplet = ds2482_w1_triplet;
+ data->w1_ch[idx].w1_bm.reset_bus = ds2482_w1_reset_bus;
+
+ err = w1_add_master_device(&data->w1_ch[idx].w1_bm);
+ if (err) {
+ data->w1_ch[idx].pdev = NULL;
+ goto exit_w1_remove;
+ }
+ }
+
+ return 0;
+
+exit_w1_remove:
+ i2c_detach_client(new_client);
+
+ for (idx = 0; idx < data->w1_count; idx++) {
+ if (data->w1_ch[idx].pdev != NULL)
+ w1_remove_master_device(&data->w1_ch[idx].w1_bm);
+ }
+exit_free:
+ kfree(data);
+exit:
+ return err;
+}
+
+static int ds2482_detach_client(struct i2c_client *client)
+{
+ struct ds2482_data *data = i2c_get_clientdata(client);
+ int err, idx;
+
+ /* Unregister the 1-wire bridge(s) */
+ for (idx = 0; idx < data->w1_count; idx++) {
+ if (data->w1_ch[idx].pdev != NULL)
+ w1_remove_master_device(&data->w1_ch[idx].w1_bm);
+ }
+
+ /* Detach the i2c device */
+ if ((err = i2c_detach_client(client))) {
+ dev_err(&client->dev,
+ "Deregistration failed, client not detached.\n");
+ return err;
+ }
+
+ /* Free the memory */
+ kfree(data);
+ return 0;
+}
+
+static int __init sensors_ds2482_init(void)
+{
+ return i2c_add_driver(&ds2482_driver);
+}
+
+static void __exit sensors_ds2482_exit(void)
+{
+ i2c_del_driver(&ds2482_driver);
+}
+
+MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
+MODULE_DESCRIPTION("DS2482 driver");
+MODULE_LICENSE("GPL");
+
+module_init(sensors_ds2482_init);
+module_exit(sensors_ds2482_exit);
diff --git a/drivers/w1/ds_w1_bridge.c b/drivers/w1/masters/ds_w1_bridge.c
index a79d16d5666..5d30783a3eb 100644
--- a/drivers/w1/ds_w1_bridge.c
+++ b/drivers/w1/masters/ds_w1_bridge.c
@@ -22,17 +22,17 @@
#include <linux/module.h>
#include <linux/types.h>
-#include "../w1/w1.h"
-#include "../w1/w1_int.h"
+#include "../w1.h"
+#include "../w1_int.h"
#include "dscore.h"
static struct ds_device *ds_dev;
static struct w1_bus_master *ds_bus_master;
-static u8 ds9490r_touch_bit(unsigned long data, u8 bit)
+static u8 ds9490r_touch_bit(void *data, u8 bit)
{
u8 ret;
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
if (ds_touch_bit(dev, bit, &ret))
return 0;
@@ -40,23 +40,23 @@ static u8 ds9490r_touch_bit(unsigned long data, u8 bit)
return ret;
}
-static void ds9490r_write_bit(unsigned long data, u8 bit)
+static void ds9490r_write_bit(void *data, u8 bit)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
ds_write_bit(dev, bit);
}
-static void ds9490r_write_byte(unsigned long data, u8 byte)
+static void ds9490r_write_byte(void *data, u8 byte)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
ds_write_byte(dev, byte);
}
-static u8 ds9490r_read_bit(unsigned long data)
+static u8 ds9490r_read_bit(void *data)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
int err;
u8 bit = 0;
@@ -70,9 +70,9 @@ static u8 ds9490r_read_bit(unsigned long data)
return bit & 1;
}
-static u8 ds9490r_read_byte(unsigned long data)
+static u8 ds9490r_read_byte(void *data)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
int err;
u8 byte = 0;
@@ -83,16 +83,16 @@ static u8 ds9490r_read_byte(unsigned long data)
return byte;
}
-static void ds9490r_write_block(unsigned long data, const u8 *buf, int len)
+static void ds9490r_write_block(void *data, const u8 *buf, int len)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
ds_write_block(dev, (u8 *)buf, len);
}
-static u8 ds9490r_read_block(unsigned long data, u8 *buf, int len)
+static u8 ds9490r_read_block(void *data, u8 *buf, int len)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
int err;
err = ds_read_block(dev, buf, len);
@@ -102,9 +102,9 @@ static u8 ds9490r_read_block(unsigned long data, u8 *buf, int len)
return len;
}
-static u8 ds9490r_reset(unsigned long data)
+static u8 ds9490r_reset(void *data)
{
- struct ds_device *dev = (struct ds_device *)data;
+ struct ds_device *dev = data;
struct ds_status st;
int err;
@@ -136,7 +136,7 @@ static int __devinit ds_w1_init(void)
memset(ds_bus_master, 0, sizeof(*ds_bus_master));
- ds_bus_master->data = (unsigned long)ds_dev;
+ ds_bus_master->data = ds_dev;
ds_bus_master->touch_bit = &ds9490r_touch_bit;
ds_bus_master->read_bit = &ds9490r_read_bit;
ds_bus_master->write_bit = &ds9490r_write_bit;
diff --git a/drivers/w1/dscore.c b/drivers/w1/masters/dscore.c
index b9146306df4..2cf7776a708 100644
--- a/drivers/w1/dscore.c
+++ b/drivers/w1/masters/dscore.c
@@ -340,7 +340,7 @@ int ds_reset(struct ds_device *dev, struct ds_status *st)
return -EIO;
}
#endif
-
+
return 0;
}
@@ -348,7 +348,7 @@ int ds_reset(struct ds_device *dev, struct ds_status *st)
int ds_set_speed(struct ds_device *dev, int speed)
{
int err;
-
+
if (speed != SPEED_NORMAL && speed != SPEED_FLEXIBLE && speed != SPEED_OVERDRIVE)
return -EINVAL;
diff --git a/drivers/w1/dscore.h b/drivers/w1/masters/dscore.h
index 6cf5671d6eb..6cf5671d6eb 100644
--- a/drivers/w1/dscore.h
+++ b/drivers/w1/masters/dscore.h
diff --git a/drivers/w1/matrox_w1.c b/drivers/w1/masters/matrox_w1.c
index 0b03f8f93f6..2788b8ca9bb 100644
--- a/drivers/w1/matrox_w1.c
+++ b/drivers/w1/masters/matrox_w1.c
@@ -19,8 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <asm/atomic.h>
#include <asm/types.h>
+#include <asm/atomic.h>
#include <asm/io.h>
#include <linux/delay.h>
@@ -35,9 +35,9 @@
#include <linux/pci.h>
#include <linux/timer.h>
-#include "w1.h"
-#include "w1_int.h"
-#include "w1_log.h"
+#include "../w1.h"
+#include "../w1_int.h"
+#include "../w1_log.h"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
@@ -90,15 +90,15 @@ struct matrox_device
struct w1_bus_master *bus_master;
};
-static u8 matrox_w1_read_ddc_bit(unsigned long);
-static void matrox_w1_write_ddc_bit(unsigned long, u8);
+static u8 matrox_w1_read_ddc_bit(void *);
+static void matrox_w1_write_ddc_bit(void *, u8);
/*
* These functions read and write DDC Data bit.
*
* Using tristate pins, since i can't find any open-drain pin in whole motherboard.
* Unfortunately we can't connect to Intel's 82801xx IO controller
- * since we don't know motherboard schema, wich has pretty unused(may be not) GPIO.
+ * since we don't know motherboard schema, which has pretty unused(may be not) GPIO.
*
* I've heard that PIIX also has open drain pin.
*
@@ -122,10 +122,10 @@ static __inline__ void matrox_w1_write_reg(struct matrox_device *dev, u8 reg, u8
wmb();
}
-static void matrox_w1_write_ddc_bit(unsigned long data, u8 bit)
+static void matrox_w1_write_ddc_bit(void *data, u8 bit)
{
u8 ret;
- struct matrox_device *dev = (struct matrox_device *) data;
+ struct matrox_device *dev = data;
if (bit)
bit = 0;
@@ -137,10 +137,10 @@ static void matrox_w1_write_ddc_bit(unsigned long data, u8 bit)
matrox_w1_write_reg(dev, MATROX_GET_DATA, 0x00);
}
-static u8 matrox_w1_read_ddc_bit(unsigned long data)
+static u8 matrox_w1_read_ddc_bit(void *data)
{
u8 ret;
- struct matrox_device *dev = (struct matrox_device *) data;
+ struct matrox_device *dev = data;
ret = matrox_w1_read_reg(dev, MATROX_GET_DATA);
@@ -198,7 +198,7 @@ static int __devinit matrox_w1_probe(struct pci_dev *pdev, const struct pci_devi
matrox_w1_hw_init(dev);
- dev->bus_master->data = (unsigned long) dev;
+ dev->bus_master->data = dev;
dev->bus_master->read_bit = &matrox_w1_read_ddc_bit;
dev->bus_master->write_bit = &matrox_w1_write_ddc_bit;
diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig
new file mode 100644
index 00000000000..f9d4c91fc53
--- /dev/null
+++ b/drivers/w1/slaves/Kconfig
@@ -0,0 +1,38 @@
+#
+# 1-wire slaves configuration
+#
+
+menu "1-wire Slaves"
+ depends on W1
+
+config W1_SLAVE_THERM
+ tristate "Thermal family implementation"
+ depends on W1
+ help
+ Say Y here if you want to connect 1-wire thermal sensors to you
+ wire.
+
+config W1_SLAVE_SMEM
+ tristate "Simple 64bit memory family implementation"
+ depends on W1
+ help
+ Say Y here if you want to connect 1-wire
+ simple 64bit memory rom(ds2401/ds2411/ds1990*) to you wire.
+
+config W1_SLAVE_DS2433
+ tristate "4kb EEPROM family support (DS2433)"
+ depends on W1
+ help
+ Say Y here if you want to use a 1-wire
+ 4kb EEPROM family device (DS2433).
+
+config W1_SLAVE_DS2433_CRC
+ bool "Protect DS2433 data with a CRC16"
+ depends on W1_DS2433
+ select CRC16
+ help
+ Say Y here to protect DS2433 data with a CRC16.
+ Each block has 30 bytes of data and a two byte CRC16.
+ Full block writes are only allowed if the CRC is valid.
+
+endmenu
diff --git a/drivers/w1/slaves/Makefile b/drivers/w1/slaves/Makefile
new file mode 100644
index 00000000000..70e21e2d70c
--- /dev/null
+++ b/drivers/w1/slaves/Makefile
@@ -0,0 +1,12 @@
+#
+# Makefile for the Dallas's 1-wire slaves.
+#
+
+ifeq ($(CONFIG_W1_SLAVE_DS2433_CRC), y)
+EXTRA_CFLAGS += -DCONFIG_W1_F23_CRC
+endif
+
+obj-$(CONFIG_W1_SLAVE_THERM) += w1_therm.o
+obj-$(CONFIG_W1_SLAVE_SMEM) += w1_smem.o
+obj-$(CONFIG_W1_SLAVE_DS2433) += w1_ds2433.o
+
diff --git a/drivers/w1/w1_ds2433.c b/drivers/w1/slaves/w1_ds2433.c
index 1e3d98aac12..fb118be789e 100644
--- a/drivers/w1/w1_ds2433.c
+++ b/drivers/w1/slaves/w1_ds2433.c
@@ -21,10 +21,10 @@
#endif
-#include "w1.h"
-#include "w1_io.h"
-#include "w1_int.h"
-#include "w1_family.h"
+#include "../w1.h"
+#include "../w1_io.h"
+#include "../w1_int.h"
+#include "../w1_family.h"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Ben Gardner <bgardner@wabtec.com>");
diff --git a/drivers/w1/w1_smem.c b/drivers/w1/slaves/w1_smem.c
index e3209d0aca9..c6d3be54f94 100644
--- a/drivers/w1/w1_smem.c
+++ b/drivers/w1/slaves/w1_smem.c
@@ -27,10 +27,10 @@
#include <linux/device.h>
#include <linux/types.h>
-#include "w1.h"
-#include "w1_io.h"
-#include "w1_int.h"
-#include "w1_family.h"
+#include "../w1.h"
+#include "../w1_io.h"
+#include "../w1_int.h"
+#include "../w1_family.h"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
@@ -51,7 +51,7 @@ static int __init w1_smem_init(void)
err = w1_register_family(&w1_smem_family_01);
if (err)
return err;
-
+
err = w1_register_family(&w1_smem_family_81);
if (err) {
w1_unregister_family(&w1_smem_family_01);
diff --git a/drivers/w1/w1_therm.c b/drivers/w1/slaves/w1_therm.c
index 4577df3cfc4..536d16d78de 100644
--- a/drivers/w1/w1_therm.c
+++ b/drivers/w1/slaves/w1_therm.c
@@ -28,10 +28,10 @@
#include <linux/types.h>
#include <linux/delay.h>
-#include "w1.h"
-#include "w1_io.h"
-#include "w1_int.h"
-#include "w1_family.h"
+#include "../w1.h"
+#include "../w1_io.h"
+#include "../w1_int.h"
+#include "../w1_family.h"
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
@@ -123,12 +123,12 @@ static inline int w1_DS18S20_convert_temp(u8 rom[9])
if (!rom[7])
return 0;
-
+
if (rom[1] == 0)
t = ((s32)rom[0] >> 1)*1000;
else
t = 1000*(-1*(s32)(0x100-rom[0]) >> 1);
-
+
t -= 250;
h = 1000*((s32)rom[7] - (s32)rom[6]);
h /= (s32)rom[7];
@@ -231,7 +231,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
for (i = 0; i < 9; ++i)
count += sprintf(buf + count, "%02x ", sl->rom[i]);
-
+
count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid));
out:
up(&dev->mutex);
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index 024206c4a0e..a698b517e86 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -30,6 +30,7 @@
#include <linux/device.h>
#include <linux/slab.h>
#include <linux/sched.h>
+#include <linux/kthread.h>
#include <asm/atomic.h>
@@ -57,9 +58,7 @@ module_param_named(slave_ttl, w1_max_slave_ttl, int, 0);
DEFINE_SPINLOCK(w1_mlock);
LIST_HEAD(w1_masters);
-static pid_t control_thread;
-static int control_needs_exit;
-static DECLARE_COMPLETION(w1_control_complete);
+static struct task_struct *w1_control_thread;
static int w1_master_match(struct device *dev, struct device_driver *drv)
{
@@ -164,11 +163,12 @@ struct device w1_master_device = {
.release = &w1_master_release
};
-struct device_driver w1_slave_driver = {
+static struct device_driver w1_slave_driver = {
.name = "w1_slave_driver",
.bus = &w1_bus_type,
};
+#if 0
struct device w1_slave_device = {
.parent = NULL,
.bus = &w1_bus_type,
@@ -176,6 +176,7 @@ struct device w1_slave_device = {
.driver = &w1_slave_driver,
.release = &w1_slave_release
};
+#endif /* 0 */
static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf)
{
@@ -355,7 +356,7 @@ int w1_create_master_attributes(struct w1_master *master)
return sysfs_create_group(&master->dev.kobj, &w1_master_defattr_group);
}
-void w1_destroy_master_attributes(struct w1_master *master)
+static void w1_destroy_master_attributes(struct w1_master *master)
{
sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group);
}
@@ -386,11 +387,14 @@ static int w1_uevent(struct device *dev, char **envp, int num_envp, char *buffer
if (dev->driver != &w1_slave_driver || !sl)
return 0;
- err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_FID=%02X", sl->reg_num.family);
+ err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size,
+ &cur_len, "W1_FID=%02X", sl->reg_num.family);
if (err)
return err;
- err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size, &cur_len, "W1_SLAVE_ID=%024LX", (u64)sl->reg_num.id);
+ err = add_uevent_var(envp, num_envp, &cur_index, buffer, buffer_size,
+ &cur_len, "W1_SLAVE_ID=%024LX",
+ (unsigned long long)sl->reg_num.id);
if (err)
return err;
@@ -552,7 +556,7 @@ static void w1_slave_detach(struct w1_slave *sl)
kfree(sl);
}
-static struct w1_master *w1_search_master(unsigned long data)
+static struct w1_master *w1_search_master(void *data)
{
struct w1_master *dev;
int found = 0;
@@ -583,7 +587,7 @@ void w1_reconnect_slaves(struct w1_family *f)
spin_unlock_bh(&w1_mlock);
}
-static void w1_slave_found(unsigned long data, u64 rn)
+static void w1_slave_found(void *data, u64 rn)
{
int slave_count;
struct w1_slave *sl;
@@ -595,8 +599,8 @@ static void w1_slave_found(unsigned long data, u64 rn)
dev = w1_search_master(data);
if (!dev) {
- printk(KERN_ERR "Failed to find w1 master device for data %08lx, it is impossible.\n",
- data);
+ printk(KERN_ERR "Failed to find w1 master device for data %p, "
+ "it is impossible.\n", data);
return;
}
@@ -712,22 +716,16 @@ static int w1_control(void *data)
{
struct w1_slave *sl, *sln;
struct w1_master *dev, *n;
- int err, have_to_wait = 0;
+ int have_to_wait = 0;
- daemonize("w1_control");
- allow_signal(SIGTERM);
-
- while (!control_needs_exit || have_to_wait) {
+ while (!kthread_should_stop() || have_to_wait) {
have_to_wait = 0;
try_to_freeze();
msleep_interruptible(w1_control_timeout * 1000);
- if (signal_pending(current))
- flush_signals(current);
-
list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) {
- if (!control_needs_exit && !dev->flags)
+ if (!kthread_should_stop() && !dev->flags)
continue;
/*
* Little race: we can create thread but not set the flag.
@@ -738,21 +736,12 @@ static int w1_control(void *data)
continue;
}
- if (control_needs_exit) {
+ if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
- err = kill_proc(dev->kpid, SIGTERM, 1);
- if (err)
- dev_err(&dev->dev,
- "Failed to send signal to w1 kernel thread %d.\n",
- dev->kpid);
- }
-
- if (test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
- wait_for_completion(&dev->dev_exited);
- spin_lock_bh(&w1_mlock);
+ spin_lock(&w1_mlock);
list_del(&dev->w1_master_entry);
- spin_unlock_bh(&w1_mlock);
+ spin_unlock(&w1_mlock);
down(&dev->mutex);
list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
@@ -784,7 +773,7 @@ static int w1_control(void *data)
}
}
- complete_and_exit(&w1_control_complete, 0);
+ return 0;
}
int w1_process(void *data)
@@ -792,17 +781,11 @@ int w1_process(void *data)
struct w1_master *dev = (struct w1_master *) data;
struct w1_slave *sl, *sln;
- daemonize("%s", dev->name);
- allow_signal(SIGTERM);
-
- while (!test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
+ while (!kthread_should_stop() && !test_bit(W1_MASTER_NEED_EXIT, &dev->flags)) {
try_to_freeze();
msleep_interruptible(w1_timeout * 1000);
- if (signal_pending(current))
- flush_signals(current);
-
- if (test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
+ if (kthread_should_stop() || test_bit(W1_MASTER_NEED_EXIT, &dev->flags))
break;
if (!dev->initialized)
@@ -835,7 +818,6 @@ int w1_process(void *data)
}
atomic_dec(&dev->refcnt);
- complete_and_exit(&dev->dev_exited, 0);
return 0;
}
@@ -868,11 +850,11 @@ static int w1_init(void)
goto err_out_master_unregister;
}
- control_thread = kernel_thread(&w1_control, NULL, 0);
- if (control_thread < 0) {
+ w1_control_thread = kthread_run(w1_control, NULL, "w1_control");
+ if (IS_ERR(w1_control_thread)) {
+ retval = PTR_ERR(w1_control_thread);
printk(KERN_ERR "Failed to create control thread. err=%d\n",
- control_thread);
- retval = control_thread;
+ retval);
goto err_out_slave_unregister;
}
@@ -898,8 +880,7 @@ static void w1_fini(void)
list_for_each_entry(dev, &w1_masters, w1_master_entry)
__w1_remove_master_device(dev);
- control_needs_exit = 1;
- wait_for_completion(&w1_control_complete);
+ kthread_stop(w1_control_thread);
driver_unregister(&w1_slave_driver);
driver_unregister(&w1_master_driver);
diff --git a/drivers/w1/w1.h b/drivers/w1/w1.h
index d8900780c3b..56980505e6c 100644
--- a/drivers/w1/w1.h
+++ b/drivers/w1/w1.h
@@ -80,7 +80,7 @@ struct w1_slave
struct completion released;
};
-typedef void (* w1_slave_found_callback)(unsigned long, u64);
+typedef void (* w1_slave_found_callback)(void *, u64);
/**
@@ -93,16 +93,16 @@ typedef void (* w1_slave_found_callback)(unsigned long, u64);
struct w1_bus_master
{
/** the first parameter in all the functions below */
- unsigned long data;
+ void *data;
/**
* Sample the line level
* @return the level read (0 or 1)
*/
- u8 (*read_bit)(unsigned long);
+ u8 (*read_bit)(void *);
/** Sets the line level */
- void (*write_bit)(unsigned long, u8);
+ void (*write_bit)(void *, u8);
/**
* touch_bit is the lowest-level function for devices that really
@@ -111,42 +111,42 @@ struct w1_bus_master
* touch_bit(1) = write-1 / read cycle
* @return the bit read (0 or 1)
*/
- u8 (*touch_bit)(unsigned long, u8);
+ u8 (*touch_bit)(void *, u8);
/**
* Reads a bytes. Same as 8 touch_bit(1) calls.
* @return the byte read
*/
- u8 (*read_byte)(unsigned long);
+ u8 (*read_byte)(void *);
/**
* Writes a byte. Same as 8 touch_bit(x) calls.
*/
- void (*write_byte)(unsigned long, u8);
+ void (*write_byte)(void *, u8);
/**
* Same as a series of read_byte() calls
* @return the number of bytes read
*/
- u8 (*read_block)(unsigned long, u8 *, int);
+ u8 (*read_block)(void *, u8 *, int);
/** Same as a series of write_byte() calls */
- void (*write_block)(unsigned long, const u8 *, int);
+ void (*write_block)(void *, const u8 *, int);
/**
* Combines two reads and a smart write for ROM searches
* @return bit0=Id bit1=comp_id bit2=dir_taken
*/
- u8 (*triplet)(unsigned long, u8);
+ u8 (*triplet)(void *, u8);
/**
* long write-0 with a read for the presence pulse detection
* @return -1=Error, 0=Device present, 1=No device present
*/
- u8 (*reset_bus)(unsigned long);
+ u8 (*reset_bus)(void *);
/** Really nice hardware can handles the ROM searches */
- void (*search)(unsigned long, w1_slave_found_callback);
+ void (*search)(void *, w1_slave_found_callback);
};
#define W1_MASTER_NEED_EXIT 0
@@ -172,12 +172,11 @@ struct w1_master
long flags;
- pid_t kpid;
+ struct task_struct *thread;
struct semaphore mutex;
struct device_driver *driver;
struct device dev;
- struct completion dev_exited;
struct w1_bus_master *bus_master;
@@ -203,6 +202,16 @@ static inline struct w1_master* dev_to_w1_master(struct device *dev)
return container_of(dev, struct w1_master, dev);
}
+extern int w1_max_slave_count;
+extern int w1_max_slave_ttl;
+extern spinlock_t w1_mlock;
+extern struct list_head w1_masters;
+extern struct device_driver w1_master_driver;
+extern struct device w1_master_device;
+
+int w1_process(void *data);
+void w1_reconnect_slaves(struct w1_family *f);
+
#endif /* __KERNEL__ */
#endif /* __W1_H */
diff --git a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
index 9e293e139a0..0e32c114f90 100644
--- a/drivers/w1/w1_family.c
+++ b/drivers/w1/w1_family.c
@@ -25,10 +25,10 @@
#include <linux/delay.h>
#include "w1_family.h"
+#include "w1.h"
DEFINE_SPINLOCK(w1_flock);
static LIST_HEAD(w1_families);
-extern void w1_reconnect_slaves(struct w1_family *f);
int w1_register_family(struct w1_family *newf)
{
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index c3f67eafc7e..68565aacec7 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -22,23 +22,15 @@
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/delay.h>
+#include <linux/kthread.h>
#include "w1.h"
#include "w1_log.h"
#include "w1_netlink.h"
+#include "w1_int.h"
static u32 w1_ids = 1;
-extern struct device_driver w1_master_driver;
-extern struct bus_type w1_bus_type;
-extern struct device w1_master_device;
-extern int w1_max_slave_count;
-extern int w1_max_slave_ttl;
-extern struct list_head w1_masters;
-extern spinlock_t w1_mlock;
-
-extern int w1_process(void *);
-
static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
struct device_driver *driver,
struct device *device)
@@ -65,7 +57,6 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
dev->max_slave_count = slave_count;
dev->slave_count = 0;
dev->attempts = 0;
- dev->kpid = -1;
dev->initialized = 0;
dev->id = id;
dev->slave_ttl = slave_ttl;
@@ -76,8 +67,6 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
INIT_LIST_HEAD(&dev->slist);
init_MUTEX(&dev->mutex);
- init_completion(&dev->dev_exited);
-
memcpy(&dev->dev, device, sizeof(struct device));
snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
"w1_bus_master%u", dev->id);
@@ -103,7 +92,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
return dev;
}
-void w1_free_dev(struct w1_master *dev)
+static void w1_free_dev(struct w1_master *dev)
{
device_unregister(&dev->dev);
}
@@ -125,12 +114,12 @@ int w1_add_master_device(struct w1_bus_master *master)
if (!dev)
return -ENOMEM;
- dev->kpid = kernel_thread(&w1_process, dev, 0);
- if (dev->kpid < 0) {
+ dev->thread = kthread_run(&w1_process, dev, "%s", dev->name);
+ if (IS_ERR(dev->thread)) {
+ retval = PTR_ERR(dev->thread);
dev_err(&dev->dev,
"Failed to create new kernel thread. err=%d\n",
- dev->kpid);
- retval = dev->kpid;
+ retval);
goto err_out_free_dev;
}
@@ -147,20 +136,14 @@ int w1_add_master_device(struct w1_bus_master *master)
spin_unlock(&w1_mlock);
msg.id.mst.id = dev->id;
- msg.id.mst.pid = dev->kpid;
+ msg.id.mst.pid = dev->thread->pid;
msg.type = W1_MASTER_ADD;
w1_netlink_send(dev, &msg);
return 0;
err_out_kill_thread:
- set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
- if (kill_proc(dev->kpid, SIGTERM, 1))
- dev_err(&dev->dev,
- "Failed to send signal to w1 kernel thread %d.\n",
- dev->kpid);
- wait_for_completion(&dev->dev_exited);
-
+ kthread_stop(dev->thread);
err_out_free_dev:
w1_free_dev(dev);
@@ -169,18 +152,14 @@ err_out_free_dev:
void __w1_remove_master_device(struct w1_master *dev)
{
- int err;
struct w1_netlink_msg msg;
+ pid_t pid = dev->thread->pid;
set_bit(W1_MASTER_NEED_EXIT, &dev->flags);
- err = kill_proc(dev->kpid, SIGTERM, 1);
- if (err)
- dev_err(&dev->dev,
- "%s: Failed to send signal to w1 kernel thread %d.\n",
- __func__, dev->kpid);
+ kthread_stop(dev->thread);
while (atomic_read(&dev->refcnt)) {
- dev_dbg(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n",
+ dev_info(&dev->dev, "Waiting for %s to become free: refcnt=%d.\n",
dev->name, atomic_read(&dev->refcnt));
if (msleep_interruptible(1000))
@@ -188,7 +167,7 @@ void __w1_remove_master_device(struct w1_master *dev)
}
msg.id.mst.id = dev->id;
- msg.id.mst.pid = dev->kpid;
+ msg.id.mst.pid = pid;
msg.type = W1_MASTER_REMOVE;
w1_netlink_send(dev, &msg);
@@ -217,5 +196,3 @@ void w1_remove_master_device(struct w1_bus_master *bm)
EXPORT_SYMBOL(w1_add_master_device);
EXPORT_SYMBOL(w1_remove_master_device);
-
-MODULE_ALIAS_NET_PF_PROTO(PF_NETLINK, NETLINK_W1);
diff --git a/drivers/w1/w1_io.c b/drivers/w1/w1_io.c
index e2a043354dd..f7f7e8bec30 100644
--- a/drivers/w1/w1_io.c
+++ b/drivers/w1/w1_io.c
@@ -28,7 +28,7 @@
#include "w1_log.h"
#include "w1_io.h"
-int w1_delay_parm = 1;
+static int w1_delay_parm = 1;
module_param_named(delay_coef, w1_delay_parm, int, 0);
static u8 w1_crc8_table[] = {
diff --git a/drivers/zorro/zorro-driver.c b/drivers/zorro/zorro-driver.c
index fcbee748c59..067c07be928 100644
--- a/drivers/zorro/zorro-driver.c
+++ b/drivers/zorro/zorro-driver.c
@@ -65,22 +65,17 @@ static int zorro_device_probe(struct device *dev)
* @drv: the driver structure to register
*
* Adds the driver structure to the list of registered drivers
- * Returns the number of Zorro devices which were claimed by the driver
- * during registration. The driver remains registered even if the
- * return value is zero.
+ * Returns zero or a negative error value.
*/
int zorro_register_driver(struct zorro_driver *drv)
{
- int count = 0;
-
/* initialize common driver fields */
drv->driver.name = drv->name;
drv->driver.bus = &zorro_bus_type;
/* register with core */
- count = driver_register(&drv->driver);
- return count ? count : 1;
+ return driver_register(&drv->driver);
}
diff --git a/fs/9p/9p.h b/fs/9p/9p.h
index 0cd374d9471..94e2f92ab2e 100644
--- a/fs/9p/9p.h
+++ b/fs/9p/9p.h
@@ -8,9 +8,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -235,6 +234,7 @@ struct Tcreate {
struct v9fs_str name;
u32 perm;
u8 mode;
+ struct v9fs_str extension;
};
struct Rcreate {
@@ -348,8 +348,6 @@ int v9fs_t_attach(struct v9fs_session_info *v9ses, char *uname, char *aname,
int v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid);
-int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag);
-
int v9fs_t_stat(struct v9fs_session_info *v9ses, u32 fid,
struct v9fs_fcall **rcall);
@@ -366,7 +364,7 @@ int v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid,
struct v9fs_fcall **rcall);
int v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name,
- u32 perm, u8 mode, struct v9fs_fcall **rcall);
+ u32 perm, u8 mode, char *extension, struct v9fs_fcall **rcall);
int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid,
u64 offset, u32 count, struct v9fs_fcall **rcall);
@@ -374,3 +372,4 @@ int v9fs_t_read(struct v9fs_session_info *v9ses, u32 fid,
int v9fs_t_write(struct v9fs_session_info *v9ses, u32 fid, u64 offset,
u32 count, const char __user * data,
struct v9fs_fcall **rcall);
+int v9fs_printfcall(char *, int, struct v9fs_fcall *, int);
diff --git a/fs/9p/Makefile b/fs/9p/Makefile
index 2f4ce43f7b6..87897f84dfb 100644
--- a/fs/9p/Makefile
+++ b/fs/9p/Makefile
@@ -1,10 +1,9 @@
-obj-$(CONFIG_9P_FS) := 9p2000.o
+obj-$(CONFIG_9P_FS) := 9p.o
-9p2000-objs := \
+9p-objs := \
trans_fd.o \
- trans_sock.o \
mux.o \
- 9p.o \
+ fcall.o \
conv.o \
vfs_super.o \
vfs_inode.o \
@@ -14,5 +13,6 @@ obj-$(CONFIG_9P_FS) := 9p2000.o
vfs_dentry.o \
error.o \
v9fs.o \
- fid.o
+ fid.o \
+ fcprint.o
diff --git a/fs/9p/conv.c b/fs/9p/conv.c
index bf1f1006796..a767e05b60b 100644
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -8,9 +8,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -536,6 +535,7 @@ struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version)
return fc;
}
+#if 0
struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
{
int size;
@@ -559,6 +559,7 @@ struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname)
error:
return fc;
}
+#endif /* 0 */
struct v9fs_fcall *
v9fs_create_tattach(u32 fid, u32 afid, char *uname, char *aname)
@@ -664,7 +665,8 @@ struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode)
return fc;
}
-struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
+struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
+ char *extension, int extended)
{
int size;
struct v9fs_fcall *fc;
@@ -672,6 +674,9 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
struct cbuf *bufp = &buffer;
size = 4 + 2 + strlen(name) + 4 + 1; /* fid[4] name[s] perm[4] mode[1] */
+ if (extended && extension!=NULL)
+ size += 2 + strlen(extension); /* extension[s] */
+
fc = v9fs_create_common(bufp, size, TCREATE);
if (IS_ERR(fc))
goto error;
@@ -680,6 +685,8 @@ struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode)
v9fs_put_str(bufp, name, &fc->params.tcreate.name);
v9fs_put_int32(bufp, perm, &fc->params.tcreate.perm);
v9fs_put_int8(bufp, mode, &fc->params.tcreate.mode);
+ if (extended)
+ v9fs_put_str(bufp, extension, &fc->params.tcreate.extension);
if (buf_check_overflow(bufp)) {
kfree(fc);
diff --git a/fs/9p/conv.h b/fs/9p/conv.h
index 26a736e4a2e..dd5b6b1b610 100644
--- a/fs/9p/conv.h
+++ b/fs/9p/conv.h
@@ -8,9 +8,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -33,14 +32,14 @@ int v9fs_deserialize_fcall(void *buf, u32 buflen, struct v9fs_fcall *rcall,
void v9fs_set_tag(struct v9fs_fcall *fc, u16 tag);
struct v9fs_fcall *v9fs_create_tversion(u32 msize, char *version);
-struct v9fs_fcall *v9fs_create_tauth(u32 afid, char *uname, char *aname);
struct v9fs_fcall *v9fs_create_tattach(u32 fid, u32 afid, char *uname,
char *aname);
struct v9fs_fcall *v9fs_create_tflush(u16 oldtag);
struct v9fs_fcall *v9fs_create_twalk(u32 fid, u32 newfid, u16 nwname,
char **wnames);
struct v9fs_fcall *v9fs_create_topen(u32 fid, u8 mode);
-struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode);
+struct v9fs_fcall *v9fs_create_tcreate(u32 fid, char *name, u32 perm, u8 mode,
+ char *extension, int extended);
struct v9fs_fcall *v9fs_create_tread(u32 fid, u64 offset, u32 count);
struct v9fs_fcall *v9fs_create_twrite(u32 fid, u64 offset, u32 count,
const char __user *data);
diff --git a/fs/9p/debug.h b/fs/9p/debug.h
index fe551032788..4228c0bb3c3 100644
--- a/fs/9p/debug.h
+++ b/fs/9p/debug.h
@@ -5,9 +5,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -30,6 +29,7 @@
#define DEBUG_MUX (1<<5)
#define DEBUG_TRANS (1<<6)
#define DEBUG_SLABS (1<<7)
+#define DEBUG_FCALL (1<<8)
#define DEBUG_DUMP_PKT 0
diff --git a/fs/9p/error.c b/fs/9p/error.c
index e4b6f8f38b6..981fe8ecd78 100644
--- a/fs/9p/error.c
+++ b/fs/9p/error.c
@@ -11,9 +11,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/error.h b/fs/9p/error.h
index a9794e85fe5..5f3ca522b31 100644
--- a/fs/9p/error.h
+++ b/fs/9p/error.h
@@ -12,9 +12,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/9p.c b/fs/9p/fcall.c
index f86a28d1d6a..71742ba150c 100644
--- a/fs/9p/9p.c
+++ b/fs/9p/fcall.c
@@ -1,5 +1,5 @@
/*
- * linux/fs/9p/9p.c
+ * linux/fs/9p/fcall.c
*
* This file contains functions to perform synchronous 9P calls
*
@@ -8,9 +8,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -148,13 +147,13 @@ v9fs_t_clunk(struct v9fs_session_info *v9ses, u32 fid)
return ret;
}
+#if 0
/**
* v9fs_v9fs_t_flush - flush a pending transaction
* @v9ses: 9P2000 session information
- * @tag: tid to release
+ * @tag: tag to release
*
*/
-
int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag)
{
int ret;
@@ -171,6 +170,7 @@ int v9fs_t_flush(struct v9fs_session_info *v9ses, u16 oldtag)
return ret;
}
+#endif
/**
* v9fs_t_stat - read a file's meta-data
@@ -332,8 +332,8 @@ v9fs_t_remove(struct v9fs_session_info *v9ses, u32 fid,
*/
int
-v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name,
- u32 perm, u8 mode, struct v9fs_fcall **rcp)
+v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name, u32 perm,
+ u8 mode, char *extension, struct v9fs_fcall **rcp)
{
int ret;
struct v9fs_fcall *tc;
@@ -341,7 +341,9 @@ v9fs_t_create(struct v9fs_session_info *v9ses, u32 fid, char *name,
dprintk(DEBUG_9P, "fid %d name '%s' perm %x mode %d\n",
fid, name, perm, mode);
- tc = v9fs_create_tcreate(fid, name, perm, mode);
+ tc = v9fs_create_tcreate(fid, name, perm, mode, extension,
+ v9ses->extended);
+
if (!IS_ERR(tc)) {
ret = v9fs_mux_rpc(v9ses->mux, tc, rcp);
kfree(tc);
diff --git a/fs/9p/fcprint.c b/fs/9p/fcprint.c
new file mode 100644
index 00000000000..583e827baeb
--- /dev/null
+++ b/fs/9p/fcprint.c
@@ -0,0 +1,346 @@
+/*
+ * linux/fs/9p/fcprint.c
+ *
+ * Print 9P call.
+ *
+ * Copyright (C) 2005 by Latchesar Ionkov <lucho@ionkov.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to:
+ * Free Software Foundation
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02111-1301 USA
+ *
+ */
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/errno.h>
+#include <linux/fs.h>
+#include <linux/idr.h>
+
+#include "debug.h"
+#include "v9fs.h"
+#include "9p.h"
+#include "mux.h"
+
+static int
+v9fs_printqid(char *buf, int buflen, struct v9fs_qid *q)
+{
+ int n;
+ char b[10];
+
+ n = 0;
+ if (q->type & V9FS_QTDIR)
+ b[n++] = 'd';
+ if (q->type & V9FS_QTAPPEND)
+ b[n++] = 'a';
+ if (q->type & V9FS_QTAUTH)
+ b[n++] = 'A';
+ if (q->type & V9FS_QTEXCL)
+ b[n++] = 'l';
+ if (q->type & V9FS_QTTMP)
+ b[n++] = 't';
+ if (q->type & V9FS_QTSYMLINK)
+ b[n++] = 'L';
+ b[n] = '\0';
+
+ return scnprintf(buf, buflen, "(%.16llx %x %s)", (long long int) q->path,
+ q->version, b);
+}
+
+static int
+v9fs_printperm(char *buf, int buflen, int perm)
+{
+ int n;
+ char b[15];
+
+ n = 0;
+ if (perm & V9FS_DMDIR)
+ b[n++] = 'd';
+ if (perm & V9FS_DMAPPEND)
+ b[n++] = 'a';
+ if (perm & V9FS_DMAUTH)
+ b[n++] = 'A';
+ if (perm & V9FS_DMEXCL)
+ b[n++] = 'l';
+ if (perm & V9FS_DMTMP)
+ b[n++] = 't';
+ if (perm & V9FS_DMDEVICE)
+ b[n++] = 'D';
+ if (perm & V9FS_DMSOCKET)
+ b[n++] = 'S';
+ if (perm & V9FS_DMNAMEDPIPE)
+ b[n++] = 'P';
+ if (perm & V9FS_DMSYMLINK)
+ b[n++] = 'L';
+ b[n] = '\0';
+
+ return scnprintf(buf, buflen, "%s%03o", b, perm&077);
+}
+
+static int
+v9fs_printstat(char *buf, int buflen, struct v9fs_stat *st, int extended)
+{
+ int n;
+
+ n = scnprintf(buf, buflen, "'%.*s' '%.*s'", st->name.len,
+ st->name.str, st->uid.len, st->uid.str);
+ if (extended)
+ n += scnprintf(buf+n, buflen-n, "(%d)", st->n_uid);
+
+ n += scnprintf(buf+n, buflen-n, " '%.*s'", st->gid.len, st->gid.str);
+ if (extended)
+ n += scnprintf(buf+n, buflen-n, "(%d)", st->n_gid);
+
+ n += scnprintf(buf+n, buflen-n, " '%.*s'", st->muid.len, st->muid.str);
+ if (extended)
+ n += scnprintf(buf+n, buflen-n, "(%d)", st->n_muid);
+
+ n += scnprintf(buf+n, buflen-n, " q ");
+ n += v9fs_printqid(buf+n, buflen-n, &st->qid);
+ n += scnprintf(buf+n, buflen-n, " m ");
+ n += v9fs_printperm(buf+n, buflen-n, st->mode);
+ n += scnprintf(buf+n, buflen-n, " at %d mt %d l %lld",
+ st->atime, st->mtime, (long long int) st->length);
+
+ if (extended)
+ n += scnprintf(buf+n, buflen-n, " ext '%.*s'",
+ st->extension.len, st->extension.str);
+
+ return n;
+}
+
+static int
+v9fs_dumpdata(char *buf, int buflen, u8 *data, int datalen)
+{
+ int i, n;
+
+ i = n = 0;
+ while (i < datalen) {
+ n += scnprintf(buf + n, buflen - n, "%02x", data[i]);
+ if (i%4 == 3)
+ n += scnprintf(buf + n, buflen - n, " ");
+ if (i%32 == 31)
+ n += scnprintf(buf + n, buflen - n, "\n");
+
+ i++;
+ }
+ n += scnprintf(buf + n, buflen - n, "\n");
+
+ return n;
+}
+
+static int
+v9fs_printdata(char *buf, int buflen, u8 *data, int datalen)
+{
+ return v9fs_dumpdata(buf, buflen, data, datalen<16?datalen:16);
+}
+
+int
+v9fs_printfcall(char *buf, int buflen, struct v9fs_fcall *fc, int extended)
+{
+ int i, ret, type, tag;
+
+ if (!fc)
+ return scnprintf(buf, buflen, "<NULL>");
+
+ type = fc->id;
+ tag = fc->tag;
+
+ ret = 0;
+ switch (type) {
+ case TVERSION:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Tversion tag %u msize %u version '%.*s'", tag,
+ fc->params.tversion.msize, fc->params.tversion.version.len,
+ fc->params.tversion.version.str);
+ break;
+
+ case RVERSION:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Rversion tag %u msize %u version '%.*s'", tag,
+ fc->params.rversion.msize, fc->params.rversion.version.len,
+ fc->params.rversion.version.str);
+ break;
+
+ case TAUTH:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Tauth tag %u afid %d uname '%.*s' aname '%.*s'", tag,
+ fc->params.tauth.afid, fc->params.tauth.uname.len,
+ fc->params.tauth.uname.str, fc->params.tauth.aname.len,
+ fc->params.tauth.aname.str);
+ break;
+
+ case RAUTH:
+ ret += scnprintf(buf+ret, buflen-ret, "Rauth tag %u qid ", tag);
+ v9fs_printqid(buf+ret, buflen-ret, &fc->params.rauth.qid);
+ break;
+
+ case TATTACH:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Tattach tag %u fid %d afid %d uname '%.*s' aname '%.*s'",
+ tag, fc->params.tattach.fid, fc->params.tattach.afid,
+ fc->params.tattach.uname.len, fc->params.tattach.uname.str,
+ fc->params.tattach.aname.len, fc->params.tattach.aname.str);
+ break;
+
+ case RATTACH:
+ ret += scnprintf(buf+ret, buflen-ret, "Rattach tag %u qid ", tag);
+ v9fs_printqid(buf+ret, buflen-ret, &fc->params.rattach.qid);
+ break;
+
+ case RERROR:
+ ret += scnprintf(buf+ret, buflen-ret, "Rerror tag %u ename '%.*s'",
+ tag, fc->params.rerror.error.len,
+ fc->params.rerror.error.str);
+ if (extended)
+ ret += scnprintf(buf+ret, buflen-ret, " ecode %d\n",
+ fc->params.rerror.errno);
+ break;
+
+ case TFLUSH:
+ ret += scnprintf(buf+ret, buflen-ret, "Tflush tag %u oldtag %u",
+ tag, fc->params.tflush.oldtag);
+ break;
+
+ case RFLUSH:
+ ret += scnprintf(buf+ret, buflen-ret, "Rflush tag %u", tag);
+ break;
+
+ case TWALK:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Twalk tag %u fid %d newfid %d nwname %d", tag,
+ fc->params.twalk.fid, fc->params.twalk.newfid,
+ fc->params.twalk.nwname);
+ for(i = 0; i < fc->params.twalk.nwname; i++)
+ ret += scnprintf(buf+ret, buflen-ret," '%.*s'",
+ fc->params.twalk.wnames[i].len,
+ fc->params.twalk.wnames[i].str);
+ break;
+
+ case RWALK:
+ ret += scnprintf(buf+ret, buflen-ret, "Rwalk tag %u nwqid %d",
+ tag, fc->params.rwalk.nwqid);
+ for(i = 0; i < fc->params.rwalk.nwqid; i++)
+ ret += v9fs_printqid(buf+ret, buflen-ret,
+ &fc->params.rwalk.wqids[i]);
+ break;
+
+ case TOPEN:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Topen tag %u fid %d mode %d", tag,
+ fc->params.topen.fid, fc->params.topen.mode);
+ break;
+
+ case ROPEN:
+ ret += scnprintf(buf+ret, buflen-ret, "Ropen tag %u", tag);
+ ret += v9fs_printqid(buf+ret, buflen-ret, &fc->params.ropen.qid);
+ ret += scnprintf(buf+ret, buflen-ret," iounit %d",
+ fc->params.ropen.iounit);
+ break;
+
+ case TCREATE:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Tcreate tag %u fid %d name '%.*s' perm ", tag,
+ fc->params.tcreate.fid, fc->params.tcreate.name.len,
+ fc->params.tcreate.name.str);
+
+ ret += v9fs_printperm(buf+ret, buflen-ret, fc->params.tcreate.perm);
+ ret += scnprintf(buf+ret, buflen-ret, " mode %d",
+ fc->params.tcreate.mode);
+ break;
+
+ case RCREATE:
+ ret += scnprintf(buf+ret, buflen-ret, "Rcreate tag %u", tag);
+ ret += v9fs_printqid(buf+ret, buflen-ret, &fc->params.rcreate.qid);
+ ret += scnprintf(buf+ret, buflen-ret, " iounit %d",
+ fc->params.rcreate.iounit);
+ break;
+
+ case TREAD:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Tread tag %u fid %d offset %lld count %u", tag,
+ fc->params.tread.fid,
+ (long long int) fc->params.tread.offset,
+ fc->params.tread.count);
+ break;
+
+ case RREAD:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Rread tag %u count %u data ", tag,
+ fc->params.rread.count);
+ ret += v9fs_printdata(buf+ret, buflen-ret, fc->params.rread.data,
+ fc->params.rread.count);
+ break;
+
+ case TWRITE:
+ ret += scnprintf(buf+ret, buflen-ret,
+ "Twrite tag %u fid %d offset %lld count %u data ",
+ tag, fc->params.twrite.fid,
+ (long long int) fc->params.twrite.offset,
+ fc->params.twrite.count);
+ ret += v9fs_printdata(buf+ret, buflen-ret, fc->params.twrite.data,
+ fc->params.twrite.count);
+ break;
+
+ case RWRITE:
+ ret += scnprintf(buf+ret, buflen-ret, "Rwrite tag %u count %u",
+ tag, fc->params.rwrite.count);
+ break;
+
+ case TCLUNK:
+ ret += scnprintf(buf+ret, buflen-ret, "Tclunk tag %u fid %d",
+ tag, fc->params.tclunk.fid);
+ break;
+
+ case RCLUNK:
+ ret += scnprintf(buf+ret, buflen-ret, "Rclunk tag %u", tag);
+ break;
+
+ case TREMOVE:
+ ret += scnprintf(buf+ret, buflen-ret, "Tremove tag %u fid %d",
+ tag, fc->params.tremove.fid);
+ break;
+
+ case RREMOVE:
+ ret += scnprintf(buf+ret, buflen-ret, "Rremove tag %u", tag);
+ break;
+
+ case TSTAT:
+ ret += scnprintf(buf+ret, buflen-ret, "Tstat tag %u fid %d",
+ tag, fc->params.tstat.fid);
+ break;
+
+ case RSTAT:
+ ret += scnprintf(buf+ret, buflen-ret, "Rstat tag %u ", tag);
+ ret += v9fs_printstat(buf+ret, buflen-ret, &fc->params.rstat.stat,
+ extended);
+ break;
+
+ case TWSTAT:
+ ret += scnprintf(buf+ret, buflen-ret, "Twstat tag %u fid %d ",
+ tag, fc->params.twstat.fid);
+ ret += v9fs_printstat(buf+ret, buflen-ret, &fc->params.twstat.stat,
+ extended);
+ break;
+
+ case RWSTAT:
+ ret += scnprintf(buf+ret, buflen-ret, "Rwstat tag %u", tag);
+ break;
+
+ default:
+ ret += scnprintf(buf+ret, buflen-ret, "unknown type %d", type);
+ break;
+ }
+
+ return ret;
+}
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index c4d13bf904d..b7608af07ce 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -4,9 +4,8 @@
* Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/fid.h b/fs/9p/fid.h
index 1fc2dd08d75..aa974d6875c 100644
--- a/fs/9p/fid.h
+++ b/fs/9p/fid.h
@@ -4,9 +4,8 @@
* Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/mux.c b/fs/9p/mux.c
index ea1134eb47c..3e5b124a721 100644
--- a/fs/9p/mux.c
+++ b/fs/9p/mux.c
@@ -7,9 +7,8 @@
* Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,6 +30,7 @@
#include <linux/poll.h>
#include <linux/kthread.h>
#include <linux/idr.h>
+#include <linux/mutex.h>
#include "debug.h"
#include "v9fs.h"
@@ -69,7 +69,7 @@ struct v9fs_mux_data {
int msize;
unsigned char *extended;
struct v9fs_transport *trans;
- struct v9fs_idpool tidpool;
+ struct v9fs_idpool tagpool;
int err;
wait_queue_head_t equeue;
struct list_head req_list;
@@ -110,7 +110,7 @@ static void v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
static u16 v9fs_mux_get_tag(struct v9fs_mux_data *);
static void v9fs_mux_put_tag(struct v9fs_mux_data *, u16);
-static DECLARE_MUTEX(v9fs_mux_task_lock);
+static DEFINE_MUTEX(v9fs_mux_task_lock);
static struct workqueue_struct *v9fs_mux_wq;
static int v9fs_mux_num;
@@ -142,7 +142,7 @@ void v9fs_mux_global_exit(void)
*
* The current implementation returns sqrt of the number of mounts.
*/
-inline int v9fs_mux_calc_poll_procs(int muxnum)
+static int v9fs_mux_calc_poll_procs(int muxnum)
{
int n;
@@ -166,7 +166,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
dprintk(DEBUG_MUX, "mux %p muxnum %d procnum %d\n", m, v9fs_mux_num,
v9fs_mux_poll_task_num);
- up(&v9fs_mux_task_lock);
+ mutex_lock(&v9fs_mux_task_lock);
n = v9fs_mux_calc_poll_procs(v9fs_mux_num + 1);
if (n > v9fs_mux_poll_task_num) {
@@ -225,7 +225,7 @@ static int v9fs_mux_poll_start(struct v9fs_mux_data *m)
}
v9fs_mux_num++;
- down(&v9fs_mux_task_lock);
+ mutex_unlock(&v9fs_mux_task_lock);
return 0;
}
@@ -235,7 +235,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
int i;
struct v9fs_mux_poll_task *vpt;
- up(&v9fs_mux_task_lock);
+ mutex_lock(&v9fs_mux_task_lock);
vpt = m->poll_task;
list_del(&m->mux_list);
for(i = 0; i < ARRAY_SIZE(m->poll_waddr); i++) {
@@ -252,7 +252,7 @@ static void v9fs_mux_poll_stop(struct v9fs_mux_data *m)
v9fs_mux_poll_task_num--;
}
v9fs_mux_num--;
- down(&v9fs_mux_task_lock);
+ mutex_unlock(&v9fs_mux_task_lock);
}
/**
@@ -279,8 +279,8 @@ struct v9fs_mux_data *v9fs_mux_init(struct v9fs_transport *trans, int msize,
m->msize = msize;
m->extended = extended;
m->trans = trans;
- idr_init(&m->tidpool.pool);
- init_MUTEX(&m->tidpool.lock);
+ idr_init(&m->tagpool.pool);
+ init_MUTEX(&m->tagpool.lock);
m->err = 0;
init_waitqueue_head(&m->equeue);
INIT_LIST_HEAD(&m->req_list);
@@ -383,7 +383,7 @@ v9fs_pollwait(struct file *filp, wait_queue_head_t * wait_address,
/**
* v9fs_poll_mux - polls a mux and schedules read or write works if necessary
*/
-static inline void v9fs_poll_mux(struct v9fs_mux_data *m)
+static void v9fs_poll_mux(struct v9fs_mux_data *m)
{
int n;
@@ -634,6 +634,14 @@ static void v9fs_read_work(void *a)
goto error;
}
+ if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
+ char buf[150];
+
+ v9fs_printfcall(buf, sizeof(buf), m->rcall,
+ *m->extended);
+ printk(KERN_NOTICE ">>> %p %s\n", m, buf);
+ }
+
rcall = m->rcall;
rbuf = m->rbuf;
if (m->rpos > n) {
@@ -739,6 +747,13 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
v9fs_set_tag(tc, n);
+ if ((v9fs_debug_level&DEBUG_FCALL) == DEBUG_FCALL) {
+ char buf[150];
+
+ v9fs_printfcall(buf, sizeof(buf), tc, *m->extended);
+ printk(KERN_NOTICE "<<< %p %s\n", m, buf);
+ }
+
req->tag = n;
req->tcall = tc;
req->rcall = NULL;
@@ -761,9 +776,8 @@ static struct v9fs_req *v9fs_send_request(struct v9fs_mux_data *m,
return req;
}
-static inline void
-v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc, struct v9fs_fcall *rc,
- int err)
+static void v9fs_mux_flush_cb(void *a, struct v9fs_fcall *tc,
+ struct v9fs_fcall *rc, int err)
{
v9fs_mux_req_callback cb;
int tag;
@@ -901,6 +915,7 @@ v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
return err;
}
+#if 0
/**
* v9fs_mux_rpcnb - sends 9P request without waiting for response.
* @m: mux data
@@ -924,6 +939,7 @@ int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
dprintk(DEBUG_MUX, "mux %p tc %p tag %d\n", m, tc, req->tag);
return 0;
}
+#endif /* 0 */
/**
* v9fs_mux_cancel - cancel all pending requests with error
@@ -963,7 +979,7 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
{
int tag;
- tag = v9fs_get_idpool(&m->tidpool);
+ tag = v9fs_get_idpool(&m->tagpool);
if (tag < 0)
return V9FS_NOTAG;
else
@@ -972,6 +988,6 @@ static u16 v9fs_mux_get_tag(struct v9fs_mux_data *m)
static void v9fs_mux_put_tag(struct v9fs_mux_data *m, u16 tag)
{
- if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tidpool))
- v9fs_put_idpool(tag, &m->tidpool);
+ if (tag != V9FS_NOTAG && v9fs_check_idpool(tag, &m->tagpool))
+ v9fs_put_idpool(tag, &m->tagpool);
}
diff --git a/fs/9p/mux.h b/fs/9p/mux.h
index 9473b84f24b..e90bfd32ea4 100644
--- a/fs/9p/mux.h
+++ b/fs/9p/mux.h
@@ -7,9 +7,8 @@
* Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -50,8 +49,6 @@ void v9fs_mux_destroy(struct v9fs_mux_data *);
int v9fs_mux_send(struct v9fs_mux_data *m, struct v9fs_fcall *tc);
struct v9fs_fcall *v9fs_mux_recv(struct v9fs_mux_data *m);
int v9fs_mux_rpc(struct v9fs_mux_data *m, struct v9fs_fcall *tc, struct v9fs_fcall **rc);
-int v9fs_mux_rpcnb(struct v9fs_mux_data *m, struct v9fs_fcall *tc,
- v9fs_mux_req_callback cb, void *a);
void v9fs_mux_flush(struct v9fs_mux_data *m, int sendflush);
void v9fs_mux_cancel(struct v9fs_mux_data *m, int err);
diff --git a/fs/9p/trans_fd.c b/fs/9p/trans_fd.c
index 5b2ce21b10f..94e0a7fd9fc 100644
--- a/fs/9p/trans_fd.c
+++ b/fs/9p/trans_fd.c
@@ -1,15 +1,16 @@
/*
* linux/fs/9p/trans_fd.c
*
- * File Descriptor Transport Layer
+ * Fd transport layer. Includes deprecated socket layer.
*
- * Copyright (C) 2005 by Latchesar Ionkov <lucho@ionkov.net>
- * Copyright (C) 2005 by Eric Van Hensbergen <ericvh@gmail.com>
+ * Copyright (C) 2006 by Russ Cox <rsc@swtch.com>
+ * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
+ * Copyright (C) 2004-2005 by Eric Van Hensbergen <ericvh@gmail.com>
+ * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,6 +26,7 @@
*/
#include <linux/config.h>
+#include <linux/in.h>
#include <linux/module.h>
#include <linux/net.h>
#include <linux/ipv6.h>
@@ -40,89 +42,119 @@
#include "v9fs.h"
#include "transport.h"
+#define V9FS_PORT 564
+
struct v9fs_trans_fd {
- struct file *in_file;
- struct file *out_file;
+ struct file *rd;
+ struct file *wr;
};
/**
- * v9fs_fd_recv - receive from a socket
+ * v9fs_fd_read- read from a fd
* @v9ses: session information
* @v: buffer to receive data into
* @len: size of receive buffer
*
*/
-
-static int v9fs_fd_recv(struct v9fs_transport *trans, void *v, int len)
+static int v9fs_fd_read(struct v9fs_transport *trans, void *v, int len)
{
- struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
+ int ret;
+ struct v9fs_trans_fd *ts;
- if (!trans || trans->status != Connected || !ts)
- return -EIO;
+ if (!trans || trans->status == Disconnected || !(ts = trans->priv))
+ return -EREMOTEIO;
- return kernel_read(ts->in_file, ts->in_file->f_pos, v, len);
+ if (!(ts->rd->f_flags & O_NONBLOCK))
+ dprintk(DEBUG_ERROR, "blocking read ...\n");
+
+ ret = kernel_read(ts->rd, ts->rd->f_pos, v, len);
+ if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
+ trans->status = Disconnected;
+ return ret;
}
/**
- * v9fs_fd_send - send to a socket
+ * v9fs_fd_write - write to a socket
* @v9ses: session information
* @v: buffer to send data from
* @len: size of send buffer
*
*/
-
-static int v9fs_fd_send(struct v9fs_transport *trans, void *v, int len)
+static int v9fs_fd_write(struct v9fs_transport *trans, void *v, int len)
{
- struct v9fs_trans_fd *ts = trans ? trans->priv : NULL;
- mm_segment_t oldfs = get_fs();
- int ret = 0;
+ int ret;
+ mm_segment_t oldfs;
+ struct v9fs_trans_fd *ts;
- if (!trans || trans->status != Connected || !ts)
- return -EIO;
+ if (!trans || trans->status == Disconnected || !(ts = trans->priv))
+ return -EREMOTEIO;
+
+ if (!(ts->wr->f_flags & O_NONBLOCK))
+ dprintk(DEBUG_ERROR, "blocking write ...\n");
oldfs = get_fs();
set_fs(get_ds());
/* The cast to a user pointer is valid due to the set_fs() */
- ret = vfs_write(ts->out_file, (void __user *)v, len, &ts->out_file->f_pos);
+ ret = vfs_write(ts->wr, (void __user *)v, len, &ts->wr->f_pos);
set_fs(oldfs);
+ if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
+ trans->status = Disconnected;
return ret;
}
-/**
- * v9fs_fd_init - initialize file descriptor transport
- * @v9ses: session information
- * @addr: address of server to mount
- * @data: mount options
- *
- */
-
-static int
-v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
+static unsigned int
+v9fs_fd_poll(struct v9fs_transport *trans, struct poll_table_struct *pt)
{
- struct v9fs_trans_fd *ts = NULL;
- struct v9fs_transport *trans = v9ses->transport;
+ int ret, n;
+ struct v9fs_trans_fd *ts;
+ mm_segment_t oldfs;
- if((v9ses->wfdno == ~0) || (v9ses->rfdno == ~0)) {
- printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n");
- return -ENOPROTOOPT;
- }
+ if (!trans || trans->status != Connected || !(ts = trans->priv))
+ return -EREMOTEIO;
- ts = kmalloc(sizeof(struct v9fs_trans_fd), GFP_KERNEL);
+ if (!ts->rd->f_op || !ts->rd->f_op->poll)
+ return -EIO;
- if (!ts)
- return -ENOMEM;
+ if (!ts->wr->f_op || !ts->wr->f_op->poll)
+ return -EIO;
- ts->in_file = fget( v9ses->rfdno );
- ts->out_file = fget( v9ses->wfdno );
+ oldfs = get_fs();
+ set_fs(get_ds());
- if (!ts->in_file || !ts->out_file) {
- if (ts->in_file)
- fput(ts->in_file);
+ ret = ts->rd->f_op->poll(ts->rd, pt);
+ if (ret < 0)
+ goto end;
- if (ts->out_file)
- fput(ts->out_file);
+ if (ts->rd != ts->wr) {
+ n = ts->wr->f_op->poll(ts->wr, pt);
+ if (n < 0) {
+ ret = n;
+ goto end;
+ }
+ ret = (ret & ~POLLOUT) | (n & ~POLLIN);
+ }
+ end:
+ set_fs(oldfs);
+ return ret;
+}
+
+static int v9fs_fd_open(struct v9fs_session_info *v9ses, int rfd, int wfd)
+{
+ struct v9fs_transport *trans = v9ses->transport;
+ struct v9fs_trans_fd *ts = kmalloc(sizeof(struct v9fs_trans_fd),
+ GFP_KERNEL);
+ if (!ts)
+ return -ENOMEM;
+
+ ts->rd = fget(rfd);
+ ts->wr = fget(wfd);
+ if (!ts->rd || !ts->wr) {
+ if (ts->rd)
+ fput(ts->rd);
+ if (ts->wr)
+ fput(ts->wr);
kfree(ts);
return -EIO;
}
@@ -133,84 +165,145 @@ v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
return 0;
}
-
-/**
- * v9fs_fd_close - shutdown file descriptor
- * @trans: private socket structure
- *
- */
-
-static void v9fs_fd_close(struct v9fs_transport *trans)
+static int v9fs_fd_init(struct v9fs_session_info *v9ses, const char *addr,
+ char *data)
{
- struct v9fs_trans_fd *ts;
-
- if (!trans)
- return;
-
- ts = xchg(&trans->priv, NULL);
+ if (v9ses->rfdno == ~0 || v9ses->wfdno == ~0) {
+ printk(KERN_ERR "v9fs: Insufficient options for proto=fd\n");
+ return -ENOPROTOOPT;
+ }
- if (!ts)
- return;
+ return v9fs_fd_open(v9ses, v9ses->rfdno, v9ses->wfdno);
+}
- trans->status = Disconnected;
- if (ts->in_file)
- fput(ts->in_file);
+static int v9fs_socket_open(struct v9fs_session_info *v9ses,
+ struct socket *csocket)
+{
+ int fd, ret;
+
+ csocket->sk->sk_allocation = GFP_NOIO;
+ if ((fd = sock_map_fd(csocket)) < 0) {
+ eprintk(KERN_ERR, "v9fs_socket_open: failed to map fd\n");
+ ret = fd;
+ release_csocket:
+ sock_release(csocket);
+ return ret;
+ }
- if (ts->out_file)
- fput(ts->out_file);
+ if ((ret = v9fs_fd_open(v9ses, fd, fd)) < 0) {
+ sockfd_put(csocket);
+ eprintk(KERN_ERR, "v9fs_socket_open: failed to open fd\n");
+ goto release_csocket;
+ }
- kfree(ts);
+ ((struct v9fs_trans_fd *)v9ses->transport->priv)->rd->f_flags |=
+ O_NONBLOCK;
+ return 0;
}
-static unsigned int
-v9fs_fd_poll(struct v9fs_transport *trans, struct poll_table_struct *pt)
+static int v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr,
+ char *data)
{
- int ret, n;
- struct v9fs_trans_fd *ts;
- mm_segment_t oldfs;
+ int ret;
+ struct socket *csocket = NULL;
+ struct sockaddr_in sin_server;
+
+ sin_server.sin_family = AF_INET;
+ sin_server.sin_addr.s_addr = in_aton(addr);
+ sin_server.sin_port = htons(v9ses->port);
+ sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
+
+ if (!csocket) {
+ eprintk(KERN_ERR, "v9fs_trans_tcp: problem creating socket\n");
+ return -1;
+ }
- if (!trans)
- return -EIO;
+ ret = csocket->ops->connect(csocket,
+ (struct sockaddr *)&sin_server,
+ sizeof(struct sockaddr_in), 0);
+ if (ret < 0) {
+ eprintk(KERN_ERR,
+ "v9fs_trans_tcp: problem connecting socket to %s\n",
+ addr);
+ return ret;
+ }
- ts = trans->priv;
- if (trans->status != Connected || !ts)
- return -EIO;
+ return v9fs_socket_open(v9ses, csocket);
+}
- oldfs = get_fs();
- set_fs(get_ds());
+static int
+v9fs_unix_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
+{
+ int ret;
+ struct socket *csocket;
+ struct sockaddr_un sun_server;
+
+ if (strlen(addr) > UNIX_PATH_MAX) {
+ eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n",
+ addr);
+ return -ENAMETOOLONG;
+ }
- if (!ts->in_file->f_op || !ts->in_file->f_op->poll) {
- ret = -EIO;
- goto end;
+ sun_server.sun_family = PF_UNIX;
+ strcpy(sun_server.sun_path, addr);
+ sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
+ ret = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
+ sizeof(struct sockaddr_un) - 1, 0);
+ if (ret < 0) {
+ eprintk(KERN_ERR,
+ "v9fs_trans_unix: problem connecting socket: %s: %d\n",
+ addr, ret);
+ return ret;
}
- ret = ts->in_file->f_op->poll(ts->in_file, pt);
+ return v9fs_socket_open(v9ses, csocket);
+}
- if (ts->out_file != ts->in_file) {
- if (!ts->out_file->f_op || !ts->out_file->f_op->poll) {
- ret = -EIO;
- goto end;
- }
+/**
+ * v9fs_sock_close - shutdown socket
+ * @trans: private socket structure
+ *
+ */
+static void v9fs_fd_close(struct v9fs_transport *trans)
+{
+ struct v9fs_trans_fd *ts;
- n = ts->out_file->f_op->poll(ts->out_file, pt);
+ if (!trans)
+ return;
- ret &= ~POLLOUT;
- n &= ~POLLIN;
+ ts = xchg(&trans->priv, NULL);
- ret |= n;
- }
+ if (!ts)
+ return;
-end:
- set_fs(oldfs);
- return ret;
+ trans->status = Disconnected;
+ if (ts->rd)
+ fput(ts->rd);
+ if (ts->wr)
+ fput(ts->wr);
+ kfree(ts);
}
-
struct v9fs_transport v9fs_trans_fd = {
.init = v9fs_fd_init,
- .write = v9fs_fd_send,
- .read = v9fs_fd_recv,
+ .write = v9fs_fd_write,
+ .read = v9fs_fd_read,
.close = v9fs_fd_close,
.poll = v9fs_fd_poll,
};
+struct v9fs_transport v9fs_trans_tcp = {
+ .init = v9fs_tcp_init,
+ .write = v9fs_fd_write,
+ .read = v9fs_fd_read,
+ .close = v9fs_fd_close,
+ .poll = v9fs_fd_poll,
+};
+
+struct v9fs_transport v9fs_trans_unix = {
+ .init = v9fs_unix_init,
+ .write = v9fs_fd_write,
+ .read = v9fs_fd_read,
+ .close = v9fs_fd_close,
+ .poll = v9fs_fd_poll,
+};
diff --git a/fs/9p/trans_sock.c b/fs/9p/trans_sock.c
deleted file mode 100644
index 44e830697ac..00000000000
--- a/fs/9p/trans_sock.c
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * linux/fs/9p/trans_socket.c
- *
- * Socket Transport Layer
- *
- * Copyright (C) 2004-2005 by Latchesar Ionkov <lucho@ionkov.net>
- * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
- * Copyright (C) 1997-2002 by Ron Minnich <rminnich@sarnoff.com>
- * Copyright (C) 1995, 1996 by Olaf Kirch <okir@monad.swb.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to:
- * Free Software Foundation
- * 51 Franklin Street, Fifth Floor
- * Boston, MA 02111-1301 USA
- *
- */
-
-#include <linux/config.h>
-#include <linux/in.h>
-#include <linux/module.h>
-#include <linux/net.h>
-#include <linux/ipv6.h>
-#include <linux/errno.h>
-#include <linux/kernel.h>
-#include <linux/un.h>
-#include <asm/uaccess.h>
-#include <linux/inet.h>
-#include <linux/idr.h>
-#include <linux/file.h>
-
-#include "debug.h"
-#include "v9fs.h"
-#include "transport.h"
-
-#define V9FS_PORT 564
-
-struct v9fs_trans_sock {
- struct socket *s;
- struct file *filp;
-};
-
-/**
- * v9fs_sock_recv - receive from a socket
- * @v9ses: session information
- * @v: buffer to receive data into
- * @len: size of receive buffer
- *
- */
-
-static int v9fs_sock_recv(struct v9fs_transport *trans, void *v, int len)
-{
- int ret;
- struct v9fs_trans_sock *ts;
-
- if (!trans || trans->status == Disconnected) {
- dprintk(DEBUG_ERROR, "disconnected ...\n");
- return -EREMOTEIO;
- }
-
- ts = trans->priv;
-
- if (!(ts->filp->f_flags & O_NONBLOCK))
- dprintk(DEBUG_ERROR, "blocking read ...\n");
-
- ret = kernel_read(ts->filp, ts->filp->f_pos, v, len);
- if (ret <= 0) {
- if (ret != -ERESTARTSYS && ret != -EAGAIN)
- trans->status = Disconnected;
- }
-
- return ret;
-}
-
-/**
- * v9fs_sock_send - send to a socket
- * @v9ses: session information
- * @v: buffer to send data from
- * @len: size of send buffer
- *
- */
-
-static int v9fs_sock_send(struct v9fs_transport *trans, void *v, int len)
-{
- int ret;
- mm_segment_t oldfs;
- struct v9fs_trans_sock *ts;
-
- if (!trans || trans->status == Disconnected) {
- dprintk(DEBUG_ERROR, "disconnected ...\n");
- return -EREMOTEIO;
- }
-
- ts = trans->priv;
- if (!ts) {
- dprintk(DEBUG_ERROR, "no transport ...\n");
- return -EREMOTEIO;
- }
-
- if (!(ts->filp->f_flags & O_NONBLOCK))
- dprintk(DEBUG_ERROR, "blocking write ...\n");
-
- oldfs = get_fs();
- set_fs(get_ds());
- ret = vfs_write(ts->filp, (void __user *)v, len, &ts->filp->f_pos);
- set_fs(oldfs);
-
- if (ret < 0) {
- if (ret != -ERESTARTSYS)
- trans->status = Disconnected;
- }
-
- return ret;
-}
-
-static unsigned int v9fs_sock_poll(struct v9fs_transport *trans,
- struct poll_table_struct *pt) {
-
- int ret;
- struct v9fs_trans_sock *ts;
- mm_segment_t oldfs;
-
- if (!trans) {
- dprintk(DEBUG_ERROR, "no transport\n");
- return -EIO;
- }
-
- ts = trans->priv;
- if (trans->status != Connected || !ts) {
- dprintk(DEBUG_ERROR, "transport disconnected: %d\n", trans->status);
- return -EIO;
- }
-
- oldfs = get_fs();
- set_fs(get_ds());
-
- if (!ts->filp->f_op || !ts->filp->f_op->poll) {
- dprintk(DEBUG_ERROR, "no poll operation\n");
- ret = -EIO;
- goto end;
- }
-
- ret = ts->filp->f_op->poll(ts->filp, pt);
-
-end:
- set_fs(oldfs);
- return ret;
-}
-
-
-/**
- * v9fs_tcp_init - initialize TCP socket
- * @v9ses: session information
- * @addr: address of server to mount
- * @data: mount options
- *
- */
-
-static int
-v9fs_tcp_init(struct v9fs_session_info *v9ses, const char *addr, char *data)
-{
- struct socket *csocket = NULL;
- struct sockaddr_in sin_server;
- int rc = 0;
- struct v9fs_trans_sock *ts = NULL;
- struct v9fs_transport *trans = v9ses->transport;
- int fd;
-
- trans->status = Disconnected;
-
- ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL);
-
- if (!ts)
- return -ENOMEM;
-
- trans->priv = ts;
- ts->s = NULL;
- ts->filp = NULL;
-
- if (!addr)
- return -EINVAL;
-
- dprintk(DEBUG_TRANS, "Connecting to %s\n", addr);
-
- sin_server.sin_family = AF_INET;
- sin_server.sin_addr.s_addr = in_aton(addr);
- sin_server.sin_port = htons(v9ses->port);
- sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, &csocket);
- rc = csocket->ops->connect(csocket,
- (struct sockaddr *)&sin_server,
- sizeof(struct sockaddr_in), 0);
- if (rc < 0) {
- eprintk(KERN_ERR,
- "v9fs_trans_tcp: problem connecting socket to %s\n",
- addr);
- return rc;
- }
- csocket->sk->sk_allocation = GFP_NOIO;
-
- fd = sock_map_fd(csocket);
- if (fd < 0) {
- sock_release(csocket);
- kfree(ts);
- trans->priv = NULL;
- return fd;
- }
-
- ts->s = csocket;
- ts->filp = fget(fd);
- ts->filp->f_flags |= O_NONBLOCK;
- trans->status = Connected;
-
- return 0;
-}
-
-/**
- * v9fs_unix_init - initialize UNIX domain socket
- * @v9ses: session information
- * @dev_name: path to named pipe
- * @data: mount options
- *
- */
-
-static int
-v9fs_unix_init(struct v9fs_session_info *v9ses, const char *dev_name,
- char *data)
-{
- int rc, fd;
- struct socket *csocket;
- struct sockaddr_un sun_server;
- struct v9fs_transport *trans;
- struct v9fs_trans_sock *ts;
-
- rc = 0;
- csocket = NULL;
- trans = v9ses->transport;
-
- trans->status = Disconnected;
-
- if (strlen(dev_name) > UNIX_PATH_MAX) {
- eprintk(KERN_ERR, "v9fs_trans_unix: address too long: %s\n",
- dev_name);
- return -ENOMEM;
- }
-
- ts = kmalloc(sizeof(struct v9fs_trans_sock), GFP_KERNEL);
- if (!ts)
- return -ENOMEM;
-
- trans->priv = ts;
- ts->s = NULL;
- ts->filp = NULL;
-
- sun_server.sun_family = PF_UNIX;
- strcpy(sun_server.sun_path, dev_name);
- sock_create_kern(PF_UNIX, SOCK_STREAM, 0, &csocket);
- rc = csocket->ops->connect(csocket, (struct sockaddr *)&sun_server,
- sizeof(struct sockaddr_un) - 1, 0); /* -1 *is* important */
- if (rc < 0) {
- eprintk(KERN_ERR,
- "v9fs_trans_unix: problem connecting socket: %s: %d\n",
- dev_name, rc);
- return rc;
- }
- csocket->sk->sk_allocation = GFP_NOIO;
-
- fd = sock_map_fd(csocket);
- if (fd < 0) {
- sock_release(csocket);
- kfree(ts);
- trans->priv = NULL;
- return fd;
- }
-
- ts->s = csocket;
- ts->filp = fget(fd);
- ts->filp->f_flags |= O_NONBLOCK;
- trans->status = Connected;
-
- return 0;
-}
-
-/**
- * v9fs_sock_close - shutdown socket
- * @trans: private socket structure
- *
- */
-
-static void v9fs_sock_close(struct v9fs_transport *trans)
-{
- struct v9fs_trans_sock *ts;
-
- if (!trans)
- return;
-
- ts = trans->priv;
-
- if ((ts) && (ts->filp)) {
- fput(ts->filp);
- ts->filp = NULL;
- ts->s = NULL;
- trans->status = Disconnected;
- }
-
- kfree(ts);
-
- trans->priv = NULL;
-}
-
-struct v9fs_transport v9fs_trans_tcp = {
- .init = v9fs_tcp_init,
- .write = v9fs_sock_send,
- .read = v9fs_sock_recv,
- .close = v9fs_sock_close,
- .poll = v9fs_sock_poll,
-};
-
-struct v9fs_transport v9fs_trans_unix = {
- .init = v9fs_unix_init,
- .write = v9fs_sock_send,
- .read = v9fs_sock_recv,
- .close = v9fs_sock_close,
- .poll = v9fs_sock_poll,
-};
diff --git a/fs/9p/transport.h b/fs/9p/transport.h
index 91fcdb94b36..b38a4b8a41c 100644
--- a/fs/9p/transport.h
+++ b/fs/9p/transport.h
@@ -7,9 +7,8 @@
* Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 61352491ba3..d37416eb579 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,7 +50,7 @@ enum {
Opt_port, Opt_msize, Opt_uid, Opt_gid, Opt_afid, Opt_debug,
Opt_rfdno, Opt_wfdno,
/* String options */
- Opt_name, Opt_remotename,
+ Opt_uname, Opt_remotename,
/* Options that take no arguments */
Opt_legacy, Opt_nodevmap, Opt_unix, Opt_tcp, Opt_fd,
/* Error token */
@@ -67,7 +66,7 @@ static match_table_t tokens = {
{Opt_rfdno, "rfdno=%u"},
{Opt_wfdno, "wfdno=%u"},
{Opt_debug, "debug=%x"},
- {Opt_name, "name=%s"},
+ {Opt_uname, "uname=%s"},
{Opt_remotename, "aname=%s"},
{Opt_unix, "proto=unix"},
{Opt_tcp, "proto=tcp"},
@@ -116,7 +115,7 @@ static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses)
if (!*p)
continue;
token = match_token(p, tokens, args);
- if (token < Opt_name) {
+ if (token < Opt_uname) {
if ((ret = match_int(&args[0], &option)) < 0) {
dprintk(DEBUG_ERROR,
"integer field, but no integer?\n");
@@ -158,7 +157,7 @@ static void v9fs_parse_options(char *options, struct v9fs_session_info *v9ses)
case Opt_fd:
v9ses->proto = PROTO_FD;
break;
- case Opt_name:
+ case Opt_uname:
match_strcpy(v9ses->name, &args[0]);
break;
case Opt_remotename:
@@ -289,7 +288,7 @@ v9fs_session_init(struct v9fs_session_info *v9ses,
/* set global debug level */
v9fs_debug_level = v9ses->debug;
- /* id pools that are session-dependent: FIDs and TIDs */
+ /* id pools that are session-dependent: fids and tags */
idr_init(&v9ses->fidpool.pool);
init_MUTEX(&v9ses->fidpool.lock);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index f337da7a0ee..c134d104cb2 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -5,9 +5,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -91,6 +90,3 @@ void v9fs_session_cancel(struct v9fs_session_info *v9ses);
#define V9FS_DEFUSER "nobody"
#define V9FS_DEFANAME ""
-/* inital pool sizes for fids and tags */
-#define V9FS_START_FIDS 8192
-#define V9FS_START_TIDS 256
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index a759278acaa..43c9f7de031 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -5,9 +5,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 8100fb5171b..efda46fb64d 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c
index 12c9cc926b7..062daa6000a 100644
--- a/fs/9p/vfs_dentry.c
+++ b/fs/9p/vfs_dentry.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -51,7 +50,7 @@
*
*/
-int v9fs_dentry_delete(struct dentry *dentry)
+static int v9fs_dentry_delete(struct dentry *dentry)
{
dprintk(DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_iname, dentry);
return 1;
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c
index cd5eeb032d6..766f11f1215 100644
--- a/fs/9p/vfs_dir.c
+++ b/fs/9p/vfs_dir.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index de3a129698d..59e74416340 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -69,29 +68,30 @@ int v9fs_file_open(struct inode *inode, struct file *file)
fid = v9fs_get_idpool(&v9ses->fidpool);
if (fid < 0) {
- eprintk(KERN_WARNING, "newfid fails!\n");
- return -ENOSPC;
- }
+ eprintk(KERN_WARNING, "newfid fails!\n");
+ return -ENOSPC;
+ }
err = v9fs_t_walk(v9ses, vfid->fid, fid, NULL, NULL);
if (err < 0) {
- dprintk(DEBUG_ERROR, "rewalk didn't work\n");
+ dprintk(DEBUG_ERROR, "rewalk didn't work\n");
goto put_fid;
}
- vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
- if (vfid == NULL) {
- dprintk(DEBUG_ERROR, "out of memory\n");
- goto clunk_fid;
- }
-
- /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
- /* translate open mode appropriately */
+ /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */
+ /* translate open mode appropriately */
omode = v9fs_uflags2omode(file->f_flags);
err = v9fs_t_open(v9ses, fid, omode, &fcall);
if (err < 0) {
PRINT_FCALL_ERROR("open failed", fcall);
- goto destroy_vfid;
+ goto clunk_fid;
+ }
+
+ vfid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL);
+ if (vfid == NULL) {
+ dprintk(DEBUG_ERROR, "out of memory\n");
+ err = -ENOMEM;
+ goto clunk_fid;
}
file->private_data = vfid;
@@ -106,15 +106,12 @@ int v9fs_file_open(struct inode *inode, struct file *file)
return 0;
-destroy_vfid:
- v9fs_fid_destroy(vfid);
-
clunk_fid:
v9fs_t_clunk(v9ses, fid);
put_fid:
v9fs_put_idpool(fid, &v9ses->fidpool);
- kfree(fcall);
+ kfree(fcall);
return err;
}
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 651a9e14d9a..133db366d30 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -7,9 +7,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -255,8 +254,8 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode)
}
static int
-v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
- u32 perm, u8 mode, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
+v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name, u32 perm,
+ u8 mode, char *extension, u32 *fidp, struct v9fs_qid *qid, u32 *iounit)
{
u32 fid;
int err;
@@ -271,14 +270,14 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
err = v9fs_t_walk(v9ses, pfid, fid, NULL, &fcall);
if (err < 0) {
PRINT_FCALL_ERROR("clone error", fcall);
- goto error;
+ goto put_fid;
}
kfree(fcall);
- err = v9fs_t_create(v9ses, fid, name, perm, mode, &fcall);
+ err = v9fs_t_create(v9ses, fid, name, perm, mode, extension, &fcall);
if (err < 0) {
PRINT_FCALL_ERROR("create fails", fcall);
- goto error;
+ goto clunk_fid;
}
if (iounit)
@@ -293,7 +292,11 @@ v9fs_create(struct v9fs_session_info *v9ses, u32 pfid, char *name,
kfree(fcall);
return 0;
-error:
+clunk_fid:
+ v9fs_t_clunk(v9ses, fid);
+ fid = V9FS_NOFID;
+
+put_fid:
if (fid >= 0)
v9fs_put_idpool(fid, &v9ses->fidpool);
@@ -348,7 +351,7 @@ error:
return ERR_PTR(err);
}
-struct inode *
+static struct inode *
v9fs_inode_from_fid(struct v9fs_session_info *v9ses, u32 fid,
struct super_block *sb)
{
@@ -474,7 +477,7 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, int mode,
flags = O_RDWR;
err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
- perm, v9fs_uflags2omode(flags), &fid, &qid, &iounit);
+ perm, v9fs_uflags2omode(flags), NULL, &fid, &qid, &iounit);
if (err)
goto error;
@@ -550,7 +553,7 @@ static int v9fs_vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
perm = unixmode2p9mode(v9ses, mode | S_IFDIR);
err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
- perm, V9FS_OREAD, &fid, NULL, NULL);
+ perm, V9FS_OREAD, NULL, &fid, NULL, NULL);
if (err) {
dprintk(DEBUG_ERROR, "create error %d\n", err);
@@ -1008,11 +1011,13 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen)
/* copy extension buffer into buffer */
if (fcall->params.rstat.stat.extension.len < buflen)
- buflen = fcall->params.rstat.stat.extension.len;
+ buflen = fcall->params.rstat.stat.extension.len + 1;
- memcpy(buffer, fcall->params.rstat.stat.extension.str, buflen - 1);
+ memmove(buffer, fcall->params.rstat.stat.extension.str, buflen - 1);
buffer[buflen-1] = 0;
+ dprintk(DEBUG_ERROR, "%s -> %.*s (%s)\n", dentry->d_name.name, fcall->params.rstat.stat.extension.len,
+ fcall->params.rstat.stat.extension.str, buffer);
retval = buflen;
FreeFcall:
@@ -1072,7 +1077,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
if (!link)
link = ERR_PTR(-ENOMEM);
else {
- len = v9fs_readlink(dentry, link, strlen(link));
+ len = v9fs_readlink(dentry, link, PATH_MAX);
if (len < 0) {
__putname(link);
@@ -1109,10 +1114,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
struct v9fs_session_info *v9ses;
struct v9fs_fid *dfid, *vfid;
struct inode *inode;
- struct v9fs_fcall *fcall;
- struct v9fs_wstat wstat;
- fcall = NULL;
inode = NULL;
vfid = NULL;
v9ses = v9fs_inode2v9ses(dir);
@@ -1125,7 +1127,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
}
err = v9fs_create(v9ses, dfid->fid, (char *) dentry->d_name.name,
- perm, V9FS_OREAD, &fid, NULL, NULL);
+ perm, V9FS_OREAD, (char *) extension, &fid, NULL, NULL);
if (err)
goto error;
@@ -1148,23 +1150,11 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
goto error;
}
- /* issue a Twstat */
- v9fs_blank_wstat(&wstat);
- wstat.muid = v9ses->name;
- wstat.extension = (char *) extension;
- err = v9fs_t_wstat(v9ses, vfid->fid, &wstat, &fcall);
- if (err < 0) {
- PRINT_FCALL_ERROR("wstat error", fcall);
- goto error;
- }
-
- kfree(fcall);
dentry->d_op = &v9fs_dentry_operations;
d_instantiate(dentry, inode);
return 0;
error:
- kfree(fcall);
if (vfid)
v9fs_fid_destroy(vfid);
@@ -1224,7 +1214,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
}
name = __getname();
- sprintf(name, "hardlink(%d)\n", oldfid->fid);
+ sprintf(name, "%d\n", oldfid->fid);
retval = v9fs_vfs_mkspecial(dir, dentry, V9FS_DMLINK, name);
__putname(name);
@@ -1253,6 +1243,8 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
return -EINVAL;
name = __getname();
+ if (!name)
+ return -ENOMEM;
/* build extension */
if (S_ISBLK(mode))
sprintf(name, "b %u %u", MAJOR(rdev), MINOR(rdev));
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index d05318fa684..b0a0ae509c0 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -8,9 +8,8 @@
* Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -262,7 +261,7 @@ static struct super_operations v9fs_super_ops = {
};
struct file_system_type v9fs_fs_type = {
- .name = "9P",
+ .name = "9p",
.get_sb = v9fs_get_sb,
.kill_sb = v9fs_kill_super,
.owner = THIS_MODULE,
diff --git a/fs/Kconfig b/fs/Kconfig
index e9749b0eecd..c8d0a209120 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -859,18 +859,6 @@ config RAMFS
To compile this as a module, choose M here: the module will be called
ramfs.
-config RELAYFS_FS
- tristate "Relayfs file system support"
- ---help---
- Relayfs is a high-speed data relay filesystem designed to provide
- an efficient mechanism for tools and facilities to relay large
- amounts of data from kernel space to user space.
-
- To compile this code as a module, choose M here: the module will be
- called relayfs.
-
- If unsure, say N.
-
config CONFIGFS_FS
tristate "Userspace-driven configuration filesystem (EXPERIMENTAL)"
depends on EXPERIMENTAL
diff --git a/fs/Makefile b/fs/Makefile
index 1db711319c8..080b3867be4 100644
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -91,7 +91,6 @@ obj-$(CONFIG_AUTOFS4_FS) += autofs4/
obj-$(CONFIG_ADFS_FS) += adfs/
obj-$(CONFIG_FUSE_FS) += fuse/
obj-$(CONFIG_UDF_FS) += udf/
-obj-$(CONFIG_RELAYFS_FS) += relayfs/
obj-$(CONFIG_SUN_OPENPROMFS) += openpromfs/
obj-$(CONFIG_JFS_FS) += jfs/
obj-$(CONFIG_XFS_FS) += xfs/
diff --git a/fs/adfs/file.c b/fs/adfs/file.c
index afebbfde696..6af10885f9d 100644
--- a/fs/adfs/file.c
+++ b/fs/adfs/file.c
@@ -19,11 +19,7 @@
*
* adfs regular file handling primitives
*/
-#include <linux/errno.h>
#include <linux/fs.h>
-#include <linux/fcntl.h>
-#include <linux/time.h>
-#include <linux/stat.h>
#include <linux/buffer_head.h> /* for file_fsync() */
#include <linux/adfs_fs.h>
diff --git a/fs/adfs/super.c b/fs/adfs/super.c
index 243963228d1..252abda0d20 100644
--- a/fs/adfs/super.c
+++ b/fs/adfs/super.c
@@ -241,7 +241,8 @@ static int init_inodecache(void)
{
adfs_inode_cachep = kmem_cache_create("adfs_inode_cache",
sizeof(struct adfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (adfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index aaec015a16e..4d7e5b19e5c 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -98,7 +98,8 @@ static int init_inodecache(void)
{
affs_inode_cachep = kmem_cache_create("affs_inode_cache",
sizeof(struct affs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (affs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c
index 9eef6bf156a..3d097fddcb7 100644
--- a/fs/afs/cmservice.c
+++ b/fs/afs/cmservice.c
@@ -94,7 +94,7 @@ static struct rxrpc_service AFSCM_service = {
.error_func = afscm_error,
.aemap_func = afscm_aemap,
.ops_begin = &AFSCM_ops[0],
- .ops_end = &AFSCM_ops[sizeof(AFSCM_ops) / sizeof(AFSCM_ops[0])],
+ .ops_end = &AFSCM_ops[ARRAY_SIZE(AFSCM_ops)],
};
static DECLARE_COMPLETION(kafscmd_alive);
diff --git a/fs/afs/super.c b/fs/afs/super.c
index d6fa8e5999d..53c56e7231a 100644
--- a/fs/afs/super.c
+++ b/fs/afs/super.c
@@ -341,7 +341,7 @@ static struct super_block *afs_get_sb(struct file_system_type *fs_type,
sb->s_flags = flags;
- ret = afs_fill_super(sb, &params, flags & MS_VERBOSE ? 1 : 0);
+ ret = afs_fill_super(sb, &params, flags & MS_SILENT ? 1 : 0);
if (ret < 0) {
up_write(&sb->s_umount);
deactivate_super(sb);
diff --git a/fs/aio.c b/fs/aio.c
index aec2b1916d1..e41e932ba48 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -122,10 +122,9 @@ static int aio_setup_ring(struct kioctx *ctx)
info->nr = 0;
info->ring_pages = info->internal_pages;
if (nr_pages > AIO_RING_PAGES) {
- info->ring_pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL);
+ info->ring_pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
if (!info->ring_pages)
return -ENOMEM;
- memset(info->ring_pages, 0, sizeof(struct page *) * nr_pages);
}
info->mmap_size = nr_pages * PAGE_SIZE;
diff --git a/fs/autofs4/autofs_i.h b/fs/autofs4/autofs_i.h
index 385bed09b0d..f54c5b21f87 100644
--- a/fs/autofs4/autofs_i.h
+++ b/fs/autofs4/autofs_i.h
@@ -13,6 +13,7 @@
/* Internal header file for autofs */
#include <linux/auto_fs4.h>
+#include <linux/mutex.h>
#include <linux/list.h>
/* This is the range of ioctl() numbers we claim as ours */
@@ -102,7 +103,7 @@ struct autofs_sb_info {
int reghost_enabled;
int needs_reghost;
struct super_block *sb;
- struct semaphore wq_sem;
+ struct mutex wq_mutex;
spinlock_t fs_lock;
struct autofs_wait_queue *queues; /* Wait queue pointer */
};
diff --git a/fs/autofs4/inode.c b/fs/autofs4/inode.c
index 2d3082854a2..1ad98d48e55 100644
--- a/fs/autofs4/inode.c
+++ b/fs/autofs4/inode.c
@@ -269,7 +269,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
sbi->sb = s;
sbi->version = 0;
sbi->sub_version = 0;
- init_MUTEX(&sbi->wq_sem);
+ mutex_init(&sbi->wq_mutex);
spin_lock_init(&sbi->fs_lock);
sbi->queues = NULL;
s->s_blocksize = 1024;
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 394ff36ef8f..be78e9378c0 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -178,7 +178,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
return -ENOENT;
}
- if (down_interruptible(&sbi->wq_sem)) {
+ if (mutex_lock_interruptible(&sbi->wq_mutex)) {
kfree(name);
return -EINTR;
}
@@ -194,7 +194,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
/* Can't wait for an expire if there's no mount */
if (notify == NFY_NONE && !d_mountpoint(dentry)) {
kfree(name);
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
return -ENOENT;
}
@@ -202,7 +202,7 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
wq = kmalloc(sizeof(struct autofs_wait_queue),GFP_KERNEL);
if ( !wq ) {
kfree(name);
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
return -ENOMEM;
}
@@ -218,10 +218,10 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
wq->status = -EINTR; /* Status return if interrupted */
atomic_set(&wq->wait_ctr, 2);
atomic_set(&wq->notified, 1);
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
} else {
atomic_inc(&wq->wait_ctr);
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
kfree(name);
DPRINTK("existing wait id = 0x%08lx, name = %.*s, nfy=%d",
(unsigned long) wq->wait_queue_token, wq->len, wq->name, notify);
@@ -282,19 +282,19 @@ int autofs4_wait_release(struct autofs_sb_info *sbi, autofs_wqt_t wait_queue_tok
{
struct autofs_wait_queue *wq, **wql;
- down(&sbi->wq_sem);
+ mutex_lock(&sbi->wq_mutex);
for ( wql = &sbi->queues ; (wq = *wql) != 0 ; wql = &wq->next ) {
if ( wq->wait_queue_token == wait_queue_token )
break;
}
if ( !wq ) {
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
return -EINVAL;
}
*wql = wq->next; /* Unlink from chain */
- up(&sbi->wq_sem);
+ mutex_unlock(&sbi->wq_mutex);
kfree(wq->name);
wq->name = NULL; /* Do not wait on this queue */
diff --git a/fs/befs/datastream.c b/fs/befs/datastream.c
index 785f6b2d5d1..b7d6b920f65 100644
--- a/fs/befs/datastream.c
+++ b/fs/befs/datastream.c
@@ -118,7 +118,7 @@ befs_fblock2brun(struct super_block *sb, befs_data_stream * data,
* befs_read_lsmylink - read long symlink from datastream.
* @sb: Filesystem superblock
* @ds: Datastrem to read from
- * @buf: Buffer in wich to place long symlink data
+ * @buf: Buffer in which to place long symlink data
* @len: Length of the long symlink in bytes
*
* Returns the number of bytes read
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index dd6048ce053..044a5958782 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -427,7 +427,8 @@ befs_init_inodecache(void)
{
befs_inode_cachep = kmem_cache_create("befs_inode_cache",
sizeof (struct befs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (befs_inode_cachep == NULL) {
printk(KERN_ERR "befs_init_inodecache: "
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 3af6c73c5b5..55a7a78332f 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -257,7 +257,8 @@ static int init_inodecache(void)
{
bfs_inode_cachep = kmem_cache_create("bfs_inode_cache",
sizeof(struct bfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (bfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index c2eac2a50bd..4349113881f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1334,7 +1334,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
i = p->state ? ffz(~p->state) + 1 : 0;
psinfo->pr_state = i;
- psinfo->pr_sname = (i < 0 || i > 5) ? '.' : "RSDTZW"[i];
+ psinfo->pr_sname = (i > 5) ? '.' : "RSDTZW"[i];
psinfo->pr_zomb = psinfo->pr_sname == 'Z';
psinfo->pr_nice = task_nice(p);
psinfo->pr_flag = p->flags;
@@ -1465,12 +1465,11 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file)
read_lock(&tasklist_lock);
do_each_thread(g,p)
if (current->mm == p->mm && current != p) {
- tmp = kmalloc(sizeof(*tmp), GFP_ATOMIC);
+ tmp = kzalloc(sizeof(*tmp), GFP_ATOMIC);
if (!tmp) {
read_unlock(&tasklist_lock);
goto cleanup;
}
- memset(tmp, 0, sizeof(*tmp));
INIT_LIST_HEAD(&tmp->list);
tmp->thread = p;
list_add(&tmp->list, &thread_list);
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 5b3076e8ee9..a2e48c999c2 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -572,8 +572,7 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
csp -= sizeof(unsigned long);
__put_user(bprm->argc, (unsigned long *) csp);
- if (csp != sp)
- BUG();
+ BUG_ON(csp != sp);
/* fill in the argv[] array */
#ifdef CONFIG_MMU
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 108d56bbd0d..69f44dcdb0b 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -36,6 +36,7 @@
#include <linux/personality.h>
#include <linux/init.h>
#include <linux/flat.h>
+#include <linux/syscalls.h>
#include <asm/byteorder.h>
#include <asm/system.h>
@@ -426,6 +427,8 @@ static int load_flat_file(struct linux_binprm * bprm,
int i, rev, relocs = 0;
loff_t fpos;
unsigned long start_code, end_code;
+ int ret;
+ int exec_fileno;
hdr = ((struct flat_hdr *) bprm->buf); /* exec-header */
inode = bprm->file->f_dentry->d_inode;
@@ -450,7 +453,8 @@ static int load_flat_file(struct linux_binprm * bprm,
*/
if (strncmp(hdr->magic, "#!", 2))
printk("BINFMT_FLAT: bad header magic\n");
- return -ENOEXEC;
+ ret = -ENOEXEC;
+ goto err;
}
if (flags & FLAT_FLAG_KTRACE)
@@ -458,14 +462,16 @@ static int load_flat_file(struct linux_binprm * bprm,
if (rev != FLAT_VERSION && rev != OLD_FLAT_VERSION) {
printk("BINFMT_FLAT: bad flat file version 0x%x (supported 0x%x and 0x%x)\n", rev, FLAT_VERSION, OLD_FLAT_VERSION);
- return -ENOEXEC;
+ ret = -ENOEXEC;
+ goto err;
}
/* Don't allow old format executables to use shared libraries */
if (rev == OLD_FLAT_VERSION && id != 0) {
printk("BINFMT_FLAT: shared libraries are not available before rev 0x%x\n",
(int) FLAT_VERSION);
- return -ENOEXEC;
+ ret = -ENOEXEC;
+ goto err;
}
/*
@@ -478,7 +484,8 @@ static int load_flat_file(struct linux_binprm * bprm,
#ifndef CONFIG_BINFMT_ZFLAT
if (flags & (FLAT_FLAG_GZIP|FLAT_FLAG_GZDATA)) {
printk("Support for ZFLAT executables is not enabled.\n");
- return -ENOEXEC;
+ ret = -ENOEXEC;
+ goto err;
}
#endif
@@ -490,14 +497,27 @@ static int load_flat_file(struct linux_binprm * bprm,
rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur;
if (rlim >= RLIM_INFINITY)
rlim = ~0;
- if (data_len + bss_len > rlim)
- return -ENOMEM;
+ if (data_len + bss_len > rlim) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ /* check file descriptor */
+ exec_fileno = get_unused_fd();
+ if (exec_fileno < 0) {
+ ret = -EMFILE;
+ goto err;
+ }
+ get_file(bprm->file);
+ fd_install(exec_fileno, bprm->file);
/* Flush all traces of the currently running executable */
if (id == 0) {
result = flush_old_exec(bprm);
- if (result)
- return result;
+ if (result) {
+ ret = result;
+ goto err_close;
+ }
/* OK, This is the point of no return */
set_personality(PER_LINUX);
@@ -527,7 +547,8 @@ static int load_flat_file(struct linux_binprm * bprm,
if (!textpos)
textpos = (unsigned long) -ENOMEM;
printk("Unable to mmap process text, errno %d\n", (int)-textpos);
- return(textpos);
+ ret = textpos;
+ goto err_close;
}
down_write(&current->mm->mmap_sem);
@@ -542,7 +563,8 @@ static int load_flat_file(struct linux_binprm * bprm,
printk("Unable to allocate RAM for process data, errno %d\n",
(int)-datapos);
do_munmap(current->mm, textpos, text_len);
- return realdatastart;
+ ret = realdatastart;
+ goto err_close;
}
datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
@@ -564,7 +586,8 @@ static int load_flat_file(struct linux_binprm * bprm,
printk("Unable to read data+bss, errno %d\n", (int)-result);
do_munmap(current->mm, textpos, text_len);
do_munmap(current->mm, realdatastart, data_len + extra);
- return result;
+ ret = result;
+ goto err_close;
}
reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len));
@@ -582,7 +605,8 @@ static int load_flat_file(struct linux_binprm * bprm,
textpos = (unsigned long) -ENOMEM;
printk("Unable to allocate RAM for process text/data, errno %d\n",
(int)-textpos);
- return(textpos);
+ ret = textpos;
+ goto err_close;
}
realdatastart = textpos + ntohl(hdr->data_start);
@@ -627,7 +651,8 @@ static int load_flat_file(struct linux_binprm * bprm,
printk("Unable to read code+data+bss, errno %d\n",(int)-result);
do_munmap(current->mm, textpos, text_len + data_len + extra +
MAX_SHARED_LIBS * sizeof(unsigned long));
- return result;
+ ret = result;
+ goto err_close;
}
}
@@ -690,8 +715,10 @@ static int load_flat_file(struct linux_binprm * bprm,
unsigned long addr;
if (*rp) {
addr = calc_reloc(*rp, libinfo, id, 0);
- if (addr == RELOC_FAILED)
- return -ENOEXEC;
+ if (addr == RELOC_FAILED) {
+ ret = -ENOEXEC;
+ goto err_close;
+ }
*rp = addr;
}
}
@@ -718,8 +745,10 @@ static int load_flat_file(struct linux_binprm * bprm,
relval = ntohl(reloc[i]);
addr = flat_get_relocate_addr(relval);
rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
- if (rp == (unsigned long *)RELOC_FAILED)
- return -ENOEXEC;
+ if (rp == (unsigned long *)RELOC_FAILED) {
+ ret = -ENOEXEC;
+ goto err_close;
+ }
/* Get the pointer's value. */
addr = flat_get_addr_from_rp(rp, relval, flags);
@@ -731,8 +760,10 @@ static int load_flat_file(struct linux_binprm * bprm,
if ((flags & FLAT_FLAG_GOTPIC) == 0)
addr = ntohl(addr);
addr = calc_reloc(addr, libinfo, id, 0);
- if (addr == RELOC_FAILED)
- return -ENOEXEC;
+ if (addr == RELOC_FAILED) {
+ ret = -ENOEXEC;
+ goto err_close;
+ }
/* Write back the relocated pointer. */
flat_put_addr_at_rp(rp, addr, relval);
@@ -752,6 +783,10 @@ static int load_flat_file(struct linux_binprm * bprm,
stack_len);
return 0;
+err_close:
+ sys_close(exec_fileno);
+err:
+ return ret;
}
diff --git a/fs/bio.c b/fs/bio.c
index 1f3bb501c26..73e664c01d3 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -25,6 +25,7 @@
#include <linux/module.h>
#include <linux/mempool.h>
#include <linux/workqueue.h>
+#include <linux/blktrace_api.h>
#include <scsi/sg.h> /* for struct sg_iovec */
#define BIO_POOL_SIZE 256
@@ -635,12 +636,10 @@ static struct bio *__bio_map_user_iov(request_queue_t *q,
return ERR_PTR(-ENOMEM);
ret = -ENOMEM;
- pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
+ pages = kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
if (!pages)
goto out;
- memset(pages, 0, nr_pages * sizeof(struct page *));
-
for (i = 0; i < iov_count; i++) {
unsigned long uaddr = (unsigned long)iov[i].iov_base;
unsigned long len = iov[i].iov_len;
@@ -1095,6 +1094,9 @@ struct bio_pair *bio_split(struct bio *bi, mempool_t *pool, int first_sectors)
if (!bp)
return bp;
+ blk_add_trace_pdu_int(bdev_get_queue(bi->bi_bdev), BLK_TA_SPLIT, bi,
+ bi->bi_sector + first_sectors);
+
BUG_ON(bi->bi_vcnt != 1);
BUG_ON(bi->bi_idx != 0);
atomic_set(&bp->cnt, 3);
@@ -1182,12 +1184,11 @@ void bioset_free(struct bio_set *bs)
struct bio_set *bioset_create(int bio_pool_size, int bvec_pool_size, int scale)
{
- struct bio_set *bs = kmalloc(sizeof(*bs), GFP_KERNEL);
+ struct bio_set *bs = kzalloc(sizeof(*bs), GFP_KERNEL);
if (!bs)
return NULL;
- memset(bs, 0, sizeof(*bs));
bs->bio_pool = mempool_create(bio_pool_size, mempool_alloc_slab,
mempool_free_slab, bio_slab);
@@ -1243,11 +1244,11 @@ static int __init init_bio(void)
scale = 4;
/*
- * scale number of entries
+ * Limit number of entries reserved -- mempools are only used when
+ * the system is completely unable to allocate memory, so we only
+ * need enough to make progress.
*/
- bvec_pool_entries = megabytes * 2;
- if (bvec_pool_entries > 256)
- bvec_pool_entries = 256;
+ bvec_pool_entries = 1 + scale;
fs_bio_set = bioset_create(BIO_POOL_SIZE, bvec_pool_entries, scale);
if (!fs_bio_set)
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6e50346fb1e..573fc8e0b67 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -86,16 +86,12 @@ EXPORT_SYMBOL(set_blocksize);
int sb_set_blocksize(struct super_block *sb, int size)
{
- int bits = 9; /* 2^9 = 512 */
-
if (set_blocksize(sb->s_bdev, size))
return 0;
/* If we get here, we know size is power of two
* and it's value is between 512 and PAGE_SIZE */
sb->s_blocksize = size;
- for (size >>= 10; size; size >>= 1)
- ++bits;
- sb->s_blocksize_bits = bits;
+ sb->s_blocksize_bits = blksize_bits(size);
return sb->s_blocksize;
}
@@ -265,8 +261,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
SLAB_CTOR_CONSTRUCTOR)
{
memset(bdev, 0, sizeof(*bdev));
- sema_init(&bdev->bd_sem, 1);
- sema_init(&bdev->bd_mount_sem, 1);
+ mutex_init(&bdev->bd_mutex);
+ mutex_init(&bdev->bd_mount_mutex);
INIT_LIST_HEAD(&bdev->bd_inodes);
INIT_LIST_HEAD(&bdev->bd_list);
inode_init_once(&ei->vfs_inode);
@@ -319,7 +315,8 @@ void __init bdev_cache_init(void)
{
int err;
bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_PANIC,
+ 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD|SLAB_PANIC),
init_once, NULL);
err = register_filesystem(&bd_type);
if (err)
@@ -574,7 +571,7 @@ static int do_open(struct block_device *bdev, struct file *file)
}
owner = disk->fops->owner;
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
if (!bdev->bd_openers) {
bdev->bd_disk = disk;
bdev->bd_contains = bdev;
@@ -605,21 +602,21 @@ static int do_open(struct block_device *bdev, struct file *file)
if (ret)
goto out_first;
bdev->bd_contains = whole;
- down(&whole->bd_sem);
+ mutex_lock(&whole->bd_mutex);
whole->bd_part_count++;
p = disk->part[part - 1];
bdev->bd_inode->i_data.backing_dev_info =
whole->bd_inode->i_data.backing_dev_info;
if (!(disk->flags & GENHD_FL_UP) || !p || !p->nr_sects) {
whole->bd_part_count--;
- up(&whole->bd_sem);
+ mutex_unlock(&whole->bd_mutex);
ret = -ENXIO;
goto out_first;
}
kobject_get(&p->kobj);
bdev->bd_part = p;
bd_set_size(bdev, (loff_t) p->nr_sects << 9);
- up(&whole->bd_sem);
+ mutex_unlock(&whole->bd_mutex);
}
} else {
put_disk(disk);
@@ -633,13 +630,13 @@ static int do_open(struct block_device *bdev, struct file *file)
if (bdev->bd_invalidated)
rescan_partitions(bdev->bd_disk, bdev);
} else {
- down(&bdev->bd_contains->bd_sem);
+ mutex_lock(&bdev->bd_contains->bd_mutex);
bdev->bd_contains->bd_part_count++;
- up(&bdev->bd_contains->bd_sem);
+ mutex_unlock(&bdev->bd_contains->bd_mutex);
}
}
bdev->bd_openers++;
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
unlock_kernel();
return 0;
@@ -652,7 +649,7 @@ out_first:
put_disk(disk);
module_put(owner);
out:
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
unlock_kernel();
if (ret)
bdput(bdev);
@@ -714,7 +711,7 @@ int blkdev_put(struct block_device *bdev)
struct inode *bd_inode = bdev->bd_inode;
struct gendisk *disk = bdev->bd_disk;
- down(&bdev->bd_sem);
+ mutex_lock(&bdev->bd_mutex);
lock_kernel();
if (!--bdev->bd_openers) {
sync_blockdev(bdev);
@@ -724,9 +721,9 @@ int blkdev_put(struct block_device *bdev)
if (disk->fops->release)
ret = disk->fops->release(bd_inode, NULL);
} else {
- down(&bdev->bd_contains->bd_sem);
+ mutex_lock(&bdev->bd_contains->bd_mutex);
bdev->bd_contains->bd_part_count--;
- up(&bdev->bd_contains->bd_sem);
+ mutex_unlock(&bdev->bd_contains->bd_mutex);
}
if (!bdev->bd_openers) {
struct module *owner = disk->fops->owner;
@@ -746,7 +743,7 @@ int blkdev_put(struct block_device *bdev)
bdev->bd_contains = NULL;
}
unlock_kernel();
- up(&bdev->bd_sem);
+ mutex_unlock(&bdev->bd_mutex);
bdput(bdev);
return ret;
}
diff --git a/fs/buffer.c b/fs/buffer.c
index 1d3683d496f..3b3ab528192 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -160,12 +160,7 @@ int sync_blockdev(struct block_device *bdev)
}
EXPORT_SYMBOL(sync_blockdev);
-/*
- * Write out and wait upon all dirty data associated with this
- * superblock. Filesystem data as well as the underlying block
- * device. Takes the superblock lock.
- */
-int fsync_super(struct super_block *sb)
+static void __fsync_super(struct super_block *sb)
{
sync_inodes_sb(sb, 0);
DQUOT_SYNC(sb);
@@ -177,7 +172,16 @@ int fsync_super(struct super_block *sb)
sb->s_op->sync_fs(sb, 1);
sync_blockdev(sb->s_bdev);
sync_inodes_sb(sb, 1);
+}
+/*
+ * Write out and wait upon all dirty data associated with this
+ * superblock. Filesystem data as well as the underlying block
+ * device. Takes the superblock lock.
+ */
+int fsync_super(struct super_block *sb)
+{
+ __fsync_super(sb);
return sync_blockdev(sb->s_bdev);
}
@@ -201,7 +205,7 @@ int fsync_bdev(struct block_device *bdev)
* freeze_bdev -- lock a filesystem and force it into a consistent state
* @bdev: blockdevice to lock
*
- * This takes the block device bd_mount_sem to make sure no new mounts
+ * This takes the block device bd_mount_mutex to make sure no new mounts
* happen on bdev until thaw_bdev() is called.
* If a superblock is found on this device, we take the s_umount semaphore
* on it to make sure nobody unmounts until the snapshot creation is done.
@@ -210,25 +214,13 @@ struct super_block *freeze_bdev(struct block_device *bdev)
{
struct super_block *sb;
- down(&bdev->bd_mount_sem);
+ mutex_lock(&bdev->bd_mount_mutex);
sb = get_super(bdev);
if (sb && !(sb->s_flags & MS_RDONLY)) {
sb->s_frozen = SB_FREEZE_WRITE;
smp_wmb();
- sync_inodes_sb(sb, 0);
- DQUOT_SYNC(sb);
-
- lock_super(sb);
- if (sb->s_dirt && sb->s_op->write_super)
- sb->s_op->write_super(sb);
- unlock_super(sb);
-
- if (sb->s_op->sync_fs)
- sb->s_op->sync_fs(sb, 1);
-
- sync_blockdev(sb->s_bdev);
- sync_inodes_sb(sb, 1);
+ __fsync_super(sb);
sb->s_frozen = SB_FREEZE_TRANS;
smp_wmb();
@@ -264,7 +256,7 @@ void thaw_bdev(struct block_device *bdev, struct super_block *sb)
drop_super(sb);
}
- up(&bdev->bd_mount_sem);
+ mutex_unlock(&bdev->bd_mount_mutex);
}
EXPORT_SYMBOL(thaw_bdev);
@@ -327,31 +319,24 @@ int file_fsync(struct file *filp, struct dentry *dentry, int datasync)
return ret;
}
-static long do_fsync(unsigned int fd, int datasync)
+long do_fsync(struct file *file, int datasync)
{
- struct file * file;
- struct address_space *mapping;
- int ret, err;
-
- ret = -EBADF;
- file = fget(fd);
- if (!file)
- goto out;
+ int ret;
+ int err;
+ struct address_space *mapping = file->f_mapping;
- ret = -EINVAL;
if (!file->f_op || !file->f_op->fsync) {
/* Why? We can still call filemap_fdatawrite */
- goto out_putf;
+ ret = -EINVAL;
+ goto out;
}
- mapping = file->f_mapping;
-
current->flags |= PF_SYNCWRITE;
ret = filemap_fdatawrite(mapping);
/*
- * We need to protect against concurrent writers,
- * which could cause livelocks in fsync_buffers_list
+ * We need to protect against concurrent writers, which could cause
+ * livelocks in fsync_buffers_list().
*/
mutex_lock(&mapping->host->i_mutex);
err = file->f_op->fsync(file, file->f_dentry, datasync);
@@ -362,21 +347,31 @@ static long do_fsync(unsigned int fd, int datasync)
if (!ret)
ret = err;
current->flags &= ~PF_SYNCWRITE;
-
-out_putf:
- fput(file);
out:
return ret;
}
+static long __do_fsync(unsigned int fd, int datasync)
+{
+ struct file *file;
+ int ret = -EBADF;
+
+ file = fget(fd);
+ if (file) {
+ ret = do_fsync(file, datasync);
+ fput(file);
+ }
+ return ret;
+}
+
asmlinkage long sys_fsync(unsigned int fd)
{
- return do_fsync(fd, 0);
+ return __do_fsync(fd, 0);
}
asmlinkage long sys_fdatasync(unsigned int fd)
{
- return do_fsync(fd, 1);
+ return __do_fsync(fd, 1);
}
/*
@@ -865,8 +860,8 @@ int __set_page_dirty_buffers(struct page *page)
}
write_unlock_irq(&mapping->tree_lock);
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
+ return 1;
}
-
return 0;
}
EXPORT_SYMBOL(__set_page_dirty_buffers);
@@ -3078,7 +3073,7 @@ static void recalc_bh_state(void)
if (__get_cpu_var(bh_accounting).ratelimit++ < 4096)
return;
__get_cpu_var(bh_accounting).ratelimit = 0;
- for_each_cpu(i)
+ for_each_online_cpu(i)
tot += per_cpu(bh_accounting, i).nr;
buffer_heads_over_limit = (tot > max_buffer_heads);
}
@@ -3127,6 +3122,9 @@ static void buffer_exit_cpu(int cpu)
brelse(b->bhs[i]);
b->bhs[i] = NULL;
}
+ get_cpu_var(bh_accounting).nr += per_cpu(bh_accounting, cpu).nr;
+ per_cpu(bh_accounting, cpu).nr = 0;
+ put_cpu_var(bh_accounting);
}
static int buffer_cpu_notify(struct notifier_block *self,
@@ -3143,8 +3141,11 @@ void __init buffer_init(void)
int nrpages;
bh_cachep = kmem_cache_create("buffer_head",
- sizeof(struct buffer_head), 0,
- SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_buffer_head, NULL);
+ sizeof(struct buffer_head), 0,
+ (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
+ SLAB_MEM_SPREAD),
+ init_buffer_head,
+ NULL);
/*
* Limit the bh occupancy to 10% of ZONE_NORMAL
diff --git a/fs/char_dev.c b/fs/char_dev.c
index 5c36345c9bf..8c6eb04d31e 100644
--- a/fs/char_dev.c
+++ b/fs/char_dev.c
@@ -146,12 +146,10 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor,
int ret = 0;
int i;
- cd = kmalloc(sizeof(struct char_device_struct), GFP_KERNEL);
+ cd = kzalloc(sizeof(struct char_device_struct), GFP_KERNEL);
if (cd == NULL)
return ERR_PTR(-ENOMEM);
- memset(cd, 0, sizeof(struct char_device_struct));
-
mutex_lock(&chrdevs_lock);
/* temporary */
@@ -466,9 +464,8 @@ static struct kobj_type ktype_cdev_dynamic = {
struct cdev *cdev_alloc(void)
{
- struct cdev *p = kmalloc(sizeof(struct cdev), GFP_KERNEL);
+ struct cdev *p = kzalloc(sizeof(struct cdev), GFP_KERNEL);
if (p) {
- memset(p, 0, sizeof(struct cdev));
p->kobj.ktype = &ktype_cdev_dynamic;
INIT_LIST_HEAD(&p->list);
kobject_init(&p->kobj);
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 79eeccd0437..221b3334b73 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -479,7 +479,7 @@ cifs_get_sb(struct file_system_type *fs_type,
sb->s_flags = flags;
- rc = cifs_read_super(sb, data, dev_name, flags & MS_VERBOSE ? 1 : 0);
+ rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
if (rc) {
up_write(&sb->s_umount);
deactivate_super(sb);
@@ -695,7 +695,8 @@ cifs_init_inodecache(void)
{
cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
sizeof (struct cifsInodeInfo),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
cifs_init_once, NULL);
if (cifs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index b41e8b37965..a243fe2792d 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -4908,7 +4908,7 @@ SetEARetry:
parm_data->list_len = cpu_to_le32(count);
parm_data->list[0].EA_flags = 0;
/* we checked above that name len is less than 255 */
- parm_data->list[0].name_len = (__u8)name_len;;
+ parm_data->list[0].name_len = (__u8)name_len;
/* EA names are always ASCII */
if(ea_name)
strncpy(parm_data->list[0].name,ea_name,name_len);
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index fed55e3c53d..632561dd9c5 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -138,9 +138,9 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
- down(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -317,9 +317,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
- down(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL)
rc = -ENOMEM;
else if (pTcon->ses->capabilities & CAP_UNIX) {
diff --git a/fs/cifs/fcntl.c b/fs/cifs/fcntl.c
index a7a47bb36bf..ec4dfe9bf5e 100644
--- a/fs/cifs/fcntl.c
+++ b/fs/cifs/fcntl.c
@@ -86,9 +86,9 @@ int cifs_dir_notify(struct file * file, unsigned long arg)
cifs_sb = CIFS_SB(file->f_dentry->d_sb);
pTcon = cifs_sb->tcon;
- down(&file->f_dentry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry);
- up(&file->f_dentry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) {
rc = -ENOMEM;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 675bd256829..165d6742638 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -203,9 +203,9 @@ int cifs_open(struct inode *inode, struct file *file)
}
}
- down(&inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry);
- up(&inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 59359911f48..ff93a9f81d1 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -574,9 +574,9 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
/* Unlink can be called from rename so we can not grab the sem here
since we deadlock otherwise */
-/* down(&direntry->d_sb->s_vfs_rename_sem);*/
+/* mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);*/
full_path = build_path_from_dentry(direntry);
-/* up(&direntry->d_sb->s_vfs_rename_sem);*/
+/* mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);*/
if (full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -718,9 +718,9 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, int mode)
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
- down(&inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -803,9 +803,9 @@ int cifs_rmdir(struct inode *inode, struct dentry *direntry)
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
- down(&inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if (full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -1137,9 +1137,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
rc = 0;
}
- down(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if (full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
diff --git a/fs/cifs/link.c b/fs/cifs/link.c
index 0f99aae3316..8d0da7c87c7 100644
--- a/fs/cifs/link.c
+++ b/fs/cifs/link.c
@@ -48,10 +48,10 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
/* No need to check for cross device links since server will do that
BB note DFS case in future though (when we may have to check) */
- down(&inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
fromName = build_path_from_dentry(old_file);
toName = build_path_from_dentry(direntry);
- up(&inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if((fromName == NULL) || (toName == NULL)) {
rc = -ENOMEM;
goto cifs_hl_exit;
@@ -103,9 +103,9 @@ cifs_follow_link(struct dentry *direntry, struct nameidata *nd)
xid = GetXid();
- down(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&direntry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&direntry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&direntry->d_sb->s_vfs_rename_mutex);
if (!full_path)
goto out_no_free;
@@ -164,9 +164,9 @@ cifs_symlink(struct inode *inode, struct dentry *direntry, const char *symname)
cifs_sb = CIFS_SB(inode->i_sb);
pTcon = cifs_sb->tcon;
- down(&inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&inode->i_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
@@ -232,9 +232,9 @@ cifs_readlink(struct dentry *direntry, char __user *pBuffer, int buflen)
/* BB would it be safe against deadlock to grab this sem
even though rename itself grabs the sem and calls lookup? */
-/* down(&inode->i_sb->s_vfs_rename_sem);*/
+/* mutex_lock(&inode->i_sb->s_vfs_rename_mutex);*/
full_path = build_path_from_dentry(direntry);
-/* up(&inode->i_sb->s_vfs_rename_sem);*/
+/* mutex_unlock(&inode->i_sb->s_vfs_rename_mutex);*/
if(full_path == NULL) {
FreeXid(xid);
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c
index 288cc048d37..edb3b6eb34b 100644
--- a/fs/cifs/readdir.c
+++ b/fs/cifs/readdir.c
@@ -404,9 +404,9 @@ static int initiate_cifs_search(const int xid, struct file *file)
if(pTcon == NULL)
return -EINVAL;
- down(&file->f_dentry->d_sb->s_vfs_rename_sem);
+ mutex_lock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(file->f_dentry);
- up(&file->f_dentry->d_sb->s_vfs_rename_sem);
+ mutex_unlock(&file->f_dentry->d_sb->s_vfs_rename_mutex);
if(full_path == NULL) {
return -ENOMEM;
diff --git a/fs/cifs/xattr.c b/fs/cifs/xattr.c
index 777e3363c2a..3938444d87b 100644
--- a/fs/cifs/xattr.c
+++ b/fs/cifs/xattr.c
@@ -62,9 +62,9 @@ int cifs_removexattr(struct dentry * direntry, const char * ea_name)
cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon;
- down(&sb->s_vfs_rename_sem);
+ mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&sb->s_vfs_rename_sem);
+ mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -116,9 +116,9 @@ int cifs_setxattr(struct dentry * direntry, const char * ea_name,
cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon;
- down(&sb->s_vfs_rename_sem);
+ mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&sb->s_vfs_rename_sem);
+ mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -223,9 +223,9 @@ ssize_t cifs_getxattr(struct dentry * direntry, const char * ea_name,
cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon;
- down(&sb->s_vfs_rename_sem);
+ mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&sb->s_vfs_rename_sem);
+ mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
@@ -341,9 +341,9 @@ ssize_t cifs_listxattr(struct dentry * direntry, char * data, size_t buf_size)
cifs_sb = CIFS_SB(sb);
pTcon = cifs_sb->tcon;
- down(&sb->s_vfs_rename_sem);
+ mutex_lock(&sb->s_vfs_rename_mutex);
full_path = build_path_from_dentry(direntry);
- up(&sb->s_vfs_rename_sem);
+ mutex_unlock(&sb->s_vfs_rename_mutex);
if(full_path == NULL) {
FreeXid(xid);
return -ENOMEM;
diff --git a/fs/coda/cache.c b/fs/coda/cache.c
index c607d923350..5d052713326 100644
--- a/fs/coda/cache.c
+++ b/fs/coda/cache.c
@@ -51,7 +51,7 @@ void coda_cache_clear_all(struct super_block *sb)
struct coda_sb_info *sbi;
sbi = coda_sbp(sb);
- if (!sbi) BUG();
+ BUG_ON(!sbi);
atomic_inc(&permission_epoch);
}
diff --git a/fs/coda/cnode.c b/fs/coda/cnode.c
index 23aeef5aa81..4c9fecbfa91 100644
--- a/fs/coda/cnode.c
+++ b/fs/coda/cnode.c
@@ -120,8 +120,7 @@ void coda_replace_fid(struct inode *inode, struct CodaFid *oldfid,
cii = ITOC(inode);
- if (!coda_fideq(&cii->c_fid, oldfid))
- BUG();
+ BUG_ON(!coda_fideq(&cii->c_fid, oldfid));
/* replace fid and rehash inode */
/* XXX we probably need to hold some lock here! */
diff --git a/fs/coda/coda_int.h b/fs/coda/coda_int.h
new file mode 100644
index 00000000000..9e6338fea51
--- /dev/null
+++ b/fs/coda/coda_int.h
@@ -0,0 +1,13 @@
+#ifndef _CODA_INT_
+#define _CODA_INT_
+
+extern struct file_system_type coda_fs_type;
+
+void coda_destroy_inodecache(void);
+int coda_init_inodecache(void);
+int coda_fsync(struct file *coda_file, struct dentry *coda_dentry,
+ int datasync);
+
+#endif /* _CODA_INT_ */
+
+
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 8f1a517f8b4..54f76de8a68 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -27,6 +27,8 @@
#include <linux/coda_cache.h>
#include <linux/coda_proc.h>
+#include "coda_int.h"
+
/* dir inode-ops */
static int coda_create(struct inode *dir, struct dentry *new, int mode, struct nameidata *nd);
static struct dentry *coda_lookup(struct inode *dir, struct dentry *target, struct nameidata *nd);
@@ -50,7 +52,6 @@ static int coda_dentry_delete(struct dentry *);
/* support routines */
static int coda_venus_readdir(struct file *filp, filldir_t filldir,
void *dirent, struct dentry *dir);
-int coda_fsync(struct file *, struct dentry *dentry, int datasync);
/* same as fs/bad_inode.c */
static int coda_return_EIO(void)
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 30b4630bd73..146a991d6eb 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -24,6 +24,8 @@
#include <linux/coda_psdev.h>
#include <linux/coda_proc.h>
+#include "coda_int.h"
+
/* if CODA_STORE fails with EOPNOTSUPP, venus clearly doesn't support
* CODA_STORE/CODA_RELEASE and we fall back on using the CODA_CLOSE upcall */
static int use_coda_close;
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 04a73fb4848..ada1a81df6b 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -31,6 +31,8 @@
#include <linux/coda_fs_i.h>
#include <linux/coda_cache.h>
+#include "coda_int.h"
+
/* VFS super_block ops */
static void coda_clear_inode(struct inode *);
static void coda_put_super(struct super_block *);
@@ -69,7 +71,7 @@ int coda_init_inodecache(void)
{
coda_inode_cachep = kmem_cache_create("coda_inode_cache",
sizeof(struct coda_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
init_once, NULL);
if (coda_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c
index 6a3df88accf..98c74fe2e13 100644
--- a/fs/coda/psdev.c
+++ b/fs/coda/psdev.c
@@ -48,12 +48,9 @@
#include <linux/coda_psdev.h>
#include <linux/coda_proc.h>
-#define upc_free(r) kfree(r)
+#include "coda_int.h"
-/*
- * Coda stuff
- */
-extern struct file_system_type coda_fs_type;
+#define upc_free(r) kfree(r)
/* statistics */
int coda_hard; /* allows signals during upcalls */
@@ -394,8 +391,6 @@ out:
MODULE_AUTHOR("Peter J. Braam <braam@cs.cmu.edu>");
MODULE_LICENSE("GPL");
-extern int coda_init_inodecache(void);
-extern void coda_destroy_inodecache(void);
static int __init init_coda(void)
{
int status;
diff --git a/fs/compat.c b/fs/compat.c
index 5333c7d7427..ef5a0771592 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -114,6 +114,7 @@ asmlinkage long compat_sys_newlstat(char __user * filename,
return error;
}
+#ifndef __ARCH_WANT_STAT64
asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
struct compat_stat __user *statbuf, int flag)
{
@@ -134,6 +135,7 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
out:
return error;
}
+#endif
asmlinkage long compat_sys_newfstat(unsigned int fd,
struct compat_stat __user * statbuf)
@@ -1474,10 +1476,9 @@ int compat_do_execve(char * filename,
int i;
retval = -ENOMEM;
- bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
+ bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
if (!bprm)
goto out_ret;
- memset(bprm, 0, sizeof(*bprm));
file = open_exec(filename);
retval = PTR_ERR(file);
@@ -2168,9 +2169,12 @@ asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *
default:
err = -EINVAL;
- goto done;
+ break;
}
+ if (err)
+ goto done;
+
oldfs = get_fs();
set_fs(KERNEL_DS);
/* The __user pointer casts are valid because of the set_fs() */
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index c666769a875..d2c38875ab2 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -72,6 +72,7 @@
#include <linux/i2c-dev.h>
#include <linux/wireless.h>
#include <linux/atalk.h>
+#include <linux/blktrace_api.h>
#include <net/sock.h> /* siocdevprivate_ioctl */
#include <net/bluetooth/bluetooth.h>
@@ -1521,8 +1522,7 @@ static struct {
{ ATM_QUERYLOOP32, ATM_QUERYLOOP }
};
-#define NR_ATM_IOCTL (sizeof(atm_ioctl_map)/sizeof(atm_ioctl_map[0]))
-
+#define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map)
static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg)
{
@@ -1823,7 +1823,7 @@ static struct {
{ FDWERRORGET32, FDWERRORGET }
};
-#define NR_FD_IOCTL_TRANS (sizeof(fd_ioctl_trans_table)/sizeof(fd_ioctl_trans_table[0]))
+#define NR_FD_IOCTL_TRANS ARRAY_SIZE(fd_ioctl_trans_table)
static int fd_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
{
diff --git a/fs/dcache.c b/fs/dcache.c
index 11dc83092d4..93958464850 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -325,10 +325,13 @@ static struct dentry * __d_find_alias(struct inode *inode, int want_discon)
struct dentry * d_find_alias(struct inode *inode)
{
- struct dentry *de;
- spin_lock(&dcache_lock);
- de = __d_find_alias(inode, 0);
- spin_unlock(&dcache_lock);
+ struct dentry *de = NULL;
+
+ if (!list_empty(&inode->i_dentry)) {
+ spin_lock(&dcache_lock);
+ de = __d_find_alias(inode, 0);
+ spin_unlock(&dcache_lock);
+ }
return de;
}
@@ -486,6 +489,7 @@ repeat:
continue;
}
prune_one_dentry(dentry);
+ cond_resched_lock(&dcache_lock);
goto repeat;
}
spin_unlock(&dcache_lock);
@@ -799,6 +803,7 @@ void d_instantiate(struct dentry *entry, struct inode * inode)
if (inode)
list_add(&entry->d_alias, &inode->i_dentry);
entry->d_inode = inode;
+ fsnotify_d_instantiate(entry, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(entry, inode);
}
@@ -850,6 +855,7 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
list_add(&entry->d_alias, &inode->i_dentry);
do_negative:
entry->d_inode = inode;
+ fsnotify_d_instantiate(entry, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(entry, inode);
return NULL;
@@ -980,6 +986,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
new = __d_find_alias(inode, 1);
if (new) {
BUG_ON(!(new->d_flags & DCACHE_DISCONNECTED));
+ fsnotify_d_instantiate(new, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(new, inode);
d_rehash(dentry);
@@ -989,6 +996,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
/* d_instantiate takes dcache_lock, so we do it by hand */
list_add(&dentry->d_alias, &inode->i_dentry);
dentry->d_inode = inode;
+ fsnotify_d_instantiate(dentry, inode);
spin_unlock(&dcache_lock);
security_d_instantiate(dentry, inode);
d_rehash(dentry);
@@ -1173,6 +1181,9 @@ void d_delete(struct dentry * dentry)
spin_lock(&dentry->d_lock);
isdir = S_ISDIR(dentry->d_inode->i_mode);
if (atomic_read(&dentry->d_count) == 1) {
+ /* remove this and other inotify debug checks after 2.6.18 */
+ dentry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED;
+
dentry_iput(dentry);
fsnotify_nameremove(dentry, isdir);
return;
@@ -1339,6 +1350,7 @@ already_unhashed:
list_add(&dentry->d_u.d_child, &dentry->d_parent->d_subdirs);
spin_unlock(&target->d_lock);
+ fsnotify_d_move(dentry);
spin_unlock(&dentry->d_lock);
write_sequnlock(&rename_lock);
spin_unlock(&dcache_lock);
@@ -1682,7 +1694,8 @@ static void __init dcache_init(unsigned long mempages)
dentry_cache = kmem_cache_create("dentry_cache",
sizeof(struct dentry),
0,
- SLAB_RECLAIM_ACCOUNT|SLAB_PANIC,
+ (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
+ SLAB_MEM_SPREAD),
NULL, NULL);
set_shrinker(DEFAULT_SEEKS, shrink_dcache_memory);
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index bfb8a230bac..14c5620b5ca 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -18,6 +18,7 @@
#include <linux/mount.h>
#include <linux/tty.h>
#include <linux/devpts_fs.h>
+#include <linux/parser.h>
#define DEVPTS_SUPER_MAGIC 0x1cd1
@@ -32,39 +33,60 @@ static struct {
umode_t mode;
} config = {.mode = 0600};
+enum {
+ Opt_uid, Opt_gid, Opt_mode,
+ Opt_err
+};
+
+static match_table_t tokens = {
+ {Opt_uid, "uid=%u"},
+ {Opt_gid, "gid=%u"},
+ {Opt_mode, "mode=%o"},
+ {Opt_err, NULL}
+};
+
static int devpts_remount(struct super_block *sb, int *flags, char *data)
{
- int setuid = 0;
- int setgid = 0;
- uid_t uid = 0;
- gid_t gid = 0;
- umode_t mode = 0600;
- char *this_char;
-
- this_char = NULL;
- while ((this_char = strsep(&data, ",")) != NULL) {
- int n;
- char dummy;
- if (!*this_char)
+ char *p;
+
+ config.setuid = 0;
+ config.setgid = 0;
+ config.uid = 0;
+ config.gid = 0;
+ config.mode = 0600;
+
+ while ((p = strsep(&data, ",")) != NULL) {
+ substring_t args[MAX_OPT_ARGS];
+ int token;
+ int option;
+
+ if (!*p)
continue;
- if (sscanf(this_char, "uid=%i%c", &n, &dummy) == 1) {
- setuid = 1;
- uid = n;
- } else if (sscanf(this_char, "gid=%i%c", &n, &dummy) == 1) {
- setgid = 1;
- gid = n;
- } else if (sscanf(this_char, "mode=%o%c", &n, &dummy) == 1)
- mode = n & ~S_IFMT;
- else {
- printk("devpts: called with bogus options\n");
+
+ token = match_token(p, tokens, args);
+ switch (token) {
+ case Opt_uid:
+ if (match_int(&args[0], &option))
+ return -EINVAL;
+ config.uid = option;
+ config.setuid = 1;
+ break;
+ case Opt_gid:
+ if (match_int(&args[0], &option))
+ return -EINVAL;
+ config.gid = option;
+ config.setgid = 1;
+ break;
+ case Opt_mode:
+ if (match_octal(&args[0], &option))
+ return -EINVAL;
+ config.mode = option & ~S_IFMT;
+ break;
+ default:
+ printk(KERN_ERR "devpts: called with bogus options\n");
return -EINVAL;
}
}
- config.setuid = setuid;
- config.setgid = setgid;
- config.uid = uid;
- config.gid = gid;
- config.mode = mode;
return 0;
}
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 27f3e787fac..235ed8d1f11 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -129,6 +129,7 @@ struct dio {
/* AIO related stuff */
struct kiocb *iocb; /* kiocb */
int is_async; /* is IO async ? */
+ int io_error; /* IO error in completion path */
ssize_t result; /* IO result */
};
@@ -250,6 +251,10 @@ static void finished_one_bio(struct dio *dio)
((offset + transferred) > dio->i_size))
transferred = dio->i_size - offset;
+ /* check for error in completion path */
+ if (dio->io_error)
+ transferred = dio->io_error;
+
dio_complete(dio, offset, transferred);
/* Complete AIO later if falling back to buffered i/o */
@@ -406,7 +411,7 @@ static int dio_bio_complete(struct dio *dio, struct bio *bio)
int page_no;
if (!uptodate)
- dio->result = -EIO;
+ dio->io_error = -EIO;
if (dio->is_async && dio->rw == READ) {
bio_check_pages_dirty(bio); /* transfers ownership */
@@ -971,6 +976,7 @@ direct_io_worker(int rw, struct kiocb *iocb, struct inode *inode,
dio->next_block_for_io = -1;
dio->page_errors = 0;
+ dio->io_error = 0;
dio->result = 0;
dio->iocb = iocb;
dio->i_size = i_size_read(inode);
diff --git a/fs/dquot.c b/fs/dquot.c
index 1966c890b48..6b388692093 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -103,12 +103,12 @@
* (these locking rules also apply for S_NOQUOTA flag in the inode - note that
* for altering the flag i_mutex is also needed). If operation is holding
* reference to dquot in other way (e.g. quotactl ops) it must be guarded by
- * dqonoff_sem.
+ * dqonoff_mutex.
* This locking assures that:
* a) update/access to dquot pointers in inode is serialized
* b) everyone is guarded against invalidate_dquots()
*
- * Each dquot has its dq_lock semaphore. Locked dquots might not be referenced
+ * Each dquot has its dq_lock mutex. Locked dquots might not be referenced
* from inodes (dquot_alloc_space() and such don't check the dq_lock).
* Currently dquot is locked only when it is being read to memory (or space for
* it is being allocated) on the first dqget() and when it is being released on
@@ -118,9 +118,9 @@
* spinlock to internal buffers before writing.
*
* Lock ordering (including related VFS locks) is the following:
- * i_mutex > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem >
- * > dquot->dq_lock > dqio_sem
- * i_mutex on quota files is special (it's below dqio_sem)
+ * i_mutex > dqonoff_sem > journal_lock > dqptr_sem > dquot->dq_lock >
+ * dqio_mutex
+ * i_mutex on quota files is special (it's below dqio_mutex)
*/
static DEFINE_SPINLOCK(dq_list_lock);
@@ -281,8 +281,8 @@ static inline void remove_inuse(struct dquot *dquot)
static void wait_on_dquot(struct dquot *dquot)
{
- down(&dquot->dq_lock);
- up(&dquot->dq_lock);
+ mutex_lock(&dquot->dq_lock);
+ mutex_unlock(&dquot->dq_lock);
}
#define mark_dquot_dirty(dquot) ((dquot)->dq_sb->dq_op->mark_dirty(dquot))
@@ -321,8 +321,8 @@ int dquot_acquire(struct dquot *dquot)
int ret = 0, ret2 = 0;
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
- down(&dquot->dq_lock);
- down(&dqopt->dqio_sem);
+ mutex_lock(&dquot->dq_lock);
+ mutex_lock(&dqopt->dqio_mutex);
if (!test_bit(DQ_READ_B, &dquot->dq_flags))
ret = dqopt->ops[dquot->dq_type]->read_dqblk(dquot);
if (ret < 0)
@@ -343,8 +343,8 @@ int dquot_acquire(struct dquot *dquot)
}
set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
out_iolock:
- up(&dqopt->dqio_sem);
- up(&dquot->dq_lock);
+ mutex_unlock(&dqopt->dqio_mutex);
+ mutex_unlock(&dquot->dq_lock);
return ret;
}
@@ -356,7 +356,7 @@ int dquot_commit(struct dquot *dquot)
int ret = 0, ret2 = 0;
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
- down(&dqopt->dqio_sem);
+ mutex_lock(&dqopt->dqio_mutex);
spin_lock(&dq_list_lock);
if (!clear_dquot_dirty(dquot)) {
spin_unlock(&dq_list_lock);
@@ -373,7 +373,7 @@ int dquot_commit(struct dquot *dquot)
ret = ret2;
}
out_sem:
- up(&dqopt->dqio_sem);
+ mutex_unlock(&dqopt->dqio_mutex);
return ret;
}
@@ -385,11 +385,11 @@ int dquot_release(struct dquot *dquot)
int ret = 0, ret2 = 0;
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
- down(&dquot->dq_lock);
+ mutex_lock(&dquot->dq_lock);
/* Check whether we are not racing with some other dqget() */
if (atomic_read(&dquot->dq_count) > 1)
goto out_dqlock;
- down(&dqopt->dqio_sem);
+ mutex_lock(&dqopt->dqio_mutex);
if (dqopt->ops[dquot->dq_type]->release_dqblk) {
ret = dqopt->ops[dquot->dq_type]->release_dqblk(dquot);
/* Write the info */
@@ -399,31 +399,57 @@ int dquot_release(struct dquot *dquot)
ret = ret2;
}
clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
- up(&dqopt->dqio_sem);
+ mutex_unlock(&dqopt->dqio_mutex);
out_dqlock:
- up(&dquot->dq_lock);
+ mutex_unlock(&dquot->dq_lock);
return ret;
}
/* Invalidate all dquots on the list. Note that this function is called after
* quota is disabled and pointers from inodes removed so there cannot be new
- * quota users. Also because we hold dqonoff_sem there can be no quota users
- * for this sb+type at all. */
+ * quota users. There can still be some users of quotas due to inodes being
+ * just deleted or pruned by prune_icache() (those are not attached to any
+ * list). We have to wait for such users.
+ */
static void invalidate_dquots(struct super_block *sb, int type)
{
struct dquot *dquot, *tmp;
+restart:
spin_lock(&dq_list_lock);
list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
if (dquot->dq_sb != sb)
continue;
if (dquot->dq_type != type)
continue;
-#ifdef __DQUOT_PARANOIA
- if (atomic_read(&dquot->dq_count))
- BUG();
-#endif
- /* Quota now has no users and it has been written on last dqput() */
+ /* Wait for dquot users */
+ if (atomic_read(&dquot->dq_count)) {
+ DEFINE_WAIT(wait);
+
+ atomic_inc(&dquot->dq_count);
+ prepare_to_wait(&dquot->dq_wait_unused, &wait,
+ TASK_UNINTERRUPTIBLE);
+ spin_unlock(&dq_list_lock);
+ /* Once dqput() wakes us up, we know it's time to free
+ * the dquot.
+ * IMPORTANT: we rely on the fact that there is always
+ * at most one process waiting for dquot to free.
+ * Otherwise dq_count would be > 1 and we would never
+ * wake up.
+ */
+ if (atomic_read(&dquot->dq_count) > 1)
+ schedule();
+ finish_wait(&dquot->dq_wait_unused, &wait);
+ dqput(dquot);
+ /* At this moment dquot() need not exist (it could be
+ * reclaimed by prune_dqcache(). Hence we must
+ * restart. */
+ goto restart;
+ }
+ /*
+ * Quota now has no users and it has been written on last
+ * dqput()
+ */
remove_dquot_hash(dquot);
remove_free_dquot(dquot);
remove_inuse(dquot);
@@ -439,7 +465,7 @@ int vfs_quota_sync(struct super_block *sb, int type)
struct quota_info *dqopt = sb_dqopt(sb);
int cnt;
- down(&dqopt->dqonoff_sem);
+ mutex_lock(&dqopt->dqonoff_mutex);
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
if (type != -1 && cnt != type)
continue;
@@ -474,7 +500,7 @@ int vfs_quota_sync(struct super_block *sb, int type)
spin_lock(&dq_list_lock);
dqstats.syncs++;
spin_unlock(&dq_list_lock);
- up(&dqopt->dqonoff_sem);
+ mutex_unlock(&dqopt->dqonoff_mutex);
return 0;
}
@@ -515,7 +541,7 @@ static int shrink_dqcache_memory(int nr, gfp_t gfp_mask)
/*
* Put reference to dquot
* NOTE: If you change this function please check whether dqput_blocks() works right...
- * MUST be called with either dqptr_sem or dqonoff_sem held
+ * MUST be called with either dqptr_sem or dqonoff_mutex held
*/
static void dqput(struct dquot *dquot)
{
@@ -540,6 +566,10 @@ we_slept:
if (atomic_read(&dquot->dq_count) > 1) {
/* We have more than one user... nothing to do */
atomic_dec(&dquot->dq_count);
+ /* Releasing dquot during quotaoff phase? */
+ if (!sb_has_quota_enabled(dquot->dq_sb, dquot->dq_type) &&
+ atomic_read(&dquot->dq_count) == 1)
+ wake_up(&dquot->dq_wait_unused);
spin_unlock(&dq_list_lock);
return;
}
@@ -576,11 +606,12 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
return NODQUOT;
memset((caddr_t)dquot, 0, sizeof(struct dquot));
- sema_init(&dquot->dq_lock, 1);
+ mutex_init(&dquot->dq_lock);
INIT_LIST_HEAD(&dquot->dq_free);
INIT_LIST_HEAD(&dquot->dq_inuse);
INIT_HLIST_NODE(&dquot->dq_hash);
INIT_LIST_HEAD(&dquot->dq_dirty);
+ init_waitqueue_head(&dquot->dq_wait_unused);
dquot->dq_sb = sb;
dquot->dq_type = type;
atomic_set(&dquot->dq_count, 1);
@@ -590,7 +621,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
/*
* Get reference to dquot
- * MUST be called with either dqptr_sem or dqonoff_sem held
+ * MUST be called with either dqptr_sem or dqonoff_mutex held
*/
static struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
{
@@ -656,7 +687,7 @@ static int dqinit_needed(struct inode *inode, int type)
return 0;
}
-/* This routine is guarded by dqonoff_sem semaphore */
+/* This routine is guarded by dqonoff_mutex mutex */
static void add_dquot_ref(struct super_block *sb, int type)
{
struct list_head *p;
@@ -732,13 +763,9 @@ static void drop_dquot_ref(struct super_block *sb, int type)
{
LIST_HEAD(tofree_head);
- /* We need to be guarded against prune_icache to reach all the
- * inodes - otherwise some can be on the local list of prune_icache */
- down(&iprune_sem);
down_write(&sb_dqopt(sb)->dqptr_sem);
remove_dquot_ref(sb, type, &tofree_head);
up_write(&sb_dqopt(sb)->dqptr_sem);
- up(&iprune_sem);
put_dquot_list(&tofree_head);
}
@@ -938,8 +965,8 @@ int dquot_initialize(struct inode *inode, int type)
unsigned int id = 0;
int cnt, ret = 0;
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode))
return 0;
down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1002,8 +1029,8 @@ int dquot_alloc_space(struct inode *inode, qsize_t number, int warn)
int cnt, ret = NO_QUOTA;
char warntype[MAXQUOTAS];
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode)) {
out_add:
inode_add_bytes(inode, number);
@@ -1051,8 +1078,8 @@ int dquot_alloc_inode(const struct inode *inode, unsigned long number)
int cnt, ret = NO_QUOTA;
char warntype[MAXQUOTAS];
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode))
return QUOTA_OK;
for (cnt = 0; cnt < MAXQUOTAS; cnt++)
@@ -1095,8 +1122,8 @@ int dquot_free_space(struct inode *inode, qsize_t number)
{
unsigned int cnt;
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode)) {
out_sub:
inode_sub_bytes(inode, number);
@@ -1131,8 +1158,8 @@ int dquot_free_inode(const struct inode *inode, unsigned long number)
{
unsigned int cnt;
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode))
return QUOTA_OK;
down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
@@ -1171,8 +1198,8 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
chgid = (iattr->ia_valid & ATTR_GID) && inode->i_gid != iattr->ia_gid;
char warntype[MAXQUOTAS];
- /* First test before acquiring semaphore - solves deadlocks when we
- * re-enter the quota code and are already holding the semaphore */
+ /* First test before acquiring mutex - solves deadlocks when we
+ * re-enter the quota code and are already holding the mutex */
if (IS_NOQUOTA(inode))
return QUOTA_OK;
/* Clear the arrays */
@@ -1266,9 +1293,9 @@ int dquot_commit_info(struct super_block *sb, int type)
int ret;
struct quota_info *dqopt = sb_dqopt(sb);
- down(&dqopt->dqio_sem);
+ mutex_lock(&dqopt->dqio_mutex);
ret = dqopt->ops[type]->write_file_info(sb, type);
- up(&dqopt->dqio_sem);
+ mutex_unlock(&dqopt->dqio_mutex);
return ret;
}
@@ -1324,7 +1351,7 @@ int vfs_quota_off(struct super_block *sb, int type)
struct inode *toputinode[MAXQUOTAS];
/* We need to serialize quota_off() for device */
- down(&dqopt->dqonoff_sem);
+ mutex_lock(&dqopt->dqonoff_mutex);
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
toputinode[cnt] = NULL;
if (type != -1 && cnt != type)
@@ -1353,7 +1380,7 @@ int vfs_quota_off(struct super_block *sb, int type)
dqopt->info[cnt].dqi_bgrace = 0;
dqopt->ops[cnt] = NULL;
}
- up(&dqopt->dqonoff_sem);
+ mutex_unlock(&dqopt->dqonoff_mutex);
/* Sync the superblock so that buffers with quota data are written to
* disk (and so userspace sees correct data afterwards). */
if (sb->s_op->sync_fs)
@@ -1366,7 +1393,7 @@ int vfs_quota_off(struct super_block *sb, int type)
* changes done by userspace on the next quotaon() */
for (cnt = 0; cnt < MAXQUOTAS; cnt++)
if (toputinode[cnt]) {
- down(&dqopt->dqonoff_sem);
+ mutex_lock(&dqopt->dqonoff_mutex);
/* If quota was reenabled in the meantime, we have
* nothing to do */
if (!sb_has_quota_enabled(sb, cnt)) {
@@ -1378,7 +1405,7 @@ int vfs_quota_off(struct super_block *sb, int type)
mark_inode_dirty(toputinode[cnt]);
iput(toputinode[cnt]);
}
- up(&dqopt->dqonoff_sem);
+ mutex_unlock(&dqopt->dqonoff_mutex);
}
if (sb->s_bdev)
invalidate_bdev(sb->s_bdev, 0);
@@ -1419,7 +1446,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
/* And now flush the block cache so that kernel sees the changes */
invalidate_bdev(sb->s_bdev, 0);
mutex_lock(&inode->i_mutex);
- down(&dqopt->dqonoff_sem);
+ mutex_lock(&dqopt->dqonoff_mutex);
if (sb_has_quota_enabled(sb, type)) {
error = -EBUSY;
goto out_lock;
@@ -1444,17 +1471,17 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
dqopt->ops[type] = fmt->qf_ops;
dqopt->info[type].dqi_format = fmt;
INIT_LIST_HEAD(&dqopt->info[type].dqi_dirty_list);
- down(&dqopt->dqio_sem);
+ mutex_lock(&dqopt->dqio_mutex);
if ((error = dqopt->ops[type]->read_file_info(sb, type)) < 0) {
- up(&dqopt->dqio_sem);
+ mutex_unlock(&dqopt->dqio_mutex);
goto out_file_init;
}
- up(&dqopt->dqio_sem);
+ mutex_unlock(&dqopt->dqio_mutex);
mutex_unlock(&inode->i_mutex);
set_enable_flags(dqopt, type);
add_dquot_ref(sb, type);
- up(&dqopt->dqonoff_sem);
+ mutex_unlock(&dqopt->dqonoff_mutex);
return 0;
@@ -1462,7 +1489,7 @@ out_file_init:
dqopt->files[type] = NULL;
iput(inode);
out_lock:
- up(&dqopt->dqonoff_sem);
+ mutex_unlock(&dqopt->dqonoff_mutex);
if (oldflags != -1) {
down_write(&dqopt->dqptr_sem);
/* Set the flags back (in the case of accidental quotaon()
@@ -1550,14 +1577,14 @@ int vfs_get_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
{
struct dquot *dquot;
- down(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
if (!(dquot = dqget(sb, id, type))) {
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return -ESRCH;
}
do_get_dqblk(dquot, di);
dqput(dquot);
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return 0;
}
@@ -1619,14 +1646,14 @@ int vfs_set_dqblk(struct super_block *sb, int type, qid_t id, struct if_dqblk *d
{
struct dquot *dquot;
- down(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
if (!(dquot = dqget(sb, id, type))) {
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return -ESRCH;
}
do_set_dqblk(dquot, di);
dqput(dquot);
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return 0;
}
@@ -1635,9 +1662,9 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
{
struct mem_dqinfo *mi;
- down(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
if (!sb_has_quota_enabled(sb, type)) {
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return -ESRCH;
}
mi = sb_dqopt(sb)->info + type;
@@ -1647,7 +1674,7 @@ int vfs_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
ii->dqi_flags = mi->dqi_flags & DQF_MASK;
ii->dqi_valid = IIF_ALL;
spin_unlock(&dq_data_lock);
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return 0;
}
@@ -1656,9 +1683,9 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
{
struct mem_dqinfo *mi;
- down(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
if (!sb_has_quota_enabled(sb, type)) {
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return -ESRCH;
}
mi = sb_dqopt(sb)->info + type;
@@ -1673,7 +1700,7 @@ int vfs_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii)
mark_info_dirty(sb, type);
/* Force write to disk */
sb->dq_op->write_info(sb, type);
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
return 0;
}
@@ -1794,7 +1821,8 @@ static int __init dquot_init(void)
dquot_cachep = kmem_cache_create("dquot",
sizeof(struct dquot), sizeof(unsigned long) * 4,
- SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_PANIC,
+ (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD|SLAB_PANIC),
NULL, NULL);
order = 0;
diff --git a/fs/efs/super.c b/fs/efs/super.c
index afc4891feb3..dff623e3ddb 100644
--- a/fs/efs/super.c
+++ b/fs/efs/super.c
@@ -81,7 +81,7 @@ static int init_inodecache(void)
{
efs_inode_cachep = kmem_cache_create("efs_inode_cache",
sizeof(struct efs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
init_once, NULL);
if (efs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/eventpoll.c b/fs/eventpoll.c
index 4284cd31eba..a0f682cdd03 100644
--- a/fs/eventpoll.c
+++ b/fs/eventpoll.c
@@ -34,6 +34,7 @@
#include <linux/eventpoll.h>
#include <linux/mount.h>
#include <linux/bitops.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/system.h>
#include <asm/io.h>
@@ -46,7 +47,7 @@
* LOCKING:
* There are three level of locking required by epoll :
*
- * 1) epsem (semaphore)
+ * 1) epmutex (mutex)
* 2) ep->sem (rw_semaphore)
* 3) ep->lock (rw_lock)
*
@@ -67,9 +68,9 @@
* if a file has been pushed inside an epoll set and it is then
* close()d without a previous call toepoll_ctl(EPOLL_CTL_DEL).
* It is possible to drop the "ep->sem" and to use the global
- * semaphore "epsem" (together with "ep->lock") to have it working,
+ * semaphore "epmutex" (together with "ep->lock") to have it working,
* but having "ep->sem" will make the interface more scalable.
- * Events that require holding "epsem" are very rare, while for
+ * Events that require holding "epmutex" are very rare, while for
* normal operations the epoll private "ep->sem" will guarantee
* a greater scalability.
*/
@@ -274,7 +275,7 @@ static struct super_block *eventpollfs_get_sb(struct file_system_type *fs_type,
/*
* This semaphore is used to serialize ep_free() and eventpoll_release_file().
*/
-static struct semaphore epsem;
+static struct mutex epmutex;
/* Safe wake up implementation */
static struct poll_safewake psw;
@@ -451,15 +452,6 @@ static void ep_poll_safewake(struct poll_safewake *psw, wait_queue_head_t *wq)
}
-/* Used to initialize the epoll bits inside the "struct file" */
-void eventpoll_init_file(struct file *file)
-{
-
- INIT_LIST_HEAD(&file->f_ep_links);
- spin_lock_init(&file->f_ep_lock);
-}
-
-
/*
* This is called from eventpoll_release() to unlink files from the eventpoll
* interface. We need to have this facility to cleanup correctly files that are
@@ -477,10 +469,10 @@ void eventpoll_release_file(struct file *file)
* cleanup path, and this means that noone is using this file anymore.
* The only hit might come from ep_free() but by holding the semaphore
* will correctly serialize the operation. We do need to acquire
- * "ep->sem" after "epsem" because ep_remove() requires it when called
+ * "ep->sem" after "epmutex" because ep_remove() requires it when called
* from anywhere but ep_free().
*/
- down(&epsem);
+ mutex_lock(&epmutex);
while (!list_empty(lsthead)) {
epi = list_entry(lsthead->next, struct epitem, fllink);
@@ -492,7 +484,7 @@ void eventpoll_release_file(struct file *file)
up_write(&ep->sem);
}
- up(&epsem);
+ mutex_unlock(&epmutex);
}
@@ -607,7 +599,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
switch (op) {
case EPOLL_CTL_ADD:
if (!epi) {
- epds.events |= POLLERR | POLLHUP;
+ epds.events |= POLLERR | POLLHUP | POLLRDHUP;
error = ep_insert(ep, &epds, tfile, fd);
} else
@@ -621,7 +613,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event)
break;
case EPOLL_CTL_MOD:
if (epi) {
- epds.events |= POLLERR | POLLHUP;
+ epds.events |= POLLERR | POLLHUP | POLLRDHUP;
error = ep_modify(ep, epi, &epds);
} else
error = -ENOENT;
@@ -819,9 +811,9 @@ static void ep_free(struct eventpoll *ep)
* We do not need to hold "ep->sem" here because the epoll file
* is on the way to be removed and no one has references to it
* anymore. The only hit might come from eventpoll_release_file() but
- * holding "epsem" is sufficent here.
+ * holding "epmutex" is sufficent here.
*/
- down(&epsem);
+ mutex_lock(&epmutex);
/*
* Walks through the whole tree by unregistering poll callbacks.
@@ -843,7 +835,7 @@ static void ep_free(struct eventpoll *ep)
ep_remove(ep, epi);
}
- up(&epsem);
+ mutex_unlock(&epmutex);
}
@@ -1615,7 +1607,7 @@ static int __init eventpoll_init(void)
{
int error;
- init_MUTEX(&epsem);
+ mutex_init(&epmutex);
/* Initialize the structure used to perform safe poll wait head wake ups */
ep_poll_safewake_init(&psw);
diff --git a/fs/exec.c b/fs/exec.c
index 0b515ac5313..995cba3c62b 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -127,7 +127,7 @@ asmlinkage long sys_uselib(const char __user * library)
struct nameidata nd;
int error;
- error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ);
+ error = __user_path_lookup_open(library, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
if (error)
goto out;
@@ -477,7 +477,7 @@ struct file *open_exec(const char *name)
int err;
struct file *file;
- err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ);
+ err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
file = ERR_PTR(err);
if (!err) {
@@ -1143,10 +1143,9 @@ int do_execve(char * filename,
int i;
retval = -ENOMEM;
- bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
+ bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
if (!bprm)
goto out_ret;
- memset(bprm, 0, sizeof(*bprm));
file = open_exec(filename);
retval = PTR_ERR(file);
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 00de0a7312a..11035ac7986 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -138,6 +138,9 @@ extern void ext2_set_inode_flags(struct inode *inode);
extern int ext2_ioctl (struct inode *, struct file *, unsigned int,
unsigned long);
+/* namei.c */
+struct dentry *ext2_get_parent(struct dentry *child);
+
/* super.c */
extern void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index ad1432a2a62..4ca82498532 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -36,22 +36,6 @@
#include "acl.h"
#include "xip.h"
-/*
- * Couple of helper functions - make the code slightly cleaner.
- */
-
-static inline void ext2_inc_count(struct inode *inode)
-{
- inode->i_nlink++;
- mark_inode_dirty(inode);
-}
-
-static inline void ext2_dec_count(struct inode *inode)
-{
- inode->i_nlink--;
- mark_inode_dirty(inode);
-}
-
static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = ext2_add_link(dentry, inode);
@@ -59,7 +43,7 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
d_instantiate(dentry, inode);
return 0;
}
- ext2_dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
return err;
}
@@ -201,7 +185,7 @@ out:
return err;
out_fail:
- ext2_dec_count(inode);
+ inode_dec_link_count(inode);
iput (inode);
goto out;
}
@@ -215,7 +199,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
return -EMLINK;
inode->i_ctime = CURRENT_TIME_SEC;
- ext2_inc_count(inode);
+ inode_inc_link_count(inode);
atomic_inc(&inode->i_count);
return ext2_add_nondir(dentry, inode);
@@ -229,7 +213,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
if (dir->i_nlink >= EXT2_LINK_MAX)
goto out;
- ext2_inc_count(dir);
+ inode_inc_link_count(dir);
inode = ext2_new_inode (dir, S_IFDIR | mode);
err = PTR_ERR(inode);
@@ -243,7 +227,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
else
inode->i_mapping->a_ops = &ext2_aops;
- ext2_inc_count(inode);
+ inode_inc_link_count(inode);
err = ext2_make_empty(inode, dir);
if (err)
@@ -258,11 +242,11 @@ out:
return err;
out_fail:
- ext2_dec_count(inode);
- ext2_dec_count(inode);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
out_dir:
- ext2_dec_count(dir);
+ inode_dec_link_count(dir);
goto out;
}
@@ -282,7 +266,7 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
goto out;
inode->i_ctime = dir->i_ctime;
- ext2_dec_count(inode);
+ inode_dec_link_count(inode);
err = 0;
out:
return err;
@@ -297,8 +281,8 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
err = ext2_unlink(dir, dentry);
if (!err) {
inode->i_size = 0;
- ext2_dec_count(inode);
- ext2_dec_count(dir);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(dir);
}
}
return err;
@@ -338,41 +322,41 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
new_de = ext2_find_entry (new_dir, new_dentry, &new_page);
if (!new_de)
goto out_dir;
- ext2_inc_count(old_inode);
+ inode_inc_link_count(old_inode);
ext2_set_link(new_dir, new_de, new_page, old_inode);
new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de)
new_inode->i_nlink--;
- ext2_dec_count(new_inode);
+ inode_dec_link_count(new_inode);
} else {
if (dir_de) {
err = -EMLINK;
if (new_dir->i_nlink >= EXT2_LINK_MAX)
goto out_dir;
}
- ext2_inc_count(old_inode);
+ inode_inc_link_count(old_inode);
err = ext2_add_link(new_dentry, old_inode);
if (err) {
- ext2_dec_count(old_inode);
+ inode_dec_link_count(old_inode);
goto out_dir;
}
if (dir_de)
- ext2_inc_count(new_dir);
+ inode_inc_link_count(new_dir);
}
/*
* Like most other Unix systems, set the ctime for inodes on a
* rename.
- * ext2_dec_count() will mark the inode dirty.
+ * inode_dec_link_count() will mark the inode dirty.
*/
old_inode->i_ctime = CURRENT_TIME_SEC;
ext2_delete_entry (old_de, old_page);
- ext2_dec_count(old_inode);
+ inode_dec_link_count(old_inode);
if (dir_de) {
ext2_set_link(old_inode, dir_de, dir_page, new_dir);
- ext2_dec_count(old_dir);
+ inode_dec_link_count(old_dir);
}
return 0;
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index cb6f9bd658d..7e30bae174e 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -175,7 +175,8 @@ static int init_inodecache(void)
{
ext2_inode_cachep = kmem_cache_create("ext2_inode_cache",
sizeof(struct ext2_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (ext2_inode_cachep == NULL)
return -ENOMEM;
@@ -210,8 +211,6 @@ static int ext2_show_options(struct seq_file *seq, struct vfsmount *vfs)
if (sbi->s_mount_opt & EXT2_MOUNT_GRPID)
seq_puts(seq, ",grpid");
- else
- seq_puts(seq, ",nogrpid");
#if defined(CONFIG_QUOTA)
if (sbi->s_mount_opt & EXT2_MOUNT_USRQUOTA)
@@ -258,7 +257,6 @@ static struct super_operations ext2_sops = {
* systems, but can be improved upon.
* Currently only get_parent is required.
*/
-struct dentry *ext2_get_parent(struct dentry *child);
static struct export_operations ext2_export_ops = {
.get_parent = ext2_get_parent,
};
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 6250fcdf14a..46623f77666 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -1493,12 +1493,33 @@ static int ext3_group_sparse(int group)
*/
int ext3_bg_has_super(struct super_block *sb, int group)
{
- if (EXT3_HAS_RO_COMPAT_FEATURE(sb,EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)&&
- !ext3_group_sparse(group))
+ if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
+ EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
+ !ext3_group_sparse(group))
return 0;
return 1;
}
+static unsigned long ext3_bg_num_gdb_meta(struct super_block *sb, int group)
+{
+ unsigned long metagroup = group / EXT3_DESC_PER_BLOCK(sb);
+ unsigned long first = metagroup * EXT3_DESC_PER_BLOCK(sb);
+ unsigned long last = first + EXT3_DESC_PER_BLOCK(sb) - 1;
+
+ if (group == first || group == first + 1 || group == last)
+ return 1;
+ return 0;
+}
+
+static unsigned long ext3_bg_num_gdb_nometa(struct super_block *sb, int group)
+{
+ if (EXT3_HAS_RO_COMPAT_FEATURE(sb,
+ EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
+ !ext3_group_sparse(group))
+ return 0;
+ return EXT3_SB(sb)->s_gdb_count;
+}
+
/**
* ext3_bg_num_gdb - number of blocks used by the group table in group
* @sb: superblock for filesystem
@@ -1510,9 +1531,14 @@ int ext3_bg_has_super(struct super_block *sb, int group)
*/
unsigned long ext3_bg_num_gdb(struct super_block *sb, int group)
{
- if (EXT3_HAS_RO_COMPAT_FEATURE(sb,EXT3_FEATURE_RO_COMPAT_SPARSE_SUPER)&&
- !ext3_group_sparse(group))
- return 0;
- return EXT3_SB(sb)->s_gdb_count;
-}
+ unsigned long first_meta_bg =
+ le32_to_cpu(EXT3_SB(sb)->s_es->s_first_meta_bg);
+ unsigned long metagroup = group / EXT3_DESC_PER_BLOCK(sb);
+
+ if (!EXT3_HAS_INCOMPAT_FEATURE(sb,EXT3_FEATURE_INCOMPAT_META_BG) ||
+ metagroup < first_meta_bg)
+ return ext3_bg_num_gdb_nometa(sb,group);
+ return ext3_bg_num_gdb_meta(sb,group);
+
+}
diff --git a/fs/ext3/bitmap.c b/fs/ext3/bitmap.c
index cb16b4c5d5d..ce4f82b9e52 100644
--- a/fs/ext3/bitmap.c
+++ b/fs/ext3/bitmap.c
@@ -7,11 +7,11 @@
* Universite Pierre et Marie Curie (Paris VI)
*/
-#ifdef EXT3FS_DEBUG
-
#include <linux/buffer_head.h>
+#include <linux/jbd.h>
+#include <linux/ext3_fs.h>
-#include "ext3_fs.h"
+#ifdef EXT3FS_DEBUG
static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
diff --git a/fs/ext3/dir.c b/fs/ext3/dir.c
index 832867aef3d..773459164bb 100644
--- a/fs/ext3/dir.c
+++ b/fs/ext3/dir.c
@@ -95,11 +95,10 @@ static int ext3_readdir(struct file * filp,
void * dirent, filldir_t filldir)
{
int error = 0;
- unsigned long offset, blk;
- int i, num, stored;
- struct buffer_head * bh, * tmp, * bha[16];
- struct ext3_dir_entry_2 * de;
- struct super_block * sb;
+ unsigned long offset;
+ int i, stored;
+ struct ext3_dir_entry_2 *de;
+ struct super_block *sb;
int err;
struct inode *inode = filp->f_dentry->d_inode;
int ret = 0;
@@ -124,12 +123,29 @@ static int ext3_readdir(struct file * filp,
}
#endif
stored = 0;
- bh = NULL;
offset = filp->f_pos & (sb->s_blocksize - 1);
while (!error && !stored && filp->f_pos < inode->i_size) {
- blk = (filp->f_pos) >> EXT3_BLOCK_SIZE_BITS(sb);
- bh = ext3_bread(NULL, inode, blk, 0, &err);
+ unsigned long blk = filp->f_pos >> EXT3_BLOCK_SIZE_BITS(sb);
+ struct buffer_head map_bh;
+ struct buffer_head *bh = NULL;
+
+ map_bh.b_state = 0;
+ err = ext3_get_block_handle(NULL, inode, blk, &map_bh, 0, 0);
+ if (!err) {
+ page_cache_readahead(sb->s_bdev->bd_inode->i_mapping,
+ &filp->f_ra,
+ filp,
+ map_bh.b_blocknr >>
+ (PAGE_CACHE_SHIFT - inode->i_blkbits),
+ 1);
+ bh = ext3_bread(NULL, inode, blk, 0, &err);
+ }
+
+ /*
+ * We ignore I/O errors on directories so users have a chance
+ * of recovering data when there's a bad sector
+ */
if (!bh) {
ext3_error (sb, "ext3_readdir",
"directory #%lu contains a hole at offset %lu",
@@ -138,26 +154,6 @@ static int ext3_readdir(struct file * filp,
continue;
}
- /*
- * Do the readahead
- */
- if (!offset) {
- for (i = 16 >> (EXT3_BLOCK_SIZE_BITS(sb) - 9), num = 0;
- i > 0; i--) {
- tmp = ext3_getblk (NULL, inode, ++blk, 0, &err);
- if (tmp && !buffer_uptodate(tmp) &&
- !buffer_locked(tmp))
- bha[num++] = tmp;
- else
- brelse (tmp);
- }
- if (num) {
- ll_rw_block (READA, num, bha);
- for (i = 0; i < num; i++)
- brelse (bha[i]);
- }
- }
-
revalidate:
/* If the dir block has changed since the last call to
* readdir(2), then we might be pointing to an invalid
diff --git a/fs/ext3/file.c b/fs/ext3/file.c
index 98e78345ead..59098ea5671 100644
--- a/fs/ext3/file.c
+++ b/fs/ext3/file.c
@@ -37,9 +37,9 @@ static int ext3_release_file (struct inode * inode, struct file * filp)
if ((filp->f_mode & FMODE_WRITE) &&
(atomic_read(&inode->i_writecount) == 1))
{
- down(&EXT3_I(inode)->truncate_sem);
+ mutex_lock(&EXT3_I(inode)->truncate_mutex);
ext3_discard_reservation(inode);
- up(&EXT3_I(inode)->truncate_sem);
+ mutex_unlock(&EXT3_I(inode)->truncate_mutex);
}
if (is_dx(inode) && filp->private_data)
ext3_htree_free_dir_info(filp->private_data);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 0384e539b88..2c361377e0a 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -671,7 +671,7 @@ err_out:
* The BKL may not be held on entry here. Be sure to take it early.
*/
-static int
+int
ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
struct buffer_head *bh_result, int create, int extend_disksize)
{
@@ -702,7 +702,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
if (!create || err == -EIO)
goto cleanup;
- down(&ei->truncate_sem);
+ mutex_lock(&ei->truncate_mutex);
/*
* If the indirect block is missing while we are reading
@@ -723,7 +723,7 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
}
partial = ext3_get_branch(inode, depth, offsets, chain, &err);
if (!partial) {
- up(&ei->truncate_sem);
+ mutex_unlock(&ei->truncate_mutex);
if (err)
goto cleanup;
clear_buffer_new(bh_result);
@@ -759,13 +759,13 @@ ext3_get_block_handle(handle_t *handle, struct inode *inode, sector_t iblock,
err = ext3_splice_branch(handle, inode, iblock, chain,
partial, left);
/*
- * i_disksize growing is protected by truncate_sem. Don't forget to
+ * i_disksize growing is protected by truncate_mutex. Don't forget to
* protect it if you're about to implement concurrent
* ext3_get_block() -bzzz
*/
if (!err && extend_disksize && inode->i_size > ei->i_disksize)
ei->i_disksize = inode->i_size;
- up(&ei->truncate_sem);
+ mutex_unlock(&ei->truncate_mutex);
if (err)
goto cleanup;
@@ -1227,7 +1227,7 @@ static int journal_dirty_data_fn(handle_t *handle, struct buffer_head *bh)
* ext3_file_write() -> generic_file_write() -> __alloc_pages() -> ...
*
* Same applies to ext3_get_block(). We will deadlock on various things like
- * lock_journal and i_truncate_sem.
+ * lock_journal and i_truncate_mutex.
*
* Setting PF_MEMALLOC here doesn't work - too many internal memory
* allocations fail.
@@ -2161,7 +2161,7 @@ void ext3_truncate(struct inode * inode)
* From here we block out all ext3_get_block() callers who want to
* modify the block allocation tree.
*/
- down(&ei->truncate_sem);
+ mutex_lock(&ei->truncate_mutex);
if (n == 1) { /* direct blocks */
ext3_free_data(handle, inode, NULL, i_data+offsets[0],
@@ -2228,7 +2228,7 @@ do_indirects:
ext3_discard_reservation(inode);
- up(&ei->truncate_sem);
+ mutex_unlock(&ei->truncate_mutex);
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
ext3_mark_inode_dirty(handle, inode);
diff --git a/fs/ext3/ioctl.c b/fs/ext3/ioctl.c
index 556cd551007..aaf1da17b6d 100644
--- a/fs/ext3/ioctl.c
+++ b/fs/ext3/ioctl.c
@@ -182,7 +182,7 @@ flags_err:
* need to allocate reservation structure for this inode
* before set the window size
*/
- down(&ei->truncate_sem);
+ mutex_lock(&ei->truncate_mutex);
if (!ei->i_block_alloc_info)
ext3_init_block_alloc_info(inode);
@@ -190,7 +190,7 @@ flags_err:
struct ext3_reserve_window_node *rsv = &ei->i_block_alloc_info->rsv_window_node;
rsv->rsv_goal_size = rsv_window_size;
}
- up(&ei->truncate_sem);
+ mutex_unlock(&ei->truncate_mutex);
return 0;
}
case EXT3_IOC_GROUP_EXTEND: {
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 56bf7658601..86e443182de 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -472,7 +472,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
#ifdef CONFIG_EXT3_FS_XATTR
init_rwsem(&ei->xattr_sem);
#endif
- init_MUTEX(&ei->truncate_sem);
+ mutex_init(&ei->truncate_mutex);
inode_init_once(&ei->vfs_inode);
}
}
@@ -481,7 +481,8 @@ static int init_inodecache(void)
{
ext3_inode_cachep = kmem_cache_create("ext3_inode_cache",
sizeof(struct ext3_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (ext3_inode_cachep == NULL)
return -ENOMEM;
@@ -2325,7 +2326,8 @@ restore_opts:
static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
{
- struct ext3_super_block *es = EXT3_SB(sb)->s_es;
+ struct ext3_sb_info *sbi = EXT3_SB(sb);
+ struct ext3_super_block *es = sbi->s_es;
unsigned long overhead;
int i;
@@ -2367,12 +2369,12 @@ static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
buf->f_type = EXT3_SUPER_MAGIC;
buf->f_bsize = sb->s_blocksize;
buf->f_blocks = le32_to_cpu(es->s_blocks_count) - overhead;
- buf->f_bfree = ext3_count_free_blocks (sb);
+ buf->f_bfree = percpu_counter_sum(&sbi->s_freeblocks_counter);
buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
buf->f_bavail = 0;
buf->f_files = le32_to_cpu(es->s_inodes_count);
- buf->f_ffree = ext3_count_free_inodes (sb);
+ buf->f_ffree = percpu_counter_sum(&sbi->s_freeinodes_counter);
buf->f_namelen = EXT3_NAME_LEN;
return 0;
}
@@ -2382,8 +2384,8 @@ static int ext3_statfs (struct super_block * sb, struct kstatfs * buf)
* Process 1 Process 2
* ext3_create() quota_sync()
* journal_start() write_dquot()
- * DQUOT_INIT() down(dqio_sem)
- * down(dqio_sem) journal_start()
+ * DQUOT_INIT() down(dqio_mutex)
+ * down(dqio_mutex) journal_start()
*
*/
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index 1acc941245f..97b967b84fc 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -49,7 +49,7 @@ int __init fat_cache_init(void)
{
fat_cache_cachep = kmem_cache_create("fat_cache",
sizeof(struct fat_cache),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
init_once, NULL);
if (fat_cache_cachep == NULL)
return -ENOMEM;
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index a1a9e045121..ab171ea8e86 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -267,19 +267,19 @@ static struct fatent_operations fat32_ops = {
static inline void lock_fat(struct msdos_sb_info *sbi)
{
- down(&sbi->fat_lock);
+ mutex_lock(&sbi->fat_lock);
}
static inline void unlock_fat(struct msdos_sb_info *sbi)
{
- up(&sbi->fat_lock);
+ mutex_unlock(&sbi->fat_lock);
}
void fat_ent_access_init(struct super_block *sb)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
- init_MUTEX(&sbi->fat_lock);
+ mutex_init(&sbi->fat_lock);
switch (sbi->fat_bits) {
case 32:
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index e78d7b4842c..297300fe81c 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -518,7 +518,8 @@ static int __init fat_init_inodecache(void)
{
fat_inode_cachep = kmem_cache_create("fat_inode_cache",
sizeof(struct msdos_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (fat_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/fcntl.c b/fs/fcntl.c
index dc4a7007f4e..03c789560fb 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -73,8 +73,8 @@ repeat:
* orig_start..fdt->next_fd
*/
start = orig_start;
- if (start < fdt->next_fd)
- start = fdt->next_fd;
+ if (start < files->next_fd)
+ start = files->next_fd;
newfd = start;
if (start < fdt->max_fdset) {
@@ -102,9 +102,8 @@ repeat:
* we reacquire the fdtable pointer and use it while holding
* the lock, no one can free it during that time.
*/
- fdt = files_fdtable(files);
- if (start <= fdt->next_fd)
- fdt->next_fd = newfd + 1;
+ if (start <= files->next_fd)
+ files->next_fd = newfd + 1;
error = newfd;
diff --git a/fs/file.c b/fs/file.c
index cea7cbea11d..bbc74331473 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -125,7 +125,8 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
kmem_cache_free(files_cachep, fdt->free_files);
return;
}
- if (fdt->max_fdset <= __FD_SETSIZE && fdt->max_fds <= NR_OPEN_DEFAULT) {
+ if (fdt->max_fdset <= EMBEDDED_FD_SET_SIZE &&
+ fdt->max_fds <= NR_OPEN_DEFAULT) {
/*
* The fdtable was embedded
*/
@@ -155,8 +156,9 @@ static void free_fdtable_rcu(struct rcu_head *rcu)
void free_fdtable(struct fdtable *fdt)
{
- if (fdt->free_files || fdt->max_fdset > __FD_SETSIZE ||
- fdt->max_fds > NR_OPEN_DEFAULT)
+ if (fdt->free_files ||
+ fdt->max_fdset > EMBEDDED_FD_SET_SIZE ||
+ fdt->max_fds > NR_OPEN_DEFAULT)
call_rcu(&fdt->rcu, free_fdtable_rcu);
}
@@ -199,7 +201,6 @@ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *fdt)
(nfdt->max_fds - fdt->max_fds) *
sizeof(struct file *));
}
- nfdt->next_fd = fdt->next_fd;
}
/*
@@ -220,11 +221,9 @@ fd_set * alloc_fdset(int num)
void free_fdset(fd_set *array, int num)
{
- int size = num / 8;
-
- if (num <= __FD_SETSIZE) /* Don't free an embedded fdset */
+ if (num <= EMBEDDED_FD_SET_SIZE) /* Don't free an embedded fdset */
return;
- else if (size <= PAGE_SIZE)
+ else if (num <= 8 * PAGE_SIZE)
kfree(array);
else
vfree(array);
@@ -237,22 +236,17 @@ static struct fdtable *alloc_fdtable(int nr)
fd_set *new_openset = NULL, *new_execset = NULL;
struct file **new_fds;
- fdt = kmalloc(sizeof(*fdt), GFP_KERNEL);
+ fdt = kzalloc(sizeof(*fdt), GFP_KERNEL);
if (!fdt)
goto out;
- memset(fdt, 0, sizeof(*fdt));
- nfds = __FD_SETSIZE;
+ nfds = 8 * L1_CACHE_BYTES;
/* Expand to the max in easy steps */
- do {
- if (nfds < (PAGE_SIZE * 8))
- nfds = PAGE_SIZE * 8;
- else {
- nfds = nfds * 2;
- if (nfds > NR_OPEN)
- nfds = NR_OPEN;
- }
- } while (nfds <= nr);
+ while (nfds <= nr) {
+ nfds = nfds * 2;
+ if (nfds > NR_OPEN)
+ nfds = NR_OPEN;
+ }
new_openset = alloc_fdset(nfds);
new_execset = alloc_fdset(nfds);
diff --git a/fs/file_table.c b/fs/file_table.c
index 44fabeaa941..bcea1998b4d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -88,6 +88,7 @@ int proc_nr_files(ctl_table *table, int write, struct file *filp,
*/
struct file *get_empty_filp(void)
{
+ struct task_struct *tsk;
static int old_max;
struct file * f;
@@ -112,13 +113,14 @@ struct file *get_empty_filp(void)
if (security_file_alloc(f))
goto fail_sec;
- eventpoll_init_file(f);
+ tsk = current;
+ INIT_LIST_HEAD(&f->f_u.fu_list);
atomic_set(&f->f_count, 1);
- f->f_uid = current->fsuid;
- f->f_gid = current->fsgid;
rwlock_init(&f->f_owner.lock);
+ f->f_uid = tsk->fsuid;
+ f->f_gid = tsk->fsgid;
+ eventpoll_init_file(f);
/* f->f_version: 0 */
- INIT_LIST_HEAD(&f->f_u.fu_list);
return f;
over:
diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c
index 6aa6fbe4f8e..b44c916d24a 100644
--- a/fs/freevxfs/vxfs_super.c
+++ b/fs/freevxfs/vxfs_super.c
@@ -260,7 +260,7 @@ vxfs_init(void)
{
vxfs_inode_cachep = kmem_cache_create("vxfs_inode",
sizeof(struct vxfs_inode_info), 0,
- SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
if (vxfs_inode_cachep)
return register_filesystem(&vxfs_fs_type);
return -ENOMEM;
diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
index 785c7213a54..f3fbe2d030f 100644
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -381,8 +381,8 @@ sync_sb_inodes(struct super_block *sb, struct writeback_control *wbc)
list_move(&inode->i_list, &sb->s_dirty);
}
spin_unlock(&inode_lock);
- cond_resched();
iput(inode);
+ cond_resched();
spin_lock(&inode_lock);
if (wbc->nr_to_write <= 0)
break;
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 6628c3b352c..4c6473ab3b3 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -9,6 +9,7 @@
//#define DBG
//#define DEBUG_LOCKS
+#include <linux/mutex.h>
#include <linux/pagemap.h>
#include <linux/buffer_head.h>
#include <linux/hpfs_fs.h>
@@ -57,8 +58,8 @@ struct hpfs_inode_info {
unsigned i_ea_uid : 1; /* file's uid is stored in ea */
unsigned i_ea_gid : 1; /* file's gid is stored in ea */
unsigned i_dirty : 1;
- struct semaphore i_sem;
- struct semaphore i_parent;
+ struct mutex i_mutex;
+ struct mutex i_parent_mutex;
loff_t **i_rddir_off;
struct inode vfs_inode;
};
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index e3d17e9ea6c..56f2c338c4d 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -186,9 +186,9 @@ void hpfs_write_inode(struct inode *i)
kfree(hpfs_inode->i_rddir_off);
hpfs_inode->i_rddir_off = NULL;
}
- down(&hpfs_inode->i_parent);
+ mutex_lock(&hpfs_inode->i_parent_mutex);
if (!i->i_nlink) {
- up(&hpfs_inode->i_parent);
+ mutex_unlock(&hpfs_inode->i_parent_mutex);
return;
}
parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir);
@@ -199,14 +199,14 @@ void hpfs_write_inode(struct inode *i)
hpfs_read_inode(parent);
unlock_new_inode(parent);
}
- down(&hpfs_inode->i_sem);
+ mutex_lock(&hpfs_inode->i_mutex);
hpfs_write_inode_nolock(i);
- up(&hpfs_inode->i_sem);
+ mutex_unlock(&hpfs_inode->i_mutex);
iput(parent);
} else {
mark_inode_dirty(i);
}
- up(&hpfs_inode->i_parent);
+ mutex_unlock(&hpfs_inode->i_parent_mutex);
}
void hpfs_write_inode_nolock(struct inode *i)
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 8ff8fc433fc..a03abb12c61 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -60,7 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
if (dee.read_only)
result->i_mode &= ~0222;
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1)
goto bail3;
@@ -101,11 +101,11 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
hpfs_write_inode_nolock(result);
}
d_instantiate(dentry, result);
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel();
return 0;
bail3:
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result);
bail2:
hpfs_brelse4(&qbh0);
@@ -168,7 +168,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
result->i_data.a_ops = &hpfs_aops;
hpfs_i(result)->mmu_private = 0;
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1)
goto bail2;
@@ -193,12 +193,12 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc
hpfs_write_inode_nolock(result);
}
d_instantiate(dentry, result);
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel();
return 0;
bail2:
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result);
bail1:
brelse(bh);
@@ -254,7 +254,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
result->i_blocks = 1;
init_special_inode(result, mode, rdev);
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1)
goto bail2;
@@ -271,12 +271,12 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t
hpfs_write_inode_nolock(result);
d_instantiate(dentry, result);
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
brelse(bh);
unlock_kernel();
return 0;
bail2:
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result);
bail1:
brelse(bh);
@@ -333,7 +333,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
result->i_op = &page_symlink_inode_operations;
result->i_data.a_ops = &hpfs_symlink_aops;
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
r = hpfs_add_dirent(dir, (char *)name, len, &dee, 0);
if (r == 1)
goto bail2;
@@ -352,11 +352,11 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy
hpfs_write_inode_nolock(result);
d_instantiate(dentry, result);
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
unlock_kernel();
return 0;
bail2:
- up(&hpfs_i(dir)->i_sem);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
iput(result);
bail1:
brelse(bh);
@@ -382,8 +382,8 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)
lock_kernel();
hpfs_adjust_length((char *)name, &len);
again:
- down(&hpfs_i(inode)->i_parent);
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(inode)->i_parent_mutex);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
err = -ENOENT;
de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
if (!de)
@@ -410,8 +410,8 @@ again:
if (rep++)
break;
- up(&hpfs_i(dir)->i_sem);
- up(&hpfs_i(inode)->i_parent);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
+ mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
d_drop(dentry);
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1 ||
@@ -442,8 +442,8 @@ again:
out1:
hpfs_brelse4(&qbh);
out:
- up(&hpfs_i(dir)->i_sem);
- up(&hpfs_i(inode)->i_parent);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
+ mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel();
return err;
}
@@ -463,8 +463,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
hpfs_adjust_length((char *)name, &len);
lock_kernel();
- down(&hpfs_i(inode)->i_parent);
- down(&hpfs_i(dir)->i_sem);
+ mutex_lock(&hpfs_i(inode)->i_parent_mutex);
+ mutex_lock(&hpfs_i(dir)->i_mutex);
err = -ENOENT;
de = map_dirent(dir, hpfs_i(dir)->i_dno, (char *)name, len, &dno, &qbh);
if (!de)
@@ -502,8 +502,8 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry)
out1:
hpfs_brelse4(&qbh);
out:
- up(&hpfs_i(dir)->i_sem);
- up(&hpfs_i(inode)->i_parent);
+ mutex_unlock(&hpfs_i(dir)->i_mutex);
+ mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
unlock_kernel();
return err;
}
@@ -565,12 +565,12 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
lock_kernel();
/* order doesn't matter, due to VFS exclusion */
- down(&hpfs_i(i)->i_parent);
+ mutex_lock(&hpfs_i(i)->i_parent_mutex);
if (new_inode)
- down(&hpfs_i(new_inode)->i_parent);
- down(&hpfs_i(old_dir)->i_sem);
+ mutex_lock(&hpfs_i(new_inode)->i_parent_mutex);
+ mutex_lock(&hpfs_i(old_dir)->i_mutex);
if (new_dir != old_dir)
- down(&hpfs_i(new_dir)->i_sem);
+ mutex_lock(&hpfs_i(new_dir)->i_mutex);
/* Erm? Moving over the empty non-busy directory is perfectly legal */
if (new_inode && S_ISDIR(new_inode->i_mode)) {
@@ -650,11 +650,11 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
hpfs_decide_conv(i, (char *)new_name, new_len);
end1:
if (old_dir != new_dir)
- up(&hpfs_i(new_dir)->i_sem);
- up(&hpfs_i(old_dir)->i_sem);
- up(&hpfs_i(i)->i_parent);
+ mutex_unlock(&hpfs_i(new_dir)->i_mutex);
+ mutex_unlock(&hpfs_i(old_dir)->i_mutex);
+ mutex_unlock(&hpfs_i(i)->i_parent_mutex);
if (new_inode)
- up(&hpfs_i(new_inode)->i_parent);
+ mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex);
unlock_kernel();
return err;
}
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c
index 63e88d7e2c3..d72d8c87c99 100644
--- a/fs/hpfs/super.c
+++ b/fs/hpfs/super.c
@@ -181,8 +181,8 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) {
- init_MUTEX(&ei->i_sem);
- init_MUTEX(&ei->i_parent);
+ mutex_init(&ei->i_mutex);
+ mutex_init(&ei->i_parent_mutex);
inode_init_once(&ei->vfs_inode);
}
}
@@ -191,7 +191,8 @@ static int init_inodecache(void)
{
hpfs_inode_cachep = kmem_cache_create("hpfs_inode_cache",
sizeof(struct hpfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (hpfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/inode.c b/fs/inode.c
index d0be6159eb7..85da11044ad 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -84,14 +84,14 @@ static struct hlist_head *inode_hashtable;
DEFINE_SPINLOCK(inode_lock);
/*
- * iprune_sem provides exclusion between the kswapd or try_to_free_pages
+ * iprune_mutex provides exclusion between the kswapd or try_to_free_pages
* icache shrinking path, and the umount path. Without this exclusion,
* by the time prune_icache calls iput for the inode whose pages it has
* been invalidating, or by the time it calls clear_inode & destroy_inode
* from its final dispose_list, the struct super_block they refer to
* (for inode->i_sb->s_op) may already have been freed and reused.
*/
-DECLARE_MUTEX(iprune_sem);
+static DEFINE_MUTEX(iprune_mutex);
/*
* Statistics gathering..
@@ -206,7 +206,7 @@ void inode_init_once(struct inode *inode)
i_size_ordered_init(inode);
#ifdef CONFIG_INOTIFY
INIT_LIST_HEAD(&inode->inotify_watches);
- sema_init(&inode->inotify_sem, 1);
+ mutex_init(&inode->inotify_mutex);
#endif
}
@@ -319,7 +319,7 @@ static int invalidate_list(struct list_head *head, struct list_head *dispose)
/*
* We can reschedule here without worrying about the list's
* consistency because the per-sb list of inodes must not
- * change during umount anymore, and because iprune_sem keeps
+ * change during umount anymore, and because iprune_mutex keeps
* shrink_icache_memory() away.
*/
cond_resched_lock(&inode_lock);
@@ -355,14 +355,14 @@ int invalidate_inodes(struct super_block * sb)
int busy;
LIST_HEAD(throw_away);
- down(&iprune_sem);
+ mutex_lock(&iprune_mutex);
spin_lock(&inode_lock);
inotify_unmount_inodes(&sb->s_inodes);
busy = invalidate_list(&sb->s_inodes, &throw_away);
spin_unlock(&inode_lock);
dispose_list(&throw_away);
- up(&iprune_sem);
+ mutex_unlock(&iprune_mutex);
return busy;
}
@@ -377,7 +377,7 @@ int __invalidate_device(struct block_device *bdev)
if (sb) {
/*
* no need to lock the super, get_super holds the
- * read semaphore so the filesystem cannot go away
+ * read mutex so the filesystem cannot go away
* under us (->put_super runs with the write lock
* hold).
*/
@@ -423,7 +423,7 @@ static void prune_icache(int nr_to_scan)
int nr_scanned;
unsigned long reap = 0;
- down(&iprune_sem);
+ mutex_lock(&iprune_mutex);
spin_lock(&inode_lock);
for (nr_scanned = 0; nr_scanned < nr_to_scan; nr_scanned++) {
struct inode *inode;
@@ -459,7 +459,7 @@ static void prune_icache(int nr_to_scan)
spin_unlock(&inode_lock);
dispose_list(&freeable);
- up(&iprune_sem);
+ mutex_unlock(&iprune_mutex);
if (current_is_kswapd())
mod_page_state(kswapd_inodesteal, reap);
@@ -1375,8 +1375,13 @@ void __init inode_init(unsigned long mempages)
int loop;
/* inode slab cache */
- inode_cachep = kmem_cache_create("inode_cache", sizeof(struct inode),
- 0, SLAB_RECLAIM_ACCOUNT|SLAB_PANIC, init_once, NULL);
+ inode_cachep = kmem_cache_create("inode_cache",
+ sizeof(struct inode),
+ 0,
+ (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
+ SLAB_MEM_SPREAD),
+ init_once,
+ NULL);
set_shrinker(DEFAULT_SEEKS, shrink_icache_memory);
/* Hash may have been set up in inode_init_early */
diff --git a/fs/inotify.c b/fs/inotify.c
index 3041503bde0..a61e93e1785 100644
--- a/fs/inotify.c
+++ b/fs/inotify.c
@@ -38,7 +38,6 @@
#include <asm/ioctls.h>
static atomic_t inotify_cookie;
-static atomic_t inotify_watches;
static kmem_cache_t *watch_cachep;
static kmem_cache_t *event_cachep;
@@ -54,10 +53,10 @@ int inotify_max_queued_events;
* Lock ordering:
*
* dentry->d_lock (used to keep d_move() away from dentry->d_parent)
- * iprune_sem (synchronize shrink_icache_memory())
+ * iprune_mutex (synchronize shrink_icache_memory())
* inode_lock (protects the super_block->s_inodes list)
- * inode->inotify_sem (protects inode->inotify_watches and watches->i_list)
- * inotify_dev->sem (protects inotify_device and watches->d_list)
+ * inode->inotify_mutex (protects inode->inotify_watches and watches->i_list)
+ * inotify_dev->mutex (protects inotify_device and watches->d_list)
*/
/*
@@ -79,12 +78,12 @@ int inotify_max_queued_events;
/*
* struct inotify_device - represents an inotify instance
*
- * This structure is protected by the semaphore 'sem'.
+ * This structure is protected by the mutex 'mutex'.
*/
struct inotify_device {
wait_queue_head_t wq; /* wait queue for i/o */
struct idr idr; /* idr mapping wd -> watch */
- struct semaphore sem; /* protects this bad boy */
+ struct mutex mutex; /* protects this bad boy */
struct list_head events; /* list of queued events */
struct list_head watches; /* list of watches */
atomic_t count; /* reference count */
@@ -101,7 +100,7 @@ struct inotify_device {
* device. In read(), this list is walked and all events that can fit in the
* buffer are returned.
*
- * Protected by dev->sem of the device in which we are queued.
+ * Protected by dev->mutex of the device in which we are queued.
*/
struct inotify_kernel_event {
struct inotify_event event; /* the user-space event */
@@ -112,8 +111,8 @@ struct inotify_kernel_event {
/*
* struct inotify_watch - represents a watch request on a specific inode
*
- * d_list is protected by dev->sem of the associated watch->dev.
- * i_list and mask are protected by inode->inotify_sem of the associated inode.
+ * d_list is protected by dev->mutex of the associated watch->dev.
+ * i_list and mask are protected by inode->inotify_mutex of the associated inode.
* dev, inode, and wd are never written to once the watch is created.
*/
struct inotify_watch {
@@ -261,7 +260,7 @@ static struct inotify_kernel_event * kernel_event(s32 wd, u32 mask, u32 cookie,
/*
* inotify_dev_get_event - return the next event in the given dev's queue
*
- * Caller must hold dev->sem.
+ * Caller must hold dev->mutex.
*/
static inline struct inotify_kernel_event *
inotify_dev_get_event(struct inotify_device *dev)
@@ -272,7 +271,7 @@ inotify_dev_get_event(struct inotify_device *dev)
/*
* inotify_dev_queue_event - add a new event to the given device
*
- * Caller must hold dev->sem. Can sleep (calls kernel_event()).
+ * Caller must hold dev->mutex. Can sleep (calls kernel_event()).
*/
static void inotify_dev_queue_event(struct inotify_device *dev,
struct inotify_watch *watch, u32 mask,
@@ -315,7 +314,7 @@ static void inotify_dev_queue_event(struct inotify_device *dev,
/*
* remove_kevent - cleans up and ultimately frees the given kevent
*
- * Caller must hold dev->sem.
+ * Caller must hold dev->mutex.
*/
static void remove_kevent(struct inotify_device *dev,
struct inotify_kernel_event *kevent)
@@ -332,7 +331,7 @@ static void remove_kevent(struct inotify_device *dev,
/*
* inotify_dev_event_dequeue - destroy an event on the given device
*
- * Caller must hold dev->sem.
+ * Caller must hold dev->mutex.
*/
static void inotify_dev_event_dequeue(struct inotify_device *dev)
{
@@ -346,7 +345,7 @@ static void inotify_dev_event_dequeue(struct inotify_device *dev)
/*
* inotify_dev_get_wd - returns the next WD for use by the given dev
*
- * Callers must hold dev->sem. This function can sleep.
+ * Callers must hold dev->mutex. This function can sleep.
*/
static int inotify_dev_get_wd(struct inotify_device *dev,
struct inotify_watch *watch)
@@ -381,9 +380,51 @@ static int find_inode(const char __user *dirname, struct nameidata *nd,
}
/*
+ * inotify_inode_watched - returns nonzero if there are watches on this inode
+ * and zero otherwise. We call this lockless, we do not care if we race.
+ */
+static inline int inotify_inode_watched(struct inode *inode)
+{
+ return !list_empty(&inode->inotify_watches);
+}
+
+/*
+ * Get child dentry flag into synch with parent inode.
+ * Flag should always be clear for negative dentrys.
+ */
+static void set_dentry_child_flags(struct inode *inode, int watched)
+{
+ struct dentry *alias;
+
+ spin_lock(&dcache_lock);
+ list_for_each_entry(alias, &inode->i_dentry, d_alias) {
+ struct dentry *child;
+
+ list_for_each_entry(child, &alias->d_subdirs, d_u.d_child) {
+ if (!child->d_inode) {
+ WARN_ON(child->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
+ continue;
+ }
+ spin_lock(&child->d_lock);
+ if (watched) {
+ WARN_ON(child->d_flags &
+ DCACHE_INOTIFY_PARENT_WATCHED);
+ child->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
+ } else {
+ WARN_ON(!(child->d_flags &
+ DCACHE_INOTIFY_PARENT_WATCHED));
+ child->d_flags&=~DCACHE_INOTIFY_PARENT_WATCHED;
+ }
+ spin_unlock(&child->d_lock);
+ }
+ }
+ spin_unlock(&dcache_lock);
+}
+
+/*
* create_watch - creates a watch on the given device.
*
- * Callers must hold dev->sem. Calls inotify_dev_get_wd() so may sleep.
+ * Callers must hold dev->mutex. Calls inotify_dev_get_wd() so may sleep.
* Both 'dev' and 'inode' (by way of nameidata) need to be pinned.
*/
static struct inotify_watch *create_watch(struct inotify_device *dev,
@@ -426,7 +467,6 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
get_inotify_watch(watch);
atomic_inc(&dev->user->inotify_watches);
- atomic_inc(&inotify_watches);
return watch;
}
@@ -434,7 +474,7 @@ static struct inotify_watch *create_watch(struct inotify_device *dev,
/*
* inotify_find_dev - find the watch associated with the given inode and dev
*
- * Callers must hold inode->inotify_sem.
+ * Callers must hold inode->inotify_mutex.
*/
static struct inotify_watch *inode_find_dev(struct inode *inode,
struct inotify_device *dev)
@@ -458,8 +498,10 @@ static void remove_watch_no_event(struct inotify_watch *watch,
list_del(&watch->i_list);
list_del(&watch->d_list);
+ if (!inotify_inode_watched(watch->inode))
+ set_dentry_child_flags(watch->inode, 0);
+
atomic_dec(&dev->user->inotify_watches);
- atomic_dec(&inotify_watches);
idr_remove(&dev->idr, watch->wd);
put_inotify_watch(watch);
}
@@ -469,7 +511,7 @@ static void remove_watch_no_event(struct inotify_watch *watch,
* the IN_IGNORED event to the given device signifying that the inode is no
* longer watched.
*
- * Callers must hold both inode->inotify_sem and dev->sem. We drop a
+ * Callers must hold both inode->inotify_mutex and dev->mutex. We drop a
* reference to the inode before returning.
*
* The inode is not iput() so as to remain atomic. If the inode needs to be
@@ -481,16 +523,39 @@ static void remove_watch(struct inotify_watch *watch,struct inotify_device *dev)
remove_watch_no_event(watch, dev);
}
+/* Kernel API */
+
/*
- * inotify_inode_watched - returns nonzero if there are watches on this inode
- * and zero otherwise. We call this lockless, we do not care if we race.
+ * inotify_d_instantiate - instantiate dcache entry for inode
*/
-static inline int inotify_inode_watched(struct inode *inode)
+void inotify_d_instantiate(struct dentry *entry, struct inode *inode)
{
- return !list_empty(&inode->inotify_watches);
+ struct dentry *parent;
+
+ if (!inode)
+ return;
+
+ WARN_ON(entry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED);
+ spin_lock(&entry->d_lock);
+ parent = entry->d_parent;
+ if (inotify_inode_watched(parent->d_inode))
+ entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
+ spin_unlock(&entry->d_lock);
}
-/* Kernel API */
+/*
+ * inotify_d_move - dcache entry has been moved
+ */
+void inotify_d_move(struct dentry *entry)
+{
+ struct dentry *parent;
+
+ parent = entry->d_parent;
+ if (inotify_inode_watched(parent->d_inode))
+ entry->d_flags |= DCACHE_INOTIFY_PARENT_WATCHED;
+ else
+ entry->d_flags &= ~DCACHE_INOTIFY_PARENT_WATCHED;
+}
/**
* inotify_inode_queue_event - queue an event to all watches on this inode
@@ -507,21 +572,21 @@ void inotify_inode_queue_event(struct inode *inode, u32 mask, u32 cookie,
if (!inotify_inode_watched(inode))
return;
- down(&inode->inotify_sem);
+ mutex_lock(&inode->inotify_mutex);
list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
u32 watch_mask = watch->mask;
if (watch_mask & mask) {
struct inotify_device *dev = watch->dev;
get_inotify_watch(watch);
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
inotify_dev_queue_event(dev, watch, mask, cookie, name);
if (watch_mask & IN_ONESHOT)
remove_watch_no_event(watch, dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
put_inotify_watch(watch);
}
}
- up(&inode->inotify_sem);
+ mutex_unlock(&inode->inotify_mutex);
}
EXPORT_SYMBOL_GPL(inotify_inode_queue_event);
@@ -538,7 +603,7 @@ void inotify_dentry_parent_queue_event(struct dentry *dentry, u32 mask,
struct dentry *parent;
struct inode *inode;
- if (!atomic_read (&inotify_watches))
+ if (!(dentry->d_flags & DCACHE_INOTIFY_PARENT_WATCHED))
return;
spin_lock(&dentry->d_lock);
@@ -569,7 +634,7 @@ EXPORT_SYMBOL_GPL(inotify_get_cookie);
* @list: list of inodes being unmounted (sb->s_inodes)
*
* Called with inode_lock held, protecting the unmounting super block's list
- * of inodes, and with iprune_sem held, keeping shrink_icache_memory() at bay.
+ * of inodes, and with iprune_mutex held, keeping shrink_icache_memory() at bay.
* We temporarily drop inode_lock, however, and CAN block.
*/
void inotify_unmount_inodes(struct list_head *list)
@@ -618,7 +683,7 @@ void inotify_unmount_inodes(struct list_head *list)
* We can safely drop inode_lock here because we hold
* references on both inode and next_i. Also no new inodes
* will be added since the umount has begun. Finally,
- * iprune_sem keeps shrink_icache_memory() away.
+ * iprune_mutex keeps shrink_icache_memory() away.
*/
spin_unlock(&inode_lock);
@@ -626,16 +691,16 @@ void inotify_unmount_inodes(struct list_head *list)
iput(need_iput_tmp);
/* for each watch, send IN_UNMOUNT and then remove it */
- down(&inode->inotify_sem);
+ mutex_lock(&inode->inotify_mutex);
watches = &inode->inotify_watches;
list_for_each_entry_safe(watch, next_w, watches, i_list) {
struct inotify_device *dev = watch->dev;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
inotify_dev_queue_event(dev, watch, IN_UNMOUNT,0,NULL);
remove_watch(watch, dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
- up(&inode->inotify_sem);
+ mutex_unlock(&inode->inotify_mutex);
iput(inode);
spin_lock(&inode_lock);
@@ -651,14 +716,14 @@ void inotify_inode_is_dead(struct inode *inode)
{
struct inotify_watch *watch, *next;
- down(&inode->inotify_sem);
+ mutex_lock(&inode->inotify_mutex);
list_for_each_entry_safe(watch, next, &inode->inotify_watches, i_list) {
struct inotify_device *dev = watch->dev;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
remove_watch(watch, dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
}
- up(&inode->inotify_sem);
+ mutex_unlock(&inode->inotify_mutex);
}
EXPORT_SYMBOL_GPL(inotify_inode_is_dead);
@@ -670,10 +735,10 @@ static unsigned int inotify_poll(struct file *file, poll_table *wait)
int ret = 0;
poll_wait(file, &dev->wq, wait);
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
if (!list_empty(&dev->events))
ret = POLLIN | POLLRDNORM;
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return ret;
}
@@ -695,9 +760,9 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
prepare_to_wait(&dev->wq, &wait, TASK_INTERRUPTIBLE);
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
events = !list_empty(&dev->events);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
if (events) {
ret = 0;
break;
@@ -720,7 +785,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
if (ret)
return ret;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
while (1) {
struct inotify_kernel_event *kevent;
@@ -750,7 +815,7 @@ static ssize_t inotify_read(struct file *file, char __user *buf,
remove_kevent(dev, kevent);
}
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return ret;
}
@@ -763,37 +828,37 @@ static int inotify_release(struct inode *ignored, struct file *file)
* Destroy all of the watches on this device. Unfortunately, not very
* pretty. We cannot do a simple iteration over the list, because we
* do not know the inode until we iterate to the watch. But we need to
- * hold inode->inotify_sem before dev->sem. The following works.
+ * hold inode->inotify_mutex before dev->mutex. The following works.
*/
while (1) {
struct inotify_watch *watch;
struct list_head *watches;
struct inode *inode;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
watches = &dev->watches;
if (list_empty(watches)) {
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
break;
}
watch = list_entry(watches->next, struct inotify_watch, d_list);
get_inotify_watch(watch);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
inode = watch->inode;
- down(&inode->inotify_sem);
- down(&dev->sem);
+ mutex_lock(&inode->inotify_mutex);
+ mutex_lock(&dev->mutex);
remove_watch_no_event(watch, dev);
- up(&dev->sem);
- up(&inode->inotify_sem);
+ mutex_unlock(&dev->mutex);
+ mutex_unlock(&inode->inotify_mutex);
put_inotify_watch(watch);
}
/* destroy all of the events on this device */
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
while (!list_empty(&dev->events))
inotify_dev_event_dequeue(dev);
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
/* free this device: the put matching the get in inotify_init() */
put_inotify_dev(dev);
@@ -811,26 +876,26 @@ static int inotify_ignore(struct inotify_device *dev, s32 wd)
struct inotify_watch *watch;
struct inode *inode;
- down(&dev->sem);
+ mutex_lock(&dev->mutex);
watch = idr_find(&dev->idr, wd);
if (unlikely(!watch)) {
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
return -EINVAL;
}
get_inotify_watch(watch);
inode = watch->inode;
- up(&dev->sem);
+ mutex_unlock(&dev->mutex);
- down(&inode->inotify_sem);
- down(&dev->sem);
+ mutex_lock(&inode->inotify_mutex);
+ mutex_lock(&dev->mutex);
/* make sure that we did not race */
watch = idr_find(&dev->idr, wd);
if (likely(watch))
remove_watch(watch, dev);
- up(&dev->sem);
- up(&inode->inotify_sem);
+ mutex_unlock(&dev->mutex);
+ mutex_unlock(&inode->inotify_mutex);
put_inotify_watch(watch);
return 0;
@@ -905,7 +970,7 @@ asmlinkage long sys_inotify_init(void)
INIT_LIST_HEAD(&dev->events);
INIT_LIST_HEAD(&dev->watches);
init_waitqueue_head(&dev->wq);
- sema_init(&dev->sem, 1);
+ mutex_init(&dev->mutex);
dev->event_count = 0;
dev->queue_size = 0;
dev->max_events = inotify_max_queued_events;
@@ -960,8 +1025,8 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
inode = nd.dentry->d_inode;
dev = filp->private_data;
- down(&inode->inotify_sem);
- down(&dev->sem);
+ mutex_lock(&inode->inotify_mutex);
+ mutex_lock(&dev->mutex);
if (mask & IN_MASK_ADD)
mask_add = 1;
@@ -993,13 +1058,16 @@ asmlinkage long sys_inotify_add_watch(int fd, const char __user *path, u32 mask)
goto out;
}
+ if (!inotify_inode_watched(inode))
+ set_dentry_child_flags(inode, 1);
+
/* Add the watch to the device's and the inode's list */
list_add(&watch->d_list, &dev->watches);
list_add(&watch->i_list, &inode->inotify_watches);
ret = watch->wd;
out:
- up(&dev->sem);
- up(&inode->inotify_sem);
+ mutex_unlock(&dev->mutex);
+ mutex_unlock(&inode->inotify_mutex);
path_release(&nd);
fput_and_out:
fput_light(filp, fput_needed);
@@ -1065,7 +1133,6 @@ static int __init inotify_setup(void)
inotify_max_user_watches = 8192;
atomic_set(&inotify_cookie, 0);
- atomic_set(&inotify_watches, 0);
watch_cachep = kmem_cache_create("inotify_watch_cache",
sizeof(struct inotify_watch),
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c
index 298f08be22d..70adbb98bad 100644
--- a/fs/isofs/inode.c
+++ b/fs/isofs/inode.c
@@ -87,7 +87,8 @@ static int init_inodecache(void)
{
isofs_inode_cachep = kmem_cache_create("isofs_inode_cache",
sizeof(struct iso_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (isofs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/isofs/isofs.h b/fs/isofs/isofs.h
index 38c75151fc6..439a19b1bf3 100644
--- a/fs/isofs/isofs.h
+++ b/fs/isofs/isofs.h
@@ -178,15 +178,3 @@ extern struct inode_operations isofs_dir_inode_operations;
extern struct file_operations isofs_dir_operations;
extern struct address_space_operations isofs_symlink_aops;
extern struct export_operations isofs_export_ops;
-
-/* The following macros are used to check for memory leaks. */
-#ifdef LEAK_CHECK
-#define free_s leak_check_free_s
-#define malloc leak_check_malloc
-#define sb_bread leak_check_bread
-#define brelse leak_check_brelse
-extern void * leak_check_malloc(unsigned int size);
-extern void leak_check_free_s(void * obj, int size);
-extern struct buffer_head * leak_check_bread(struct super_block *sb, int block);
-extern void leak_check_brelse(struct buffer_head * bh);
-#endif /* LEAK_CHECK */
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c
index 543ed543d1e..3f5102b069d 100644
--- a/fs/jbd/checkpoint.c
+++ b/fs/jbd/checkpoint.c
@@ -85,7 +85,7 @@ void __log_wait_for_space(journal_t *journal)
if (journal->j_flags & JFS_ABORT)
return;
spin_unlock(&journal->j_state_lock);
- down(&journal->j_checkpoint_sem);
+ mutex_lock(&journal->j_checkpoint_mutex);
/*
* Test again, another process may have checkpointed while we
@@ -98,7 +98,7 @@ void __log_wait_for_space(journal_t *journal)
log_do_checkpoint(journal);
spin_lock(&journal->j_state_lock);
}
- up(&journal->j_checkpoint_sem);
+ mutex_unlock(&journal->j_checkpoint_mutex);
}
}
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index e4b516ac498..7f96b5cb678 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/journal.c
@@ -33,9 +33,11 @@
#include <linux/mm.h>
#include <linux/suspend.h>
#include <linux/pagemap.h>
+#include <linux/kthread.h>
+#include <linux/proc_fs.h>
+
#include <asm/uaccess.h>
#include <asm/page.h>
-#include <linux/proc_fs.h>
EXPORT_SYMBOL(journal_start);
EXPORT_SYMBOL(journal_restart);
@@ -111,18 +113,15 @@ static void commit_timeout(unsigned long __data)
static int kjournald(void *arg)
{
- journal_t *journal = (journal_t *) arg;
+ journal_t *journal = arg;
transaction_t *transaction;
- struct timer_list timer;
- daemonize("kjournald");
-
- /* Set up an interval timer which can be used to trigger a
- commit wakeup after the commit interval expires */
- init_timer(&timer);
- timer.data = (unsigned long) current;
- timer.function = commit_timeout;
- journal->j_commit_timer = &timer;
+ /*
+ * Set up an interval timer which can be used to trigger a commit wakeup
+ * after the commit interval expires
+ */
+ setup_timer(&journal->j_commit_timer, commit_timeout,
+ (unsigned long)current);
/* Record that the journal thread is running */
journal->j_task = current;
@@ -146,7 +145,7 @@ loop:
if (journal->j_commit_sequence != journal->j_commit_request) {
jbd_debug(1, "OK, requests differ\n");
spin_unlock(&journal->j_state_lock);
- del_timer_sync(journal->j_commit_timer);
+ del_timer_sync(&journal->j_commit_timer);
journal_commit_transaction(journal);
spin_lock(&journal->j_state_lock);
goto loop;
@@ -203,7 +202,7 @@ loop:
end_loop:
spin_unlock(&journal->j_state_lock);
- del_timer_sync(journal->j_commit_timer);
+ del_timer_sync(&journal->j_commit_timer);
journal->j_task = NULL;
wake_up(&journal->j_wait_done_commit);
jbd_debug(1, "Journal thread exiting.\n");
@@ -212,7 +211,7 @@ end_loop:
static void journal_start_thread(journal_t *journal)
{
- kernel_thread(kjournald, journal, CLONE_VM|CLONE_FS|CLONE_FILES);
+ kthread_run(kjournald, journal, "kjournald");
wait_event(journal->j_wait_done_commit, journal->j_task != 0);
}
@@ -659,8 +658,8 @@ static journal_t * journal_init_common (void)
init_waitqueue_head(&journal->j_wait_checkpoint);
init_waitqueue_head(&journal->j_wait_commit);
init_waitqueue_head(&journal->j_wait_updates);
- init_MUTEX(&journal->j_barrier);
- init_MUTEX(&journal->j_checkpoint_sem);
+ mutex_init(&journal->j_barrier);
+ mutex_init(&journal->j_checkpoint_mutex);
spin_lock_init(&journal->j_revoke_lock);
spin_lock_init(&journal->j_list_lock);
spin_lock_init(&journal->j_state_lock);
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index ca917973c2c..ada31fa272e 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -53,8 +53,8 @@ get_transaction(journal_t *journal, transaction_t *transaction)
spin_lock_init(&transaction->t_handle_lock);
/* Set up the commit timer for the new transaction. */
- journal->j_commit_timer->expires = transaction->t_expires;
- add_timer(journal->j_commit_timer);
+ journal->j_commit_timer.expires = transaction->t_expires;
+ add_timer(&journal->j_commit_timer);
J_ASSERT(journal->j_running_transaction == NULL);
journal->j_running_transaction = transaction;
@@ -455,7 +455,7 @@ void journal_lock_updates(journal_t *journal)
* to make sure that we serialise special journal-locked operations
* too.
*/
- down(&journal->j_barrier);
+ mutex_lock(&journal->j_barrier);
}
/**
@@ -470,7 +470,7 @@ void journal_unlock_updates (journal_t *journal)
{
J_ASSERT(journal->j_barrier_count != 0);
- up(&journal->j_barrier);
+ mutex_unlock(&journal->j_barrier);
spin_lock(&journal->j_state_lock);
--journal->j_barrier_count;
spin_unlock(&journal->j_state_lock);
diff --git a/fs/jffs/inode-v23.c b/fs/jffs/inode-v23.c
index fc3855a1aef..5a4519e834d 100644
--- a/fs/jffs/inode-v23.c
+++ b/fs/jffs/inode-v23.c
@@ -42,7 +42,7 @@
#include <linux/quotaops.h>
#include <linux/highmem.h>
#include <linux/vfs.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <asm/uaccess.h>
@@ -203,7 +203,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
fmc = c->fmc;
D3(printk (KERN_NOTICE "notify_change(): down biglock\n"));
- down(&fmc->biglock);
+ mutex_lock(&fmc->biglock);
f = jffs_find_file(c, inode->i_ino);
@@ -211,7 +211,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
printk("jffs_setattr(): Invalid inode number: %lu\n",
inode->i_ino);
D3(printk (KERN_NOTICE "notify_change(): up biglock\n"));
- up(&fmc->biglock);
+ mutex_unlock(&fmc->biglock);
res = -EINVAL;
goto out;
});
@@ -232,7 +232,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
if (!(new_node = jffs_alloc_node())) {
D(printk("jffs_setattr(): Allocation failed!\n"));
D3(printk (KERN_NOTICE "notify_change(): up biglock\n"));
- up(&fmc->biglock);
+ mutex_unlock(&fmc->biglock);
res = -ENOMEM;
goto out;
}
@@ -319,7 +319,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
D(printk("jffs_notify_change(): The write failed!\n"));
jffs_free_node(new_node);
D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
goto out;
}
@@ -327,7 +327,7 @@ jffs_setattr(struct dentry *dentry, struct iattr *iattr)
mark_inode_dirty(inode);
D3(printk (KERN_NOTICE "n_c(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
out:
unlock_kernel();
return res;
@@ -461,7 +461,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto jffs_rename_end;
}
D3(printk (KERN_NOTICE "rename(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
/* Create a node and initialize as much as needed. */
result = -ENOMEM;
if (!(node = jffs_alloc_node())) {
@@ -555,7 +555,7 @@ jffs_rename(struct inode *old_dir, struct dentry *old_dentry,
jffs_rename_end:
D3(printk (KERN_NOTICE "rename(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return result;
} /* jffs_rename() */
@@ -574,14 +574,14 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
int ddino;
lock_kernel();
D3(printk (KERN_NOTICE "readdir(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
D2(printk("jffs_readdir(): inode: 0x%p, filp: 0x%p\n", inode, filp));
if (filp->f_pos == 0) {
D3(printk("jffs_readdir(): \".\" %lu\n", inode->i_ino));
if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0) {
D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return 0;
}
@@ -598,7 +598,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
D3(printk("jffs_readdir(): \"..\" %u\n", ddino));
if (filldir(dirent, "..", 2, filp->f_pos, ddino, DT_DIR) < 0) {
D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return 0;
}
@@ -617,7 +617,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (filldir(dirent, f->name, f->nsize,
filp->f_pos , f->ino, DT_UNKNOWN) < 0) {
D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return 0;
}
@@ -627,7 +627,7 @@ jffs_readdir(struct file *filp, void *dirent, filldir_t filldir)
} while(f && f->deleted);
}
D3(printk (KERN_NOTICE "readdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return filp->f_pos;
} /* jffs_readdir() */
@@ -660,7 +660,7 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
});
D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
r = -ENAMETOOLONG;
if (len > JFFS_MAX_NAME_LEN) {
@@ -683,31 +683,31 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
if ((len == 1) && (name[0] == '.')) {
D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
if (!(inode = iget(dir->i_sb, d->ino))) {
D(printk("jffs_lookup(): . iget() ==> NULL\n"));
goto jffs_lookup_end_no_biglock;
}
D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
} else if ((len == 2) && (name[0] == '.') && (name[1] == '.')) {
D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
if (!(inode = iget(dir->i_sb, d->pino))) {
D(printk("jffs_lookup(): .. iget() ==> NULL\n"));
goto jffs_lookup_end_no_biglock;
}
D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
} else if ((f = jffs_find_child(d, name, len))) {
D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
if (!(inode = iget(dir->i_sb, f->ino))) {
D(printk("jffs_lookup(): iget() ==> NULL\n"));
goto jffs_lookup_end_no_biglock;
}
D3(printk (KERN_NOTICE "lookup(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
} else {
D3(printk("jffs_lookup(): Couldn't find the file. "
"f = 0x%p, name = \"%s\", d = 0x%p, d->ino = %u\n",
@@ -717,13 +717,13 @@ jffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
d_add(dentry, inode);
D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return NULL;
jffs_lookup_end:
D3(printk (KERN_NOTICE "lookup(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
jffs_lookup_end_no_biglock:
unlock_kernel();
@@ -753,7 +753,7 @@ jffs_do_readpage_nolock(struct file *file, struct page *page)
ClearPageError(page);
D3(printk (KERN_NOTICE "readpage(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
read_len = 0;
result = 0;
@@ -782,7 +782,7 @@ jffs_do_readpage_nolock(struct file *file, struct page *page)
kunmap(page);
D3(printk (KERN_NOTICE "readpage(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
if (result) {
SetPageError(page);
@@ -839,7 +839,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
c = dir_f->c;
D3(printk (KERN_NOTICE "mkdir(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
dir_mode = S_IFDIR | (mode & (S_IRWXUGO|S_ISVTX)
& ~current->fs->umask);
@@ -906,7 +906,7 @@ jffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
result = 0;
jffs_mkdir_end:
D3(printk (KERN_NOTICE "mkdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return result;
} /* jffs_mkdir() */
@@ -921,10 +921,10 @@ jffs_rmdir(struct inode *dir, struct dentry *dentry)
D3(printk("***jffs_rmdir()\n"));
D3(printk (KERN_NOTICE "rmdir(): down biglock\n"));
lock_kernel();
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
ret = jffs_remove(dir, dentry, S_IFDIR);
D3(printk (KERN_NOTICE "rmdir(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return ret;
}
@@ -940,10 +940,10 @@ jffs_unlink(struct inode *dir, struct dentry *dentry)
lock_kernel();
D3(printk("***jffs_unlink()\n"));
D3(printk (KERN_NOTICE "unlink(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
ret = jffs_remove(dir, dentry, 0);
D3(printk (KERN_NOTICE "unlink(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return ret;
}
@@ -1086,7 +1086,7 @@ jffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
c = dir_f->c;
D3(printk (KERN_NOTICE "mknod(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
/* Create and initialize a new node. */
if (!(node = jffs_alloc_node())) {
@@ -1152,7 +1152,7 @@ jffs_mknod_err:
jffs_mknod_end:
D3(printk (KERN_NOTICE "mknod(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return result;
} /* jffs_mknod() */
@@ -1203,7 +1203,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
return -ENOMEM;
}
D3(printk (KERN_NOTICE "symlink(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
node->data_offset = 0;
node->removed_size = 0;
@@ -1253,7 +1253,7 @@ jffs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
d_instantiate(dentry, inode);
jffs_symlink_end:
D3(printk (KERN_NOTICE "symlink(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return err;
} /* jffs_symlink() */
@@ -1306,7 +1306,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
return -ENOMEM;
}
D3(printk (KERN_NOTICE "create(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
node->data_offset = 0;
node->removed_size = 0;
@@ -1359,7 +1359,7 @@ jffs_create(struct inode *dir, struct dentry *dentry, int mode,
d_instantiate(dentry, inode);
jffs_create_end:
D3(printk (KERN_NOTICE "create(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
unlock_kernel();
return err;
} /* jffs_create() */
@@ -1423,7 +1423,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
thiscount = min(c->fmc->max_chunk_size - sizeof(struct jffs_raw_inode), count);
D3(printk (KERN_NOTICE "file_write(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
/* Urgh. POSIX says we can do short writes if we feel like it.
* In practice, we can't. Nothing will cope. So we loop until
@@ -1511,7 +1511,7 @@ jffs_file_write(struct file *filp, const char *buf, size_t count,
}
out:
D3(printk (KERN_NOTICE "file_write(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
/* Fix things in the real inode. */
if (pos > inode->i_size) {
@@ -1567,7 +1567,7 @@ jffs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
return -EIO;
}
D3(printk (KERN_NOTICE "ioctl(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
switch (cmd) {
case JFFS_PRINT_HASH:
@@ -1609,7 +1609,7 @@ jffs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
ret = -ENOTTY;
}
D3(printk (KERN_NOTICE "ioctl(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
return ret;
} /* jffs_ioctl() */
@@ -1685,12 +1685,12 @@ jffs_read_inode(struct inode *inode)
}
c = (struct jffs_control *)inode->i_sb->s_fs_info;
D3(printk (KERN_NOTICE "read_inode(): down biglock\n"));
- down(&c->fmc->biglock);
+ mutex_lock(&c->fmc->biglock);
if (!(f = jffs_find_file(c, inode->i_ino))) {
D(printk("jffs_read_inode(): No such inode (%lu).\n",
inode->i_ino));
D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
return;
}
inode->u.generic_ip = (void *)f;
@@ -1732,7 +1732,7 @@ jffs_read_inode(struct inode *inode)
}
D3(printk (KERN_NOTICE "read_inode(): up biglock\n"));
- up(&c->fmc->biglock);
+ mutex_unlock(&c->fmc->biglock);
}
@@ -1812,15 +1812,17 @@ init_jffs_fs(void)
}
#endif
fm_cache = kmem_cache_create("jffs_fm", sizeof(struct jffs_fm),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- NULL, NULL);
+ 0,
+ SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
+ NULL, NULL);
if (!fm_cache) {
return -ENOMEM;
}
node_cache = kmem_cache_create("jffs_node",sizeof(struct jffs_node),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- NULL, NULL);
+ 0,
+ SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
+ NULL, NULL);
if (!node_cache) {
kmem_cache_destroy(fm_cache);
return -ENOMEM;
diff --git a/fs/jffs/intrep.c b/fs/jffs/intrep.c
index ce7b54b0b2b..0ef207dfaf6 100644
--- a/fs/jffs/intrep.c
+++ b/fs/jffs/intrep.c
@@ -62,7 +62,7 @@
#include <linux/fs.h>
#include <linux/stat.h>
#include <linux/pagemap.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <linux/smp_lock.h>
#include <linux/time.h>
@@ -3416,7 +3416,7 @@ jffs_garbage_collect_thread(void *ptr)
D1(printk (KERN_NOTICE "jffs_garbage_collect_thread(): collecting.\n"));
D3(printk (KERN_NOTICE "g_c_thread(): down biglock\n"));
- down(&fmc->biglock);
+ mutex_lock(&fmc->biglock);
D1(printk("***jffs_garbage_collect_thread(): round #%u, "
"fmc->dirty_size = %u\n", i++, fmc->dirty_size));
@@ -3447,6 +3447,6 @@ jffs_garbage_collect_thread(void *ptr)
gc_end:
D3(printk (KERN_NOTICE "g_c_thread(): up biglock\n"));
- up(&fmc->biglock);
+ mutex_unlock(&fmc->biglock);
} /* for (;;) */
} /* jffs_garbage_collect_thread() */
diff --git a/fs/jffs/jffs_fm.c b/fs/jffs/jffs_fm.c
index 6da13b309bd..7d8ca1aeace 100644
--- a/fs/jffs/jffs_fm.c
+++ b/fs/jffs/jffs_fm.c
@@ -139,7 +139,7 @@ jffs_build_begin(struct jffs_control *c, int unit)
fmc->tail = NULL;
fmc->head_extra = NULL;
fmc->tail_extra = NULL;
- init_MUTEX(&fmc->biglock);
+ mutex_init(&fmc->biglock);
return fmc;
}
diff --git a/fs/jffs/jffs_fm.h b/fs/jffs/jffs_fm.h
index f64151e7412..c794d923df2 100644
--- a/fs/jffs/jffs_fm.h
+++ b/fs/jffs/jffs_fm.h
@@ -20,10 +20,11 @@
#ifndef __LINUX_JFFS_FM_H__
#define __LINUX_JFFS_FM_H__
+#include <linux/config.h>
#include <linux/types.h>
#include <linux/jffs.h>
#include <linux/mtd/mtd.h>
-#include <linux/config.h>
+#include <linux/mutex.h>
/* The alignment between two nodes in the flash memory. */
#define JFFS_ALIGN_SIZE 4
@@ -97,7 +98,7 @@ struct jffs_fmcontrol
struct jffs_fm *tail;
struct jffs_fm *head_extra;
struct jffs_fm *tail_extra;
- struct semaphore biglock;
+ struct mutex biglock;
};
/* Notice the two members head_extra and tail_extra in the jffs_control
diff --git a/fs/jffs2/super.c b/fs/jffs2/super.c
index 93883817cbd..ffd8e84b22c 100644
--- a/fs/jffs2/super.c
+++ b/fs/jffs2/super.c
@@ -152,7 +152,7 @@ static struct super_block *jffs2_get_sb_mtd(struct file_system_type *fs_type,
sb->s_op = &jffs2_super_operations;
sb->s_flags = flags | MS_NOATIME;
- ret = jffs2_do_fill_super(sb, data, (flags&MS_VERBOSE)?1:0);
+ ret = jffs2_do_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
if (ret) {
/* Failure case... */
@@ -257,7 +257,7 @@ static struct super_block *jffs2_get_sb(struct file_system_type *fs_type,
}
if (imajor(nd.dentry->d_inode) != MTD_BLOCK_MAJOR) {
- if (!(flags & MS_VERBOSE)) /* Yes I mean this. Strangely */
+ if (!(flags & MS_SILENT))
printk(KERN_NOTICE "Attempt to mount non-MTD device \"%s\" as JFFS2\n",
dev_name);
goto out;
@@ -331,7 +331,8 @@ static int __init init_jffs2_fs(void)
jffs2_inode_cachep = kmem_cache_create("jffs2_i",
sizeof(struct jffs2_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
jffs2_i_init_once, NULL);
if (!jffs2_inode_cachep) {
printk(KERN_ERR "JFFS2 error: Failed to initialise inode cache\n");
diff --git a/fs/jfs/jfs_debug.c b/fs/jfs/jfs_debug.c
index 4caea6b43b9..81f0e514c49 100644
--- a/fs/jfs/jfs_debug.c
+++ b/fs/jfs/jfs_debug.c
@@ -111,7 +111,7 @@ static struct {
{ "loglevel", loglevel_read, loglevel_write }
#endif
};
-#define NPROCENT (sizeof(Entries)/sizeof(Entries[0]))
+#define NPROCENT ARRAY_SIZE(Entries)
void jfs_proc_init(void)
{
diff --git a/fs/jfs/super.c b/fs/jfs/super.c
index 18f69e6aa71..db6f41d6dd6 100644
--- a/fs/jfs/super.c
+++ b/fs/jfs/super.c
@@ -664,7 +664,8 @@ static int __init init_jfs_fs(void)
jfs_inode_cachep =
kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
- SLAB_RECLAIM_ACCOUNT, init_once, NULL);
+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
+ init_once, NULL);
if (jfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/libfs.c b/fs/libfs.c
index 71fd08fa410..4fdeaceb892 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -7,6 +7,8 @@
#include <linux/pagemap.h>
#include <linux/mount.h>
#include <linux/vfs.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,
@@ -530,7 +532,7 @@ struct simple_attr {
char set_buf[24];
void *data;
const char *fmt; /* format for read operation */
- struct semaphore sem; /* protects access to these buffers */
+ struct mutex mutex; /* protects access to these buffers */
};
/* simple_attr_open is called by an actual attribute open file operation
@@ -549,7 +551,7 @@ int simple_attr_open(struct inode *inode, struct file *file,
attr->set = set;
attr->data = inode->u.generic_ip;
attr->fmt = fmt;
- init_MUTEX(&attr->sem);
+ mutex_init(&attr->mutex);
file->private_data = attr;
@@ -575,7 +577,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
if (!attr->get)
return -EACCES;
- down(&attr->sem);
+ mutex_lock(&attr->mutex);
if (*ppos) /* continued read */
size = strlen(attr->get_buf);
else /* first read */
@@ -584,7 +586,7 @@ ssize_t simple_attr_read(struct file *file, char __user *buf,
(unsigned long long)attr->get(attr->data));
ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
- up(&attr->sem);
+ mutex_unlock(&attr->mutex);
return ret;
}
@@ -602,7 +604,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
if (!attr->set)
return -EACCES;
- down(&attr->sem);
+ mutex_lock(&attr->mutex);
ret = -EFAULT;
size = min(sizeof(attr->set_buf) - 1, len);
if (copy_from_user(attr->set_buf, buf, size))
@@ -613,7 +615,7 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf,
val = simple_strtol(attr->set_buf, NULL, 0);
attr->set(attr->data, val);
out:
- up(&attr->sem);
+ mutex_unlock(&attr->mutex);
return ret;
}
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c
index 0edc03e6796..a89cb8aa2c8 100644
--- a/fs/lockd/mon.c
+++ b/fs/lockd/mon.c
@@ -224,8 +224,8 @@ static struct rpc_procinfo nsm_procedures[] = {
};
static struct rpc_version nsm_version1 = {
- .number = 1,
- .nrprocs = sizeof(nsm_procedures)/sizeof(nsm_procedures[0]),
+ .number = 1,
+ .nrprocs = ARRAY_SIZE(nsm_procedures),
.procs = nsm_procedures
};
@@ -238,7 +238,7 @@ static struct rpc_stat nsm_stats;
static struct rpc_program nsm_program = {
.name = "statd",
.number = SM_PROGRAM,
- .nrvers = sizeof(nsm_version)/sizeof(nsm_version[0]),
+ .nrvers = ARRAY_SIZE(nsm_version),
.version = nsm_version,
.stats = &nsm_stats
};
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
index 71a30b416d1..5e85bde6c12 100644
--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -509,7 +509,7 @@ static struct svc_version * nlmsvc_version[] = {
static struct svc_stat nlmsvc_stats;
-#define NLM_NRVERS (sizeof(nlmsvc_version)/sizeof(nlmsvc_version[0]))
+#define NLM_NRVERS ARRAY_SIZE(nlmsvc_version)
static struct svc_program nlmsvc_program = {
.pg_prog = NLM_PROGRAM, /* program number */
.pg_nvers = NLM_NRVERS, /* number of entries in nlmsvc_version */
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c
index 200fbda2c6d..1d700a4dd0b 100644
--- a/fs/lockd/xdr.c
+++ b/fs/lockd/xdr.c
@@ -599,7 +599,7 @@ static struct rpc_stat nlm_stats;
struct rpc_program nlm_program = {
.name = "lockd",
.number = NLM_PROGRAM,
- .nrvers = sizeof(nlm_versions) / sizeof(nlm_versions[0]),
+ .nrvers = ARRAY_SIZE(nlm_versions),
.version = nlm_versions,
.stats = &nlm_stats,
};
diff --git a/fs/mbcache.c b/fs/mbcache.c
index f5bbe4c97c5..73e754fea2d 100644
--- a/fs/mbcache.c
+++ b/fs/mbcache.c
@@ -288,7 +288,7 @@ mb_cache_create(const char *name, struct mb_cache_op *cache_op,
INIT_LIST_HEAD(&cache->c_indexes_hash[m][n]);
}
cache->c_entry_cache = kmem_cache_create(name, entry_size, 0,
- SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
if (!cache->c_entry_cache)
goto fail;
diff --git a/fs/minix/bitmap.c b/fs/minix/bitmap.c
index dc6a4e4abcd..4a6abc49418 100644
--- a/fs/minix/bitmap.c
+++ b/fs/minix/bitmap.c
@@ -56,7 +56,7 @@ void minix_free_block(struct inode * inode, int block)
unsigned int bit,zone;
if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) {
- printk("trying to free block not in datazone\n");
+ printk("Trying to free block not in datazone\n");
return;
}
zone = block - sbi->s_firstdatazone + 1;
@@ -124,7 +124,7 @@ minix_V1_raw_inode(struct super_block *sb, ino_t ino, struct buffer_head **bh)
ino / MINIX_INODES_PER_BLOCK;
*bh = sb_bread(sb, block);
if (!*bh) {
- printk("unable to read i-node block\n");
+ printk("Unable to read inode block\n");
return NULL;
}
p = (void *)(*bh)->b_data;
@@ -149,7 +149,7 @@ minix_V2_raw_inode(struct super_block *sb, ino_t ino, struct buffer_head **bh)
ino / MINIX2_INODES_PER_BLOCK;
*bh = sb_bread(sb, block);
if (!*bh) {
- printk("unable to read i-node block\n");
+ printk("Unable to read inode block\n");
return NULL;
}
p = (void *)(*bh)->b_data;
@@ -204,7 +204,7 @@ void minix_free_inode(struct inode * inode)
bh = sbi->s_imap[ino >> 13];
lock_kernel();
if (!minix_test_and_clear_bit(ino & 8191, bh->b_data))
- printk("minix_free_inode: bit %lu already cleared.\n", ino);
+ printk("minix_free_inode: bit %lu already cleared\n", ino);
unlock_kernel();
mark_buffer_dirty(bh);
out:
@@ -238,7 +238,7 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)
return NULL;
}
if (minix_test_and_set_bit(j,bh->b_data)) { /* shouldn't happen */
- printk("new_inode: bit already set");
+ printk("new_inode: bit already set\n");
unlock_kernel();
iput(inode);
return NULL;
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 790cc0d0e97..2dcccf1d1b7 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -80,7 +80,8 @@ static int init_inodecache(void)
{
minix_inode_cachep = kmem_cache_create("minix_inode_cache",
sizeof(struct minix_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (minix_inode_cachep == NULL)
return -ENOMEM;
@@ -126,11 +127,11 @@ static int minix_remount (struct super_block * sb, int * flags, char * data)
mark_buffer_dirty(sbi->s_sbh);
if (!(sbi->s_mount_state & MINIX_VALID_FS))
- printk ("MINIX-fs warning: remounting unchecked fs, "
- "running fsck is recommended.\n");
+ printk("MINIX-fs warning: remounting unchecked fs, "
+ "running fsck is recommended\n");
else if ((sbi->s_mount_state & MINIX_ERROR_FS))
- printk ("MINIX-fs warning: remounting fs with errors, "
- "running fsck is recommended.\n");
+ printk("MINIX-fs warning: remounting fs with errors, "
+ "running fsck is recommended\n");
}
return 0;
}
@@ -244,11 +245,11 @@ static int minix_fill_super(struct super_block *s, void *data, int silent)
mark_buffer_dirty(bh);
}
if (!(sbi->s_mount_state & MINIX_VALID_FS))
- printk ("MINIX-fs: mounting unchecked file system, "
- "running fsck is recommended.\n");
+ printk("MINIX-fs: mounting unchecked file system, "
+ "running fsck is recommended\n");
else if (sbi->s_mount_state & MINIX_ERROR_FS)
- printk ("MINIX-fs: mounting file system with errors, "
- "running fsck is recommended.\n");
+ printk("MINIX-fs: mounting file system with errors, "
+ "running fsck is recommended\n");
return 0;
out_iput:
@@ -272,19 +273,19 @@ out_no_bitmap:
out_no_map:
if (!silent)
- printk ("MINIX-fs: can't allocate map\n");
+ printk("MINIX-fs: can't allocate map\n");
goto out_release;
out_no_fs:
if (!silent)
- printk("VFS: Can't find a Minix or Minix V2 filesystem on device "
- "%s.\n", s->s_id);
+ printk("VFS: Can't find a Minix or Minix V2 filesystem "
+ "on device %s\n", s->s_id);
out_release:
brelse(bh);
goto out;
out_bad_hblock:
- printk("MINIX-fs: blocksize too small for device.\n");
+ printk("MINIX-fs: blocksize too small for device\n");
goto out;
out_bad_sb:
@@ -523,7 +524,7 @@ int minix_sync_inode(struct inode * inode)
sync_dirty_buffer(bh);
if (buffer_req(bh) && !buffer_uptodate(bh))
{
- printk ("IO error syncing minix inode [%s:%08lx]\n",
+ printk("IO error syncing minix inode [%s:%08lx]\n",
inode->i_sb->s_id, inode->i_ino);
err = -1;
}
diff --git a/fs/minix/itree_v1.c b/fs/minix/itree_v1.c
index ba06aef4aca..656b1347a25 100644
--- a/fs/minix/itree_v1.c
+++ b/fs/minix/itree_v1.c
@@ -25,9 +25,9 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
int n = 0;
if (block < 0) {
- printk("minix_bmap: block<0");
+ printk("minix_bmap: block<0\n");
} else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
- printk("minix_bmap: block>big");
+ printk("minix_bmap: block>big\n");
} else if (block < 7) {
offsets[n++] = block;
} else if ((block -= 7) < 512) {
diff --git a/fs/minix/itree_v2.c b/fs/minix/itree_v2.c
index 3adc7675560..9adcdc754e0 100644
--- a/fs/minix/itree_v2.c
+++ b/fs/minix/itree_v2.c
@@ -25,9 +25,9 @@ static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
int n = 0;
if (block < 0) {
- printk("minix_bmap: block<0");
+ printk("minix_bmap: block<0\n");
} else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
- printk("minix_bmap: block>big");
+ printk("minix_bmap: block>big\n");
} else if (block < 7) {
offsets[n++] = block;
} else if ((block -= 7) < 256) {
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index b25bca5bdb5..5b6a4540a05 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -6,18 +6,6 @@
#include "minix.h"
-static inline void inc_count(struct inode *inode)
-{
- inode->i_nlink++;
- mark_inode_dirty(inode);
-}
-
-static inline void dec_count(struct inode *inode)
-{
- inode->i_nlink--;
- mark_inode_dirty(inode);
-}
-
static int add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = minix_add_link(dentry, inode);
@@ -25,7 +13,7 @@ static int add_nondir(struct dentry *dentry, struct inode *inode)
d_instantiate(dentry, inode);
return 0;
}
- dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
return err;
}
@@ -125,7 +113,7 @@ out:
return err;
out_fail:
- dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
goto out;
}
@@ -139,7 +127,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
return -EMLINK;
inode->i_ctime = CURRENT_TIME_SEC;
- inc_count(inode);
+ inode_inc_link_count(inode);
atomic_inc(&inode->i_count);
return add_nondir(dentry, inode);
}
@@ -152,7 +140,7 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
if (dir->i_nlink >= minix_sb(dir->i_sb)->s_link_max)
goto out;
- inc_count(dir);
+ inode_inc_link_count(dir);
inode = minix_new_inode(dir, &err);
if (!inode)
@@ -163,7 +151,7 @@ static int minix_mkdir(struct inode * dir, struct dentry *dentry, int mode)
inode->i_mode |= S_ISGID;
minix_set_inode(inode, 0);
- inc_count(inode);
+ inode_inc_link_count(inode);
err = minix_make_empty(inode, dir);
if (err)
@@ -178,11 +166,11 @@ out:
return err;
out_fail:
- dec_count(inode);
- dec_count(inode);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
out_dir:
- dec_count(dir);
+ inode_dec_link_count(dir);
goto out;
}
@@ -202,7 +190,7 @@ static int minix_unlink(struct inode * dir, struct dentry *dentry)
goto end_unlink;
inode->i_ctime = dir->i_ctime;
- dec_count(inode);
+ inode_dec_link_count(inode);
end_unlink:
return err;
}
@@ -215,8 +203,8 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
if (minix_empty_dir(inode)) {
err = minix_unlink(dir, dentry);
if (!err) {
- dec_count(dir);
- dec_count(inode);
+ inode_dec_link_count(dir);
+ inode_dec_link_count(inode);
}
}
return err;
@@ -257,34 +245,34 @@ static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
new_de = minix_find_entry(new_dentry, &new_page);
if (!new_de)
goto out_dir;
- inc_count(old_inode);
+ inode_inc_link_count(old_inode);
minix_set_link(new_de, new_page, old_inode);
new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de)
new_inode->i_nlink--;
- dec_count(new_inode);
+ inode_dec_link_count(new_inode);
} else {
if (dir_de) {
err = -EMLINK;
if (new_dir->i_nlink >= info->s_link_max)
goto out_dir;
}
- inc_count(old_inode);
+ inode_inc_link_count(old_inode);
err = minix_add_link(new_dentry, old_inode);
if (err) {
- dec_count(old_inode);
+ inode_dec_link_count(old_inode);
goto out_dir;
}
if (dir_de)
- inc_count(new_dir);
+ inode_inc_link_count(new_dir);
}
minix_delete_entry(old_de, old_page);
- dec_count(old_inode);
+ inode_dec_link_count(old_inode);
if (dir_de) {
minix_set_link(dir_de, dir_page, new_dir);
- dec_count(old_dir);
+ inode_dec_link_count(old_dir);
}
return 0;
diff --git a/fs/namei.c b/fs/namei.c
index 8dc2b038d5d..712dfc77793 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -104,7 +104,7 @@
*/
/*
* [Sep 2001 AV] Single-semaphore locking scheme (kudos to David Holland)
- * implemented. Let's see if raised priority of ->s_vfs_rename_sem gives
+ * implemented. Let's see if raised priority of ->s_vfs_rename_mutex gives
* any extra contention...
*/
@@ -1422,7 +1422,7 @@ struct dentry *lock_rename(struct dentry *p1, struct dentry *p2)
return NULL;
}
- down(&p1->d_inode->i_sb->s_vfs_rename_sem);
+ mutex_lock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
for (p = p1; p->d_parent != p; p = p->d_parent) {
if (p->d_parent == p2) {
@@ -1450,7 +1450,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
mutex_unlock(&p1->d_inode->i_mutex);
if (p1 != p2) {
mutex_unlock(&p2->d_inode->i_mutex);
- up(&p1->d_inode->i_sb->s_vfs_rename_sem);
+ mutex_unlock(&p1->d_inode->i_sb->s_vfs_rename_mutex);
}
}
@@ -1628,6 +1628,12 @@ do_last:
goto exit;
}
+ if (IS_ERR(nd->intent.open.file)) {
+ mutex_unlock(&dir->d_inode->i_mutex);
+ error = PTR_ERR(nd->intent.open.file);
+ goto exit_dput;
+ }
+
/* Negative dentry, just create the file */
if (!path.dentry->d_inode) {
if (!IS_POSIXACL(dir->d_inode))
@@ -2277,17 +2283,17 @@ asmlinkage long sys_link(const char __user *oldname, const char __user *newname)
* a) we can get into loop creation. Check is done in is_subdir().
* b) race potential - two innocent renames can create a loop together.
* That's where 4.4 screws up. Current fix: serialization on
- * sb->s_vfs_rename_sem. We might be more accurate, but that's another
+ * sb->s_vfs_rename_mutex. We might be more accurate, but that's another
* story.
* c) we have to lock _three_ objects - parents and victim (if it exists).
* And that - after we got ->i_mutex on parents (until then we don't know
* whether the target exists). Solution: try to be smart with locking
* order for inodes. We rely on the fact that tree topology may change
- * only under ->s_vfs_rename_sem _and_ that parent of the object we
+ * only under ->s_vfs_rename_mutex _and_ that parent of the object we
* move will be locked. Thus we can rank directories by the tree
* (ancestors first) and rank all non-directories after them.
* That works since everybody except rename does "lock parent, lookup,
- * lock child" and rename is under ->s_vfs_rename_sem.
+ * lock child" and rename is under ->s_vfs_rename_mutex.
* HOWEVER, it relies on the assumption that any object with ->lookup()
* has no more than 1 dentry. If "hybrid" objects will ever appear,
* we'd better make sure that there's no link(2) for them.
@@ -2621,16 +2627,27 @@ int __page_symlink(struct inode *inode, const char *symname, int len,
int err = -ENOMEM;
char *kaddr;
+retry:
page = find_or_create_page(mapping, 0, gfp_mask);
if (!page)
goto fail;
err = mapping->a_ops->prepare_write(NULL, page, 0, len-1);
+ if (err == AOP_TRUNCATED_PAGE) {
+ page_cache_release(page);
+ goto retry;
+ }
if (err)
goto fail_map;
kaddr = kmap_atomic(page, KM_USER0);
memcpy(kaddr, symname, len-1);
kunmap_atomic(kaddr, KM_USER0);
- mapping->a_ops->commit_write(NULL, page, 0, len-1);
+ err = mapping->a_ops->commit_write(NULL, page, 0, len-1);
+ if (err == AOP_TRUNCATED_PAGE) {
+ page_cache_release(page);
+ goto retry;
+ }
+ if (err)
+ goto fail_map;
/*
* Notice that we are _not_ going to block here - end of page is
* unmapped, so this will only try to map the rest of page, see
@@ -2640,7 +2657,8 @@ int __page_symlink(struct inode *inode, const char *symname, int len,
*/
if (!PageUptodate(page)) {
err = mapping->a_ops->readpage(NULL, page);
- wait_on_page_locked(page);
+ if (err != AOP_TRUNCATED_PAGE)
+ wait_on_page_locked(page);
} else {
unlock_page(page);
}
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c
index 973b444d691..ebdad8f6398 100644
--- a/fs/ncpfs/file.c
+++ b/fs/ncpfs/file.c
@@ -46,7 +46,7 @@ int ncp_make_open(struct inode *inode, int right)
NCP_FINFO(inode)->volNumber,
NCP_FINFO(inode)->dirEntNum);
error = -EACCES;
- down(&NCP_FINFO(inode)->open_sem);
+ mutex_lock(&NCP_FINFO(inode)->open_mutex);
if (!atomic_read(&NCP_FINFO(inode)->opened)) {
struct ncp_entry_info finfo;
int result;
@@ -93,7 +93,7 @@ int ncp_make_open(struct inode *inode, int right)
}
out_unlock:
- up(&NCP_FINFO(inode)->open_sem);
+ mutex_unlock(&NCP_FINFO(inode)->open_mutex);
out:
return error;
}
diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index d277a58bd12..a1f3e972c6e 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -63,7 +63,7 @@ static void init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
SLAB_CTOR_CONSTRUCTOR) {
- init_MUTEX(&ei->open_sem);
+ mutex_init(&ei->open_mutex);
inode_init_once(&ei->vfs_inode);
}
}
@@ -72,7 +72,8 @@ static int init_inodecache(void)
{
ncp_inode_cachep = kmem_cache_create("ncp_inode_cache",
sizeof(struct ncp_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (ncp_inode_cachep == NULL)
return -ENOMEM;
@@ -520,7 +521,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
}
/* server->lock = 0; */
- init_MUTEX(&server->sem);
+ mutex_init(&server->mutex);
server->packet = NULL;
/* server->buffer_size = 0; */
/* server->conn_status = 0; */
@@ -557,7 +558,7 @@ static int ncp_fill_super(struct super_block *sb, void *raw_data, int silent)
server->dentry_ttl = 0; /* no caching */
INIT_LIST_HEAD(&server->tx.requests);
- init_MUTEX(&server->rcv.creq_sem);
+ mutex_init(&server->rcv.creq_mutex);
server->tx.creq = NULL;
server->rcv.creq = NULL;
server->data_ready = sock->sk->sk_data_ready;
diff --git a/fs/ncpfs/ncplib_kernel.c b/fs/ncpfs/ncplib_kernel.c
index c755e1848a4..d9ebf6439f5 100644
--- a/fs/ncpfs/ncplib_kernel.c
+++ b/fs/ncpfs/ncplib_kernel.c
@@ -291,7 +291,7 @@ ncp_make_closed(struct inode *inode)
int err;
err = 0;
- down(&NCP_FINFO(inode)->open_sem);
+ mutex_lock(&NCP_FINFO(inode)->open_mutex);
if (atomic_read(&NCP_FINFO(inode)->opened) == 1) {
atomic_set(&NCP_FINFO(inode)->opened, 0);
err = ncp_close_file(NCP_SERVER(inode), NCP_FINFO(inode)->file_handle);
@@ -301,7 +301,7 @@ ncp_make_closed(struct inode *inode)
NCP_FINFO(inode)->volNumber,
NCP_FINFO(inode)->dirEntNum, err);
}
- up(&NCP_FINFO(inode)->open_sem);
+ mutex_unlock(&NCP_FINFO(inode)->open_mutex);
return err;
}
diff --git a/fs/ncpfs/sock.c b/fs/ncpfs/sock.c
index 6593a5ca88b..8783eb7ec64 100644
--- a/fs/ncpfs/sock.c
+++ b/fs/ncpfs/sock.c
@@ -171,9 +171,9 @@ static inline void __ncp_abort_request(struct ncp_server *server, struct ncp_req
static inline void ncp_abort_request(struct ncp_server *server, struct ncp_request_reply *req, int err)
{
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
__ncp_abort_request(server, req, err);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
}
static inline void __ncptcp_abort(struct ncp_server *server)
@@ -303,20 +303,20 @@ static inline void __ncp_start_request(struct ncp_server *server, struct ncp_req
static int ncp_add_request(struct ncp_server *server, struct ncp_request_reply *req)
{
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
if (!ncp_conn_valid(server)) {
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
printk(KERN_ERR "ncpfs: tcp: Server died\n");
return -EIO;
}
if (server->tx.creq || server->rcv.creq) {
req->status = RQ_QUEUED;
list_add_tail(&req->req, &server->tx.requests);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
return 0;
}
__ncp_start_request(server, req);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
return 0;
}
@@ -400,7 +400,7 @@ void ncpdgram_rcv_proc(void *s)
info_server(server, 0, server->unexpected_packet.data, result);
continue;
}
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
req = server->rcv.creq;
if (req && (req->tx_type == NCP_ALLOC_SLOT_REQUEST || (server->sequence == reply.sequence &&
server->connection == get_conn_number(&reply)))) {
@@ -430,11 +430,11 @@ void ncpdgram_rcv_proc(void *s)
server->rcv.creq = NULL;
ncp_finish_request(req, result);
__ncp_next_request(server);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
continue;
}
}
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
}
drop:;
_recv(sock, &reply, sizeof(reply), MSG_DONTWAIT);
@@ -472,9 +472,9 @@ static void __ncpdgram_timeout_proc(struct ncp_server *server)
void ncpdgram_timeout_proc(void *s)
{
struct ncp_server *server = s;
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
__ncpdgram_timeout_proc(server);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
}
static inline void ncp_init_req(struct ncp_request_reply* req)
@@ -657,18 +657,18 @@ void ncp_tcp_rcv_proc(void *s)
{
struct ncp_server *server = s;
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
__ncptcp_rcv_proc(server);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
}
void ncp_tcp_tx_proc(void *s)
{
struct ncp_server *server = s;
- down(&server->rcv.creq_sem);
+ mutex_lock(&server->rcv.creq_mutex);
__ncptcp_try_send(server);
- up(&server->rcv.creq_sem);
+ mutex_unlock(&server->rcv.creq_mutex);
}
static int do_ncp_rpc_call(struct ncp_server *server, int size,
@@ -833,7 +833,7 @@ int ncp_disconnect(struct ncp_server *server)
void ncp_lock_server(struct ncp_server *server)
{
- down(&server->sem);
+ mutex_lock(&server->mutex);
if (server->lock)
printk(KERN_WARNING "ncp_lock_server: was locked!\n");
server->lock = 1;
@@ -846,5 +846,5 @@ void ncp_unlock_server(struct ncp_server *server)
return;
}
server->lock = 0;
- up(&server->sem);
+ mutex_unlock(&server->mutex);
}
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 4e9b3a1b36c..4ae2f3b33fe 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -781,7 +781,8 @@ int nfs_init_directcache(void)
{
nfs_direct_cachep = kmem_cache_create("nfs_direct_cache",
sizeof(struct nfs_direct_req),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
NULL, NULL);
if (nfs_direct_cachep == NULL)
return -ENOMEM;
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index a77ee95b7ef..3413996f9a8 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -103,7 +103,7 @@ static struct rpc_version * nfs_version[] = {
static struct rpc_program nfs_program = {
.name = "nfs",
.number = NFS_PROGRAM,
- .nrvers = sizeof(nfs_version) / sizeof(nfs_version[0]),
+ .nrvers = ARRAY_SIZE(nfs_version),
.version = nfs_version,
.stats = &nfs_rpcstat,
.pipe_dir_name = "/nfs",
@@ -118,7 +118,7 @@ static struct rpc_version * nfsacl_version[] = {
struct rpc_program nfsacl_program = {
.name = "nfsacl",
.number = NFS_ACL_PROGRAM,
- .nrvers = sizeof(nfsacl_version) / sizeof(nfsacl_version[0]),
+ .nrvers = ARRAY_SIZE(nfsacl_version),
.version = nfsacl_version,
.stats = &nfsacl_rpcstat,
};
@@ -1679,7 +1679,7 @@ static struct super_block *nfs_get_sb(struct file_system_type *fs_type,
s->s_flags = flags;
- error = nfs_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
+ error = nfs_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
if (error) {
up_write(&s->s_umount);
deactivate_super(s);
@@ -1996,7 +1996,7 @@ static struct super_block *nfs4_get_sb(struct file_system_type *fs_type,
s->s_flags = flags;
- error = nfs4_fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
+ error = nfs4_fill_super(s, data, flags & MS_SILENT ? 1 : 0);
if (error) {
up_write(&s->s_umount);
deactivate_super(s);
@@ -2163,7 +2163,8 @@ static int nfs_init_inodecache(void)
{
nfs_inode_cachep = kmem_cache_create("nfs_inode_cache",
sizeof(struct nfs_inode),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (nfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/nfs/mount_clnt.c b/fs/nfs/mount_clnt.c
index db99b8f678f..0b9a78353d6 100644
--- a/fs/nfs/mount_clnt.c
+++ b/fs/nfs/mount_clnt.c
@@ -174,7 +174,7 @@ static struct rpc_stat mnt_stats;
static struct rpc_program mnt_program = {
.name = "mount",
.number = NFS_MNT_PROGRAM,
- .nrvers = sizeof(mnt_version)/sizeof(mnt_version[0]),
+ .nrvers = ARRAY_SIZE(mnt_version),
.version = mnt_version,
.stats = &mnt_stats,
};
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index 7fc0560c89c..6548a65de94 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -704,6 +704,6 @@ struct rpc_procinfo nfs_procedures[] = {
struct rpc_version nfs_version2 = {
.number = 2,
- .nrprocs = sizeof(nfs_procedures)/sizeof(nfs_procedures[0]),
+ .nrprocs = ARRAY_SIZE(nfs_procedures),
.procs = nfs_procedures
};
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index b6c0b5012bc..5224a191efb 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -1138,7 +1138,7 @@ struct rpc_procinfo nfs3_procedures[] = {
struct rpc_version nfs_version3 = {
.number = 3,
- .nrprocs = sizeof(nfs3_procedures)/sizeof(nfs3_procedures[0]),
+ .nrprocs = ARRAY_SIZE(nfs3_procedures),
.procs = nfs3_procedures
};
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 4bbf5ef5778..0a1bd36a483 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -4384,7 +4384,7 @@ struct rpc_procinfo nfs4_procedures[] = {
struct rpc_version nfs_version4 = {
.number = 4,
- .nrprocs = sizeof(nfs4_procedures)/sizeof(nfs4_procedures[0]),
+ .nrprocs = ARRAY_SIZE(nfs4_procedures),
.procs = nfs4_procedures
};
diff --git a/fs/nfsctl.c b/fs/nfsctl.c
index 1c72c7f85dd..a5a18d4aca4 100644
--- a/fs/nfsctl.c
+++ b/fs/nfsctl.c
@@ -101,7 +101,7 @@ asmlinkage sys_nfsservctl(int cmd, struct nfsctl_arg __user *arg, void __user *r
if (version != NFSCTL_VERSION)
return -EINVAL;
- if (cmd < 0 || cmd >= sizeof(map)/sizeof(map[0]) || !map[cmd].name)
+ if (cmd < 0 || cmd >= ARRAY_SIZE(map) || !map[cmd].name)
return -EINVAL;
file = do_open(map[cmd].name, map[cmd].rsize ? O_RDWR : O_WRONLY);
diff --git a/fs/nfsd/nfs4acl.c b/fs/nfsd/nfs4acl.c
index 4a2105552ac..7391f4aabed 100644
--- a/fs/nfsd/nfs4acl.c
+++ b/fs/nfsd/nfs4acl.c
@@ -907,7 +907,7 @@ nfs4_acl_get_whotype(char *p, u32 len)
{
int i;
- for (i=0; i < sizeof(s2t_map) / sizeof(*s2t_map); i++) {
+ for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
if (s2t_map[i].stringlen == len &&
0 == memcmp(s2t_map[i].string, p, len))
return s2t_map[i].type;
@@ -920,7 +920,7 @@ nfs4_acl_write_who(int who, char *p)
{
int i;
- for (i=0; i < sizeof(s2t_map) / sizeof(*s2t_map); i++) {
+ for (i = 0; i < ARRAY_SIZE(s2t_map); i++) {
if (s2t_map[i].type == who) {
memcpy(p, s2t_map[i].string, s2t_map[i].stringlen);
return s2t_map[i].stringlen;
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c
index d828662d737..8d3d23c8a4d 100644
--- a/fs/nfsd/nfs4callback.c
+++ b/fs/nfsd/nfs4callback.c
@@ -335,7 +335,7 @@ static struct rpc_procinfo nfs4_cb_procedures[] = {
static struct rpc_version nfs_cb_version4 = {
.number = 1,
- .nrprocs = sizeof(nfs4_cb_procedures)/sizeof(nfs4_cb_procedures[0]),
+ .nrprocs = ARRAY_SIZE(nfs4_cb_procedures),
.procs = nfs4_cb_procedures
};
@@ -411,7 +411,7 @@ nfsd4_probe_callback(struct nfs4_client *clp)
/* Initialize rpc_program */
program->name = "nfs4_cb";
program->number = cb->cb_prog;
- program->nrvers = sizeof(nfs_cb_version)/sizeof(nfs_cb_version[0]);
+ program->nrvers = ARRAY_SIZE(nfs_cb_version);
program->version = nfs_cb_version;
program->stats = stat;
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 69d3501173a..03857fd8112 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -992,7 +992,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
if (argp->opcnt > 100)
goto xdr_error;
- if (argp->opcnt > sizeof(argp->iops)/sizeof(argp->iops[0])) {
+ if (argp->opcnt > ARRAY_SIZE(argp->iops)) {
argp->ops = kmalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL);
if (!argp->ops) {
argp->ops = argp->iops;
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index a0871b3efeb..c8960aff096 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -105,7 +105,7 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu
char *data;
ssize_t rv;
- if (ino >= sizeof(write_op)/sizeof(write_op[0]) || !write_op[ino])
+ if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
return -EINVAL;
data = simple_transaction_get(file, buf, size);
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c
index 1d163b61691..3790727e5df 100644
--- a/fs/nfsd/nfssvc.c
+++ b/fs/nfsd/nfssvc.c
@@ -72,7 +72,7 @@ static struct svc_version * nfsd_acl_version[] = {
};
#define NFSD_ACL_MINVERS 2
-#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0]))
+#define NFSD_ACL_NRVERS ARRAY_SIZE(nfsd_acl_version)
static struct svc_version *nfsd_acl_versions[NFSD_ACL_NRVERS];
static struct svc_program nfsd_acl_program = {
@@ -101,7 +101,7 @@ static struct svc_version * nfsd_version[] = {
};
#define NFSD_MINVERS 2
-#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0]))
+#define NFSD_NRVERS ARRAY_SIZE(nfsd_version)
static struct svc_version *nfsd_versions[NFSD_NRVERS];
struct svc_program nfsd_program = {
diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
index 80f108ae666..06640c3e402 100644
--- a/fs/nls/nls_euc-jp.c
+++ b/fs/nls/nls_euc-jp.c
@@ -268,8 +268,6 @@ static unsigned char euc2sjisibm_g3upper_map[][2] = {
{0xFC, 0x4B},
};
-#define MAP_ELEMENT_OF(map) (sizeof(map) / sizeof(map[0]))
-
static inline int sjisibm2euc(unsigned char *euc, const unsigned char sjis_hi,
const unsigned char sjis_lo);
static inline int euc2sjisibm_jisx0212(unsigned char *sjis, const unsigned char euc_hi,
@@ -310,7 +308,7 @@ static inline int euc2sjisibm_jisx0212(unsigned char *sjis, const unsigned char
unsigned short euc;
min_index = 0;
- max_index = MAP_ELEMENT_OF(euc2sjisibm_jisx0212_map) - 1;
+ max_index = ARRAY_SIZE(euc2sjisibm_jisx0212_map) - 1;
euc = (euc_hi << 8) | euc_lo;
while (min_index <= max_index) {
@@ -339,7 +337,7 @@ static inline int euc2sjisibm_g3upper(unsigned char *sjis, const unsigned char e
else
index = ((euc_hi << 8) | euc_lo) - 0xF4A1 + 12;
- if ((index < 0) || (index >= MAP_ELEMENT_OF(euc2sjisibm_g3upper_map)))
+ if ((index < 0) || (index >= ARRAY_SIZE(euc2sjisibm_g3upper_map)))
return 0;
sjis[0] = euc2sjisibm_g3upper_map[index][0];
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 9d8ffa89e2c..35cc4b1d60f 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -16,8 +16,34 @@ ToDo/Notes:
inode having been discarded already. Whether this can actually ever
happen is unclear however so it is worth waiting until someone hits
the problem.
- - Enable the code for setting the NT4 compatibility flag when we start
- making NTFS 1.2 specific modifications.
+
+2.1.27 - Various bug fixes and cleanups.
+
+ - Fix two compiler warnings on Alpha. Thanks to Andrew Morton for
+ reporting them.
+ - Fix an (innocent) off-by-one error in the runlist code.
+ - Fix a buggette in an "should be impossible" case handling where we
+ continued the attribute lookup loop instead of aborting it.
+ - Use buffer_migrate_page() for the ->migratepage function of all ntfs
+ address space operations.
+ - Fix comparison of $MFT and $MFTMirr to not bail out when there are
+ unused, invalid mft records which are the same in both $MFT and
+ $MFTMirr.
+ - Add support for sparse files which have a compression unit of 0.
+ - Remove all the make_bad_inode() calls. This should only be called
+ from read inode and new inode code paths.
+ - Limit name length in fs/ntfs/unistr.c::ntfs_nlstoucs() to maximum
+ allowed by NTFS, i.e. 255 Unicode characters, not including the
+ terminating NULL (which is not stored on disk).
+ - Improve comments on file attribute flags in fs/ntfs/layout.h.
+ - Fix a bug in fs/ntfs/inode.c::ntfs_read_locked_index_inode() where we
+ forgot to update a temporary variable so loading index inodes which
+ have an index allocation attribute failed.
+ - Add a missing call to flush_dcache_mft_record_page() in
+ fs/ntfs/inode.c::ntfs_write_inode().
+ - Handle the recently introduced -ENAMETOOLONG return value from
+ fs/ntfs/unistr.c::ntfs_nlstoucs() in fs/ntfs/namei.c::ntfs_lookup().
+ - Semaphore to mutex conversion. (Ingo Molnar)
2.1.26 - Minor bug fixes and updates.
diff --git a/fs/ntfs/Makefile b/fs/ntfs/Makefile
index d95fac7fdeb..e27b4eacffb 100644
--- a/fs/ntfs/Makefile
+++ b/fs/ntfs/Makefile
@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \
unistr.o upcase.o
-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.26\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.27\"
ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG
diff --git a/fs/ntfs/aops.c b/fs/ntfs/aops.c
index 7e361da770b..580412d330c 100644
--- a/fs/ntfs/aops.c
+++ b/fs/ntfs/aops.c
@@ -22,6 +22,7 @@
*/
#include <linux/errno.h>
+#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/swap.h>
@@ -1277,18 +1278,18 @@ unm_done:
tni = locked_nis[nr_locked_nis];
/* Get the base inode. */
- down(&tni->extent_lock);
+ mutex_lock(&tni->extent_lock);
if (tni->nr_extents >= 0)
base_tni = tni;
else {
base_tni = tni->ext.base_ntfs_ino;
BUG_ON(!base_tni);
}
- up(&tni->extent_lock);
+ mutex_unlock(&tni->extent_lock);
ntfs_debug("Unlocking %s inode 0x%lx.",
tni == base_tni ? "base" : "extent",
tni->mft_no);
- up(&tni->mrec_lock);
+ mutex_unlock(&tni->mrec_lock);
atomic_dec(&tni->count);
iput(VFS_I(base_tni));
}
@@ -1529,7 +1530,6 @@ err_out:
"error %i.", err);
SetPageError(page);
NVolSetErrors(ni->vol);
- make_bad_inode(vi);
}
unlock_page(page);
if (ctx)
@@ -1551,6 +1551,9 @@ struct address_space_operations ntfs_aops = {
#ifdef NTFS_RW
.writepage = ntfs_writepage, /* Write dirty page to disk. */
#endif /* NTFS_RW */
+ .migratepage = buffer_migrate_page, /* Move a page cache page from
+ one physical page to an
+ other. */
};
/**
@@ -1567,6 +1570,9 @@ struct address_space_operations ntfs_mst_aops = {
without touching the buffers
belonging to the page. */
#endif /* NTFS_RW */
+ .migratepage = buffer_migrate_page, /* Move a page cache page from
+ one physical page to an
+ other. */
};
#ifdef NTFS_RW
diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
index 9480a0526cd..1663f5c3c6a 100644
--- a/fs/ntfs/attrib.c
+++ b/fs/ntfs/attrib.c
@@ -1,7 +1,7 @@
/**
* attrib.c - NTFS attribute operations. Part of the Linux-NTFS project.
*
- * Copyright (c) 2001-2005 Anton Altaparmakov
+ * Copyright (c) 2001-2006 Anton Altaparmakov
* Copyright (c) 2002 Richard Russon
*
* This program/include file is free software; you can redistribute it and/or
@@ -1048,7 +1048,7 @@ do_next_attr_loop:
le32_to_cpu(ctx->mrec->bytes_allocated))
break;
if (a->type == AT_END)
- continue;
+ break;
if (!a->length)
break;
if (al_entry->instance != a->instance)
@@ -1695,7 +1695,9 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
a->data.non_resident.initialized_size =
cpu_to_sle64(attr_size);
if (NInoSparse(ni) || NInoCompressed(ni)) {
- a->data.non_resident.compression_unit = 4;
+ a->data.non_resident.compression_unit = 0;
+ if (NInoCompressed(ni) || vol->major_ver < 3)
+ a->data.non_resident.compression_unit = 4;
a->data.non_resident.compressed_size =
a->data.non_resident.allocated_size;
} else
@@ -1714,13 +1716,20 @@ int ntfs_attr_make_non_resident(ntfs_inode *ni, const u32 data_size)
ni->allocated_size = new_size;
if (NInoSparse(ni) || NInoCompressed(ni)) {
ni->itype.compressed.size = ni->allocated_size;
- ni->itype.compressed.block_size = 1U <<
- (a->data.non_resident.compression_unit +
- vol->cluster_size_bits);
- ni->itype.compressed.block_size_bits =
- ffs(ni->itype.compressed.block_size) - 1;
- ni->itype.compressed.block_clusters = 1U <<
- a->data.non_resident.compression_unit;
+ if (a->data.non_resident.compression_unit) {
+ ni->itype.compressed.block_size = 1U << (a->data.
+ non_resident.compression_unit +
+ vol->cluster_size_bits);
+ ni->itype.compressed.block_size_bits =
+ ffs(ni->itype.compressed.block_size) -
+ 1;
+ ni->itype.compressed.block_clusters = 1U <<
+ a->data.non_resident.compression_unit;
+ } else {
+ ni->itype.compressed.block_size = 0;
+ ni->itype.compressed.block_size_bits = 0;
+ ni->itype.compressed.block_clusters = 0;
+ }
vi->i_blocks = ni->itype.compressed.size >> 9;
} else
vi->i_blocks = ni->allocated_size >> 9;
@@ -2429,16 +2438,12 @@ undo_alloc:
"chkdsk to recover.", IS_ERR(m) ?
"restore attribute search context" :
"truncate attribute runlist");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
} else if (mp_rebuilt) {
if (ntfs_attr_record_resize(m, a, attr_len)) {
ntfs_error(vol->sb, "Failed to restore attribute "
"record in error code path. Run "
"chkdsk to recover.");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
} else /* if (success) */ {
if (ntfs_mapping_pairs_build(vol, (u8*)a + le16_to_cpu(
@@ -2451,8 +2456,6 @@ undo_alloc:
"mapping pairs array in error "
"code path. Run chkdsk to "
"recover.");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
}
flush_dcache_mft_record_page(ctx->ntfs_ino);
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c
index 25d24106f89..68a607ff9fd 100644
--- a/fs/ntfs/compress.c
+++ b/fs/ntfs/compress.c
@@ -67,7 +67,7 @@ static DEFINE_SPINLOCK(ntfs_cb_lock);
/**
* allocate_compression_buffers - allocate the decompression buffers
*
- * Caller has to hold the ntfs_lock semaphore.
+ * Caller has to hold the ntfs_lock mutex.
*
* Return 0 on success or -ENOMEM if the allocations failed.
*/
@@ -84,7 +84,7 @@ int allocate_compression_buffers(void)
/**
* free_compression_buffers - free the decompression buffers
*
- * Caller has to hold the ntfs_lock semaphore.
+ * Caller has to hold the ntfs_lock mutex.
*/
void free_compression_buffers(void)
{
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index b0690d4c890..9d9ed3fe371 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1136,7 +1136,7 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (fpos == 1) {
ntfs_debug("Calling filldir for .. with len 2, fpos 0x1, "
"inode 0x%lx, DT_DIR.",
- parent_ino(filp->f_dentry));
+ (unsigned long)parent_ino(filp->f_dentry));
rc = filldir(dirent, "..", 2, fpos,
parent_ino(filp->f_dentry), DT_DIR);
if (rc)
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 5027d3d1b3f..f5d057e4acc 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -943,7 +943,8 @@ rl_not_mapped_enoent:
}
ni->runlist.rl = rl;
status.runlist_merged = 1;
- ntfs_debug("Allocated cluster, lcn 0x%llx.", lcn);
+ ntfs_debug("Allocated cluster, lcn 0x%llx.",
+ (unsigned long long)lcn);
/* Map and lock the mft record and get the attribute record. */
if (!NInoAttr(ni))
base_ni = ni;
@@ -1206,8 +1207,6 @@ rl_not_mapped_enoent:
"attribute runlist in error code "
"path. Run chkdsk to recover the "
"lost cluster.");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
} else /* if (success) */ {
status.runlist_merged = 0;
@@ -1238,8 +1237,6 @@ rl_not_mapped_enoent:
ntfs_error(vol->sb, "Failed to restore attribute "
"record in error code path. Run "
"chkdsk to recover.");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
} else /* if (success) */ {
if (ntfs_mapping_pairs_build(vol, (u8*)a +
@@ -1252,8 +1249,6 @@ rl_not_mapped_enoent:
"mapping pairs array in error "
"code path. Run chkdsk to "
"recover.");
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
NVolSetErrors(vol);
}
flush_dcache_mft_record_page(ctx->ntfs_ino);
@@ -1622,11 +1617,8 @@ err_out:
unmap_mft_record(base_ni);
ntfs_error(vi->i_sb, "Failed to update initialized_size/i_size (error "
"code %i).", err);
- if (err != -ENOMEM) {
+ if (err != -ENOMEM)
NVolSetErrors(ni->vol);
- make_bad_inode(VFS_I(base_ni));
- make_bad_inode(vi);
- }
return err;
}
@@ -1801,8 +1793,6 @@ err_out:
ntfs_error(vi->i_sb, "Resident attribute commit write failed "
"with error %i.", err);
NVolSetErrors(ni->vol);
- make_bad_inode(VFS_I(base_ni));
- make_bad_inode(vi);
}
if (ctx)
ntfs_attr_put_search_ctx(ctx);
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 55263b7de9c..4c86b7e1d1e 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -1,7 +1,7 @@
/**
* inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
*
- * Copyright (c) 2001-2005 Anton Altaparmakov
+ * Copyright (c) 2001-2006 Anton Altaparmakov
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -19,13 +19,19 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <linux/pagemap.h>
#include <linux/buffer_head.h>
-#include <linux/smp_lock.h>
-#include <linux/quotaops.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
#include <linux/mount.h>
+#include <linux/mutex.h>
+#include <linux/pagemap.h>
+#include <linux/quotaops.h>
+#include <linux/slab.h>
+#include <linux/smp_lock.h>
#include "aops.h"
+#include "attrib.h"
+#include "bitmap.h"
#include "dir.h"
#include "debug.h"
#include "inode.h"
@@ -382,7 +388,7 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
atomic_set(&ni->count, 1);
ni->vol = NTFS_SB(sb);
ntfs_init_runlist(&ni->runlist);
- init_MUTEX(&ni->mrec_lock);
+ mutex_init(&ni->mrec_lock);
ni->page = NULL;
ni->page_ofs = 0;
ni->attr_list_size = 0;
@@ -394,7 +400,7 @@ void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
ni->itype.index.collation_rule = 0;
ni->itype.index.block_size_bits = 0;
ni->itype.index.vcn_size_bits = 0;
- init_MUTEX(&ni->extent_lock);
+ mutex_init(&ni->extent_lock);
ni->nr_extents = 0;
ni->ext.base_ntfs_ino = NULL;
}
@@ -1064,10 +1070,10 @@ skip_large_dir_stuff:
if (a->non_resident) {
NInoSetNonResident(ni);
if (NInoCompressed(ni) || NInoSparse(ni)) {
- if (a->data.non_resident.compression_unit !=
- 4) {
+ if (NInoCompressed(ni) && a->data.non_resident.
+ compression_unit != 4) {
ntfs_error(vi->i_sb, "Found "
- "nonstandard "
+ "non-standard "
"compression unit (%u "
"instead of 4). "
"Cannot handle this.",
@@ -1076,16 +1082,26 @@ skip_large_dir_stuff:
err = -EOPNOTSUPP;
goto unm_err_out;
}
- ni->itype.compressed.block_clusters = 1U <<
- a->data.non_resident.
- compression_unit;
- ni->itype.compressed.block_size = 1U << (
- a->data.non_resident.
- compression_unit +
- vol->cluster_size_bits);
- ni->itype.compressed.block_size_bits = ffs(
- ni->itype.compressed.
- block_size) - 1;
+ if (a->data.non_resident.compression_unit) {
+ ni->itype.compressed.block_size = 1U <<
+ (a->data.non_resident.
+ compression_unit +
+ vol->cluster_size_bits);
+ ni->itype.compressed.block_size_bits =
+ ffs(ni->itype.
+ compressed.
+ block_size) - 1;
+ ni->itype.compressed.block_clusters =
+ 1U << a->data.
+ non_resident.
+ compression_unit;
+ } else {
+ ni->itype.compressed.block_size = 0;
+ ni->itype.compressed.block_size_bits =
+ 0;
+ ni->itype.compressed.block_clusters =
+ 0;
+ }
ni->itype.compressed.size = sle64_to_cpu(
a->data.non_resident.
compressed_size);
@@ -1338,8 +1354,9 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
goto unm_err_out;
}
if (NInoCompressed(ni) || NInoSparse(ni)) {
- if (a->data.non_resident.compression_unit != 4) {
- ntfs_error(vi->i_sb, "Found nonstandard "
+ if (NInoCompressed(ni) && a->data.non_resident.
+ compression_unit != 4) {
+ ntfs_error(vi->i_sb, "Found non-standard "
"compression unit (%u instead "
"of 4). Cannot handle this.",
a->data.non_resident.
@@ -1347,13 +1364,22 @@ static int ntfs_read_locked_attr_inode(struct inode *base_vi, struct inode *vi)
err = -EOPNOTSUPP;
goto unm_err_out;
}
- ni->itype.compressed.block_clusters = 1U <<
- a->data.non_resident.compression_unit;
- ni->itype.compressed.block_size = 1U << (
- a->data.non_resident.compression_unit +
- vol->cluster_size_bits);
- ni->itype.compressed.block_size_bits = ffs(
- ni->itype.compressed.block_size) - 1;
+ if (a->data.non_resident.compression_unit) {
+ ni->itype.compressed.block_size = 1U <<
+ (a->data.non_resident.
+ compression_unit +
+ vol->cluster_size_bits);
+ ni->itype.compressed.block_size_bits =
+ ffs(ni->itype.compressed.
+ block_size) - 1;
+ ni->itype.compressed.block_clusters = 1U <<
+ a->data.non_resident.
+ compression_unit;
+ } else {
+ ni->itype.compressed.block_size = 0;
+ ni->itype.compressed.block_size_bits = 0;
+ ni->itype.compressed.block_clusters = 0;
+ }
ni->itype.compressed.size = sle64_to_cpu(
a->data.non_resident.compressed_size);
}
@@ -1406,7 +1432,6 @@ err_out:
"Run chkdsk.", err, vi->i_ino, ni->type, ni->name_len,
base_vi->i_ino);
make_bad_inode(vi);
- make_bad_inode(base_vi);
if (err != -ENOMEM)
NVolSetErrors(vol);
return err;
@@ -1591,6 +1616,7 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
"$INDEX_ALLOCATION attribute.");
goto unm_err_out;
}
+ a = ctx->attr;
if (!a->non_resident) {
ntfs_error(vi->i_sb, "$INDEX_ALLOCATION attribute is "
"resident.");
@@ -2823,11 +2849,8 @@ done:
old_bad_out:
old_size = -1;
bad_out:
- if (err != -ENOMEM && err != -EOPNOTSUPP) {
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
+ if (err != -ENOMEM && err != -EOPNOTSUPP)
NVolSetErrors(vol);
- }
if (err != -EOPNOTSUPP)
NInoSetTruncateFailed(ni);
else if (old_size >= 0)
@@ -2842,11 +2865,8 @@ out:
ntfs_debug("Failed. Returning error code %i.", err);
return err;
conv_err_out:
- if (err != -ENOMEM && err != -EOPNOTSUPP) {
- make_bad_inode(vi);
- make_bad_inode(VFS_I(base_ni));
+ if (err != -ENOMEM && err != -EOPNOTSUPP)
NVolSetErrors(vol);
- }
if (err != -EOPNOTSUPP)
NInoSetTruncateFailed(ni);
else
@@ -3044,15 +3064,18 @@ int ntfs_write_inode(struct inode *vi, int sync)
* record will be cleaned and written out to disk below, i.e. before
* this function returns.
*/
- if (modified && !NInoTestSetDirty(ctx->ntfs_ino))
- mark_ntfs_record_dirty(ctx->ntfs_ino->page,
- ctx->ntfs_ino->page_ofs);
+ if (modified) {
+ flush_dcache_mft_record_page(ctx->ntfs_ino);
+ if (!NInoTestSetDirty(ctx->ntfs_ino))
+ mark_ntfs_record_dirty(ctx->ntfs_ino->page,
+ ctx->ntfs_ino->page_ofs);
+ }
ntfs_attr_put_search_ctx(ctx);
/* Now the access times are updated, write the base mft record. */
if (NInoDirty(ni))
err = write_mft_record(ni, m, sync);
/* Write all attached extent mft records. */
- down(&ni->extent_lock);
+ mutex_lock(&ni->extent_lock);
if (ni->nr_extents > 0) {
ntfs_inode **extent_nis = ni->ext.extent_ntfs_inos;
int i;
@@ -3079,7 +3102,7 @@ int ntfs_write_inode(struct inode *vi, int sync)
}
}
}
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
unmap_mft_record(ni);
if (unlikely(err))
goto err_out;
@@ -3094,9 +3117,7 @@ err_out:
"retries later.");
mark_inode_dirty(vi);
} else {
- ntfs_error(vi->i_sb, "Failed (error code %i): Marking inode "
- "as bad. You should run chkdsk.", -err);
- make_bad_inode(vi);
+ ntfs_error(vi->i_sb, "Failed (error %i): Run chkdsk.", -err);
NVolSetErrors(ni->vol);
}
return err;
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index 3de5c023196..f088291e017 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -24,12 +24,13 @@
#ifndef _LINUX_NTFS_INODE_H
#define _LINUX_NTFS_INODE_H
-#include <linux/mm.h>
+#include <asm/atomic.h>
+
#include <linux/fs.h>
-#include <linux/seq_file.h>
#include <linux/list.h>
-#include <asm/atomic.h>
-#include <asm/semaphore.h>
+#include <linux/mm.h>
+#include <linux/mutex.h>
+#include <linux/seq_file.h>
#include "layout.h"
#include "volume.h"
@@ -81,7 +82,7 @@ struct _ntfs_inode {
* The following fields are only valid for real inodes and extent
* inodes.
*/
- struct semaphore mrec_lock; /* Lock for serializing access to the
+ struct mutex mrec_lock; /* Lock for serializing access to the
mft record belonging to this inode. */
struct page *page; /* The page containing the mft record of the
inode. This should only be touched by the
@@ -119,7 +120,7 @@ struct _ntfs_inode {
u8 block_clusters; /* Number of clusters per cb. */
} compressed;
} itype;
- struct semaphore extent_lock; /* Lock for accessing/modifying the
+ struct mutex extent_lock; /* Lock for accessing/modifying the
below . */
s32 nr_extents; /* For a base mft record, the number of attached extent
inodes (0 if none), for extent records and for fake
diff --git a/fs/ntfs/layout.h b/fs/ntfs/layout.h
index bb408d4dcbb..d34b93cb8b4 100644
--- a/fs/ntfs/layout.h
+++ b/fs/ntfs/layout.h
@@ -769,7 +769,7 @@ typedef struct {
compressed. (This effectively limits the
compression unit size to be a power of two
clusters.) WinNT4 only uses a value of 4.
- Sparse files also have this set to 4. */
+ Sparse files have this set to 0 on XPSP2. */
/* 35*/ u8 reserved[5]; /* Align to 8-byte boundary. */
/* The sizes below are only used when lowest_vcn is zero, as otherwise it would
be difficult to keep them up-to-date.*/
@@ -801,13 +801,16 @@ typedef struct {
typedef ATTR_RECORD ATTR_REC;
/*
- * File attribute flags (32-bit).
+ * File attribute flags (32-bit) appearing in the file_attributes fields of the
+ * STANDARD_INFORMATION attribute of MFT_RECORDs and the FILENAME_ATTR
+ * attributes of MFT_RECORDs and directory index entries.
+ *
+ * All of the below flags appear in the directory index entries but only some
+ * appear in the STANDARD_INFORMATION attribute whilst only some others appear
+ * in the FILENAME_ATTR attribute of MFT_RECORDs. Unless otherwise stated the
+ * flags appear in all of the above.
*/
enum {
- /*
- * The following flags are only present in the STANDARD_INFORMATION
- * attribute (in the field file_attributes).
- */
FILE_ATTR_READONLY = const_cpu_to_le32(0x00000001),
FILE_ATTR_HIDDEN = const_cpu_to_le32(0x00000002),
FILE_ATTR_SYSTEM = const_cpu_to_le32(0x00000004),
@@ -839,18 +842,14 @@ enum {
F_A_COMPRESSED, and F_A_ENCRYPTED and preserves the rest. This mask
is used to to obtain all flags that are valid for setting. */
/*
- * The following flag is only present in the FILE_NAME attribute (in
- * the field file_attributes).
+ * The flag FILE_ATTR_DUP_FILENAME_INDEX_PRESENT is present in all
+ * FILENAME_ATTR attributes but not in the STANDARD_INFORMATION
+ * attribute of an mft record.
*/
FILE_ATTR_DUP_FILE_NAME_INDEX_PRESENT = const_cpu_to_le32(0x10000000),
/* Note, this is a copy of the corresponding bit from the mft record,
telling us whether this is a directory or not, i.e. whether it has
an index root attribute or not. */
- /*
- * The following flag is present both in the STANDARD_INFORMATION
- * attribute and in the FILE_NAME attribute (in the field
- * file_attributes).
- */
FILE_ATTR_DUP_VIEW_INDEX_PRESENT = const_cpu_to_le32(0x20000000),
/* Note, this is a copy of the corresponding bit from the mft record,
telling us whether this file has a view index present (eg. object id
@@ -891,7 +890,7 @@ typedef struct {
Windows this is only updated when
accessed if some time delta has
passed since the last update. Also,
- last access times updates can be
+ last access time updates can be
disabled altogether for speed. */
/* 32*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */
/* 36*/ union {
@@ -1076,16 +1075,21 @@ typedef struct {
/* 20*/ sle64 last_access_time; /* Time this mft record was last
accessed. */
/* 28*/ sle64 allocated_size; /* Byte size of on-disk allocated space
- for the data attribute. So for
- normal $DATA, this is the
+ for the unnamed data attribute. So
+ for normal $DATA, this is the
allocated_size from the unnamed
$DATA attribute and for compressed
and/or sparse $DATA, this is the
compressed_size from the unnamed
- $DATA attribute. NOTE: This is a
- multiple of the cluster size. */
-/* 30*/ sle64 data_size; /* Byte size of actual data in data
- attribute. */
+ $DATA attribute. For a directory or
+ other inode without an unnamed $DATA
+ attribute, this is always 0. NOTE:
+ This is a multiple of the cluster
+ size. */
+/* 30*/ sle64 data_size; /* Byte size of actual data in unnamed
+ data attribute. For a directory or
+ other inode without an unnamed $DATA
+ attribute, this is always 0. */
/* 38*/ FILE_ATTR_FLAGS file_attributes; /* Flags describing the file. */
/* 3c*/ union {
/* 3c*/ struct {
diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c
index 6499aafc225..4e72bc7afdf 100644
--- a/fs/ntfs/mft.c
+++ b/fs/ntfs/mft.c
@@ -93,6 +93,7 @@ static inline MFT_RECORD *map_mft_record_page(ntfs_inode *ni)
"Run chkdsk.", ni->mft_no);
ntfs_unmap_page(page);
page = ERR_PTR(-EIO);
+ NVolSetErrors(vol);
}
err_out:
ni->page = NULL;
@@ -104,8 +105,8 @@ err_out:
* map_mft_record - map, pin and lock an mft record
* @ni: ntfs inode whose MFT record to map
*
- * First, take the mrec_lock semaphore. We might now be sleeping, while waiting
- * for the semaphore if it was already locked by someone else.
+ * First, take the mrec_lock mutex. We might now be sleeping, while waiting
+ * for the mutex if it was already locked by someone else.
*
* The page of the record is mapped using map_mft_record_page() before being
* returned to the caller.
@@ -135,9 +136,9 @@ err_out:
* So that code will end up having to own the mrec_lock of all mft
* records/inodes present in the page before I/O can proceed. In that case we
* wouldn't need to bother with PG_locked and PG_uptodate as nobody will be
- * accessing anything without owning the mrec_lock semaphore. But we do need
- * to use them because of the read_cache_page() invocation and the code becomes
- * so much simpler this way that it is well worth it.
+ * accessing anything without owning the mrec_lock mutex. But we do need to
+ * use them because of the read_cache_page() invocation and the code becomes so
+ * much simpler this way that it is well worth it.
*
* The mft record is now ours and we return a pointer to it. You need to check
* the returned pointer with IS_ERR() and if that is true, PTR_ERR() will return
@@ -160,13 +161,13 @@ MFT_RECORD *map_mft_record(ntfs_inode *ni)
atomic_inc(&ni->count);
/* Serialize access to this mft record. */
- down(&ni->mrec_lock);
+ mutex_lock(&ni->mrec_lock);
m = map_mft_record_page(ni);
if (likely(!IS_ERR(m)))
return m;
- up(&ni->mrec_lock);
+ mutex_unlock(&ni->mrec_lock);
atomic_dec(&ni->count);
ntfs_error(ni->vol->sb, "Failed with error code %lu.", -PTR_ERR(m));
return m;
@@ -217,7 +218,7 @@ void unmap_mft_record(ntfs_inode *ni)
ntfs_debug("Entering for mft_no 0x%lx.", ni->mft_no);
unmap_mft_record_page(ni);
- up(&ni->mrec_lock);
+ mutex_unlock(&ni->mrec_lock);
atomic_dec(&ni->count);
/*
* If pure ntfs_inode, i.e. no vfs inode attached, we leave it to
@@ -261,7 +262,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
* in which case just return it. If not found, add it to the base
* inode before returning it.
*/
- down(&base_ni->extent_lock);
+ mutex_lock(&base_ni->extent_lock);
if (base_ni->nr_extents > 0) {
extent_nis = base_ni->ext.extent_ntfs_inos;
for (i = 0; i < base_ni->nr_extents; i++) {
@@ -274,7 +275,7 @@ MFT_RECORD *map_extent_mft_record(ntfs_inode *base_ni, MFT_REF mref,
}
}
if (likely(ni != NULL)) {
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
/* We found the record; just have to map and return it. */
m = map_mft_record(ni);
@@ -301,7 +302,7 @@ map_err_out:
/* Record wasn't there. Get a new ntfs inode and initialize it. */
ni = ntfs_new_extent_inode(base_ni->vol->sb, mft_no);
if (unlikely(!ni)) {
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
return ERR_PTR(-ENOMEM);
}
@@ -312,7 +313,7 @@ map_err_out:
/* Now map the record. */
m = map_mft_record(ni);
if (IS_ERR(m)) {
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
ntfs_clear_extent_inode(ni);
goto map_err_out;
@@ -347,14 +348,14 @@ map_err_out:
base_ni->ext.extent_ntfs_inos = tmp;
}
base_ni->ext.extent_ntfs_inos[base_ni->nr_extents++] = ni;
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
ntfs_debug("Done 2.");
*ntfs_ino = ni;
return m;
unm_err_out:
unmap_mft_record(ni);
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
/*
* If the extent inode was not attached to the base inode we need to
@@ -399,12 +400,12 @@ void __mark_mft_record_dirty(ntfs_inode *ni)
BUG_ON(NInoAttr(ni));
mark_ntfs_record_dirty(ni->page, ni->page_ofs);
/* Determine the base vfs inode and mark it dirty, too. */
- down(&ni->extent_lock);
+ mutex_lock(&ni->extent_lock);
if (likely(ni->nr_extents >= 0))
base_ni = ni;
else
base_ni = ni->ext.base_ntfs_ino;
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
__mark_inode_dirty(VFS_I(base_ni), I_DIRTY_SYNC | I_DIRTY_DATASYNC);
}
@@ -650,10 +651,7 @@ err_out:
* fs/ntfs/aops.c::mark_ntfs_record_dirty().
*
* On success, clean the mft record and return 0. On error, leave the mft
- * record dirty and return -errno. The caller should call make_bad_inode() on
- * the base inode to ensure no more access happens to this inode. We do not do
- * it here as the caller may want to finish writing other extent mft records
- * first to minimize on-disk metadata inconsistencies.
+ * record dirty and return -errno.
*
* NOTE: We always perform synchronous i/o and ignore the @sync parameter.
* However, if the mft record has a counterpart in the mft mirror and @sync is
@@ -983,7 +981,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
}
ntfs_debug("Inode 0x%lx is not dirty.", mft_no);
/* The inode is not dirty, try to take the mft record lock. */
- if (unlikely(down_trylock(&ni->mrec_lock))) {
+ if (unlikely(!mutex_trylock(&ni->mrec_lock))) {
ntfs_debug("Mft record 0x%lx is already locked, do "
"not write it.", mft_no);
atomic_dec(&ni->count);
@@ -1043,13 +1041,13 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
* corresponding to this extent mft record attached.
*/
ni = NTFS_I(vi);
- down(&ni->extent_lock);
+ mutex_lock(&ni->extent_lock);
if (ni->nr_extents <= 0) {
/*
* The base inode has no attached extent inodes, write this
* extent mft record.
*/
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
iput(vi);
ntfs_debug("Base inode 0x%lx has no attached extent inodes, "
"write the extent record.", na.mft_no);
@@ -1072,7 +1070,7 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
* extent mft record.
*/
if (!eni) {
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
iput(vi);
ntfs_debug("Extent inode 0x%lx is not attached to its base "
"inode 0x%lx, write the extent record.",
@@ -1083,12 +1081,12 @@ BOOL ntfs_may_write_mft_record(ntfs_volume *vol, const unsigned long mft_no,
mft_no, na.mft_no);
/* Take a reference to the extent ntfs inode. */
atomic_inc(&eni->count);
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
/*
* Found the extent inode coresponding to this extent mft record.
* Try to take the mft record lock.
*/
- if (unlikely(down_trylock(&eni->mrec_lock))) {
+ if (unlikely(!mutex_trylock(&eni->mrec_lock))) {
atomic_dec(&eni->count);
iput(vi);
ntfs_debug("Extent mft record 0x%lx is already locked, do "
@@ -2711,7 +2709,7 @@ mft_rec_already_initialized:
* have its page mapped and it is very easy to do.
*/
atomic_inc(&ni->count);
- down(&ni->mrec_lock);
+ mutex_lock(&ni->mrec_lock);
ni->page = page;
ni->page_ofs = ofs;
/*
@@ -2798,22 +2796,22 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
BUG_ON(NInoAttr(ni));
BUG_ON(ni->nr_extents != -1);
- down(&ni->extent_lock);
+ mutex_lock(&ni->extent_lock);
base_ni = ni->ext.base_ntfs_ino;
- up(&ni->extent_lock);
+ mutex_unlock(&ni->extent_lock);
BUG_ON(base_ni->nr_extents <= 0);
ntfs_debug("Entering for extent inode 0x%lx, base inode 0x%lx.\n",
mft_no, base_ni->mft_no);
- down(&base_ni->extent_lock);
+ mutex_lock(&base_ni->extent_lock);
/* Make sure we are holding the only reference to the extent inode. */
if (atomic_read(&ni->count) > 2) {
ntfs_error(vol->sb, "Tried to free busy extent inode 0x%lx, "
"not freeing.", base_ni->mft_no);
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
return -EBUSY;
}
@@ -2831,7 +2829,7 @@ int ntfs_extent_mft_record_free(ntfs_inode *ni, MFT_RECORD *m)
break;
}
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
if (unlikely(err)) {
ntfs_error(vol->sb, "Extent inode 0x%lx is not attached to "
@@ -2890,7 +2888,7 @@ rollback_error:
return 0;
rollback:
/* Rollback what we did... */
- down(&base_ni->extent_lock);
+ mutex_lock(&base_ni->extent_lock);
extent_nis = base_ni->ext.extent_ntfs_inos;
if (!(base_ni->nr_extents & 3)) {
int new_size = (base_ni->nr_extents + 4) * sizeof(ntfs_inode*);
@@ -2899,7 +2897,7 @@ rollback:
if (unlikely(!extent_nis)) {
ntfs_error(vol->sb, "Failed to allocate internal "
"buffer during rollback.%s", es);
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
NVolSetErrors(vol);
goto rollback_error;
}
@@ -2914,7 +2912,7 @@ rollback:
m->flags |= MFT_RECORD_IN_USE;
m->sequence_number = old_seq_no;
extent_nis[base_ni->nr_extents++] = ni;
- up(&base_ni->extent_lock);
+ mutex_unlock(&base_ni->extent_lock);
mark_mft_record_dirty(ni);
return err;
}
diff --git a/fs/ntfs/mft.h b/fs/ntfs/mft.h
index 407de2cef1d..639cd1bab08 100644
--- a/fs/ntfs/mft.h
+++ b/fs/ntfs/mft.h
@@ -97,10 +97,7 @@ extern int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync);
* uptodate.
*
* On success, clean the mft record and return 0. On error, leave the mft
- * record dirty and return -errno. The caller should call make_bad_inode() on
- * the base inode to ensure no more access happens to this inode. We do not do
- * it here as the caller may want to finish writing other extent mft records
- * first to minimize on-disk metadata inconsistencies.
+ * record dirty and return -errno.
*/
static inline int write_mft_record(ntfs_inode *ni, MFT_RECORD *m, int sync)
{
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 5ea9eb93af6..eddb2247cec 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -2,7 +2,7 @@
* namei.c - NTFS kernel directory inode operations. Part of the Linux-NTFS
* project.
*
- * Copyright (c) 2001-2004 Anton Altaparmakov
+ * Copyright (c) 2001-2006 Anton Altaparmakov
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -115,7 +115,9 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
uname_len = ntfs_nlstoucs(vol, dent->d_name.name, dent->d_name.len,
&uname);
if (uname_len < 0) {
- ntfs_error(vol->sb, "Failed to convert name to Unicode.");
+ if (uname_len != -ENAMETOOLONG)
+ ntfs_error(vol->sb, "Failed to convert name to "
+ "Unicode.");
return ERR_PTR(uname_len);
}
mref = ntfs_lookup_inode_by_name(NTFS_I(dir_ino), uname, uname_len,
@@ -157,7 +159,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
/* Return the error code. */
return (struct dentry *)dent_inode;
}
- /* It is guaranteed that name is no longer allocated at this point. */
+ /* It is guaranteed that @name is no longer allocated at this point. */
if (MREF_ERR(mref) == -ENOENT) {
ntfs_debug("Entry was not found, adding negative dentry.");
/* The dcache will handle negative entries. */
@@ -168,7 +170,6 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error "
"code %i.", -MREF_ERR(mref));
return ERR_PTR(MREF_ERR(mref));
-
// TODO: Consider moving this lot to a separate function! (AIA)
handle_name:
{
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
index 653d2a5c489..0624c8ef4d9 100644
--- a/fs/ntfs/ntfs.h
+++ b/fs/ntfs/ntfs.h
@@ -91,7 +91,7 @@ extern void free_compression_buffers(void);
/* From fs/ntfs/super.c */
#define default_upcase_len 0x10000
-extern struct semaphore ntfs_lock;
+extern struct mutex ntfs_lock;
typedef struct {
int val;
diff --git a/fs/ntfs/runlist.c b/fs/ntfs/runlist.c
index 061b5ff6b73..eb52b801512 100644
--- a/fs/ntfs/runlist.c
+++ b/fs/ntfs/runlist.c
@@ -381,6 +381,7 @@ static inline runlist_element *ntfs_rl_insert(runlist_element *dst,
static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
int dsize, runlist_element *src, int ssize, int loc)
{
+ signed delta;
BOOL left = FALSE; /* Left end of @src needs merging. */
BOOL right = FALSE; /* Right end of @src needs merging. */
int tail; /* Start of tail of @dst. */
@@ -396,11 +397,14 @@ static inline runlist_element *ntfs_rl_replace(runlist_element *dst,
left = ntfs_are_rl_mergeable(dst + loc - 1, src);
/*
* Allocate some space. We will need less if the left, right, or both
- * ends get merged.
+ * ends get merged. The -1 accounts for the run being replaced.
*/
- dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left - right);
- if (IS_ERR(dst))
- return dst;
+ delta = ssize - 1 - left - right;
+ if (delta > 0) {
+ dst = ntfs_rl_realloc(dst, dsize, dsize + delta);
+ if (IS_ERR(dst))
+ return dst;
+ }
/*
* We are guaranteed to succeed from here so can start modifying the
* original runlists.
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 368a8ec1066..27833f6df49 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1099,26 +1099,38 @@ static BOOL check_mft_mirror(ntfs_volume *vol)
kmirr = page_address(mirr_page);
++index;
}
- /* Make sure the record is ok. */
- if (ntfs_is_baad_recordp((le32*)kmft)) {
- ntfs_error(sb, "Incomplete multi sector transfer "
- "detected in mft record %i.", i);
+ /* Do not check the record if it is not in use. */
+ if (((MFT_RECORD*)kmft)->flags & MFT_RECORD_IN_USE) {
+ /* Make sure the record is ok. */
+ if (ntfs_is_baad_recordp((le32*)kmft)) {
+ ntfs_error(sb, "Incomplete multi sector "
+ "transfer detected in mft "
+ "record %i.", i);
mm_unmap_out:
- ntfs_unmap_page(mirr_page);
+ ntfs_unmap_page(mirr_page);
mft_unmap_out:
- ntfs_unmap_page(mft_page);
- return FALSE;
+ ntfs_unmap_page(mft_page);
+ return FALSE;
+ }
}
- if (ntfs_is_baad_recordp((le32*)kmirr)) {
- ntfs_error(sb, "Incomplete multi sector transfer "
- "detected in mft mirror record %i.", i);
- goto mm_unmap_out;
+ /* Do not check the mirror record if it is not in use. */
+ if (((MFT_RECORD*)kmirr)->flags & MFT_RECORD_IN_USE) {
+ if (ntfs_is_baad_recordp((le32*)kmirr)) {
+ ntfs_error(sb, "Incomplete multi sector "
+ "transfer detected in mft "
+ "mirror record %i.", i);
+ goto mm_unmap_out;
+ }
}
/* Get the amount of data in the current record. */
bytes = le32_to_cpu(((MFT_RECORD*)kmft)->bytes_in_use);
- if (!bytes || bytes > vol->mft_record_size) {
+ if (bytes < sizeof(MFT_RECORD_OLD) ||
+ bytes > vol->mft_record_size ||
+ ntfs_is_baad_recordp((le32*)kmft)) {
bytes = le32_to_cpu(((MFT_RECORD*)kmirr)->bytes_in_use);
- if (!bytes || bytes > vol->mft_record_size)
+ if (bytes < sizeof(MFT_RECORD_OLD) ||
+ bytes > vol->mft_record_size ||
+ ntfs_is_baad_recordp((le32*)kmirr))
bytes = vol->mft_record_size;
}
/* Compare the two records. */
@@ -1665,11 +1677,11 @@ read_partial_upcase_page:
ntfs_debug("Read %llu bytes from $UpCase (expected %zu bytes).",
i_size, 64 * 1024 * sizeof(ntfschar));
iput(ino);
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (!default_upcase) {
ntfs_debug("Using volume specified $UpCase since default is "
"not present.");
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
return TRUE;
}
max = default_upcase_len;
@@ -1683,12 +1695,12 @@ read_partial_upcase_page:
vol->upcase = default_upcase;
vol->upcase_len = max;
ntfs_nr_upcase_users++;
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
ntfs_debug("Volume specified $UpCase matches default. Using "
"default.");
return TRUE;
}
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
ntfs_debug("Using volume specified $UpCase since it does not match "
"the default.");
return TRUE;
@@ -1697,17 +1709,17 @@ iput_upcase_failed:
ntfs_free(vol->upcase);
vol->upcase = NULL;
upcase_failed:
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (default_upcase) {
vol->upcase = default_upcase;
vol->upcase_len = default_upcase_len;
ntfs_nr_upcase_users++;
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
ntfs_error(sb, "Failed to load $UpCase from the volume. Using "
"default.");
return TRUE;
}
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
ntfs_error(sb, "Failed to initialize upcase table.");
return FALSE;
}
@@ -2183,12 +2195,12 @@ iput_attrdef_err_out:
iput_upcase_err_out:
#endif /* NTFS_RW */
vol->upcase_len = 0;
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (vol->upcase == default_upcase) {
ntfs_nr_upcase_users--;
vol->upcase = NULL;
}
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
if (vol->upcase) {
ntfs_free(vol->upcase);
vol->upcase = NULL;
@@ -2393,7 +2405,7 @@ static void ntfs_put_super(struct super_block *sb)
* Destroy the global default upcase table if necessary. Also decrease
* the number of upcase users if we are a user.
*/
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (vol->upcase == default_upcase) {
ntfs_nr_upcase_users--;
vol->upcase = NULL;
@@ -2404,7 +2416,7 @@ static void ntfs_put_super(struct super_block *sb)
}
if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users)
free_compression_buffers();
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
if (vol->upcase) {
ntfs_free(vol->upcase);
vol->upcase = NULL;
@@ -2878,7 +2890,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
ntfs_error(sb, "Failed to load essential metadata.");
goto iput_tmp_ino_err_out_now;
}
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
/*
* The current mount is a compression user if the cluster size is
* less than or equal 4kiB.
@@ -2889,7 +2901,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
ntfs_error(NULL, "Failed to allocate buffers "
"for compression engine.");
ntfs_nr_compression_users--;
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
goto iput_tmp_ino_err_out_now;
}
}
@@ -2901,7 +2913,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
if (!default_upcase)
default_upcase = generate_default_upcase();
ntfs_nr_upcase_users++;
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
/*
* From now on, ignore @silent parameter. If we fail below this line,
* it will be due to a corrupt fs or a system error, so we report it.
@@ -2919,12 +2931,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
atomic_inc(&vol->root_ino->i_count);
ntfs_debug("Exiting, status successful.");
/* Release the default upcase if it has no users. */
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (!--ntfs_nr_upcase_users && default_upcase) {
ntfs_free(default_upcase);
default_upcase = NULL;
}
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
sb->s_export_op = &ntfs_export_ops;
lock_kernel();
return 0;
@@ -2992,12 +3004,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
vol->attrdef = NULL;
}
vol->upcase_len = 0;
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (vol->upcase == default_upcase) {
ntfs_nr_upcase_users--;
vol->upcase = NULL;
}
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
if (vol->upcase) {
ntfs_free(vol->upcase);
vol->upcase = NULL;
@@ -3012,14 +3024,14 @@ unl_upcase_iput_tmp_ino_err_out_now:
* Decrease the number of upcase users and destroy the global default
* upcase table if necessary.
*/
- down(&ntfs_lock);
+ mutex_lock(&ntfs_lock);
if (!--ntfs_nr_upcase_users && default_upcase) {
ntfs_free(default_upcase);
default_upcase = NULL;
}
if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users)
free_compression_buffers();
- up(&ntfs_lock);
+ mutex_unlock(&ntfs_lock);
iput_tmp_ino_err_out_now:
iput(tmp_ino);
if (vol->mft_ino && vol->mft_ino != tmp_ino)
@@ -3078,8 +3090,8 @@ static void ntfs_big_inode_init_once(void *foo, struct kmem_cache *cachep,
struct kmem_cache *ntfs_attr_ctx_cache;
struct kmem_cache *ntfs_index_ctx_cache;
-/* Driver wide semaphore. */
-DECLARE_MUTEX(ntfs_lock);
+/* Driver wide mutex. */
+DEFINE_MUTEX(ntfs_lock);
static struct super_block *ntfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data)
@@ -3151,7 +3163,7 @@ static int __init init_ntfs_fs(void)
ntfs_inode_cache = kmem_cache_create(ntfs_inode_cache_name,
sizeof(ntfs_inode), 0,
- SLAB_RECLAIM_ACCOUNT, NULL, NULL);
+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
if (!ntfs_inode_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n",
ntfs_inode_cache_name);
@@ -3160,7 +3172,7 @@ static int __init init_ntfs_fs(void)
ntfs_big_inode_cache = kmem_cache_create(ntfs_big_inode_cache_name,
sizeof(big_ntfs_inode), 0,
- SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+ SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
ntfs_big_inode_init_once, NULL);
if (!ntfs_big_inode_cache) {
printk(KERN_CRIT "NTFS: Failed to create %s!\n",
@@ -3234,7 +3246,7 @@ static void __exit exit_ntfs_fs(void)
}
MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
-MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2005 Anton Altaparmakov");
+MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2006 Anton Altaparmakov");
MODULE_VERSION(NTFS_VERSION);
MODULE_LICENSE("GPL");
#ifdef DEBUG
diff --git a/fs/ntfs/unistr.c b/fs/ntfs/unistr.c
index 0ea887fc859..b123c0fa6bf 100644
--- a/fs/ntfs/unistr.c
+++ b/fs/ntfs/unistr.c
@@ -1,7 +1,7 @@
/*
* unistr.c - NTFS Unicode string handling. Part of the Linux-NTFS project.
*
- * Copyright (c) 2001-2005 Anton Altaparmakov
+ * Copyright (c) 2001-2006 Anton Altaparmakov
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@@ -19,6 +19,8 @@
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <linux/slab.h>
+
#include "types.h"
#include "debug.h"
#include "ntfs.h"
@@ -242,7 +244,7 @@ int ntfs_file_compare_values(FILE_NAME_ATTR *file_name_attr1,
* map dictates, into a little endian, 2-byte Unicode string.
*
* This function allocates the string and the caller is responsible for
- * calling kmem_cache_free(ntfs_name_cache, @outs); when finished with it.
+ * calling kmem_cache_free(ntfs_name_cache, *@outs); when finished with it.
*
* On success the function returns the number of Unicode characters written to
* the output string *@outs (>= 0), not counting the terminating Unicode NULL
@@ -262,37 +264,48 @@ int ntfs_nlstoucs(const ntfs_volume *vol, const char *ins,
wchar_t wc;
int i, o, wc_len;
- /* We don't trust outside sources. */
- if (ins) {
+ /* We do not trust outside sources. */
+ if (likely(ins)) {
ucs = kmem_cache_alloc(ntfs_name_cache, SLAB_NOFS);
- if (ucs) {
+ if (likely(ucs)) {
for (i = o = 0; i < ins_len; i += wc_len) {
wc_len = nls->char2uni(ins + i, ins_len - i,
&wc);
- if (wc_len >= 0) {
- if (wc) {
+ if (likely(wc_len >= 0 &&
+ o < NTFS_MAX_NAME_LEN)) {
+ if (likely(wc)) {
ucs[o++] = cpu_to_le16(wc);
continue;
- } /* else (!wc) */
+ } /* else if (!wc) */
break;
- } /* else (wc_len < 0) */
- goto conversion_err;
+ } /* else if (wc_len < 0 ||
+ o >= NTFS_MAX_NAME_LEN) */
+ goto name_err;
}
ucs[o] = 0;
*outs = ucs;
return o;
- } /* else (!ucs) */
- ntfs_error(vol->sb, "Failed to allocate name from "
- "ntfs_name_cache!");
+ } /* else if (!ucs) */
+ ntfs_error(vol->sb, "Failed to allocate buffer for converted "
+ "name from ntfs_name_cache.");
return -ENOMEM;
- } /* else (!ins) */
- ntfs_error(NULL, "Received NULL pointer.");
+ } /* else if (!ins) */
+ ntfs_error(vol->sb, "Received NULL pointer.");
return -EINVAL;
-conversion_err:
- ntfs_error(vol->sb, "Name using character set %s contains characters "
- "that cannot be converted to Unicode.", nls->charset);
+name_err:
kmem_cache_free(ntfs_name_cache, ucs);
- return -EILSEQ;
+ if (wc_len < 0) {
+ ntfs_error(vol->sb, "Name using character set %s contains "
+ "characters that cannot be converted to "
+ "Unicode.", nls->charset);
+ i = -EILSEQ;
+ } else /* if (o >= NTFS_MAX_NAME_LEN) */ {
+ ntfs_error(vol->sb, "Name is too long (maximum length for a "
+ "name on NTFS is %d Unicode characters.",
+ NTFS_MAX_NAME_LEN);
+ i = -ENAMETOOLONG;
+ }
+ return i;
}
/**
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c
index dd2d24dc25e..7e88e24b347 100644
--- a/fs/ocfs2/dlm/dlmfs.c
+++ b/fs/ocfs2/dlm/dlmfs.c
@@ -596,7 +596,8 @@ static int __init init_dlmfs_fs(void)
dlmfs_inode_cache = kmem_cache_create("dlmfs_inode_cache",
sizeof(struct dlmfs_inode_private),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
dlmfs_init_once, NULL);
if (!dlmfs_inode_cache)
return -ENOMEM;
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 09e1c57a86a..44d8b524823 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -950,9 +950,11 @@ static void ocfs2_inode_init_once(void *data,
static int ocfs2_initialize_mem_caches(void)
{
ocfs2_inode_cachep = kmem_cache_create("ocfs2_inode_cache",
- sizeof(struct ocfs2_inode_info),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- ocfs2_inode_init_once, NULL);
+ sizeof(struct ocfs2_inode_info),
+ 0,
+ (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
+ ocfs2_inode_init_once, NULL);
if (!ocfs2_inode_cachep)
return -ENOMEM;
diff --git a/fs/open.c b/fs/open.c
index 70e0230d8e7..7d02d19bd0a 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -890,6 +890,10 @@ EXPORT_SYMBOL(filp_open);
* a fully instantiated struct file to the caller.
* This function is meant to be called from within a filesystem's
* lookup method.
+ * Beware of calling it for non-regular files! Those ->open methods might block
+ * (e.g. in fifo_open), leaving you with parent locked (and in case of fifo,
+ * leading to a deadlock, as nobody can open that fifo anymore, because
+ * another process to open fifo will block on locked parent when doing lookup).
* Note that in case of error, nd->intent.open.file is destroyed, but the
* path information remains valid.
* If the open callback is set to NULL, then the standard f_op->open()
@@ -973,7 +977,7 @@ repeat:
fdt = files_fdtable(files);
fd = find_next_zero_bit(fdt->open_fds->fds_bits,
fdt->max_fdset,
- fdt->next_fd);
+ files->next_fd);
/*
* N.B. For clone tasks sharing a files structure, this test
@@ -998,7 +1002,7 @@ repeat:
FD_SET(fd, fdt->open_fds);
FD_CLR(fd, fdt->close_on_exec);
- fdt->next_fd = fd + 1;
+ files->next_fd = fd + 1;
#if 1
/* Sanity check */
if (fdt->fd[fd] != NULL) {
@@ -1019,8 +1023,8 @@ static void __put_unused_fd(struct files_struct *files, unsigned int fd)
{
struct fdtable *fdt = files_fdtable(files);
__FD_CLR(fd, fdt->open_fds);
- if (fd < fdt->next_fd)
- fdt->next_fd = fd;
+ if (fd < files->next_fd)
+ files->next_fd = fd;
}
void fastcall put_unused_fd(unsigned int fd)
diff --git a/fs/partitions/ibm.c b/fs/partitions/ibm.c
index 1e4a93835fe..830c55d86ab 100644
--- a/fs/partitions/ibm.c
+++ b/fs/partitions/ibm.c
@@ -1,15 +1,9 @@
/*
- * File...........: linux/fs/partitions/ibm.c
+ * File...........: linux/fs/partitions/ibm.c
* Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
* Volker Sameske <sameske@de.ibm.com>
* Bugreports.to..: <Linux390@de.ibm.com>
* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
-
- * History of changes (starts July 2000)
- * 07/10/00 Fixed detection of CMS formatted disks
- * 02/13/00 VTOC partition support added
- * 12/27/01 fixed PL030593 (CMS reserved minidisk not detected on 64 bit)
- * 07/24/03 no longer using contents of freed page for CMS label recognition (BZ3611)
*/
#include <linux/config.h>
@@ -25,7 +19,7 @@
#include "ibm.h"
/*
- * compute the block number from a
+ * compute the block number from a
* cyl-cyl-head-head structure
*/
static inline int
@@ -34,9 +28,8 @@ cchh2blk (struct vtoc_cchh *ptr, struct hd_geometry *geo) {
ptr->hh * geo->sectors;
}
-
/*
- * compute the block number from a
+ * compute the block number from a
* cyl-cyl-head-head-block structure
*/
static inline int
@@ -48,7 +41,7 @@ cchhb2blk (struct vtoc_cchhb *ptr, struct hd_geometry *geo) {
/*
*/
-int
+int
ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
{
int blocksize, offset, size;
@@ -77,7 +70,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
goto out_nogeo;
if ((label = kmalloc(sizeof(union label_t), GFP_KERNEL)) == NULL)
goto out_nolab;
-
+
if (ioctl_by_bdev(bdev, BIODASDINFO, (unsigned long)info) != 0 ||
ioctl_by_bdev(bdev, HDIO_GETGEO, (unsigned long)geo) != 0)
goto out_noioctl;
@@ -154,13 +147,13 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
/* OK, we got valid partition data */
offset = cchh2blk(&f1.DS1EXT1.llimit, geo);
- size = cchh2blk(&f1.DS1EXT1.ulimit, geo) -
+ size = cchh2blk(&f1.DS1EXT1.ulimit, geo) -
offset + geo->sectors;
if (counter >= state->limit)
break;
- put_partition(state, counter + 1,
- offset * (blocksize >> 9),
- size * (blocksize >> 9));
+ put_partition(state, counter + 1,
+ offset * (blocksize >> 9),
+ size * (blocksize >> 9));
counter++;
blk++;
}
@@ -175,7 +168,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
offset = (info->label_block + 1);
size = i_size >> 9;
put_partition(state, 1, offset*(blocksize >> 9),
- size-offset*(blocksize >> 9));
+ size-offset*(blocksize >> 9));
}
printk("\n");
@@ -183,7 +176,7 @@ ibm_partition(struct parsed_partitions *state, struct block_device *bdev)
kfree(geo);
kfree(info);
return 1;
-
+
out_readerr:
out_noioctl:
kfree(label);
diff --git a/fs/pipe.c b/fs/pipe.c
index 8aada8e426f..d976866a115 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -662,10 +662,9 @@ struct inode* pipe_new(struct inode* inode)
{
struct pipe_inode_info *info;
- info = kmalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
+ info = kzalloc(sizeof(struct pipe_inode_info), GFP_KERNEL);
if (!info)
goto fail_page;
- memset(info, 0, sizeof(*info));
inode->i_pipe = info;
init_waitqueue_head(PIPE_WAIT(*inode));
diff --git a/fs/pnode.c b/fs/pnode.c
index f1871f773f6..37b568ed0e0 100644
--- a/fs/pnode.c
+++ b/fs/pnode.c
@@ -130,7 +130,7 @@ static struct vfsmount *get_source(struct vfsmount *dest,
{
struct vfsmount *p_last_src = NULL;
struct vfsmount *p_last_dest = NULL;
- *type = CL_PROPAGATION;;
+ *type = CL_PROPAGATION;
if (IS_MNT_SHARED(dest))
*type |= CL_MAKE_SHARED;
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 075d3e94560..722b9c46311 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -121,7 +121,8 @@ int __init proc_init_inodecache(void)
{
proc_inode_cachep = kmem_cache_create("proc_inode_cache",
sizeof(struct proc_inode),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (proc_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index 1d24fead51a..1e9ea37d457 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -312,7 +312,7 @@ static void *devinfo_next(struct seq_file *f, void *v, loff_t *pos)
case BLK_HDR:
info->state = BLK_LIST;
(*pos)++;
- break;
+ /*fallthrough*/
case BLK_LIST:
if (get_blkdev_info(info->blkdev,&idummy,&ndummy)) {
/*
@@ -485,6 +485,40 @@ static struct file_operations proc_slabinfo_operations = {
.llseek = seq_lseek,
.release = seq_release,
};
+
+#ifdef CONFIG_DEBUG_SLAB_LEAK
+extern struct seq_operations slabstats_op;
+static int slabstats_open(struct inode *inode, struct file *file)
+{
+ unsigned long *n = kzalloc(PAGE_SIZE, GFP_KERNEL);
+ int ret = -ENOMEM;
+ if (n) {
+ ret = seq_open(file, &slabstats_op);
+ if (!ret) {
+ struct seq_file *m = file->private_data;
+ *n = PAGE_SIZE / (2 * sizeof(unsigned long));
+ m->private = n;
+ n = NULL;
+ }
+ kfree(n);
+ }
+ return ret;
+}
+
+static int slabstats_release(struct inode *inode, struct file *file)
+{
+ struct seq_file *m = file->private_data;
+ kfree(m->private);
+ return seq_release(inode, file);
+}
+
+static struct file_operations proc_slabstats_operations = {
+ .open = slabstats_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = slabstats_release,
+};
+#endif
#endif
static int show_stat(struct seq_file *p, void *v)
@@ -744,6 +778,9 @@ void __init proc_misc_init(void)
create_seq_entry("interrupts", 0, &proc_interrupts_operations);
#ifdef CONFIG_SLAB
create_seq_entry("slabinfo",S_IWUSR|S_IRUGO,&proc_slabinfo_operations);
+#ifdef CONFIG_DEBUG_SLAB_LEAK
+ create_seq_entry("slab_allocators", 0 ,&proc_slabstats_operations);
+#endif
#endif
create_seq_entry("buddyinfo",S_IRUGO, &fragmentation_file_operations);
create_seq_entry("vmstat",S_IRUGO, &proc_vmstat_file_operations);
diff --git a/fs/qnx4/file.c b/fs/qnx4/file.c
index b471315e24e..c33963fded9 100644
--- a/fs/qnx4/file.c
+++ b/fs/qnx4/file.c
@@ -12,10 +12,7 @@
* 27-06-1998 by Frank Denis : file overwriting.
*/
-#include <linux/config.h>
-#include <linux/types.h>
#include <linux/fs.h>
-#include <linux/time.h>
#include <linux/qnx4_fs.h>
/*
diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c
index 80f32911c0c..2ecd46f85e9 100644
--- a/fs/qnx4/inode.c
+++ b/fs/qnx4/inode.c
@@ -546,7 +546,8 @@ static int init_inodecache(void)
{
qnx4_inode_cachep = kmem_cache_create("qnx4_inode_cache",
sizeof(struct qnx4_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (qnx4_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/quota.c b/fs/quota.c
index ba9e0bf32f6..d6a2be826e2 100644
--- a/fs/quota.c
+++ b/fs/quota.c
@@ -170,10 +170,10 @@ static void quota_sync_sb(struct super_block *sb, int type)
/* Now when everything is written we can discard the pagecache so
* that userspace sees the changes. We need i_mutex and so we could
- * not do it inside dqonoff_sem. Moreover we need to be carefull
+ * not do it inside dqonoff_mutex. Moreover we need to be carefull
* about races with quotaoff() (that is the reason why we have own
* reference to inode). */
- down(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
discard[cnt] = NULL;
if (type != -1 && cnt != type)
@@ -182,7 +182,7 @@ static void quota_sync_sb(struct super_block *sb, int type)
continue;
discard[cnt] = igrab(sb_dqopt(sb)->files[cnt]);
}
- up(&sb_dqopt(sb)->dqonoff_sem);
+ mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
if (discard[cnt]) {
mutex_lock(&discard[cnt]->i_mutex);
diff --git a/fs/quota_v2.c b/fs/quota_v2.c
index b4199ec3ece..c519a583e68 100644
--- a/fs/quota_v2.c
+++ b/fs/quota_v2.c
@@ -394,7 +394,7 @@ static int v2_write_dquot(struct dquot *dquot)
ssize_t ret;
struct v2_disk_dqblk ddquot, empty;
- /* dq_off is guarded by dqio_sem */
+ /* dq_off is guarded by dqio_mutex */
if (!dquot->dq_off)
if ((ret = dq_insert_tree(dquot)) < 0) {
printk(KERN_ERR "VFS: Error %zd occurred while creating quota.\n", ret);
diff --git a/fs/ramfs/file-mmu.c b/fs/ramfs/file-mmu.c
index 2115383dcc8..6ada2095b9a 100644
--- a/fs/ramfs/file-mmu.c
+++ b/fs/ramfs/file-mmu.c
@@ -24,18 +24,7 @@
* caches is sufficient.
*/
-#include <linux/module.h>
#include <linux/fs.h>
-#include <linux/pagemap.h>
-#include <linux/highmem.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/smp_lock.h>
-#include <linux/backing-dev.h>
-#include <linux/ramfs.h>
-
-#include <asm/uaccess.h>
-#include "internal.h"
struct address_space_operations ramfs_aops = {
.readpage = simple_readpage,
diff --git a/fs/read_write.c b/fs/read_write.c
index 3f7a1a62165..34b1bf259ef 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -470,7 +470,7 @@ static ssize_t do_readv_writev(int type, struct file *file,
* verify all the pointers
*/
ret = -EINVAL;
- if ((nr_segs > UIO_MAXIOV) || (nr_segs <= 0))
+ if (nr_segs > UIO_MAXIOV)
goto out;
if (!file->f_op)
goto out;
diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index be12879bb17..d0c1e865963 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -1532,7 +1532,7 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
buf += write_bytes;
*ppos = pos += write_bytes;
count -= write_bytes;
- balance_dirty_pages_ratelimited(inode->i_mapping);
+ balance_dirty_pages_ratelimited_nr(inode->i_mapping, num_pages);
}
/* this is only true on error */
@@ -1546,10 +1546,10 @@ static ssize_t reiserfs_file_write(struct file *file, /* the file we are going t
}
}
- if ((file->f_flags & O_SYNC) || IS_SYNC(inode))
- res =
- generic_osync_inode(inode, file->f_mapping,
- OSYNC_METADATA | OSYNC_DATA);
+ if (likely(res >= 0) &&
+ (unlikely((file->f_flags & O_SYNC) || IS_SYNC(inode))))
+ res = generic_osync_inode(inode, file->f_mapping,
+ OSYNC_METADATA | OSYNC_DATA);
mutex_unlock(&inode->i_mutex);
reiserfs_async_progress_wait(inode->i_sb);
diff --git a/fs/reiserfs/fix_node.c b/fs/reiserfs/fix_node.c
index aa22588019e..5600d3d60cf 100644
--- a/fs/reiserfs/fix_node.c
+++ b/fs/reiserfs/fix_node.c
@@ -191,9 +191,7 @@ static void create_virtual_node(struct tree_balance *tb, int h)
"vs-8045: create_virtual_node: rdkey %k, affected item==%d (mode==%c) Must be %c",
key, vn->vn_affected_item_num,
vn->vn_mode, M_DELETE);
- } else
- /* we can delete directory item, that has only one directory entry in it */
- ;
+ }
}
#endif
diff --git a/fs/reiserfs/item_ops.c b/fs/reiserfs/item_ops.c
index e237cd668e5..7a88adbceef 100644
--- a/fs/reiserfs/item_ops.c
+++ b/fs/reiserfs/item_ops.c
@@ -275,7 +275,7 @@ static void indirect_print_item(struct item_head *ih, char *item)
int j;
__le32 *unp;
__u32 prev = INT_MAX;
- int num;
+ int num = 0;
unp = (__le32 *) item;
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c
index 5a9d2722fa0..1b73529b809 100644
--- a/fs/reiserfs/journal.c
+++ b/fs/reiserfs/journal.c
@@ -2227,6 +2227,9 @@ static int journal_read_transaction(struct super_block *p_s_sb,
journal->j_start = cur_dblock - SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb);
journal->j_last_flush_trans_id = trans_id;
journal->j_trans_id = trans_id + 1;
+ /* check for trans_id overflow */
+ if (journal->j_trans_id == 0)
+ journal->j_trans_id = 10;
brelse(c_bh);
brelse(d_bh);
kfree(log_blocks);
@@ -2450,6 +2453,9 @@ static int journal_read(struct super_block *p_s_sb)
journal->j_start = le32_to_cpu(jh->j_first_unflushed_offset);
journal->j_trans_id =
le32_to_cpu(jh->j_last_flush_trans_id) + 1;
+ /* check for trans_id overflow */
+ if (journal->j_trans_id == 0)
+ journal->j_trans_id = 10;
journal->j_last_flush_trans_id =
le32_to_cpu(jh->j_last_flush_trans_id);
journal->j_mount_id = le32_to_cpu(jh->j_mount_id) + 1;
@@ -3873,8 +3879,8 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
int cur_write_start = 0; /* start index of current log write */
int old_start;
int i;
- int flush = flags & FLUSH_ALL;
- int wait_on_commit = flags & WAIT;
+ int flush;
+ int wait_on_commit;
struct reiserfs_journal_list *jl, *temp_jl;
struct list_head *entry, *safe;
unsigned long jindex;
@@ -3884,6 +3890,13 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
BUG_ON(th->t_refcount > 1);
BUG_ON(!th->t_trans_id);
+ /* protect flush_older_commits from doing mistakes if the
+ transaction ID counter gets overflowed. */
+ if (th->t_trans_id == ~0UL)
+ flags |= FLUSH_ALL | COMMIT_NOW | WAIT;
+ flush = flags & FLUSH_ALL;
+ wait_on_commit = flags & WAIT;
+
put_fs_excl();
current->journal_info = th->t_handle_save;
reiserfs_check_lock_depth(p_s_sb, "journal end");
@@ -4105,7 +4118,9 @@ static int do_journal_end(struct reiserfs_transaction_handle *th,
journal->j_first = NULL;
journal->j_len = 0;
journal->j_trans_start_time = 0;
- journal->j_trans_id++;
+ /* check for trans_id overflow */
+ if (++journal->j_trans_id == 0)
+ journal->j_trans_id = 10;
journal->j_current_jl->j_trans_id = journal->j_trans_id;
journal->j_must_wait = 0;
journal->j_len_alloc = 0;
diff --git a/fs/reiserfs/prints.c b/fs/reiserfs/prints.c
index d55e164bd5c..78b40621b88 100644
--- a/fs/reiserfs/prints.c
+++ b/fs/reiserfs/prints.c
@@ -601,8 +601,7 @@ void store_print_tb(struct tree_balance *tb)
tb->tb_mode, PATH_LAST_POSITION(tb->tb_path),
tb->tb_path->pos_in_item);
- for (h = 0; h < sizeof(tb->insert_size) / sizeof(tb->insert_size[0]);
- h++) {
+ for (h = 0; h < ARRAY_SIZE(tb->insert_size); h++) {
if (PATH_H_PATH_OFFSET(tb->tb_path, h) <=
tb->tb_path->path_length
&& PATH_H_PATH_OFFSET(tb->tb_path,
@@ -658,15 +657,13 @@ void store_print_tb(struct tree_balance *tb)
/* print FEB list (list of buffers in form (bh (b_blocknr, b_count), that will be used for new nodes) */
h = 0;
- for (i = 0; i < sizeof(tb->FEB) / sizeof(tb->FEB[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(tb->FEB); i++)
sprintf(print_tb_buf + strlen(print_tb_buf),
"%p (%llu %d)%s", tb->FEB[i],
tb->FEB[i] ? (unsigned long long)tb->FEB[i]->
b_blocknr : 0ULL,
tb->FEB[i] ? atomic_read(&(tb->FEB[i]->b_count)) : 0,
- (i ==
- sizeof(tb->FEB) / sizeof(tb->FEB[0]) -
- 1) ? "\n" : ", ");
+ (i == ARRAY_SIZE(tb->FEB) - 1) ? "\n" : ", ");
sprintf(print_tb_buf + strlen(print_tb_buf),
"======================== the end ====================================\n");
diff --git a/fs/reiserfs/stree.c b/fs/reiserfs/stree.c
index e2d08d7bcff..d2b25e1ba6e 100644
--- a/fs/reiserfs/stree.c
+++ b/fs/reiserfs/stree.c
@@ -981,6 +981,8 @@ static inline int prepare_for_direntry_item(struct path *path,
return M_CUT;
}
+#define JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD (2 * JOURNAL_PER_BALANCE_CNT + 1)
+
/* If the path points to a directory or direct item, calculate mode and the size cut, for balance.
If the path points to an indirect item, remove some number of its unformatted nodes.
In case of file truncate calculate whether this item must be deleted/truncated or last
@@ -1020,148 +1022,79 @@ static char prepare_for_delete_or_cut(struct reiserfs_transaction_handle *th, st
/* Case of an indirect item. */
{
- int n_unfm_number, /* Number of the item unformatted nodes. */
- n_counter, n_blk_size;
- __le32 *p_n_unfm_pointer; /* Pointer to the unformatted node number. */
- __u32 tmp;
- struct item_head s_ih; /* Item header. */
- char c_mode; /* Returned mode of the balance. */
- int need_research;
-
- n_blk_size = p_s_sb->s_blocksize;
-
- /* Search for the needed object indirect item until there are no unformatted nodes to be removed. */
- do {
- need_research = 0;
- p_s_bh = PATH_PLAST_BUFFER(p_s_path);
- /* Copy indirect item header to a temp variable. */
- copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
- /* Calculate number of unformatted nodes in this item. */
- n_unfm_number = I_UNFM_NUM(&s_ih);
-
- RFALSE(!is_indirect_le_ih(&s_ih) || !n_unfm_number ||
- pos_in_item(p_s_path) + 1 != n_unfm_number,
- "PAP-5240: invalid item %h "
- "n_unfm_number = %d *p_n_pos_in_item = %d",
- &s_ih, n_unfm_number, pos_in_item(p_s_path));
-
- /* Calculate balance mode and position in the item to remove unformatted nodes. */
- if (n_new_file_length == max_reiserfs_offset(inode)) { /* Case of delete. */
- pos_in_item(p_s_path) = 0;
- *p_n_cut_size = -(IH_SIZE + ih_item_len(&s_ih));
- c_mode = M_DELETE;
- } else { /* Case of truncate. */
- if (n_new_file_length < le_ih_k_offset(&s_ih)) {
- pos_in_item(p_s_path) = 0;
- *p_n_cut_size =
- -(IH_SIZE + ih_item_len(&s_ih));
- c_mode = M_DELETE; /* Delete this item. */
- } else {
- /* indirect item must be truncated starting from *p_n_pos_in_item-th position */
- pos_in_item(p_s_path) =
- (n_new_file_length + n_blk_size -
- le_ih_k_offset(&s_ih)) >> p_s_sb->
- s_blocksize_bits;
-
- RFALSE(pos_in_item(p_s_path) >
- n_unfm_number,
- "PAP-5250: invalid position in the item");
-
- /* Either convert last unformatted node of indirect item to direct item or increase
- its free space. */
- if (pos_in_item(p_s_path) ==
- n_unfm_number) {
- *p_n_cut_size = 0; /* Nothing to cut. */
- return M_CONVERT; /* Maybe convert last unformatted node to the direct item. */
- }
- /* Calculate size to cut. */
- *p_n_cut_size =
- -(ih_item_len(&s_ih) -
- pos_in_item(p_s_path) *
- UNFM_P_SIZE);
-
- c_mode = M_CUT; /* Cut from this indirect item. */
- }
- }
+ int blk_size = p_s_sb->s_blocksize;
+ struct item_head s_ih;
+ int need_re_search;
+ int delete = 0;
+ int result = M_CUT;
+ int pos = 0;
+
+ if ( n_new_file_length == max_reiserfs_offset (inode) ) {
+ /* prepare_for_delete_or_cut() is called by
+ * reiserfs_delete_item() */
+ n_new_file_length = 0;
+ delete = 1;
+ }
+
+ do {
+ need_re_search = 0;
+ *p_n_cut_size = 0;
+ p_s_bh = PATH_PLAST_BUFFER(p_s_path);
+ copy_item_head(&s_ih, PATH_PITEM_HEAD(p_s_path));
+ pos = I_UNFM_NUM(&s_ih);
- RFALSE(n_unfm_number <= pos_in_item(p_s_path),
- "PAP-5260: invalid position in the indirect item");
-
- /* pointers to be cut */
- n_unfm_number -= pos_in_item(p_s_path);
- /* Set pointer to the last unformatted node pointer that is to be cut. */
- p_n_unfm_pointer =
- (__le32 *) B_I_PITEM(p_s_bh,
- &s_ih) + I_UNFM_NUM(&s_ih) -
- 1 - *p_n_removed;
-
- /* We go through the unformatted nodes pointers of the indirect
- item and look for the unformatted nodes in the cache. If we
- found some of them we free it, zero corresponding indirect item
- entry and log buffer containing that indirect item. For this we
- need to prepare last path element for logging. If some
- unformatted node has b_count > 1 we must not free this
- unformatted node since it is in use. */
- reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
- // note: path could be changed, first line in for loop takes care
- // of it
+ while (le_ih_k_offset (&s_ih) + (pos - 1) * blk_size > n_new_file_length) {
+ __u32 *unfm, block;
- for (n_counter = *p_n_removed;
- n_counter < n_unfm_number;
- n_counter++, p_n_unfm_pointer--) {
+ /* Each unformatted block deletion may involve one additional
+ * bitmap block into the transaction, thereby the initial
+ * journal space reservation might not be enough. */
+ if (!delete && (*p_n_cut_size) != 0 &&
+ reiserfs_transaction_free_space(th) < JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
+ break;
+ }
- cond_resched();
- if (item_moved(&s_ih, p_s_path)) {
- need_research = 1;
- break;
- }
- RFALSE(p_n_unfm_pointer <
- (__le32 *) B_I_PITEM(p_s_bh, &s_ih)
- || p_n_unfm_pointer >
- (__le32 *) B_I_PITEM(p_s_bh,
- &s_ih) +
- I_UNFM_NUM(&s_ih) - 1,
- "vs-5265: pointer out of range");
-
- /* Hole, nothing to remove. */
- if (!get_block_num(p_n_unfm_pointer, 0)) {
- (*p_n_removed)++;
- continue;
- }
+ unfm = (__u32 *)B_I_PITEM(p_s_bh, &s_ih) + pos - 1;
+ block = get_block_num(unfm, 0);
- (*p_n_removed)++;
+ if (block != 0) {
+ reiserfs_prepare_for_journal(p_s_sb, p_s_bh, 1);
+ put_block_num(unfm, 0, 0);
+ journal_mark_dirty (th, p_s_sb, p_s_bh);
+ reiserfs_free_block(th, inode, block, 1);
+ }
- tmp = get_block_num(p_n_unfm_pointer, 0);
- put_block_num(p_n_unfm_pointer, 0, 0);
- journal_mark_dirty(th, p_s_sb, p_s_bh);
- reiserfs_free_block(th, inode, tmp, 1);
- if (item_moved(&s_ih, p_s_path)) {
- need_research = 1;
- break;
- }
- }
+ cond_resched();
- /* a trick. If the buffer has been logged, this
- ** will do nothing. If we've broken the loop without
- ** logging it, it will restore the buffer
- **
- */
- reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
-
- /* This loop can be optimized. */
- } while ((*p_n_removed < n_unfm_number || need_research) &&
- search_for_position_by_key(p_s_sb, p_s_item_key,
- p_s_path) ==
- POSITION_FOUND);
-
- RFALSE(*p_n_removed < n_unfm_number,
- "PAP-5310: indirect item is not found");
- RFALSE(item_moved(&s_ih, p_s_path),
- "after while, comp failed, retry");
-
- if (c_mode == M_CUT)
- pos_in_item(p_s_path) *= UNFM_P_SIZE;
- return c_mode;
+ if (item_moved (&s_ih, p_s_path)) {
+ need_re_search = 1;
+ break;
+ }
+
+ pos --;
+ (*p_n_removed) ++;
+ (*p_n_cut_size) -= UNFM_P_SIZE;
+
+ if (pos == 0) {
+ (*p_n_cut_size) -= IH_SIZE;
+ result = M_DELETE;
+ break;
+ }
+ }
+ /* a trick. If the buffer has been logged, this will do nothing. If
+ ** we've broken the loop without logging it, it will restore the
+ ** buffer */
+ reiserfs_restore_prepared_buffer(p_s_sb, p_s_bh);
+ } while (need_re_search &&
+ search_for_position_by_key(p_s_sb, p_s_item_key, p_s_path) == POSITION_FOUND);
+ pos_in_item(p_s_path) = pos * UNFM_P_SIZE;
+
+ if (*p_n_cut_size == 0) {
+ /* Nothing were cut. maybe convert last unformatted node to the
+ * direct item? */
+ result = M_CONVERT;
+ }
+ return result;
}
}
@@ -1948,7 +1881,8 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
** sure the file is consistent before ending the current trans
** and starting a new one
*/
- if (journal_transaction_should_end(th, th->t_blocks_allocated)) {
+ if (journal_transaction_should_end(th, 0) ||
+ reiserfs_transaction_free_space(th) <= JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD) {
int orig_len_alloc = th->t_blocks_allocated;
decrement_counters_in_path(&s_search_path);
@@ -1962,7 +1896,7 @@ int reiserfs_do_truncate(struct reiserfs_transaction_handle *th, struct inode *p
if (err)
goto out;
err = journal_begin(th, p_s_inode->i_sb,
- JOURNAL_PER_BALANCE_CNT * 6);
+ JOURNAL_FOR_FREE_BLOCK_AND_UPDATE_SD + JOURNAL_PER_BALANCE_CNT * 4) ;
if (err)
goto out;
reiserfs_update_inode_transaction(p_s_inode);
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index d63da756eb4..cae2abbc0c7 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -521,7 +521,8 @@ static int init_inodecache(void)
reiserfs_inode_cachep = kmem_cache_create("reiser_inode_cache",
sizeof(struct
reiserfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (reiserfs_inode_cachep == NULL)
return -ENOMEM;
@@ -684,14 +685,14 @@ static const arg_desc_t logging_mode[] = {
(1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_WRITEBACK)},
{"writeback", 1 << REISERFS_DATA_WRITEBACK,
(1 << REISERFS_DATA_ORDERED | 1 << REISERFS_DATA_LOG)},
- {NULL, 0}
+ {.value = NULL}
};
/* possible values for -o barrier= */
static const arg_desc_t barrier_mode[] = {
{"none", 1 << REISERFS_BARRIER_NONE, 1 << REISERFS_BARRIER_FLUSH},
{"flush", 1 << REISERFS_BARRIER_FLUSH, 1 << REISERFS_BARRIER_NONE},
- {NULL, 0}
+ {.value = NULL}
};
/* possible values for "-o block-allocator=" and bits which are to be set in
@@ -889,7 +890,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
{"acl",.setmask = 1 << REISERFS_UNSUPPORTED_OPT},
{"noacl",.clrmask = 1 << REISERFS_UNSUPPORTED_OPT},
#endif
- {"nolog",}, /* This is unsupported */
+ {.option_name = "nolog"},
{"replayonly",.setmask = 1 << REPLAYONLY},
{"block-allocator",.arg_required = 'a',.values = balloc},
{"data",.arg_required = 'd',.values = logging_mode},
@@ -907,7 +908,7 @@ static int reiserfs_parse_options(struct super_block *s, char *options, /* strin
{"grpjquota",.arg_required =
'g' | (1 << REISERFS_OPT_ALLOWEMPTY),.values = NULL},
{"jqfmt",.arg_required = 'f',.values = NULL},
- {NULL,}
+ {.option_name = NULL}
};
*blocks = 0;
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index ab8894c3b9e..58c418fbca2 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -182,7 +182,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
{
char *name, *value;
struct posix_acl *acl, **p_acl;
- size_t size;
+ int size;
int retval;
struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode);
@@ -206,7 +206,7 @@ struct posix_acl *reiserfs_get_acl(struct inode *inode, int type)
return posix_acl_dup(*p_acl);
size = reiserfs_xattr_get(inode, name, NULL, 0);
- if ((int)size < 0) {
+ if (size < 0) {
if (size == -ENODATA || size == -ENOSYS) {
*p_acl = ERR_PTR(-ENODATA);
return NULL;
diff --git a/fs/relayfs/Makefile b/fs/relayfs/Makefile
deleted file mode 100644
index e76e182cdb3..00000000000
--- a/fs/relayfs/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-obj-$(CONFIG_RELAYFS_FS) += relayfs.o
-
-relayfs-y := relay.o inode.o buffers.o
-
diff --git a/fs/relayfs/buffers.c b/fs/relayfs/buffers.c
deleted file mode 100644
index 10187812771..00000000000
--- a/fs/relayfs/buffers.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * RelayFS buffer management code.
- *
- * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
- * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
- *
- * This file is released under the GPL.
- */
-
-#include <linux/module.h>
-#include <linux/vmalloc.h>
-#include <linux/mm.h>
-#include <linux/relayfs_fs.h>
-#include "relay.h"
-#include "buffers.h"
-
-/*
- * close() vm_op implementation for relayfs file mapping.
- */
-static void relay_file_mmap_close(struct vm_area_struct *vma)
-{
- struct rchan_buf *buf = vma->vm_private_data;
- buf->chan->cb->buf_unmapped(buf, vma->vm_file);
-}
-
-/*
- * nopage() vm_op implementation for relayfs file mapping.
- */
-static struct page *relay_buf_nopage(struct vm_area_struct *vma,
- unsigned long address,
- int *type)
-{
- struct page *page;
- struct rchan_buf *buf = vma->vm_private_data;
- unsigned long offset = address - vma->vm_start;
-
- if (address > vma->vm_end)
- return NOPAGE_SIGBUS; /* Disallow mremap */
- if (!buf)
- return NOPAGE_OOM;
-
- page = vmalloc_to_page(buf->start + offset);
- if (!page)
- return NOPAGE_OOM;
- get_page(page);
-
- if (type)
- *type = VM_FAULT_MINOR;
-
- return page;
-}
-
-/*
- * vm_ops for relay file mappings.
- */
-static struct vm_operations_struct relay_file_mmap_ops = {
- .nopage = relay_buf_nopage,
- .close = relay_file_mmap_close,
-};
-
-/**
- * relay_mmap_buf: - mmap channel buffer to process address space
- * @buf: relay channel buffer
- * @vma: vm_area_struct describing memory to be mapped
- *
- * Returns 0 if ok, negative on error
- *
- * Caller should already have grabbed mmap_sem.
- */
-int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
-{
- unsigned long length = vma->vm_end - vma->vm_start;
- struct file *filp = vma->vm_file;
-
- if (!buf)
- return -EBADF;
-
- if (length != (unsigned long)buf->chan->alloc_size)
- return -EINVAL;
-
- vma->vm_ops = &relay_file_mmap_ops;
- vma->vm_private_data = buf;
- buf->chan->cb->buf_mapped(buf, filp);
-
- return 0;
-}
-
-/**
- * relay_alloc_buf - allocate a channel buffer
- * @buf: the buffer struct
- * @size: total size of the buffer
- *
- * Returns a pointer to the resulting buffer, NULL if unsuccessful
- */
-static void *relay_alloc_buf(struct rchan_buf *buf, unsigned long size)
-{
- void *mem;
- unsigned int i, j, n_pages;
-
- size = PAGE_ALIGN(size);
- n_pages = size >> PAGE_SHIFT;
-
- buf->page_array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
- if (!buf->page_array)
- return NULL;
-
- for (i = 0; i < n_pages; i++) {
- buf->page_array[i] = alloc_page(GFP_KERNEL);
- if (unlikely(!buf->page_array[i]))
- goto depopulate;
- }
- mem = vmap(buf->page_array, n_pages, VM_MAP, PAGE_KERNEL);
- if (!mem)
- goto depopulate;
-
- memset(mem, 0, size);
- buf->page_count = n_pages;
- return mem;
-
-depopulate:
- for (j = 0; j < i; j++)
- __free_page(buf->page_array[j]);
- kfree(buf->page_array);
- return NULL;
-}
-
-/**
- * relay_create_buf - allocate and initialize a channel buffer
- * @alloc_size: size of the buffer to allocate
- * @n_subbufs: number of sub-buffers in the channel
- *
- * Returns channel buffer if successful, NULL otherwise
- */
-struct rchan_buf *relay_create_buf(struct rchan *chan)
-{
- struct rchan_buf *buf = kcalloc(1, sizeof(struct rchan_buf), GFP_KERNEL);
- if (!buf)
- return NULL;
-
- buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
- if (!buf->padding)
- goto free_buf;
-
- buf->start = relay_alloc_buf(buf, chan->alloc_size);
- if (!buf->start)
- goto free_buf;
-
- buf->chan = chan;
- kref_get(&buf->chan->kref);
- return buf;
-
-free_buf:
- kfree(buf->padding);
- kfree(buf);
- return NULL;
-}
-
-/**
- * relay_destroy_buf - destroy an rchan_buf struct and associated buffer
- * @buf: the buffer struct
- */
-void relay_destroy_buf(struct rchan_buf *buf)
-{
- struct rchan *chan = buf->chan;
- unsigned int i;
-
- if (likely(buf->start)) {
- vunmap(buf->start);
- for (i = 0; i < buf->page_count; i++)
- __free_page(buf->page_array[i]);
- kfree(buf->page_array);
- }
- kfree(buf->padding);
- kfree(buf);
- kref_put(&chan->kref, relay_destroy_channel);
-}
-
-/**
- * relay_remove_buf - remove a channel buffer
- *
- * Removes the file from the relayfs fileystem, which also frees the
- * rchan_buf_struct and the channel buffer. Should only be called from
- * kref_put().
- */
-void relay_remove_buf(struct kref *kref)
-{
- struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
- buf->chan->cb->remove_buf_file(buf->dentry);
- relay_destroy_buf(buf);
-}
diff --git a/fs/relayfs/buffers.h b/fs/relayfs/buffers.h
deleted file mode 100644
index 37a12493f64..00000000000
--- a/fs/relayfs/buffers.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _BUFFERS_H
-#define _BUFFERS_H
-
-/* This inspired by rtai/shmem */
-#define FIX_SIZE(x) (((x) - 1) & PAGE_MASK) + PAGE_SIZE
-
-extern int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma);
-extern struct rchan_buf *relay_create_buf(struct rchan *chan);
-extern void relay_destroy_buf(struct rchan_buf *buf);
-extern void relay_remove_buf(struct kref *kref);
-
-#endif/* _BUFFERS_H */
diff --git a/fs/relayfs/inode.c b/fs/relayfs/inode.c
deleted file mode 100644
index 383523011aa..00000000000
--- a/fs/relayfs/inode.c
+++ /dev/null
@@ -1,581 +0,0 @@
-/*
- * VFS-related code for RelayFS, a high-speed data relay filesystem.
- *
- * Copyright (C) 2003-2005 - Tom Zanussi <zanussi@us.ibm.com>, IBM Corp
- * Copyright (C) 2003-2005 - Karim Yaghmour <karim@opersys.com>
- *
- * Based on ramfs, Copyright (C) 2002 - Linus Torvalds
- *
- * This file is released under the GPL.
- */
-
-#include <linux/module.h>
-#include <linux/fs.h>
-#include <linux/mount.h>
-#include <linux/pagemap.h>
-#include <linux/init.h>
-#include <linux/string.h>
-#include <linux/backing-dev.h>
-#include <linux/namei.h>
-#include <linux/poll.h>
-#include <linux/relayfs_fs.h>
-#include "relay.h"
-#include "buffers.h"
-
-#define RELAYFS_MAGIC 0xF0B4A981
-
-static struct vfsmount * relayfs_mount;
-static int relayfs_mount_count;
-
-static struct backing_dev_info relayfs_backing_dev_info = {
- .ra_pages = 0, /* No readahead */
- .capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
-};
-
-static struct inode *relayfs_get_inode(struct super_block *sb,
- int mode,
- struct file_operations *fops,
- void *data)
-{
- struct inode *inode;
-
- inode = new_inode(sb);
- if (!inode)
- return NULL;
-
- inode->i_mode = mode;
- inode->i_uid = 0;
- inode->i_gid = 0;
- inode->i_blksize = PAGE_CACHE_SIZE;
- inode->i_blocks = 0;
- inode->i_mapping->backing_dev_info = &relayfs_backing_dev_info;
- inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
- switch (mode & S_IFMT) {
- case S_IFREG:
- inode->i_fop = fops;
- if (data)
- inode->u.generic_ip = data;
- break;
- case S_IFDIR:
- inode->i_op = &simple_dir_inode_operations;
- inode->i_fop = &simple_dir_operations;
-
- /* directory inodes start off with i_nlink == 2 (for "." entry) */
- inode->i_nlink++;
- break;
- default:
- break;
- }
-
- return inode;
-}
-
-/**
- * relayfs_create_entry - create a relayfs directory or file
- * @name: the name of the file to create
- * @parent: parent directory
- * @mode: mode
- * @fops: file operations to use for the file
- * @data: user-associated data for this file
- *
- * Returns the new dentry, NULL on failure
- *
- * Creates a file or directory with the specifed permissions.
- */
-static struct dentry *relayfs_create_entry(const char *name,
- struct dentry *parent,
- int mode,
- struct file_operations *fops,
- void *data)
-{
- struct dentry *d;
- struct inode *inode;
- int error = 0;
-
- BUG_ON(!name || !(S_ISREG(mode) || S_ISDIR(mode)));
-
- error = simple_pin_fs("relayfs", &relayfs_mount, &relayfs_mount_count);
- if (error) {
- printk(KERN_ERR "Couldn't mount relayfs: errcode %d\n", error);
- return NULL;
- }
-
- if (!parent && relayfs_mount && relayfs_mount->mnt_sb)
- parent = relayfs_mount->mnt_sb->s_root;
-
- if (!parent) {
- simple_release_fs(&relayfs_mount, &relayfs_mount_count);
- return NULL;
- }
-
- parent = dget(parent);
- mutex_lock(&parent->d_inode->i_mutex);
- d = lookup_one_len(name, parent, strlen(name));
- if (IS_ERR(d)) {
- d = NULL;
- goto release_mount;
- }
-
- if (d->d_inode) {
- d = NULL;
- goto release_mount;
- }
-
- inode = relayfs_get_inode(parent->d_inode->i_sb, mode, fops, data);
- if (!inode) {
- d = NULL;
- goto release_mount;
- }
-
- d_instantiate(d, inode);
- dget(d); /* Extra count - pin the dentry in core */
-
- if (S_ISDIR(mode))
- parent->d_inode->i_nlink++;
-
- goto exit;
-
-release_mount:
- simple_release_fs(&relayfs_mount, &relayfs_mount_count);
-
-exit:
- mutex_unlock(&parent->d_inode->i_mutex);
- dput(parent);
- return d;
-}
-
-/**
- * relayfs_create_file - create a file in the relay filesystem
- * @name: the name of the file to create
- * @parent: parent directory
- * @mode: mode, if not specied the default perms are used
- * @fops: file operations to use for the file
- * @data: user-associated data for this file
- *
- * Returns file dentry if successful, NULL otherwise.
- *
- * The file will be created user r on behalf of current user.
- */
-struct dentry *relayfs_create_file(const char *name,
- struct dentry *parent,
- int mode,
- struct file_operations *fops,
- void *data)
-{
- BUG_ON(!fops);
-
- if (!mode)
- mode = S_IRUSR;
- mode = (mode & S_IALLUGO) | S_IFREG;
-
- return relayfs_create_entry(name, parent, mode, fops, data);
-}
-
-/**
- * relayfs_create_dir - create a directory in the relay filesystem
- * @name: the name of the directory to create
- * @parent: parent directory, NULL if parent should be fs root
- *
- * Returns directory dentry if successful, NULL otherwise.
- *
- * The directory will be created world rwx on behalf of current user.
- */
-struct dentry *relayfs_create_dir(const char *name, struct dentry *parent)
-{
- int mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
- return relayfs_create_entry(name, parent, mode, NULL, NULL);
-}
-
-/**
- * relayfs_remove - remove a file or directory in the relay filesystem
- * @dentry: file or directory dentry
- *
- * Returns 0 if successful, negative otherwise.
- */
-int relayfs_remove(struct dentry *dentry)
-{
- struct dentry *parent;
- int error = 0;
-
- if (!dentry)
- return -EINVAL;
- parent = dentry->d_parent;
- if (!parent)
- return -EINVAL;
-
- parent = dget(parent);
- mutex_lock(&parent->d_inode->i_mutex);
- if (dentry->d_inode) {
- if (S_ISDIR(dentry->d_inode->i_mode))
- error = simple_rmdir(parent->d_inode, dentry);
- else
- error = simple_unlink(parent->d_inode, dentry);
- if (!error)
- d_delete(dentry);
- }
- if (!error)
- dput(dentry);
- mutex_unlock(&parent->d_inode->i_mutex);
- dput(parent);
-
- if (!error)
- simple_release_fs(&relayfs_mount, &relayfs_mount_count);
-
- return error;
-}
-
-/**
- * relayfs_remove_file - remove a file from relay filesystem
- * @dentry: directory dentry
- *
- * Returns 0 if successful, negative otherwise.
- */
-int relayfs_remove_file(struct dentry *dentry)
-{
- return relayfs_remove(dentry);
-}
-
-/**
- * relayfs_remove_dir - remove a directory in the relay filesystem
- * @dentry: directory dentry
- *
- * Returns 0 if successful, negative otherwise.
- */
-int relayfs_remove_dir(struct dentry *dentry)
-{
- return relayfs_remove(dentry);
-}
-
-/**
- * relay_file_open - open file op for relay files
- * @inode: the inode
- * @filp: the file
- *
- * Increments the channel buffer refcount.
- */
-static int relay_file_open(struct inode *inode, struct file *filp)
-{
- struct rchan_buf *buf = inode->u.generic_ip;
- kref_get(&buf->kref);
- filp->private_data = buf;
-
- return 0;
-}
-
-/**
- * relay_file_mmap - mmap file op for relay files
- * @filp: the file
- * @vma: the vma describing what to map
- *
- * Calls upon relay_mmap_buf to map the file into user space.
- */
-static int relay_file_mmap(struct file *filp, struct vm_area_struct *vma)
-{
- struct rchan_buf *buf = filp->private_data;
- return relay_mmap_buf(buf, vma);
-}
-
-/**
- * relay_file_poll - poll file op for relay files
- * @filp: the file
- * @wait: poll table
- *
- * Poll implemention.
- */
-static unsigned int relay_file_poll(struct file *filp, poll_table *wait)
-{
- unsigned int mask = 0;
- struct rchan_buf *buf = filp->private_data;
-
- if (buf->finalized)
- return POLLERR;
-
- if (filp->f_mode & FMODE_READ) {
- poll_wait(filp, &buf->read_wait, wait);
- if (!relay_buf_empty(buf))
- mask |= POLLIN | POLLRDNORM;
- }
-
- return mask;
-}
-
-/**
- * relay_file_release - release file op for relay files
- * @inode: the inode
- * @filp: the file
- *
- * Decrements the channel refcount, as the filesystem is
- * no longer using it.
- */
-static int relay_file_release(struct inode *inode, struct file *filp)
-{
- struct rchan_buf *buf = filp->private_data;
- kref_put(&buf->kref, relay_remove_buf);
-
- return 0;
-}
-
-/**
- * relay_file_read_consume - update the consumed count for the buffer
- */
-static void relay_file_read_consume(struct rchan_buf *buf,
- size_t read_pos,
- size_t bytes_consumed)
-{
- size_t subbuf_size = buf->chan->subbuf_size;
- size_t n_subbufs = buf->chan->n_subbufs;
- size_t read_subbuf;
-
- if (buf->bytes_consumed + bytes_consumed > subbuf_size) {
- relay_subbufs_consumed(buf->chan, buf->cpu, 1);
- buf->bytes_consumed = 0;
- }
-
- buf->bytes_consumed += bytes_consumed;
- read_subbuf = read_pos / buf->chan->subbuf_size;
- if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) {
- if ((read_subbuf == buf->subbufs_produced % n_subbufs) &&
- (buf->offset == subbuf_size))
- return;
- relay_subbufs_consumed(buf->chan, buf->cpu, 1);
- buf->bytes_consumed = 0;
- }
-}
-
-/**
- * relay_file_read_avail - boolean, are there unconsumed bytes available?
- */
-static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
-{
- size_t bytes_produced, bytes_consumed, write_offset;
- size_t subbuf_size = buf->chan->subbuf_size;
- size_t n_subbufs = buf->chan->n_subbufs;
- size_t produced = buf->subbufs_produced % n_subbufs;
- size_t consumed = buf->subbufs_consumed % n_subbufs;
-
- write_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset;
-
- if (consumed > produced) {
- if ((produced > n_subbufs) &&
- (produced + n_subbufs - consumed <= n_subbufs))
- produced += n_subbufs;
- } else if (consumed == produced) {
- if (buf->offset > subbuf_size) {
- produced += n_subbufs;
- if (buf->subbufs_produced == buf->subbufs_consumed)
- consumed += n_subbufs;
- }
- }
-
- if (buf->offset > subbuf_size)
- bytes_produced = (produced - 1) * subbuf_size + write_offset;
- else
- bytes_produced = produced * subbuf_size + write_offset;
- bytes_consumed = consumed * subbuf_size + buf->bytes_consumed;
-
- if (bytes_produced == bytes_consumed)
- return 0;
-
- relay_file_read_consume(buf, read_pos, 0);
-
- return 1;
-}
-
-/**
- * relay_file_read_subbuf_avail - return bytes available in sub-buffer
- */
-static size_t relay_file_read_subbuf_avail(size_t read_pos,
- struct rchan_buf *buf)
-{
- size_t padding, avail = 0;
- size_t read_subbuf, read_offset, write_subbuf, write_offset;
- size_t subbuf_size = buf->chan->subbuf_size;
-
- write_subbuf = (buf->data - buf->start) / subbuf_size;
- write_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset;
- read_subbuf = read_pos / subbuf_size;
- read_offset = read_pos % subbuf_size;
- padding = buf->padding[read_subbuf];
-
- if (read_subbuf == write_subbuf) {
- if (read_offset + padding < write_offset)
- avail = write_offset - (read_offset + padding);
- } else
- avail = (subbuf_size - padding) - read_offset;
-
- return avail;
-}
-
-/**
- * relay_file_read_start_pos - find the first available byte to read
- *
- * If the read_pos is in the middle of padding, return the
- * position of the first actually available byte, otherwise
- * return the original value.
- */
-static size_t relay_file_read_start_pos(size_t read_pos,
- struct rchan_buf *buf)
-{
- size_t read_subbuf, padding, padding_start, padding_end;
- size_t subbuf_size = buf->chan->subbuf_size;
- size_t n_subbufs = buf->chan->n_subbufs;
-
- read_subbuf = read_pos / subbuf_size;
- padding = buf->padding[read_subbuf];
- padding_start = (read_subbuf + 1) * subbuf_size - padding;
- padding_end = (read_subbuf + 1) * subbuf_size;
- if (read_pos >= padding_start && read_pos < padding_end) {
- read_subbuf = (read_subbuf + 1) % n_subbufs;
- read_pos = read_subbuf * subbuf_size;
- }
-
- return read_pos;
-}
-
-/**
- * relay_file_read_end_pos - return the new read position
- */
-static size_t relay_file_read_end_pos(struct rchan_buf *buf,
- size_t read_pos,
- size_t count)
-{
- size_t read_subbuf, padding, end_pos;
- size_t subbuf_size = buf->chan->subbuf_size;
- size_t n_subbufs = buf->chan->n_subbufs;
-
- read_subbuf = read_pos / subbuf_size;
- padding = buf->padding[read_subbuf];
- if (read_pos % subbuf_size + count + padding == subbuf_size)
- end_pos = (read_subbuf + 1) * subbuf_size;
- else
- end_pos = read_pos + count;
- if (end_pos >= subbuf_size * n_subbufs)
- end_pos = 0;
-
- return end_pos;
-}
-
-/**
- * relay_file_read - read file op for relay files
- * @filp: the file
- * @buffer: the userspace buffer
- * @count: number of bytes to read
- * @ppos: position to read from
- *
- * Reads count bytes or the number of bytes available in the
- * current sub-buffer being read, whichever is smaller.
- */
-static ssize_t relay_file_read(struct file *filp,
- char __user *buffer,
- size_t count,
- loff_t *ppos)
-{
- struct rchan_buf *buf = filp->private_data;
- struct inode *inode = filp->f_dentry->d_inode;
- size_t read_start, avail;
- ssize_t ret = 0;
- void *from;
-
- mutex_lock(&inode->i_mutex);
- if(!relay_file_read_avail(buf, *ppos))
- goto out;
-
- read_start = relay_file_read_start_pos(*ppos, buf);
- avail = relay_file_read_subbuf_avail(read_start, buf);
- if (!avail)
- goto out;
-
- from = buf->start + read_start;
- ret = count = min(count, avail);
- if (copy_to_user(buffer, from, count)) {
- ret = -EFAULT;
- goto out;
- }
- relay_file_read_consume(buf, read_start, count);
- *ppos = relay_file_read_end_pos(buf, read_start, count);
-out:
- mutex_unlock(&inode->i_mutex);
- return ret;
-}
-
-struct file_operations relay_file_operations = {
- .open = relay_file_open,
- .poll = relay_file_poll,
- .mmap = relay_file_mmap,
- .read = relay_file_read,
- .llseek = no_llseek,
- .release = relay_file_release,
-};
-
-static struct super_operations relayfs_ops = {
- .statfs = simple_statfs,
- .drop_inode = generic_delete_inode,
-};
-
-static int relayfs_fill_super(struct super_block * sb, void * data, int silent)
-{
- struct inode *inode;
- struct dentry *root;
- int mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
-
- sb->s_blocksize = PAGE_CACHE_SIZE;
- sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
- sb->s_magic = RELAYFS_MAGIC;
- sb->s_op = &relayfs_ops;
- inode = relayfs_get_inode(sb, mode, NULL, NULL);
-
- if (!inode)
- return -ENOMEM;
-
- root = d_alloc_root(inode);
- if (!root) {
- iput(inode);
- return -ENOMEM;
- }
- sb->s_root = root;
-
- return 0;
-}
-
-static struct super_block * relayfs_get_sb(struct file_system_type *fs_type,
- int flags, const char *dev_name,
- void *data)
-{
- return get_sb_single(fs_type, flags, data, relayfs_fill_super);
-}
-
-static struct file_system_type relayfs_fs_type = {
- .owner = THIS_MODULE,
- .name = "relayfs",
- .get_sb = relayfs_get_sb,
- .kill_sb = kill_litter_super,
-};
-
-static int __init init_relayfs_fs(void)
-{
- return register_filesystem(&relayfs_fs_type);
-}
-
-static void __exit exit_relayfs_fs(void)
-{
-
-
-
-
-
- unregister_filesystem(&relayfs_fs_type);
-}
-
-module_init(init_relayfs_fs)
-module_exit(exit_relayfs_fs)
-
-EXPORT_SYMBOL_GPL(relay_file_operations);
-EXPORT_SYMBOL_GPL(relayfs_create_dir);
-EXPORT_SYMBOL_GPL(relayfs_remove_dir);
-EXPORT_SYMBOL_GPL(relayfs_create_file);
-EXPORT_SYMBOL_GPL(relayfs_remove_file);
-
-MODULE_AUTHOR("Tom Zanussi <zanussi@us.ibm.com> and Karim Yaghmour <karim@opersys.com>");
-MODULE_DESCRIPTION("Relay Filesystem");
-MODULE_LICENSE("GPL");
-
diff --git a/fs/relayfs/relay.c b/fs/relayfs/relay.c
deleted file mode 100644
index abf3ceaace4..00000000000
--- a/fs/relayfs/relay.c
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- * Public API and common code for RelayFS.
- *
- * See Documentation/filesystems/relayfs.txt for an overview of relayfs.
- *
- * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
- * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
- *
- * This file is released under the GPL.
- */
-
-#include <linux/errno.h>
-#include <linux/stddef.h>
-#include <linux/slab.h>
-#include <linux/module.h>
-#include <linux/string.h>
-#include <linux/relayfs_fs.h>
-#include "relay.h"
-#include "buffers.h"
-
-/**
- * relay_buf_empty - boolean, is the channel buffer empty?
- * @buf: channel buffer
- *
- * Returns 1 if the buffer is empty, 0 otherwise.
- */
-int relay_buf_empty(struct rchan_buf *buf)
-{
- return (buf->subbufs_produced - buf->subbufs_consumed) ? 0 : 1;
-}
-
-/**
- * relay_buf_full - boolean, is the channel buffer full?
- * @buf: channel buffer
- *
- * Returns 1 if the buffer is full, 0 otherwise.
- */
-int relay_buf_full(struct rchan_buf *buf)
-{
- size_t ready = buf->subbufs_produced - buf->subbufs_consumed;
- return (ready >= buf->chan->n_subbufs) ? 1 : 0;
-}
-
-/*
- * High-level relayfs kernel API and associated functions.
- */
-
-/*
- * rchan_callback implementations defining default channel behavior. Used
- * in place of corresponding NULL values in client callback struct.
- */
-
-/*
- * subbuf_start() default callback. Does nothing.
- */
-static int subbuf_start_default_callback (struct rchan_buf *buf,
- void *subbuf,
- void *prev_subbuf,
- size_t prev_padding)
-{
- if (relay_buf_full(buf))
- return 0;
-
- return 1;
-}
-
-/*
- * buf_mapped() default callback. Does nothing.
- */
-static void buf_mapped_default_callback(struct rchan_buf *buf,
- struct file *filp)
-{
-}
-
-/*
- * buf_unmapped() default callback. Does nothing.
- */
-static void buf_unmapped_default_callback(struct rchan_buf *buf,
- struct file *filp)
-{
-}
-
-/*
- * create_buf_file_create() default callback. Creates file to represent buf.
- */
-static struct dentry *create_buf_file_default_callback(const char *filename,
- struct dentry *parent,
- int mode,
- struct rchan_buf *buf,
- int *is_global)
-{
- return relayfs_create_file(filename, parent, mode,
- &relay_file_operations, buf);
-}
-
-/*
- * remove_buf_file() default callback. Removes file representing relay buffer.
- */
-static int remove_buf_file_default_callback(struct dentry *dentry)
-{
- return relayfs_remove(dentry);
-}
-
-/* relay channel default callbacks */
-static struct rchan_callbacks default_channel_callbacks = {
- .subbuf_start = subbuf_start_default_callback,
- .buf_mapped = buf_mapped_default_callback,
- .buf_unmapped = buf_unmapped_default_callback,
- .create_buf_file = create_buf_file_default_callback,
- .remove_buf_file = remove_buf_file_default_callback,
-};
-
-/**
- * wakeup_readers - wake up readers waiting on a channel
- * @private: the channel buffer
- *
- * This is the work function used to defer reader waking. The
- * reason waking is deferred is that calling directly from write
- * causes problems if you're writing from say the scheduler.
- */
-static void wakeup_readers(void *private)
-{
- struct rchan_buf *buf = private;
- wake_up_interruptible(&buf->read_wait);
-}
-
-/**
- * __relay_reset - reset a channel buffer
- * @buf: the channel buffer
- * @init: 1 if this is a first-time initialization
- *
- * See relay_reset for description of effect.
- */
-static inline void __relay_reset(struct rchan_buf *buf, unsigned int init)
-{
- size_t i;
-
- if (init) {
- init_waitqueue_head(&buf->read_wait);
- kref_init(&buf->kref);
- INIT_WORK(&buf->wake_readers, NULL, NULL);
- } else {
- cancel_delayed_work(&buf->wake_readers);
- flush_scheduled_work();
- }
-
- buf->subbufs_produced = 0;
- buf->subbufs_consumed = 0;
- buf->bytes_consumed = 0;
- buf->finalized = 0;
- buf->data = buf->start;
- buf->offset = 0;
-
- for (i = 0; i < buf->chan->n_subbufs; i++)
- buf->padding[i] = 0;
-
- buf->chan->cb->subbuf_start(buf, buf->data, NULL, 0);
-}
-
-/**
- * relay_reset - reset the channel
- * @chan: the channel
- *
- * This has the effect of erasing all data from all channel buffers
- * and restarting the channel in its initial state. The buffers
- * are not freed, so any mappings are still in effect.
- *
- * NOTE: Care should be taken that the channel isn't actually
- * being used by anything when this call is made.
- */
-void relay_reset(struct rchan *chan)
-{
- unsigned int i;
- struct rchan_buf *prev = NULL;
-
- if (!chan)
- return;
-
- for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i] || chan->buf[i] == prev)
- break;
- __relay_reset(chan->buf[i], 0);
- prev = chan->buf[i];
- }
-}
-
-/**
- * relay_open_buf - create a new channel buffer in relayfs
- *
- * Internal - used by relay_open().
- */
-static struct rchan_buf *relay_open_buf(struct rchan *chan,
- const char *filename,
- struct dentry *parent,
- int *is_global)
-{
- struct rchan_buf *buf;
- struct dentry *dentry;
-
- if (*is_global)
- return chan->buf[0];
-
- buf = relay_create_buf(chan);
- if (!buf)
- return NULL;
-
- /* Create file in fs */
- dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR,
- buf, is_global);
- if (!dentry) {
- relay_destroy_buf(buf);
- return NULL;
- }
-
- buf->dentry = dentry;
- __relay_reset(buf, 1);
-
- return buf;
-}
-
-/**
- * relay_close_buf - close a channel buffer
- * @buf: channel buffer
- *
- * Marks the buffer finalized and restores the default callbacks.
- * The channel buffer and channel buffer data structure are then freed
- * automatically when the last reference is given up.
- */
-static inline void relay_close_buf(struct rchan_buf *buf)
-{
- buf->finalized = 1;
- buf->chan->cb = &default_channel_callbacks;
- cancel_delayed_work(&buf->wake_readers);
- flush_scheduled_work();
- kref_put(&buf->kref, relay_remove_buf);
-}
-
-static inline void setup_callbacks(struct rchan *chan,
- struct rchan_callbacks *cb)
-{
- if (!cb) {
- chan->cb = &default_channel_callbacks;
- return;
- }
-
- if (!cb->subbuf_start)
- cb->subbuf_start = subbuf_start_default_callback;
- if (!cb->buf_mapped)
- cb->buf_mapped = buf_mapped_default_callback;
- if (!cb->buf_unmapped)
- cb->buf_unmapped = buf_unmapped_default_callback;
- if (!cb->create_buf_file)
- cb->create_buf_file = create_buf_file_default_callback;
- if (!cb->remove_buf_file)
- cb->remove_buf_file = remove_buf_file_default_callback;
- chan->cb = cb;
-}
-
-/**
- * relay_open - create a new relayfs channel
- * @base_filename: base name of files to create
- * @parent: dentry of parent directory, NULL for root directory
- * @subbuf_size: size of sub-buffers
- * @n_subbufs: number of sub-buffers
- * @cb: client callback functions
- *
- * Returns channel pointer if successful, NULL otherwise.
- *
- * Creates a channel buffer for each cpu using the sizes and
- * attributes specified. The created channel buffer files
- * will be named base_filename0...base_filenameN-1. File
- * permissions will be S_IRUSR.
- */
-struct rchan *relay_open(const char *base_filename,
- struct dentry *parent,
- size_t subbuf_size,
- size_t n_subbufs,
- struct rchan_callbacks *cb)
-{
- unsigned int i;
- struct rchan *chan;
- char *tmpname;
- int is_global = 0;
-
- if (!base_filename)
- return NULL;
-
- if (!(subbuf_size && n_subbufs))
- return NULL;
-
- chan = kcalloc(1, sizeof(struct rchan), GFP_KERNEL);
- if (!chan)
- return NULL;
-
- chan->version = RELAYFS_CHANNEL_VERSION;
- chan->n_subbufs = n_subbufs;
- chan->subbuf_size = subbuf_size;
- chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
- setup_callbacks(chan, cb);
- kref_init(&chan->kref);
-
- tmpname = kmalloc(NAME_MAX + 1, GFP_KERNEL);
- if (!tmpname)
- goto free_chan;
-
- for_each_online_cpu(i) {
- sprintf(tmpname, "%s%d", base_filename, i);
- chan->buf[i] = relay_open_buf(chan, tmpname, parent,
- &is_global);
- chan->buf[i]->cpu = i;
- if (!chan->buf[i])
- goto free_bufs;
- }
-
- kfree(tmpname);
- return chan;
-
-free_bufs:
- for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i])
- break;
- relay_close_buf(chan->buf[i]);
- if (is_global)
- break;
- }
- kfree(tmpname);
-
-free_chan:
- kref_put(&chan->kref, relay_destroy_channel);
- return NULL;
-}
-
-/**
- * relay_switch_subbuf - switch to a new sub-buffer
- * @buf: channel buffer
- * @length: size of current event
- *
- * Returns either the length passed in or 0 if full.
-
- * Performs sub-buffer-switch tasks such as invoking callbacks,
- * updating padding counts, waking up readers, etc.
- */
-size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
-{
- void *old, *new;
- size_t old_subbuf, new_subbuf;
-
- if (unlikely(length > buf->chan->subbuf_size))
- goto toobig;
-
- if (buf->offset != buf->chan->subbuf_size + 1) {
- buf->prev_padding = buf->chan->subbuf_size - buf->offset;
- old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
- buf->padding[old_subbuf] = buf->prev_padding;
- buf->subbufs_produced++;
- if (waitqueue_active(&buf->read_wait)) {
- PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf);
- schedule_delayed_work(&buf->wake_readers, 1);
- }
- }
-
- old = buf->data;
- new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
- new = buf->start + new_subbuf * buf->chan->subbuf_size;
- buf->offset = 0;
- if (!buf->chan->cb->subbuf_start(buf, new, old, buf->prev_padding)) {
- buf->offset = buf->chan->subbuf_size + 1;
- return 0;
- }
- buf->data = new;
- buf->padding[new_subbuf] = 0;
-
- if (unlikely(length + buf->offset > buf->chan->subbuf_size))
- goto toobig;
-
- return length;
-
-toobig:
- buf->chan->last_toobig = length;
- return 0;
-}
-
-/**
- * relay_subbufs_consumed - update the buffer's sub-buffers-consumed count
- * @chan: the channel
- * @cpu: the cpu associated with the channel buffer to update
- * @subbufs_consumed: number of sub-buffers to add to current buf's count
- *
- * Adds to the channel buffer's consumed sub-buffer count.
- * subbufs_consumed should be the number of sub-buffers newly consumed,
- * not the total consumed.
- *
- * NOTE: kernel clients don't need to call this function if the channel
- * mode is 'overwrite'.
- */
-void relay_subbufs_consumed(struct rchan *chan,
- unsigned int cpu,
- size_t subbufs_consumed)
-{
- struct rchan_buf *buf;
-
- if (!chan)
- return;
-
- if (cpu >= NR_CPUS || !chan->buf[cpu])
- return;
-
- buf = chan->buf[cpu];
- buf->subbufs_consumed += subbufs_consumed;
- if (buf->subbufs_consumed > buf->subbufs_produced)
- buf->subbufs_consumed = buf->subbufs_produced;
-}
-
-/**
- * relay_destroy_channel - free the channel struct
- *
- * Should only be called from kref_put().
- */
-void relay_destroy_channel(struct kref *kref)
-{
- struct rchan *chan = container_of(kref, struct rchan, kref);
- kfree(chan);
-}
-
-/**
- * relay_close - close the channel
- * @chan: the channel
- *
- * Closes all channel buffers and frees the channel.
- */
-void relay_close(struct rchan *chan)
-{
- unsigned int i;
- struct rchan_buf *prev = NULL;
-
- if (!chan)
- return;
-
- for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i] || chan->buf[i] == prev)
- break;
- relay_close_buf(chan->buf[i]);
- prev = chan->buf[i];
- }
-
- if (chan->last_toobig)
- printk(KERN_WARNING "relayfs: one or more items not logged "
- "[item size (%Zd) > sub-buffer size (%Zd)]\n",
- chan->last_toobig, chan->subbuf_size);
-
- kref_put(&chan->kref, relay_destroy_channel);
-}
-
-/**
- * relay_flush - close the channel
- * @chan: the channel
- *
- * Flushes all channel buffers i.e. forces buffer switch.
- */
-void relay_flush(struct rchan *chan)
-{
- unsigned int i;
- struct rchan_buf *prev = NULL;
-
- if (!chan)
- return;
-
- for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i] || chan->buf[i] == prev)
- break;
- relay_switch_subbuf(chan->buf[i], 0);
- prev = chan->buf[i];
- }
-}
-
-EXPORT_SYMBOL_GPL(relay_open);
-EXPORT_SYMBOL_GPL(relay_close);
-EXPORT_SYMBOL_GPL(relay_flush);
-EXPORT_SYMBOL_GPL(relay_reset);
-EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
-EXPORT_SYMBOL_GPL(relay_switch_subbuf);
-EXPORT_SYMBOL_GPL(relay_buf_full);
diff --git a/fs/relayfs/relay.h b/fs/relayfs/relay.h
deleted file mode 100644
index 0993d3e5753..00000000000
--- a/fs/relayfs/relay.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _RELAY_H
-#define _RELAY_H
-
-extern int relayfs_remove(struct dentry *dentry);
-extern int relay_buf_empty(struct rchan_buf *buf);
-extern void relay_destroy_channel(struct kref *kref);
-
-#endif /* _RELAY_H */
diff --git a/fs/romfs/inode.c b/fs/romfs/inode.c
index 0a13859fd57..c2fc424d7d5 100644
--- a/fs/romfs/inode.c
+++ b/fs/romfs/inode.c
@@ -579,7 +579,8 @@ static int init_inodecache(void)
{
romfs_inode_cachep = kmem_cache_create("romfs_inode_cache",
sizeof(struct romfs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (romfs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 7c40570b71d..555b9ac04c2 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -37,7 +37,7 @@ int seq_open(struct file *file, struct seq_operations *op)
file->private_data = p;
}
memset(p, 0, sizeof(*p));
- sema_init(&p->sem, 1);
+ mutex_init(&p->lock);
p->op = op;
/*
@@ -71,7 +71,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
void *p;
int err = 0;
- down(&m->sem);
+ mutex_lock(&m->lock);
/*
* seq_file->op->..m_start/m_stop/m_next may do special actions
* or optimisations based on the file->f_version, so we want to
@@ -164,7 +164,7 @@ Done:
else
*ppos += copied;
file->f_version = m->version;
- up(&m->sem);
+ mutex_unlock(&m->lock);
return copied;
Enomem:
err = -ENOMEM;
@@ -237,7 +237,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
struct seq_file *m = (struct seq_file *)file->private_data;
long long retval = -EINVAL;
- down(&m->sem);
+ mutex_lock(&m->lock);
m->version = file->f_version;
switch (origin) {
case 1:
@@ -260,7 +260,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
}
}
}
- up(&m->sem);
+ mutex_unlock(&m->lock);
file->f_version = m->version;
return retval;
}
diff --git a/fs/smbfs/inode.c b/fs/smbfs/inode.c
index 02e3e82d465..fdeabc0a34f 100644
--- a/fs/smbfs/inode.c
+++ b/fs/smbfs/inode.c
@@ -80,7 +80,8 @@ static int init_inodecache(void)
{
smb_inode_cachep = kmem_cache_create("smb_inode_cache",
sizeof(struct smb_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (smb_inode_cachep == NULL)
return -ENOMEM;
@@ -216,7 +217,7 @@ smb_set_inode_attr(struct inode *inode, struct smb_fattr *fattr)
if (inode->i_mtime.tv_sec != last_time || inode->i_size != last_sz) {
VERBOSE("%ld changed, old=%ld, new=%ld, oz=%ld, nz=%ld\n",
inode->i_ino,
- (long) last_time, (long) inode->i_mtime,
+ (long) last_time, (long) inode->i_mtime.tv_sec,
(long) last_sz, (long) inode->i_size);
if (!S_ISDIR(inode->i_mode))
diff --git a/fs/super.c b/fs/super.c
index e20b5580afd..8743e9bbb29 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -55,11 +55,10 @@ DEFINE_SPINLOCK(sb_lock);
*/
static struct super_block *alloc_super(void)
{
- struct super_block *s = kmalloc(sizeof(struct super_block), GFP_USER);
+ struct super_block *s = kzalloc(sizeof(struct super_block), GFP_USER);
static struct super_operations default_op;
if (s) {
- memset(s, 0, sizeof(struct super_block));
if (security_sb_alloc(s)) {
kfree(s);
s = NULL;
@@ -76,9 +75,9 @@ static struct super_block *alloc_super(void)
down_write(&s->s_umount);
s->s_count = S_BIAS;
atomic_set(&s->s_active, 1);
- sema_init(&s->s_vfs_rename_sem,1);
- sema_init(&s->s_dquot.dqio_sem, 1);
- sema_init(&s->s_dquot.dqonoff_sem, 1);
+ mutex_init(&s->s_vfs_rename_mutex);
+ mutex_init(&s->s_dquot.dqio_mutex);
+ mutex_init(&s->s_dquot.dqonoff_mutex);
init_rwsem(&s->s_dquot.dqptr_sem);
init_waitqueue_head(&s->s_wait_unfrozen);
s->s_maxbytes = MAX_NON_LFS;
@@ -693,9 +692,9 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
* will protect the lockfs code from trying to start a snapshot
* while we are mounting
*/
- down(&bdev->bd_mount_sem);
+ mutex_lock(&bdev->bd_mount_mutex);
s = sget(fs_type, test_bdev_super, set_bdev_super, bdev);
- up(&bdev->bd_mount_sem);
+ mutex_unlock(&bdev->bd_mount_mutex);
if (IS_ERR(s))
goto out;
@@ -712,7 +711,7 @@ struct super_block *get_sb_bdev(struct file_system_type *fs_type,
s->s_flags = flags;
strlcpy(s->s_id, bdevname(bdev, b), sizeof(s->s_id));
sb_set_blocksize(s, block_size(bdev));
- error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
+ error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
if (error) {
up_write(&s->s_umount);
deactivate_super(s);
@@ -756,7 +755,7 @@ struct super_block *get_sb_nodev(struct file_system_type *fs_type,
s->s_flags = flags;
- error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
+ error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
if (error) {
up_write(&s->s_umount);
deactivate_super(s);
@@ -785,7 +784,7 @@ struct super_block *get_sb_single(struct file_system_type *fs_type,
return s;
if (!s->s_root) {
s->s_flags = flags;
- error = fill_super(s, data, flags & MS_VERBOSE ? 1 : 0);
+ error = fill_super(s, data, flags & MS_SILENT ? 1 : 0);
if (error) {
up_write(&s->s_umount);
deactivate_super(s);
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index fa33eceb001..3ff89cc5833 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -342,7 +342,7 @@ int __init sysv_init_icache(void)
{
sysv_inode_cachep = kmem_cache_create("sysv_inode_cache",
sizeof(struct sysv_inode_info), 0,
- SLAB_RECLAIM_ACCOUNT,
+ SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
init_once, NULL);
if (!sysv_inode_cachep)
return -ENOMEM;
diff --git a/fs/sysv/namei.c b/fs/sysv/namei.c
index 7f0e4b53085..b8a73f716fb 100644
--- a/fs/sysv/namei.c
+++ b/fs/sysv/namei.c
@@ -16,18 +16,6 @@
#include <linux/smp_lock.h>
#include "sysv.h"
-static inline void inc_count(struct inode *inode)
-{
- inode->i_nlink++;
- mark_inode_dirty(inode);
-}
-
-static inline void dec_count(struct inode *inode)
-{
- inode->i_nlink--;
- mark_inode_dirty(inode);
-}
-
static int add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = sysv_add_link(dentry, inode);
@@ -35,7 +23,7 @@ static int add_nondir(struct dentry *dentry, struct inode *inode)
d_instantiate(dentry, inode);
return 0;
}
- dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
return err;
}
@@ -124,7 +112,7 @@ out:
return err;
out_fail:
- dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
goto out;
}
@@ -138,7 +126,7 @@ static int sysv_link(struct dentry * old_dentry, struct inode * dir,
return -EMLINK;
inode->i_ctime = CURRENT_TIME_SEC;
- inc_count(inode);
+ inode_inc_link_count(inode);
atomic_inc(&inode->i_count);
return add_nondir(dentry, inode);
@@ -151,7 +139,7 @@ static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
if (dir->i_nlink >= SYSV_SB(dir->i_sb)->s_link_max)
goto out;
- inc_count(dir);
+ inode_inc_link_count(dir);
inode = sysv_new_inode(dir, S_IFDIR|mode);
err = PTR_ERR(inode);
@@ -160,7 +148,7 @@ static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode)
sysv_set_inode(inode, 0);
- inc_count(inode);
+ inode_inc_link_count(inode);
err = sysv_make_empty(inode, dir);
if (err)
@@ -175,11 +163,11 @@ out:
return err;
out_fail:
- dec_count(inode);
- dec_count(inode);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
out_dir:
- dec_count(dir);
+ inode_dec_link_count(dir);
goto out;
}
@@ -199,7 +187,7 @@ static int sysv_unlink(struct inode * dir, struct dentry * dentry)
goto out;
inode->i_ctime = dir->i_ctime;
- dec_count(inode);
+ inode_dec_link_count(inode);
out:
return err;
}
@@ -213,8 +201,8 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
err = sysv_unlink(dir, dentry);
if (!err) {
inode->i_size = 0;
- dec_count(inode);
- dec_count(dir);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(dir);
}
}
return err;
@@ -258,34 +246,34 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
new_de = sysv_find_entry(new_dentry, &new_page);
if (!new_de)
goto out_dir;
- inc_count(old_inode);
+ inode_inc_link_count(old_inode);
sysv_set_link(new_de, new_page, old_inode);
new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de)
new_inode->i_nlink--;
- dec_count(new_inode);
+ inode_dec_link_count(new_inode);
} else {
if (dir_de) {
err = -EMLINK;
if (new_dir->i_nlink >= SYSV_SB(new_dir->i_sb)->s_link_max)
goto out_dir;
}
- inc_count(old_inode);
+ inode_inc_link_count(old_inode);
err = sysv_add_link(new_dentry, old_inode);
if (err) {
- dec_count(old_inode);
+ inode_dec_link_count(old_inode);
goto out_dir;
}
if (dir_de)
- inc_count(new_dir);
+ inode_inc_link_count(new_dir);
}
sysv_delete_entry(old_de, old_page);
- dec_count(old_inode);
+ inode_dec_link_count(old_inode);
if (dir_de) {
sysv_set_link(dir_de, dir_page, new_dir);
- dec_count(old_dir);
+ inode_dec_link_count(old_dir);
}
return 0;
diff --git a/fs/sysv/super.c b/fs/sysv/super.c
index 59e76b51142..e92b991e6dd 100644
--- a/fs/sysv/super.c
+++ b/fs/sysv/super.c
@@ -377,10 +377,10 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_sb = sb;
sbi->s_block_base = 0;
sb->s_fs_info = sbi;
-
+
sb_set_blocksize(sb, BLOCK_SIZE);
- for (i = 0; i < sizeof(flavours)/sizeof(flavours[0]) && !size; i++) {
+ for (i = 0; i < ARRAY_SIZE(flavours) && !size; i++) {
brelse(bh);
bh = sb_bread(sb, flavours[i].block);
if (!bh)
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index 201049ac8a9..ea521f846d9 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -152,7 +152,7 @@ static void udf_bitmap_free_blocks(struct super_block * sb,
int bitmap_nr;
unsigned long overflow;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
if (bloc.logicalBlockNum < 0 ||
(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
{
@@ -211,7 +211,7 @@ error_return:
sb->s_dirt = 1;
if (UDF_SB_LVIDBH(sb))
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return;
}
@@ -226,7 +226,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block * sb,
int nr_groups, bitmap_nr;
struct buffer_head *bh;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
if (first_block < 0 || first_block >= UDF_SB_PARTLEN(sb, partition))
goto out;
@@ -275,7 +275,7 @@ out:
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
}
sb->s_dirt = 1;
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return alloc_count;
}
@@ -291,7 +291,7 @@ static int udf_bitmap_new_block(struct super_block * sb,
int newblock = 0;
*err = -ENOSPC;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
repeat:
if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
@@ -364,7 +364,7 @@ repeat:
}
if (i >= (nr_groups*2))
{
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return newblock;
}
if (bit < sb->s_blocksize << 3)
@@ -373,7 +373,7 @@ repeat:
bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
if (bit >= sb->s_blocksize << 3)
{
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return 0;
}
@@ -387,7 +387,7 @@ got_block:
*/
if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
{
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
*err = -EDQUOT;
return 0;
}
@@ -410,13 +410,13 @@ got_block:
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
}
sb->s_dirt = 1;
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
*err = 0;
return newblock;
error_return:
*err = -EIO;
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return 0;
}
@@ -433,7 +433,7 @@ static void udf_table_free_blocks(struct super_block * sb,
int8_t etype;
int i;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
if (bloc.logicalBlockNum < 0 ||
(bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum))
{
@@ -666,7 +666,7 @@ static void udf_table_free_blocks(struct super_block * sb,
error_return:
sb->s_dirt = 1;
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return;
}
@@ -692,7 +692,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
else
return 0;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
extoffset = sizeof(struct unallocSpaceEntry);
bloc = UDF_I_LOCATION(table);
@@ -736,7 +736,7 @@ static int udf_table_prealloc_blocks(struct super_block * sb,
mark_buffer_dirty(UDF_SB_LVIDBH(sb));
sb->s_dirt = 1;
}
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return alloc_count;
}
@@ -761,7 +761,7 @@ static int udf_table_new_block(struct super_block * sb,
else
return newblock;
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
goal = 0;
@@ -811,7 +811,7 @@ static int udf_table_new_block(struct super_block * sb,
if (spread == 0xFFFFFFFF)
{
udf_release_data(goal_bh);
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
return 0;
}
@@ -827,7 +827,7 @@ static int udf_table_new_block(struct super_block * sb,
if (inode && DQUOT_ALLOC_BLOCK(inode, 1))
{
udf_release_data(goal_bh);
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
*err = -EDQUOT;
return 0;
}
@@ -846,7 +846,7 @@ static int udf_table_new_block(struct super_block * sb,
}
sb->s_dirt = 1;
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
*err = 0;
return newblock;
}
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index c9b707b470c..3873c672cb4 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -42,7 +42,7 @@ void udf_free_inode(struct inode * inode)
clear_inode(inode);
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
if (sbi->s_lvidbh) {
if (S_ISDIR(inode->i_mode))
UDF_SB_LVIDIU(sb)->numDirs =
@@ -53,7 +53,7 @@ void udf_free_inode(struct inode * inode)
mark_buffer_dirty(sbi->s_lvidbh);
}
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
udf_free_blocks(sb, NULL, UDF_I_LOCATION(inode), 0, 1);
}
@@ -83,7 +83,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
return NULL;
}
- down(&sbi->s_alloc_sem);
+ mutex_lock(&sbi->s_alloc_mutex);
UDF_I_UNIQUE(inode) = 0;
UDF_I_LENEXTENTS(inode) = 0;
UDF_I_NEXT_ALLOC_BLOCK(inode) = 0;
@@ -148,7 +148,7 @@ struct inode * udf_new_inode (struct inode *dir, int mode, int * err)
UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
insert_inode_hash(inode);
mark_inode_dirty(inode);
- up(&sbi->s_alloc_sem);
+ mutex_unlock(&sbi->s_alloc_mutex);
if (DQUOT_ALLOC_INODE(inode))
{
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index d04cff2273b..81e0e8459af 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1341,13 +1341,11 @@ udf_update_inode(struct inode *inode, int do_sync)
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_UID_FORGET))
fe->uid = cpu_to_le32(-1);
- else if (inode->i_uid != UDF_SB(inode->i_sb)->s_uid)
- fe->uid = cpu_to_le32(inode->i_uid);
+ else fe->uid = cpu_to_le32(inode->i_uid);
if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_GID_FORGET))
fe->gid = cpu_to_le32(-1);
- else if (inode->i_gid != UDF_SB(inode->i_sb)->s_gid)
- fe->gid = cpu_to_le32(inode->i_gid);
+ else fe->gid = cpu_to_le32(inode->i_gid);
udfperms = ((inode->i_mode & S_IRWXO) ) |
((inode->i_mode & S_IRWXG) << 2) |
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 368d8f81fe5..e45789fe38e 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -140,7 +140,8 @@ static int init_inodecache(void)
{
udf_inode_cachep = kmem_cache_create("udf_inode_cache",
sizeof(struct udf_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (udf_inode_cachep == NULL)
return -ENOMEM;
@@ -660,8 +661,7 @@ udf_find_anchor(struct super_block *sb)
* lastblock
* however, if the disc isn't closed, it could be 512 */
- for (i=0; (!lastblock && i<sizeof(last)/sizeof(int)); i++)
- {
+ for (i = 0; !lastblock && i < ARRAY_SIZE(last); i++) {
if (last[i] < 0 || !(bh = sb_bread(sb, last[i])))
{
ident = location = 0;
@@ -672,7 +672,7 @@ udf_find_anchor(struct super_block *sb)
location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
udf_release_data(bh);
}
-
+
if (ident == TAG_IDENT_AVDP)
{
if (location == last[i] - UDF_SB_SESSION(sb))
@@ -753,8 +753,7 @@ udf_find_anchor(struct super_block *sb)
}
}
- for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++)
- {
+ for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
if (UDF_SB_ANCHOR(sb)[i])
{
if (!(bh = udf_read_tagged(sb,
@@ -1313,8 +1312,7 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
if (!sb)
return 1;
- for (i=0; i<sizeof(UDF_SB_ANCHOR(sb))/sizeof(int); i++)
- {
+ for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb,
UDF_SB_ANCHOR(sb)[i], UDF_SB_ANCHOR(sb)[i], &ident)))
{
@@ -1325,7 +1323,7 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
main_e = le32_to_cpu( anchor->mainVolDescSeqExt.extLength );
main_e = main_e >> sb->s_blocksize_bits;
main_e += main_s;
-
+
/* Locate the reserve sequence */
reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
@@ -1344,12 +1342,10 @@ udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
}
}
- if (i == sizeof(UDF_SB_ANCHOR(sb))/sizeof(int))
- {
+ if (i == ARRAY_SIZE(UDF_SB_ANCHOR(sb))) {
udf_debug("No Anchor block found\n");
return 1;
- }
- else
+ } else
udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
for (i=0; i<UDF_SB_NUMPARTS(sb); i++)
@@ -1515,7 +1511,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
sb->s_fs_info = sbi;
memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
- init_MUTEX(&sbi->s_alloc_sem);
+ mutex_init(&sbi->s_alloc_mutex);
if (!udf_parse_options((char *)options, &uopt))
goto error_out;
diff --git a/fs/ufs/file.c b/fs/ufs/file.c
index ed69d7fe1b5..62ad481810e 100644
--- a/fs/ufs/file.c
+++ b/fs/ufs/file.c
@@ -23,18 +23,8 @@
* ext2 fs regular file handling primitives
*/
-#include <asm/uaccess.h>
-#include <asm/system.h>
-
-#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/ufs_fs.h>
-#include <linux/fcntl.h>
-#include <linux/time.h>
-#include <linux/stat.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-#include <linux/smp_lock.h>
/*
* We have mostly NULL's here: the current defaults are ok for
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 2958cde7d3d..8d5f98a01c7 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -43,18 +43,6 @@
#define UFSD(x)
#endif
-static inline void ufs_inc_count(struct inode *inode)
-{
- inode->i_nlink++;
- mark_inode_dirty(inode);
-}
-
-static inline void ufs_dec_count(struct inode *inode)
-{
- inode->i_nlink--;
- mark_inode_dirty(inode);
-}
-
static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
{
int err = ufs_add_link(dentry, inode);
@@ -62,7 +50,7 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
d_instantiate(dentry, inode);
return 0;
}
- ufs_dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
return err;
}
@@ -173,7 +161,7 @@ out:
return err;
out_fail:
- ufs_dec_count(inode);
+ inode_dec_link_count(inode);
iput(inode);
goto out;
}
@@ -191,7 +179,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
}
inode->i_ctime = CURRENT_TIME_SEC;
- ufs_inc_count(inode);
+ inode_inc_link_count(inode);
atomic_inc(&inode->i_count);
error = ufs_add_nondir(dentry, inode);
@@ -208,7 +196,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
goto out;
lock_kernel();
- ufs_inc_count(dir);
+ inode_inc_link_count(dir);
inode = ufs_new_inode(dir, S_IFDIR|mode);
err = PTR_ERR(inode);
@@ -218,7 +206,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
inode->i_op = &ufs_dir_inode_operations;
inode->i_fop = &ufs_dir_operations;
- ufs_inc_count(inode);
+ inode_inc_link_count(inode);
err = ufs_make_empty(inode, dir);
if (err)
@@ -234,11 +222,11 @@ out:
return err;
out_fail:
- ufs_dec_count(inode);
- ufs_dec_count(inode);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(inode);
iput (inode);
out_dir:
- ufs_dec_count(dir);
+ inode_dec_link_count(dir);
unlock_kernel();
goto out;
}
@@ -260,7 +248,7 @@ static int ufs_unlink(struct inode * dir, struct dentry *dentry)
goto out;
inode->i_ctime = dir->i_ctime;
- ufs_dec_count(inode);
+ inode_dec_link_count(inode);
err = 0;
out:
unlock_kernel();
@@ -277,8 +265,8 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
err = ufs_unlink(dir, dentry);
if (!err) {
inode->i_size = 0;
- ufs_dec_count(inode);
- ufs_dec_count(dir);
+ inode_dec_link_count(inode);
+ inode_dec_link_count(dir);
}
}
unlock_kernel();
@@ -319,35 +307,35 @@ static int ufs_rename (struct inode * old_dir, struct dentry * old_dentry,
new_de = ufs_find_entry (new_dentry, &new_bh);
if (!new_de)
goto out_dir;
- ufs_inc_count(old_inode);
+ inode_inc_link_count(old_inode);
ufs_set_link(new_dir, new_de, new_bh, old_inode);
new_inode->i_ctime = CURRENT_TIME_SEC;
if (dir_de)
new_inode->i_nlink--;
- ufs_dec_count(new_inode);
+ inode_dec_link_count(new_inode);
} else {
if (dir_de) {
err = -EMLINK;
if (new_dir->i_nlink >= UFS_LINK_MAX)
goto out_dir;
}
- ufs_inc_count(old_inode);
+ inode_inc_link_count(old_inode);
err = ufs_add_link(new_dentry, old_inode);
if (err) {
- ufs_dec_count(old_inode);
+ inode_dec_link_count(old_inode);
goto out_dir;
}
if (dir_de)
- ufs_inc_count(new_dir);
+ inode_inc_link_count(new_dir);
}
ufs_delete_entry (old_dir, old_de, old_bh);
- ufs_dec_count(old_inode);
+ inode_dec_link_count(old_inode);
if (dir_de) {
ufs_set_link(old_inode, dir_de, dir_bh, new_dir);
- ufs_dec_count(old_dir);
+ inode_dec_link_count(old_dir);
}
unlock_kernel();
return 0;
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index e9055ef7f5a..db98a4c71e6 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -575,7 +575,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
if (!silent)
printk("You didn't specify the type of your ufs filesystem\n\n"
"mount -t ufs -o ufstype="
- "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|netxstep-cd|openstep ...\n\n"
+ "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...\n\n"
">>>WARNING<<< Wrong ufstype may corrupt your filesystem, "
"default is ufstype=old\n");
ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD);
@@ -1184,7 +1184,8 @@ static int init_inodecache(void)
{
ufs_inode_cachep = kmem_cache_create("ufs_inode_cache",
sizeof(struct ufs_inode_info),
- 0, SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (ufs_inode_cachep == NULL)
return -ENOMEM;
diff --git a/fs/xfs/Makefile-linux-2.6 b/fs/xfs/Makefile-linux-2.6
index 97bd4743b46..5d73eaa1971 100644
--- a/fs/xfs/Makefile-linux-2.6
+++ b/fs/xfs/Makefile-linux-2.6
@@ -1,33 +1,19 @@
#
-# Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (c) 2000-2005 Silicon Graphics, Inc.
+# All Rights Reserved.
#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of version 2 of the GNU General Public License as
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like. Any license provided herein, whether implied or
-# otherwise, applies only to this software file. Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-#
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-#
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA 94043, or:
-#
-# http://www.sgi.com
-#
-# For further information regarding this notice, see:
-#
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
EXTRA_CFLAGS += -Ifs/xfs -Ifs/xfs/linux-2.6 -funsigned-char
@@ -36,7 +22,7 @@ XFS_LINUX := linux-2.6
ifeq ($(CONFIG_XFS_DEBUG),y)
EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG
- EXTRA_CFLAGS += -DPAGEBUF_LOCK_TRACKING
+ EXTRA_CFLAGS += -DXFS_BUF_LOCK_TRACKING
endif
ifeq ($(CONFIG_XFS_TRACE),y)
EXTRA_CFLAGS += -DXFS_ALLOC_TRACE
@@ -50,7 +36,7 @@ ifeq ($(CONFIG_XFS_TRACE),y)
EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
EXTRA_CFLAGS += -DXFS_LOG_TRACE
EXTRA_CFLAGS += -DXFS_RW_TRACE
- EXTRA_CFLAGS += -DPAGEBUF_TRACE
+ EXTRA_CFLAGS += -DXFS_BUF_TRACE
EXTRA_CFLAGS += -DXFS_VNODE_TRACE
endif
diff --git a/fs/xfs/linux-2.6/kmem.h b/fs/xfs/linux-2.6/kmem.h
index c64a29cdfff..2cfd33d4d8a 100644
--- a/fs/xfs/linux-2.6/kmem.h
+++ b/fs/xfs/linux-2.6/kmem.h
@@ -23,17 +23,8 @@
#include <linux/mm.h>
/*
- * memory management routines
+ * Process flags handling
*/
-#define KM_SLEEP 0x0001u
-#define KM_NOSLEEP 0x0002u
-#define KM_NOFS 0x0004u
-#define KM_MAYFAIL 0x0008u
-
-#define kmem_zone kmem_cache
-#define kmem_zone_t struct kmem_cache
-
-typedef unsigned long xfs_pflags_t;
#define PFLAGS_TEST_NOIO() (current->flags & PF_NOIO)
#define PFLAGS_TEST_FSTRANS() (current->flags & PF_FSTRANS)
@@ -67,74 +58,102 @@ typedef unsigned long xfs_pflags_t;
*(NSTATEP) = *(OSTATEP); \
} while (0)
-static __inline gfp_t kmem_flags_convert(unsigned int __nocast flags)
+/*
+ * General memory allocation interfaces
+ */
+
+#define KM_SLEEP 0x0001u
+#define KM_NOSLEEP 0x0002u
+#define KM_NOFS 0x0004u
+#define KM_MAYFAIL 0x0008u
+
+/*
+ * We use a special process flag to avoid recursive callbacks into
+ * the filesystem during transactions. We will also issue our own
+ * warnings, so we explicitly skip any generic ones (silly of us).
+ */
+static inline gfp_t
+kmem_flags_convert(unsigned int __nocast flags)
{
- gfp_t lflags = __GFP_NOWARN; /* we'll report problems, if need be */
+ gfp_t lflags;
-#ifdef DEBUG
- if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) {
- printk(KERN_WARNING
- "XFS: memory allocation with wrong flags (%x)\n", flags);
- BUG();
- }
-#endif
+ BUG_ON(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL));
if (flags & KM_NOSLEEP) {
- lflags |= GFP_ATOMIC;
+ lflags = GFP_ATOMIC | __GFP_NOWARN;
} else {
- lflags |= GFP_KERNEL;
-
- /* avoid recusive callbacks to filesystem during transactions */
+ lflags = GFP_KERNEL | __GFP_NOWARN;
if (PFLAGS_TEST_FSTRANS() || (flags & KM_NOFS))
lflags &= ~__GFP_FS;
}
-
- return lflags;
+ return lflags;
}
-static __inline kmem_zone_t *
+extern void *kmem_alloc(size_t, unsigned int __nocast);
+extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
+extern void *kmem_zalloc(size_t, unsigned int __nocast);
+extern void kmem_free(void *, size_t);
+
+/*
+ * Zone interfaces
+ */
+
+#define KM_ZONE_HWALIGN SLAB_HWCACHE_ALIGN
+#define KM_ZONE_RECLAIM SLAB_RECLAIM_ACCOUNT
+#define KM_ZONE_SPREAD SLAB_MEM_SPREAD
+
+#define kmem_zone kmem_cache
+#define kmem_zone_t struct kmem_cache
+
+static inline kmem_zone_t *
kmem_zone_init(int size, char *zone_name)
{
return kmem_cache_create(zone_name, size, 0, 0, NULL, NULL);
}
-static __inline void
+static inline kmem_zone_t *
+kmem_zone_init_flags(int size, char *zone_name, unsigned long flags,
+ void (*construct)(void *, kmem_zone_t *, unsigned long))
+{
+ return kmem_cache_create(zone_name, size, 0, flags, construct, NULL);
+}
+
+static inline void
kmem_zone_free(kmem_zone_t *zone, void *ptr)
{
kmem_cache_free(zone, ptr);
}
-static __inline void
+static inline void
kmem_zone_destroy(kmem_zone_t *zone)
{
if (zone && kmem_cache_destroy(zone))
BUG();
}
-extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast);
+extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast);
-extern void *kmem_alloc(size_t, unsigned int __nocast);
-extern void *kmem_realloc(void *, size_t, size_t, unsigned int __nocast);
-extern void *kmem_zalloc(size_t, unsigned int __nocast);
-extern void kmem_free(void *, size_t);
+/*
+ * Low memory cache shrinkers
+ */
typedef struct shrinker *kmem_shaker_t;
typedef int (*kmem_shake_func_t)(int, gfp_t);
-static __inline kmem_shaker_t
+static inline kmem_shaker_t
kmem_shake_register(kmem_shake_func_t sfunc)
{
return set_shrinker(DEFAULT_SEEKS, sfunc);
}
-static __inline void
+static inline void
kmem_shake_deregister(kmem_shaker_t shrinker)
{
remove_shrinker(shrinker);
}
-static __inline int
+static inline int
kmem_shake_allow(gfp_t gfp_mask)
{
return (gfp_mask & __GFP_WAIT);
diff --git a/fs/xfs/linux-2.6/xfs_aops.c b/fs/xfs/linux-2.6/xfs_aops.c
index 74d8be87f98..97fc056130e 100644
--- a/fs/xfs/linux-2.6/xfs_aops.c
+++ b/fs/xfs/linux-2.6/xfs_aops.c
@@ -43,7 +43,29 @@
#include <linux/pagevec.h>
#include <linux/writeback.h>
-STATIC void xfs_count_page_state(struct page *, int *, int *, int *);
+STATIC void
+xfs_count_page_state(
+ struct page *page,
+ int *delalloc,
+ int *unmapped,
+ int *unwritten)
+{
+ struct buffer_head *bh, *head;
+
+ *delalloc = *unmapped = *unwritten = 0;
+
+ bh = head = page_buffers(page);
+ do {
+ if (buffer_uptodate(bh) && !buffer_mapped(bh))
+ (*unmapped) = 1;
+ else if (buffer_unwritten(bh) && !buffer_delay(bh))
+ clear_buffer_unwritten(bh);
+ else if (buffer_unwritten(bh))
+ (*unwritten) = 1;
+ else if (buffer_delay(bh))
+ (*delalloc) = 1;
+ } while ((bh = bh->b_this_page) != head);
+}
#if defined(XFS_RW_TRACE)
void
@@ -54,7 +76,7 @@ xfs_page_trace(
int mask)
{
xfs_inode_t *ip;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
loff_t isize = i_size_read(inode);
loff_t offset = page_offset(page);
int delalloc = -1, unmapped = -1, unwritten = -1;
@@ -81,7 +103,7 @@ xfs_page_trace(
(void *)((unsigned long)delalloc),
(void *)((unsigned long)unmapped),
(void *)((unsigned long)unwritten),
- (void *)NULL,
+ (void *)((unsigned long)current_pid()),
(void *)NULL);
}
#else
@@ -192,7 +214,7 @@ xfs_alloc_ioend(
ioend->io_uptodate = 1; /* cleared if any I/O fails */
ioend->io_list = NULL;
ioend->io_type = type;
- ioend->io_vnode = LINVFS_GET_VP(inode);
+ ioend->io_vnode = vn_from_inode(inode);
ioend->io_buffer_head = NULL;
ioend->io_buffer_tail = NULL;
atomic_inc(&ioend->io_vnode->v_iocount);
@@ -217,7 +239,7 @@ xfs_map_blocks(
xfs_iomap_t *mapp,
int flags)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error, nmaps = 1;
VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error);
@@ -462,28 +484,37 @@ xfs_add_to_ioend(
}
STATIC void
+xfs_map_buffer(
+ struct buffer_head *bh,
+ xfs_iomap_t *mp,
+ xfs_off_t offset,
+ uint block_bits)
+{
+ sector_t bn;
+
+ ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
+
+ bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) +
+ ((offset - mp->iomap_offset) >> block_bits);
+
+ ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME));
+
+ bh->b_blocknr = bn;
+ set_buffer_mapped(bh);
+}
+
+STATIC void
xfs_map_at_offset(
struct buffer_head *bh,
loff_t offset,
int block_bits,
xfs_iomap_t *iomapp)
{
- xfs_daddr_t bn;
- int sector_shift;
-
ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
- ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
-
- sector_shift = block_bits - BBSHIFT;
- bn = (iomapp->iomap_bn >> sector_shift) +
- ((offset - iomapp->iomap_offset) >> block_bits);
-
- ASSERT(bn || (iomapp->iomap_flags & IOMAP_REALTIME));
- ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
lock_buffer(bh);
- bh->b_blocknr = bn;
+ xfs_map_buffer(bh, iomapp, offset, block_bits);
bh->b_bdev = iomapp->iomap_target->bt_bdev;
set_buffer_mapped(bh);
clear_buffer_delay(bh);
@@ -616,7 +647,7 @@ xfs_is_delayed_page(
acceptable = (type == IOMAP_UNWRITTEN);
else if (buffer_delay(bh))
acceptable = (type == IOMAP_DELAY);
- else if (buffer_mapped(bh))
+ else if (buffer_dirty(bh) && buffer_mapped(bh))
acceptable = (type == 0);
else
break;
@@ -1040,8 +1071,159 @@ error:
return err;
}
+/*
+ * writepage: Called from one of two places:
+ *
+ * 1. we are flushing a delalloc buffer head.
+ *
+ * 2. we are writing out a dirty page. Typically the page dirty
+ * state is cleared before we get here. In this case is it
+ * conceivable we have no buffer heads.
+ *
+ * For delalloc space on the page we need to allocate space and
+ * flush it. For unmapped buffer heads on the page we should
+ * allocate space if the page is uptodate. For any other dirty
+ * buffer heads on the page we should flush them.
+ *
+ * If we detect that a transaction would be required to flush
+ * the page, we have to check the process flags first, if we
+ * are already in a transaction or disk I/O during allocations
+ * is off, we need to fail the writepage and redirty the page.
+ */
+
+STATIC int
+xfs_vm_writepage(
+ struct page *page,
+ struct writeback_control *wbc)
+{
+ int error;
+ int need_trans;
+ int delalloc, unmapped, unwritten;
+ struct inode *inode = page->mapping->host;
+
+ xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
+
+ /*
+ * We need a transaction if:
+ * 1. There are delalloc buffers on the page
+ * 2. The page is uptodate and we have unmapped buffers
+ * 3. The page is uptodate and we have no buffers
+ * 4. There are unwritten buffers on the page
+ */
+
+ if (!page_has_buffers(page)) {
+ unmapped = 1;
+ need_trans = 1;
+ } else {
+ xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
+ if (!PageUptodate(page))
+ unmapped = 0;
+ need_trans = delalloc + unmapped + unwritten;
+ }
+
+ /*
+ * If we need a transaction and the process flags say
+ * we are already in a transaction, or no IO is allowed
+ * then mark the page dirty again and leave the page
+ * as is.
+ */
+ if (PFLAGS_TEST_FSTRANS() && need_trans)
+ goto out_fail;
+
+ /*
+ * Delay hooking up buffer heads until we have
+ * made our go/no-go decision.
+ */
+ if (!page_has_buffers(page))
+ create_empty_buffers(page, 1 << inode->i_blkbits, 0);
+
+ /*
+ * Convert delayed allocate, unwritten or unmapped space
+ * to real space and flush out to disk.
+ */
+ error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
+ if (error == -EAGAIN)
+ goto out_fail;
+ if (unlikely(error < 0))
+ goto out_unlock;
+
+ return 0;
+
+out_fail:
+ redirty_page_for_writepage(wbc, page);
+ unlock_page(page);
+ return 0;
+out_unlock:
+ unlock_page(page);
+ return error;
+}
+
+/*
+ * Called to move a page into cleanable state - and from there
+ * to be released. Possibly the page is already clean. We always
+ * have buffer heads in this call.
+ *
+ * Returns 0 if the page is ok to release, 1 otherwise.
+ *
+ * Possible scenarios are:
+ *
+ * 1. We are being called to release a page which has been written
+ * to via regular I/O. buffer heads will be dirty and possibly
+ * delalloc. If no delalloc buffer heads in this case then we
+ * can just return zero.
+ *
+ * 2. We are called to release a page which has been written via
+ * mmap, all we need to do is ensure there is no delalloc
+ * state in the buffer heads, if not we can let the caller
+ * free them and we should come back later via writepage.
+ */
STATIC int
-__linvfs_get_block(
+xfs_vm_releasepage(
+ struct page *page,
+ gfp_t gfp_mask)
+{
+ struct inode *inode = page->mapping->host;
+ int dirty, delalloc, unmapped, unwritten;
+ struct writeback_control wbc = {
+ .sync_mode = WB_SYNC_ALL,
+ .nr_to_write = 1,
+ };
+
+ xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
+
+ if (!page_has_buffers(page))
+ return 0;
+
+ xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
+ if (!delalloc && !unwritten)
+ goto free_buffers;
+
+ if (!(gfp_mask & __GFP_FS))
+ return 0;
+
+ /* If we are already inside a transaction or the thread cannot
+ * do I/O, we cannot release this page.
+ */
+ if (PFLAGS_TEST_FSTRANS())
+ return 0;
+
+ /*
+ * Convert delalloc space to real space, do not flush the
+ * data out to disk, that will be done by the caller.
+ * Never need to allocate space here - we will always
+ * come back to writepage in that case.
+ */
+ dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
+ if (dirty == 0 && !unwritten)
+ goto free_buffers;
+ return 0;
+
+free_buffers:
+ return try_to_free_buffers(page);
+}
+
+STATIC int
+__xfs_get_block(
struct inode *inode,
sector_t iblock,
unsigned long blocks,
@@ -1050,7 +1232,7 @@ __linvfs_get_block(
int direct,
bmapi_flags_t flags)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
xfs_iomap_t iomap;
xfs_off_t offset;
ssize_t size;
@@ -1073,21 +1255,13 @@ __linvfs_get_block(
return 0;
if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
- xfs_daddr_t bn;
- xfs_off_t delta;
-
- /* For unwritten extents do not report a disk address on
+ /*
+ * For unwritten extents do not report a disk address on
* the read case (treat as if we're reading into a hole).
*/
if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
- delta = offset - iomap.iomap_offset;
- delta >>= inode->i_blkbits;
-
- bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
- bn += delta;
- BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
- bh_result->b_blocknr = bn;
- set_buffer_mapped(bh_result);
+ xfs_map_buffer(bh_result, &iomap, offset,
+ inode->i_blkbits);
}
if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
if (direct)
@@ -1130,30 +1304,30 @@ __linvfs_get_block(
}
int
-linvfs_get_block(
+xfs_get_block(
struct inode *inode,
sector_t iblock,
struct buffer_head *bh_result,
int create)
{
- return __linvfs_get_block(inode, iblock, 0, bh_result,
+ return __xfs_get_block(inode, iblock, 0, bh_result,
create, 0, BMAPI_WRITE);
}
STATIC int
-linvfs_get_blocks_direct(
+xfs_get_blocks_direct(
struct inode *inode,
sector_t iblock,
unsigned long max_blocks,
struct buffer_head *bh_result,
int create)
{
- return __linvfs_get_block(inode, iblock, max_blocks, bh_result,
+ return __xfs_get_block(inode, iblock, max_blocks, bh_result,
create, 1, BMAPI_WRITE|BMAPI_DIRECT);
}
STATIC void
-linvfs_end_io_direct(
+xfs_end_io_direct(
struct kiocb *iocb,
loff_t offset,
ssize_t size,
@@ -1191,7 +1365,7 @@ linvfs_end_io_direct(
}
STATIC ssize_t
-linvfs_direct_IO(
+xfs_vm_direct_IO(
int rw,
struct kiocb *iocb,
const struct iovec *iov,
@@ -1200,7 +1374,7 @@ linvfs_direct_IO(
{
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
xfs_iomap_t iomap;
int maps = 1;
int error;
@@ -1215,164 +1389,61 @@ linvfs_direct_IO(
ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
iomap.iomap_target->bt_bdev,
iov, offset, nr_segs,
- linvfs_get_blocks_direct,
- linvfs_end_io_direct);
+ xfs_get_blocks_direct,
+ xfs_end_io_direct);
if (unlikely(ret <= 0 && iocb->private))
xfs_destroy_ioend(iocb->private);
return ret;
}
+STATIC int
+xfs_vm_prepare_write(
+ struct file *file,
+ struct page *page,
+ unsigned int from,
+ unsigned int to)
+{
+ return block_prepare_write(page, from, to, xfs_get_block);
+}
STATIC sector_t
-linvfs_bmap(
+xfs_vm_bmap(
struct address_space *mapping,
sector_t block)
{
struct inode *inode = (struct inode *)mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error;
- vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address);
+ vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
VOP_RWLOCK(vp, VRWLOCK_READ);
VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
VOP_RWUNLOCK(vp, VRWLOCK_READ);
- return generic_block_bmap(mapping, block, linvfs_get_block);
+ return generic_block_bmap(mapping, block, xfs_get_block);
}
STATIC int
-linvfs_readpage(
+xfs_vm_readpage(
struct file *unused,
struct page *page)
{
- return mpage_readpage(page, linvfs_get_block);
+ return mpage_readpage(page, xfs_get_block);
}
STATIC int
-linvfs_readpages(
+xfs_vm_readpages(
struct file *unused,
struct address_space *mapping,
struct list_head *pages,
unsigned nr_pages)
{
- return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block);
-}
-
-STATIC void
-xfs_count_page_state(
- struct page *page,
- int *delalloc,
- int *unmapped,
- int *unwritten)
-{
- struct buffer_head *bh, *head;
-
- *delalloc = *unmapped = *unwritten = 0;
-
- bh = head = page_buffers(page);
- do {
- if (buffer_uptodate(bh) && !buffer_mapped(bh))
- (*unmapped) = 1;
- else if (buffer_unwritten(bh) && !buffer_delay(bh))
- clear_buffer_unwritten(bh);
- else if (buffer_unwritten(bh))
- (*unwritten) = 1;
- else if (buffer_delay(bh))
- (*delalloc) = 1;
- } while ((bh = bh->b_this_page) != head);
+ return mpage_readpages(mapping, pages, nr_pages, xfs_get_block);
}
-
-/*
- * writepage: Called from one of two places:
- *
- * 1. we are flushing a delalloc buffer head.
- *
- * 2. we are writing out a dirty page. Typically the page dirty
- * state is cleared before we get here. In this case is it
- * conceivable we have no buffer heads.
- *
- * For delalloc space on the page we need to allocate space and
- * flush it. For unmapped buffer heads on the page we should
- * allocate space if the page is uptodate. For any other dirty
- * buffer heads on the page we should flush them.
- *
- * If we detect that a transaction would be required to flush
- * the page, we have to check the process flags first, if we
- * are already in a transaction or disk I/O during allocations
- * is off, we need to fail the writepage and redirty the page.
- */
-
STATIC int
-linvfs_writepage(
- struct page *page,
- struct writeback_control *wbc)
-{
- int error;
- int need_trans;
- int delalloc, unmapped, unwritten;
- struct inode *inode = page->mapping->host;
-
- xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
-
- /*
- * We need a transaction if:
- * 1. There are delalloc buffers on the page
- * 2. The page is uptodate and we have unmapped buffers
- * 3. The page is uptodate and we have no buffers
- * 4. There are unwritten buffers on the page
- */
-
- if (!page_has_buffers(page)) {
- unmapped = 1;
- need_trans = 1;
- } else {
- xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
- if (!PageUptodate(page))
- unmapped = 0;
- need_trans = delalloc + unmapped + unwritten;
- }
-
- /*
- * If we need a transaction and the process flags say
- * we are already in a transaction, or no IO is allowed
- * then mark the page dirty again and leave the page
- * as is.
- */
- if (PFLAGS_TEST_FSTRANS() && need_trans)
- goto out_fail;
-
- /*
- * Delay hooking up buffer heads until we have
- * made our go/no-go decision.
- */
- if (!page_has_buffers(page))
- create_empty_buffers(page, 1 << inode->i_blkbits, 0);
-
- /*
- * Convert delayed allocate, unwritten or unmapped space
- * to real space and flush out to disk.
- */
- error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
- if (error == -EAGAIN)
- goto out_fail;
- if (unlikely(error < 0))
- goto out_unlock;
-
- return 0;
-
-out_fail:
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
- return 0;
-out_unlock:
- unlock_page(page);
- return error;
-}
-
-STATIC int
-linvfs_invalidate_page(
+xfs_vm_invalidatepage(
struct page *page,
unsigned long offset)
{
@@ -1381,87 +1452,16 @@ linvfs_invalidate_page(
return block_invalidatepage(page, offset);
}
-/*
- * Called to move a page into cleanable state - and from there
- * to be released. Possibly the page is already clean. We always
- * have buffer heads in this call.
- *
- * Returns 0 if the page is ok to release, 1 otherwise.
- *
- * Possible scenarios are:
- *
- * 1. We are being called to release a page which has been written
- * to via regular I/O. buffer heads will be dirty and possibly
- * delalloc. If no delalloc buffer heads in this case then we
- * can just return zero.
- *
- * 2. We are called to release a page which has been written via
- * mmap, all we need to do is ensure there is no delalloc
- * state in the buffer heads, if not we can let the caller
- * free them and we should come back later via writepage.
- */
-STATIC int
-linvfs_release_page(
- struct page *page,
- gfp_t gfp_mask)
-{
- struct inode *inode = page->mapping->host;
- int dirty, delalloc, unmapped, unwritten;
- struct writeback_control wbc = {
- .sync_mode = WB_SYNC_ALL,
- .nr_to_write = 1,
- };
-
- xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
-
- xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
- if (!delalloc && !unwritten)
- goto free_buffers;
-
- if (!(gfp_mask & __GFP_FS))
- return 0;
-
- /* If we are already inside a transaction or the thread cannot
- * do I/O, we cannot release this page.
- */
- if (PFLAGS_TEST_FSTRANS())
- return 0;
-
- /*
- * Convert delalloc space to real space, do not flush the
- * data out to disk, that will be done by the caller.
- * Never need to allocate space here - we will always
- * come back to writepage in that case.
- */
- dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
- if (dirty == 0 && !unwritten)
- goto free_buffers;
- return 0;
-
-free_buffers:
- return try_to_free_buffers(page);
-}
-
-STATIC int
-linvfs_prepare_write(
- struct file *file,
- struct page *page,
- unsigned int from,
- unsigned int to)
-{
- return block_prepare_write(page, from, to, linvfs_get_block);
-}
-
-struct address_space_operations linvfs_aops = {
- .readpage = linvfs_readpage,
- .readpages = linvfs_readpages,
- .writepage = linvfs_writepage,
+struct address_space_operations xfs_address_space_operations = {
+ .readpage = xfs_vm_readpage,
+ .readpages = xfs_vm_readpages,
+ .writepage = xfs_vm_writepage,
.sync_page = block_sync_page,
- .releasepage = linvfs_release_page,
- .invalidatepage = linvfs_invalidate_page,
- .prepare_write = linvfs_prepare_write,
+ .releasepage = xfs_vm_releasepage,
+ .invalidatepage = xfs_vm_invalidatepage,
+ .prepare_write = xfs_vm_prepare_write,
.commit_write = generic_commit_write,
- .bmap = linvfs_bmap,
- .direct_IO = linvfs_direct_IO,
+ .bmap = xfs_vm_bmap,
+ .direct_IO = xfs_vm_direct_IO,
.migratepage = buffer_migrate_page,
};
diff --git a/fs/xfs/linux-2.6/xfs_aops.h b/fs/xfs/linux-2.6/xfs_aops.h
index 55339dd5a30..795699f121d 100644
--- a/fs/xfs/linux-2.6/xfs_aops.h
+++ b/fs/xfs/linux-2.6/xfs_aops.h
@@ -40,7 +40,7 @@ typedef struct xfs_ioend {
struct work_struct io_work; /* xfsdatad work queue */
} xfs_ioend_t;
-extern struct address_space_operations linvfs_aops;
-extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
+extern struct address_space_operations xfs_address_space_operations;
+extern int xfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 8cdfa415165..9fb0312665c 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -1806,13 +1806,12 @@ xfs_flush_buftarg(
int __init
xfs_buf_init(void)
{
- int error = -ENOMEM;
-
#ifdef XFS_BUF_TRACE
xfs_buf_trace_buf = ktrace_alloc(XFS_BUF_TRACE_SIZE, KM_SLEEP);
#endif
- xfs_buf_zone = kmem_zone_init(sizeof(xfs_buf_t), "xfs_buf");
+ xfs_buf_zone = kmem_zone_init_flags(sizeof(xfs_buf_t), "xfs_buf",
+ KM_ZONE_HWALIGN, NULL);
if (!xfs_buf_zone)
goto out_free_trace_buf;
@@ -1840,7 +1839,7 @@ xfs_buf_init(void)
#ifdef XFS_BUF_TRACE
ktrace_free(xfs_buf_trace_buf);
#endif
- return error;
+ return -ENOMEM;
}
void
diff --git a/fs/xfs/linux-2.6/xfs_export.c b/fs/xfs/linux-2.6/xfs_export.c
index 80eb249f2fa..b768ea910bb 100644
--- a/fs/xfs/linux-2.6/xfs_export.c
+++ b/fs/xfs/linux-2.6/xfs_export.c
@@ -25,6 +25,8 @@
#include "xfs_mount.h"
#include "xfs_export.h"
+STATIC struct dentry dotdot = { .d_name.name = "..", .d_name.len = 2, };
+
/*
* XFS encodes and decodes the fileid portion of NFS filehandles
* itself instead of letting the generic NFS code do it. This
@@ -37,7 +39,7 @@
*/
STATIC struct dentry *
-linvfs_decode_fh(
+xfs_fs_decode_fh(
struct super_block *sb,
__u32 *fh,
int fh_len,
@@ -78,12 +80,12 @@ linvfs_decode_fh(
}
fh = (__u32 *)&ifid;
- return find_exported_dentry(sb, fh, parent, acceptable, context);
+ return sb->s_export_op->find_exported_dentry(sb, fh, parent, acceptable, context);
}
STATIC int
-linvfs_encode_fh(
+xfs_fs_encode_fh(
struct dentry *dentry,
__u32 *fh,
int *max_len,
@@ -95,7 +97,7 @@ linvfs_encode_fh(
int len;
int is64 = 0;
#if XFS_BIG_INUMS
- vfs_t *vfs = LINVFS_GET_VFS(inode->i_sb);
+ vfs_t *vfs = vfs_from_sb(inode->i_sb);
if (!(vfs->vfs_flag & VFS_32BITINODES)) {
/* filesystem may contain 64bit inode numbers */
@@ -130,21 +132,21 @@ linvfs_encode_fh(
}
STATIC struct dentry *
-linvfs_get_dentry(
+xfs_fs_get_dentry(
struct super_block *sb,
void *data)
{
vnode_t *vp;
struct inode *inode;
struct dentry *result;
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
int error;
VFS_VGET(vfsp, &vp, (fid_t *)data, error);
if (error || vp == NULL)
return ERR_PTR(-ESTALE) ;
- inode = LINVFS_GET_IP(vp);
+ inode = vn_to_inode(vp);
result = d_alloc_anon(inode);
if (!result) {
iput(inode);
@@ -154,25 +156,20 @@ linvfs_get_dentry(
}
STATIC struct dentry *
-linvfs_get_parent(
+xfs_fs_get_parent(
struct dentry *child)
{
int error;
vnode_t *vp, *cvp;
struct dentry *parent;
- struct dentry dotdot;
-
- dotdot.d_name.name = "..";
- dotdot.d_name.len = 2;
- dotdot.d_inode = NULL;
cvp = NULL;
- vp = LINVFS_GET_VP(child->d_inode);
+ vp = vn_from_inode(child->d_inode);
VOP_LOOKUP(vp, &dotdot, &cvp, 0, NULL, NULL, error);
if (unlikely(error))
return ERR_PTR(-error);
- parent = d_alloc_anon(LINVFS_GET_IP(cvp));
+ parent = d_alloc_anon(vn_to_inode(cvp));
if (unlikely(!parent)) {
VN_RELE(cvp);
return ERR_PTR(-ENOMEM);
@@ -180,9 +177,9 @@ linvfs_get_parent(
return parent;
}
-struct export_operations linvfs_export_ops = {
- .decode_fh = linvfs_decode_fh,
- .encode_fh = linvfs_encode_fh,
- .get_parent = linvfs_get_parent,
- .get_dentry = linvfs_get_dentry,
+struct export_operations xfs_export_operations = {
+ .decode_fh = xfs_fs_decode_fh,
+ .encode_fh = xfs_fs_encode_fh,
+ .get_parent = xfs_fs_get_parent,
+ .get_dentry = xfs_fs_get_dentry,
};
diff --git a/fs/xfs/linux-2.6/xfs_file.c b/fs/xfs/linux-2.6/xfs_file.c
index ced4404339c..185567a6a56 100644
--- a/fs/xfs/linux-2.6/xfs_file.c
+++ b/fs/xfs/linux-2.6/xfs_file.c
@@ -43,13 +43,13 @@
#include <linux/dcache.h>
#include <linux/smp_lock.h>
-static struct vm_operations_struct linvfs_file_vm_ops;
+static struct vm_operations_struct xfs_file_vm_ops;
#ifdef CONFIG_XFS_DMAPI
-static struct vm_operations_struct linvfs_dmapi_file_vm_ops;
+static struct vm_operations_struct xfs_dmapi_file_vm_ops;
#endif
STATIC inline ssize_t
-__linvfs_read(
+__xfs_file_read(
struct kiocb *iocb,
char __user *buf,
int ioflags,
@@ -58,7 +58,7 @@ __linvfs_read(
{
struct iovec iov = {buf, count};
struct file *file = iocb->ki_filp;
- vnode_t *vp = LINVFS_GET_VP(file->f_dentry->d_inode);
+ vnode_t *vp = vn_from_inode(file->f_dentry->d_inode);
ssize_t rval;
BUG_ON(iocb->ki_pos != pos);
@@ -71,28 +71,28 @@ __linvfs_read(
STATIC ssize_t
-linvfs_aio_read(
+xfs_file_aio_read(
struct kiocb *iocb,
char __user *buf,
size_t count,
loff_t pos)
{
- return __linvfs_read(iocb, buf, IO_ISAIO, count, pos);
+ return __xfs_file_read(iocb, buf, IO_ISAIO, count, pos);
}
STATIC ssize_t
-linvfs_aio_read_invis(
+xfs_file_aio_read_invis(
struct kiocb *iocb,
char __user *buf,
size_t count,
loff_t pos)
{
- return __linvfs_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
+ return __xfs_file_read(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
}
STATIC inline ssize_t
-__linvfs_write(
+__xfs_file_write(
struct kiocb *iocb,
const char __user *buf,
int ioflags,
@@ -102,7 +102,7 @@ __linvfs_write(
struct iovec iov = {(void __user *)buf, count};
struct file *file = iocb->ki_filp;
struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
ssize_t rval;
BUG_ON(iocb->ki_pos != pos);
@@ -115,28 +115,28 @@ __linvfs_write(
STATIC ssize_t
-linvfs_aio_write(
+xfs_file_aio_write(
struct kiocb *iocb,
const char __user *buf,
size_t count,
loff_t pos)
{
- return __linvfs_write(iocb, buf, IO_ISAIO, count, pos);
+ return __xfs_file_write(iocb, buf, IO_ISAIO, count, pos);
}
STATIC ssize_t
-linvfs_aio_write_invis(
+xfs_file_aio_write_invis(
struct kiocb *iocb,
const char __user *buf,
size_t count,
loff_t pos)
{
- return __linvfs_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
+ return __xfs_file_write(iocb, buf, IO_ISAIO|IO_INVIS, count, pos);
}
STATIC inline ssize_t
-__linvfs_readv(
+__xfs_file_readv(
struct file *file,
const struct iovec *iov,
int ioflags,
@@ -144,8 +144,8 @@ __linvfs_readv(
loff_t *ppos)
{
struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- struct kiocb kiocb;
+ vnode_t *vp = vn_from_inode(inode);
+ struct kiocb kiocb;
ssize_t rval;
init_sync_kiocb(&kiocb, file);
@@ -160,28 +160,28 @@ __linvfs_readv(
}
STATIC ssize_t
-linvfs_readv(
+xfs_file_readv(
struct file *file,
const struct iovec *iov,
unsigned long nr_segs,
loff_t *ppos)
{
- return __linvfs_readv(file, iov, 0, nr_segs, ppos);
+ return __xfs_file_readv(file, iov, 0, nr_segs, ppos);
}
STATIC ssize_t
-linvfs_readv_invis(
+xfs_file_readv_invis(
struct file *file,
const struct iovec *iov,
unsigned long nr_segs,
loff_t *ppos)
{
- return __linvfs_readv(file, iov, IO_INVIS, nr_segs, ppos);
+ return __xfs_file_readv(file, iov, IO_INVIS, nr_segs, ppos);
}
STATIC inline ssize_t
-__linvfs_writev(
+__xfs_file_writev(
struct file *file,
const struct iovec *iov,
int ioflags,
@@ -189,8 +189,8 @@ __linvfs_writev(
loff_t *ppos)
{
struct inode *inode = file->f_mapping->host;
- vnode_t *vp = LINVFS_GET_VP(inode);
- struct kiocb kiocb;
+ vnode_t *vp = vn_from_inode(inode);
+ struct kiocb kiocb;
ssize_t rval;
init_sync_kiocb(&kiocb, file);
@@ -206,34 +206,34 @@ __linvfs_writev(
STATIC ssize_t
-linvfs_writev(
+xfs_file_writev(
struct file *file,
const struct iovec *iov,
unsigned long nr_segs,
loff_t *ppos)
{
- return __linvfs_writev(file, iov, 0, nr_segs, ppos);
+ return __xfs_file_writev(file, iov, 0, nr_segs, ppos);
}
STATIC ssize_t
-linvfs_writev_invis(
+xfs_file_writev_invis(
struct file *file,
const struct iovec *iov,
unsigned long nr_segs,
loff_t *ppos)
{
- return __linvfs_writev(file, iov, IO_INVIS, nr_segs, ppos);
+ return __xfs_file_writev(file, iov, IO_INVIS, nr_segs, ppos);
}
STATIC ssize_t
-linvfs_sendfile(
+xfs_file_sendfile(
struct file *filp,
loff_t *ppos,
size_t count,
read_actor_t actor,
void *target)
{
- vnode_t *vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
+ vnode_t *vp = vn_from_inode(filp->f_dentry->d_inode);
ssize_t rval;
VOP_SENDFILE(vp, filp, ppos, 0, count, actor, target, NULL, rval);
@@ -242,11 +242,11 @@ linvfs_sendfile(
STATIC int
-linvfs_open(
+xfs_file_open(
struct inode *inode,
struct file *filp)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error;
if (!(filp->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
@@ -259,11 +259,11 @@ linvfs_open(
STATIC int
-linvfs_release(
+xfs_file_release(
struct inode *inode,
struct file *filp)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error = 0;
if (vp)
@@ -273,13 +273,13 @@ linvfs_release(
STATIC int
-linvfs_fsync(
+xfs_file_fsync(
struct file *filp,
struct dentry *dentry,
int datasync)
{
struct inode *inode = dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error;
int flags = FSYNC_WAIT;
@@ -292,7 +292,7 @@ linvfs_fsync(
}
/*
- * linvfs_readdir maps to VOP_READDIR().
+ * xfs_file_readdir maps to VOP_READDIR().
* We need to build a uio, cred, ...
*/
@@ -301,13 +301,13 @@ linvfs_fsync(
#ifdef CONFIG_XFS_DMAPI
STATIC struct page *
-linvfs_filemap_nopage(
+xfs_vm_nopage(
struct vm_area_struct *area,
unsigned long address,
int *type)
{
struct inode *inode = area->vm_file->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
int error;
@@ -324,7 +324,7 @@ linvfs_filemap_nopage(
STATIC int
-linvfs_readdir(
+xfs_file_readdir(
struct file *filp,
void *dirent,
filldir_t filldir)
@@ -340,7 +340,7 @@ linvfs_readdir(
xfs_off_t start_offset, curr_offset;
xfs_dirent_t *dbp = NULL;
- vp = LINVFS_GET_VP(filp->f_dentry->d_inode);
+ vp = vn_from_inode(filp->f_dentry->d_inode);
ASSERT(vp);
/* Try fairly hard to get memory */
@@ -404,39 +404,40 @@ done:
STATIC int
-linvfs_file_mmap(
+xfs_file_mmap(
struct file *filp,
struct vm_area_struct *vma)
{
struct inode *ip = filp->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(ip);
- vattr_t va = { .va_mask = XFS_AT_UPDATIME };
+ vnode_t *vp = vn_from_inode(ip);
+ vattr_t vattr;
int error;
- vma->vm_ops = &linvfs_file_vm_ops;
+ vma->vm_ops = &xfs_file_vm_ops;
#ifdef CONFIG_XFS_DMAPI
if (vp->v_vfsp->vfs_flag & VFS_DMI) {
- vma->vm_ops = &linvfs_dmapi_file_vm_ops;
+ vma->vm_ops = &xfs_dmapi_file_vm_ops;
}
#endif /* CONFIG_XFS_DMAPI */
- VOP_SETATTR(vp, &va, XFS_AT_UPDATIME, NULL, error);
- if (!error)
- vn_revalidate(vp); /* update Linux inode flags */
+ vattr.va_mask = XFS_AT_UPDATIME;
+ VOP_SETATTR(vp, &vattr, XFS_AT_UPDATIME, NULL, error);
+ if (likely(!error))
+ __vn_revalidate(vp, &vattr); /* update flags */
return 0;
}
STATIC long
-linvfs_ioctl(
+xfs_file_ioctl(
struct file *filp,
unsigned int cmd,
unsigned long arg)
{
int error;
- struct inode *inode = filp->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ struct inode *inode = filp->f_dentry->d_inode;
+ vnode_t *vp = vn_from_inode(inode);
VOP_IOCTL(vp, inode, filp, 0, cmd, (void __user *)arg, error);
VMODIFY(vp);
@@ -451,14 +452,14 @@ linvfs_ioctl(
}
STATIC long
-linvfs_ioctl_invis(
+xfs_file_ioctl_invis(
struct file *filp,
unsigned int cmd,
unsigned long arg)
{
int error;
- struct inode *inode = filp->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ struct inode *inode = filp->f_dentry->d_inode;
+ vnode_t *vp = vn_from_inode(inode);
ASSERT(vp);
VOP_IOCTL(vp, inode, filp, IO_INVIS, cmd, (void __user *)arg, error);
@@ -476,11 +477,11 @@ linvfs_ioctl_invis(
#ifdef CONFIG_XFS_DMAPI
#ifdef HAVE_VMOP_MPROTECT
STATIC int
-linvfs_mprotect(
+xfs_vm_mprotect(
struct vm_area_struct *vma,
unsigned int newflags)
{
- vnode_t *vp = LINVFS_GET_VP(vma->vm_file->f_dentry->d_inode);
+ vnode_t *vp = vn_from_inode(vma->vm_file->f_dentry->d_inode);
int error = 0;
if (vp->v_vfsp->vfs_flag & VFS_DMI) {
@@ -503,10 +504,10 @@ linvfs_mprotect(
* it back online.
*/
STATIC int
-linvfs_open_exec(
+xfs_file_open_exec(
struct inode *inode)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
xfs_mount_t *mp = XFS_VFSTOM(vp->v_vfsp);
int error = 0;
xfs_inode_t *ip;
@@ -527,69 +528,69 @@ open_exec_out:
}
#endif /* HAVE_FOP_OPEN_EXEC */
-struct file_operations linvfs_file_operations = {
+struct file_operations xfs_file_operations = {
.llseek = generic_file_llseek,
.read = do_sync_read,
.write = do_sync_write,
- .readv = linvfs_readv,
- .writev = linvfs_writev,
- .aio_read = linvfs_aio_read,
- .aio_write = linvfs_aio_write,
- .sendfile = linvfs_sendfile,
- .unlocked_ioctl = linvfs_ioctl,
+ .readv = xfs_file_readv,
+ .writev = xfs_file_writev,
+ .aio_read = xfs_file_aio_read,
+ .aio_write = xfs_file_aio_write,
+ .sendfile = xfs_file_sendfile,
+ .unlocked_ioctl = xfs_file_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = linvfs_compat_ioctl,
+ .compat_ioctl = xfs_file_compat_ioctl,
#endif
- .mmap = linvfs_file_mmap,
- .open = linvfs_open,
- .release = linvfs_release,
- .fsync = linvfs_fsync,
+ .mmap = xfs_file_mmap,
+ .open = xfs_file_open,
+ .release = xfs_file_release,
+ .fsync = xfs_file_fsync,
#ifdef HAVE_FOP_OPEN_EXEC
- .open_exec = linvfs_open_exec,
+ .open_exec = xfs_file_open_exec,
#endif
};
-struct file_operations linvfs_invis_file_operations = {
+struct file_operations xfs_invis_file_operations = {
.llseek = generic_file_llseek,
.read = do_sync_read,
.write = do_sync_write,
- .readv = linvfs_readv_invis,
- .writev = linvfs_writev_invis,
- .aio_read = linvfs_aio_read_invis,
- .aio_write = linvfs_aio_write_invis,
- .sendfile = linvfs_sendfile,
- .unlocked_ioctl = linvfs_ioctl_invis,
+ .readv = xfs_file_readv_invis,
+ .writev = xfs_file_writev_invis,
+ .aio_read = xfs_file_aio_read_invis,
+ .aio_write = xfs_file_aio_write_invis,
+ .sendfile = xfs_file_sendfile,
+ .unlocked_ioctl = xfs_file_ioctl_invis,
#ifdef CONFIG_COMPAT
- .compat_ioctl = linvfs_compat_invis_ioctl,
+ .compat_ioctl = xfs_file_compat_invis_ioctl,
#endif
- .mmap = linvfs_file_mmap,
- .open = linvfs_open,
- .release = linvfs_release,
- .fsync = linvfs_fsync,
+ .mmap = xfs_file_mmap,
+ .open = xfs_file_open,
+ .release = xfs_file_release,
+ .fsync = xfs_file_fsync,
};
-struct file_operations linvfs_dir_operations = {
+struct file_operations xfs_dir_file_operations = {
.read = generic_read_dir,
- .readdir = linvfs_readdir,
- .unlocked_ioctl = linvfs_ioctl,
+ .readdir = xfs_file_readdir,
+ .unlocked_ioctl = xfs_file_ioctl,
#ifdef CONFIG_COMPAT
- .compat_ioctl = linvfs_compat_ioctl,
+ .compat_ioctl = xfs_file_compat_ioctl,
#endif
- .fsync = linvfs_fsync,
+ .fsync = xfs_file_fsync,
};
-static struct vm_operations_struct linvfs_file_vm_ops = {
+static struct vm_operations_struct xfs_file_vm_ops = {
.nopage = filemap_nopage,
.populate = filemap_populate,
};
#ifdef CONFIG_XFS_DMAPI
-static struct vm_operations_struct linvfs_dmapi_file_vm_ops = {
- .nopage = linvfs_filemap_nopage,
+static struct vm_operations_struct xfs_dmapi_file_vm_ops = {
+ .nopage = xfs_vm_nopage,
.populate = filemap_populate,
#ifdef HAVE_VMOP_MPROTECT
- .mprotect = linvfs_mprotect,
+ .mprotect = xfs_vm_mprotect,
#endif
};
#endif /* CONFIG_XFS_DMAPI */
diff --git a/fs/xfs/linux-2.6/xfs_fs_subr.c b/fs/xfs/linux-2.6/xfs_fs_subr.c
index 4fa4b1a5187..575f2a790f3 100644
--- a/fs/xfs/linux-2.6/xfs_fs_subr.c
+++ b/fs/xfs/linux-2.6/xfs_fs_subr.c
@@ -57,7 +57,7 @@ fs_tosspages(
int fiopt)
{
vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
+ struct inode *ip = vn_to_inode(vp);
if (VN_CACHED(vp))
truncate_inode_pages(ip->i_mapping, first);
@@ -76,7 +76,7 @@ fs_flushinval_pages(
int fiopt)
{
vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
+ struct inode *ip = vn_to_inode(vp);
if (VN_CACHED(vp)) {
filemap_write_and_wait(ip->i_mapping);
@@ -98,7 +98,7 @@ fs_flush_pages(
int fiopt)
{
vnode_t *vp = BHV_TO_VNODE(bdp);
- struct inode *ip = LINVFS_GET_IP(vp);
+ struct inode *ip = vn_to_inode(vp);
if (VN_CACHED(vp)) {
filemap_fdatawrite(ip->i_mapping);
diff --git a/fs/xfs/linux-2.6/xfs_ioctl.c b/fs/xfs/linux-2.6/xfs_ioctl.c
index 4db47790415..84478491609 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl.c
@@ -138,7 +138,7 @@ xfs_find_handle(
}
/* we need the vnode */
- vp = LINVFS_GET_VP(inode);
+ vp = vn_from_inode(inode);
/* now we can grab the fsid */
memcpy(&handle.ha_fsid, vp->v_vfsp->vfs_altfsid, sizeof(xfs_fsid_t));
@@ -256,7 +256,7 @@ xfs_vget_fsop_handlereq(
}
vpp = XFS_ITOV(ip);
- inodep = LINVFS_GET_IP(vpp);
+ inodep = vn_to_inode(vpp);
xfs_iunlock(ip, XFS_ILOCK_SHARED);
*vp = vpp;
@@ -344,7 +344,7 @@ xfs_open_by_handle(
return -XFS_ERROR(-PTR_ERR(filp));
}
if (inode->i_mode & S_IFREG)
- filp->f_op = &linvfs_invis_file_operations;
+ filp->f_op = &xfs_invis_file_operations;
fd_install(new_fd, filp);
return new_fd;
@@ -715,7 +715,7 @@ xfs_ioctl(
xfs_inode_t *ip;
xfs_mount_t *mp;
- vp = LINVFS_GET_VP(inode);
+ vp = vn_from_inode(inode);
vn_trace_entry(vp, "xfs_ioctl", (inst_t *)__return_address);
@@ -1160,105 +1160,129 @@ xfs_ioc_xattr(
void __user *arg)
{
struct fsxattr fa;
- vattr_t va;
- int error;
+ struct vattr *vattr;
+ int error = 0;
int attr_flags;
unsigned int flags;
+ vattr = kmalloc(sizeof(*vattr), GFP_KERNEL);
+ if (unlikely(!vattr))
+ return -ENOMEM;
+
switch (cmd) {
case XFS_IOC_FSGETXATTR: {
- va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
- XFS_AT_NEXTENTS | XFS_AT_PROJID;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (error)
- return -error;
+ vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
+ XFS_AT_NEXTENTS | XFS_AT_PROJID;
+ VOP_GETATTR(vp, vattr, 0, NULL, error);
+ if (unlikely(error)) {
+ error = -error;
+ break;
+ }
- fa.fsx_xflags = va.va_xflags;
- fa.fsx_extsize = va.va_extsize;
- fa.fsx_nextents = va.va_nextents;
- fa.fsx_projid = va.va_projid;
+ fa.fsx_xflags = vattr->va_xflags;
+ fa.fsx_extsize = vattr->va_extsize;
+ fa.fsx_nextents = vattr->va_nextents;
+ fa.fsx_projid = vattr->va_projid;
- if (copy_to_user(arg, &fa, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
- return 0;
+ if (copy_to_user(arg, &fa, sizeof(fa))) {
+ error = -EFAULT;
+ break;
+ }
+ break;
}
case XFS_IOC_FSSETXATTR: {
- if (copy_from_user(&fa, arg, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
+ if (copy_from_user(&fa, arg, sizeof(fa))) {
+ error = -EFAULT;
+ break;
+ }
attr_flags = 0;
if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
attr_flags |= ATTR_NONBLOCK;
- va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
- va.va_xflags = fa.fsx_xflags;
- va.va_extsize = fa.fsx_extsize;
- va.va_projid = fa.fsx_projid;
+ vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | XFS_AT_PROJID;
+ vattr->va_xflags = fa.fsx_xflags;
+ vattr->va_extsize = fa.fsx_extsize;
+ vattr->va_projid = fa.fsx_projid;
- VOP_SETATTR(vp, &va, attr_flags, NULL, error);
- if (!error)
- vn_revalidate(vp); /* update Linux inode flags */
- return -error;
+ VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
+ if (likely(!error))
+ __vn_revalidate(vp, vattr); /* update flags */
+ error = -error;
+ break;
}
case XFS_IOC_FSGETXATTRA: {
- va.va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
- XFS_AT_ANEXTENTS | XFS_AT_PROJID;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (error)
- return -error;
+ vattr->va_mask = XFS_AT_XFLAGS | XFS_AT_EXTSIZE | \
+ XFS_AT_ANEXTENTS | XFS_AT_PROJID;
+ VOP_GETATTR(vp, vattr, 0, NULL, error);
+ if (unlikely(error)) {
+ error = -error;
+ break;
+ }
- fa.fsx_xflags = va.va_xflags;
- fa.fsx_extsize = va.va_extsize;
- fa.fsx_nextents = va.va_anextents;
- fa.fsx_projid = va.va_projid;
+ fa.fsx_xflags = vattr->va_xflags;
+ fa.fsx_extsize = vattr->va_extsize;
+ fa.fsx_nextents = vattr->va_anextents;
+ fa.fsx_projid = vattr->va_projid;
- if (copy_to_user(arg, &fa, sizeof(fa)))
- return -XFS_ERROR(EFAULT);
- return 0;
+ if (copy_to_user(arg, &fa, sizeof(fa))) {
+ error = -EFAULT;
+ break;
+ }
+ break;
}
case XFS_IOC_GETXFLAGS: {
flags = xfs_di2lxflags(ip->i_d.di_flags);
if (copy_to_user(arg, &flags, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
- return 0;
+ error = -EFAULT;
+ break;
}
case XFS_IOC_SETXFLAGS: {
- if (copy_from_user(&flags, arg, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
+ if (copy_from_user(&flags, arg, sizeof(flags))) {
+ error = -EFAULT;
+ break;
+ }
if (flags & ~(LINUX_XFLAG_IMMUTABLE | LINUX_XFLAG_APPEND | \
LINUX_XFLAG_NOATIME | LINUX_XFLAG_NODUMP | \
- LINUX_XFLAG_SYNC))
- return -XFS_ERROR(EOPNOTSUPP);
+ LINUX_XFLAG_SYNC)) {
+ error = -EOPNOTSUPP;
+ break;
+ }
attr_flags = 0;
if (filp->f_flags & (O_NDELAY|O_NONBLOCK))
attr_flags |= ATTR_NONBLOCK;
- va.va_mask = XFS_AT_XFLAGS;
- va.va_xflags = xfs_merge_ioc_xflags(flags,
- xfs_ip2xflags(ip));
+ vattr->va_mask = XFS_AT_XFLAGS;
+ vattr->va_xflags = xfs_merge_ioc_xflags(flags,
+ xfs_ip2xflags(ip));
- VOP_SETATTR(vp, &va, attr_flags, NULL, error);
- if (!error)
- vn_revalidate(vp); /* update Linux inode flags */
- return -error;
+ VOP_SETATTR(vp, vattr, attr_flags, NULL, error);
+ if (likely(!error))
+ __vn_revalidate(vp, vattr); /* update flags */
+ error = -error;
+ break;
}
case XFS_IOC_GETVERSION: {
- flags = LINVFS_GET_IP(vp)->i_generation;
+ flags = vn_to_inode(vp)->i_generation;
if (copy_to_user(arg, &flags, sizeof(flags)))
- return -XFS_ERROR(EFAULT);
- return 0;
+ error = -EFAULT;
+ break;
}
default:
- return -ENOTTY;
+ error = -ENOTTY;
+ break;
}
+
+ kfree(vattr);
+ return error;
}
STATIC int
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.c b/fs/xfs/linux-2.6/xfs_ioctl32.c
index a7c9ba1a9f7..b6321abd9a8 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.c
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.c
@@ -107,11 +107,11 @@ xfs_ioctl32_bulkstat(
#endif
STATIC long
-__linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
+xfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
{
int error;
struct inode *inode = f->f_dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_to_inode(inode);
switch (cmd) {
case XFS_IOC_DIOINFO:
@@ -196,19 +196,19 @@ __linvfs_compat_ioctl(int mode, struct file *f, unsigned cmd, unsigned long arg)
}
long
-linvfs_compat_ioctl(
+xfs_file_compat_ioctl(
struct file *f,
unsigned cmd,
unsigned long arg)
{
- return __linvfs_compat_ioctl(0, f, cmd, arg);
+ return xfs_compat_ioctl(0, f, cmd, arg);
}
long
-linvfs_compat_invis_ioctl(
+xfs_file_compat_invis_ioctl(
struct file *f,
unsigned cmd,
unsigned long arg)
{
- return __linvfs_compat_ioctl(IO_INVIS, f, cmd, arg);
+ return xfs_compat_ioctl(IO_INVIS, f, cmd, arg);
}
diff --git a/fs/xfs/linux-2.6/xfs_ioctl32.h b/fs/xfs/linux-2.6/xfs_ioctl32.h
index 011c273bec5..02de6e62ee3 100644
--- a/fs/xfs/linux-2.6/xfs_ioctl32.h
+++ b/fs/xfs/linux-2.6/xfs_ioctl32.h
@@ -18,7 +18,7 @@
#ifndef __XFS_IOCTL32_H__
#define __XFS_IOCTL32_H__
-extern long linvfs_compat_ioctl(struct file *, unsigned, unsigned long);
-extern long linvfs_compat_invis_ioctl(struct file *f, unsigned, unsigned long);
+extern long xfs_file_compat_ioctl(struct file *, unsigned, unsigned long);
+extern long xfs_file_compat_invis_ioctl(struct file *, unsigned, unsigned long);
#endif /* __XFS_IOCTL32_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index d7f6f2d8ac8..af487437bd7 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -106,7 +106,7 @@ xfs_ichgtime(
xfs_inode_t *ip,
int flags)
{
- struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+ struct inode *inode = vn_to_inode(XFS_ITOV(ip));
timespec_t tv;
nanotime(&tv);
@@ -198,22 +198,22 @@ xfs_ichgtime_fast(
* Pull the link count and size up from the xfs inode to the linux inode
*/
STATIC void
-validate_fields(
- struct inode *ip)
+xfs_validate_fields(
+ struct inode *ip,
+ struct vattr *vattr)
{
- vnode_t *vp = LINVFS_GET_VP(ip);
- vattr_t va;
+ vnode_t *vp = vn_from_inode(ip);
int error;
- va.va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
- VOP_GETATTR(vp, &va, ATTR_LAZY, NULL, error);
- if (likely(!error)) {
- ip->i_nlink = va.va_nlink;
- ip->i_blocks = va.va_nblocks;
+ vattr->va_mask = XFS_AT_NLINK|XFS_AT_SIZE|XFS_AT_NBLOCKS;
+ VOP_GETATTR(vp, vattr, ATTR_LAZY, NULL, error);
+ if (likely(!error)) {
+ ip->i_nlink = vattr->va_nlink;
+ ip->i_blocks = vattr->va_nblocks;
- /* we're under i_mutex so i_size can't change under us */
- if (i_size_read(ip) != va.va_size)
- i_size_write(ip, va.va_size);
+ /* we're under i_sem so i_size can't change under us */
+ if (i_size_read(ip) != vattr->va_size)
+ i_size_write(ip, vattr->va_size);
}
}
@@ -224,11 +224,11 @@ validate_fields(
* inode, of course, such that log replay can't cause these to be lost).
*/
STATIC int
-linvfs_init_security(
+xfs_init_security(
struct vnode *vp,
struct inode *dir)
{
- struct inode *ip = LINVFS_GET_IP(vp);
+ struct inode *ip = vn_to_inode(vp);
size_t length;
void *value;
char *name;
@@ -257,46 +257,46 @@ linvfs_init_security(
* XXX(hch): nfsd is broken, better fix it instead.
*/
STATIC inline int
-has_fs_struct(struct task_struct *task)
+xfs_has_fs_struct(struct task_struct *task)
{
return (task->fs != init_task.fs);
}
STATIC inline void
-cleanup_inode(
+xfs_cleanup_inode(
vnode_t *dvp,
vnode_t *vp,
- struct dentry *dentry,
+ struct dentry *dentry,
int mode)
{
struct dentry teardown = {};
- int err2;
+ int error;
/* Oh, the horror.
- * If we can't add the ACL or we fail in
- * linvfs_init_security we must back out.
+ * If we can't add the ACL or we fail in
+ * xfs_init_security we must back out.
* ENOSPC can hit here, among other things.
*/
- teardown.d_inode = LINVFS_GET_IP(vp);
+ teardown.d_inode = vn_to_inode(vp);
teardown.d_name = dentry->d_name;
if (S_ISDIR(mode))
- VOP_RMDIR(dvp, &teardown, NULL, err2);
+ VOP_RMDIR(dvp, &teardown, NULL, error);
else
- VOP_REMOVE(dvp, &teardown, NULL, err2);
+ VOP_REMOVE(dvp, &teardown, NULL, error);
VN_RELE(vp);
}
STATIC int
-linvfs_mknod(
+xfs_vn_mknod(
struct inode *dir,
struct dentry *dentry,
int mode,
dev_t rdev)
{
struct inode *ip;
- vattr_t va;
- vnode_t *vp = NULL, *dvp = LINVFS_GET_VP(dir);
+ vattr_t vattr = { 0 };
+ vnode_t *vp = NULL, *dvp = vn_from_inode(dir);
xfs_acl_t *default_acl = NULL;
attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS;
int error;
@@ -305,99 +305,98 @@ linvfs_mknod(
* Irix uses Missed'em'V split, but doesn't want to see
* the upper 5 bits of (14bit) major.
*/
- if (!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)
+ if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff))
return -EINVAL;
- if (test_default_acl && test_default_acl(dvp)) {
- if (!_ACL_ALLOC(default_acl))
+ if (unlikely(test_default_acl && test_default_acl(dvp))) {
+ if (!_ACL_ALLOC(default_acl)) {
return -ENOMEM;
+ }
if (!_ACL_GET_DEFAULT(dvp, default_acl)) {
_ACL_FREE(default_acl);
default_acl = NULL;
}
}
- if (IS_POSIXACL(dir) && !default_acl && has_fs_struct(current))
+ if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current))
mode &= ~current->fs->umask;
- memset(&va, 0, sizeof(va));
- va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
- va.va_mode = mode;
+ vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+ vattr.va_mode = mode;
switch (mode & S_IFMT) {
case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK:
- va.va_rdev = sysv_encode_dev(rdev);
- va.va_mask |= XFS_AT_RDEV;
+ vattr.va_rdev = sysv_encode_dev(rdev);
+ vattr.va_mask |= XFS_AT_RDEV;
/*FALLTHROUGH*/
case S_IFREG:
- VOP_CREATE(dvp, dentry, &va, &vp, NULL, error);
+ VOP_CREATE(dvp, dentry, &vattr, &vp, NULL, error);
break;
case S_IFDIR:
- VOP_MKDIR(dvp, dentry, &va, &vp, NULL, error);
+ VOP_MKDIR(dvp, dentry, &vattr, &vp, NULL, error);
break;
default:
error = EINVAL;
break;
}
- if (!error)
- {
- error = linvfs_init_security(vp, dir);
+ if (unlikely(!error)) {
+ error = xfs_init_security(vp, dir);
if (error)
- cleanup_inode(dvp, vp, dentry, mode);
+ xfs_cleanup_inode(dvp, vp, dentry, mode);
}
- if (default_acl) {
+ if (unlikely(default_acl)) {
if (!error) {
- error = _ACL_INHERIT(vp, &va, default_acl);
- if (!error)
+ error = _ACL_INHERIT(vp, &vattr, default_acl);
+ if (!error)
VMODIFY(vp);
else
- cleanup_inode(dvp, vp, dentry, mode);
+ xfs_cleanup_inode(dvp, vp, dentry, mode);
}
_ACL_FREE(default_acl);
}
- if (!error) {
+ if (likely(!error)) {
ASSERT(vp);
- ip = LINVFS_GET_IP(vp);
+ ip = vn_to_inode(vp);
if (S_ISCHR(mode) || S_ISBLK(mode))
ip->i_rdev = rdev;
else if (S_ISDIR(mode))
- validate_fields(ip);
+ xfs_validate_fields(ip, &vattr);
d_instantiate(dentry, ip);
- validate_fields(dir);
+ xfs_validate_fields(dir, &vattr);
}
return -error;
}
STATIC int
-linvfs_create(
+xfs_vn_create(
struct inode *dir,
struct dentry *dentry,
int mode,
struct nameidata *nd)
{
- return linvfs_mknod(dir, dentry, mode, 0);
+ return xfs_vn_mknod(dir, dentry, mode, 0);
}
STATIC int
-linvfs_mkdir(
+xfs_vn_mkdir(
struct inode *dir,
struct dentry *dentry,
int mode)
{
- return linvfs_mknod(dir, dentry, mode|S_IFDIR, 0);
+ return xfs_vn_mknod(dir, dentry, mode|S_IFDIR, 0);
}
STATIC struct dentry *
-linvfs_lookup(
+xfs_vn_lookup(
struct inode *dir,
struct dentry *dentry,
struct nameidata *nd)
{
- struct vnode *vp = LINVFS_GET_VP(dir), *cvp;
+ struct vnode *vp = vn_from_inode(dir), *cvp;
int error;
if (dentry->d_name.len >= MAXNAMELEN)
@@ -411,11 +410,11 @@ linvfs_lookup(
return NULL;
}
- return d_splice_alias(LINVFS_GET_IP(cvp), dentry);
+ return d_splice_alias(vn_to_inode(cvp), dentry);
}
STATIC int
-linvfs_link(
+xfs_vn_link(
struct dentry *old_dentry,
struct inode *dir,
struct dentry *dentry)
@@ -423,99 +422,102 @@ linvfs_link(
struct inode *ip; /* inode of guy being linked to */
vnode_t *tdvp; /* target directory for new name/link */
vnode_t *vp; /* vp of name being linked */
+ vattr_t vattr;
int error;
ip = old_dentry->d_inode; /* inode being linked to */
if (S_ISDIR(ip->i_mode))
return -EPERM;
- tdvp = LINVFS_GET_VP(dir);
- vp = LINVFS_GET_VP(ip);
+ tdvp = vn_from_inode(dir);
+ vp = vn_from_inode(ip);
VOP_LINK(tdvp, vp, dentry, NULL, error);
- if (!error) {
+ if (likely(!error)) {
VMODIFY(tdvp);
VN_HOLD(vp);
- validate_fields(ip);
+ xfs_validate_fields(ip, &vattr);
d_instantiate(dentry, ip);
}
return -error;
}
STATIC int
-linvfs_unlink(
+xfs_vn_unlink(
struct inode *dir,
struct dentry *dentry)
{
struct inode *inode;
vnode_t *dvp; /* directory containing name to remove */
+ vattr_t vattr;
int error;
inode = dentry->d_inode;
- dvp = LINVFS_GET_VP(dir);
+ dvp = vn_from_inode(dir);
VOP_REMOVE(dvp, dentry, NULL, error);
- if (!error) {
- validate_fields(dir); /* For size only */
- validate_fields(inode);
+ if (likely(!error)) {
+ xfs_validate_fields(dir, &vattr); /* size needs update */
+ xfs_validate_fields(inode, &vattr);
}
-
return -error;
}
STATIC int
-linvfs_symlink(
+xfs_vn_symlink(
struct inode *dir,
struct dentry *dentry,
const char *symname)
{
struct inode *ip;
- vattr_t va;
+ vattr_t vattr = { 0 };
vnode_t *dvp; /* directory containing name of symlink */
vnode_t *cvp; /* used to lookup symlink to put in dentry */
int error;
- dvp = LINVFS_GET_VP(dir);
+ dvp = vn_from_inode(dir);
cvp = NULL;
- memset(&va, 0, sizeof(va));
- va.va_mode = S_IFLNK |
+ vattr.va_mode = S_IFLNK |
(irix_symlink_mode ? 0777 & ~current->fs->umask : S_IRWXUGO);
- va.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
+ vattr.va_mask = XFS_AT_TYPE|XFS_AT_MODE;
error = 0;
- VOP_SYMLINK(dvp, dentry, &va, (char *)symname, &cvp, NULL, error);
+ VOP_SYMLINK(dvp, dentry, &vattr, (char *)symname, &cvp, NULL, error);
if (likely(!error && cvp)) {
- error = linvfs_init_security(cvp, dir);
+ error = xfs_init_security(cvp, dir);
if (likely(!error)) {
- ip = LINVFS_GET_IP(cvp);
+ ip = vn_to_inode(cvp);
d_instantiate(dentry, ip);
- validate_fields(dir);
- validate_fields(ip);
+ xfs_validate_fields(dir, &vattr);
+ xfs_validate_fields(ip, &vattr);
+ } else {
+ xfs_cleanup_inode(dvp, cvp, dentry, 0);
}
}
return -error;
}
STATIC int
-linvfs_rmdir(
+xfs_vn_rmdir(
struct inode *dir,
struct dentry *dentry)
{
struct inode *inode = dentry->d_inode;
- vnode_t *dvp = LINVFS_GET_VP(dir);
+ vnode_t *dvp = vn_from_inode(dir);
+ vattr_t vattr;
int error;
VOP_RMDIR(dvp, dentry, NULL, error);
- if (!error) {
- validate_fields(inode);
- validate_fields(dir);
+ if (likely(!error)) {
+ xfs_validate_fields(inode, &vattr);
+ xfs_validate_fields(dir, &vattr);
}
return -error;
}
STATIC int
-linvfs_rename(
+xfs_vn_rename(
struct inode *odir,
struct dentry *odentry,
struct inode *ndir,
@@ -524,22 +526,21 @@ linvfs_rename(
struct inode *new_inode = ndentry->d_inode;
vnode_t *fvp; /* from directory */
vnode_t *tvp; /* target directory */
+ vattr_t vattr;
int error;
- fvp = LINVFS_GET_VP(odir);
- tvp = LINVFS_GET_VP(ndir);
+ fvp = vn_from_inode(odir);
+ tvp = vn_from_inode(ndir);
VOP_RENAME(fvp, odentry, tvp, ndentry, NULL, error);
- if (error)
- return -error;
-
- if (new_inode)
- validate_fields(new_inode);
-
- validate_fields(odir);
- if (ndir != odir)
- validate_fields(ndir);
- return 0;
+ if (likely(!error)) {
+ if (new_inode)
+ xfs_validate_fields(new_inode, &vattr);
+ xfs_validate_fields(odir, &vattr);
+ if (ndir != odir)
+ xfs_validate_fields(ndir, &vattr);
+ }
+ return -error;
}
/*
@@ -548,7 +549,7 @@ linvfs_rename(
* uio is kmalloced for this reason...
*/
STATIC void *
-linvfs_follow_link(
+xfs_vn_follow_link(
struct dentry *dentry,
struct nameidata *nd)
{
@@ -574,7 +575,7 @@ linvfs_follow_link(
return NULL;
}
- vp = LINVFS_GET_VP(dentry->d_inode);
+ vp = vn_from_inode(dentry->d_inode);
iov.iov_base = link;
iov.iov_len = MAXPATHLEN;
@@ -599,7 +600,7 @@ linvfs_follow_link(
}
STATIC void
-linvfs_put_link(
+xfs_vn_put_link(
struct dentry *dentry,
struct nameidata *nd,
void *p)
@@ -612,12 +613,12 @@ linvfs_put_link(
#ifdef CONFIG_XFS_POSIX_ACL
STATIC int
-linvfs_permission(
+xfs_vn_permission(
struct inode *inode,
int mode,
struct nameidata *nd)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error;
mode <<= 6; /* convert from linux to vnode access bits */
@@ -625,17 +626,17 @@ linvfs_permission(
return -error;
}
#else
-#define linvfs_permission NULL
+#define xfs_vn_permission NULL
#endif
STATIC int
-linvfs_getattr(
+xfs_vn_getattr(
struct vfsmount *mnt,
struct dentry *dentry,
struct kstat *stat)
{
struct inode *inode = dentry->d_inode;
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error = 0;
if (unlikely(vp->v_flag & VMODIFIED))
@@ -646,18 +647,17 @@ linvfs_getattr(
}
STATIC int
-linvfs_setattr(
+xfs_vn_setattr(
struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = dentry->d_inode;
unsigned int ia_valid = attr->ia_valid;
- vnode_t *vp = LINVFS_GET_VP(inode);
- vattr_t vattr;
+ vnode_t *vp = vn_from_inode(inode);
+ vattr_t vattr = { 0 };
int flags = 0;
int error;
- memset(&vattr, 0, sizeof(vattr_t));
if (ia_valid & ATTR_UID) {
vattr.va_mask |= XFS_AT_UID;
vattr.va_uid = attr->ia_uid;
@@ -699,28 +699,27 @@ linvfs_setattr(
#endif
VOP_SETATTR(vp, &vattr, flags, NULL, error);
- if (error)
- return -error;
- vn_revalidate(vp);
- return error;
+ if (likely(!error))
+ __vn_revalidate(vp, &vattr);
+ return -error;
}
STATIC void
-linvfs_truncate(
+xfs_vn_truncate(
struct inode *inode)
{
- block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
+ block_truncate_page(inode->i_mapping, inode->i_size, xfs_get_block);
}
STATIC int
-linvfs_setxattr(
+xfs_vn_setxattr(
struct dentry *dentry,
const char *name,
const void *data,
size_t size,
int flags)
{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
+ vnode_t *vp = vn_from_inode(dentry->d_inode);
char *attr = (char *)name;
attrnames_t *namesp;
int xflags = 0;
@@ -744,13 +743,13 @@ linvfs_setxattr(
}
STATIC ssize_t
-linvfs_getxattr(
+xfs_vn_getxattr(
struct dentry *dentry,
const char *name,
void *data,
size_t size)
{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
+ vnode_t *vp = vn_from_inode(dentry->d_inode);
char *attr = (char *)name;
attrnames_t *namesp;
int xflags = 0;
@@ -774,12 +773,12 @@ linvfs_getxattr(
}
STATIC ssize_t
-linvfs_listxattr(
+xfs_vn_listxattr(
struct dentry *dentry,
char *data,
size_t size)
{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
+ vnode_t *vp = vn_from_inode(dentry->d_inode);
int error, xflags = ATTR_KERNAMELS;
ssize_t result;
@@ -794,11 +793,11 @@ linvfs_listxattr(
}
STATIC int
-linvfs_removexattr(
+xfs_vn_removexattr(
struct dentry *dentry,
const char *name)
{
- vnode_t *vp = LINVFS_GET_VP(dentry->d_inode);
+ vnode_t *vp = vn_from_inode(dentry->d_inode);
char *attr = (char *)name;
attrnames_t *namesp;
int xflags = 0;
@@ -816,45 +815,45 @@ linvfs_removexattr(
}
-struct inode_operations linvfs_file_inode_operations = {
- .permission = linvfs_permission,
- .truncate = linvfs_truncate,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
+struct inode_operations xfs_inode_operations = {
+ .permission = xfs_vn_permission,
+ .truncate = xfs_vn_truncate,
+ .getattr = xfs_vn_getattr,
+ .setattr = xfs_vn_setattr,
+ .setxattr = xfs_vn_setxattr,
+ .getxattr = xfs_vn_getxattr,
+ .listxattr = xfs_vn_listxattr,
+ .removexattr = xfs_vn_removexattr,
};
-struct inode_operations linvfs_dir_inode_operations = {
- .create = linvfs_create,
- .lookup = linvfs_lookup,
- .link = linvfs_link,
- .unlink = linvfs_unlink,
- .symlink = linvfs_symlink,
- .mkdir = linvfs_mkdir,
- .rmdir = linvfs_rmdir,
- .mknod = linvfs_mknod,
- .rename = linvfs_rename,
- .permission = linvfs_permission,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
+struct inode_operations xfs_dir_inode_operations = {
+ .create = xfs_vn_create,
+ .lookup = xfs_vn_lookup,
+ .link = xfs_vn_link,
+ .unlink = xfs_vn_unlink,
+ .symlink = xfs_vn_symlink,
+ .mkdir = xfs_vn_mkdir,
+ .rmdir = xfs_vn_rmdir,
+ .mknod = xfs_vn_mknod,
+ .rename = xfs_vn_rename,
+ .permission = xfs_vn_permission,
+ .getattr = xfs_vn_getattr,
+ .setattr = xfs_vn_setattr,
+ .setxattr = xfs_vn_setxattr,
+ .getxattr = xfs_vn_getxattr,
+ .listxattr = xfs_vn_listxattr,
+ .removexattr = xfs_vn_removexattr,
};
-struct inode_operations linvfs_symlink_inode_operations = {
+struct inode_operations xfs_symlink_inode_operations = {
.readlink = generic_readlink,
- .follow_link = linvfs_follow_link,
- .put_link = linvfs_put_link,
- .permission = linvfs_permission,
- .getattr = linvfs_getattr,
- .setattr = linvfs_setattr,
- .setxattr = linvfs_setxattr,
- .getxattr = linvfs_getxattr,
- .listxattr = linvfs_listxattr,
- .removexattr = linvfs_removexattr,
+ .follow_link = xfs_vn_follow_link,
+ .put_link = xfs_vn_put_link,
+ .permission = xfs_vn_permission,
+ .getattr = xfs_vn_getattr,
+ .setattr = xfs_vn_setattr,
+ .setxattr = xfs_vn_setxattr,
+ .getxattr = xfs_vn_getxattr,
+ .listxattr = xfs_vn_listxattr,
+ .removexattr = xfs_vn_removexattr,
};
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index 6899a6b4a50..a8417d7af5f 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -18,13 +18,13 @@
#ifndef __XFS_IOPS_H__
#define __XFS_IOPS_H__
-extern struct inode_operations linvfs_file_inode_operations;
-extern struct inode_operations linvfs_dir_inode_operations;
-extern struct inode_operations linvfs_symlink_inode_operations;
+extern struct inode_operations xfs_inode_operations;
+extern struct inode_operations xfs_dir_inode_operations;
+extern struct inode_operations xfs_symlink_inode_operations;
-extern struct file_operations linvfs_file_operations;
-extern struct file_operations linvfs_invis_file_operations;
-extern struct file_operations linvfs_dir_operations;
+extern struct file_operations xfs_file_operations;
+extern struct file_operations xfs_dir_file_operations;
+extern struct file_operations xfs_invis_file_operations;
extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
int, unsigned int, void __user *);
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 67389b74552..1fe09f2d651 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -73,6 +73,9 @@
#include <linux/list.h>
#include <linux/proc_fs.h>
#include <linux/sort.h>
+#include <linux/cpu.h>
+#include <linux/notifier.h>
+#include <linux/delay.h>
#include <asm/page.h>
#include <asm/div64.h>
@@ -100,6 +103,11 @@
*/
#undef HAVE_REFCACHE /* reference cache not needed for NFS in 2.6 */
#define HAVE_SENDFILE /* sendfile(2) exists in 2.6, but not in 2.4 */
+#ifdef CONFIG_SMP
+#define HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
+#else
+#undef HAVE_PERCPU_SB /* per cpu superblock counters are a 2.6 feature */
+#endif
/*
* State flag for unwritten extent buffers.
@@ -226,7 +234,7 @@ BUFFER_FNS(PrivateStart, unwritten);
#define xfs_sort(a,n,s,fn) sort(a,n,s,fn,NULL)
#define xfs_stack_trace() dump_stack()
#define xfs_itruncate_data(ip, off) \
- (-vmtruncate(LINVFS_GET_IP(XFS_ITOV(ip)), (off)))
+ (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off)))
#define xfs_statvfs_fsid(statp, mp) \
({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \
__kernel_fsid_t *fsid = &(statp)->f_fsid; \
diff --git a/fs/xfs/linux-2.6/xfs_lrw.c b/fs/xfs/linux-2.6/xfs_lrw.c
index e0ab45fbfeb..0169360475c 100644
--- a/fs/xfs/linux-2.6/xfs_lrw.c
+++ b/fs/xfs/linux-2.6/xfs_lrw.c
@@ -83,7 +83,7 @@ xfs_rw_enter_trace(
(void *)((unsigned long)ioflags),
(void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
(void *)((unsigned long)(io->io_new_size & 0xffffffff)),
- (void *)NULL,
+ (void *)((unsigned long)current_pid()),
(void *)NULL,
(void *)NULL,
(void *)NULL,
@@ -113,7 +113,7 @@ xfs_inval_cached_trace(
(void *)((unsigned long)(first & 0xffffffff)),
(void *)((unsigned long)((last >> 32) & 0xffffffff)),
(void *)((unsigned long)(last & 0xffffffff)),
- (void *)NULL,
+ (void *)((unsigned long)current_pid()),
(void *)NULL,
(void *)NULL,
(void *)NULL,
@@ -249,9 +249,8 @@ xfs_read(
if (n < size)
size = n;
- if (XFS_FORCED_SHUTDOWN(mp)) {
+ if (XFS_FORCED_SHUTDOWN(mp))
return -EIO;
- }
if (unlikely(ioflags & IO_ISDIRECT))
mutex_lock(&inode->i_mutex);
@@ -267,10 +266,14 @@ xfs_read(
dmflags, &locktype);
if (ret) {
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
- goto unlock_isem;
+ goto unlock_mutex;
}
}
+ if (unlikely((ioflags & IO_ISDIRECT) && VN_CACHED(vp)))
+ VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(*offset)),
+ -1, FI_REMAPF_LOCKED);
+
xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
(void *)iovp, segs, *offset, ioflags);
ret = __generic_file_aio_read(iocb, iovp, segs, offset);
@@ -281,7 +284,7 @@ xfs_read(
xfs_iunlock(ip, XFS_IOLOCK_SHARED);
-unlock_isem:
+unlock_mutex:
if (unlikely(ioflags & IO_ISDIRECT))
mutex_unlock(&inode->i_mutex);
return ret;
@@ -432,7 +435,7 @@ xfs_zero_eof(
xfs_fsize_t isize, /* current inode size */
xfs_fsize_t end_size) /* terminal inode size */
{
- struct inode *ip = LINVFS_GET_IP(vp);
+ struct inode *ip = vn_to_inode(vp);
xfs_fileoff_t start_zero_fsb;
xfs_fileoff_t end_zero_fsb;
xfs_fileoff_t zero_count_fsb;
@@ -573,7 +576,7 @@ xfs_write(
vrwlock_t locktype;
size_t ocount = 0, count;
loff_t pos;
- int need_isem = 1, need_flush = 0;
+ int need_i_mutex = 1, need_flush = 0;
XFS_STATS_INC(xs_write_calls);
@@ -622,14 +625,14 @@ xfs_write(
return XFS_ERROR(-EINVAL);
if (!VN_CACHED(vp) && pos < i_size_read(inode))
- need_isem = 0;
+ need_i_mutex = 0;
if (VN_CACHED(vp))
need_flush = 1;
}
relock:
- if (need_isem) {
+ if (need_i_mutex) {
iolock = XFS_IOLOCK_EXCL;
locktype = VRWLOCK_WRITE;
@@ -651,7 +654,7 @@ start:
S_ISBLK(inode->i_mode));
if (error) {
xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
- goto out_unlock_isem;
+ goto out_unlock_mutex;
}
new_size = pos + count;
@@ -663,7 +666,7 @@ start:
loff_t savedsize = pos;
int dmflags = FILP_DELAY_FLAG(file);
- if (need_isem)
+ if (need_i_mutex)
dmflags |= DM_FLAGS_IMUX;
xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -672,7 +675,7 @@ start:
dmflags, &locktype);
if (error) {
xfs_iunlock(xip, iolock);
- goto out_unlock_isem;
+ goto out_unlock_mutex;
}
xfs_ilock(xip, XFS_ILOCK_EXCL);
eventsent = 1;
@@ -710,7 +713,7 @@ start:
isize, pos + count);
if (error) {
xfs_iunlock(xip, XFS_ILOCK_EXCL|iolock);
- goto out_unlock_isem;
+ goto out_unlock_mutex;
}
}
xfs_iunlock(xip, XFS_ILOCK_EXCL);
@@ -731,7 +734,7 @@ start:
error = -remove_suid(file->f_dentry);
if (unlikely(error)) {
xfs_iunlock(xip, iolock);
- goto out_unlock_isem;
+ goto out_unlock_mutex;
}
}
@@ -747,14 +750,14 @@ retry:
-1, FI_REMAPF_LOCKED);
}
- if (need_isem) {
+ if (need_i_mutex) {
/* demote the lock now the cached pages are gone */
XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
mutex_unlock(&inode->i_mutex);
iolock = XFS_IOLOCK_SHARED;
locktype = VRWLOCK_WRITE_DIRECT;
- need_isem = 0;
+ need_i_mutex = 0;
}
xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
@@ -772,7 +775,7 @@ retry:
pos += ret;
count -= ret;
- need_isem = 1;
+ need_i_mutex = 1;
ioflags &= ~IO_ISDIRECT;
xfs_iunlock(xip, iolock);
goto relock;
@@ -794,14 +797,14 @@ retry:
!(ioflags & IO_INVIS)) {
xfs_rwunlock(bdp, locktype);
- if (need_isem)
+ if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
error = XFS_SEND_NAMESP(xip->i_mount, DM_EVENT_NOSPACE, vp,
DM_RIGHT_NULL, vp, DM_RIGHT_NULL, NULL, NULL,
0, 0, 0); /* Delay flag intentionally unused */
if (error)
goto out_nounlocks;
- if (need_isem)
+ if (need_i_mutex)
mutex_lock(&inode->i_mutex);
xfs_rwlock(bdp, locktype);
pos = xip->i_d.di_size;
@@ -905,9 +908,9 @@ retry:
if (error)
goto out_unlock_internal;
}
-
+
xfs_rwunlock(bdp, locktype);
- if (need_isem)
+ if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
error = sync_page_range(inode, mapping, pos, ret);
@@ -918,8 +921,8 @@ retry:
out_unlock_internal:
xfs_rwunlock(bdp, locktype);
- out_unlock_isem:
- if (need_isem)
+ out_unlock_mutex:
+ if (need_i_mutex)
mutex_unlock(&inode->i_mutex);
out_nounlocks:
return -error;
diff --git a/fs/xfs/linux-2.6/xfs_stats.c b/fs/xfs/linux-2.6/xfs_stats.c
index 8955720a2c6..1f0589a05ec 100644
--- a/fs/xfs/linux-2.6/xfs_stats.c
+++ b/fs/xfs/linux-2.6/xfs_stats.c
@@ -56,24 +56,21 @@ xfs_read_xfsstats(
};
/* Loop over all stats groups */
- for (i=j=len = 0; i < sizeof(xstats)/sizeof(struct xstats_entry); i++) {
+ for (i=j=len = 0; i < ARRAY_SIZE(xstats); i++) {
len += sprintf(buffer + len, xstats[i].desc);
/* inner loop does each group */
while (j < xstats[i].endpoint) {
val = 0;
/* sum over all cpus */
- for (c = 0; c < NR_CPUS; c++) {
- if (!cpu_possible(c)) continue;
+ for_each_cpu(c)
val += *(((__u32*)&per_cpu(xfsstats, c) + j));
- }
len += sprintf(buffer + len, " %u", val);
j++;
}
buffer[len++] = '\n';
}
/* extra precision counters */
- for (i = 0; i < NR_CPUS; i++) {
- if (!cpu_possible(i)) continue;
+ for_each_cpu(i) {
xs_xstrat_bytes += per_cpu(xfsstats, i).xs_xstrat_bytes;
xs_write_bytes += per_cpu(xfsstats, i).xs_write_bytes;
xs_read_bytes += per_cpu(xfsstats, i).xs_read_bytes;
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index f22e426d9e4..8355faf8ffd 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -59,8 +59,8 @@
#include <linux/writeback.h>
#include <linux/kthread.h>
-STATIC struct quotactl_ops linvfs_qops;
-STATIC struct super_operations linvfs_sops;
+STATIC struct quotactl_ops xfs_quotactl_operations;
+STATIC struct super_operations xfs_super_operations;
STATIC kmem_zone_t *xfs_vnode_zone;
STATIC kmem_zone_t *xfs_ioend_zone;
mempool_t *xfs_ioend_pool;
@@ -76,8 +76,6 @@ xfs_args_allocate(
strncpy(args->fsname, sb->s_id, MAXNAMELEN);
/* Copy the already-parsed mount(2) flags we're interested in */
- if (sb->s_flags & MS_NOATIME)
- args->flags |= XFSMNT_NOATIME;
if (sb->s_flags & MS_DIRSYNC)
args->flags |= XFSMNT_DIRSYNC;
if (sb->s_flags & MS_SYNCHRONOUS)
@@ -129,21 +127,21 @@ xfs_set_inodeops(
{
switch (inode->i_mode & S_IFMT) {
case S_IFREG:
- inode->i_op = &linvfs_file_inode_operations;
- inode->i_fop = &linvfs_file_operations;
- inode->i_mapping->a_ops = &linvfs_aops;
+ inode->i_op = &xfs_inode_operations;
+ inode->i_fop = &xfs_file_operations;
+ inode->i_mapping->a_ops = &xfs_address_space_operations;
break;
case S_IFDIR:
- inode->i_op = &linvfs_dir_inode_operations;
- inode->i_fop = &linvfs_dir_operations;
+ inode->i_op = &xfs_dir_inode_operations;
+ inode->i_fop = &xfs_dir_file_operations;
break;
case S_IFLNK:
- inode->i_op = &linvfs_symlink_inode_operations;
+ inode->i_op = &xfs_symlink_inode_operations;
if (inode->i_blocks)
- inode->i_mapping->a_ops = &linvfs_aops;
+ inode->i_mapping->a_ops = &xfs_address_space_operations;
break;
default:
- inode->i_op = &linvfs_file_inode_operations;
+ inode->i_op = &xfs_inode_operations;
init_special_inode(inode, inode->i_mode, inode->i_rdev);
break;
}
@@ -155,7 +153,7 @@ xfs_revalidate_inode(
vnode_t *vp,
xfs_inode_t *ip)
{
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
inode->i_mode = ip->i_d.di_mode;
inode->i_nlink = ip->i_d.di_nlink;
@@ -212,7 +210,7 @@ xfs_initialize_vnode(
int unlock)
{
xfs_inode_t *ip = XFS_BHVTOI(inode_bhv);
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
if (!inode_bhv->bd_vobj) {
vp->v_vfsp = bhvtovfs(bdp);
@@ -230,7 +228,7 @@ xfs_initialize_vnode(
if (ip->i_d.di_mode != 0 && unlock && (inode->i_state & I_NEW)) {
xfs_revalidate_inode(XFS_BHVTOM(bdp), vp, ip);
xfs_set_inodeops(inode);
-
+
ip->i_flags &= ~XFS_INEW;
barrier();
@@ -334,43 +332,42 @@ xfs_blkdev_issue_flush(
}
STATIC struct inode *
-linvfs_alloc_inode(
+xfs_fs_alloc_inode(
struct super_block *sb)
{
vnode_t *vp;
- vp = kmem_cache_alloc(xfs_vnode_zone, kmem_flags_convert(KM_SLEEP));
- if (!vp)
+ vp = kmem_zone_alloc(xfs_vnode_zone, KM_SLEEP);
+ if (unlikely(!vp))
return NULL;
- return LINVFS_GET_IP(vp);
+ return vn_to_inode(vp);
}
STATIC void
-linvfs_destroy_inode(
+xfs_fs_destroy_inode(
struct inode *inode)
{
- kmem_zone_free(xfs_vnode_zone, LINVFS_GET_VP(inode));
+ kmem_zone_free(xfs_vnode_zone, vn_from_inode(inode));
}
STATIC void
-linvfs_inode_init_once(
- void *data,
- kmem_cache_t *cachep,
+xfs_fs_inode_init_once(
+ void *vnode,
+ kmem_zone_t *zonep,
unsigned long flags)
{
- vnode_t *vp = (vnode_t *)data;
-
if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
- SLAB_CTOR_CONSTRUCTOR)
- inode_init_once(LINVFS_GET_IP(vp));
+ SLAB_CTOR_CONSTRUCTOR)
+ inode_init_once(vn_to_inode((vnode_t *)vnode));
}
STATIC int
-linvfs_init_zones(void)
+xfs_init_zones(void)
{
- xfs_vnode_zone = kmem_cache_create("xfs_vnode",
- sizeof(vnode_t), 0, SLAB_RECLAIM_ACCOUNT,
- linvfs_inode_init_once, NULL);
+ xfs_vnode_zone = kmem_zone_init_flags(sizeof(vnode_t), "xfs_vnode_t",
+ KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
+ KM_ZONE_SPREAD,
+ xfs_fs_inode_init_once);
if (!xfs_vnode_zone)
goto out;
@@ -379,14 +376,12 @@ linvfs_init_zones(void)
goto out_destroy_vnode_zone;
xfs_ioend_pool = mempool_create(4 * MAX_BUF_PER_PAGE,
- mempool_alloc_slab, mempool_free_slab,
- xfs_ioend_zone);
+ mempool_alloc_slab, mempool_free_slab,
+ xfs_ioend_zone);
if (!xfs_ioend_pool)
goto out_free_ioend_zone;
-
return 0;
-
out_free_ioend_zone:
kmem_zone_destroy(xfs_ioend_zone);
out_destroy_vnode_zone:
@@ -396,7 +391,7 @@ linvfs_init_zones(void)
}
STATIC void
-linvfs_destroy_zones(void)
+xfs_destroy_zones(void)
{
mempool_destroy(xfs_ioend_pool);
kmem_zone_destroy(xfs_vnode_zone);
@@ -407,14 +402,14 @@ linvfs_destroy_zones(void)
* Attempt to flush the inode, this will actually fail
* if the inode is pinned, but we dirty the inode again
* at the point when it is unpinned after a log write,
- * since this is when the inode itself becomes flushable.
+ * since this is when the inode itself becomes flushable.
*/
STATIC int
-linvfs_write_inode(
+xfs_fs_write_inode(
struct inode *inode,
int sync)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error = 0, flags = FLUSH_INODE;
if (vp) {
@@ -434,13 +429,13 @@ linvfs_write_inode(
}
STATIC void
-linvfs_clear_inode(
+xfs_fs_clear_inode(
struct inode *inode)
{
- vnode_t *vp = LINVFS_GET_VP(inode);
+ vnode_t *vp = vn_from_inode(inode);
int error, cache;
- vn_trace_entry(vp, "clear_inode", (inst_t *)__return_address);
+ vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
XFS_STATS_INC(vn_rele);
XFS_STATS_INC(vn_remove);
@@ -516,7 +511,7 @@ void
xfs_flush_inode(
xfs_inode_t *ip)
{
- struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+ struct inode *inode = vn_to_inode(XFS_ITOV(ip));
struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
igrab(inode);
@@ -541,7 +536,7 @@ void
xfs_flush_device(
xfs_inode_t *ip)
{
- struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+ struct inode *inode = vn_to_inode(XFS_ITOV(ip));
struct vfs *vfs = XFS_MTOVFS(ip->i_mount);
igrab(inode);
@@ -550,7 +545,7 @@ xfs_flush_device(
xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
}
-#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR)
+#define SYNCD_FLAGS (SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR|SYNC_REFCACHE)
STATIC void
vfs_sync_worker(
vfs_t *vfsp,
@@ -613,7 +608,7 @@ xfssyncd(
}
STATIC int
-linvfs_start_syncd(
+xfs_fs_start_syncd(
vfs_t *vfsp)
{
vfsp->vfs_sync_work.w_syncer = vfs_sync_worker;
@@ -625,20 +620,20 @@ linvfs_start_syncd(
}
STATIC void
-linvfs_stop_syncd(
+xfs_fs_stop_syncd(
vfs_t *vfsp)
{
kthread_stop(vfsp->vfs_sync_task);
}
STATIC void
-linvfs_put_super(
+xfs_fs_put_super(
struct super_block *sb)
{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
int error;
- linvfs_stop_syncd(vfsp);
+ xfs_fs_stop_syncd(vfsp);
VFS_SYNC(vfsp, SYNC_ATTR|SYNC_DELWRI, NULL, error);
if (!error)
VFS_UNMOUNT(vfsp, 0, NULL, error);
@@ -652,10 +647,10 @@ linvfs_put_super(
}
STATIC void
-linvfs_write_super(
+xfs_fs_write_super(
struct super_block *sb)
{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
int error;
if (sb->s_flags & MS_RDONLY) {
@@ -668,11 +663,11 @@ linvfs_write_super(
}
STATIC int
-linvfs_sync_super(
+xfs_fs_sync_super(
struct super_block *sb,
int wait)
{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
int error;
int flags = SYNC_FSDATA;
@@ -707,11 +702,11 @@ linvfs_sync_super(
}
STATIC int
-linvfs_statfs(
+xfs_fs_statfs(
struct super_block *sb,
struct kstatfs *statp)
{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
int error;
VFS_STATVFS(vfsp, statp, NULL, error);
@@ -719,12 +714,12 @@ linvfs_statfs(
}
STATIC int
-linvfs_remount(
+xfs_fs_remount(
struct super_block *sb,
int *flags,
char *options)
{
- vfs_t *vfsp = LINVFS_GET_VFS(sb);
+ vfs_t *vfsp = vfs_from_sb(sb);
struct xfs_mount_args *args = xfs_args_allocate(sb);
int error;
@@ -736,18 +731,18 @@ linvfs_remount(
}
STATIC void
-linvfs_freeze_fs(
+xfs_fs_lockfs(
struct super_block *sb)
{
- VFS_FREEZE(LINVFS_GET_VFS(sb));
+ VFS_FREEZE(vfs_from_sb(sb));
}
STATIC int
-linvfs_show_options(
+xfs_fs_show_options(
struct seq_file *m,
struct vfsmount *mnt)
{
- struct vfs *vfsp = LINVFS_GET_VFS(mnt->mnt_sb);
+ struct vfs *vfsp = vfs_from_sb(mnt->mnt_sb);
int error;
VFS_SHOWARGS(vfsp, m, error);
@@ -755,11 +750,11 @@ linvfs_show_options(
}
STATIC int
-linvfs_quotasync(
+xfs_fs_quotasync(
struct super_block *sb,
int type)
{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
+ struct vfs *vfsp = vfs_from_sb(sb);
int error;
VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
@@ -767,11 +762,11 @@ linvfs_quotasync(
}
STATIC int
-linvfs_getxstate(
+xfs_fs_getxstate(
struct super_block *sb,
struct fs_quota_stat *fqs)
{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
+ struct vfs *vfsp = vfs_from_sb(sb);
int error;
VFS_QUOTACTL(vfsp, Q_XGETQSTAT, 0, (caddr_t)fqs, error);
@@ -779,12 +774,12 @@ linvfs_getxstate(
}
STATIC int
-linvfs_setxstate(
+xfs_fs_setxstate(
struct super_block *sb,
unsigned int flags,
int op)
{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
+ struct vfs *vfsp = vfs_from_sb(sb);
int error;
VFS_QUOTACTL(vfsp, op, 0, (caddr_t)&flags, error);
@@ -792,13 +787,13 @@ linvfs_setxstate(
}
STATIC int
-linvfs_getxquota(
+xfs_fs_getxquota(
struct super_block *sb,
int type,
qid_t id,
struct fs_disk_quota *fdq)
{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
+ struct vfs *vfsp = vfs_from_sb(sb);
int error, getmode;
getmode = (type == USRQUOTA) ? Q_XGETQUOTA :
@@ -808,13 +803,13 @@ linvfs_getxquota(
}
STATIC int
-linvfs_setxquota(
+xfs_fs_setxquota(
struct super_block *sb,
int type,
qid_t id,
struct fs_disk_quota *fdq)
{
- struct vfs *vfsp = LINVFS_GET_VFS(sb);
+ struct vfs *vfsp = vfs_from_sb(sb);
int error, setmode;
setmode = (type == USRQUOTA) ? Q_XSETQLIM :
@@ -824,21 +819,17 @@ linvfs_setxquota(
}
STATIC int
-linvfs_fill_super(
+xfs_fs_fill_super(
struct super_block *sb,
void *data,
int silent)
{
vnode_t *rootvp;
- struct vfs *vfsp = vfs_allocate();
+ struct vfs *vfsp = vfs_allocate(sb);
struct xfs_mount_args *args = xfs_args_allocate(sb);
struct kstatfs statvfs;
int error, error2;
- vfsp->vfs_super = sb;
- LINVFS_SET_VFS(sb, vfsp);
- if (sb->s_flags & MS_RDONLY)
- vfsp->vfs_flag |= VFS_RDONLY;
bhv_insert_all_vfsops(vfsp);
VFS_PARSEARGS(vfsp, (char *)data, args, 0, error);
@@ -849,10 +840,10 @@ linvfs_fill_super(
sb_min_blocksize(sb, BBSIZE);
#ifdef CONFIG_XFS_EXPORT
- sb->s_export_op = &linvfs_export_ops;
+ sb->s_export_op = &xfs_export_operations;
#endif
- sb->s_qcop = &linvfs_qops;
- sb->s_op = &linvfs_sops;
+ sb->s_qcop = &xfs_quotactl_operations;
+ sb->s_op = &xfs_super_operations;
VFS_MOUNT(vfsp, args, NULL, error);
if (error) {
@@ -876,7 +867,7 @@ linvfs_fill_super(
if (error)
goto fail_unmount;
- sb->s_root = d_alloc_root(LINVFS_GET_IP(rootvp));
+ sb->s_root = d_alloc_root(vn_to_inode(rootvp));
if (!sb->s_root) {
error = ENOMEM;
goto fail_vnrele;
@@ -885,7 +876,7 @@ linvfs_fill_super(
error = EINVAL;
goto fail_vnrele;
}
- if ((error = linvfs_start_syncd(vfsp)))
+ if ((error = xfs_fs_start_syncd(vfsp)))
goto fail_vnrele;
vn_trace_exit(rootvp, __FUNCTION__, (inst_t *)__return_address);
@@ -910,41 +901,41 @@ fail_vfsop:
}
STATIC struct super_block *
-linvfs_get_sb(
+xfs_fs_get_sb(
struct file_system_type *fs_type,
int flags,
const char *dev_name,
void *data)
{
- return get_sb_bdev(fs_type, flags, dev_name, data, linvfs_fill_super);
-}
-
-STATIC struct super_operations linvfs_sops = {
- .alloc_inode = linvfs_alloc_inode,
- .destroy_inode = linvfs_destroy_inode,
- .write_inode = linvfs_write_inode,
- .clear_inode = linvfs_clear_inode,
- .put_super = linvfs_put_super,
- .write_super = linvfs_write_super,
- .sync_fs = linvfs_sync_super,
- .write_super_lockfs = linvfs_freeze_fs,
- .statfs = linvfs_statfs,
- .remount_fs = linvfs_remount,
- .show_options = linvfs_show_options,
+ return get_sb_bdev(fs_type, flags, dev_name, data, xfs_fs_fill_super);
+}
+
+STATIC struct super_operations xfs_super_operations = {
+ .alloc_inode = xfs_fs_alloc_inode,
+ .destroy_inode = xfs_fs_destroy_inode,
+ .write_inode = xfs_fs_write_inode,
+ .clear_inode = xfs_fs_clear_inode,
+ .put_super = xfs_fs_put_super,
+ .write_super = xfs_fs_write_super,
+ .sync_fs = xfs_fs_sync_super,
+ .write_super_lockfs = xfs_fs_lockfs,
+ .statfs = xfs_fs_statfs,
+ .remount_fs = xfs_fs_remount,
+ .show_options = xfs_fs_show_options,
};
-STATIC struct quotactl_ops linvfs_qops = {
- .quota_sync = linvfs_quotasync,
- .get_xstate = linvfs_getxstate,
- .set_xstate = linvfs_setxstate,
- .get_xquota = linvfs_getxquota,
- .set_xquota = linvfs_setxquota,
+STATIC struct quotactl_ops xfs_quotactl_operations = {
+ .quota_sync = xfs_fs_quotasync,
+ .get_xstate = xfs_fs_getxstate,
+ .set_xstate = xfs_fs_setxstate,
+ .get_xquota = xfs_fs_getxquota,
+ .set_xquota = xfs_fs_setxquota,
};
STATIC struct file_system_type xfs_fs_type = {
.owner = THIS_MODULE,
.name = "xfs",
- .get_sb = linvfs_get_sb,
+ .get_sb = xfs_fs_get_sb,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
@@ -965,7 +956,7 @@ init_xfs_fs( void )
ktrace_init(64);
- error = linvfs_init_zones();
+ error = xfs_init_zones();
if (error < 0)
goto undo_zones;
@@ -981,14 +972,13 @@ init_xfs_fs( void )
error = register_filesystem(&xfs_fs_type);
if (error)
goto undo_register;
- XFS_DM_INIT(&xfs_fs_type);
return 0;
undo_register:
xfs_buf_terminate();
undo_buffers:
- linvfs_destroy_zones();
+ xfs_destroy_zones();
undo_zones:
return error;
@@ -998,11 +988,10 @@ STATIC void __exit
exit_xfs_fs( void )
{
vfs_exitquota();
- XFS_DM_EXIT(&xfs_fs_type);
unregister_filesystem(&xfs_fs_type);
xfs_cleanup();
xfs_buf_terminate();
- linvfs_destroy_zones();
+ xfs_destroy_zones();
ktrace_uninit();
}
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index df59408dca0..376b96cb513 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -98,11 +98,6 @@ extern void xfs_qm_exit(void);
XFS_DMAPI_STRING \
XFS_DBG_STRING /* DBG must be last */
-#define LINVFS_GET_VFS(s) \
- (vfs_t *)((s)->s_fs_info)
-#define LINVFS_SET_VFS(s, vfsp) \
- ((s)->s_fs_info = vfsp)
-
struct xfs_inode;
struct xfs_mount;
struct xfs_buftarg;
@@ -120,6 +115,6 @@ extern int xfs_blkdev_get(struct xfs_mount *, const char *,
extern void xfs_blkdev_put(struct block_device *);
extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
-extern struct export_operations linvfs_export_ops;
+extern struct export_operations xfs_export_operations;
#endif /* __XFS_SUPER_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c
index a0256497242..7079cc83721 100644
--- a/fs/xfs/linux-2.6/xfs_sysctl.c
+++ b/fs/xfs/linux-2.6/xfs_sysctl.c
@@ -38,8 +38,7 @@ xfs_stats_clear_proc_handler(
if (!ret && write && *valp) {
printk("XFS Clearing xfsstats\n");
- for (c = 0; c < NR_CPUS; c++) {
- if (!cpu_possible(c)) continue;
+ for_each_cpu(c) {
preempt_disable();
/* save vn_active, it's a universal truth! */
vn_active = per_cpu(xfsstats, c).vn_active;
diff --git a/fs/xfs/linux-2.6/xfs_vfs.c b/fs/xfs/linux-2.6/xfs_vfs.c
index c855d62e534..6f7c9f7a862 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.c
+++ b/fs/xfs/linux-2.6/xfs_vfs.c
@@ -227,7 +227,8 @@ vfs_freeze(
}
vfs_t *
-vfs_allocate( void )
+vfs_allocate(
+ struct super_block *sb)
{
struct vfs *vfsp;
@@ -236,9 +237,23 @@ vfs_allocate( void )
INIT_LIST_HEAD(&vfsp->vfs_sync_list);
spin_lock_init(&vfsp->vfs_sync_lock);
init_waitqueue_head(&vfsp->vfs_wait_single_sync_task);
+
+ vfsp->vfs_super = sb;
+ sb->s_fs_info = vfsp;
+
+ if (sb->s_flags & MS_RDONLY)
+ vfsp->vfs_flag |= VFS_RDONLY;
+
return vfsp;
}
+vfs_t *
+vfs_from_sb(
+ struct super_block *sb)
+{
+ return (vfs_t *)sb->s_fs_info;
+}
+
void
vfs_deallocate(
struct vfs *vfsp)
@@ -295,7 +310,7 @@ bhv_remove_all_vfsops(
bhv_remove_vfsops(vfsp, VFS_POSITION_DM);
if (!freebase)
return;
- mp = XFS_BHVTOM(bhv_lookup(VFS_BHVHEAD(vfsp), &xfs_vfsops));
+ mp = XFS_VFSTOM(vfsp);
VFS_REMOVEBHV(vfsp, &mp->m_bhv);
xfs_mount_free(mp, 0);
}
diff --git a/fs/xfs/linux-2.6/xfs_vfs.h b/fs/xfs/linux-2.6/xfs_vfs.h
index 57caf9eddee..8fed356db05 100644
--- a/fs/xfs/linux-2.6/xfs_vfs.h
+++ b/fs/xfs/linux-2.6/xfs_vfs.h
@@ -193,7 +193,8 @@ typedef struct bhv_vfsops {
#define vfs_bhv_set_custom(b,o) ( (b)->bhv_custom = (void *)(o))
#define vfs_bhv_clr_custom(b) ( (b)->bhv_custom = NULL )
-extern vfs_t *vfs_allocate(void);
+extern vfs_t *vfs_allocate(struct super_block *);
+extern vfs_t *vfs_from_sb(struct super_block *);
extern void vfs_deallocate(vfs_t *);
extern void vfs_insertops(vfs_t *, bhv_vfsops_t *);
extern void vfs_insertbhv(vfs_t *, bhv_desc_t *, vfsops_t *, void *);
diff --git a/fs/xfs/linux-2.6/xfs_vnode.c b/fs/xfs/linux-2.6/xfs_vnode.c
index 260dd8415dd..d27c25b27cc 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.c
+++ b/fs/xfs/linux-2.6/xfs_vnode.c
@@ -58,7 +58,7 @@ struct vnode *
vn_initialize(
struct inode *inode)
{
- struct vnode *vp = LINVFS_GET_VP(inode);
+ struct vnode *vp = vn_from_inode(inode);
XFS_STATS_INC(vn_active);
XFS_STATS_INC(vn_alloc);
@@ -83,7 +83,7 @@ vn_initialize(
vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
#endif /* XFS_VNODE_TRACE */
- vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
+ vn_trace_exit(vp, __FUNCTION__, (inst_t *)__return_address);
return vp;
}
@@ -97,7 +97,7 @@ vn_revalidate_core(
struct vnode *vp,
vattr_t *vap)
{
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
inode->i_mode = vap->va_mode;
inode->i_nlink = vap->va_nlink;
@@ -129,24 +129,31 @@ vn_revalidate_core(
* Revalidate the Linux inode from the vnode.
*/
int
-vn_revalidate(
- struct vnode *vp)
+__vn_revalidate(
+ struct vnode *vp,
+ struct vattr *vattr)
{
- vattr_t va;
int error;
- vn_trace_entry(vp, "vn_revalidate", (inst_t *)__return_address);
- ASSERT(vp->v_fbhv != NULL);
-
- va.va_mask = XFS_AT_STAT|XFS_AT_XFLAGS;
- VOP_GETATTR(vp, &va, 0, NULL, error);
- if (!error) {
- vn_revalidate_core(vp, &va);
+ vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
+ vattr->va_mask = XFS_AT_STAT | XFS_AT_XFLAGS;
+ VOP_GETATTR(vp, vattr, 0, NULL, error);
+ if (likely(!error)) {
+ vn_revalidate_core(vp, vattr);
VUNMODIFY(vp);
}
return -error;
}
+int
+vn_revalidate(
+ struct vnode *vp)
+{
+ vattr_t vattr;
+
+ return __vn_revalidate(vp, &vattr);
+}
+
/*
* Add a reference to a referenced vnode.
*/
@@ -159,7 +166,7 @@ vn_hold(
XFS_STATS_INC(vn_hold);
VN_LOCK(vp);
- inode = igrab(LINVFS_GET_IP(vp));
+ inode = igrab(vn_to_inode(vp));
ASSERT(inode);
VN_UNLOCK(vp, 0);
diff --git a/fs/xfs/linux-2.6/xfs_vnode.h b/fs/xfs/linux-2.6/xfs_vnode.h
index 0fe2419461d..06f5845e956 100644
--- a/fs/xfs/linux-2.6/xfs_vnode.h
+++ b/fs/xfs/linux-2.6/xfs_vnode.h
@@ -116,8 +116,14 @@ typedef enum {
/*
* Vnode to Linux inode mapping.
*/
-#define LINVFS_GET_VP(inode) ((vnode_t *)list_entry(inode, vnode_t, v_inode))
-#define LINVFS_GET_IP(vp) (&(vp)->v_inode)
+static inline struct vnode *vn_from_inode(struct inode *inode)
+{
+ return (vnode_t *)list_entry(inode, vnode_t, v_inode);
+}
+static inline struct inode *vn_to_inode(struct vnode *vnode)
+{
+ return &vnode->v_inode;
+}
/*
* Vnode flags.
@@ -490,6 +496,7 @@ typedef struct vnode_map {
(vmap).v_ino = (vp)->v_inode.i_ino; }
extern int vn_revalidate(struct vnode *);
+extern int __vn_revalidate(struct vnode *, vattr_t *);
extern void vn_revalidate_core(struct vnode *, vattr_t *);
extern void vn_iowait(struct vnode *vp);
@@ -497,7 +504,7 @@ extern void vn_iowake(struct vnode *vp);
static inline int vn_count(struct vnode *vp)
{
- return atomic_read(&LINVFS_GET_IP(vp)->i_count);
+ return atomic_read(&vn_to_inode(vp)->i_count);
}
/*
@@ -511,16 +518,16 @@ extern vnode_t *vn_hold(struct vnode *);
vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
#define VN_RELE(vp) \
(vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
- iput(LINVFS_GET_IP(vp)))
+ iput(vn_to_inode(vp)))
#else
#define VN_HOLD(vp) ((void)vn_hold(vp))
-#define VN_RELE(vp) (iput(LINVFS_GET_IP(vp)))
+#define VN_RELE(vp) (iput(vn_to_inode(vp)))
#endif
static inline struct vnode *vn_grab(struct vnode *vp)
{
- struct inode *inode = igrab(LINVFS_GET_IP(vp));
- return inode ? LINVFS_GET_VP(inode) : NULL;
+ struct inode *inode = igrab(vn_to_inode(vp));
+ return inode ? vn_from_inode(inode) : NULL;
}
/*
@@ -528,7 +535,7 @@ static inline struct vnode *vn_grab(struct vnode *vp)
*/
#define VNAME(dentry) ((char *) (dentry)->d_name.name)
#define VNAMELEN(dentry) ((dentry)->d_name.len)
-#define VNAME_TO_VNODE(dentry) (LINVFS_GET_VP((dentry)->d_inode))
+#define VNAME_TO_VNODE(dentry) (vn_from_inode((dentry)->d_inode))
/*
* Vnode spinlock manipulation.
@@ -557,12 +564,12 @@ static __inline__ void vn_flagclr(struct vnode *vp, uint flag)
*/
static inline void vn_mark_bad(struct vnode *vp)
{
- make_bad_inode(LINVFS_GET_IP(vp));
+ make_bad_inode(vn_to_inode(vp));
}
static inline int VN_BAD(struct vnode *vp)
{
- return is_bad_inode(LINVFS_GET_IP(vp));
+ return is_bad_inode(vn_to_inode(vp));
}
/*
@@ -587,9 +594,9 @@ static inline void vn_atime_to_time_t(struct vnode *vp, time_t *tt)
/*
* Some useful predicates.
*/
-#define VN_MAPPED(vp) mapping_mapped(LINVFS_GET_IP(vp)->i_mapping)
-#define VN_CACHED(vp) (LINVFS_GET_IP(vp)->i_mapping->nrpages)
-#define VN_DIRTY(vp) mapping_tagged(LINVFS_GET_IP(vp)->i_mapping, \
+#define VN_MAPPED(vp) mapping_mapped(vn_to_inode(vp)->i_mapping)
+#define VN_CACHED(vp) (vn_to_inode(vp)->i_mapping->nrpages)
+#define VN_DIRTY(vp) mapping_tagged(vn_to_inode(vp)->i_mapping, \
PAGECACHE_TAG_DIRTY)
#define VMODIFY(vp) VN_FLAGSET(vp, VMODIFIED)
#define VUNMODIFY(vp) VN_FLAGCLR(vp, VMODIFIED)
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index 2ec6b441849..e4e5f05b841 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -79,9 +79,11 @@ xfs_qm_dquot_logitem_format(
logvec->i_addr = (xfs_caddr_t)&logitem->qli_format;
logvec->i_len = sizeof(xfs_dq_logformat_t);
+ XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_QFORMAT);
logvec++;
logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core;
logvec->i_len = sizeof(xfs_disk_dquot_t);
+ XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_DQUOT);
ASSERT(2 == logitem->qli_item.li_desc->lid_size);
logitem->qli_format.qlf_size = 2;
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 7c0e39dc618..1fb757ef3f4 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -1704,9 +1704,9 @@ xfs_qm_get_rtblks(
xfs_qcnt_t *O_rtblks)
{
xfs_filblks_t rtblks; /* total rt blks */
+ xfs_extnum_t idx; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extnum_t nextents; /* number of extent entries */
- xfs_bmbt_rec_t *base; /* base of extent array */
xfs_bmbt_rec_t *ep; /* pointer to an extent entry */
int error;
@@ -1717,10 +1717,11 @@ xfs_qm_get_rtblks(
return error;
}
rtblks = 0;
- nextents = ifp->if_bytes / sizeof(xfs_bmbt_rec_t);
- base = &ifp->if_u1.if_extents[0];
- for (ep = base; ep < &base[nextents]; ep++)
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ for (idx = 0; idx < nextents; idx++) {
+ ep = xfs_iext_get_ext(ifp, idx);
rtblks += xfs_bmbt_get_blockcount(ep);
+ }
*O_rtblks = (xfs_qcnt_t)rtblks;
return 0;
}
@@ -2788,9 +2789,7 @@ xfs_qm_freelist_destroy(xfs_frlist_t *ql)
xfs_qm_dqdestroy(dqp);
dqp = nextdqp;
}
- /*
- * Don't bother about unlocking.
- */
+ mutex_unlock(&ql->qh_lock);
mutex_destroy(&ql->qh_lock);
ASSERT(ql->qh_nelems == 0);
diff --git a/fs/xfs/quota/xfs_qm_bhv.c b/fs/xfs/quota/xfs_qm_bhv.c
index 90402a1c398..6838b36d95a 100644
--- a/fs/xfs/quota/xfs_qm_bhv.c
+++ b/fs/xfs/quota/xfs_qm_bhv.c
@@ -374,7 +374,7 @@ xfs_qm_exit(void)
vfs_bhv_clr_custom(&xfs_qmops);
xfs_qm_cleanup_procfs();
if (qm_dqzone)
- kmem_cache_destroy(qm_dqzone);
+ kmem_zone_destroy(qm_dqzone);
if (qm_dqtrxzone)
- kmem_cache_destroy(qm_dqtrxzone);
+ kmem_zone_destroy(qm_dqtrxzone);
}
diff --git a/fs/xfs/support/ktrace.c b/fs/xfs/support/ktrace.c
index 841aa4c15b8..addf5a7ea06 100644
--- a/fs/xfs/support/ktrace.c
+++ b/fs/xfs/support/ktrace.c
@@ -39,8 +39,8 @@ ktrace_init(int zentries)
void
ktrace_uninit(void)
{
- kmem_cache_destroy(ktrace_hdr_zone);
- kmem_cache_destroy(ktrace_ent_zone);
+ kmem_zone_destroy(ktrace_hdr_zone);
+ kmem_zone_destroy(ktrace_ent_zone);
}
/*
diff --git a/fs/xfs/support/uuid.c b/fs/xfs/support/uuid.c
index a3d565a6773..e157015c70f 100644
--- a/fs/xfs/support/uuid.c
+++ b/fs/xfs/support/uuid.c
@@ -21,13 +21,6 @@ static mutex_t uuid_monitor;
static int uuid_table_size;
static uuid_t *uuid_table;
-void
-uuid_init(void)
-{
- mutex_init(&uuid_monitor);
-}
-
-
/* IRIX interpretation of an uuid_t */
typedef struct {
__be32 uu_timelow;
@@ -50,7 +43,7 @@ uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
be16_to_cpu(uup->uu_timemid);
- fsid[1] = be16_to_cpu(uup->uu_timelow);
+ fsid[1] = be32_to_cpu(uup->uu_timelow);
}
void
@@ -139,3 +132,9 @@ uuid_table_remove(uuid_t *uuid)
ASSERT(i < uuid_table_size);
mutex_unlock(&uuid_monitor);
}
+
+void
+uuid_init(void)
+{
+ mutex_init(&uuid_monitor);
+}
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index f9315bc960c..538d0d65b04 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -55,8 +55,8 @@ struct xfs_inode;
extern struct kmem_zone *xfs_acl_zone;
#define xfs_acl_zone_init(zone, name) \
- (zone) = kmem_zone_init(sizeof(xfs_acl_t), name)
-#define xfs_acl_zone_destroy(zone) kmem_cache_destroy(zone)
+ (zone) = kmem_zone_init(sizeof(xfs_acl_t), (name))
+#define xfs_acl_zone_destroy(zone) kmem_zone_destroy(zone)
extern int xfs_acl_inherit(struct vnode *, struct vattr *, xfs_acl_t *);
extern int xfs_acl_iaccess(struct xfs_inode *, mode_t, cred_t *);
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index e5e91e9c7e8..093fac476bd 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
return(error);
ASSERT(bp != NULL);
leaf = bp->data;
- if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- != XFS_ATTR_LEAF_MAGIC)) {
+ if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
context->dp->i_mount, leaf);
xfs_da_brelse(NULL, bp);
@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
XFS_ATTR_FORK);
if (error)
goto out;
- ASSERT(INT_GET(((xfs_attr_leafblock_t *)
- bp->data)->hdr.info.magic, ARCH_CONVERT)
+ ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
+ bp->data)->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC);
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(error);
if (bp) {
node = bp->data;
- switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) {
+ switch (be16_to_cpu(node->hdr.info.magic)) {
case XFS_DA_NODE_MAGIC:
xfs_attr_trace_l_cn("wrong blk", context, node);
xfs_da_brelse(NULL, bp);
@@ -1771,18 +1770,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
break;
case XFS_ATTR_LEAF_MAGIC:
leaf = bp->data;
- if (cursor->hashval >
- INT_GET(leaf->entries[
- INT_GET(leaf->hdr.count,
- ARCH_CONVERT)-1].hashval,
- ARCH_CONVERT)) {
+ if (cursor->hashval > be32_to_cpu(leaf->entries[
+ be16_to_cpu(leaf->hdr.count)-1].hashval)) {
xfs_attr_trace_l_cl("wrong blk",
context, leaf);
xfs_da_brelse(NULL, bp);
bp = NULL;
} else if (cursor->hashval <=
- INT_GET(leaf->entries[0].hashval,
- ARCH_CONVERT)) {
+ be32_to_cpu(leaf->entries[0].hashval)) {
xfs_attr_trace_l_cl("maybe wrong blk",
context, leaf);
xfs_da_brelse(NULL, bp);
@@ -1817,10 +1812,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(XFS_ERROR(EFSCORRUPTED));
}
node = bp->data;
- if (INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+ if (be16_to_cpu(node->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC)
break;
- if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+ if (unlikely(be16_to_cpu(node->hdr.info.magic)
!= XFS_DA_NODE_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
XFS_ERRLEVEL_LOW,
@@ -1830,19 +1825,17 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(XFS_ERROR(EFSCORRUPTED));
}
btree = node->btree;
- for (i = 0;
- i < INT_GET(node->hdr.count, ARCH_CONVERT);
+ for (i = 0; i < be16_to_cpu(node->hdr.count);
btree++, i++) {
if (cursor->hashval
- <= INT_GET(btree->hashval,
- ARCH_CONVERT)) {
- cursor->blkno = INT_GET(btree->before, ARCH_CONVERT);
+ <= be32_to_cpu(btree->hashval)) {
+ cursor->blkno = be32_to_cpu(btree->before);
xfs_attr_trace_l_cb("descending",
context, btree);
break;
}
}
- if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) {
+ if (i == be16_to_cpu(node->hdr.count)) {
xfs_da_brelse(NULL, bp);
return(0);
}
@@ -1858,7 +1851,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
*/
for (;;) {
leaf = bp->data;
- if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
+ if (unlikely(be16_to_cpu(leaf->hdr.info.magic)
!= XFS_ATTR_LEAF_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
XFS_ERRLEVEL_LOW,
@@ -1869,7 +1862,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
error = xfs_attr_leaf_list_int(bp, context);
if (error || !leaf->hdr.info.forw)
break; /* not really an error, buffer full or EOF */
- cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
+ cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
xfs_da_brelse(NULL, bp);
error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK);
@@ -2232,9 +2225,10 @@ xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
: 0,
(__psunsigned_t)context->dupcnt,
(__psunsigned_t)context->flags,
- (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
- (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
- (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+ (__psunsigned_t)be16_to_cpu(node->hdr.count),
+ (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
+ (__psunsigned_t)be32_to_cpu(node->btree[
+ be16_to_cpu(node->hdr.count)-1].hashval));
}
/*
@@ -2261,8 +2255,8 @@ xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
: 0,
(__psunsigned_t)context->dupcnt,
(__psunsigned_t)context->flags,
- (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT),
- (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT),
+ (__psunsigned_t)be32_to_cpu(btree->hashval),
+ (__psunsigned_t)be32_to_cpu(btree->before),
(__psunsigned_t)NULL);
}
@@ -2290,9 +2284,10 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
: 0,
(__psunsigned_t)context->dupcnt,
(__psunsigned_t)context->flags,
- (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
- (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
- (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+ (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
+ (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
+ (__psunsigned_t)be32_to_cpu(leaf->entries[
+ be16_to_cpu(leaf->hdr.count)-1].hashval));
}
/*
@@ -2522,7 +2517,7 @@ attr_user_capable(
struct vnode *vp,
cred_t *cred)
{
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
@@ -2540,7 +2535,7 @@ attr_trusted_capable(
struct vnode *vp,
cred_t *cred)
{
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
return -EPERM;
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index fe91eac4e2a..717682747bd 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -194,7 +194,7 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
hdr->count = 0;
- INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr));
+ hdr->totsize = cpu_to_be16(sizeof(*hdr));
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
}
@@ -224,8 +224,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
ASSERT(ifp->if_flags & XFS_IFINLINE);
sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
sfe = &sf->list[0];
- for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
- sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
+ for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
#ifdef DEBUG
if (sfe->namelen != args->namelen)
continue;
@@ -248,13 +247,13 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset);
sfe->namelen = args->namelen;
- INT_SET(sfe->valuelen, ARCH_CONVERT, args->valuelen);
+ sfe->valuelen = args->valuelen;
sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
memcpy(sfe->nameval, args->name, args->namelen);
memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen);
- INT_MOD(sf->hdr.count, ARCH_CONVERT, 1);
- INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size);
+ sf->hdr.count++;
+ be16_add(&sf->hdr.totsize, size);
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
xfs_sbversion_add_attr2(mp, args->trans);
@@ -277,7 +276,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
base = sizeof(xfs_attr_sf_hdr_t);
sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
sfe = &sf->list[0];
- end = INT_GET(sf->hdr.count, ARCH_CONVERT);
+ end = sf->hdr.count;
for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe),
base += size, i++) {
size = XFS_ATTR_SF_ENTSIZE(sfe);
@@ -300,11 +299,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
* Fix up the attribute fork data, covering the hole
*/
end = base + size;
- totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
+ totsize = be16_to_cpu(sf->hdr.totsize);
if (end != totsize)
memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
- INT_MOD(sf->hdr.count, ARCH_CONVERT, -1);
- INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size);
+ sf->hdr.count--;
+ be16_add(&sf->hdr.totsize, -size);
/*
* Fix up the start offset of the attribute fork
@@ -360,7 +359,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
ASSERT(ifp->if_flags & XFS_IFINLINE);
sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
sfe = &sf->list[0];
- for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
+ for (i = 0; i < sf->hdr.count;
sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
if (sfe->namelen != args->namelen)
continue;
@@ -391,7 +390,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE);
sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data;
sfe = &sf->list[0];
- for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT);
+ for (i = 0; i < sf->hdr.count;
sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
if (sfe->namelen != args->namelen)
continue;
@@ -404,14 +403,14 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
((sfe->flags & XFS_ATTR_ROOT) != 0))
continue;
if (args->flags & ATTR_KERNOVAL) {
- args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+ args->valuelen = sfe->valuelen;
return(XFS_ERROR(EEXIST));
}
- if (args->valuelen < INT_GET(sfe->valuelen, ARCH_CONVERT)) {
- args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+ if (args->valuelen < sfe->valuelen) {
+ args->valuelen = sfe->valuelen;
return(XFS_ERROR(ERANGE));
}
- args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+ args->valuelen = sfe->valuelen;
memcpy(args->value, &sfe->nameval[args->namelen],
args->valuelen);
return(XFS_ERROR(EEXIST));
@@ -438,7 +437,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
dp = args->dp;
ifp = dp->i_afp;
sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
- size = INT_GET(sf->hdr.totsize, ARCH_CONVERT);
+ size = be16_to_cpu(sf->hdr.totsize);
tmpbuffer = kmem_alloc(size, KM_SLEEP);
ASSERT(tmpbuffer != NULL);
memcpy(tmpbuffer, ifp->if_u1.if_data, size);
@@ -481,11 +480,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
nargs.oknoent = 1;
sfe = &sf->list[0];
- for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+ for (i = 0; i < sf->hdr.count; i++) {
nargs.name = (char *)sfe->nameval;
nargs.namelen = sfe->namelen;
nargs.value = (char *)&sfe->nameval[nargs.namelen];
- nargs.valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT);
+ nargs.valuelen = sfe->valuelen;
nargs.hashval = xfs_da_hashname((char *)sfe->nameval,
sfe->namelen);
nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
@@ -514,11 +513,9 @@ xfs_attr_shortform_compare(const void *a, const void *b)
sa = (xfs_attr_sf_sort_t *)a;
sb = (xfs_attr_sf_sort_t *)b;
- if (INT_GET(sa->hash, ARCH_CONVERT)
- < INT_GET(sb->hash, ARCH_CONVERT)) {
+ if (sa->hash < sb->hash) {
return(-1);
- } else if (INT_GET(sa->hash, ARCH_CONVERT)
- > INT_GET(sb->hash, ARCH_CONVERT)) {
+ } else if (sa->hash > sb->hash) {
return(1);
} else {
return(sa->entno - sb->entno);
@@ -560,10 +557,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
* If the buffer is large enough, do not bother with sorting.
* Note the generous fudge factor of 16 overhead bytes per entry.
*/
- if ((dp->i_afp->if_bytes + INT_GET(sf->hdr.count, ARCH_CONVERT) * 16)
- < context->bufsize) {
- for (i = 0, sfe = &sf->list[0];
- i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+ if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) {
+ for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
attrnames_t *namesp;
if (((context->flags & ATTR_SECURE) != 0) !=
@@ -584,14 +579,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
if (context->flags & ATTR_KERNOVAL) {
ASSERT(context->flags & ATTR_KERNAMELS);
context->count += namesp->attr_namelen +
- INT_GET(sfe->namelen, ARCH_CONVERT) + 1;
+ sfe->namelen + 1;
}
else {
if (xfs_attr_put_listent(context, namesp,
(char *)sfe->nameval,
(int)sfe->namelen,
- (int)INT_GET(sfe->valuelen,
- ARCH_CONVERT)))
+ (int)sfe->valuelen))
break;
}
sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
@@ -603,7 +597,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
/*
* It didn't all fit, so we have to sort everything on hashval.
*/
- sbsize = INT_GET(sf->hdr.count, ARCH_CONVERT) * sizeof(*sbuf);
+ sbsize = sf->hdr.count * sizeof(*sbuf);
sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);
/*
@@ -611,8 +605,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
* the relevant info from only those that match into a buffer.
*/
nsbuf = 0;
- for (i = 0, sfe = &sf->list[0];
- i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+ for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
if (unlikely(
((char *)sfe < (char *)sf) ||
((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) {
@@ -636,8 +629,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
continue;
}
sbp->entno = i;
- INT_SET(sbp->hash, ARCH_CONVERT,
- xfs_da_hashname((char *)sfe->nameval, sfe->namelen));
+ sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen);
sbp->name = (char *)sfe->nameval;
sbp->namelen = sfe->namelen;
/* These are bytes, and both on-disk, don't endian-flip */
@@ -660,12 +652,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
cursor->initted = 1;
cursor->blkno = 0;
for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) {
- if (INT_GET(sbp->hash, ARCH_CONVERT) == cursor->hashval) {
+ if (sbp->hash == cursor->hashval) {
if (cursor->offset == count) {
break;
}
count++;
- } else if (INT_GET(sbp->hash, ARCH_CONVERT) > cursor->hashval) {
+ } else if (sbp->hash > cursor->hashval) {
break;
}
}
@@ -685,8 +677,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
((sbp->flags & XFS_ATTR_ROOT) ? &attr_trusted :
&attr_user);
- if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) {
- cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT);
+ if (cursor->hashval != sbp->hash) {
+ cursor->hashval = sbp->hash;
cursor->offset = 0;
}
if (context->flags & ATTR_KERNOVAL) {
@@ -696,7 +688,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
} else {
if (xfs_attr_put_listent(context, namesp,
sbp->name, sbp->namelen,
- INT_GET(sbp->valuelen, ARCH_CONVERT)))
+ sbp->valuelen))
break;
}
cursor->offset++;
@@ -720,12 +712,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
int bytes, i;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
entry = &leaf->entries[0];
bytes = sizeof(struct xfs_attr_sf_hdr);
- for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
+ for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
if (entry->flags & XFS_ATTR_INCOMPLETE)
continue; /* don't copy partial entries */
if (!(entry->flags & XFS_ATTR_LOCAL))
@@ -733,11 +724,11 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
if (name_loc->namelen >= XFS_ATTR_SF_ENTSIZE_MAX)
return(0);
- if (INT_GET(name_loc->valuelen, ARCH_CONVERT) >= XFS_ATTR_SF_ENTSIZE_MAX)
+ if (be16_to_cpu(name_loc->valuelen) >= XFS_ATTR_SF_ENTSIZE_MAX)
return(0);
bytes += sizeof(struct xfs_attr_sf_entry)-1
+ name_loc->namelen
- + INT_GET(name_loc->valuelen, ARCH_CONVERT);
+ + be16_to_cpu(name_loc->valuelen);
}
if ((dp->i_mount->m_flags & XFS_MOUNT_ATTR2) &&
(bytes == sizeof(struct xfs_attr_sf_hdr)))
@@ -766,8 +757,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
ASSERT(bp != NULL);
memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
leaf = (xfs_attr_leafblock_t *)tmpbuffer;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
/*
@@ -810,7 +800,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
nargs.trans = args->trans;
nargs.oknoent = 1;
entry = &leaf->entries[0];
- for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
+ for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
if (entry->flags & XFS_ATTR_INCOMPLETE)
continue; /* don't copy partial entries */
if (!entry->nameidx)
@@ -820,8 +810,8 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
nargs.name = (char *)name_loc->nameval;
nargs.namelen = name_loc->namelen;
nargs.value = (char *)&name_loc->nameval[nargs.namelen];
- nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT);
- nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT);
+ nargs.valuelen = be16_to_cpu(name_loc->valuelen);
+ nargs.hashval = be32_to_cpu(entry->hashval);
nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0);
xfs_attr_shortform_add(&nargs, forkoff);
@@ -875,13 +865,12 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
goto out;
node = bp1->data;
leaf = bp2->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
/* both on-disk, don't endian-flip twice */
node->btree[0].hashval =
- leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval;
- INT_SET(node->btree[0].before, ARCH_CONVERT, blkno);
- INT_SET(node->hdr.count, ARCH_CONVERT, 1);
+ leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
+ node->btree[0].before = cpu_to_be32(blkno);
+ node->hdr.count = cpu_to_be16(1);
xfs_da_log_buf(args->trans, bp1, 0, XFS_LBSIZE(dp->i_mount) - 1);
error = 0;
out:
@@ -920,19 +909,16 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
leaf = bp->data;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
hdr = &leaf->hdr;
- INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC);
- INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
+ hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
+ hdr->firstused = cpu_to_be16(XFS_LBSIZE(dp->i_mount));
if (!hdr->firstused) {
- INT_SET(hdr->firstused, ARCH_CONVERT,
+ hdr->firstused = cpu_to_be16(
XFS_LBSIZE(dp->i_mount) - XFS_ATTR_LEAF_NAME_ALIGN);
}
- INT_SET(hdr->freemap[0].base, ARCH_CONVERT,
- sizeof(xfs_attr_leaf_hdr_t));
- INT_SET(hdr->freemap[0].size, ARCH_CONVERT,
- INT_GET(hdr->firstused, ARCH_CONVERT)
- - INT_GET(hdr->freemap[0].base,
- ARCH_CONVERT));
+ hdr->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+ hdr->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr->firstused) -
+ sizeof(xfs_attr_leaf_hdr_t));
xfs_da_log_buf(args->trans, bp, 0, XFS_LBSIZE(dp->i_mount) - 1);
@@ -1004,10 +990,9 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
int tablesize, entsize, sum, tmp, i;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT((args->index >= 0)
- && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
+ && (args->index <= be16_to_cpu(leaf->hdr.count)));
hdr = &leaf->hdr;
entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
args->trans->t_mountp->m_sb.sb_blocksize, NULL);
@@ -1016,26 +1001,25 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
* Search through freemap for first-fit on new name length.
* (may need to figure in size of entry struct too)
*/
- tablesize = (INT_GET(hdr->count, ARCH_CONVERT) + 1)
+ tablesize = (be16_to_cpu(hdr->count) + 1)
* sizeof(xfs_attr_leaf_entry_t)
+ sizeof(xfs_attr_leaf_hdr_t);
map = &hdr->freemap[XFS_ATTR_LEAF_MAPSIZE-1];
for (sum = 0, i = XFS_ATTR_LEAF_MAPSIZE-1; i >= 0; map--, i--) {
- if (tablesize > INT_GET(hdr->firstused, ARCH_CONVERT)) {
- sum += INT_GET(map->size, ARCH_CONVERT);
+ if (tablesize > be16_to_cpu(hdr->firstused)) {
+ sum += be16_to_cpu(map->size);
continue;
}
if (!map->size)
continue; /* no space in this map */
tmp = entsize;
- if (INT_GET(map->base, ARCH_CONVERT)
- < INT_GET(hdr->firstused, ARCH_CONVERT))
+ if (be16_to_cpu(map->base) < be16_to_cpu(hdr->firstused))
tmp += sizeof(xfs_attr_leaf_entry_t);
- if (INT_GET(map->size, ARCH_CONVERT) >= tmp) {
+ if (be16_to_cpu(map->size) >= tmp) {
tmp = xfs_attr_leaf_add_work(bp, args, i);
return(tmp);
}
- sum += INT_GET(map->size, ARCH_CONVERT);
+ sum += be16_to_cpu(map->size);
}
/*
@@ -1056,7 +1040,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
* After compaction, the block is guaranteed to have only one
* free region, in freemap[0]. If it is not big enough, give up.
*/
- if (INT_GET(hdr->freemap[0].size, ARCH_CONVERT)
+ if (be16_to_cpu(hdr->freemap[0].size)
< (entsize + sizeof(xfs_attr_leaf_entry_t)))
return(XFS_ERROR(ENOSPC));
@@ -1079,45 +1063,42 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
int tmp, i;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr = &leaf->hdr;
ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
- ASSERT((args->index >= 0)
- && (args->index <= INT_GET(hdr->count, ARCH_CONVERT)));
+ ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count)));
/*
* Force open some space in the entry array and fill it in.
*/
entry = &leaf->entries[args->index];
- if (args->index < INT_GET(hdr->count, ARCH_CONVERT)) {
- tmp = INT_GET(hdr->count, ARCH_CONVERT) - args->index;
+ if (args->index < be16_to_cpu(hdr->count)) {
+ tmp = be16_to_cpu(hdr->count) - args->index;
tmp *= sizeof(xfs_attr_leaf_entry_t);
memmove((char *)(entry+1), (char *)entry, tmp);
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
}
- INT_MOD(hdr->count, ARCH_CONVERT, 1);
+ be16_add(&hdr->count, 1);
/*
* Allocate space for the new string (at the end of the run).
*/
map = &hdr->freemap[mapindex];
mp = args->trans->t_mountp;
- ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
- ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
- ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
+ ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp));
+ ASSERT((be16_to_cpu(map->base) & 0x3) == 0);
+ ASSERT(be16_to_cpu(map->size) >=
xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, NULL));
- ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
- ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
- INT_MOD(map->size, ARCH_CONVERT,
+ ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
+ ASSERT((be16_to_cpu(map->size) & 0x3) == 0);
+ be16_add(&map->size,
-xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
mp->m_sb.sb_blocksize, &tmp));
- INT_SET(entry->nameidx, ARCH_CONVERT,
- INT_GET(map->base, ARCH_CONVERT)
- + INT_GET(map->size, ARCH_CONVERT));
- INT_SET(entry->hashval, ARCH_CONVERT, args->hashval);
+ entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) +
+ be16_to_cpu(map->size));
+ entry->hashval = cpu_to_be32(args->hashval);
entry->flags = tmp ? XFS_ATTR_LOCAL : 0;
entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
@@ -1130,12 +1111,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
}
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
- ASSERT((args->index == 0) || (INT_GET(entry->hashval, ARCH_CONVERT)
- >= INT_GET((entry-1)->hashval,
- ARCH_CONVERT)));
- ASSERT((args->index == INT_GET(hdr->count, ARCH_CONVERT)-1) ||
- (INT_GET(entry->hashval, ARCH_CONVERT)
- <= (INT_GET((entry+1)->hashval, ARCH_CONVERT))));
+ ASSERT((args->index == 0) ||
+ (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval)));
+ ASSERT((args->index == be16_to_cpu(hdr->count)-1) ||
+ (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval)));
/*
* Copy the attribute name and value into the new space.
@@ -1149,10 +1128,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
if (entry->flags & XFS_ATTR_LOCAL) {
name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
name_loc->namelen = args->namelen;
- INT_SET(name_loc->valuelen, ARCH_CONVERT, args->valuelen);
+ name_loc->valuelen = cpu_to_be16(args->valuelen);
memcpy((char *)name_loc->nameval, args->name, args->namelen);
memcpy((char *)&name_loc->nameval[args->namelen], args->value,
- INT_GET(name_loc->valuelen, ARCH_CONVERT));
+ be16_to_cpu(name_loc->valuelen));
} else {
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
name_rmt->namelen = args->namelen;
@@ -1171,28 +1150,23 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
/*
* Update the control info for this leaf node
*/
- if (INT_GET(entry->nameidx, ARCH_CONVERT)
- < INT_GET(hdr->firstused, ARCH_CONVERT)) {
+ if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) {
/* both on-disk, don't endian-flip twice */
hdr->firstused = entry->nameidx;
}
- ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT)
- >= ((INT_GET(hdr->count, ARCH_CONVERT)
- * sizeof(*entry))+sizeof(*hdr)));
- tmp = (INT_GET(hdr->count, ARCH_CONVERT)-1)
- * sizeof(xfs_attr_leaf_entry_t)
+ ASSERT(be16_to_cpu(hdr->firstused) >=
+ ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr)));
+ tmp = (be16_to_cpu(hdr->count)-1) * sizeof(xfs_attr_leaf_entry_t)
+ sizeof(xfs_attr_leaf_hdr_t);
map = &hdr->freemap[0];
for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) {
- if (INT_GET(map->base, ARCH_CONVERT) == tmp) {
- INT_MOD(map->base, ARCH_CONVERT,
- sizeof(xfs_attr_leaf_entry_t));
- INT_MOD(map->size, ARCH_CONVERT,
- -sizeof(xfs_attr_leaf_entry_t));
+ if (be16_to_cpu(map->base) == tmp) {
+ be16_add(&map->base, sizeof(xfs_attr_leaf_entry_t));
+ be16_add(&map->size,
+ -((int)sizeof(xfs_attr_leaf_entry_t)));
}
}
- INT_MOD(hdr->usedbytes, ARCH_CONVERT,
- xfs_attr_leaf_entsize(leaf, args->index));
+ be16_add(&hdr->usedbytes, xfs_attr_leaf_entsize(leaf, args->index));
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, hdr, sizeof(*hdr)));
return(0);
@@ -1223,28 +1197,25 @@ xfs_attr_leaf_compact(xfs_trans_t *trans, xfs_dabuf_t *bp)
hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr;
hdr_d->info = hdr_s->info; /* struct copy */
- INT_SET(hdr_d->firstused, ARCH_CONVERT, XFS_LBSIZE(mp));
+ hdr_d->firstused = cpu_to_be16(XFS_LBSIZE(mp));
/* handle truncation gracefully */
if (!hdr_d->firstused) {
- INT_SET(hdr_d->firstused, ARCH_CONVERT,
+ hdr_d->firstused = cpu_to_be16(
XFS_LBSIZE(mp) - XFS_ATTR_LEAF_NAME_ALIGN);
}
hdr_d->usedbytes = 0;
hdr_d->count = 0;
hdr_d->holes = 0;
- INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT,
- sizeof(xfs_attr_leaf_hdr_t));
- INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT,
- INT_GET(hdr_d->firstused, ARCH_CONVERT)
- - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT));
+ hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+ hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused) -
+ sizeof(xfs_attr_leaf_hdr_t));
/*
* Copy all entry's in the same (sorted) order,
* but allocate name/value pairs packed and in sequence.
*/
xfs_attr_leaf_moveents(leaf_s, 0, leaf_d, 0,
- (int)INT_GET(hdr_s->count, ARCH_CONVERT), mp);
-
+ be16_to_cpu(hdr_s->count), mp);
xfs_da_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1);
kmem_free(tmpbuffer, XFS_LBSIZE(mp));
@@ -1279,10 +1250,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC);
leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data;
- ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
args = state->args;
/*
@@ -1319,22 +1288,21 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
/*
* Move any entries required from leaf to leaf:
*/
- if (count < INT_GET(hdr1->count, ARCH_CONVERT)) {
+ if (count < be16_to_cpu(hdr1->count)) {
/*
* Figure the total bytes to be added to the destination leaf.
*/
/* number entries being moved */
- count = INT_GET(hdr1->count, ARCH_CONVERT) - count;
- space = INT_GET(hdr1->usedbytes, ARCH_CONVERT) - totallen;
+ count = be16_to_cpu(hdr1->count) - count;
+ space = be16_to_cpu(hdr1->usedbytes) - totallen;
space += count * sizeof(xfs_attr_leaf_entry_t);
/*
* leaf2 is the destination, compact it if it looks tight.
*/
- max = INT_GET(hdr2->firstused, ARCH_CONVERT)
+ max = be16_to_cpu(hdr2->firstused)
- sizeof(xfs_attr_leaf_hdr_t);
- max -= INT_GET(hdr2->count, ARCH_CONVERT)
- * sizeof(xfs_attr_leaf_entry_t);
+ max -= be16_to_cpu(hdr2->count) * sizeof(xfs_attr_leaf_entry_t);
if (space > max) {
xfs_attr_leaf_compact(args->trans, blk2->bp);
}
@@ -1342,13 +1310,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
/*
* Move high entries from leaf1 to low end of leaf2.
*/
- xfs_attr_leaf_moveents(leaf1,
- INT_GET(hdr1->count, ARCH_CONVERT)-count,
+ xfs_attr_leaf_moveents(leaf1, be16_to_cpu(hdr1->count) - count,
leaf2, 0, count, state->mp);
xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
- } else if (count > INT_GET(hdr1->count, ARCH_CONVERT)) {
+ } else if (count > be16_to_cpu(hdr1->count)) {
/*
* I assert that since all callers pass in an empty
* second buffer, this code should never execute.
@@ -1358,17 +1325,16 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
* Figure the total bytes to be added to the destination leaf.
*/
/* number entries being moved */
- count -= INT_GET(hdr1->count, ARCH_CONVERT);
- space = totallen - INT_GET(hdr1->usedbytes, ARCH_CONVERT);
+ count -= be16_to_cpu(hdr1->count);
+ space = totallen - be16_to_cpu(hdr1->usedbytes);
space += count * sizeof(xfs_attr_leaf_entry_t);
/*
* leaf1 is the destination, compact it if it looks tight.
*/
- max = INT_GET(hdr1->firstused, ARCH_CONVERT)
+ max = be16_to_cpu(hdr1->firstused)
- sizeof(xfs_attr_leaf_hdr_t);
- max -= INT_GET(hdr1->count, ARCH_CONVERT)
- * sizeof(xfs_attr_leaf_entry_t);
+ max -= be16_to_cpu(hdr1->count) * sizeof(xfs_attr_leaf_entry_t);
if (space > max) {
xfs_attr_leaf_compact(args->trans, blk1->bp);
}
@@ -1377,8 +1343,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
* Move low entries from leaf2 to high end of leaf1.
*/
xfs_attr_leaf_moveents(leaf2, 0, leaf1,
- (int)INT_GET(hdr1->count, ARCH_CONVERT), count,
- state->mp);
+ be16_to_cpu(hdr1->count), count, state->mp);
xfs_da_log_buf(args->trans, blk1->bp, 0, state->blocksize-1);
xfs_da_log_buf(args->trans, blk2->bp, 0, state->blocksize-1);
@@ -1387,12 +1352,10 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
/*
* Copy out last hashval in each block for B-tree code.
*/
- blk1->hashval =
- INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count,
- ARCH_CONVERT)-1].hashval, ARCH_CONVERT);
- blk2->hashval =
- INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count,
- ARCH_CONVERT)-1].hashval, ARCH_CONVERT);
+ blk1->hashval = be32_to_cpu(
+ leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval);
+ blk2->hashval = be32_to_cpu(
+ leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval);
/*
* Adjust the expected index for insertion.
@@ -1406,13 +1369,12 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
* inserting. The index/blkno fields refer to the "old" entry,
* while the index2/blkno2 fields refer to the "new" entry.
*/
- if (blk1->index > INT_GET(leaf1->hdr.count, ARCH_CONVERT)) {
+ if (blk1->index > be16_to_cpu(leaf1->hdr.count)) {
ASSERT(state->inleaf == 0);
- blk2->index = blk1->index
- - INT_GET(leaf1->hdr.count, ARCH_CONVERT);
+ blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
args->index = args->index2 = blk2->index;
args->blkno = args->blkno2 = blk2->blkno;
- } else if (blk1->index == INT_GET(leaf1->hdr.count, ARCH_CONVERT)) {
+ } else if (blk1->index == be16_to_cpu(leaf1->hdr.count)) {
if (state->inleaf) {
args->index = blk1->index;
args->blkno = blk1->blkno;
@@ -1420,7 +1382,7 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
args->blkno2 = blk2->blkno;
} else {
blk2->index = blk1->index
- - INT_GET(leaf1->hdr.count, ARCH_CONVERT);
+ - be16_to_cpu(leaf1->hdr.count);
args->index = args->index2 = blk2->index;
args->blkno = args->blkno2 = blk2->blkno;
}
@@ -1464,15 +1426,14 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
* Examine entries until we reduce the absolute difference in
* byte usage between the two blocks to a minimum.
*/
- max = INT_GET(hdr1->count, ARCH_CONVERT)
- + INT_GET(hdr2->count, ARCH_CONVERT);
+ max = be16_to_cpu(hdr1->count) + be16_to_cpu(hdr2->count);
half = (max+1) * sizeof(*entry);
- half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
- + INT_GET(hdr2->usedbytes, ARCH_CONVERT)
- + xfs_attr_leaf_newentsize(
- state->args->namelen,
- state->args->valuelen,
- state->blocksize, NULL);
+ half += be16_to_cpu(hdr1->usedbytes) +
+ be16_to_cpu(hdr2->usedbytes) +
+ xfs_attr_leaf_newentsize(
+ state->args->namelen,
+ state->args->valuelen,
+ state->blocksize, NULL);
half /= 2;
lastdelta = state->blocksize;
entry = &leaf1->entries[0];
@@ -1498,7 +1459,7 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
/*
* Wrap around into the second block if necessary.
*/
- if (count == INT_GET(hdr1->count, ARCH_CONVERT)) {
+ if (count == be16_to_cpu(hdr1->count)) {
leaf1 = leaf2;
entry = &leaf1->entries[0];
index = 0;
@@ -1566,12 +1527,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
*/
blk = &state->path.blk[ state->path.active-1 ];
info = blk->bp->data;
- ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
leaf = (xfs_attr_leafblock_t *)info;
- count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ count = be16_to_cpu(leaf->hdr.count);
bytes = sizeof(xfs_attr_leaf_hdr_t) +
count * sizeof(xfs_attr_leaf_entry_t) +
- INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+ be16_to_cpu(leaf->hdr.usedbytes);
if (bytes > (state->blocksize >> 1)) {
*action = 0; /* blk over 50%, don't try to join */
return(0);
@@ -1588,7 +1549,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one).
*/
- forward = info->forw;
+ forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval);
@@ -1610,13 +1571,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
* to shrink an attribute list over time.
*/
/* start with smaller blk num */
- forward = (INT_GET(info->forw, ARCH_CONVERT)
- < INT_GET(info->back, ARCH_CONVERT));
+ forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
for (i = 0; i < 2; forward = !forward, i++) {
if (forward)
- blkno = INT_GET(info->forw, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->forw);
else
- blkno = INT_GET(info->back, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->back);
if (blkno == 0)
continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -1626,14 +1586,13 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
ASSERT(bp != NULL);
leaf = (xfs_attr_leafblock_t *)info;
- count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ count = be16_to_cpu(leaf->hdr.count);
bytes = state->blocksize - (state->blocksize>>2);
- bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+ bytes -= be16_to_cpu(leaf->hdr.usedbytes);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
- bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ count += be16_to_cpu(leaf->hdr.count);
+ bytes -= be16_to_cpu(leaf->hdr.usedbytes);
bytes -= count * sizeof(xfs_attr_leaf_entry_t);
bytes -= sizeof(xfs_attr_leaf_hdr_t);
xfs_da_brelse(state->args->trans, bp);
@@ -1685,21 +1644,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_mount_t *mp;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr = &leaf->hdr;
mp = args->trans->t_mountp;
- ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0)
- && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
+ ASSERT((be16_to_cpu(hdr->count) > 0)
+ && (be16_to_cpu(hdr->count) < (XFS_LBSIZE(mp)/8)));
ASSERT((args->index >= 0)
- && (args->index < INT_GET(hdr->count, ARCH_CONVERT)));
- ASSERT(INT_GET(hdr->firstused, ARCH_CONVERT)
- >= ((INT_GET(hdr->count, ARCH_CONVERT)
- * sizeof(*entry))+sizeof(*hdr)));
+ && (args->index < be16_to_cpu(hdr->count)));
+ ASSERT(be16_to_cpu(hdr->firstused) >=
+ ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr)));
entry = &leaf->entries[args->index];
- ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
- >= INT_GET(hdr->firstused, ARCH_CONVERT));
- ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp));
+ ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused));
+ ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
/*
* Scan through free region table:
@@ -1707,33 +1663,30 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
* find smallest free region in case we need to replace it,
* adjust any map that borders the entry table,
*/
- tablesize = INT_GET(hdr->count, ARCH_CONVERT)
- * sizeof(xfs_attr_leaf_entry_t)
+ tablesize = be16_to_cpu(hdr->count) * sizeof(xfs_attr_leaf_entry_t)
+ sizeof(xfs_attr_leaf_hdr_t);
map = &hdr->freemap[0];
- tmp = INT_GET(map->size, ARCH_CONVERT);
+ tmp = be16_to_cpu(map->size);
before = after = -1;
smallest = XFS_ATTR_LEAF_MAPSIZE - 1;
entsize = xfs_attr_leaf_entsize(leaf, args->index);
for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; map++, i++) {
- ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
- ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
- if (INT_GET(map->base, ARCH_CONVERT) == tablesize) {
- INT_MOD(map->base, ARCH_CONVERT,
- -sizeof(xfs_attr_leaf_entry_t));
- INT_MOD(map->size, ARCH_CONVERT,
- sizeof(xfs_attr_leaf_entry_t));
+ ASSERT(be16_to_cpu(map->base) < XFS_LBSIZE(mp));
+ ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
+ if (be16_to_cpu(map->base) == tablesize) {
+ be16_add(&map->base,
+ -((int)sizeof(xfs_attr_leaf_entry_t)));
+ be16_add(&map->size, sizeof(xfs_attr_leaf_entry_t));
}
- if ((INT_GET(map->base, ARCH_CONVERT)
- + INT_GET(map->size, ARCH_CONVERT))
- == INT_GET(entry->nameidx, ARCH_CONVERT)) {
+ if ((be16_to_cpu(map->base) + be16_to_cpu(map->size))
+ == be16_to_cpu(entry->nameidx)) {
before = i;
- } else if (INT_GET(map->base, ARCH_CONVERT)
- == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) {
+ } else if (be16_to_cpu(map->base)
+ == (be16_to_cpu(entry->nameidx) + entsize)) {
after = i;
- } else if (INT_GET(map->size, ARCH_CONVERT) < tmp) {
- tmp = INT_GET(map->size, ARCH_CONVERT);
+ } else if (be16_to_cpu(map->size) < tmp) {
+ tmp = be16_to_cpu(map->size);
smallest = i;
}
}
@@ -1745,38 +1698,35 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
if ((before >= 0) || (after >= 0)) {
if ((before >= 0) && (after >= 0)) {
map = &hdr->freemap[before];
- INT_MOD(map->size, ARCH_CONVERT, entsize);
- INT_MOD(map->size, ARCH_CONVERT,
- INT_GET(hdr->freemap[after].size,
- ARCH_CONVERT));
+ be16_add(&map->size, entsize);
+ be16_add(&map->size,
+ be16_to_cpu(hdr->freemap[after].size));
hdr->freemap[after].base = 0;
hdr->freemap[after].size = 0;
} else if (before >= 0) {
map = &hdr->freemap[before];
- INT_MOD(map->size, ARCH_CONVERT, entsize);
+ be16_add(&map->size, entsize);
} else {
map = &hdr->freemap[after];
/* both on-disk, don't endian flip twice */
map->base = entry->nameidx;
- INT_MOD(map->size, ARCH_CONVERT, entsize);
+ be16_add(&map->size, entsize);
}
} else {
/*
* Replace smallest region (if it is smaller than free'd entry)
*/
map = &hdr->freemap[smallest];
- if (INT_GET(map->size, ARCH_CONVERT) < entsize) {
- INT_SET(map->base, ARCH_CONVERT,
- INT_GET(entry->nameidx, ARCH_CONVERT));
- INT_SET(map->size, ARCH_CONVERT, entsize);
+ if (be16_to_cpu(map->size) < entsize) {
+ map->base = cpu_to_be16(be16_to_cpu(entry->nameidx));
+ map->size = cpu_to_be16(entsize);
}
}
/*
* Did we remove the first entry?
*/
- if (INT_GET(entry->nameidx, ARCH_CONVERT)
- == INT_GET(hdr->firstused, ARCH_CONVERT))
+ if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused))
smallest = 1;
else
smallest = 0;
@@ -1785,18 +1735,18 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
* Compress the remaining entries and zero out the removed stuff.
*/
memset(XFS_ATTR_LEAF_NAME(leaf, args->index), 0, entsize);
- INT_MOD(hdr->usedbytes, ARCH_CONVERT, -entsize);
+ be16_add(&hdr->usedbytes, -entsize);
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, XFS_ATTR_LEAF_NAME(leaf, args->index),
entsize));
- tmp = (INT_GET(hdr->count, ARCH_CONVERT) - args->index)
+ tmp = (be16_to_cpu(hdr->count) - args->index)
* sizeof(xfs_attr_leaf_entry_t);
memmove((char *)entry, (char *)(entry+1), tmp);
- INT_MOD(hdr->count, ARCH_CONVERT, -1);
+ be16_add(&hdr->count, -1);
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, entry, tmp + sizeof(*entry)));
- entry = &leaf->entries[INT_GET(hdr->count, ARCH_CONVERT)];
+ entry = &leaf->entries[be16_to_cpu(hdr->count)];
memset((char *)entry, 0, sizeof(xfs_attr_leaf_entry_t));
/*
@@ -1808,18 +1758,17 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
if (smallest) {
tmp = XFS_LBSIZE(mp);
entry = &leaf->entries[0];
- for (i = INT_GET(hdr->count, ARCH_CONVERT)-1;
- i >= 0; entry++, i--) {
- ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
- >= INT_GET(hdr->firstused, ARCH_CONVERT));
- ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT)
- < XFS_LBSIZE(mp));
- if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp)
- tmp = INT_GET(entry->nameidx, ARCH_CONVERT);
+ for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) {
+ ASSERT(be16_to_cpu(entry->nameidx) >=
+ be16_to_cpu(hdr->firstused));
+ ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
+
+ if (be16_to_cpu(entry->nameidx) < tmp)
+ tmp = be16_to_cpu(entry->nameidx);
}
- INT_SET(hdr->firstused, ARCH_CONVERT, tmp);
+ hdr->firstused = cpu_to_be16(tmp);
if (!hdr->firstused) {
- INT_SET(hdr->firstused, ARCH_CONVERT,
+ hdr->firstused = cpu_to_be16(
tmp - XFS_ATTR_LEAF_NAME_ALIGN);
}
} else {
@@ -1833,9 +1782,8 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
* "join" the leaf with a sibling if so.
*/
tmp = sizeof(xfs_attr_leaf_hdr_t);
- tmp += INT_GET(leaf->hdr.count, ARCH_CONVERT)
- * sizeof(xfs_attr_leaf_entry_t);
- tmp += INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
+ tmp += be16_to_cpu(leaf->hdr.count) * sizeof(xfs_attr_leaf_entry_t);
+ tmp += be16_to_cpu(leaf->hdr.usedbytes);
return(tmp < mp->m_attr_magicpct); /* leaf is < 37% full */
}
@@ -1859,20 +1807,16 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
- ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr;
/*
* Save last hashval from dying block for later Btree fixup.
*/
- drop_blk->hashval =
- INT_GET(drop_leaf->entries[INT_GET(drop_leaf->hdr.count,
- ARCH_CONVERT)-1].hashval,
- ARCH_CONVERT);
+ drop_blk->hashval = be32_to_cpu(
+ drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval);
/*
* Check if we need a temp buffer, or can we do it in place.
@@ -1886,12 +1830,11 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
*/
if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) {
xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf, 0,
- (int)INT_GET(drop_hdr->count, ARCH_CONVERT), mp);
+ be16_to_cpu(drop_hdr->count), mp);
} else {
xfs_attr_leaf_moveents(drop_leaf, 0, save_leaf,
- INT_GET(save_hdr->count, ARCH_CONVERT),
- (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
- mp);
+ be16_to_cpu(save_hdr->count),
+ be16_to_cpu(drop_hdr->count), mp);
}
} else {
/*
@@ -1905,28 +1848,24 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
tmp_hdr = &tmp_leaf->hdr;
tmp_hdr->info = save_hdr->info; /* struct copy */
tmp_hdr->count = 0;
- INT_SET(tmp_hdr->firstused, ARCH_CONVERT, state->blocksize);
+ tmp_hdr->firstused = cpu_to_be16(state->blocksize);
if (!tmp_hdr->firstused) {
- INT_SET(tmp_hdr->firstused, ARCH_CONVERT,
+ tmp_hdr->firstused = cpu_to_be16(
state->blocksize - XFS_ATTR_LEAF_NAME_ALIGN);
}
tmp_hdr->usedbytes = 0;
if (xfs_attr_leaf_order(save_blk->bp, drop_blk->bp)) {
xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf, 0,
- (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
- mp);
+ be16_to_cpu(drop_hdr->count), mp);
xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf,
- INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT),
- (int)INT_GET(save_hdr->count, ARCH_CONVERT),
- mp);
+ be16_to_cpu(tmp_leaf->hdr.count),
+ be16_to_cpu(save_hdr->count), mp);
} else {
xfs_attr_leaf_moveents(save_leaf, 0, tmp_leaf, 0,
- (int)INT_GET(save_hdr->count, ARCH_CONVERT),
- mp);
+ be16_to_cpu(save_hdr->count), mp);
xfs_attr_leaf_moveents(drop_leaf, 0, tmp_leaf,
- INT_GET(tmp_leaf->hdr.count, ARCH_CONVERT),
- (int)INT_GET(drop_hdr->count, ARCH_CONVERT),
- mp);
+ be16_to_cpu(tmp_leaf->hdr.count),
+ be16_to_cpu(drop_hdr->count), mp);
}
memcpy((char *)save_leaf, (char *)tmp_leaf, state->blocksize);
kmem_free(tmpbuffer, state->blocksize);
@@ -1938,10 +1877,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
/*
* Copy out last hashval in each block for B-tree code.
*/
- save_blk->hashval =
- INT_GET(save_leaf->entries[INT_GET(save_leaf->hdr.count,
- ARCH_CONVERT)-1].hashval,
- ARCH_CONVERT);
+ save_blk->hashval = be32_to_cpu(
+ save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1].hashval);
}
/*========================================================================
@@ -1972,48 +1909,45 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_dahash_t hashval;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.count)
< (XFS_LBSIZE(args->dp->i_mount)/8));
/*
* Binary search. (note: small blocks will skip this loop)
*/
hashval = args->hashval;
- probe = span = INT_GET(leaf->hdr.count, ARCH_CONVERT) / 2;
+ probe = span = be16_to_cpu(leaf->hdr.count) / 2;
for (entry = &leaf->entries[probe]; span > 4;
entry = &leaf->entries[probe]) {
span /= 2;
- if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)
+ if (be32_to_cpu(entry->hashval) < hashval)
probe += span;
- else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval)
+ else if (be32_to_cpu(entry->hashval) > hashval)
probe -= span;
else
break;
}
ASSERT((probe >= 0) &&
(!leaf->hdr.count
- || (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))));
- ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT)
- == hashval));
+ || (probe < be16_to_cpu(leaf->hdr.count))));
+ ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval));
/*
* Since we may have duplicate hashval's, find the first matching
* hashval in the leaf.
*/
- while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT)
- >= hashval)) {
+ while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) {
entry--;
probe--;
}
- while ((probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))
- && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) {
+ while ((probe < be16_to_cpu(leaf->hdr.count)) &&
+ (be32_to_cpu(entry->hashval) < hashval)) {
entry++;
probe++;
}
- if ((probe == INT_GET(leaf->hdr.count, ARCH_CONVERT))
- || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) {
+ if ((probe == be16_to_cpu(leaf->hdr.count)) ||
+ (be32_to_cpu(entry->hashval) != hashval)) {
args->index = probe;
return(XFS_ERROR(ENOATTR));
}
@@ -2021,8 +1955,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
/*
* Duplicate keys may be present, so search all of them for a match.
*/
- for ( ; (probe < INT_GET(leaf->hdr.count, ARCH_CONVERT))
- && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval);
+ for ( ; (probe < be16_to_cpu(leaf->hdr.count)) &&
+ (be32_to_cpu(entry->hashval) == hashval);
entry++, probe++) {
/*
* GROT: Add code to remove incomplete entries.
@@ -2064,11 +1998,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
((entry->flags & XFS_ATTR_ROOT) != 0))
continue;
args->index = probe;
- args->rmtblkno
- = INT_GET(name_rmt->valueblk, ARCH_CONVERT);
+ args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount,
- INT_GET(name_rmt->valuelen,
- ARCH_CONVERT));
+ be32_to_cpu(name_rmt->valuelen));
return(XFS_ERROR(EEXIST));
}
}
@@ -2090,18 +2022,17 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_attr_leaf_name_remote_t *name_rmt;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.count)
< (XFS_LBSIZE(args->dp->i_mount)/8));
- ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT)));
+ ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
entry = &leaf->entries[args->index];
if (entry->flags & XFS_ATTR_LOCAL) {
name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, args->index);
ASSERT(name_loc->namelen == args->namelen);
ASSERT(memcmp(args->name, name_loc->nameval, args->namelen) == 0);
- valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT);
+ valuelen = be16_to_cpu(name_loc->valuelen);
if (args->flags & ATTR_KERNOVAL) {
args->valuelen = valuelen;
return(0);
@@ -2116,8 +2047,8 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
ASSERT(name_rmt->namelen == args->namelen);
ASSERT(memcmp(args->name, name_rmt->name, args->namelen) == 0);
- valuelen = INT_GET(name_rmt->valuelen, ARCH_CONVERT);
- args->rmtblkno = INT_GET(name_rmt->valueblk, ARCH_CONVERT);
+ valuelen = be32_to_cpu(name_rmt->valuelen);
+ args->rmtblkno = be32_to_cpu(name_rmt->valueblk);
args->rmtblkcnt = XFS_B_TO_FSB(args->dp->i_mount, valuelen);
if (args->flags & ATTR_KERNOVAL) {
args->valuelen = valuelen;
@@ -2159,32 +2090,29 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/*
* Set up environment.
*/
- ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr;
- ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0)
- && (INT_GET(hdr_s->count, ARCH_CONVERT)
- < (XFS_LBSIZE(mp)/8)));
- ASSERT(INT_GET(hdr_s->firstused, ARCH_CONVERT) >=
- ((INT_GET(hdr_s->count, ARCH_CONVERT)
+ ASSERT((be16_to_cpu(hdr_s->count) > 0) &&
+ (be16_to_cpu(hdr_s->count) < (XFS_LBSIZE(mp)/8)));
+ ASSERT(be16_to_cpu(hdr_s->firstused) >=
+ ((be16_to_cpu(hdr_s->count)
* sizeof(*entry_s))+sizeof(*hdr_s)));
- ASSERT(INT_GET(hdr_d->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8));
- ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >=
- ((INT_GET(hdr_d->count, ARCH_CONVERT)
+ ASSERT(be16_to_cpu(hdr_d->count) < (XFS_LBSIZE(mp)/8));
+ ASSERT(be16_to_cpu(hdr_d->firstused) >=
+ ((be16_to_cpu(hdr_d->count)
* sizeof(*entry_d))+sizeof(*hdr_d)));
- ASSERT(start_s < INT_GET(hdr_s->count, ARCH_CONVERT));
- ASSERT(start_d <= INT_GET(hdr_d->count, ARCH_CONVERT));
- ASSERT(count <= INT_GET(hdr_s->count, ARCH_CONVERT));
+ ASSERT(start_s < be16_to_cpu(hdr_s->count));
+ ASSERT(start_d <= be16_to_cpu(hdr_d->count));
+ ASSERT(count <= be16_to_cpu(hdr_s->count));
/*
* Move the entries in the destination leaf up to make a hole?
*/
- if (start_d < INT_GET(hdr_d->count, ARCH_CONVERT)) {
- tmp = INT_GET(hdr_d->count, ARCH_CONVERT) - start_d;
+ if (start_d < be16_to_cpu(hdr_d->count)) {
+ tmp = be16_to_cpu(hdr_d->count) - start_d;
tmp *= sizeof(xfs_attr_leaf_entry_t);
entry_s = &leaf_d->entries[start_d];
entry_d = &leaf_d->entries[start_d + count];
@@ -2199,8 +2127,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
entry_d = &leaf_d->entries[start_d];
desti = start_d;
for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) {
- ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT)
- >= INT_GET(hdr_s->firstused, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(entry_s->nameidx)
+ >= be16_to_cpu(hdr_s->firstused));
tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i);
#ifdef GROT
/*
@@ -2210,35 +2138,35 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
*/
if (entry_s->flags & XFS_ATTR_INCOMPLETE) { /* skip partials? */
memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
- INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp);
- INT_MOD(hdr_s->count, ARCH_CONVERT, -1);
+ be16_add(&hdr_s->usedbytes, -tmp);
+ be16_add(&hdr_s->count, -1);
entry_d--; /* to compensate for ++ in loop hdr */
desti--;
if ((start_s + i) < offset)
result++; /* insertion index adjustment */
} else {
#endif /* GROT */
- INT_MOD(hdr_d->firstused, ARCH_CONVERT, -tmp);
+ be16_add(&hdr_d->firstused, -tmp);
/* both on-disk, don't endian flip twice */
entry_d->hashval = entry_s->hashval;
/* both on-disk, don't endian flip twice */
entry_d->nameidx = hdr_d->firstused;
entry_d->flags = entry_s->flags;
- ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp
+ ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
<= XFS_LBSIZE(mp));
memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti),
XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp);
- ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp
+ ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
<= XFS_LBSIZE(mp));
memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
- INT_MOD(hdr_s->usedbytes, ARCH_CONVERT, -tmp);
- INT_MOD(hdr_d->usedbytes, ARCH_CONVERT, tmp);
- INT_MOD(hdr_s->count, ARCH_CONVERT, -1);
- INT_MOD(hdr_d->count, ARCH_CONVERT, 1);
- tmp = INT_GET(hdr_d->count, ARCH_CONVERT)
+ be16_add(&hdr_s->usedbytes, -tmp);
+ be16_add(&hdr_d->usedbytes, tmp);
+ be16_add(&hdr_s->count, -1);
+ be16_add(&hdr_d->count, 1);
+ tmp = be16_to_cpu(hdr_d->count)
* sizeof(xfs_attr_leaf_entry_t)
+ sizeof(xfs_attr_leaf_hdr_t);
- ASSERT(INT_GET(hdr_d->firstused, ARCH_CONVERT) >= tmp);
+ ASSERT(be16_to_cpu(hdr_d->firstused) >= tmp);
#ifdef GROT
}
#endif /* GROT */
@@ -2247,7 +2175,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/*
* Zero out the entries we just copied.
*/
- if (start_s == INT_GET(hdr_s->count, ARCH_CONVERT)) {
+ if (start_s == be16_to_cpu(hdr_s->count)) {
tmp = count * sizeof(xfs_attr_leaf_entry_t);
entry_s = &leaf_s->entries[start_s];
ASSERT(((char *)entry_s + tmp) <=
@@ -2258,15 +2186,14 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
* Move the remaining entries down to fill the hole,
* then zero the entries at the top.
*/
- tmp = INT_GET(hdr_s->count, ARCH_CONVERT) - count;
+ tmp = be16_to_cpu(hdr_s->count) - count;
tmp *= sizeof(xfs_attr_leaf_entry_t);
entry_s = &leaf_s->entries[start_s + count];
entry_d = &leaf_s->entries[start_s];
memmove((char *)entry_d, (char *)entry_s, tmp);
tmp = count * sizeof(xfs_attr_leaf_entry_t);
- entry_s = &leaf_s->entries[INT_GET(hdr_s->count,
- ARCH_CONVERT)];
+ entry_s = &leaf_s->entries[be16_to_cpu(hdr_s->count)];
ASSERT(((char *)entry_s + tmp) <=
((char *)leaf_s + XFS_LBSIZE(mp)));
memset((char *)entry_s, 0, tmp);
@@ -2275,14 +2202,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/*
* Fill in the freemap information
*/
- INT_SET(hdr_d->freemap[0].base, ARCH_CONVERT,
- sizeof(xfs_attr_leaf_hdr_t));
- INT_MOD(hdr_d->freemap[0].base, ARCH_CONVERT,
- INT_GET(hdr_d->count, ARCH_CONVERT)
- * sizeof(xfs_attr_leaf_entry_t));
- INT_SET(hdr_d->freemap[0].size, ARCH_CONVERT,
- INT_GET(hdr_d->firstused, ARCH_CONVERT)
- - INT_GET(hdr_d->freemap[0].base, ARCH_CONVERT));
+ hdr_d->freemap[0].base = cpu_to_be16(sizeof(xfs_attr_leaf_hdr_t));
+ be16_add(&hdr_d->freemap[0].base, be16_to_cpu(hdr_d->count) *
+ sizeof(xfs_attr_leaf_entry_t));
+ hdr_d->freemap[0].size = cpu_to_be16(be16_to_cpu(hdr_d->firstused)
+ - be16_to_cpu(hdr_d->freemap[0].base));
hdr_d->freemap[1].base = 0;
hdr_d->freemap[2].base = 0;
hdr_d->freemap[1].size = 0;
@@ -2301,18 +2225,16 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data;
- ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC) &&
- (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC));
- if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0)
- && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0)
- && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
- INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT))
- || (INT_GET(leaf2->entries[INT_GET(leaf2->hdr.count,
- ARCH_CONVERT)-1].hashval, ARCH_CONVERT) <
- INT_GET(leaf1->entries[INT_GET(leaf1->hdr.count,
- ARCH_CONVERT)-1].hashval, ARCH_CONVERT))) ) {
+ ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) &&
+ (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC));
+ if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
+ (be16_to_cpu(leaf2->hdr.count) > 0) &&
+ ((be32_to_cpu(leaf2->entries[0].hashval) <
+ be32_to_cpu(leaf1->entries[0].hashval)) ||
+ (be32_to_cpu(leaf2->entries[
+ be16_to_cpu(leaf2->hdr.count)-1].hashval) <
+ be32_to_cpu(leaf1->entries[
+ be16_to_cpu(leaf1->hdr.count)-1].hashval)))) {
return(1);
}
return(0);
@@ -2327,14 +2249,12 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
xfs_attr_leafblock_t *leaf;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
if (count)
- *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count)
return(0);
- return(INT_GET(leaf->entries[INT_GET(leaf->hdr.count,
- ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+ return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval);
}
/*
@@ -2348,13 +2268,11 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
xfs_attr_leaf_name_remote_t *name_rmt;
int size;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index);
size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen,
- INT_GET(name_loc->valuelen,
- ARCH_CONVERT));
+ be16_to_cpu(name_loc->valuelen));
} else {
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, index);
size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(name_rmt->namelen);
@@ -2412,22 +2330,20 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
*/
if (context->resynch) {
entry = &leaf->entries[0];
- for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT);
- entry++, i++) {
- if (INT_GET(entry->hashval, ARCH_CONVERT)
- == cursor->hashval) {
+ for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+ if (be32_to_cpu(entry->hashval) == cursor->hashval) {
if (cursor->offset == context->dupcnt) {
context->dupcnt = 0;
break;
}
context->dupcnt++;
- } else if (INT_GET(entry->hashval, ARCH_CONVERT)
- > cursor->hashval) {
+ } else if (be32_to_cpu(entry->hashval) >
+ cursor->hashval) {
context->dupcnt = 0;
break;
}
}
- if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
+ if (i == be16_to_cpu(leaf->hdr.count)) {
xfs_attr_trace_l_c("not found", context);
return(0);
}
@@ -2441,12 +2357,12 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
* We have found our place, start copying out the new attributes.
*/
retval = 0;
- for ( ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT))
+ for ( ; (i < be16_to_cpu(leaf->hdr.count))
&& (retval == 0); entry++, i++) {
attrnames_t *namesp;
- if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) {
- cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT);
+ if (be32_to_cpu(entry->hashval) != cursor->hashval) {
+ cursor->hashval = be32_to_cpu(entry->hashval);
cursor->offset = 0;
}
@@ -2475,8 +2391,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
retval = xfs_attr_put_listent(context, namesp,
(char *)name_loc->nameval,
(int)name_loc->namelen,
- (int)INT_GET(name_loc->valuelen,
- ARCH_CONVERT));
+ be16_to_cpu(name_loc->valuelen));
}
} else {
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
@@ -2488,8 +2403,7 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
retval = xfs_attr_put_listent(context, namesp,
(char *)name_rmt->name,
(int)name_rmt->namelen,
- (int)INT_GET(name_rmt->valuelen,
- ARCH_CONVERT));
+ be32_to_cpu(name_rmt->valuelen));
}
}
if (retval == 0) {
@@ -2596,9 +2510,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
ASSERT(bp != NULL);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ];
ASSERT(entry->flags & XFS_ATTR_INCOMPLETE);
@@ -2613,7 +2526,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
namelen = name_rmt->namelen;
name = (char *)name_rmt->name;
}
- ASSERT(INT_GET(entry->hashval, ARCH_CONVERT) == args->hashval);
+ ASSERT(be32_to_cpu(entry->hashval) == args->hashval);
ASSERT(namelen == args->namelen);
ASSERT(memcmp(name, args->name, namelen) == 0);
#endif /* DEBUG */
@@ -2625,8 +2538,8 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
if (args->rmtblkno) {
ASSERT((entry->flags & XFS_ATTR_LOCAL) == 0);
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, args->index);
- INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno);
- INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen);
+ name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
+ name_rmt->valuelen = cpu_to_be32(args->valuelen);
xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, name_rmt, sizeof(*name_rmt)));
}
@@ -2663,9 +2576,8 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
ASSERT(bp != NULL);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ];
@@ -2736,16 +2648,14 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
}
leaf1 = bp1->data;
- ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(args->index < be16_to_cpu(leaf1->hdr.count));
ASSERT(args->index >= 0);
entry1 = &leaf1->entries[ args->index ];
leaf2 = bp2->data;
- ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
- ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count));
ASSERT(args->index2 >= 0);
entry2 = &leaf2->entries[ args->index2 ];
@@ -2768,7 +2678,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
namelen2 = name_rmt->namelen;
name2 = (char *)name_rmt->name;
}
- ASSERT(INT_GET(entry1->hashval, ARCH_CONVERT) == INT_GET(entry2->hashval, ARCH_CONVERT));
+ ASSERT(be32_to_cpu(entry1->hashval) == be32_to_cpu(entry2->hashval));
ASSERT(namelen1 == namelen2);
ASSERT(memcmp(name1, name2, namelen1) == 0);
#endif /* DEBUG */
@@ -2782,8 +2692,8 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
if (args->rmtblkno) {
ASSERT((entry1->flags & XFS_ATTR_LOCAL) == 0);
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf1, args->index);
- INT_SET(name_rmt->valueblk, ARCH_CONVERT, args->rmtblkno);
- INT_SET(name_rmt->valuelen, ARCH_CONVERT, args->valuelen);
+ name_rmt->valueblk = cpu_to_be32(args->rmtblkno);
+ name_rmt->valuelen = cpu_to_be32(args->valuelen);
xfs_da_log_buf(args->trans, bp1,
XFS_DA_LOGRANGE(leaf1, name_rmt, sizeof(*name_rmt)));
}
@@ -2842,9 +2752,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
* This is a depth-first traversal!
*/
info = bp->data;
- if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
+ if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
error = xfs_attr_node_inactive(trans, dp, bp, 1);
- } else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
+ } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) {
error = xfs_attr_leaf_inactive(trans, dp, bp);
} else {
error = XFS_ERROR(EIO);
@@ -2892,15 +2802,14 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
}
node = bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
- == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
parent_blkno = xfs_da_blkno(bp); /* save for re-read later */
- count = INT_GET(node->hdr.count, ARCH_CONVERT);
+ count = be16_to_cpu(node->hdr.count);
if (!count) {
xfs_da_brelse(*trans, bp);
return(0);
}
- child_fsb = INT_GET(node->btree[0].before, ARCH_CONVERT);
+ child_fsb = be32_to_cpu(node->btree[0].before);
xfs_da_brelse(*trans, bp); /* no locks for later trans */
/*
@@ -2927,12 +2836,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
* Invalidate the subtree, however we have to.
*/
info = child_bp->data;
- if (INT_GET(info->magic, ARCH_CONVERT)
- == XFS_DA_NODE_MAGIC) {
+ if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
error = xfs_attr_node_inactive(trans, dp,
child_bp, level+1);
- } else if (INT_GET(info->magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC) {
+ } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) {
error = xfs_attr_leaf_inactive(trans, dp,
child_bp);
} else {
@@ -2962,7 +2869,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
&bp, XFS_ATTR_FORK);
if (error)
return(error);
- child_fsb = INT_GET(node->btree[i+1].before, ARCH_CONVERT);
+ child_fsb = be32_to_cpu(node->btree[i+1].before);
xfs_da_brelse(*trans, bp);
}
/*
@@ -2991,17 +2898,16 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
int error, count, size, tmp, i;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
- == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
/*
* Count the number of "remote" value extents.
*/
count = 0;
entry = &leaf->entries[0];
- for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
- if ( INT_GET(entry->nameidx, ARCH_CONVERT)
- && ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
+ for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+ if (be16_to_cpu(entry->nameidx) &&
+ ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
if (name_rmt->valueblk)
count++;
@@ -3027,17 +2933,14 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
*/
lp = list;
entry = &leaf->entries[0];
- for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
- if ( INT_GET(entry->nameidx, ARCH_CONVERT)
- && ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
+ for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
+ if (be16_to_cpu(entry->nameidx) &&
+ ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
if (name_rmt->valueblk) {
- /* both on-disk, don't endian flip twice */
- lp->valueblk = name_rmt->valueblk;
- INT_SET(lp->valuelen, ARCH_CONVERT,
- XFS_B_TO_FSB(dp->i_mount,
- INT_GET(name_rmt->valuelen,
- ARCH_CONVERT)));
+ lp->valueblk = be32_to_cpu(name_rmt->valueblk);
+ lp->valuelen = XFS_B_TO_FSB(dp->i_mount,
+ be32_to_cpu(name_rmt->valuelen));
lp++;
}
}
@@ -3050,10 +2953,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
error = 0;
for (lp = list, i = 0; i < count; i++, lp++) {
tmp = xfs_attr_leaf_freextent(trans, dp,
- INT_GET(lp->valueblk,
- ARCH_CONVERT),
- INT_GET(lp->valuelen,
- ARCH_CONVERT));
+ lp->valueblk, lp->valuelen);
+
if (error == 0)
error = tmp; /* save only the 1st errno */
}
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 541e34109bb..51c3ee156b2 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -73,39 +73,39 @@ struct xfs_trans;
#define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */
typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */
- __uint16_t base; /* base of free region */
- __uint16_t size; /* length of free region */
+ __be16 base; /* base of free region */
+ __be16 size; /* length of free region */
} xfs_attr_leaf_map_t;
typedef struct xfs_attr_leaf_hdr { /* constant-structure header block */
xfs_da_blkinfo_t info; /* block type, links, etc. */
- __uint16_t count; /* count of active leaf_entry's */
- __uint16_t usedbytes; /* num bytes of names/values stored */
- __uint16_t firstused; /* first used byte in name area */
- __uint8_t holes; /* != 0 if blk needs compaction */
- __uint8_t pad1;
+ __be16 count; /* count of active leaf_entry's */
+ __be16 usedbytes; /* num bytes of names/values stored */
+ __be16 firstused; /* first used byte in name area */
+ __u8 holes; /* != 0 if blk needs compaction */
+ __u8 pad1;
xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE];
/* N largest free regions */
} xfs_attr_leaf_hdr_t;
typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */
- xfs_dahash_t hashval; /* hash value of name */
- __uint16_t nameidx; /* index into buffer of name/value */
- __uint8_t flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
- __uint8_t pad2; /* unused pad byte */
+ __be32 hashval; /* hash value of name */
+ __be16 nameidx; /* index into buffer of name/value */
+ __u8 flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
+ __u8 pad2; /* unused pad byte */
} xfs_attr_leaf_entry_t;
typedef struct xfs_attr_leaf_name_local {
- __uint16_t valuelen; /* number of bytes in value */
- __uint8_t namelen; /* length of name bytes */
- __uint8_t nameval[1]; /* name/value bytes */
+ __be16 valuelen; /* number of bytes in value */
+ __u8 namelen; /* length of name bytes */
+ __u8 nameval[1]; /* name/value bytes */
} xfs_attr_leaf_name_local_t;
typedef struct xfs_attr_leaf_name_remote {
- xfs_dablk_t valueblk; /* block number of value bytes */
- __uint32_t valuelen; /* number of bytes in value */
- __uint8_t namelen; /* length of name bytes */
- __uint8_t name[1]; /* name bytes */
+ __be32 valueblk; /* block number of value bytes */
+ __be32 valuelen; /* number of bytes in value */
+ __u8 namelen; /* length of name bytes */
+ __u8 name[1]; /* name bytes */
} xfs_attr_leaf_name_remote_t;
typedef struct xfs_attr_leafblock {
@@ -143,8 +143,8 @@ typedef struct xfs_attr_leafblock {
static inline xfs_attr_leaf_name_remote_t *
xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
{
- return (xfs_attr_leaf_name_remote_t *) &((char *)
- (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
+ return (xfs_attr_leaf_name_remote_t *)
+ &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
}
#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
@@ -152,16 +152,15 @@ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
static inline xfs_attr_leaf_name_local_t *
xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
{
- return (xfs_attr_leaf_name_local_t *) &((char *)
- (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)];
+ return (xfs_attr_leaf_name_local_t *)
+ &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
}
#define XFS_ATTR_LEAF_NAME(leafp,idx) \
xfs_attr_leaf_name(leafp,idx)
static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
{
- return (&((char *)
- (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]);
+ return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
}
/*
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h
index ffed6ca81a5..f67f917803b 100644
--- a/fs/xfs/xfs_attr_sf.h
+++ b/fs/xfs/xfs_attr_sf.h
@@ -32,8 +32,8 @@ struct xfs_inode;
*/
typedef struct xfs_attr_shortform {
struct xfs_attr_sf_hdr { /* constant-structure header block */
- __uint16_t totsize; /* total bytes in shortform list */
- __uint8_t count; /* count of active entries */
+ __be16 totsize; /* total bytes in shortform list */
+ __u8 count; /* count of active entries */
} hdr;
struct xfs_attr_sf_entry {
__uint8_t namelen; /* actual length of name (no NULL) */
@@ -66,8 +66,8 @@ typedef struct xfs_attr_sf_sort {
#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
- (INT_GET(((xfs_attr_shortform_t *) \
- ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
+ (be16_to_cpu(((xfs_attr_shortform_t *) \
+ ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
#if defined(XFS_ATTR_TRACE)
/*
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 70625e577c7..2d702e4a74a 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -89,7 +89,7 @@ xfs_bmap_add_attrfork_local(
int *flags); /* inode logging flags */
/*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
* after allocating space (or doing a delayed allocation).
*/
STATIC int /* error */
@@ -97,7 +97,7 @@ xfs_bmap_add_extent(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
xfs_fsblock_t *first, /* pointer to firstblock variable */
xfs_bmap_free_t *flist, /* list of extents to be freed */
int *logflagsp, /* inode logging flags */
@@ -113,7 +113,7 @@ xfs_bmap_add_extent_delay_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */
xfs_fsblock_t *first, /* pointer to firstblock variable */
xfs_bmap_free_t *flist, /* list of extents to be freed */
@@ -129,7 +129,7 @@ xfs_bmap_add_extent_hole_delay(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp,/* inode logging flags */
int rsvd); /* OK to allocate reserved blocks */
@@ -142,7 +142,7 @@ xfs_bmap_add_extent_hole_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp, /* inode logging flags */
int whichfork); /* data or attr fork */
@@ -155,7 +155,7 @@ xfs_bmap_add_extent_unwritten_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp); /* inode logging flags */
/*
@@ -169,7 +169,7 @@ xfs_bmap_alloc(
/*
* Transform a btree format file with only one leaf node, where the
* extents list will fit in the inode, into an extents format file.
- * Since the extent list is already in-core, all we have to do is
+ * Since the file extents are already in-core, all we have to do is
* give up the space for the btree root and pitch the leaf block.
*/
STATIC int /* error */
@@ -191,7 +191,7 @@ xfs_bmap_check_extents(
#endif
/*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
* after removing space (or undoing a delayed allocation).
*/
STATIC int /* error */
@@ -201,7 +201,7 @@ xfs_bmap_del_extent(
xfs_extnum_t idx, /* extent number to update/insert */
xfs_bmap_free_t *flist, /* list of extents to be freed */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp,/* inode logging flags */
int whichfork, /* data or attr fork */
int rsvd); /* OK to allocate reserved blocks */
@@ -217,18 +217,6 @@ xfs_bmap_del_free(
xfs_bmap_free_item_t *free); /* list item to be freed */
/*
- * Remove count entries from the extents array for inode "ip", starting
- * at index "idx". Copies the remaining items down over the deleted ones,
- * and gives back the excess memory.
- */
-STATIC void
-xfs_bmap_delete_exlist(
- xfs_inode_t *ip, /* incode inode pointer */
- xfs_extnum_t idx, /* starting delete index */
- xfs_extnum_t count, /* count of items to delete */
- int whichfork); /* data or attr fork */
-
-/*
* Convert an extents-format file into a btree-format file.
* The new file will have a root block (in the inode) and a single child block.
*/
@@ -244,18 +232,6 @@ xfs_bmap_extents_to_btree(
int whichfork); /* data or attr fork */
/*
- * Insert new item(s) in the extent list for inode "ip".
- * Count new items are inserted at offset idx.
- */
-STATIC void
-xfs_bmap_insert_exlist(
- xfs_inode_t *ip, /* incore inode pointer */
- xfs_extnum_t idx, /* starting index of new items */
- xfs_extnum_t count, /* number of inserted items */
- xfs_bmbt_irec_t *new, /* items to insert */
- int whichfork); /* data or attr fork */
-
-/*
* Convert a local file to an extents file.
* This code is sort of bogus, since the file data needs to get
* logged so it won't be lost. The bmap-level manipulations are ok, though.
@@ -316,7 +292,7 @@ xfs_bmap_trace_addentry(
int whichfork); /* data or attr fork */
/*
- * Add bmap trace entry prior to a call to xfs_bmap_delete_exlist.
+ * Add bmap trace entry prior to a call to xfs_iext_remove.
*/
STATIC void
xfs_bmap_trace_delete(
@@ -328,7 +304,7 @@ xfs_bmap_trace_delete(
int whichfork); /* data or attr fork */
/*
- * Add bmap trace entry prior to a call to xfs_bmap_insert_exlist, or
+ * Add bmap trace entry prior to a call to xfs_iext_insert, or
* reading in the extents list from the disk (in the btree).
*/
STATIC void
@@ -343,7 +319,7 @@ xfs_bmap_trace_insert(
int whichfork); /* data or attr fork */
/*
- * Add bmap trace entry after updating an extent list entry in place.
+ * Add bmap trace entry after updating an extent record in place.
*/
STATIC void
xfs_bmap_trace_post_update(
@@ -354,7 +330,7 @@ xfs_bmap_trace_post_update(
int whichfork); /* data or attr fork */
/*
- * Add bmap trace entry prior to updating an extent list entry in place.
+ * Add bmap trace entry prior to updating an extent record in place.
*/
STATIC void
xfs_bmap_trace_pre_update(
@@ -413,19 +389,24 @@ STATIC int
xfs_bmap_count_tree(
xfs_mount_t *mp,
xfs_trans_t *tp,
+ xfs_ifork_t *ifp,
xfs_fsblock_t blockno,
int levelin,
int *count);
STATIC int
xfs_bmap_count_leaves(
- xfs_bmbt_rec_t *frp,
+ xfs_ifork_t *ifp,
+ xfs_extnum_t idx,
int numrecs,
int *count);
STATIC int
xfs_bmap_disk_count_leaves(
- xfs_bmbt_rec_t *frp,
+ xfs_ifork_t *ifp,
+ xfs_mount_t *mp,
+ xfs_extnum_t idx,
+ xfs_bmbt_block_t *block,
int numrecs,
int *count);
@@ -537,7 +518,7 @@ xfs_bmap_add_attrfork_local(
}
/*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
* after allocating space (or doing a delayed allocation).
*/
STATIC int /* error */
@@ -545,7 +526,7 @@ xfs_bmap_add_extent(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
xfs_fsblock_t *first, /* pointer to firstblock variable */
xfs_bmap_free_t *flist, /* list of extents to be freed */
int *logflagsp, /* inode logging flags */
@@ -578,7 +559,7 @@ xfs_bmap_add_extent(
if (nextents == 0) {
xfs_bmap_trace_insert(fname, "insert empty", ip, 0, 1, new,
NULL, whichfork);
- xfs_bmap_insert_exlist(ip, 0, 1, new, whichfork);
+ xfs_iext_insert(ifp, 0, 1, new);
ASSERT(cur == NULL);
ifp->if_lastex = 0;
if (!ISNULLSTARTBLOCK(new->br_startblock)) {
@@ -614,7 +595,7 @@ xfs_bmap_add_extent(
/*
* Get the record referred to by idx.
*/
- xfs_bmbt_get_all(&ifp->if_u1.if_extents[idx], &prev);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx), &prev);
/*
* If it's a real allocation record, and the new allocation ends
* after the start of the referred to record, then we're filling
@@ -714,14 +695,13 @@ xfs_bmap_add_extent_delay_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
xfs_filblks_t *dnew, /* new delayed-alloc indirect blocks */
xfs_fsblock_t *first, /* pointer to firstblock variable */
xfs_bmap_free_t *flist, /* list of extents to be freed */
int *logflagsp, /* inode logging flags */
int rsvd) /* OK to use reserved data block allocation */
{
- xfs_bmbt_rec_t *base; /* base of extent entry list */
xfs_btree_cur_t *cur; /* btree cursor */
int diff; /* temp value */
xfs_bmbt_rec_t *ep; /* extent entry for idx */
@@ -730,6 +710,7 @@ xfs_bmap_add_extent_delay_real(
static char fname[] = "xfs_bmap_add_extent_delay_real";
#endif
int i; /* temp state */
+ xfs_ifork_t *ifp; /* inode fork pointer */
xfs_fileoff_t new_endoff; /* end offset of new entry */
xfs_bmbt_irec_t r[3]; /* neighbor extent entries */
/* left is 0, right is 1, prev is 2 */
@@ -763,8 +744,8 @@ xfs_bmap_add_extent_delay_real(
* Set up a bunch of variables to make the tests simpler.
*/
cur = *curp;
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx];
+ ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_get_all(ep, &PREV);
new_endoff = new->br_startoff + new->br_blockcount;
ASSERT(PREV.br_startoff <= new->br_startoff);
@@ -781,7 +762,7 @@ xfs_bmap_add_extent_delay_real(
* Don't set contiguous if the combined extent would be too large.
*/
if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
- xfs_bmbt_get_all(ep - 1, &LEFT);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock));
}
STATE_SET(LEFT_CONTIG,
@@ -798,7 +779,7 @@ xfs_bmap_add_extent_delay_real(
if (STATE_SET_TEST(RIGHT_VALID,
idx <
ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
- xfs_bmbt_get_all(ep + 1, &RIGHT);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock));
}
STATE_SET(RIGHT_CONTIG,
@@ -825,14 +806,14 @@ xfs_bmap_add_extent_delay_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + PREV.br_blockcount +
RIGHT.br_blockcount);
xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1,
XFS_DATA_FORK);
xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx, 2, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx, 2);
ip->i_df.if_lastex = idx - 1;
ip->i_d.di_nextents--;
if (cur == NULL)
@@ -867,14 +848,14 @@ xfs_bmap_add_extent_delay_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + PREV.br_blockcount);
xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1,
XFS_DATA_FORK);
ip->i_df.if_lastex = idx - 1;
xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx, 1);
if (cur == NULL)
rval = XFS_ILOG_DEXT;
else {
@@ -908,7 +889,7 @@ xfs_bmap_add_extent_delay_real(
ip->i_df.if_lastex = idx;
xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx + 1, 1, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx + 1, 1);
if (cur == NULL)
rval = XFS_ILOG_DEXT;
else {
@@ -964,7 +945,7 @@ xfs_bmap_add_extent_delay_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + new->br_blockcount);
xfs_bmbt_set_startoff(ep,
PREV.br_startoff + new->br_blockcount);
@@ -1010,7 +991,7 @@ xfs_bmap_add_extent_delay_real(
xfs_bmbt_set_blockcount(ep, temp);
xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL,
XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx, 1, new);
ip->i_df.if_lastex = idx;
ip->i_d.di_nextents++;
if (cur == NULL)
@@ -1039,8 +1020,7 @@ xfs_bmap_add_extent_delay_real(
temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
STARTBLOCKVAL(PREV.br_startblock) -
(cur ? cur->bc_private.b.allocated : 0));
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx + 1];
+ ep = xfs_iext_get_ext(ifp, idx + 1);
xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp));
xfs_bmap_trace_post_update(fname, "LF", ip, idx + 1,
XFS_DATA_FORK);
@@ -1058,7 +1038,8 @@ xfs_bmap_add_extent_delay_real(
xfs_bmap_trace_pre_update(fname, "RF|RC", ip, idx + 1,
XFS_DATA_FORK);
xfs_bmbt_set_blockcount(ep, temp);
- xfs_bmbt_set_allf(ep + 1, new->br_startoff, new->br_startblock,
+ xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1),
+ new->br_startoff, new->br_startblock,
new->br_blockcount + RIGHT.br_blockcount,
RIGHT.br_state);
xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1,
@@ -1098,7 +1079,7 @@ xfs_bmap_add_extent_delay_real(
xfs_bmbt_set_blockcount(ep, temp);
xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1,
new, NULL, XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx + 1, 1, new, XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx + 1, 1, new);
ip->i_df.if_lastex = idx + 1;
ip->i_d.di_nextents++;
if (cur == NULL)
@@ -1127,8 +1108,7 @@ xfs_bmap_add_extent_delay_real(
temp = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip, temp),
STARTBLOCKVAL(PREV.br_startblock) -
(cur ? cur->bc_private.b.allocated : 0));
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx];
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp));
xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK);
*dnew = temp;
@@ -1149,7 +1129,7 @@ xfs_bmap_add_extent_delay_real(
r[1].br_blockcount = temp2;
xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1],
XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx + 1, 2, &r[0], XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx + 1, 2, &r[0]);
ip->i_df.if_lastex = idx + 1;
ip->i_d.di_nextents++;
if (cur == NULL)
@@ -1204,13 +1184,13 @@ xfs_bmap_add_extent_delay_real(
}
}
}
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx];
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_set_startblock(ep, NULLSTARTBLOCK((int)temp));
xfs_bmap_trace_post_update(fname, "0", ip, idx, XFS_DATA_FORK);
xfs_bmap_trace_pre_update(fname, "0", ip, idx + 2,
XFS_DATA_FORK);
- xfs_bmbt_set_startblock(ep + 2, NULLSTARTBLOCK((int)temp2));
+ xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx + 2),
+ NULLSTARTBLOCK((int)temp2));
xfs_bmap_trace_post_update(fname, "0", ip, idx + 2,
XFS_DATA_FORK);
*dnew = temp + temp2;
@@ -1254,10 +1234,9 @@ xfs_bmap_add_extent_unwritten_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp) /* inode logging flags */
{
- xfs_bmbt_rec_t *base; /* base of extent entry list */
xfs_btree_cur_t *cur; /* btree cursor */
xfs_bmbt_rec_t *ep; /* extent entry for idx */
int error; /* error return value */
@@ -1265,6 +1244,7 @@ xfs_bmap_add_extent_unwritten_real(
static char fname[] = "xfs_bmap_add_extent_unwritten_real";
#endif
int i; /* temp state */
+ xfs_ifork_t *ifp; /* inode fork pointer */
xfs_fileoff_t new_endoff; /* end offset of new entry */
xfs_exntst_t newext; /* new extent state */
xfs_exntst_t oldext; /* old extent state */
@@ -1298,8 +1278,8 @@ xfs_bmap_add_extent_unwritten_real(
*/
error = 0;
cur = *curp;
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx];
+ ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_get_all(ep, &PREV);
newext = new->br_state;
oldext = (newext == XFS_EXT_UNWRITTEN) ?
@@ -1320,7 +1300,7 @@ xfs_bmap_add_extent_unwritten_real(
* Don't set contiguous if the combined extent would be too large.
*/
if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
- xfs_bmbt_get_all(ep - 1, &LEFT);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &LEFT);
STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(LEFT.br_startblock));
}
STATE_SET(LEFT_CONTIG,
@@ -1337,7 +1317,7 @@ xfs_bmap_add_extent_unwritten_real(
if (STATE_SET_TEST(RIGHT_VALID,
idx <
ip->i_df.if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - 1)) {
- xfs_bmbt_get_all(ep + 1, &RIGHT);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx + 1), &RIGHT);
STATE_SET(RIGHT_DELAY, ISNULLSTARTBLOCK(RIGHT.br_startblock));
}
STATE_SET(RIGHT_CONTIG,
@@ -1363,14 +1343,14 @@ xfs_bmap_add_extent_unwritten_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|RF|LC|RC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + PREV.br_blockcount +
RIGHT.br_blockcount);
xfs_bmap_trace_post_update(fname, "LF|RF|LC|RC", ip, idx - 1,
XFS_DATA_FORK);
xfs_bmap_trace_delete(fname, "LF|RF|LC|RC", ip, idx, 2,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx, 2, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx, 2);
ip->i_df.if_lastex = idx - 1;
ip->i_d.di_nextents -= 2;
if (cur == NULL)
@@ -1409,14 +1389,14 @@ xfs_bmap_add_extent_unwritten_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|RF|LC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + PREV.br_blockcount);
xfs_bmap_trace_post_update(fname, "LF|RF|LC", ip, idx - 1,
XFS_DATA_FORK);
ip->i_df.if_lastex = idx - 1;
xfs_bmap_trace_delete(fname, "LF|RF|LC", ip, idx, 1,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx, 1);
ip->i_d.di_nextents--;
if (cur == NULL)
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1456,7 +1436,7 @@ xfs_bmap_add_extent_unwritten_real(
ip->i_df.if_lastex = idx;
xfs_bmap_trace_delete(fname, "LF|RF|RC", ip, idx + 1, 1,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx + 1, 1, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx + 1, 1);
ip->i_d.di_nextents--;
if (cur == NULL)
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
@@ -1516,7 +1496,7 @@ xfs_bmap_add_extent_unwritten_real(
*/
xfs_bmap_trace_pre_update(fname, "LF|LC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
LEFT.br_blockcount + new->br_blockcount);
xfs_bmbt_set_startoff(ep,
PREV.br_startoff + new->br_blockcount);
@@ -1571,7 +1551,7 @@ xfs_bmap_add_extent_unwritten_real(
xfs_bmap_trace_post_update(fname, "LF", ip, idx, XFS_DATA_FORK);
xfs_bmap_trace_insert(fname, "LF", ip, idx, 1, new, NULL,
XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx, 1, new);
ip->i_df.if_lastex = idx;
ip->i_d.di_nextents++;
if (cur == NULL)
@@ -1609,7 +1589,8 @@ xfs_bmap_add_extent_unwritten_real(
PREV.br_blockcount - new->br_blockcount);
xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx,
XFS_DATA_FORK);
- xfs_bmbt_set_allf(ep + 1, new->br_startoff, new->br_startblock,
+ xfs_bmbt_set_allf(xfs_iext_get_ext(ifp, idx + 1),
+ new->br_startoff, new->br_startblock,
new->br_blockcount + RIGHT.br_blockcount, newext);
xfs_bmap_trace_post_update(fname, "RF|RC", ip, idx + 1,
XFS_DATA_FORK);
@@ -1649,7 +1630,7 @@ xfs_bmap_add_extent_unwritten_real(
xfs_bmap_trace_post_update(fname, "RF", ip, idx, XFS_DATA_FORK);
xfs_bmap_trace_insert(fname, "RF", ip, idx + 1, 1,
new, NULL, XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx + 1, 1, new, XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx + 1, 1, new);
ip->i_df.if_lastex = idx + 1;
ip->i_d.di_nextents++;
if (cur == NULL)
@@ -1696,7 +1677,7 @@ xfs_bmap_add_extent_unwritten_real(
r[1].br_state = oldext;
xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 2, &r[0], &r[1],
XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx + 1, 2, &r[0], XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx + 1, 2, &r[0]);
ip->i_df.if_lastex = idx + 1;
ip->i_d.di_nextents += 2;
if (cur == NULL)
@@ -1770,15 +1751,15 @@ xfs_bmap_add_extent_hole_delay(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp, /* inode logging flags */
int rsvd) /* OK to allocate reserved blocks */
{
- xfs_bmbt_rec_t *base; /* base of extent entry list */
- xfs_bmbt_rec_t *ep; /* extent list entry for idx */
+ xfs_bmbt_rec_t *ep; /* extent record for idx */
#ifdef XFS_BMAP_TRACE
static char fname[] = "xfs_bmap_add_extent_hole_delay";
#endif
+ xfs_ifork_t *ifp; /* inode fork pointer */
xfs_bmbt_irec_t left; /* left neighbor extent entry */
xfs_filblks_t newlen=0; /* new indirect size */
xfs_filblks_t oldlen=0; /* old indirect size */
@@ -1799,15 +1780,15 @@ xfs_bmap_add_extent_hole_delay(
((state &= ~MASK(b)), 0))
#define SWITCH_STATE (state & MASK2(LEFT_CONTIG, RIGHT_CONTIG))
- base = ip->i_df.if_u1.if_extents;
- ep = &base[idx];
+ ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+ ep = xfs_iext_get_ext(ifp, idx);
state = 0;
ASSERT(ISNULLSTARTBLOCK(new->br_startblock));
/*
* Check and set flags if this segment has a left neighbor
*/
if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
- xfs_bmbt_get_all(ep - 1, &left);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock));
}
/*
@@ -1844,23 +1825,24 @@ xfs_bmap_add_extent_hole_delay(
/*
* New allocation is contiguous with delayed allocations
* on the left and on the right.
- * Merge all three into a single extent list entry.
+ * Merge all three into a single extent record.
*/
temp = left.br_blockcount + new->br_blockcount +
right.br_blockcount;
xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1, temp);
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
oldlen = STARTBLOCKVAL(left.br_startblock) +
STARTBLOCKVAL(new->br_startblock) +
STARTBLOCKVAL(right.br_startblock);
newlen = xfs_bmap_worst_indlen(ip, temp);
- xfs_bmbt_set_startblock(ep - 1, NULLSTARTBLOCK((int)newlen));
+ xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
+ NULLSTARTBLOCK((int)newlen));
xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1,
XFS_DATA_FORK);
xfs_bmap_trace_delete(fname, "LC|RC", ip, idx, 1,
XFS_DATA_FORK);
- xfs_bmap_delete_exlist(ip, idx, 1, XFS_DATA_FORK);
+ xfs_iext_remove(ifp, idx, 1);
ip->i_df.if_lastex = idx - 1;
break;
@@ -1873,11 +1855,12 @@ xfs_bmap_add_extent_hole_delay(
temp = left.br_blockcount + new->br_blockcount;
xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1,
XFS_DATA_FORK);
- xfs_bmbt_set_blockcount(ep - 1, temp);
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1), temp);
oldlen = STARTBLOCKVAL(left.br_startblock) +
STARTBLOCKVAL(new->br_startblock);
newlen = xfs_bmap_worst_indlen(ip, temp);
- xfs_bmbt_set_startblock(ep - 1, NULLSTARTBLOCK((int)newlen));
+ xfs_bmbt_set_startblock(xfs_iext_get_ext(ifp, idx - 1),
+ NULLSTARTBLOCK((int)newlen));
xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1,
XFS_DATA_FORK);
ip->i_df.if_lastex = idx - 1;
@@ -1909,7 +1892,7 @@ xfs_bmap_add_extent_hole_delay(
oldlen = newlen = 0;
xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL,
XFS_DATA_FORK);
- xfs_bmap_insert_exlist(ip, idx, 1, new, XFS_DATA_FORK);
+ xfs_iext_insert(ifp, idx, 1, new);
ip->i_df.if_lastex = idx;
break;
}
@@ -1940,7 +1923,7 @@ xfs_bmap_add_extent_hole_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_extnum_t idx, /* extent number to update/insert */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *new, /* new data to put in extent list */
+ xfs_bmbt_irec_t *new, /* new data to add to file extents */
int *logflagsp, /* inode logging flags */
int whichfork) /* data or attr fork */
{
@@ -1970,13 +1953,13 @@ xfs_bmap_add_extent_hole_real(
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(idx <= ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t));
- ep = &ifp->if_u1.if_extents[idx];
+ ep = xfs_iext_get_ext(ifp, idx);
state = 0;
/*
* Check and set flags if this segment has a left neighbor.
*/
if (STATE_SET_TEST(LEFT_VALID, idx > 0)) {
- xfs_bmbt_get_all(ep - 1, &left);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, idx - 1), &left);
STATE_SET(LEFT_DELAY, ISNULLSTARTBLOCK(left.br_startblock));
}
/*
@@ -2019,18 +2002,18 @@ xfs_bmap_add_extent_hole_real(
/*
* New allocation is contiguous with real allocations on the
* left and on the right.
- * Merge all three into a single extent list entry.
+ * Merge all three into a single extent record.
*/
xfs_bmap_trace_pre_update(fname, "LC|RC", ip, idx - 1,
whichfork);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
left.br_blockcount + new->br_blockcount +
right.br_blockcount);
xfs_bmap_trace_post_update(fname, "LC|RC", ip, idx - 1,
whichfork);
xfs_bmap_trace_delete(fname, "LC|RC", ip,
idx, 1, whichfork);
- xfs_bmap_delete_exlist(ip, idx, 1, whichfork);
+ xfs_iext_remove(ifp, idx, 1);
ifp->if_lastex = idx - 1;
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
@@ -2062,7 +2045,7 @@ xfs_bmap_add_extent_hole_real(
* Merge the new allocation with the left neighbor.
*/
xfs_bmap_trace_pre_update(fname, "LC", ip, idx - 1, whichfork);
- xfs_bmbt_set_blockcount(ep - 1,
+ xfs_bmbt_set_blockcount(xfs_iext_get_ext(ifp, idx - 1),
left.br_blockcount + new->br_blockcount);
xfs_bmap_trace_post_update(fname, "LC", ip, idx - 1, whichfork);
ifp->if_lastex = idx - 1;
@@ -2116,7 +2099,7 @@ xfs_bmap_add_extent_hole_real(
*/
xfs_bmap_trace_insert(fname, "0", ip, idx, 1, new, NULL,
whichfork);
- xfs_bmap_insert_exlist(ip, idx, 1, new, whichfork);
+ xfs_iext_insert(ifp, idx, 1, new);
ifp->if_lastex = idx;
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
@@ -2311,25 +2294,15 @@ xfs_bmap_extsize_align(
#define XFS_ALLOC_GAP_UNITS 4
-/*
- * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file.
- * It figures out where to ask the underlying allocator to put the new extent.
- */
STATIC int
-xfs_bmap_alloc(
+xfs_bmap_adjacent(
xfs_bmalloca_t *ap) /* bmap alloc argument struct */
{
xfs_fsblock_t adjust; /* adjustment to block numbers */
- xfs_alloctype_t atype=0; /* type for allocation routines */
- int error; /* error return value */
xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */
xfs_mount_t *mp; /* mount point structure */
int nullfb; /* true if ap->firstblock isn't set */
int rt; /* true if inode is realtime */
- xfs_extlen_t prod = 0; /* product factor for allocators */
- xfs_extlen_t ralen = 0; /* realtime allocation length */
- xfs_extlen_t align; /* minimum allocation alignment */
- xfs_rtblock_t rtx;
#define ISVALID(x,y) \
(rt ? \
@@ -2338,75 +2311,10 @@ xfs_bmap_alloc(
XFS_FSB_TO_AGNO(mp, x) < mp->m_sb.sb_agcount && \
XFS_FSB_TO_AGBNO(mp, x) < mp->m_sb.sb_agblocks)
- /*
- * Set up variables.
- */
mp = ap->ip->i_mount;
nullfb = ap->firstblock == NULLFSBLOCK;
rt = XFS_IS_REALTIME_INODE(ap->ip) && ap->userdata;
fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock);
- if (rt) {
- align = ap->ip->i_d.di_extsize ?
- ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize;
- /* Set prod to match the extent size */
- prod = align / mp->m_sb.sb_rextsize;
-
- error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
- align, rt, ap->eof, 0,
- ap->conv, &ap->off, &ap->alen);
- if (error)
- return error;
- ASSERT(ap->alen);
- ASSERT(ap->alen % mp->m_sb.sb_rextsize == 0);
-
- /*
- * If the offset & length are not perfectly aligned
- * then kill prod, it will just get us in trouble.
- */
- if (do_mod(ap->off, align) || ap->alen % align)
- prod = 1;
- /*
- * Set ralen to be the actual requested length in rtextents.
- */
- ralen = ap->alen / mp->m_sb.sb_rextsize;
- /*
- * If the old value was close enough to MAXEXTLEN that
- * we rounded up to it, cut it back so it's valid again.
- * Note that if it's a really large request (bigger than
- * MAXEXTLEN), we don't hear about that number, and can't
- * adjust the starting point to match it.
- */
- if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN)
- ralen = MAXEXTLEN / mp->m_sb.sb_rextsize;
- /*
- * If it's an allocation to an empty file at offset 0,
- * pick an extent that will space things out in the rt area.
- */
- if (ap->eof && ap->off == 0) {
- error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx);
- if (error)
- return error;
- ap->rval = rtx * mp->m_sb.sb_rextsize;
- } else
- ap->rval = 0;
- } else {
- align = (ap->userdata && ap->ip->i_d.di_extsize &&
- (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ?
- ap->ip->i_d.di_extsize : 0;
- if (unlikely(align)) {
- error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
- align, rt,
- ap->eof, 0, ap->conv,
- &ap->off, &ap->alen);
- ASSERT(!error);
- ASSERT(ap->alen);
- }
- if (nullfb)
- ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
- else
- ap->rval = ap->firstblock;
- }
-
/*
* If allocating at eof, and there's a previous real block,
* try to use it's last block as our starting point.
@@ -2531,287 +2439,384 @@ xfs_bmap_alloc(
else if (gotbno != NULLFSBLOCK)
ap->rval = gotbno;
}
+#undef ISVALID
+ return 0;
+}
+
+STATIC int
+xfs_bmap_rtalloc(
+ xfs_bmalloca_t *ap) /* bmap alloc argument struct */
+{
+ xfs_alloctype_t atype = 0; /* type for allocation routines */
+ int error; /* error return value */
+ xfs_mount_t *mp; /* mount point structure */
+ xfs_extlen_t prod = 0; /* product factor for allocators */
+ xfs_extlen_t ralen = 0; /* realtime allocation length */
+ xfs_extlen_t align; /* minimum allocation alignment */
+ xfs_rtblock_t rtx; /* realtime extent number */
+ xfs_rtblock_t rtb;
+
+ mp = ap->ip->i_mount;
+ align = ap->ip->i_d.di_extsize ?
+ ap->ip->i_d.di_extsize : mp->m_sb.sb_rextsize;
+ prod = align / mp->m_sb.sb_rextsize;
+ error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
+ align, 1, ap->eof, 0,
+ ap->conv, &ap->off, &ap->alen);
+ if (error)
+ return error;
+ ASSERT(ap->alen);
+ ASSERT(ap->alen % mp->m_sb.sb_rextsize == 0);
+
+ /*
+ * If the offset & length are not perfectly aligned
+ * then kill prod, it will just get us in trouble.
+ */
+ if (do_mod(ap->off, align) || ap->alen % align)
+ prod = 1;
+ /*
+ * Set ralen to be the actual requested length in rtextents.
+ */
+ ralen = ap->alen / mp->m_sb.sb_rextsize;
+ /*
+ * If the old value was close enough to MAXEXTLEN that
+ * we rounded up to it, cut it back so it's valid again.
+ * Note that if it's a really large request (bigger than
+ * MAXEXTLEN), we don't hear about that number, and can't
+ * adjust the starting point to match it.
+ */
+ if (ralen * mp->m_sb.sb_rextsize >= MAXEXTLEN)
+ ralen = MAXEXTLEN / mp->m_sb.sb_rextsize;
+ /*
+ * If it's an allocation to an empty file at offset 0,
+ * pick an extent that will space things out in the rt area.
+ */
+ if (ap->eof && ap->off == 0) {
+ error = xfs_rtpick_extent(mp, ap->tp, ralen, &rtx);
+ if (error)
+ return error;
+ ap->rval = rtx * mp->m_sb.sb_rextsize;
+ } else {
+ ap->rval = 0;
+ }
+
+ xfs_bmap_adjacent(ap);
+
+ /*
+ * Realtime allocation, done through xfs_rtallocate_extent.
+ */
+ atype = ap->rval == 0 ? XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO;
+ do_div(ap->rval, mp->m_sb.sb_rextsize);
+ rtb = ap->rval;
+ ap->alen = ralen;
+ if ((error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, ap->alen,
+ &ralen, atype, ap->wasdel, prod, &rtb)))
+ return error;
+ if (rtb == NULLFSBLOCK && prod > 1 &&
+ (error = xfs_rtallocate_extent(ap->tp, ap->rval, 1,
+ ap->alen, &ralen, atype,
+ ap->wasdel, 1, &rtb)))
+ return error;
+ ap->rval = rtb;
+ if (ap->rval != NULLFSBLOCK) {
+ ap->rval *= mp->m_sb.sb_rextsize;
+ ralen *= mp->m_sb.sb_rextsize;
+ ap->alen = ralen;
+ ap->ip->i_d.di_nblocks += ralen;
+ xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
+ if (ap->wasdel)
+ ap->ip->i_delayed_blks -= ralen;
+ /*
+ * Adjust the disk quota also. This was reserved
+ * earlier.
+ */
+ XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip,
+ ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT :
+ XFS_TRANS_DQ_RTBCOUNT, (long) ralen);
+ } else {
+ ap->alen = 0;
+ }
+ return 0;
+}
+
+STATIC int
+xfs_bmap_btalloc(
+ xfs_bmalloca_t *ap) /* bmap alloc argument struct */
+{
+ xfs_mount_t *mp; /* mount point structure */
+ xfs_alloctype_t atype = 0; /* type for allocation routines */
+ xfs_extlen_t align; /* minimum allocation alignment */
+ xfs_agnumber_t ag;
+ xfs_agnumber_t fb_agno; /* ag number of ap->firstblock */
+ xfs_agnumber_t startag;
+ xfs_alloc_arg_t args;
+ xfs_extlen_t blen;
+ xfs_extlen_t delta;
+ xfs_extlen_t longest;
+ xfs_extlen_t need;
+ xfs_extlen_t nextminlen = 0;
+ xfs_perag_t *pag;
+ int nullfb; /* true if ap->firstblock isn't set */
+ int isaligned;
+ int notinit;
+ int tryagain;
+ int error;
+
+ mp = ap->ip->i_mount;
+ align = (ap->userdata && ap->ip->i_d.di_extsize &&
+ (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE)) ?
+ ap->ip->i_d.di_extsize : 0;
+ if (unlikely(align)) {
+ error = xfs_bmap_extsize_align(mp, ap->gotp, ap->prevp,
+ align, 0, ap->eof, 0, ap->conv,
+ &ap->off, &ap->alen);
+ ASSERT(!error);
+ ASSERT(ap->alen);
+ }
+ nullfb = ap->firstblock == NULLFSBLOCK;
+ fb_agno = nullfb ? NULLAGNUMBER : XFS_FSB_TO_AGNO(mp, ap->firstblock);
+ if (nullfb)
+ ap->rval = XFS_INO_TO_FSB(mp, ap->ip->i_ino);
+ else
+ ap->rval = ap->firstblock;
+
+ xfs_bmap_adjacent(ap);
+
/*
* If allowed, use ap->rval; otherwise must use firstblock since
* it's in the right allocation group.
*/
- if (nullfb || rt || XFS_FSB_TO_AGNO(mp, ap->rval) == fb_agno)
+ if (nullfb || XFS_FSB_TO_AGNO(mp, ap->rval) == fb_agno)
;
else
ap->rval = ap->firstblock;
/*
- * Realtime allocation, done through xfs_rtallocate_extent.
+ * Normal allocation, done through xfs_alloc_vextent.
*/
- if (rt) {
-#ifndef __KERNEL__
- ASSERT(0);
-#else
- xfs_rtblock_t rtb;
-
- atype = ap->rval == 0 ?
- XFS_ALLOCTYPE_ANY_AG : XFS_ALLOCTYPE_NEAR_BNO;
- do_div(ap->rval, mp->m_sb.sb_rextsize);
- rtb = ap->rval;
- ap->alen = ralen;
- if ((error = xfs_rtallocate_extent(ap->tp, ap->rval, 1, ap->alen,
- &ralen, atype, ap->wasdel, prod, &rtb)))
- return error;
- if (rtb == NULLFSBLOCK && prod > 1 &&
- (error = xfs_rtallocate_extent(ap->tp, ap->rval, 1,
- ap->alen, &ralen, atype,
- ap->wasdel, 1, &rtb)))
- return error;
- ap->rval = rtb;
- if (ap->rval != NULLFSBLOCK) {
- ap->rval *= mp->m_sb.sb_rextsize;
- ralen *= mp->m_sb.sb_rextsize;
- ap->alen = ralen;
- ap->ip->i_d.di_nblocks += ralen;
- xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
- if (ap->wasdel)
- ap->ip->i_delayed_blks -= ralen;
+ tryagain = isaligned = 0;
+ args.tp = ap->tp;
+ args.mp = mp;
+ args.fsbno = ap->rval;
+ args.maxlen = MIN(ap->alen, mp->m_sb.sb_agblocks);
+ blen = 0;
+ if (nullfb) {
+ args.type = XFS_ALLOCTYPE_START_BNO;
+ args.total = ap->total;
+ /*
+ * Find the longest available space.
+ * We're going to try for the whole allocation at once.
+ */
+ startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno);
+ notinit = 0;
+ down_read(&mp->m_peraglock);
+ while (blen < ap->alen) {
+ pag = &mp->m_perag[ag];
+ if (!pag->pagf_init &&
+ (error = xfs_alloc_pagf_init(mp, args.tp,
+ ag, XFS_ALLOC_FLAG_TRYLOCK))) {
+ up_read(&mp->m_peraglock);
+ return error;
+ }
/*
- * Adjust the disk quota also. This was reserved
- * earlier.
+ * See xfs_alloc_fix_freelist...
*/
- XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip,
- ap->wasdel ? XFS_TRANS_DQ_DELRTBCOUNT :
- XFS_TRANS_DQ_RTBCOUNT,
- (long) ralen);
- } else
- ap->alen = 0;
-#endif /* __KERNEL__ */
+ if (pag->pagf_init) {
+ need = XFS_MIN_FREELIST_PAG(pag, mp);
+ delta = need > pag->pagf_flcount ?
+ need - pag->pagf_flcount : 0;
+ longest = (pag->pagf_longest > delta) ?
+ (pag->pagf_longest - delta) :
+ (pag->pagf_flcount > 0 ||
+ pag->pagf_longest > 0);
+ if (blen < longest)
+ blen = longest;
+ } else
+ notinit = 1;
+ if (++ag == mp->m_sb.sb_agcount)
+ ag = 0;
+ if (ag == startag)
+ break;
+ }
+ up_read(&mp->m_peraglock);
+ /*
+ * Since the above loop did a BUF_TRYLOCK, it is
+ * possible that there is space for this request.
+ */
+ if (notinit || blen < ap->minlen)
+ args.minlen = ap->minlen;
+ /*
+ * If the best seen length is less than the request
+ * length, use the best as the minimum.
+ */
+ else if (blen < ap->alen)
+ args.minlen = blen;
+ /*
+ * Otherwise we've seen an extent as big as alen,
+ * use that as the minimum.
+ */
+ else
+ args.minlen = ap->alen;
+ } else if (ap->low) {
+ args.type = XFS_ALLOCTYPE_FIRST_AG;
+ args.total = args.minlen = ap->minlen;
+ } else {
+ args.type = XFS_ALLOCTYPE_NEAR_BNO;
+ args.total = ap->total;
+ args.minlen = ap->minlen;
+ }
+ if (unlikely(ap->userdata && ap->ip->i_d.di_extsize &&
+ (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) {
+ args.prod = ap->ip->i_d.di_extsize;
+ if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod)))
+ args.mod = (xfs_extlen_t)(args.prod - args.mod);
+ } else if (unlikely(mp->m_sb.sb_blocksize >= NBPP)) {
+ args.prod = 1;
+ args.mod = 0;
+ } else {
+ args.prod = NBPP >> mp->m_sb.sb_blocklog;
+ if ((args.mod = (xfs_extlen_t)(do_mod(ap->off, args.prod))))
+ args.mod = (xfs_extlen_t)(args.prod - args.mod);
}
/*
- * Normal allocation, done through xfs_alloc_vextent.
+ * If we are not low on available data blocks, and the
+ * underlying logical volume manager is a stripe, and
+ * the file offset is zero then try to allocate data
+ * blocks on stripe unit boundary.
+ * NOTE: ap->aeof is only set if the allocation length
+ * is >= the stripe unit and the allocation offset is
+ * at the end of file.
*/
- else {
- xfs_agnumber_t ag;
- xfs_alloc_arg_t args;
- xfs_extlen_t blen;
- xfs_extlen_t delta;
- int isaligned;
- xfs_extlen_t longest;
- xfs_extlen_t need;
- xfs_extlen_t nextminlen=0;
- int notinit;
- xfs_perag_t *pag;
- xfs_agnumber_t startag;
- int tryagain;
-
- tryagain = isaligned = 0;
- args.tp = ap->tp;
- args.mp = mp;
- args.fsbno = ap->rval;
- args.maxlen = MIN(ap->alen, mp->m_sb.sb_agblocks);
- blen = 0;
- if (nullfb) {
- args.type = XFS_ALLOCTYPE_START_BNO;
- args.total = ap->total;
- /*
- * Find the longest available space.
- * We're going to try for the whole allocation at once.
- */
- startag = ag = XFS_FSB_TO_AGNO(mp, args.fsbno);
- notinit = 0;
- down_read(&mp->m_peraglock);
- while (blen < ap->alen) {
- pag = &mp->m_perag[ag];
- if (!pag->pagf_init &&
- (error = xfs_alloc_pagf_init(mp, args.tp,
- ag, XFS_ALLOC_FLAG_TRYLOCK))) {
- up_read(&mp->m_peraglock);
- return error;
- }
- /*
- * See xfs_alloc_fix_freelist...
- */
- if (pag->pagf_init) {
- need = XFS_MIN_FREELIST_PAG(pag, mp);
- delta = need > pag->pagf_flcount ?
- need - pag->pagf_flcount : 0;
- longest = (pag->pagf_longest > delta) ?
- (pag->pagf_longest - delta) :
- (pag->pagf_flcount > 0 ||
- pag->pagf_longest > 0);
- if (blen < longest)
- blen = longest;
- } else
- notinit = 1;
- if (++ag == mp->m_sb.sb_agcount)
- ag = 0;
- if (ag == startag)
- break;
- }
- up_read(&mp->m_peraglock);
+ if (!ap->low && ap->aeof) {
+ if (!ap->off) {
+ args.alignment = mp->m_dalign;
+ atype = args.type;
+ isaligned = 1;
/*
- * Since the above loop did a BUF_TRYLOCK, it is
- * possible that there is space for this request.
+ * Adjust for alignment
*/
- if (notinit || blen < ap->minlen)
- args.minlen = ap->minlen;
+ if (blen > args.alignment && blen <= ap->alen)
+ args.minlen = blen - args.alignment;
+ args.minalignslop = 0;
+ } else {
/*
- * If the best seen length is less than the request
- * length, use the best as the minimum.
+ * First try an exact bno allocation.
+ * If it fails then do a near or start bno
+ * allocation with alignment turned on.
*/
- else if (blen < ap->alen)
- args.minlen = blen;
+ atype = args.type;
+ tryagain = 1;
+ args.type = XFS_ALLOCTYPE_THIS_BNO;
+ args.alignment = 1;
/*
- * Otherwise we've seen an extent as big as alen,
- * use that as the minimum.
+ * Compute the minlen+alignment for the
+ * next case. Set slop so that the value
+ * of minlen+alignment+slop doesn't go up
+ * between the calls.
*/
+ if (blen > mp->m_dalign && blen <= ap->alen)
+ nextminlen = blen - mp->m_dalign;
else
- args.minlen = ap->alen;
- } else if (ap->low) {
- args.type = XFS_ALLOCTYPE_FIRST_AG;
- args.total = args.minlen = ap->minlen;
- } else {
- args.type = XFS_ALLOCTYPE_NEAR_BNO;
- args.total = ap->total;
- args.minlen = ap->minlen;
- }
- if (unlikely(ap->userdata && ap->ip->i_d.di_extsize &&
- (ap->ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE))) {
- args.prod = ap->ip->i_d.di_extsize;
- if ((args.mod = (xfs_extlen_t)do_mod(ap->off, args.prod)))
- args.mod = (xfs_extlen_t)(args.prod - args.mod);
- } else if (unlikely(mp->m_sb.sb_blocksize >= NBPP)) {
- args.prod = 1;
- args.mod = 0;
- } else {
- args.prod = NBPP >> mp->m_sb.sb_blocklog;
- if ((args.mod = (xfs_extlen_t)(do_mod(ap->off, args.prod))))
- args.mod = (xfs_extlen_t)(args.prod - args.mod);
+ nextminlen = args.minlen;
+ if (nextminlen + mp->m_dalign > args.minlen + 1)
+ args.minalignslop =
+ nextminlen + mp->m_dalign -
+ args.minlen - 1;
+ else
+ args.minalignslop = 0;
}
+ } else {
+ args.alignment = 1;
+ args.minalignslop = 0;
+ }
+ args.minleft = ap->minleft;
+ args.wasdel = ap->wasdel;
+ args.isfl = 0;
+ args.userdata = ap->userdata;
+ if ((error = xfs_alloc_vextent(&args)))
+ return error;
+ if (tryagain && args.fsbno == NULLFSBLOCK) {
/*
- * If we are not low on available data blocks, and the
- * underlying logical volume manager is a stripe, and
- * the file offset is zero then try to allocate data
- * blocks on stripe unit boundary.
- * NOTE: ap->aeof is only set if the allocation length
- * is >= the stripe unit and the allocation offset is
- * at the end of file.
+ * Exact allocation failed. Now try with alignment
+ * turned on.
*/
- if (!ap->low && ap->aeof) {
- if (!ap->off) {
- args.alignment = mp->m_dalign;
- atype = args.type;
- isaligned = 1;
- /*
- * Adjust for alignment
- */
- if (blen > args.alignment && blen <= ap->alen)
- args.minlen = blen - args.alignment;
- args.minalignslop = 0;
- } else {
- /*
- * First try an exact bno allocation.
- * If it fails then do a near or start bno
- * allocation with alignment turned on.
- */
- atype = args.type;
- tryagain = 1;
- args.type = XFS_ALLOCTYPE_THIS_BNO;
- args.alignment = 1;
- /*
- * Compute the minlen+alignment for the
- * next case. Set slop so that the value
- * of minlen+alignment+slop doesn't go up
- * between the calls.
- */
- if (blen > mp->m_dalign && blen <= ap->alen)
- nextminlen = blen - mp->m_dalign;
- else
- nextminlen = args.minlen;
- if (nextminlen + mp->m_dalign > args.minlen + 1)
- args.minalignslop =
- nextminlen + mp->m_dalign -
- args.minlen - 1;
- else
- args.minalignslop = 0;
- }
- } else {
- args.alignment = 1;
- args.minalignslop = 0;
- }
- args.minleft = ap->minleft;
- args.wasdel = ap->wasdel;
- args.isfl = 0;
- args.userdata = ap->userdata;
+ args.type = atype;
+ args.fsbno = ap->rval;
+ args.alignment = mp->m_dalign;
+ args.minlen = nextminlen;
+ args.minalignslop = 0;
+ isaligned = 1;
+ if ((error = xfs_alloc_vextent(&args)))
+ return error;
+ }
+ if (isaligned && args.fsbno == NULLFSBLOCK) {
+ /*
+ * allocation failed, so turn off alignment and
+ * try again.
+ */
+ args.type = atype;
+ args.fsbno = ap->rval;
+ args.alignment = 0;
+ if ((error = xfs_alloc_vextent(&args)))
+ return error;
+ }
+ if (args.fsbno == NULLFSBLOCK && nullfb &&
+ args.minlen > ap->minlen) {
+ args.minlen = ap->minlen;
+ args.type = XFS_ALLOCTYPE_START_BNO;
+ args.fsbno = ap->rval;
if ((error = xfs_alloc_vextent(&args)))
return error;
- if (tryagain && args.fsbno == NULLFSBLOCK) {
- /*
- * Exact allocation failed. Now try with alignment
- * turned on.
- */
- args.type = atype;
- args.fsbno = ap->rval;
- args.alignment = mp->m_dalign;
- args.minlen = nextminlen;
- args.minalignslop = 0;
- isaligned = 1;
- if ((error = xfs_alloc_vextent(&args)))
- return error;
- }
- if (isaligned && args.fsbno == NULLFSBLOCK) {
- /*
- * allocation failed, so turn off alignment and
- * try again.
- */
- args.type = atype;
- args.fsbno = ap->rval;
- args.alignment = 0;
- if ((error = xfs_alloc_vextent(&args)))
- return error;
- }
- if (args.fsbno == NULLFSBLOCK && nullfb &&
- args.minlen > ap->minlen) {
- args.minlen = ap->minlen;
- args.type = XFS_ALLOCTYPE_START_BNO;
- args.fsbno = ap->rval;
- if ((error = xfs_alloc_vextent(&args)))
- return error;
- }
- if (args.fsbno == NULLFSBLOCK && nullfb) {
- args.fsbno = 0;
- args.type = XFS_ALLOCTYPE_FIRST_AG;
- args.total = ap->minlen;
- args.minleft = 0;
- if ((error = xfs_alloc_vextent(&args)))
- return error;
- ap->low = 1;
- }
- if (args.fsbno != NULLFSBLOCK) {
- ap->firstblock = ap->rval = args.fsbno;
- ASSERT(nullfb || fb_agno == args.agno ||
- (ap->low && fb_agno < args.agno));
- ap->alen = args.len;
- ap->ip->i_d.di_nblocks += args.len;
- xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
- if (ap->wasdel)
- ap->ip->i_delayed_blks -= args.len;
- /*
- * Adjust the disk quota also. This was reserved
- * earlier.
- */
- XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip,
- ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT :
- XFS_TRANS_DQ_BCOUNT,
- (long) args.len);
- } else {
- ap->rval = NULLFSBLOCK;
- ap->alen = 0;
- }
+ }
+ if (args.fsbno == NULLFSBLOCK && nullfb) {
+ args.fsbno = 0;
+ args.type = XFS_ALLOCTYPE_FIRST_AG;
+ args.total = ap->minlen;
+ args.minleft = 0;
+ if ((error = xfs_alloc_vextent(&args)))
+ return error;
+ ap->low = 1;
+ }
+ if (args.fsbno != NULLFSBLOCK) {
+ ap->firstblock = ap->rval = args.fsbno;
+ ASSERT(nullfb || fb_agno == args.agno ||
+ (ap->low && fb_agno < args.agno));
+ ap->alen = args.len;
+ ap->ip->i_d.di_nblocks += args.len;
+ xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
+ if (ap->wasdel)
+ ap->ip->i_delayed_blks -= args.len;
+ /*
+ * Adjust the disk quota also. This was reserved
+ * earlier.
+ */
+ XFS_TRANS_MOD_DQUOT_BYINO(mp, ap->tp, ap->ip,
+ ap->wasdel ? XFS_TRANS_DQ_DELBCOUNT :
+ XFS_TRANS_DQ_BCOUNT,
+ (long) args.len);
+ } else {
+ ap->rval = NULLFSBLOCK;
+ ap->alen = 0;
}
return 0;
-#undef ISVALID
+}
+
+/*
+ * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file.
+ * It figures out where to ask the underlying allocator to put the new extent.
+ */
+STATIC int
+xfs_bmap_alloc(
+ xfs_bmalloca_t *ap) /* bmap alloc argument struct */
+{
+ if ((ap->ip->i_d.di_flags & XFS_DIFLAG_REALTIME) && ap->userdata)
+ return xfs_bmap_rtalloc(ap);
+ return xfs_bmap_btalloc(ap);
}
/*
* Transform a btree format file with only one leaf node, where the
* extents list will fit in the inode, into an extents format file.
- * Since the extent list is already in-core, all we have to do is
+ * Since the file extents are already in-core, all we have to do is
* give up the space for the btree root and pitch the leaf block.
*/
STATIC int /* error */
@@ -2868,7 +2873,7 @@ xfs_bmap_btree_to_extents(
}
/*
- * Called by xfs_bmapi to update extent list structure and the btree
+ * Called by xfs_bmapi to update file extent records and the btree
* after removing space (or undoing a delayed allocation).
*/
STATIC int /* error */
@@ -2878,7 +2883,7 @@ xfs_bmap_del_extent(
xfs_extnum_t idx, /* extent number to update/delete */
xfs_bmap_free_t *flist, /* list of extents to be freed */
xfs_btree_cur_t *cur, /* if null, not a btree */
- xfs_bmbt_irec_t *del, /* data to remove from extent list */
+ xfs_bmbt_irec_t *del, /* data to remove from extents */
int *logflagsp, /* inode logging flags */
int whichfork, /* data or attr fork */
int rsvd) /* OK to allocate reserved blocks */
@@ -2903,7 +2908,6 @@ xfs_bmap_del_extent(
xfs_filblks_t nblks; /* quota/sb block count */
xfs_bmbt_irec_t new; /* new record to be inserted */
/* REFERENCED */
- xfs_extnum_t nextents; /* number of extents in list */
uint qfield; /* quota field to update */
xfs_filblks_t temp; /* for indirect length calculations */
xfs_filblks_t temp2; /* for indirect length calculations */
@@ -2911,10 +2915,10 @@ xfs_bmap_del_extent(
XFS_STATS_INC(xs_del_exlist);
mp = ip->i_mount;
ifp = XFS_IFORK_PTR(ip, whichfork);
- nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- ASSERT(idx >= 0 && idx < nextents);
+ ASSERT((idx >= 0) && (idx < ifp->if_bytes /
+ (uint)sizeof(xfs_bmbt_rec_t)));
ASSERT(del->br_blockcount > 0);
- ep = &ifp->if_u1.if_extents[idx];
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_get_all(ep, &got);
ASSERT(got.br_startoff <= del->br_startoff);
del_endoff = del->br_startoff + del->br_blockcount;
@@ -2990,7 +2994,7 @@ xfs_bmap_del_extent(
* Matches the whole extent. Delete the entry.
*/
xfs_bmap_trace_delete(fname, "3", ip, idx, 1, whichfork);
- xfs_bmap_delete_exlist(ip, idx, 1, whichfork);
+ xfs_iext_remove(ifp, idx, 1);
ifp->if_lastex = idx;
if (delay)
break;
@@ -3160,7 +3164,7 @@ xfs_bmap_del_extent(
xfs_bmap_trace_post_update(fname, "0", ip, idx, whichfork);
xfs_bmap_trace_insert(fname, "0", ip, idx + 1, 1, &new, NULL,
whichfork);
- xfs_bmap_insert_exlist(ip, idx + 1, 1, &new, whichfork);
+ xfs_iext_insert(ifp, idx + 1, 1, &new);
ifp->if_lastex = idx + 1;
break;
}
@@ -3213,31 +3217,6 @@ xfs_bmap_del_free(
}
/*
- * Remove count entries from the extents array for inode "ip", starting
- * at index "idx". Copies the remaining items down over the deleted ones,
- * and gives back the excess memory.
- */
-STATIC void
-xfs_bmap_delete_exlist(
- xfs_inode_t *ip, /* incore inode pointer */
- xfs_extnum_t idx, /* starting delete index */
- xfs_extnum_t count, /* count of items to delete */
- int whichfork) /* data or attr fork */
-{
- xfs_bmbt_rec_t *base; /* base of extent list */
- xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_extnum_t nextents; /* number of extents in list after */
-
- ifp = XFS_IFORK_PTR(ip, whichfork);
- ASSERT(ifp->if_flags & XFS_IFEXTENTS);
- base = ifp->if_u1.if_extents;
- nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t) - count;
- memmove(&base[idx], &base[idx + count],
- (nextents - idx) * sizeof(*base));
- xfs_iext_realloc(ip, -count, whichfork);
-}
-
-/*
* Convert an extents-format file into a btree-format file.
* The new file will have a root block (in the inode) and a single child block.
*/
@@ -3258,13 +3237,13 @@ xfs_bmap_extents_to_btree(
xfs_bmbt_rec_t *arp; /* child record pointer */
xfs_bmbt_block_t *block; /* btree root block */
xfs_btree_cur_t *cur; /* bmap btree cursor */
- xfs_bmbt_rec_t *ep; /* extent list pointer */
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
int error; /* error return value */
- xfs_extnum_t i, cnt; /* extent list index */
+ xfs_extnum_t i, cnt; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_bmbt_key_t *kp; /* root block key pointer */
xfs_mount_t *mp; /* mount structure */
- xfs_extnum_t nextents; /* extent list size */
+ xfs_extnum_t nextents; /* number of file extents */
xfs_bmbt_ptr_t *pp; /* root block address pointer */
ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -3343,7 +3322,8 @@ xfs_bmap_extents_to_btree(
ablock->bb_rightsib = cpu_to_be64(NULLDFSBNO);
arp = XFS_BMAP_REC_IADDR(ablock, 1, cur);
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- for (ep = ifp->if_u1.if_extents, cnt = i = 0; i < nextents; i++, ep++) {
+ for (cnt = i = 0; i < nextents; i++) {
+ ep = xfs_iext_get_ext(ifp, i);
if (!ISNULLSTARTBLOCK(xfs_bmbt_get_startblock(ep))) {
arp->l0 = INT_GET(ep->l0, ARCH_CONVERT);
arp->l1 = INT_GET(ep->l1, ARCH_CONVERT);
@@ -3373,34 +3353,6 @@ xfs_bmap_extents_to_btree(
}
/*
- * Insert new item(s) in the extent list for inode "ip".
- * Count new items are inserted at offset idx.
- */
-STATIC void
-xfs_bmap_insert_exlist(
- xfs_inode_t *ip, /* incore inode pointer */
- xfs_extnum_t idx, /* starting index of new items */
- xfs_extnum_t count, /* number of inserted items */
- xfs_bmbt_irec_t *new, /* items to insert */
- int whichfork) /* data or attr fork */
-{
- xfs_bmbt_rec_t *base; /* extent list base */
- xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_extnum_t nextents; /* extent list size */
- xfs_extnum_t to; /* extent list index */
-
- ifp = XFS_IFORK_PTR(ip, whichfork);
- ASSERT(ifp->if_flags & XFS_IFEXTENTS);
- xfs_iext_realloc(ip, count, whichfork);
- base = ifp->if_u1.if_extents;
- nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- memmove(&base[idx + count], &base[idx],
- (nextents - (idx + count)) * sizeof(*base));
- for (to = idx; to < idx + count; to++, new++)
- xfs_bmbt_set_all(&base[to], new);
-}
-
-/*
* Helper routine to reset inode di_forkoff field when switching
* attribute fork from local to extent format - we reset it where
* possible to make space available for inline data fork extents.
@@ -3457,12 +3409,13 @@ xfs_bmap_local_to_extents(
error = 0;
if (ifp->if_bytes) {
xfs_alloc_arg_t args; /* allocation arguments */
- xfs_buf_t *bp; /* buffer for extent list block */
- xfs_bmbt_rec_t *ep; /* extent list pointer */
+ xfs_buf_t *bp; /* buffer for extent block */
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
args.tp = tp;
args.mp = ip->i_mount;
- ASSERT(ifp->if_flags & XFS_IFINLINE);
+ ASSERT((ifp->if_flags &
+ (XFS_IFINLINE|XFS_IFEXTENTS|XFS_IFEXTIREC)) == XFS_IFINLINE);
/*
* Allocate a block. We know we need only one, since the
* file currently fits in an inode.
@@ -3492,8 +3445,8 @@ xfs_bmap_local_to_extents(
xfs_trans_log_buf(tp, bp, 0, ifp->if_bytes - 1);
xfs_bmap_forkoff_reset(args.mp, ip, whichfork);
xfs_idata_realloc(ip, -ifp->if_bytes, whichfork);
- xfs_iext_realloc(ip, 1, whichfork);
- ep = ifp->if_u1.if_extents;
+ xfs_iext_add(ifp, 0, 1);
+ ep = xfs_iext_get_ext(ifp, 0);
xfs_bmbt_set_allf(ep, 0, args.fsbno, 1, XFS_EXT_NORM);
xfs_bmap_trace_post_update(fname, "new", ip, 0, whichfork);
XFS_IFORK_NEXT_SET(ip, whichfork, 1);
@@ -3518,7 +3471,7 @@ xfs_bmbt_rec_t * /* pointer to found extent entry */
xfs_bmap_do_search_extents(
xfs_bmbt_rec_t *base, /* base of extent list */
xfs_extnum_t lastx, /* last extent index used */
- xfs_extnum_t nextents, /* extent list size */
+ xfs_extnum_t nextents, /* number of file extents */
xfs_fileoff_t bno, /* block number searched for */
int *eofp, /* out: end of file found */
xfs_extnum_t *lastxp, /* out: last extent index */
@@ -3569,9 +3522,9 @@ xfs_bmap_do_search_extents(
got.br_blockcount = xfs_bmbt_get_blockcount(ep);
*eofp = 0;
} else {
- /* binary search the extents array */
low = 0;
high = nextents - 1;
+ /* binary search the extents array */
while (low <= high) {
XFS_STATS_INC(xs_cmp_exlist);
lastx = (low + high) >> 1;
@@ -3622,6 +3575,57 @@ xfs_bmap_do_search_extents(
}
/*
+ * Search the extent records for the entry containing block bno.
+ * If bno lies in a hole, point to the next entry. If bno lies
+ * past eof, *eofp will be set, and *prevp will contain the last
+ * entry (null if none). Else, *lastxp will be set to the index
+ * of the found entry; *gotp will contain the entry.
+ */
+xfs_bmbt_rec_t * /* pointer to found extent entry */
+xfs_bmap_search_multi_extents(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_fileoff_t bno, /* block number searched for */
+ int *eofp, /* out: end of file found */
+ xfs_extnum_t *lastxp, /* out: last extent index */
+ xfs_bmbt_irec_t *gotp, /* out: extent entry found */
+ xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */
+{
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
+ xfs_extnum_t lastx; /* last extent index */
+
+ /*
+ * Initialize the extent entry structure to catch access to
+ * uninitialized br_startblock field.
+ */
+ gotp->br_startoff = 0xffa5a5a5a5a5a5a5LL;
+ gotp->br_blockcount = 0xa55a5a5a5a5a5a5aLL;
+ gotp->br_state = XFS_EXT_INVALID;
+#if XFS_BIG_BLKNOS
+ gotp->br_startblock = 0xffffa5a5a5a5a5a5LL;
+#else
+ gotp->br_startblock = 0xffffa5a5;
+#endif
+ prevp->br_startoff = NULLFILEOFF;
+
+ ep = xfs_iext_bno_to_ext(ifp, bno, &lastx);
+ if (lastx > 0) {
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx - 1), prevp);
+ }
+ if (lastx < (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t))) {
+ xfs_bmbt_get_all(ep, gotp);
+ *eofp = 0;
+ } else {
+ if (lastx > 0) {
+ *gotp = *prevp;
+ }
+ *eofp = 1;
+ ep = NULL;
+ }
+ *lastxp = lastx;
+ return ep;
+}
+
+/*
* Search the extents list for the inode, for the extent containing bno.
* If bno lies in a hole, point to the next entry. If bno lies past eof,
* *eofp will be set, and *prevp will contain the last entry (null if none).
@@ -3639,20 +3643,14 @@ xfs_bmap_search_extents(
xfs_bmbt_irec_t *prevp) /* out: previous extent entry found */
{
xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_bmbt_rec_t *base; /* base of extent list */
- xfs_extnum_t lastx; /* last extent index used */
- xfs_extnum_t nextents; /* extent list size */
- xfs_bmbt_rec_t *ep; /* extent list entry pointer */
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
int rt; /* realtime flag */
XFS_STATS_INC(xs_look_exlist);
ifp = XFS_IFORK_PTR(ip, whichfork);
- lastx = ifp->if_lastex;
- nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- base = &ifp->if_u1.if_extents[0];
- ep = xfs_bmap_do_search_extents(base, lastx, nextents, bno, eofp,
- lastxp, gotp, prevp);
+ ep = xfs_bmap_search_multi_extents(ifp, bno, eofp, lastxp, gotp, prevp);
+
rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
if (unlikely(!rt && !gotp->br_startblock && (*lastxp != NULLEXTNUM))) {
cmn_err(CE_PANIC,"Access to block zero: fs: <%s> inode: %lld "
@@ -3732,7 +3730,7 @@ xfs_bmap_trace_addentry(
}
/*
- * Add bmap trace entry prior to a call to xfs_bmap_delete_exlist.
+ * Add bmap trace entry prior to a call to xfs_iext_remove.
*/
STATIC void
xfs_bmap_trace_delete(
@@ -3747,13 +3745,13 @@ xfs_bmap_trace_delete(
ifp = XFS_IFORK_PTR(ip, whichfork);
xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_DELETE, fname, desc, ip, idx,
- cnt, &ifp->if_u1.if_extents[idx],
- cnt == 2 ? &ifp->if_u1.if_extents[idx + 1] : NULL,
+ cnt, xfs_iext_get_ext(ifp, idx),
+ cnt == 2 ? xfs_iext_get_ext(ifp, idx + 1) : NULL,
whichfork);
}
/*
- * Add bmap trace entry prior to a call to xfs_bmap_insert_exlist, or
+ * Add bmap trace entry prior to a call to xfs_iext_insert, or
* reading in the extents list from the disk (in the btree).
*/
STATIC void
@@ -3783,7 +3781,7 @@ xfs_bmap_trace_insert(
}
/*
- * Add bmap trace entry after updating an extent list entry in place.
+ * Add bmap trace entry after updating an extent record in place.
*/
STATIC void
xfs_bmap_trace_post_update(
@@ -3797,11 +3795,11 @@ xfs_bmap_trace_post_update(
ifp = XFS_IFORK_PTR(ip, whichfork);
xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_POST_UP, fname, desc, ip, idx,
- 1, &ifp->if_u1.if_extents[idx], NULL, whichfork);
+ 1, xfs_iext_get_ext(ifp, idx), NULL, whichfork);
}
/*
- * Add bmap trace entry prior to updating an extent list entry in place.
+ * Add bmap trace entry prior to updating an extent record in place.
*/
STATIC void
xfs_bmap_trace_pre_update(
@@ -3815,7 +3813,7 @@ xfs_bmap_trace_pre_update(
ifp = XFS_IFORK_PTR(ip, whichfork);
xfs_bmap_trace_addentry(XFS_BMAP_KTRACE_PRE_UP, fname, desc, ip, idx, 1,
- &ifp->if_u1.if_extents[idx], NULL, whichfork);
+ xfs_iext_get_ext(ifp, idx), NULL, whichfork);
}
#endif /* XFS_BMAP_TRACE */
@@ -3892,7 +3890,7 @@ xfs_bmap_add_attrfork(
int rsvd) /* xact may use reserved blks */
{
xfs_fsblock_t firstblock; /* 1st block/ag allocated */
- xfs_bmap_free_t flist; /* freed extent list */
+ xfs_bmap_free_t flist; /* freed extent records */
xfs_mount_t *mp; /* mount structure */
xfs_trans_t *tp; /* transaction pointer */
unsigned long s; /* spinlock spl value */
@@ -4146,7 +4144,7 @@ xfs_bmap_finish(
xfs_efd_log_item_t *efd; /* extent free data */
xfs_efi_log_item_t *efi; /* extent free intention */
int error; /* error return value */
- xfs_bmap_free_item_t *free; /* free extent list item */
+ xfs_bmap_free_item_t *free; /* free extent item */
unsigned int logres; /* new log reservation */
unsigned int logcount; /* new log count */
xfs_mount_t *mp; /* filesystem mount structure */
@@ -4242,9 +4240,9 @@ xfs_bmap_first_unused(
xfs_fileoff_t *first_unused, /* unused block */
int whichfork) /* data or attr fork */
{
- xfs_bmbt_rec_t *base; /* base of extent array */
xfs_bmbt_rec_t *ep; /* pointer to an extent entry */
int error; /* error return value */
+ int idx; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_fileoff_t lastaddr; /* last block number seen */
xfs_fileoff_t lowest; /* lowest useful block */
@@ -4265,10 +4263,8 @@ xfs_bmap_first_unused(
return error;
lowest = *first_unused;
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- base = &ifp->if_u1.if_extents[0];
- for (lastaddr = 0, max = lowest, ep = base;
- ep < &base[nextents];
- ep++) {
+ for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
+ ep = xfs_iext_get_ext(ifp, idx);
off = xfs_bmbt_get_startoff(ep);
/*
* See if the hole before this extent will work.
@@ -4287,8 +4283,8 @@ xfs_bmap_first_unused(
/*
* Returns the file-relative block number of the last block + 1 before
* last_block (input value) in the file.
- * This is not based on i_size, it is based on the extent list.
- * Returns 0 for local files, as they do not have an extent list.
+ * This is not based on i_size, it is based on the extent records.
+ * Returns 0 for local files, as they do not have extent records.
*/
int /* error */
xfs_bmap_last_before(
@@ -4335,8 +4331,8 @@ xfs_bmap_last_before(
/*
* Returns the file-relative block number of the first block past eof in
- * the file. This is not based on i_size, it is based on the extent list.
- * Returns 0 for local files, as they do not have an extent list.
+ * the file. This is not based on i_size, it is based on the extent records.
+ * Returns 0 for local files, as they do not have extent records.
*/
int /* error */
xfs_bmap_last_offset(
@@ -4345,7 +4341,6 @@ xfs_bmap_last_offset(
xfs_fileoff_t *last_block, /* last block */
int whichfork) /* data or attr fork */
{
- xfs_bmbt_rec_t *base; /* base of extent array */
xfs_bmbt_rec_t *ep; /* pointer to last extent */
int error; /* error return value */
xfs_ifork_t *ifp; /* inode fork pointer */
@@ -4368,9 +4363,7 @@ xfs_bmap_last_offset(
*last_block = 0;
return 0;
}
- base = &ifp->if_u1.if_extents[0];
- ASSERT(base != NULL);
- ep = &base[nextents - 1];
+ ep = xfs_iext_get_ext(ifp, nextents - 1);
*last_block = xfs_bmbt_get_startoff(ep) + xfs_bmbt_get_blockcount(ep);
return 0;
}
@@ -4400,7 +4393,7 @@ xfs_bmap_one_block(
return 0;
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_flags & XFS_IFEXTENTS);
- ep = ifp->if_u1.if_extents;
+ ep = xfs_iext_get_ext(ifp, 0);
xfs_bmbt_get_all(ep, &s);
rval = s.br_startoff == 0 && s.br_blockcount == 1;
if (rval && whichfork == XFS_DATA_FORK)
@@ -4435,7 +4428,6 @@ xfs_bmap_read_extents(
xfs_bmbt_ptr_t *pp; /* pointer to block address */
/* REFERENCED */
xfs_extnum_t room; /* number of entries there's room for */
- xfs_bmbt_rec_t *trp; /* target record pointer */
bno = NULLFSBLOCK;
mp = ip->i_mount;
@@ -4478,16 +4470,16 @@ xfs_bmap_read_extents(
/*
* Here with bp and block set to the leftmost leaf node in the tree.
*/
- room = ifp->if_bytes / (uint)sizeof(*trp);
- trp = ifp->if_u1.if_extents;
+ room = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
i = 0;
/*
- * Loop over all leaf nodes. Copy information to the extent list.
+ * Loop over all leaf nodes. Copy information to the extent records.
*/
for (;;) {
- xfs_bmbt_rec_t *frp, *temp;
+ xfs_bmbt_rec_t *frp, *trp;
xfs_fsblock_t nextbno;
xfs_extnum_t num_recs;
+ xfs_extnum_t start;
num_recs = be16_to_cpu(block->bb_numrecs);
@@ -4511,12 +4503,13 @@ xfs_bmap_read_extents(
if (nextbno != NULLFSBLOCK)
xfs_btree_reada_bufl(mp, nextbno, 1);
/*
- * Copy records into the extent list.
+ * Copy records into the extent records.
*/
frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
block, 1, mp->m_bmap_dmxr[0]);
- temp = trp;
- for (j = 0; j < num_recs; j++, frp++, trp++) {
+ start = i;
+ for (j = 0; j < num_recs; j++, i++, frp++) {
+ trp = xfs_iext_get_ext(ifp, i);
trp->l0 = INT_GET(frp->l0, ARCH_CONVERT);
trp->l1 = INT_GET(frp->l1, ARCH_CONVERT);
}
@@ -4526,14 +4519,14 @@ xfs_bmap_read_extents(
* any "older" data bmap btree records for a
* set bit in the "extent flag" position.
*/
- if (unlikely(xfs_check_nostate_extents(temp, num_recs))) {
+ if (unlikely(xfs_check_nostate_extents(ifp,
+ start, num_recs))) {
XFS_ERROR_REPORT("xfs_bmap_read_extents(2)",
XFS_ERRLEVEL_LOW,
ip->i_mount);
goto error0;
}
}
- i += num_recs;
xfs_trans_brelse(tp, bp);
bno = nextbno;
/*
@@ -4546,7 +4539,7 @@ xfs_bmap_read_extents(
return error;
block = XFS_BUF_TO_BMBT_BLOCK(bp);
}
- ASSERT(i == ifp->if_bytes / (uint)sizeof(*trp));
+ ASSERT(i == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
ASSERT(i == XFS_IFORK_NEXTENTS(ip, whichfork));
xfs_bmap_trace_exlist(fname, ip, i, whichfork);
return 0;
@@ -4557,7 +4550,7 @@ error0:
#ifdef XFS_BMAP_TRACE
/*
- * Add bmap trace insert entries for all the contents of the extent list.
+ * Add bmap trace insert entries for all the contents of the extent records.
*/
void
xfs_bmap_trace_exlist(
@@ -4566,16 +4559,15 @@ xfs_bmap_trace_exlist(
xfs_extnum_t cnt, /* count of entries in the list */
int whichfork) /* data or attr fork */
{
- xfs_bmbt_rec_t *base; /* base of extent list */
- xfs_bmbt_rec_t *ep; /* current entry in extent list */
- xfs_extnum_t idx; /* extent list entry number */
+ xfs_bmbt_rec_t *ep; /* current extent record */
+ xfs_extnum_t idx; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_bmbt_irec_t s; /* extent list record */
+ xfs_bmbt_irec_t s; /* file extent record */
ifp = XFS_IFORK_PTR(ip, whichfork);
- ASSERT(cnt == ifp->if_bytes / (uint)sizeof(*base));
- base = ifp->if_u1.if_extents;
- for (idx = 0, ep = base; idx < cnt; idx++, ep++) {
+ ASSERT(cnt == (ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t)));
+ for (idx = 0; idx < cnt; idx++) {
+ ep = xfs_iext_get_ext(ifp, idx);
xfs_bmbt_get_all(ep, &s);
xfs_bmap_trace_insert(fname, "exlist", ip, idx, 1, &s, NULL,
whichfork);
@@ -4661,14 +4653,10 @@ xfs_bmapi(
xfs_bmalloca_t bma; /* args for xfs_bmap_alloc */
xfs_btree_cur_t *cur; /* bmap btree cursor */
xfs_fileoff_t end; /* end of mapped file region */
- int eof; /* we've hit the end of extent list */
- char contig; /* allocation must be one extent */
- char delay; /* this request is for delayed alloc */
- char exact; /* don't do all of wasdelayed extent */
- char convert; /* unwritten extent I/O completion */
- xfs_bmbt_rec_t *ep; /* extent list entry pointer */
+ int eof; /* we've hit the end of extents */
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
int error; /* error return */
- xfs_bmbt_irec_t got; /* current extent list record */
+ xfs_bmbt_irec_t got; /* current file extent record */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extlen_t indlen; /* indirect blocks length */
xfs_extnum_t lastx; /* last useful extent number */
@@ -4680,17 +4668,13 @@ xfs_bmapi(
int nallocs; /* number of extents alloc\'d */
xfs_extnum_t nextents; /* number of extents in file */
xfs_fileoff_t obno; /* old block number (offset) */
- xfs_bmbt_irec_t prev; /* previous extent list record */
+ xfs_bmbt_irec_t prev; /* previous file extent record */
int tmp_logflags; /* temp flags holder */
int whichfork; /* data or attr fork */
char inhole; /* current location is hole in file */
- char stateless; /* ignore state flag set */
- char trim; /* output trimmed to match range */
- char userdata; /* allocating non-metadata */
char wasdelay; /* old extent was delayed */
char wr; /* this is a write request */
char rt; /* this is a realtime file */
- char rsvd; /* OK to allocate reserved blocks */
#ifdef DEBUG
xfs_fileoff_t orig_bno; /* original block number value */
int orig_flags; /* original flags arg value */
@@ -4727,15 +4711,8 @@ xfs_bmapi(
XFS_STATS_INC(xs_blk_mapw);
else
XFS_STATS_INC(xs_blk_mapr);
- delay = (flags & XFS_BMAPI_DELAY) != 0;
- trim = (flags & XFS_BMAPI_ENTIRE) == 0;
- userdata = (flags & XFS_BMAPI_METADATA) == 0;
- convert = (flags & XFS_BMAPI_CONVERT) != 0;
- exact = (flags & XFS_BMAPI_EXACT) != 0;
- rsvd = (flags & XFS_BMAPI_RSVBLOCKS) != 0;
- contig = (flags & XFS_BMAPI_CONTIG) != 0;
/*
- * stateless is used to combine extents which
+ * IGSTATE flag is used to combine extents which
* differ only due to the state of the extents.
* This technique is used from xfs_getbmap()
* when the caller does not wish to see the
@@ -4751,10 +4728,9 @@ xfs_bmapi(
* xfs_strat_comp(), where the xfs_bmapi() call
* is transactioned, and the extents combined.
*/
- stateless = (flags & XFS_BMAPI_IGSTATE) != 0;
- if (stateless && wr) /* if writing unwritten space, no */
- wr = 0; /* allocations are allowed */
- ASSERT(wr || !delay);
+ if ((flags & XFS_BMAPI_IGSTATE) && wr) /* if writing unwritten space */
+ wr = 0; /* no allocations are allowed */
+ ASSERT(wr || !(flags & XFS_BMAPI_DELAY));
logflags = 0;
nallocs = 0;
cur = NULL;
@@ -4789,7 +4765,7 @@ xfs_bmapi(
if (eof && !wr)
got.br_startoff = end;
inhole = eof || got.br_startoff > bno;
- wasdelay = wr && !inhole && !delay &&
+ wasdelay = wr && !inhole && !(flags & XFS_BMAPI_DELAY) &&
ISNULLSTARTBLOCK(got.br_startblock);
/*
* First, deal with the hole before the allocated space
@@ -4801,11 +4777,11 @@ xfs_bmapi(
* allocate the stuff asked for in this bmap call
* but that wouldn't be as good.
*/
- if (wasdelay && !exact) {
+ if (wasdelay && !(flags & XFS_BMAPI_EXACT)) {
alen = (xfs_extlen_t)got.br_blockcount;
aoff = got.br_startoff;
if (lastx != NULLEXTNUM && lastx) {
- ep = &ifp->if_u1.if_extents[lastx - 1];
+ ep = xfs_iext_get_ext(ifp, lastx - 1);
xfs_bmbt_get_all(ep, &prev);
}
} else if (wasdelay) {
@@ -4823,8 +4799,8 @@ xfs_bmapi(
got.br_startoff - bno);
aoff = bno;
}
- minlen = contig ? alen : 1;
- if (delay) {
+ minlen = (flags & XFS_BMAPI_CONTIG) ? alen : 1;
+ if (flags & XFS_BMAPI_DELAY) {
xfs_extlen_t extsz;
/* Figure out the extent size, adjust alen */
@@ -4837,7 +4813,9 @@ xfs_bmapi(
if (extsz) {
error = xfs_bmap_extsize_align(mp,
&got, &prev, extsz,
- rt, eof, delay, convert,
+ rt, eof,
+ flags&XFS_BMAPI_DELAY,
+ flags&XFS_BMAPI_CONVERT,
&aoff, &alen);
ASSERT(!error);
}
@@ -4875,24 +4853,29 @@ xfs_bmapi(
if (rt) {
error = xfs_mod_incore_sb(mp,
XFS_SBS_FREXTENTS,
- -(extsz), rsvd);
+ -(extsz), (flags &
+ XFS_BMAPI_RSVBLOCKS));
} else {
error = xfs_mod_incore_sb(mp,
XFS_SBS_FDBLOCKS,
- -(alen), rsvd);
+ -(alen), (flags &
+ XFS_BMAPI_RSVBLOCKS));
}
if (!error) {
error = xfs_mod_incore_sb(mp,
XFS_SBS_FDBLOCKS,
- -(indlen), rsvd);
+ -(indlen), (flags &
+ XFS_BMAPI_RSVBLOCKS));
if (error && rt)
xfs_mod_incore_sb(mp,
XFS_SBS_FREXTENTS,
- extsz, rsvd);
+ extsz, (flags &
+ XFS_BMAPI_RSVBLOCKS));
else if (error)
xfs_mod_incore_sb(mp,
XFS_SBS_FDBLOCKS,
- alen, rsvd);
+ alen, (flags &
+ XFS_BMAPI_RSVBLOCKS));
}
if (error) {
@@ -4925,7 +4908,7 @@ xfs_bmapi(
/* Indicate if this is the first user data
* in the file, or just any user data.
*/
- if (userdata) {
+ if (!(flags & XFS_BMAPI_METADATA)) {
bma.userdata = (aoff == 0) ?
XFS_ALLOC_INITIAL_USER_DATA :
XFS_ALLOC_USERDATA;
@@ -4937,7 +4920,7 @@ xfs_bmapi(
bma.firstblock = *firstblock;
bma.alen = alen;
bma.off = aoff;
- bma.conv = convert;
+ bma.conv = (flags & XFS_BMAPI_CONVERT);
bma.wasdel = wasdelay;
bma.minlen = minlen;
bma.low = flist->xbf_low;
@@ -4948,7 +4931,8 @@ xfs_bmapi(
* is larger than a stripe unit.
*/
if (mp->m_dalign && alen >= mp->m_dalign &&
- userdata && whichfork == XFS_DATA_FORK) {
+ (!(flags & XFS_BMAPI_METADATA)) &&
+ (whichfork == XFS_DATA_FORK)) {
if ((error = xfs_bmap_isaeof(ip, aoff,
whichfork, &bma.aeof)))
goto error0;
@@ -5011,19 +4995,19 @@ xfs_bmapi(
}
error = xfs_bmap_add_extent(ip, lastx, &cur, &got,
firstblock, flist, &tmp_logflags, whichfork,
- rsvd);
+ (flags & XFS_BMAPI_RSVBLOCKS));
logflags |= tmp_logflags;
if (error)
goto error0;
lastx = ifp->if_lastex;
- ep = &ifp->if_u1.if_extents[lastx];
+ ep = xfs_iext_get_ext(ifp, lastx);
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
xfs_bmbt_get_all(ep, &got);
ASSERT(got.br_startoff <= aoff);
ASSERT(got.br_startoff + got.br_blockcount >=
aoff + alen);
#ifdef DEBUG
- if (delay) {
+ if (flags & XFS_BMAPI_DELAY) {
ASSERT(ISNULLSTARTBLOCK(got.br_startblock));
ASSERT(STARTBLOCKVAL(got.br_startblock) > 0);
}
@@ -5052,14 +5036,15 @@ xfs_bmapi(
* Then deal with the allocated space we found.
*/
ASSERT(ep != NULL);
- if (trim && (got.br_startoff + got.br_blockcount > obno)) {
+ if (!(flags & XFS_BMAPI_ENTIRE) &&
+ (got.br_startoff + got.br_blockcount > obno)) {
if (obno > bno)
bno = obno;
ASSERT((bno >= obno) || (n == 0));
ASSERT(bno < end);
mval->br_startoff = bno;
if (ISNULLSTARTBLOCK(got.br_startblock)) {
- ASSERT(!wr || delay);
+ ASSERT(!wr || (flags & XFS_BMAPI_DELAY));
mval->br_startblock = DELAYSTARTBLOCK;
} else
mval->br_startblock =
@@ -5081,7 +5066,7 @@ xfs_bmapi(
} else {
*mval = got;
if (ISNULLSTARTBLOCK(mval->br_startblock)) {
- ASSERT(!wr || delay);
+ ASSERT(!wr || (flags & XFS_BMAPI_DELAY));
mval->br_startblock = DELAYSTARTBLOCK;
}
}
@@ -5107,12 +5092,12 @@ xfs_bmapi(
mval->br_state = XFS_EXT_NORM;
error = xfs_bmap_add_extent(ip, lastx, &cur, mval,
firstblock, flist, &tmp_logflags, whichfork,
- rsvd);
+ (flags & XFS_BMAPI_RSVBLOCKS));
logflags |= tmp_logflags;
if (error)
goto error0;
lastx = ifp->if_lastex;
- ep = &ifp->if_u1.if_extents[lastx];
+ ep = xfs_iext_get_ext(ifp, lastx);
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
xfs_bmbt_get_all(ep, &got);
/*
@@ -5124,9 +5109,10 @@ xfs_bmapi(
continue;
}
- ASSERT(!trim ||
+ ASSERT((flags & XFS_BMAPI_ENTIRE) ||
((mval->br_startoff + mval->br_blockcount) <= end));
- ASSERT(!trim || (mval->br_blockcount <= len) ||
+ ASSERT((flags & XFS_BMAPI_ENTIRE) ||
+ (mval->br_blockcount <= len) ||
(mval->br_startoff < obno));
bno = mval->br_startoff + mval->br_blockcount;
len = end - bno;
@@ -5141,7 +5127,8 @@ xfs_bmapi(
mval[-1].br_startblock != HOLESTARTBLOCK &&
mval->br_startblock ==
mval[-1].br_startblock + mval[-1].br_blockcount &&
- (stateless || mval[-1].br_state == mval->br_state)) {
+ ((flags & XFS_BMAPI_IGSTATE) ||
+ mval[-1].br_state == mval->br_state)) {
ASSERT(mval->br_startoff ==
mval[-1].br_startoff + mval[-1].br_blockcount);
mval[-1].br_blockcount += mval->br_blockcount;
@@ -5168,8 +5155,7 @@ xfs_bmapi(
/*
* Else go on to the next record.
*/
- ep++;
- lastx++;
+ ep = xfs_iext_get_ext(ifp, ++lastx);
if (lastx >= nextents) {
eof = 1;
prev = got;
@@ -5199,7 +5185,7 @@ xfs_bmapi(
error0:
/*
* Log everything. Do this after conversion, there's no point in
- * logging the extent list if we've converted to btree format.
+ * logging the extent records if we've converted to btree format.
*/
if ((logflags & XFS_ILOG_FEXT(whichfork)) &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
@@ -5252,12 +5238,12 @@ xfs_bmapi_single(
xfs_fsblock_t *fsb, /* output: mapped block */
xfs_fileoff_t bno) /* starting file offs. mapped */
{
- int eof; /* we've hit the end of extent list */
+ int eof; /* we've hit the end of extents */
int error; /* error return */
- xfs_bmbt_irec_t got; /* current extent list record */
+ xfs_bmbt_irec_t got; /* current file extent record */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extnum_t lastx; /* last useful extent number */
- xfs_bmbt_irec_t prev; /* previous extent list record */
+ xfs_bmbt_irec_t prev; /* previous file extent record */
ifp = XFS_IFORK_PTR(ip, whichfork);
if (unlikely(
@@ -5312,18 +5298,18 @@ xfs_bunmapi(
xfs_btree_cur_t *cur; /* bmap btree cursor */
xfs_bmbt_irec_t del; /* extent being deleted */
int eof; /* is deleting at eof */
- xfs_bmbt_rec_t *ep; /* extent list entry pointer */
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
int error; /* error return value */
xfs_extnum_t extno; /* extent number in list */
- xfs_bmbt_irec_t got; /* current extent list entry */
+ xfs_bmbt_irec_t got; /* current extent record */
xfs_ifork_t *ifp; /* inode fork pointer */
int isrt; /* freeing in rt area */
xfs_extnum_t lastx; /* last extent index used */
int logflags; /* transaction logging flags */
xfs_extlen_t mod; /* rt extent offset */
xfs_mount_t *mp; /* mount structure */
- xfs_extnum_t nextents; /* size of extent list */
- xfs_bmbt_irec_t prev; /* previous extent list entry */
+ xfs_extnum_t nextents; /* number of file extents */
+ xfs_bmbt_irec_t prev; /* previous extent record */
xfs_fileoff_t start; /* first file offset deleted */
int tmp_logflags; /* partial logging flags */
int wasdel; /* was a delayed alloc extent */
@@ -5369,7 +5355,7 @@ xfs_bunmapi(
* file, back up to the last block if so...
*/
if (eof) {
- ep = &ifp->if_u1.if_extents[--lastx];
+ ep = xfs_iext_get_ext(ifp, --lastx);
xfs_bmbt_get_all(ep, &got);
bno = got.br_startoff + got.br_blockcount - 1;
}
@@ -5393,7 +5379,7 @@ xfs_bunmapi(
if (got.br_startoff > bno) {
if (--lastx < 0)
break;
- ep--;
+ ep = xfs_iext_get_ext(ifp, lastx);
xfs_bmbt_get_all(ep, &got);
}
/*
@@ -5440,7 +5426,8 @@ xfs_bunmapi(
del.br_blockcount : mod;
if (bno < got.br_startoff) {
if (--lastx >= 0)
- xfs_bmbt_get_all(--ep, &got);
+ xfs_bmbt_get_all(xfs_iext_get_ext(
+ ifp, lastx), &got);
}
continue;
}
@@ -5500,7 +5487,8 @@ xfs_bunmapi(
* try again.
*/
ASSERT(lastx > 0);
- xfs_bmbt_get_all(ep - 1, &prev);
+ xfs_bmbt_get_all(xfs_iext_get_ext(ifp,
+ lastx - 1), &prev);
ASSERT(prev.br_state == XFS_EXT_NORM);
ASSERT(!ISNULLSTARTBLOCK(prev.br_startblock));
ASSERT(del.br_startblock ==
@@ -5587,12 +5575,12 @@ nodelete:
* If not done go on to the next (previous) record.
* Reset ep in case the extents array was re-alloced.
*/
- ep = &ifp->if_u1.if_extents[lastx];
+ ep = xfs_iext_get_ext(ifp, lastx);
if (bno != (xfs_fileoff_t)-1 && bno >= start) {
if (lastx >= XFS_IFORK_NEXTENTS(ip, whichfork) ||
xfs_bmbt_get_startoff(ep) > bno) {
- lastx--;
- ep--;
+ if (--lastx >= 0)
+ ep = xfs_iext_get_ext(ifp, lastx);
}
if (lastx >= 0)
xfs_bmbt_get_all(ep, &got);
@@ -5636,7 +5624,7 @@ nodelete:
error0:
/*
* Log everything. Do this after conversion, there's no point in
- * logging the extent list if we've converted to btree format.
+ * logging the extent records if we've converted to btree format.
*/
if ((logflags & XFS_ILOG_FEXT(whichfork)) &&
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS)
@@ -5892,9 +5880,9 @@ xfs_bmap_isaeof(
{
int error; /* error return value */
xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_bmbt_rec_t *lastrec; /* extent list entry pointer */
- xfs_extnum_t nextents; /* size of extent list */
- xfs_bmbt_irec_t s; /* expanded extent list entry */
+ xfs_bmbt_rec_t *lastrec; /* extent record pointer */
+ xfs_extnum_t nextents; /* number of file extents */
+ xfs_bmbt_irec_t s; /* expanded extent record */
ASSERT(whichfork == XFS_DATA_FORK);
ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -5909,7 +5897,7 @@ xfs_bmap_isaeof(
/*
* Go to the last extent
*/
- lastrec = &ifp->if_u1.if_extents[nextents - 1];
+ lastrec = xfs_iext_get_ext(ifp, nextents - 1);
xfs_bmbt_get_all(lastrec, &s);
/*
* Check we are allocating in the last extent (for delayed allocations)
@@ -5936,8 +5924,8 @@ xfs_bmap_eof(
xfs_fsblock_t blockcount; /* extent block count */
int error; /* error return value */
xfs_ifork_t *ifp; /* inode fork pointer */
- xfs_bmbt_rec_t *lastrec; /* extent list entry pointer */
- xfs_extnum_t nextents; /* size of extent list */
+ xfs_bmbt_rec_t *lastrec; /* extent record pointer */
+ xfs_extnum_t nextents; /* number of file extents */
xfs_fileoff_t startoff; /* extent starting file offset */
ASSERT(whichfork == XFS_DATA_FORK);
@@ -5953,7 +5941,7 @@ xfs_bmap_eof(
/*
* Go to the last extent
*/
- lastrec = &ifp->if_u1.if_extents[nextents - 1];
+ lastrec = xfs_iext_get_ext(ifp, nextents - 1);
startoff = xfs_bmbt_get_startoff(lastrec);
blockcount = xfs_bmbt_get_blockcount(lastrec);
*eof = endoff >= startoff + blockcount;
@@ -5969,18 +5957,21 @@ xfs_bmap_check_extents(
xfs_inode_t *ip, /* incore inode pointer */
int whichfork) /* data or attr fork */
{
- xfs_bmbt_rec_t *base; /* base of extents list */
xfs_bmbt_rec_t *ep; /* current extent entry */
+ xfs_extnum_t idx; /* extent record index */
xfs_ifork_t *ifp; /* inode fork pointer */
xfs_extnum_t nextents; /* number of extents in list */
+ xfs_bmbt_rec_t *nextp; /* next extent entry */
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_flags & XFS_IFEXTENTS);
- base = ifp->if_u1.if_extents;
nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
- for (ep = base; ep < &base[nextents - 1]; ep++) {
+ ep = xfs_iext_get_ext(ifp, 0);
+ for (idx = 0; idx < nextents - 1; idx++) {
+ nextp = xfs_iext_get_ext(ifp, idx + 1);
xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep,
- (void *)(ep + 1));
+ (void *)(nextp));
+ ep = nextp;
}
}
@@ -6119,12 +6110,14 @@ xfs_bmap_check_leaf_extents(
xfs_fsblock_t bno; /* block # of "block" */
xfs_buf_t *bp; /* buffer for "block" */
int error; /* error return value */
- xfs_extnum_t i=0; /* index into the extents list */
+ xfs_extnum_t i=0, j; /* index into the extents list */
xfs_ifork_t *ifp; /* fork structure */
int level; /* btree level, for checking */
xfs_mount_t *mp; /* file system mount structure */
xfs_bmbt_ptr_t *pp; /* pointer to block address */
- xfs_bmbt_rec_t *ep, *lastp; /* extent pointers in block entry */
+ xfs_bmbt_rec_t *ep; /* pointer to current extent */
+ xfs_bmbt_rec_t *lastp; /* pointer to previous extent */
+ xfs_bmbt_rec_t *nextp; /* pointer to next extent */
int bp_release = 0;
if (XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE) {
@@ -6194,7 +6187,6 @@ xfs_bmap_check_leaf_extents(
*/
lastp = NULL;
for (;;) {
- xfs_bmbt_rec_t *frp;
xfs_fsblock_t nextbno;
xfs_extnum_t num_recs;
@@ -6213,18 +6205,20 @@ xfs_bmap_check_leaf_extents(
* conform with the first entry in this one.
*/
- frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
+ ep = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
block, 1, mp->m_bmap_dmxr[0]);
-
- for (ep = frp;ep < frp + (num_recs - 1); ep++) {
+ for (j = 1; j < num_recs; j++) {
+ nextp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
+ block, j + 1, mp->m_bmap_dmxr[0]);
if (lastp) {
xfs_btree_check_rec(XFS_BTNUM_BMAP,
(void *)lastp, (void *)ep);
}
xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep,
- (void *)(ep + 1));
+ (void *)(nextp));
+ lastp = ep;
+ ep = nextp;
}
- lastp = frp + num_recs - 1; /* For the next iteration */
i += num_recs;
if (bp_release) {
@@ -6288,7 +6282,7 @@ xfs_bmap_count_blocks(
mp = ip->i_mount;
ifp = XFS_IFORK_PTR(ip, whichfork);
if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
- if (unlikely(xfs_bmap_count_leaves(ifp->if_u1.if_extents,
+ if (unlikely(xfs_bmap_count_leaves(ifp, 0,
ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
count) < 0)) {
XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)",
@@ -6310,7 +6304,7 @@ xfs_bmap_count_blocks(
ASSERT(XFS_FSB_TO_AGBNO(mp, INT_GET(*pp, ARCH_CONVERT)) < mp->m_sb.sb_agblocks);
bno = INT_GET(*pp, ARCH_CONVERT);
- if (unlikely(xfs_bmap_count_tree(mp, tp, bno, level, count) < 0)) {
+ if (unlikely(xfs_bmap_count_tree(mp, tp, ifp, bno, level, count) < 0)) {
XFS_ERROR_REPORT("xfs_bmap_count_blocks(2)", XFS_ERRLEVEL_LOW,
mp);
return XFS_ERROR(EFSCORRUPTED);
@@ -6327,6 +6321,7 @@ int /* error */
xfs_bmap_count_tree(
xfs_mount_t *mp, /* file system mount point */
xfs_trans_t *tp, /* transaction pointer */
+ xfs_ifork_t *ifp, /* inode fork pointer */
xfs_fsblock_t blockno, /* file system block number */
int levelin, /* level in btree */
int *count) /* Count of blocks */
@@ -6339,7 +6334,6 @@ xfs_bmap_count_tree(
xfs_fsblock_t nextbno;
xfs_bmbt_block_t *block, *nextblock;
int numrecs;
- xfs_bmbt_rec_t *frp;
if ((error = xfs_btree_read_bufl(mp, tp, bno, 0, &bp, XFS_BMAP_BTREE_REF)))
return error;
@@ -6364,7 +6358,7 @@ xfs_bmap_count_tree(
xfs_bmbt, block, 1, mp->m_bmap_dmxr[1]);
bno = INT_GET(*pp, ARCH_CONVERT);
if (unlikely((error =
- xfs_bmap_count_tree(mp, tp, bno, level, count)) < 0)) {
+ xfs_bmap_count_tree(mp, tp, ifp, bno, level, count)) < 0)) {
xfs_trans_brelse(tp, bp);
XFS_ERROR_REPORT("xfs_bmap_count_tree(1)",
XFS_ERRLEVEL_LOW, mp);
@@ -6376,9 +6370,8 @@ xfs_bmap_count_tree(
for (;;) {
nextbno = be64_to_cpu(block->bb_rightsib);
numrecs = be16_to_cpu(block->bb_numrecs);
- frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
- xfs_bmbt, block, 1, mp->m_bmap_dmxr[0]);
- if (unlikely(xfs_bmap_disk_count_leaves(frp, numrecs, count) < 0)) {
+ if (unlikely(xfs_bmap_disk_count_leaves(ifp, mp,
+ 0, block, numrecs, count) < 0)) {
xfs_trans_brelse(tp, bp);
XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
XFS_ERRLEVEL_LOW, mp);
@@ -6399,33 +6392,45 @@ xfs_bmap_count_tree(
}
/*
- * Count leaf blocks given a pointer to an extent list.
+ * Count leaf blocks given a range of extent records.
*/
int
xfs_bmap_count_leaves(
- xfs_bmbt_rec_t *frp,
+ xfs_ifork_t *ifp,
+ xfs_extnum_t idx,
int numrecs,
int *count)
{
int b;
+ xfs_bmbt_rec_t *frp;
- for ( b = 1; b <= numrecs; b++, frp++)
+ for (b = 0; b < numrecs; b++) {
+ frp = xfs_iext_get_ext(ifp, idx + b);
*count += xfs_bmbt_get_blockcount(frp);
+ }
return 0;
}
/*
- * Count leaf blocks given a pointer to an extent list originally in btree format.
+ * Count leaf blocks given a range of extent records originally
+ * in btree format.
*/
int
xfs_bmap_disk_count_leaves(
- xfs_bmbt_rec_t *frp,
+ xfs_ifork_t *ifp,
+ xfs_mount_t *mp,
+ xfs_extnum_t idx,
+ xfs_bmbt_block_t *block,
int numrecs,
int *count)
{
int b;
+ xfs_bmbt_rec_t *frp;
- for ( b = 1; b <= numrecs; b++, frp++)
+ for (b = 1; b <= numrecs; b++) {
+ frp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize,
+ xfs_bmbt, block, idx + b, mp->m_bmap_dmxr[0]);
*count += xfs_bmbt_disk_get_blockcount(frp);
+ }
return 0;
}
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h
index 12cc63dfc2c..011ccaa9a1c 100644
--- a/fs/xfs/xfs_bmap.h
+++ b/fs/xfs/xfs_bmap.h
@@ -20,6 +20,7 @@
struct getbmap;
struct xfs_bmbt_irec;
+struct xfs_ifork;
struct xfs_inode;
struct xfs_mount;
struct xfs_trans;
@@ -347,9 +348,28 @@ xfs_bmap_count_blocks(
*/
int
xfs_check_nostate_extents(
- xfs_bmbt_rec_t *ep,
+ struct xfs_ifork *ifp,
+ xfs_extnum_t idx,
xfs_extnum_t num);
+/*
+ * Call xfs_bmap_do_search_extents() to search for the extent
+ * record containing block bno. If in multi-level in-core extent
+ * allocation mode, find and extract the target extent buffer,
+ * otherwise just use the direct extent list.
+ */
+xfs_bmbt_rec_t *
+xfs_bmap_search_multi_extents(struct xfs_ifork *, xfs_fileoff_t, int *,
+ xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
+
+/*
+ * Search an extent list for the extent which includes block
+ * bno.
+ */
+xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *,
+ xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *,
+ xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
+
#endif /* __KERNEL__ */
#endif /* __XFS_BMAP_H__ */
diff --git a/fs/xfs/xfs_bmap_btree.c b/fs/xfs/xfs_bmap_btree.c
index 3f1383d160e..bea44709afb 100644
--- a/fs/xfs/xfs_bmap_btree.c
+++ b/fs/xfs/xfs_bmap_btree.c
@@ -2754,7 +2754,7 @@ xfs_bmbt_update(
}
/*
- * Check an extent list, which has just been read, for
+ * Check extent records, which have just been read, for
* any bit in the extent flag field. ASSERT on debug
* kernels, as this condition should not occur.
* Return an error condition (1) if any flags found,
@@ -2763,10 +2763,14 @@ xfs_bmbt_update(
int
xfs_check_nostate_extents(
- xfs_bmbt_rec_t *ep,
+ xfs_ifork_t *ifp,
+ xfs_extnum_t idx,
xfs_extnum_t num)
{
- for (; num > 0; num--, ep++) {
+ xfs_bmbt_rec_t *ep;
+
+ for (; num > 0; num--, idx++) {
+ ep = xfs_iext_get_ext(ifp, idx);
if ((ep->l0 >>
(64 - BMBT_EXNTFLAG_BITLEN)) != 0) {
ASSERT(0);
diff --git a/fs/xfs/xfs_bmap_btree.h b/fs/xfs/xfs_bmap_btree.h
index e095a2d344a..6478cfa0e53 100644
--- a/fs/xfs/xfs_bmap_btree.h
+++ b/fs/xfs/xfs_bmap_btree.h
@@ -372,14 +372,6 @@ extern int xfs_bmbt_get_rec(struct xfs_btree_cur *, xfs_fileoff_t *,
xfs_exntst_t *, int *);
#endif
-/*
- * Search an extent list for the extent which includes block
- * bno.
- */
-xfs_bmbt_rec_t *xfs_bmap_do_search_extents(xfs_bmbt_rec_t *,
- xfs_extnum_t, xfs_extnum_t, xfs_fileoff_t, int *,
- xfs_extnum_t *, xfs_bmbt_irec_t *, xfs_bmbt_irec_t *);
-
#endif /* __KERNEL__ */
#endif /* __XFS_BMAP_BTREE_H__ */
diff --git a/fs/xfs/xfs_clnt.h b/fs/xfs/xfs_clnt.h
index f57cc9ac875..022fff62085 100644
--- a/fs/xfs/xfs_clnt.h
+++ b/fs/xfs/xfs_clnt.h
@@ -68,8 +68,6 @@ struct xfs_mount_args {
* enforcement */
#define XFSMNT_PQUOTAENF 0x00000040 /* IRIX project quota limit
* enforcement */
-#define XFSMNT_NOATIME 0x00000100 /* don't modify access
- * times on reads */
#define XFSMNT_NOALIGN 0x00000200 /* don't allocate at
* stripe boundaries*/
#define XFSMNT_RETERR 0x00000400 /* return error to user */
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 473671fa5c1..4bae3a76c67 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -126,10 +126,10 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
node = bp->data;
node->hdr.info.forw = 0;
node->hdr.info.back = 0;
- INT_SET(node->hdr.info.magic, ARCH_CONVERT, XFS_DA_NODE_MAGIC);
+ node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC);
node->hdr.info.pad = 0;
node->hdr.count = 0;
- INT_SET(node->hdr.level, ARCH_CONVERT, level);
+ node->hdr.level = cpu_to_be16(level);
xfs_da_log_buf(tp, bp,
XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state)
node = oldblk->bp->data;
if (node->hdr.info.forw) {
- if (INT_GET(node->hdr.info.forw, ARCH_CONVERT) == addblk->blkno) {
+ if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) {
bp = addblk->bp;
} else {
ASSERT(state->extravalid);
bp = state->extrablk.bp;
}
node = bp->data;
- INT_SET(node->hdr.info.back, ARCH_CONVERT, oldblk->blkno);
+ node->hdr.info.back = cpu_to_be32(oldblk->blkno);
xfs_da_log_buf(state->args->trans, bp,
XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info)));
}
node = oldblk->bp->data;
- if (INT_GET(node->hdr.info.back, ARCH_CONVERT)) {
- if (INT_GET(node->hdr.info.back, ARCH_CONVERT) == addblk->blkno) {
+ if (node->hdr.info.back) {
+ if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) {
bp = addblk->bp;
} else {
ASSERT(state->extravalid);
bp = state->extrablk.bp;
}
node = bp->data;
- INT_SET(node->hdr.info.forw, ARCH_CONVERT, oldblk->blkno);
+ node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
xfs_da_log_buf(state->args->trans, bp,
XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info)));
@@ -359,14 +359,14 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(bp != NULL);
node = bp->data;
oldroot = blk1->bp->data;
- if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
- size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] -
+ if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) {
+ size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
(char *)oldroot);
} else {
ASSERT(XFS_DIR_IS_V2(mp));
- ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
leaf = (xfs_dir2_leaf_t *)oldroot;
- size = (int)((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] -
+ size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] -
(char *)leaf);
}
memcpy(node, oldroot, size);
@@ -381,18 +381,18 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
error = xfs_da_node_create(args,
args->whichfork == XFS_DATA_FORK &&
XFS_DIR_IS_V2(mp) ? mp->m_dirleafblk : 0,
- INT_GET(node->hdr.level, ARCH_CONVERT) + 1, &bp, args->whichfork);
+ be16_to_cpu(node->hdr.level) + 1, &bp, args->whichfork);
if (error)
return(error);
node = bp->data;
- INT_SET(node->btree[0].hashval, ARCH_CONVERT, blk1->hashval);
- INT_SET(node->btree[0].before, ARCH_CONVERT, blk1->blkno);
- INT_SET(node->btree[1].hashval, ARCH_CONVERT, blk2->hashval);
- INT_SET(node->btree[1].before, ARCH_CONVERT, blk2->blkno);
- INT_SET(node->hdr.count, ARCH_CONVERT, 2);
+ node->btree[0].hashval = cpu_to_be32(blk1->hashval);
+ node->btree[0].before = cpu_to_be32(blk1->blkno);
+ node->btree[1].hashval = cpu_to_be32(blk2->hashval);
+ node->btree[1].before = cpu_to_be32(blk2->blkno);
+ node->hdr.count = cpu_to_be16(2);
#ifdef DEBUG
- if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) {
+ if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) {
ASSERT(blk1->blkno >= mp->m_dirleafblk &&
blk1->blkno < mp->m_dirfreeblk);
ASSERT(blk2->blkno >= mp->m_dirleafblk &&
@@ -424,7 +424,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
int useextra;
node = oldblk->bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
/*
* With V2 the extra block is data or freespace.
@@ -435,7 +435,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
/*
* Do we have to split the node?
*/
- if ((INT_GET(node->hdr.count, ARCH_CONVERT) + newcount) > state->node_ents) {
+ if ((be16_to_cpu(node->hdr.count) + newcount) > state->node_ents) {
/*
* Allocate a new node, add to the doubly linked chain of
* nodes, then move some of our excess entries into it.
@@ -472,7 +472,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
* If we had double-split op below us, then add the extra block too.
*/
node = oldblk->bp->data;
- if (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT)) {
+ if (oldblk->index <= be16_to_cpu(node->hdr.count)) {
oldblk->index++;
xfs_da_node_add(state, oldblk, addblk);
if (useextra) {
@@ -516,17 +516,17 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
* Figure out how many entries need to move, and in which direction.
* Swap the nodes around if that makes it simpler.
*/
- if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) &&
- ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) ||
- (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) <
- INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) {
+ if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
+ ((be32_to_cpu(node2->btree[0].hashval) < be32_to_cpu(node1->btree[0].hashval)) ||
+ (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
+ be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) {
tmpnode = node1;
node1 = node2;
node2 = tmpnode;
}
- ASSERT(INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- ASSERT(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2;
+ ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ count = (be16_to_cpu(node1->hdr.count) - be16_to_cpu(node2->hdr.count)) / 2;
if (count == 0)
return;
tp = state->args->trans;
@@ -537,7 +537,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
/*
* Move elements in node2 up to make a hole.
*/
- if ((tmp = INT_GET(node2->hdr.count, ARCH_CONVERT)) > 0) {
+ if ((tmp = be16_to_cpu(node2->hdr.count)) > 0) {
tmp *= (uint)sizeof(xfs_da_node_entry_t);
btree_s = &node2->btree[0];
btree_d = &node2->btree[count];
@@ -548,13 +548,12 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
* Move the req'd B-tree elements from high in node1 to
* low in node2.
*/
- INT_MOD(node2->hdr.count, ARCH_CONVERT, count);
+ be16_add(&node2->hdr.count, count);
tmp = count * (uint)sizeof(xfs_da_node_entry_t);
- btree_s = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT) - count];
+ btree_s = &node1->btree[be16_to_cpu(node1->hdr.count) - count];
btree_d = &node2->btree[0];
memcpy(btree_d, btree_s, tmp);
- INT_MOD(node1->hdr.count, ARCH_CONVERT, -(count));
-
+ be16_add(&node1->hdr.count, -count);
} else {
/*
* Move the req'd B-tree elements from low in node2 to
@@ -563,21 +562,21 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
count = -count;
tmp = count * (uint)sizeof(xfs_da_node_entry_t);
btree_s = &node2->btree[0];
- btree_d = &node1->btree[INT_GET(node1->hdr.count, ARCH_CONVERT)];
+ btree_d = &node1->btree[be16_to_cpu(node1->hdr.count)];
memcpy(btree_d, btree_s, tmp);
- INT_MOD(node1->hdr.count, ARCH_CONVERT, count);
+ be16_add(&node1->hdr.count, count);
xfs_da_log_buf(tp, blk1->bp,
XFS_DA_LOGRANGE(node1, btree_d, tmp));
/*
* Move elements in node2 down to fill the hole.
*/
- tmp = INT_GET(node2->hdr.count, ARCH_CONVERT) - count;
+ tmp = be16_to_cpu(node2->hdr.count) - count;
tmp *= (uint)sizeof(xfs_da_node_entry_t);
btree_s = &node2->btree[count];
btree_d = &node2->btree[0];
memmove(btree_d, btree_s, tmp);
- INT_MOD(node2->hdr.count, ARCH_CONVERT, -(count));
+ be16_add(&node2->hdr.count, -count);
}
/*
@@ -588,7 +587,7 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
xfs_da_log_buf(tp, blk2->bp,
XFS_DA_LOGRANGE(node2, &node2->hdr,
sizeof(node2->hdr) +
- sizeof(node2->btree[0]) * INT_GET(node2->hdr.count, ARCH_CONVERT)));
+ sizeof(node2->btree[0]) * be16_to_cpu(node2->hdr.count)));
/*
* Record the last hashval from each block for upward propagation.
@@ -596,15 +595,15 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
*/
node1 = blk1->bp->data;
node2 = blk2->bp->data;
- blk1->hashval = INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
- blk2->hashval = INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ blk1->hashval = be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval);
+ blk2->hashval = be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval);
/*
* Adjust the expected index for insertion.
*/
- if (blk1->index >= INT_GET(node1->hdr.count, ARCH_CONVERT)) {
- blk2->index = blk1->index - INT_GET(node1->hdr.count, ARCH_CONVERT);
- blk1->index = INT_GET(node1->hdr.count, ARCH_CONVERT) + 1; /* make it invalid */
+ if (blk1->index >= be16_to_cpu(node1->hdr.count)) {
+ blk2->index = blk1->index - be16_to_cpu(node1->hdr.count);
+ blk1->index = be16_to_cpu(node1->hdr.count) + 1; /* make it invalid */
}
}
@@ -622,8 +621,8 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
node = oldblk->bp->data;
mp = state->mp;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT)));
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
ASSERT(newblk->blkno != 0);
if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
ASSERT(newblk->blkno >= mp->m_dirleafblk &&
@@ -634,22 +633,22 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
*/
tmp = 0;
btree = &node->btree[ oldblk->index ];
- if (oldblk->index < INT_GET(node->hdr.count, ARCH_CONVERT)) {
- tmp = (INT_GET(node->hdr.count, ARCH_CONVERT) - oldblk->index) * (uint)sizeof(*btree);
+ if (oldblk->index < be16_to_cpu(node->hdr.count)) {
+ tmp = (be16_to_cpu(node->hdr.count) - oldblk->index) * (uint)sizeof(*btree);
memmove(btree + 1, btree, tmp);
}
- INT_SET(btree->hashval, ARCH_CONVERT, newblk->hashval);
- INT_SET(btree->before, ARCH_CONVERT, newblk->blkno);
+ btree->hashval = cpu_to_be32(newblk->hashval);
+ btree->before = cpu_to_be32(newblk->blkno);
xfs_da_log_buf(state->args->trans, oldblk->bp,
XFS_DA_LOGRANGE(node, btree, tmp + sizeof(*btree)));
- INT_MOD(node->hdr.count, ARCH_CONVERT, +1);
+ be16_add(&node->hdr.count, 1);
xfs_da_log_buf(state->args->trans, oldblk->bp,
XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
/*
* Copy the last hash value from the oldblk to propagate upwards.
*/
- oldblk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ oldblk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1 ].hashval);
}
/*========================================================================
@@ -768,21 +767,21 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
ASSERT(args != NULL);
ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
oldroot = root_blk->bp->data;
- ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC);
ASSERT(!oldroot->hdr.info.forw);
ASSERT(!oldroot->hdr.info.back);
/*
* If the root has more than one child, then don't do anything.
*/
- if (INT_GET(oldroot->hdr.count, ARCH_CONVERT) > 1)
+ if (be16_to_cpu(oldroot->hdr.count) > 1)
return(0);
/*
* Read in the (only) child block, then copy those bytes into
* the root block's buffer and free the original child block.
*/
- child = INT_GET(oldroot->btree[ 0 ].before, ARCH_CONVERT);
+ child = be32_to_cpu(oldroot->btree[0].before);
ASSERT(child != 0);
error = xfs_da_read_buf(args->trans, args->dp, child, -1, &bp,
args->whichfork);
@@ -790,11 +789,11 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
return(error);
ASSERT(bp != NULL);
blkinfo = bp->data;
- if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) {
- ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
- INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC);
+ if (be16_to_cpu(oldroot->hdr.level) == 1) {
+ ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
+ be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC);
} else {
- ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC);
}
ASSERT(!blkinfo->forw);
ASSERT(!blkinfo->back);
@@ -830,9 +829,9 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
*/
blk = &state->path.blk[ state->path.active-1 ];
info = blk->bp->data;
- ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC);
node = (xfs_da_intnode_t *)info;
- count = INT_GET(node->hdr.count, ARCH_CONVERT);
+ count = be16_to_cpu(node->hdr.count);
if (count > (state->node_ents >> 1)) {
*action = 0; /* blk over 50%, don't try to join */
return(0); /* blk over 50%, don't try to join */
@@ -849,7 +848,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one).
*/
- forward = info->forw;
+ forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval);
@@ -871,13 +870,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
* to shrink a directory over time.
*/
/* start with smaller blk num */
- forward = (INT_GET(info->forw, ARCH_CONVERT)
- < INT_GET(info->back, ARCH_CONVERT));
+ forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
for (i = 0; i < 2; forward = !forward, i++) {
if (forward)
- blkno = INT_GET(info->forw, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->forw);
else
- blkno = INT_GET(info->back, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->back);
if (blkno == 0)
continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -889,10 +887,10 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
node = (xfs_da_intnode_t *)info;
count = state->node_ents;
count -= state->node_ents >> 2;
- count -= INT_GET(node->hdr.count, ARCH_CONVERT);
+ count -= be16_to_cpu(node->hdr.count);
node = bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- count -= INT_GET(node->hdr.count, ARCH_CONVERT);
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ count -= be16_to_cpu(node->hdr.count);
xfs_da_brelse(state->args->trans, bp);
if (count >= 0)
break; /* fits with at least 25% to spare */
@@ -973,16 +971,16 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
}
for (blk--, level--; level >= 0; blk--, level--) {
node = blk->bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
btree = &node->btree[ blk->index ];
- if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash)
+ if (be32_to_cpu(btree->hashval) == lasthash)
break;
blk->hashval = lasthash;
- INT_SET(btree->hashval, ARCH_CONVERT, lasthash);
+ btree->hashval = cpu_to_be32(lasthash);
xfs_da_log_buf(state->args->trans, blk->bp,
XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
- lasthash = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ lasthash = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
}
}
@@ -997,25 +995,25 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
int tmp;
node = drop_blk->bp->data;
- ASSERT(drop_blk->index < INT_GET(node->hdr.count, ARCH_CONVERT));
+ ASSERT(drop_blk->index < be16_to_cpu(node->hdr.count));
ASSERT(drop_blk->index >= 0);
/*
* Copy over the offending entry, or just zero it out.
*/
btree = &node->btree[drop_blk->index];
- if (drop_blk->index < (INT_GET(node->hdr.count, ARCH_CONVERT)-1)) {
- tmp = INT_GET(node->hdr.count, ARCH_CONVERT) - drop_blk->index - 1;
+ if (drop_blk->index < (be16_to_cpu(node->hdr.count)-1)) {
+ tmp = be16_to_cpu(node->hdr.count) - drop_blk->index - 1;
tmp *= (uint)sizeof(xfs_da_node_entry_t);
memmove(btree, btree + 1, tmp);
xfs_da_log_buf(state->args->trans, drop_blk->bp,
XFS_DA_LOGRANGE(node, btree, tmp));
- btree = &node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ];
+ btree = &node->btree[be16_to_cpu(node->hdr.count)-1];
}
memset((char *)btree, 0, sizeof(xfs_da_node_entry_t));
xfs_da_log_buf(state->args->trans, drop_blk->bp,
XFS_DA_LOGRANGE(node, btree, sizeof(*btree)));
- INT_MOD(node->hdr.count, ARCH_CONVERT, -1);
+ be16_add(&node->hdr.count, -1);
xfs_da_log_buf(state->args->trans, drop_blk->bp,
XFS_DA_LOGRANGE(node, &node->hdr, sizeof(node->hdr)));
@@ -1023,7 +1021,7 @@ xfs_da_node_remove(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk)
* Copy the last hash value from the block to propagate upwards.
*/
btree--;
- drop_blk->hashval = INT_GET(btree->hashval, ARCH_CONVERT);
+ drop_blk->hashval = be32_to_cpu(btree->hashval);
}
/*
@@ -1041,40 +1039,40 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
drop_node = drop_blk->bp->data;
save_node = save_blk->bp->data;
- ASSERT(INT_GET(drop_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- ASSERT(INT_GET(save_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
tp = state->args->trans;
/*
* If the dying block has lower hashvals, then move all the
* elements in the remaining block up to make a hole.
*/
- if ((INT_GET(drop_node->btree[ 0 ].hashval, ARCH_CONVERT) < INT_GET(save_node->btree[ 0 ].hashval, ARCH_CONVERT)) ||
- (INT_GET(drop_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) <
- INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))
+ if ((be32_to_cpu(drop_node->btree[0].hashval) < be32_to_cpu(save_node->btree[ 0 ].hashval)) ||
+ (be32_to_cpu(drop_node->btree[be16_to_cpu(drop_node->hdr.count)-1].hashval) <
+ be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval)))
{
- btree = &save_node->btree[ INT_GET(drop_node->hdr.count, ARCH_CONVERT) ];
- tmp = INT_GET(save_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t);
+ btree = &save_node->btree[be16_to_cpu(drop_node->hdr.count)];
+ tmp = be16_to_cpu(save_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
memmove(btree, &save_node->btree[0], tmp);
btree = &save_node->btree[0];
xfs_da_log_buf(tp, save_blk->bp,
XFS_DA_LOGRANGE(save_node, btree,
- (INT_GET(save_node->hdr.count, ARCH_CONVERT) + INT_GET(drop_node->hdr.count, ARCH_CONVERT)) *
+ (be16_to_cpu(save_node->hdr.count) + be16_to_cpu(drop_node->hdr.count)) *
sizeof(xfs_da_node_entry_t)));
} else {
- btree = &save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT) ];
+ btree = &save_node->btree[be16_to_cpu(save_node->hdr.count)];
xfs_da_log_buf(tp, save_blk->bp,
XFS_DA_LOGRANGE(save_node, btree,
- INT_GET(drop_node->hdr.count, ARCH_CONVERT) *
+ be16_to_cpu(drop_node->hdr.count) *
sizeof(xfs_da_node_entry_t)));
}
/*
* Move all the B-tree elements from drop_blk to save_blk.
*/
- tmp = INT_GET(drop_node->hdr.count, ARCH_CONVERT) * (uint)sizeof(xfs_da_node_entry_t);
+ tmp = be16_to_cpu(drop_node->hdr.count) * (uint)sizeof(xfs_da_node_entry_t);
memcpy(btree, &drop_node->btree[0], tmp);
- INT_MOD(save_node->hdr.count, ARCH_CONVERT, INT_GET(drop_node->hdr.count, ARCH_CONVERT));
+ be16_add(&save_node->hdr.count, be16_to_cpu(drop_node->hdr.count));
xfs_da_log_buf(tp, save_blk->bp,
XFS_DA_LOGRANGE(save_node, &save_node->hdr,
@@ -1083,7 +1081,7 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
/*
* Save the last hashval in the remaining block for upward propagation.
*/
- save_blk->hashval = INT_GET(save_node->btree[ INT_GET(save_node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ save_blk->hashval = be32_to_cpu(save_node->btree[be16_to_cpu(save_node->hdr.count)-1].hashval);
}
/*========================================================================
@@ -1138,46 +1136,46 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
return(error);
}
curr = blk->bp->data;
- ASSERT(INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC ||
- INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
- INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC ||
+ be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
+ be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC);
/*
* Search an intermediate node for a match.
*/
- blk->magic = INT_GET(curr->magic, ARCH_CONVERT);
- if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
+ blk->magic = be16_to_cpu(curr->magic);
+ if (blk->magic == XFS_DA_NODE_MAGIC) {
node = blk->bp->data;
- blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
/*
* Binary search. (note: small blocks will skip loop)
*/
- max = INT_GET(node->hdr.count, ARCH_CONVERT);
+ max = be16_to_cpu(node->hdr.count);
probe = span = max / 2;
hashval = args->hashval;
for (btree = &node->btree[probe]; span > 4;
btree = &node->btree[probe]) {
span /= 2;
- if (INT_GET(btree->hashval, ARCH_CONVERT) < hashval)
+ if (be32_to_cpu(btree->hashval) < hashval)
probe += span;
- else if (INT_GET(btree->hashval, ARCH_CONVERT) > hashval)
+ else if (be32_to_cpu(btree->hashval) > hashval)
probe -= span;
else
break;
}
ASSERT((probe >= 0) && (probe < max));
- ASSERT((span <= 4) || (INT_GET(btree->hashval, ARCH_CONVERT) == hashval));
+ ASSERT((span <= 4) || (be32_to_cpu(btree->hashval) == hashval));
/*
* Since we may have duplicate hashval's, find the first
* matching hashval in the node.
*/
- while ((probe > 0) && (INT_GET(btree->hashval, ARCH_CONVERT) >= hashval)) {
+ while ((probe > 0) && (be32_to_cpu(btree->hashval) >= hashval)) {
btree--;
probe--;
}
- while ((probe < max) && (INT_GET(btree->hashval, ARCH_CONVERT) < hashval)) {
+ while ((probe < max) && (be32_to_cpu(btree->hashval) < hashval)) {
btree++;
probe++;
}
@@ -1187,21 +1185,21 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
*/
if (probe == max) {
blk->index = max-1;
- blkno = INT_GET(node->btree[ max-1 ].before, ARCH_CONVERT);
+ blkno = be32_to_cpu(node->btree[max-1].before);
} else {
blk->index = probe;
- blkno = INT_GET(btree->before, ARCH_CONVERT);
+ blkno = be32_to_cpu(btree->before);
}
}
- else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) {
+ else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
break;
}
- else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) {
+ else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) {
blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
break;
}
- else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) {
+ else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL);
break;
}
@@ -1274,8 +1272,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
old_blk->magic == XFS_ATTR_LEAF_MAGIC);
- ASSERT(old_blk->magic == INT_GET(old_info->magic, ARCH_CONVERT));
- ASSERT(new_blk->magic == INT_GET(new_info->magic, ARCH_CONVERT));
+ ASSERT(old_blk->magic == be16_to_cpu(old_info->magic));
+ ASSERT(new_blk->magic == be16_to_cpu(new_info->magic));
ASSERT(old_blk->magic == new_blk->magic);
switch (old_blk->magic) {
@@ -1302,47 +1300,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
/*
* Link new block in before existing block.
*/
- INT_SET(new_info->forw, ARCH_CONVERT, old_blk->blkno);
- new_info->back = old_info->back; /* INT_: direct copy */
- if (INT_GET(old_info->back, ARCH_CONVERT)) {
+ new_info->forw = cpu_to_be32(old_blk->blkno);
+ new_info->back = old_info->back;
+ if (old_info->back) {
error = xfs_da_read_buf(args->trans, args->dp,
- INT_GET(old_info->back,
- ARCH_CONVERT), -1, &bp,
- args->whichfork);
+ be32_to_cpu(old_info->back),
+ -1, &bp, args->whichfork);
if (error)
return(error);
ASSERT(bp != NULL);
tmp_info = bp->data;
- ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(old_info->magic, ARCH_CONVERT));
- ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == old_blk->blkno);
- INT_SET(tmp_info->forw, ARCH_CONVERT, new_blk->blkno);
+ ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic));
+ ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno);
+ tmp_info->forw = cpu_to_be32(new_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
xfs_da_buf_done(bp);
}
- INT_SET(old_info->back, ARCH_CONVERT, new_blk->blkno);
+ old_info->back = cpu_to_be32(new_blk->blkno);
} else {
/*
* Link new block in after existing block.
*/
- new_info->forw = old_info->forw; /* INT_: direct copy */
- INT_SET(new_info->back, ARCH_CONVERT, old_blk->blkno);
- if (INT_GET(old_info->forw, ARCH_CONVERT)) {
+ new_info->forw = old_info->forw;
+ new_info->back = cpu_to_be32(old_blk->blkno);
+ if (old_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp,
- INT_GET(old_info->forw, ARCH_CONVERT), -1, &bp,
- args->whichfork);
+ be32_to_cpu(old_info->forw),
+ -1, &bp, args->whichfork);
if (error)
return(error);
ASSERT(bp != NULL);
tmp_info = bp->data;
- ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT)
- == INT_GET(old_info->magic, ARCH_CONVERT));
- ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT)
- == old_blk->blkno);
- INT_SET(tmp_info->back, ARCH_CONVERT, new_blk->blkno);
+ ASSERT(tmp_info->magic == old_info->magic);
+ ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno);
+ tmp_info->back = cpu_to_be32(new_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
xfs_da_buf_done(bp);
}
- INT_SET(old_info->forw, ARCH_CONVERT, new_blk->blkno);
+ old_info->forw = cpu_to_be32(new_blk->blkno);
}
xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
@@ -1360,13 +1355,13 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
node1 = node1_bp->data;
node2 = node2_bp->data;
- ASSERT((INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) &&
- (INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC));
- if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) &&
- ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) <
- INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) ||
- (INT_GET(node2->btree[ INT_GET(node2->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT) <
- INT_GET(node1->btree[ INT_GET(node1->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)))) {
+ ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) &&
+ (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC));
+ if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
+ ((be32_to_cpu(node2->btree[0].hashval) <
+ be32_to_cpu(node1->btree[0].hashval)) ||
+ (be32_to_cpu(node2->btree[be16_to_cpu(node2->hdr.count)-1].hashval) <
+ be32_to_cpu(node1->btree[be16_to_cpu(node1->hdr.count)-1].hashval)))) {
return(1);
}
return(0);
@@ -1381,12 +1376,12 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count)
xfs_da_intnode_t *node;
node = bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
if (count)
- *count = INT_GET(node->hdr.count, ARCH_CONVERT);
+ *count = be16_to_cpu(node->hdr.count);
if (!node->hdr.count)
return(0);
- return(INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT));
+ return be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
}
/*
@@ -1411,50 +1406,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
save_blk->magic == XFS_ATTR_LEAF_MAGIC);
- ASSERT(save_blk->magic == INT_GET(save_info->magic, ARCH_CONVERT));
- ASSERT(drop_blk->magic == INT_GET(drop_info->magic, ARCH_CONVERT));
+ ASSERT(save_blk->magic == be16_to_cpu(save_info->magic));
+ ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic));
ASSERT(save_blk->magic == drop_blk->magic);
- ASSERT((INT_GET(save_info->forw, ARCH_CONVERT) == drop_blk->blkno) ||
- (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno));
- ASSERT((INT_GET(drop_info->forw, ARCH_CONVERT) == save_blk->blkno) ||
- (INT_GET(drop_info->back, ARCH_CONVERT) == save_blk->blkno));
+ ASSERT((be32_to_cpu(save_info->forw) == drop_blk->blkno) ||
+ (be32_to_cpu(save_info->back) == drop_blk->blkno));
+ ASSERT((be32_to_cpu(drop_info->forw) == save_blk->blkno) ||
+ (be32_to_cpu(drop_info->back) == save_blk->blkno));
/*
* Unlink the leaf block from the doubly linked chain of leaves.
*/
- if (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno) {
- save_info->back = drop_info->back; /* INT_: direct copy */
- if (INT_GET(drop_info->back, ARCH_CONVERT)) {
+ if (be32_to_cpu(save_info->back) == drop_blk->blkno) {
+ save_info->back = drop_info->back;
+ if (drop_info->back) {
error = xfs_da_read_buf(args->trans, args->dp,
- INT_GET(drop_info->back,
- ARCH_CONVERT), -1, &bp,
- args->whichfork);
+ be32_to_cpu(drop_info->back),
+ -1, &bp, args->whichfork);
if (error)
return(error);
ASSERT(bp != NULL);
tmp_info = bp->data;
- ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(save_info->magic, ARCH_CONVERT));
- ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == drop_blk->blkno);
- INT_SET(tmp_info->forw, ARCH_CONVERT, save_blk->blkno);
+ ASSERT(tmp_info->magic == save_info->magic);
+ ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno);
+ tmp_info->forw = cpu_to_be32(save_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0,
sizeof(*tmp_info) - 1);
xfs_da_buf_done(bp);
}
} else {
- save_info->forw = drop_info->forw; /* INT_: direct copy */
- if (INT_GET(drop_info->forw, ARCH_CONVERT)) {
+ save_info->forw = drop_info->forw;
+ if (drop_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp,
- INT_GET(drop_info->forw, ARCH_CONVERT), -1, &bp,
- args->whichfork);
+ be32_to_cpu(drop_info->forw),
+ -1, &bp, args->whichfork);
if (error)
return(error);
ASSERT(bp != NULL);
tmp_info = bp->data;
- ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT)
- == INT_GET(save_info->magic, ARCH_CONVERT));
- ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT)
- == drop_blk->blkno);
- INT_SET(tmp_info->back, ARCH_CONVERT, save_blk->blkno);
+ ASSERT(tmp_info->magic == save_info->magic);
+ ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno);
+ tmp_info->back = cpu_to_be32(save_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0,
sizeof(*tmp_info) - 1);
xfs_da_buf_done(bp);
@@ -1497,14 +1489,14 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
for (blk = &path->blk[level]; level >= 0; blk--, level--) {
ASSERT(blk->bp != NULL);
node = blk->bp->data;
- ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
- if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) {
+ ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
+ if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
blk->index++;
- blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT);
+ blkno = be32_to_cpu(node->btree[blk->index].before);
break;
} else if (!forward && (blk->index > 0)) {
blk->index--;
- blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT);
+ blkno = be32_to_cpu(node->btree[blk->index].before);
break;
}
}
@@ -1536,18 +1528,18 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
return(error);
ASSERT(blk->bp != NULL);
info = blk->bp->data;
- ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC ||
- INT_GET(info->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
- INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC);
- blk->magic = INT_GET(info->magic, ARCH_CONVERT);
- if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) {
+ ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC ||
+ be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
+ be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
+ blk->magic = be16_to_cpu(info->magic);
+ if (blk->magic == XFS_DA_NODE_MAGIC) {
node = (xfs_da_intnode_t *)info;
- blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
+ blk->hashval = be32_to_cpu(node->btree[be16_to_cpu(node->hdr.count)-1].hashval);
if (forward)
blk->index = 0;
else
- blk->index = INT_GET(node->hdr.count, ARCH_CONVERT)-1;
- blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT);
+ blk->index = be16_to_cpu(node->hdr.count)-1;
+ blkno = be32_to_cpu(node->btree[blk->index].before);
} else {
ASSERT(level == path->active-1);
blk->index = 0;
@@ -1788,40 +1780,40 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/*
* Get values from the moved block.
*/
- if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) {
+ if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) {
ASSERT(XFS_DIR_IS_V1(mp));
dead_leaf = (xfs_dir_leafblock_t *)dead_info;
dead_level = 0;
dead_hash =
INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
- } else if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) {
+ } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) {
ASSERT(XFS_DIR_IS_V2(mp));
dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
dead_level = 0;
- dead_hash = INT_GET(dead_leaf2->ents[INT_GET(dead_leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
+ dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval);
} else {
- ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
+ ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC);
dead_node = (xfs_da_intnode_t *)dead_info;
- dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT);
- dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
+ dead_level = be16_to_cpu(dead_node->hdr.level);
+ dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval);
}
sib_buf = par_buf = NULL;
/*
* If the moved block has a left sibling, fix up the pointers.
*/
- if ((sib_blkno = INT_GET(dead_info->back, ARCH_CONVERT))) {
+ if ((sib_blkno = be32_to_cpu(dead_info->back))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
goto done;
sib_info = sib_buf->data;
if (unlikely(
- INT_GET(sib_info->forw, ARCH_CONVERT) != last_blkno ||
- INT_GET(sib_info->magic, ARCH_CONVERT) != INT_GET(dead_info->magic, ARCH_CONVERT))) {
+ be32_to_cpu(sib_info->forw) != last_blkno ||
+ sib_info->magic != dead_info->magic)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED);
goto done;
}
- INT_SET(sib_info->forw, ARCH_CONVERT, dead_blkno);
+ sib_info->forw = cpu_to_be32(dead_blkno);
xfs_da_log_buf(tp, sib_buf,
XFS_DA_LOGRANGE(sib_info, &sib_info->forw,
sizeof(sib_info->forw)));
@@ -1831,20 +1823,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/*
* If the moved block has a right sibling, fix up the pointers.
*/
- if ((sib_blkno = INT_GET(dead_info->forw, ARCH_CONVERT))) {
+ if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
goto done;
sib_info = sib_buf->data;
if (unlikely(
- INT_GET(sib_info->back, ARCH_CONVERT) != last_blkno
- || INT_GET(sib_info->magic, ARCH_CONVERT)
- != INT_GET(dead_info->magic, ARCH_CONVERT))) {
+ be32_to_cpu(sib_info->back) != last_blkno ||
+ sib_info->magic != dead_info->magic)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED);
goto done;
}
- INT_SET(sib_info->back, ARCH_CONVERT, dead_blkno);
+ sib_info->back = cpu_to_be32(dead_blkno);
xfs_da_log_buf(tp, sib_buf,
XFS_DA_LOGRANGE(sib_info, &sib_info->back,
sizeof(sib_info->back)));
@@ -1861,26 +1852,26 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
goto done;
par_node = par_buf->data;
if (unlikely(
- INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC ||
- (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) {
+ be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC ||
+ (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED);
goto done;
}
- level = INT_GET(par_node->hdr.level, ARCH_CONVERT);
+ level = be16_to_cpu(par_node->hdr.level);
for (entno = 0;
- entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) &&
- INT_GET(par_node->btree[entno].hashval, ARCH_CONVERT) < dead_hash;
+ entno < be16_to_cpu(par_node->hdr.count) &&
+ be32_to_cpu(par_node->btree[entno].hashval) < dead_hash;
entno++)
continue;
- if (unlikely(entno == INT_GET(par_node->hdr.count, ARCH_CONVERT))) {
+ if (unlikely(entno == be16_to_cpu(par_node->hdr.count))) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(5)",
XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED);
goto done;
}
- par_blkno = INT_GET(par_node->btree[entno].before, ARCH_CONVERT);
+ par_blkno = be32_to_cpu(par_node->btree[entno].before);
if (level == dead_level + 1)
break;
xfs_da_brelse(tp, par_buf);
@@ -1892,13 +1883,13 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
*/
for (;;) {
for (;
- entno < INT_GET(par_node->hdr.count, ARCH_CONVERT) &&
- INT_GET(par_node->btree[entno].before, ARCH_CONVERT) != last_blkno;
+ entno < be16_to_cpu(par_node->hdr.count) &&
+ be32_to_cpu(par_node->btree[entno].before) != last_blkno;
entno++)
continue;
- if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT))
+ if (entno < be16_to_cpu(par_node->hdr.count))
break;
- par_blkno = INT_GET(par_node->hdr.info.forw, ARCH_CONVERT);
+ par_blkno = be32_to_cpu(par_node->hdr.info.forw);
xfs_da_brelse(tp, par_buf);
par_buf = NULL;
if (unlikely(par_blkno == 0)) {
@@ -1911,8 +1902,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
goto done;
par_node = par_buf->data;
if (unlikely(
- INT_GET(par_node->hdr.level, ARCH_CONVERT) != level ||
- INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)) {
+ be16_to_cpu(par_node->hdr.level) != level ||
+ be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED);
@@ -1923,7 +1914,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/*
* Update the parent entry pointing to the moved block.
*/
- INT_SET(par_node->btree[entno].before, ARCH_CONVERT, dead_blkno);
+ par_node->btree[entno].before = cpu_to_be32(dead_blkno);
xfs_da_log_buf(tp, par_buf,
XFS_DA_LOGRANGE(par_node, &par_node->btree[entno].before,
sizeof(par_node->btree[entno].before)));
@@ -2203,8 +2194,8 @@ xfs_da_do_buf(
info = rbp->data;
data = rbp->data;
free = rbp->data;
- magic = INT_GET(info->magic, ARCH_CONVERT);
- magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT);
+ magic = be16_to_cpu(info->magic);
+ magic1 = be32_to_cpu(data->hdr.magic);
if (unlikely(
XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
(magic != XFS_DIR_LEAF_MAGIC) &&
@@ -2213,7 +2204,7 @@ xfs_da_do_buf(
(magic != XFS_DIR2_LEAFN_MAGIC) &&
(magic1 != XFS_DIR2_BLOCK_MAGIC) &&
(magic1 != XFS_DIR2_DATA_MAGIC) &&
- (INT_GET(free->hdr.magic, ARCH_CONVERT) != XFS_DIR2_FREE_MAGIC),
+ (be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC),
mp, XFS_ERRTAG_DA_READ_BUF,
XFS_RANDOM_DA_READ_BUF))) {
xfs_buftrace("DA READ ERROR", rbp->bps[0]);
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index 41352113721..243a730d5ec 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -45,10 +45,10 @@ struct zone;
(XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC)
typedef struct xfs_da_blkinfo {
- xfs_dablk_t forw; /* previous block in list */
- xfs_dablk_t back; /* following block in list */
- __uint16_t magic; /* validity check on block */
- __uint16_t pad; /* unused */
+ __be32 forw; /* previous block in list */
+ __be32 back; /* following block in list */
+ __be16 magic; /* validity check on block */
+ __be16 pad; /* unused */
} xfs_da_blkinfo_t;
/*
@@ -65,12 +65,12 @@ typedef struct xfs_da_blkinfo {
typedef struct xfs_da_intnode {
struct xfs_da_node_hdr { /* constant-structure header block */
xfs_da_blkinfo_t info; /* block type, links, etc. */
- __uint16_t count; /* count of active entries */
- __uint16_t level; /* level above leaves (leaf == 0) */
+ __be16 count; /* count of active entries */
+ __be16 level; /* level above leaves (leaf == 0) */
} hdr;
struct xfs_da_node_entry {
- xfs_dahash_t hashval; /* hash value for this descendant */
- xfs_dablk_t before; /* Btree block before this key */
+ __be32 hashval; /* hash value for this descendant */
+ __be32 before; /* Btree block before this key */
} btree[1]; /* variable sized array of keys */
} xfs_da_intnode_t;
typedef struct xfs_da_node_hdr xfs_da_node_hdr_t;
diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c
index c6191d00ad2..4968a6358e6 100644
--- a/fs/xfs/xfs_dfrag.c
+++ b/fs/xfs/xfs_dfrag.c
@@ -83,7 +83,7 @@ xfs_swapext(
/* Pull information for the target fd */
if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) ||
- ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) {
+ ((vp = vn_from_inode(fp->f_dentry->d_inode)) == NULL)) {
error = XFS_ERROR(EINVAL);
goto error0;
}
@@ -95,7 +95,7 @@ xfs_swapext(
}
if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) ||
- ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) {
+ ((tvp = vn_from_inode(tfp->f_dentry->d_inode)) == NULL)) {
error = XFS_ERROR(EINVAL);
goto error0;
}
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c
index bb87d2a700a..9cc702a839a 100644
--- a/fs/xfs/xfs_dir.c
+++ b/fs/xfs/xfs_dir.c
@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen)
return(retval);
ASSERT(bp != NULL);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
retval = xfs_dir_leaf_lookup_int(bp, args, &index);
if (retval == EEXIST) {
(void)xfs_dir_leaf_remove(args->trans, bp, index);
@@ -912,7 +912,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
return(error);
if (bp)
leaf = bp->data;
- if (bp && INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) {
+ if (bp && be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) {
xfs_dir_trace_g_dub("node: block not a leaf",
dp, uio, bno);
xfs_da_brelse(trans, bp);
@@ -949,17 +949,17 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
if (bp == NULL)
return(XFS_ERROR(EFSCORRUPTED));
node = bp->data;
- if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)
+ if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC)
break;
btree = &node->btree[0];
xfs_dir_trace_g_dun("node: node detail", dp, uio, node);
- for (i = 0; i < INT_GET(node->hdr.count, ARCH_CONVERT); btree++, i++) {
- if (INT_GET(btree->hashval, ARCH_CONVERT) >= cookhash) {
- bno = INT_GET(btree->before, ARCH_CONVERT);
+ for (i = 0; i < be16_to_cpu(node->hdr.count); btree++, i++) {
+ if (be32_to_cpu(btree->hashval) >= cookhash) {
+ bno = be32_to_cpu(btree->before);
break;
}
}
- if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) {
+ if (i == be16_to_cpu(node->hdr.count)) {
xfs_da_brelse(trans, bp);
xfs_dir_trace_g_du("node: hash beyond EOF",
dp, uio);
@@ -982,7 +982,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
*/
for (;;) {
leaf = bp->data;
- if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC)) {
+ if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC)) {
xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf);
xfs_da_brelse(trans, bp);
XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)",
@@ -990,7 +990,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
return XFS_ERROR(EFSCORRUPTED);
}
xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf);
- if ((nextbno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT))) {
+ if ((nextbno = be32_to_cpu(leaf->hdr.info.forw))) {
nextda = xfs_da_reada_buf(trans, dp, nextbno,
XFS_DATA_FORK);
} else
@@ -1118,21 +1118,20 @@ void
xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
xfs_da_intnode_t *node)
{
- int last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1;
+ int last = be16_to_cpu(node->hdr.count) - 1;
xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where,
(void *)dp, (void *)dp->i_mount,
(void *)((unsigned long)(uio->uio_offset >> 32)),
(void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid,
+ (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw),
(void *)(unsigned long)
- INT_GET(node->hdr.info.forw, ARCH_CONVERT),
+ be16_to_cpu(node->hdr.count),
(void *)(unsigned long)
- INT_GET(node->hdr.count, ARCH_CONVERT),
+ be32_to_cpu(node->btree[0].hashval),
(void *)(unsigned long)
- INT_GET(node->btree[0].hashval, ARCH_CONVERT),
- (void *)(unsigned long)
- INT_GET(node->btree[last].hashval, ARCH_CONVERT),
+ be32_to_cpu(node->btree[last].hashval),
NULL, NULL, NULL);
}
@@ -1150,8 +1149,7 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
(void *)((unsigned long)(uio->uio_offset >> 32)),
(void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid,
- (void *)(unsigned long)
- INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
+ (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw),
(void *)(unsigned long)
INT_GET(leaf->hdr.count, ARCH_CONVERT),
(void *)(unsigned long)
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h
index 3158f5dc431..7dd364b1e03 100644
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/xfs_dir2.h
@@ -55,16 +55,16 @@ typedef __uint32_t xfs_dir2_db_t;
/*
* Byte offset in a directory.
*/
-typedef xfs_off_t xfs_dir2_off_t;
+typedef xfs_off_t xfs_dir2_off_t;
/*
* For getdents, argument struct for put routines.
*/
typedef int (*xfs_dir2_put_t)(struct xfs_dir2_put_args *pa);
typedef struct xfs_dir2_put_args {
- xfs_off_t cook; /* cookie of (next) entry */
+ xfs_off_t cook; /* cookie of (next) entry */
xfs_intino_t ino; /* inode number */
- struct xfs_dirent *dbp; /* buffer pointer */
+ xfs_dirent_t *dbp; /* buffer pointer */
char *name; /* directory entry name */
int namelen; /* length of name */
int done; /* output: set if value was stored */
@@ -75,18 +75,13 @@ typedef struct xfs_dir2_put_args {
/*
* Other interfaces used by the rest of the dir v2 code.
*/
-extern int
- xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
- xfs_dir2_db_t *dbp);
-
-extern int
- xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp, int *vp);
-
-extern int
- xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp, int *vp);
-
-extern int
- xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
- struct xfs_dabuf *bp);
+extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
+ xfs_dir2_db_t *dbp);
+extern int xfs_dir2_isblock(struct xfs_trans *tp, struct xfs_inode *dp,
+ int *vp);
+extern int xfs_dir2_isleaf(struct xfs_trans *tp, struct xfs_inode *dp,
+ int *vp);
+extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
+ struct xfs_dabuf *bp);
#endif /* __XFS_DIR2_H__ */
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 31bc99faa70..bd5cee6aa51 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -81,7 +81,7 @@ xfs_dir2_block_addname(
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log header */
int needscan; /* need to rescan freespace */
- xfs_dir2_data_off_t *tagp; /* pointer to tag value */
+ __be16 *tagp; /* pointer to tag value */
xfs_trans_t *tp; /* transaction structure */
xfs_dir2_trace_args("block_addname", args);
@@ -100,8 +100,7 @@ xfs_dir2_block_addname(
/*
* Check the magic number, corrupted if wrong.
*/
- if (unlikely(INT_GET(block->hdr.magic, ARCH_CONVERT)
- != XFS_DIR2_BLOCK_MAGIC)) {
+ if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
XFS_ERRLEVEL_LOW, mp, block);
xfs_da_brelse(tp, bp);
@@ -121,38 +120,38 @@ xfs_dir2_block_addname(
/*
* Tag just before the first leaf entry.
*/
- tagp = (xfs_dir2_data_off_t *)blp - 1;
+ tagp = (__be16 *)blp - 1;
/*
* Data object just before the first leaf entry.
*/
- enddup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+ enddup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
/*
* If it's not free then can't do this add without cleaning up:
* the space before the first leaf entry needs to be free so it
* can be expanded to hold the pointer to the new entry.
*/
- if (INT_GET(enddup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ if (be16_to_cpu(enddup->freetag) != XFS_DIR2_DATA_FREE_TAG)
dup = enddup = NULL;
/*
* Check out the biggest freespace and see if it's the same one.
*/
else {
dup = (xfs_dir2_data_unused_t *)
- ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT));
+ ((char *)block + be16_to_cpu(bf[0].offset));
if (dup == enddup) {
/*
* It is the biggest freespace, is it too small
* to hold the new leaf too?
*/
- if (INT_GET(dup->length, ARCH_CONVERT) < len + (uint)sizeof(*blp)) {
+ if (be16_to_cpu(dup->length) < len + (uint)sizeof(*blp)) {
/*
* Yes, we use the second-largest
* entry instead if it works.
*/
- if (INT_GET(bf[1].length, ARCH_CONVERT) >= len)
+ if (be16_to_cpu(bf[1].length) >= len)
dup = (xfs_dir2_data_unused_t *)
((char *)block +
- INT_GET(bf[1].offset, ARCH_CONVERT));
+ be16_to_cpu(bf[1].offset));
else
dup = NULL;
}
@@ -161,7 +160,7 @@ xfs_dir2_block_addname(
* Not the same free entry,
* just check its length.
*/
- if (INT_GET(dup->length, ARCH_CONVERT) < len) {
+ if (be16_to_cpu(dup->length) < len) {
dup = NULL;
}
}
@@ -172,9 +171,9 @@ xfs_dir2_block_addname(
* If there are stale entries we'll use one for the leaf.
* Is the biggest entry enough to avoid compaction?
*/
- else if (INT_GET(bf[0].length, ARCH_CONVERT) >= len) {
+ else if (be16_to_cpu(bf[0].length) >= len) {
dup = (xfs_dir2_data_unused_t *)
- ((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT));
+ ((char *)block + be16_to_cpu(bf[0].offset));
compact = 0;
}
/*
@@ -184,20 +183,20 @@ xfs_dir2_block_addname(
/*
* Tag just before the first leaf entry.
*/
- tagp = (xfs_dir2_data_off_t *)blp - 1;
+ tagp = (__be16 *)blp - 1;
/*
* Data object just before the first leaf entry.
*/
- dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+ dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
/*
* If it's not free then the data will go where the
* leaf data starts now, if it works at all.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- if (INT_GET(dup->length, ARCH_CONVERT) + (INT_GET(btp->stale, ARCH_CONVERT) - 1) *
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->length) + (be32_to_cpu(btp->stale) - 1) *
(uint)sizeof(*blp) < len)
dup = NULL;
- } else if ((INT_GET(btp->stale, ARCH_CONVERT) - 1) * (uint)sizeof(*blp) < len)
+ } else if ((be32_to_cpu(btp->stale) - 1) * (uint)sizeof(*blp) < len)
dup = NULL;
else
dup = (xfs_dir2_data_unused_t *)blp;
@@ -243,11 +242,11 @@ xfs_dir2_block_addname(
int fromidx; /* source leaf index */
int toidx; /* target leaf index */
- for (fromidx = toidx = INT_GET(btp->count, ARCH_CONVERT) - 1,
+ for (fromidx = toidx = be32_to_cpu(btp->count) - 1,
highstale = lfloghigh = -1;
fromidx >= 0;
fromidx--) {
- if (INT_GET(blp[fromidx].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) {
+ if (be32_to_cpu(blp[fromidx].address) == XFS_DIR2_NULL_DATAPTR) {
if (highstale == -1)
highstale = toidx;
else {
@@ -260,15 +259,15 @@ xfs_dir2_block_addname(
blp[toidx] = blp[fromidx];
toidx--;
}
- lfloglow = toidx + 1 - (INT_GET(btp->stale, ARCH_CONVERT) - 1);
- lfloghigh -= INT_GET(btp->stale, ARCH_CONVERT) - 1;
- INT_MOD(btp->count, ARCH_CONVERT, -(INT_GET(btp->stale, ARCH_CONVERT) - 1));
+ lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1);
+ lfloghigh -= be32_to_cpu(btp->stale) - 1;
+ be32_add(&btp->count, -(be32_to_cpu(btp->stale) - 1));
xfs_dir2_data_make_free(tp, bp,
(xfs_dir2_data_aoff_t)((char *)blp - (char *)block),
- (xfs_dir2_data_aoff_t)((INT_GET(btp->stale, ARCH_CONVERT) - 1) * sizeof(*blp)),
+ (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)),
&needlog, &needscan);
- blp += INT_GET(btp->stale, ARCH_CONVERT) - 1;
- INT_SET(btp->stale, ARCH_CONVERT, 1);
+ blp += be32_to_cpu(btp->stale) - 1;
+ btp->stale = cpu_to_be32(1);
/*
* If we now need to rebuild the bestfree map, do so.
* This needs to happen before the next call to use_free.
@@ -283,23 +282,23 @@ xfs_dir2_block_addname(
* Set leaf logging boundaries to impossible state.
* For the no-stale case they're set explicitly.
*/
- else if (INT_GET(btp->stale, ARCH_CONVERT)) {
- lfloglow = INT_GET(btp->count, ARCH_CONVERT);
+ else if (btp->stale) {
+ lfloglow = be32_to_cpu(btp->count);
lfloghigh = -1;
}
/*
* Find the slot that's first lower than our hash value, -1 if none.
*/
- for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; low <= high; ) {
+ for (low = 0, high = be32_to_cpu(btp->count) - 1; low <= high; ) {
mid = (low + high) >> 1;
- if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval)
+ if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval)
break;
if (hash < args->hashval)
low = mid + 1;
else
high = mid - 1;
}
- while (mid >= 0 && INT_GET(blp[mid].hashval, ARCH_CONVERT) >= args->hashval) {
+ while (mid >= 0 && be32_to_cpu(blp[mid].hashval) >= args->hashval) {
mid--;
}
/*
@@ -311,14 +310,14 @@ xfs_dir2_block_addname(
*/
xfs_dir2_data_use_free(tp, bp, enddup,
(xfs_dir2_data_aoff_t)
- ((char *)enddup - (char *)block + INT_GET(enddup->length, ARCH_CONVERT) -
+ ((char *)enddup - (char *)block + be16_to_cpu(enddup->length) -
sizeof(*blp)),
(xfs_dir2_data_aoff_t)sizeof(*blp),
&needlog, &needscan);
/*
* Update the tail (entry count).
*/
- INT_MOD(btp->count, ARCH_CONVERT, +1);
+ be32_add(&btp->count, 1);
/*
* If we now need to rebuild the bestfree map, do so.
* This needs to happen before the next call to use_free.
@@ -346,12 +345,12 @@ xfs_dir2_block_addname(
else {
for (lowstale = mid;
lowstale >= 0 &&
- INT_GET(blp[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR;
+ be32_to_cpu(blp[lowstale].address) != XFS_DIR2_NULL_DATAPTR;
lowstale--)
continue;
for (highstale = mid + 1;
- highstale < INT_GET(btp->count, ARCH_CONVERT) &&
- INT_GET(blp[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
+ highstale < be32_to_cpu(btp->count) &&
+ be32_to_cpu(blp[highstale].address) != XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 || mid - lowstale > highstale - mid);
highstale++)
continue;
@@ -359,7 +358,7 @@ xfs_dir2_block_addname(
* Move entries toward the low-numbered stale entry.
*/
if (lowstale >= 0 &&
- (highstale == INT_GET(btp->count, ARCH_CONVERT) ||
+ (highstale == be32_to_cpu(btp->count) ||
mid - lowstale <= highstale - mid)) {
if (mid - lowstale)
memmove(&blp[lowstale], &blp[lowstale + 1],
@@ -371,7 +370,7 @@ xfs_dir2_block_addname(
* Move entries toward the high-numbered stale entry.
*/
else {
- ASSERT(highstale < INT_GET(btp->count, ARCH_CONVERT));
+ ASSERT(highstale < be32_to_cpu(btp->count));
mid++;
if (highstale - mid)
memmove(&blp[mid + 1], &blp[mid],
@@ -379,7 +378,7 @@ xfs_dir2_block_addname(
lfloglow = MIN(mid, lfloglow);
lfloghigh = MAX(highstale, lfloghigh);
}
- INT_MOD(btp->stale, ARCH_CONVERT, -1);
+ be32_add(&btp->stale, -1);
}
/*
* Point to the new data entry.
@@ -388,8 +387,9 @@ xfs_dir2_block_addname(
/*
* Fill in the leaf entry.
*/
- INT_SET(blp[mid].hashval, ARCH_CONVERT, args->hashval);
- INT_SET(blp[mid].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block));
+ blp[mid].hashval = cpu_to_be32(args->hashval);
+ blp[mid].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
+ (char *)dep - (char *)block));
xfs_dir2_block_log_leaf(tp, bp, lfloglow, lfloghigh);
/*
* Mark space for the data entry used.
@@ -404,7 +404,7 @@ xfs_dir2_block_addname(
dep->namelen = args->namelen;
memcpy(dep->name, args->name, args->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+ *tagp = cpu_to_be16((char *)dep - (char *)block);
/*
* Clean up the bestfree array and log the header, tail, and entry.
*/
@@ -485,8 +485,8 @@ xfs_dir2_block_getdents(
/*
* Unused, skip it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- ptr += INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ ptr += be16_to_cpu(dup->length);
continue;
}
@@ -622,7 +622,7 @@ xfs_dir2_block_lookup(
* Get the offset from the leaf entry, to point to the data.
*/
dep = (xfs_dir2_data_entry_t *)
- ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT)));
+ ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address)));
/*
* Fill in inode number, release the block.
*/
@@ -674,10 +674,10 @@ xfs_dir2_block_lookup_int(
* Loop doing a binary search for our hash value.
* Find our entry, ENOENT if it's not there.
*/
- for (low = 0, high = INT_GET(btp->count, ARCH_CONVERT) - 1; ; ) {
+ for (low = 0, high = be32_to_cpu(btp->count) - 1; ; ) {
ASSERT(low <= high);
mid = (low + high) >> 1;
- if ((hash = INT_GET(blp[mid].hashval, ARCH_CONVERT)) == args->hashval)
+ if ((hash = be32_to_cpu(blp[mid].hashval)) == args->hashval)
break;
if (hash < args->hashval)
low = mid + 1;
@@ -692,7 +692,7 @@ xfs_dir2_block_lookup_int(
/*
* Back up to the first one with the right hash value.
*/
- while (mid > 0 && INT_GET(blp[mid - 1].hashval, ARCH_CONVERT) == args->hashval) {
+ while (mid > 0 && be32_to_cpu(blp[mid - 1].hashval) == args->hashval) {
mid--;
}
/*
@@ -700,7 +700,7 @@ xfs_dir2_block_lookup_int(
* right hash value looking for our name.
*/
do {
- if ((addr = INT_GET(blp[mid].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR)
+ if ((addr = be32_to_cpu(blp[mid].address)) == XFS_DIR2_NULL_DATAPTR)
continue;
/*
* Get pointer to the entry from the leaf.
@@ -717,7 +717,7 @@ xfs_dir2_block_lookup_int(
*entno = mid;
return 0;
}
- } while (++mid < INT_GET(btp->count, ARCH_CONVERT) && INT_GET(blp[mid].hashval, ARCH_CONVERT) == hash);
+ } while (++mid < be32_to_cpu(btp->count) && be32_to_cpu(blp[mid].hashval) == hash);
/*
* No match, release the buffer and return ENOENT.
*/
@@ -767,7 +767,7 @@ xfs_dir2_block_removename(
* Point to the data entry using the leaf entry.
*/
dep = (xfs_dir2_data_entry_t *)
- ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT)));
+ ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address)));
/*
* Mark the data entry's space free.
*/
@@ -778,12 +778,12 @@ xfs_dir2_block_removename(
/*
* Fix up the block tail.
*/
- INT_MOD(btp->stale, ARCH_CONVERT, +1);
+ be32_add(&btp->stale, 1);
xfs_dir2_block_log_tail(tp, bp);
/*
* Remove the leaf entry by marking it stale.
*/
- INT_SET(blp[ent].address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
+ blp[ent].address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
xfs_dir2_block_log_leaf(tp, bp, ent, ent);
/*
* Fix up bestfree, log the header if necessary.
@@ -843,7 +843,7 @@ xfs_dir2_block_replace(
* Point to the data entry we need to change.
*/
dep = (xfs_dir2_data_entry_t *)
- ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(blp[ent].address, ARCH_CONVERT)));
+ ((char *)block + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(blp[ent].address)));
ASSERT(INT_GET(dep->inumber, ARCH_CONVERT) != args->inumber);
/*
* Change the inode number to the new value.
@@ -868,8 +868,8 @@ xfs_dir2_block_sort(
la = a;
lb = b;
- return INT_GET(la->hashval, ARCH_CONVERT) < INT_GET(lb->hashval, ARCH_CONVERT) ? -1 :
- (INT_GET(la->hashval, ARCH_CONVERT) > INT_GET(lb->hashval, ARCH_CONVERT) ? 1 : 0);
+ return be32_to_cpu(la->hashval) < be32_to_cpu(lb->hashval) ? -1 :
+ (be32_to_cpu(la->hashval) > be32_to_cpu(lb->hashval) ? 1 : 0);
}
/*
@@ -881,7 +881,7 @@ xfs_dir2_leaf_to_block(
xfs_dabuf_t *lbp, /* leaf buffer */
xfs_dabuf_t *dbp) /* data buffer */
{
- xfs_dir2_data_off_t *bestsp; /* leaf bests table */
+ __be16 *bestsp; /* leaf bests table */
xfs_dir2_block_t *block; /* block structure */
xfs_dir2_block_tail_t *btp; /* block tail */
xfs_inode_t *dp; /* incore directory inode */
@@ -896,7 +896,7 @@ xfs_dir2_leaf_to_block(
int needscan; /* need to scan for bestfree */
xfs_dir2_sf_hdr_t sfh; /* shortform header */
int size; /* bytes used */
- xfs_dir2_data_off_t *tagp; /* end of entry (tag) */
+ __be16 *tagp; /* end of entry (tag) */
int to; /* block/leaf to index */
xfs_trans_t *tp; /* transaction pointer */
@@ -905,7 +905,7 @@ xfs_dir2_leaf_to_block(
tp = args->trans;
mp = dp->i_mount;
leaf = lbp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
/*
* If there are data blocks other than the first one, take this
@@ -915,11 +915,11 @@ xfs_dir2_leaf_to_block(
*/
while (dp->i_d.di_size > mp->m_dirblksize) {
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
- if (INT_GET(bestsp[INT_GET(ltp->bestcount, ARCH_CONVERT) - 1], ARCH_CONVERT) ==
+ if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
mp->m_dirblksize - (uint)sizeof(block->hdr)) {
if ((error =
xfs_dir2_leaf_trim_data(args, lbp,
- (xfs_dir2_db_t)(INT_GET(ltp->bestcount, ARCH_CONVERT) - 1))))
+ (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
goto out;
} else {
error = 0;
@@ -935,28 +935,29 @@ xfs_dir2_leaf_to_block(
goto out;
}
block = dbp->data;
- ASSERT(INT_GET(block->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC);
+ ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC);
/*
* Size of the "leaf" area in the block.
*/
size = (uint)sizeof(block->tail) +
- (uint)sizeof(*lep) * (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT));
+ (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
/*
* Look at the last data entry.
*/
- tagp = (xfs_dir2_data_off_t *)((char *)block + mp->m_dirblksize) - 1;
- dup = (xfs_dir2_data_unused_t *)((char *)block + INT_GET(*tagp, ARCH_CONVERT));
+ tagp = (__be16 *)((char *)block + mp->m_dirblksize) - 1;
+ dup = (xfs_dir2_data_unused_t *)((char *)block + be16_to_cpu(*tagp));
/*
* If it's not free or is too short we can't do it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG || INT_GET(dup->length, ARCH_CONVERT) < size) {
+ if (be16_to_cpu(dup->freetag) != XFS_DIR2_DATA_FREE_TAG ||
+ be16_to_cpu(dup->length) < size) {
error = 0;
goto out;
}
/*
* Start converting it to block form.
*/
- INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC);
+ block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
needlog = 1;
needscan = 0;
/*
@@ -968,20 +969,20 @@ xfs_dir2_leaf_to_block(
* Initialize the block tail.
*/
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
- INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT));
+ btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
btp->stale = 0;
xfs_dir2_block_log_tail(tp, dbp);
/*
* Initialize the block leaf area. We compact out stale entries.
*/
lep = XFS_DIR2_BLOCK_LEAF_P(btp);
- for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
- if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
+ if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR)
continue;
lep[to++] = leaf->ents[from];
}
- ASSERT(to == INT_GET(btp->count, ARCH_CONVERT));
- xfs_dir2_block_log_leaf(tp, dbp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1);
+ ASSERT(to == be32_to_cpu(btp->count));
+ xfs_dir2_block_log_leaf(tp, dbp, 0, be32_to_cpu(btp->count) - 1);
/*
* Scan the bestfree if we need it and log the data block header.
*/
@@ -1043,7 +1044,7 @@ xfs_dir2_sf_to_block(
int offset; /* target block offset */
xfs_dir2_sf_entry_t *sfep; /* sf entry pointer */
xfs_dir2_sf_t *sfp; /* shortform structure */
- xfs_dir2_data_off_t *tagp; /* end of data entry */
+ __be16 *tagp; /* end of data entry */
xfs_trans_t *tp; /* transaction pointer */
xfs_dir2_trace_args("sf_to_block", args);
@@ -1095,12 +1096,12 @@ xfs_dir2_sf_to_block(
return error;
}
block = bp->data;
- INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC);
+ block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
/*
* Compute size of block "tail" area.
*/
i = (uint)sizeof(*btp) +
- (INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t);
+ (sfp->hdr.count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t);
/*
* The whole thing is initialized to free by the init routine.
* Say we're using the leaf and tail area.
@@ -1114,7 +1115,7 @@ xfs_dir2_sf_to_block(
* Fill in the tail.
*/
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
- INT_SET(btp->count, ARCH_CONVERT, INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */
+ btp->count = cpu_to_be32(sfp->hdr.count + 2); /* ., .. */
btp->stale = 0;
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
endoffset = (uint)((char *)blp - (char *)block);
@@ -1123,7 +1124,7 @@ xfs_dir2_sf_to_block(
*/
xfs_dir2_data_use_free(tp, bp, dup,
(xfs_dir2_data_aoff_t)((char *)dup - (char *)block),
- INT_GET(dup->length, ARCH_CONVERT), &needlog, &needscan);
+ be16_to_cpu(dup->length), &needlog, &needscan);
/*
* Create entry for .
*/
@@ -1133,10 +1134,11 @@ xfs_dir2_sf_to_block(
dep->namelen = 1;
dep->name[0] = '.';
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+ *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep);
- INT_SET(blp[0].hashval, ARCH_CONVERT, xfs_dir_hash_dot);
- INT_SET(blp[0].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block));
+ blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot);
+ blp[0].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
+ (char *)dep - (char *)block));
/*
* Create entry for ..
*/
@@ -1146,15 +1148,16 @@ xfs_dir2_sf_to_block(
dep->namelen = 2;
dep->name[0] = dep->name[1] = '.';
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+ *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep);
- INT_SET(blp[1].hashval, ARCH_CONVERT, xfs_dir_hash_dotdot);
- INT_SET(blp[1].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp, (char *)dep - (char *)block));
+ blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot);
+ blp[1].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
+ (char *)dep - (char *)block));
offset = XFS_DIR2_DATA_FIRST_OFFSET;
/*
* Loop over existing entries, stuff them in.
*/
- if ((i = 0) == INT_GET(sfp->hdr.count, ARCH_CONVERT))
+ if ((i = 0) == sfp->hdr.count)
sfep = NULL;
else
sfep = XFS_DIR2_SF_FIRSTENTRY(sfp);
@@ -1176,15 +1179,14 @@ xfs_dir2_sf_to_block(
if (offset < newoffset) {
dup = (xfs_dir2_data_unused_t *)
((char *)block + offset);
- INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(dup->length, ARCH_CONVERT, newoffset - offset);
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)
+ dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ dup->length = cpu_to_be16(newoffset - offset);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16(
((char *)dup - (char *)block));
xfs_dir2_data_log_unused(tp, bp, dup);
(void)xfs_dir2_data_freeinsert((xfs_dir2_data_t *)block,
dup, &dummy);
- offset += INT_GET(dup->length, ARCH_CONVERT);
+ offset += be16_to_cpu(dup->length);
continue;
}
/*
@@ -1196,13 +1198,14 @@ xfs_dir2_sf_to_block(
dep->namelen = sfep->namelen;
memcpy(dep->name, sfep->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)block));
+ *tagp = cpu_to_be16((char *)dep - (char *)block);
xfs_dir2_data_log_entry(tp, bp, dep);
- INT_SET(blp[2 + i].hashval, ARCH_CONVERT, xfs_da_hashname((char *)sfep->name, sfep->namelen));
- INT_SET(blp[2 + i].address, ARCH_CONVERT, XFS_DIR2_BYTE_TO_DATAPTR(mp,
+ blp[2 + i].hashval = cpu_to_be32(xfs_da_hashname(
+ (char *)sfep->name, sfep->namelen));
+ blp[2 + i].address = cpu_to_be32(XFS_DIR2_BYTE_TO_DATAPTR(mp,
(char *)dep - (char *)block));
offset = (int)((char *)(tagp + 1) - (char *)block);
- if (++i == INT_GET(sfp->hdr.count, ARCH_CONVERT))
+ if (++i == sfp->hdr.count)
sfep = NULL;
else
sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep);
@@ -1212,13 +1215,13 @@ xfs_dir2_sf_to_block(
/*
* Sort the leaf entries by hash value.
*/
- xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort);
+ xfs_sort(blp, be32_to_cpu(btp->count), sizeof(*blp), xfs_dir2_block_sort);
/*
* Log the leaf entry area and tail.
* Already logged the header in data_init, ignore needlog.
*/
ASSERT(needscan == 0);
- xfs_dir2_block_log_leaf(tp, bp, 0, INT_GET(btp->count, ARCH_CONVERT) - 1);
+ xfs_dir2_block_log_leaf(tp, bp, 0, be32_to_cpu(btp->count) - 1);
xfs_dir2_block_log_tail(tp, bp);
xfs_dir2_data_check(dp, bp);
xfs_da_buf_done(bp);
diff --git a/fs/xfs/xfs_dir2_block.h b/fs/xfs/xfs_dir2_block.h
index a2e5cb98a83..6722effd0b2 100644
--- a/fs/xfs/xfs_dir2_block.h
+++ b/fs/xfs/xfs_dir2_block.h
@@ -43,8 +43,8 @@ struct xfs_trans;
#define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: for one block dirs */
typedef struct xfs_dir2_block_tail {
- __uint32_t count; /* count of leaf entries */
- __uint32_t stale; /* count of stale lf entries */
+ __be32 count; /* count of leaf entries */
+ __be32 stale; /* count of stale lf entries */
} xfs_dir2_block_tail_t;
/*
@@ -75,8 +75,7 @@ xfs_dir2_block_tail_p(struct xfs_mount *mp, xfs_dir2_block_t *block)
static inline struct xfs_dir2_leaf_entry *
xfs_dir2_block_leaf_p(xfs_dir2_block_tail_t *btp)
{
- return (((struct xfs_dir2_leaf_entry *)
- (btp)) - INT_GET((btp)->count, ARCH_CONVERT));
+ return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
}
/*
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 5b7c47e2f14..bb3d03ff002 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -70,11 +70,11 @@ xfs_dir2_data_check(
mp = dp->i_mount;
d = bp->data;
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
bf = d->hdr.bestfree;
p = (char *)d->u;
- if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
+ if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
lep = XFS_DIR2_BLOCK_LEAF_P(btp);
endp = (char *)lep;
@@ -96,8 +96,8 @@ xfs_dir2_data_check(
ASSERT(!bf[2].offset);
freeseen |= 1 << 2;
}
- ASSERT(INT_GET(bf[0].length, ARCH_CONVERT) >= INT_GET(bf[1].length, ARCH_CONVERT));
- ASSERT(INT_GET(bf[1].length, ARCH_CONVERT) >= INT_GET(bf[2].length, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(bf[0].length) >= be16_to_cpu(bf[1].length));
+ ASSERT(be16_to_cpu(bf[1].length) >= be16_to_cpu(bf[2].length));
/*
* Loop over the data/unused entries.
*/
@@ -108,18 +108,20 @@ xfs_dir2_data_check(
* If we find it, account for that, else make sure it
* doesn't need to be there.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT(lastfree == 0);
- ASSERT(INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT) ==
+ ASSERT(be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup)) ==
(char *)dup - (char *)d);
dfp = xfs_dir2_data_freefind(d, dup);
if (dfp) {
i = (int)(dfp - bf);
ASSERT((freeseen & (1 << i)) == 0);
freeseen |= 1 << i;
- } else
- ASSERT(INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(bf[2].length, ARCH_CONVERT));
- p += INT_GET(dup->length, ARCH_CONVERT);
+ } else {
+ ASSERT(be16_to_cpu(dup->length) <=
+ be16_to_cpu(bf[2].length));
+ }
+ p += be16_to_cpu(dup->length);
lastfree = 1;
continue;
}
@@ -132,21 +134,21 @@ xfs_dir2_data_check(
dep = (xfs_dir2_data_entry_t *)p;
ASSERT(dep->namelen != 0);
ASSERT(xfs_dir_ino_validate(mp, INT_GET(dep->inumber, ARCH_CONVERT)) == 0);
- ASSERT(INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT) ==
+ ASSERT(be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep)) ==
(char *)dep - (char *)d);
count++;
lastfree = 0;
- if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
+ if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
addr = XFS_DIR2_DB_OFF_TO_DATAPTR(mp, mp->m_dirdatablk,
(xfs_dir2_data_aoff_t)
((char *)dep - (char *)d));
hash = xfs_da_hashname((char *)dep->name, dep->namelen);
- for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
- if (INT_GET(lep[i].address, ARCH_CONVERT) == addr &&
- INT_GET(lep[i].hashval, ARCH_CONVERT) == hash)
+ for (i = 0; i < be32_to_cpu(btp->count); i++) {
+ if (be32_to_cpu(lep[i].address) == addr &&
+ be32_to_cpu(lep[i].hashval) == hash)
break;
}
- ASSERT(i < INT_GET(btp->count, ARCH_CONVERT));
+ ASSERT(i < be32_to_cpu(btp->count));
}
p += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
}
@@ -154,15 +156,15 @@ xfs_dir2_data_check(
* Need to have seen all the entries and all the bestfree slots.
*/
ASSERT(freeseen == 7);
- if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
- for (i = stale = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
- if (INT_GET(lep[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
+ for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
+ if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR)
stale++;
if (i > 0)
- ASSERT(INT_GET(lep[i].hashval, ARCH_CONVERT) >= INT_GET(lep[i - 1].hashval, ARCH_CONVERT));
+ ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval));
}
- ASSERT(count == INT_GET(btp->count, ARCH_CONVERT) - INT_GET(btp->stale, ARCH_CONVERT));
- ASSERT(stale == INT_GET(btp->stale, ARCH_CONVERT));
+ ASSERT(count == be32_to_cpu(btp->count) - be32_to_cpu(btp->stale));
+ ASSERT(stale == be32_to_cpu(btp->stale));
}
}
#endif
@@ -190,8 +192,8 @@ xfs_dir2_data_freefind(
* Check order, non-overlapping entries, and if we find the
* one we're looking for it has to be exact.
*/
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
for (dfp = &d->hdr.bestfree[0], seenzero = matched = 0;
dfp < &d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT];
dfp++) {
@@ -201,23 +203,24 @@ xfs_dir2_data_freefind(
continue;
}
ASSERT(seenzero == 0);
- if (INT_GET(dfp->offset, ARCH_CONVERT) == off) {
+ if (be16_to_cpu(dfp->offset) == off) {
matched = 1;
- ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(dup->length, ARCH_CONVERT));
- } else if (off < INT_GET(dfp->offset, ARCH_CONVERT))
- ASSERT(off + INT_GET(dup->length, ARCH_CONVERT) <= INT_GET(dfp->offset, ARCH_CONVERT));
+ ASSERT(dfp->length == dup->length);
+ } else if (off < be16_to_cpu(dfp->offset))
+ ASSERT(off + be16_to_cpu(dup->length) <= be16_to_cpu(dfp->offset));
else
- ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) + INT_GET(dfp->length, ARCH_CONVERT) <= off);
- ASSERT(matched || INT_GET(dfp->length, ARCH_CONVERT) >= INT_GET(dup->length, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off);
+ ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length));
if (dfp > &d->hdr.bestfree[0])
- ASSERT(INT_GET(dfp[-1].length, ARCH_CONVERT) >= INT_GET(dfp[0].length, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length));
}
#endif
/*
* If this is smaller than the smallest bestfree entry,
* it can't be there since they're sorted.
*/
- if (INT_GET(dup->length, ARCH_CONVERT) < INT_GET(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length, ARCH_CONVERT))
+ if (be16_to_cpu(dup->length) <
+ be16_to_cpu(d->hdr.bestfree[XFS_DIR2_DATA_FD_COUNT - 1].length))
return NULL;
/*
* Look at the three bestfree entries for our guy.
@@ -227,7 +230,7 @@ xfs_dir2_data_freefind(
dfp++) {
if (!dfp->offset)
return NULL;
- if (INT_GET(dfp->offset, ARCH_CONVERT) == off)
+ if (be16_to_cpu(dfp->offset) == off)
return dfp;
}
/*
@@ -249,29 +252,29 @@ xfs_dir2_data_freeinsert(
xfs_dir2_data_free_t new; /* new bestfree entry */
#ifdef __KERNEL__
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
#endif
dfp = d->hdr.bestfree;
- INT_COPY(new.length, dup->length, ARCH_CONVERT);
- INT_SET(new.offset, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dup - (char *)d));
+ new.length = dup->length;
+ new.offset = cpu_to_be16((char *)dup - (char *)d);
/*
* Insert at position 0, 1, or 2; or not at all.
*/
- if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[0].length, ARCH_CONVERT)) {
+ if (be16_to_cpu(new.length) > be16_to_cpu(dfp[0].length)) {
dfp[2] = dfp[1];
dfp[1] = dfp[0];
dfp[0] = new;
*loghead = 1;
return &dfp[0];
}
- if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[1].length, ARCH_CONVERT)) {
+ if (be16_to_cpu(new.length) > be16_to_cpu(dfp[1].length)) {
dfp[2] = dfp[1];
dfp[1] = new;
*loghead = 1;
return &dfp[1];
}
- if (INT_GET(new.length, ARCH_CONVERT) > INT_GET(dfp[2].length, ARCH_CONVERT)) {
+ if (be16_to_cpu(new.length) > be16_to_cpu(dfp[2].length)) {
dfp[2] = new;
*loghead = 1;
return &dfp[2];
@@ -289,8 +292,8 @@ xfs_dir2_data_freeremove(
int *loghead) /* out: log data header */
{
#ifdef __KERNEL__
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
#endif
/*
* It's the first entry, slide the next 2 up.
@@ -334,8 +337,8 @@ xfs_dir2_data_freescan(
char *p; /* current entry pointer */
#ifdef __KERNEL__
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
#endif
/*
* Start by clearing the table.
@@ -348,7 +351,7 @@ xfs_dir2_data_freescan(
p = (char *)d->u;
if (aendp)
endp = aendp;
- else if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC) {
+ else if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC) {
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
endp = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
} else
@@ -361,11 +364,11 @@ xfs_dir2_data_freescan(
/*
* If it's a free entry, insert it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
ASSERT((char *)dup - (char *)d ==
- INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
+ be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup)));
xfs_dir2_data_freeinsert(d, dup, loghead);
- p += INT_GET(dup->length, ARCH_CONVERT);
+ p += be16_to_cpu(dup->length);
}
/*
* For active entries, check their tags and skip them.
@@ -373,7 +376,7 @@ xfs_dir2_data_freescan(
else {
dep = (xfs_dir2_data_entry_t *)p;
ASSERT((char *)dep - (char *)d ==
- INT_GET(*XFS_DIR2_DATA_ENTRY_TAG_P(dep), ARCH_CONVERT));
+ be16_to_cpu(*XFS_DIR2_DATA_ENTRY_TAG_P(dep)));
p += XFS_DIR2_DATA_ENTSIZE(dep->namelen);
}
}
@@ -415,8 +418,8 @@ xfs_dir2_data_init(
* Initialize the header.
*/
d = bp->data;
- INT_SET(d->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC);
- INT_SET(d->hdr.bestfree[0].offset, ARCH_CONVERT, (xfs_dir2_data_off_t)sizeof(d->hdr));
+ d->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
+ d->hdr.bestfree[0].offset = cpu_to_be16(sizeof(d->hdr));
for (i = 1; i < XFS_DIR2_DATA_FD_COUNT; i++) {
d->hdr.bestfree[i].length = 0;
d->hdr.bestfree[i].offset = 0;
@@ -425,13 +428,12 @@ xfs_dir2_data_init(
* Set up an unused entry for the block's body.
*/
dup = &d->u[0].unused;
- INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
+ dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
t=mp->m_dirblksize - (uint)sizeof(d->hdr);
- INT_SET(d->hdr.bestfree[0].length, ARCH_CONVERT, t);
- INT_SET(dup->length, ARCH_CONVERT, t);
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)dup - (char *)d));
+ d->hdr.bestfree[0].length = cpu_to_be16(t);
+ dup->length = cpu_to_be16(t);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(dup) = cpu_to_be16((char *)dup - (char *)d);
/*
* Log it and return it.
*/
@@ -453,8 +455,8 @@ xfs_dir2_data_log_entry(
xfs_dir2_data_t *d; /* data block pointer */
d = bp->data;
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)d),
(uint)((char *)(XFS_DIR2_DATA_ENTRY_TAG_P(dep) + 1) -
(char *)d - 1));
@@ -471,8 +473,8 @@ xfs_dir2_data_log_header(
xfs_dir2_data_t *d; /* data block pointer */
d = bp->data;
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)&d->hdr - (char *)d),
(uint)(sizeof(d->hdr) - 1));
}
@@ -489,8 +491,8 @@ xfs_dir2_data_log_unused(
xfs_dir2_data_t *d; /* data block pointer */
d = bp->data;
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
/*
* Log the first part of the unused entry.
*/
@@ -533,12 +535,12 @@ xfs_dir2_data_make_free(
/*
* Figure out where the end of the data area is.
*/
- if (INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC)
+ if (be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC)
endptr = (char *)d + mp->m_dirblksize;
else {
xfs_dir2_block_tail_t *btp; /* block tail */
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
btp = XFS_DIR2_BLOCK_TAIL_P(mp, (xfs_dir2_block_t *)d);
endptr = (char *)XFS_DIR2_BLOCK_LEAF_P(btp);
}
@@ -547,11 +549,11 @@ xfs_dir2_data_make_free(
* the previous entry and see if it's free.
*/
if (offset > sizeof(d->hdr)) {
- xfs_dir2_data_off_t *tagp; /* tag just before us */
+ __be16 *tagp; /* tag just before us */
- tagp = (xfs_dir2_data_off_t *)((char *)d + offset) - 1;
- prevdup = (xfs_dir2_data_unused_t *)((char *)d + INT_GET(*tagp, ARCH_CONVERT));
- if (INT_GET(prevdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ tagp = (__be16 *)((char *)d + offset) - 1;
+ prevdup = (xfs_dir2_data_unused_t *)((char *)d + be16_to_cpu(*tagp));
+ if (be16_to_cpu(prevdup->freetag) != XFS_DIR2_DATA_FREE_TAG)
prevdup = NULL;
} else
prevdup = NULL;
@@ -562,7 +564,7 @@ xfs_dir2_data_make_free(
if ((char *)d + offset + len < endptr) {
postdup =
(xfs_dir2_data_unused_t *)((char *)d + offset + len);
- if (INT_GET(postdup->freetag, ARCH_CONVERT) != XFS_DIR2_DATA_FREE_TAG)
+ if (be16_to_cpu(postdup->freetag) != XFS_DIR2_DATA_FREE_TAG)
postdup = NULL;
} else
postdup = NULL;
@@ -586,13 +588,13 @@ xfs_dir2_data_make_free(
* since the third bestfree is there, there might be more
* entries.
*/
- needscan = d->hdr.bestfree[2].length;
+ needscan = (d->hdr.bestfree[2].length != 0);
/*
* Fix up the new big freespace.
*/
- INT_MOD(prevdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT));
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
+ be16_add(&prevdup->length, len + be16_to_cpu(postdup->length));
+ *XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) =
+ cpu_to_be16((char *)prevdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, prevdup);
if (!needscan) {
/*
@@ -614,7 +616,7 @@ xfs_dir2_data_make_free(
*/
dfp = xfs_dir2_data_freeinsert(d, prevdup, needlogp);
ASSERT(dfp == &d->hdr.bestfree[0]);
- ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(prevdup->length, ARCH_CONVERT));
+ ASSERT(dfp->length == prevdup->length);
ASSERT(!dfp[1].length);
ASSERT(!dfp[2].length);
}
@@ -624,9 +626,9 @@ xfs_dir2_data_make_free(
*/
else if (prevdup) {
dfp = xfs_dir2_data_freefind(d, prevdup);
- INT_MOD(prevdup->length, ARCH_CONVERT, len);
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(prevdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)prevdup - (char *)d));
+ be16_add(&prevdup->length, len);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(prevdup) =
+ cpu_to_be16((char *)prevdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, prevdup);
/*
* If the previous entry was in the table, the new entry
@@ -640,8 +642,10 @@ xfs_dir2_data_make_free(
/*
* Otherwise we need a scan if the new entry is big enough.
*/
- else
- needscan = INT_GET(prevdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT);
+ else {
+ needscan = be16_to_cpu(prevdup->length) >
+ be16_to_cpu(d->hdr.bestfree[2].length);
+ }
}
/*
* The following entry is free, merge with it.
@@ -649,10 +653,10 @@ xfs_dir2_data_make_free(
else if (postdup) {
dfp = xfs_dir2_data_freefind(d, postdup);
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, len + INT_GET(postdup->length, ARCH_CONVERT));
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) =
+ cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup);
/*
* If the following entry was in the table, the new entry
@@ -666,18 +670,20 @@ xfs_dir2_data_make_free(
/*
* Otherwise we need a scan if the new entry is big enough.
*/
- else
- needscan = INT_GET(newdup->length, ARCH_CONVERT) > INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT);
+ else {
+ needscan = be16_to_cpu(newdup->length) >
+ be16_to_cpu(d->hdr.bestfree[2].length);
+ }
}
/*
* Neither neighbor is free. Make a new entry.
*/
else {
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, len);
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(len);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) =
+ cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup);
(void)xfs_dir2_data_freeinsert(d, newdup, needlogp);
}
@@ -707,18 +713,18 @@ xfs_dir2_data_use_free(
int oldlen; /* old unused entry's length */
d = bp->data;
- ASSERT(INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC ||
- INT_GET(d->hdr.magic, ARCH_CONVERT) == XFS_DIR2_BLOCK_MAGIC);
- ASSERT(INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG);
+ ASSERT(be32_to_cpu(d->hdr.magic) == XFS_DIR2_DATA_MAGIC ||
+ be32_to_cpu(d->hdr.magic) == XFS_DIR2_BLOCK_MAGIC);
+ ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
ASSERT(offset >= (char *)dup - (char *)d);
- ASSERT(offset + len <= (char *)dup + INT_GET(dup->length, ARCH_CONVERT) - (char *)d);
- ASSERT((char *)dup - (char *)d == INT_GET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT));
+ ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)d);
+ ASSERT((char *)dup - (char *)d == be16_to_cpu(*XFS_DIR2_DATA_UNUSED_TAG_P(dup)));
/*
* Look up the entry in the bestfree table.
*/
dfp = xfs_dir2_data_freefind(d, dup);
- oldlen = INT_GET(dup->length, ARCH_CONVERT);
- ASSERT(dfp || oldlen <= INT_GET(d->hdr.bestfree[2].length, ARCH_CONVERT));
+ oldlen = be16_to_cpu(dup->length);
+ ASSERT(dfp || oldlen <= be16_to_cpu(d->hdr.bestfree[2].length));
/*
* Check for alignment with front and back of the entry.
*/
@@ -732,7 +738,7 @@ xfs_dir2_data_use_free(
*/
if (matchfront && matchback) {
if (dfp) {
- needscan = d->hdr.bestfree[2].offset;
+ needscan = (d->hdr.bestfree[2].offset != 0);
if (!needscan)
xfs_dir2_data_freeremove(d, dfp, needlogp);
}
@@ -743,10 +749,10 @@ xfs_dir2_data_use_free(
*/
else if (matchfront) {
newdup = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
- INT_SET(newdup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup->length, ARCH_CONVERT, oldlen - len);
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+ newdup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup->length = cpu_to_be16(oldlen - len);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) =
+ cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup);
/*
* If it was in the table, remove it and add the new one.
@@ -755,8 +761,8 @@ xfs_dir2_data_use_free(
xfs_dir2_data_freeremove(d, dfp, needlogp);
dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
ASSERT(dfp != NULL);
- ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT));
- ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d);
+ ASSERT(dfp->length == newdup->length);
+ ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
/*
* If we got inserted at the last slot,
* that means we don't know if there was a better
@@ -771,10 +777,9 @@ xfs_dir2_data_use_free(
*/
else if (matchback) {
newdup = dup;
- INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t)
- (((char *)d + offset) - (char *)newdup));
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+ newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) =
+ cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup);
/*
* If it was in the table, remove it and add the new one.
@@ -783,8 +788,8 @@ xfs_dir2_data_use_free(
xfs_dir2_data_freeremove(d, dfp, needlogp);
dfp = xfs_dir2_data_freeinsert(d, newdup, needlogp);
ASSERT(dfp != NULL);
- ASSERT(INT_GET(dfp->length, ARCH_CONVERT) == INT_GET(newdup->length, ARCH_CONVERT));
- ASSERT(INT_GET(dfp->offset, ARCH_CONVERT) == (char *)newdup - (char *)d);
+ ASSERT(dfp->length == newdup->length);
+ ASSERT(be16_to_cpu(dfp->offset) == (char *)newdup - (char *)d);
/*
* If we got inserted at the last slot,
* that means we don't know if there was a better
@@ -799,16 +804,15 @@ xfs_dir2_data_use_free(
*/
else {
newdup = dup;
- INT_SET(newdup->length, ARCH_CONVERT, (xfs_dir2_data_off_t)
- (((char *)d + offset) - (char *)newdup));
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup - (char *)d));
+ newdup->length = cpu_to_be16(((char *)d + offset) - (char *)newdup);
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup) =
+ cpu_to_be16((char *)newdup - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup);
newdup2 = (xfs_dir2_data_unused_t *)((char *)d + offset + len);
- INT_SET(newdup2->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
- INT_SET(newdup2->length, ARCH_CONVERT, oldlen - len - INT_GET(newdup->length, ARCH_CONVERT));
- INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(newdup2), ARCH_CONVERT,
- (xfs_dir2_data_off_t)((char *)newdup2 - (char *)d));
+ newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
+ newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
+ *XFS_DIR2_DATA_UNUSED_TAG_P(newdup2) =
+ cpu_to_be16((char *)newdup2 - (char *)d);
xfs_dir2_data_log_unused(tp, bp, newdup2);
/*
* If the old entry was in the table, we need to scan
@@ -819,7 +823,7 @@ xfs_dir2_data_use_free(
* the 2 new will work.
*/
if (dfp) {
- needscan = d->hdr.bestfree[2].length;
+ needscan = (d->hdr.bestfree[2].length != 0);
if (!needscan) {
xfs_dir2_data_freeremove(d, dfp, needlogp);
(void)xfs_dir2_data_freeinsert(d, newdup,
diff --git a/fs/xfs/xfs_dir2_data.h b/fs/xfs/xfs_dir2_data.h
index 5e3a7f9ec73..0847cbb53e1 100644
--- a/fs/xfs/xfs_dir2_data.h
+++ b/fs/xfs/xfs_dir2_data.h
@@ -65,8 +65,8 @@ struct xfs_trans;
* The freespace will be formatted as a xfs_dir2_data_unused_t.
*/
typedef struct xfs_dir2_data_free {
- xfs_dir2_data_off_t offset; /* start of freespace */
- xfs_dir2_data_off_t length; /* length of freespace */
+ __be16 offset; /* start of freespace */
+ __be16 length; /* length of freespace */
} xfs_dir2_data_free_t;
/*
@@ -75,7 +75,7 @@ typedef struct xfs_dir2_data_free {
* The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
*/
typedef struct xfs_dir2_data_hdr {
- __uint32_t magic; /* XFS_DIR2_DATA_MAGIC */
+ __be32 magic; /* XFS_DIR2_DATA_MAGIC */
/* or XFS_DIR2_BLOCK_MAGIC */
xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
} xfs_dir2_data_hdr_t;
@@ -97,10 +97,10 @@ typedef struct xfs_dir2_data_entry {
* Tag appears as the last 2 bytes.
*/
typedef struct xfs_dir2_data_unused {
- __uint16_t freetag; /* XFS_DIR2_DATA_FREE_TAG */
- xfs_dir2_data_off_t length; /* total free length */
+ __be16 freetag; /* XFS_DIR2_DATA_FREE_TAG */
+ __be16 length; /* total free length */
/* variable offset */
- xfs_dir2_data_off_t tag; /* starting offset of us */
+ __be16 tag; /* starting offset of us */
} xfs_dir2_data_unused_t;
typedef union {
@@ -134,12 +134,11 @@ static inline int xfs_dir2_data_entsize(int n)
* Pointer to an entry's tag word.
*/
#define XFS_DIR2_DATA_ENTRY_TAG_P(dep) xfs_dir2_data_entry_tag_p(dep)
-static inline xfs_dir2_data_off_t *
+static inline __be16 *
xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep)
{
- return (xfs_dir2_data_off_t *) \
- ((char *)(dep) + XFS_DIR2_DATA_ENTSIZE((dep)->namelen) - \
- (uint)sizeof(xfs_dir2_data_off_t));
+ return (__be16 *)((char *)dep +
+ XFS_DIR2_DATA_ENTSIZE(dep->namelen) - sizeof(__be16));
}
/*
@@ -147,12 +146,11 @@ xfs_dir2_data_entry_tag_p(xfs_dir2_data_entry_t *dep)
*/
#define XFS_DIR2_DATA_UNUSED_TAG_P(dup) \
xfs_dir2_data_unused_tag_p(dup)
-static inline xfs_dir2_data_off_t *
+static inline __be16 *
xfs_dir2_data_unused_tag_p(xfs_dir2_data_unused_t *dup)
{
- return (xfs_dir2_data_off_t *) \
- ((char *)(dup) + INT_GET((dup)->length, ARCH_CONVERT) \
- - (uint)sizeof(xfs_dir2_data_off_t));
+ return (__be16 *)((char *)dup +
+ be16_to_cpu(dup->length) - sizeof(__be16));
}
/*
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index d342b6b5523..08648b18265 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -66,7 +66,7 @@ xfs_dir2_block_to_leaf(
xfs_da_args_t *args, /* operation arguments */
xfs_dabuf_t *dbp) /* input block's buffer */
{
- xfs_dir2_data_off_t *bestsp; /* leaf's bestsp entries */
+ __be16 *bestsp; /* leaf's bestsp entries */
xfs_dablk_t blkno; /* leaf block's bno */
xfs_dir2_block_t *block; /* block structure */
xfs_dir2_leaf_entry_t *blp; /* block's leaf entries */
@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf(
/*
* Set the counts in the leaf header.
*/
- INT_COPY(leaf->hdr.count, btp->count, ARCH_CONVERT); /* INT_: type change */
- INT_COPY(leaf->hdr.stale, btp->stale, ARCH_CONVERT); /* INT_: type change */
+ leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count));
+ leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale));
/*
* Could compact these but I think we always do the conversion
* after squeezing out stale entries.
*/
- memcpy(leaf->ents, blp, INT_GET(btp->count, ARCH_CONVERT) * sizeof(xfs_dir2_leaf_entry_t));
- xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1);
+ memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
+ xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1);
needscan = 0;
needlog = 1;
/*
@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf(
/*
* Fix up the block header, make it a data block.
*/
- INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC);
+ block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog,
NULL);
@@ -141,9 +141,9 @@ xfs_dir2_block_to_leaf(
* Set up leaf tail and bests table.
*/
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
- INT_SET(ltp->bestcount, ARCH_CONVERT, 1);
+ ltp->bestcount = cpu_to_be32(1);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
- INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT);
+ bestsp[0] = block->hdr.bestfree[0].length;
/*
* Log the data header and leaf bests table.
*/
@@ -163,7 +163,7 @@ int /* error */
xfs_dir2_leaf_addname(
xfs_da_args_t *args) /* operation arguments */
{
- xfs_dir2_data_off_t *bestsp; /* freespace table in leaf */
+ __be16 *bestsp; /* freespace table in leaf */
int compact; /* need to compact leaves */
xfs_dir2_data_t *data; /* data block structure */
xfs_dabuf_t *dbp; /* data block buffer */
@@ -187,7 +187,7 @@ xfs_dir2_leaf_addname(
int needbytes; /* leaf block bytes needed */
int needlog; /* need to log data header */
int needscan; /* need to rescan data free */
- xfs_dir2_data_off_t *tagp; /* end of data entry */
+ __be16 *tagp; /* end of data entry */
xfs_trans_t *tp; /* transaction pointer */
xfs_dir2_db_t use_block; /* data block number */
@@ -222,14 +222,14 @@ xfs_dir2_leaf_addname(
* in a data block, improving the lookup of those entries.
*/
for (use_block = -1, lep = &leaf->ents[index];
- index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
+ index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
index++, lep++) {
- if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
- i = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
- ASSERT(i < INT_GET(ltp->bestcount, ARCH_CONVERT));
- ASSERT(INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF);
- if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) {
+ i = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
+ ASSERT(i < be32_to_cpu(ltp->bestcount));
+ ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF);
+ if (be16_to_cpu(bestsp[i]) >= length) {
use_block = i;
break;
}
@@ -238,13 +238,13 @@ xfs_dir2_leaf_addname(
* Didn't find a block yet, linear search all the data blocks.
*/
if (use_block == -1) {
- for (i = 0; i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++) {
+ for (i = 0; i < be32_to_cpu(ltp->bestcount); i++) {
/*
* Remember a block we see that's missing.
*/
- if (INT_GET(bestsp[i], ARCH_CONVERT) == NULLDATAOFF && use_block == -1)
+ if (be16_to_cpu(bestsp[i]) == NULLDATAOFF && use_block == -1)
use_block = i;
- else if (INT_GET(bestsp[i], ARCH_CONVERT) >= length) {
+ else if (be16_to_cpu(bestsp[i]) >= length) {
use_block = i;
break;
}
@@ -260,21 +260,21 @@ xfs_dir2_leaf_addname(
* Now kill use_block if it refers to a missing block, so we
* can use it as an indication of allocation needed.
*/
- if (use_block != -1 && INT_GET(bestsp[use_block], ARCH_CONVERT) == NULLDATAOFF)
+ if (use_block != -1 && be16_to_cpu(bestsp[use_block]) == NULLDATAOFF)
use_block = -1;
/*
* If we don't have enough free bytes but we can make enough
* by compacting out stale entries, we'll do that.
*/
- if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes &&
- INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) {
+ if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes &&
+ be16_to_cpu(leaf->hdr.stale) > 1) {
compact = 1;
}
/*
* Otherwise if we don't have enough free bytes we need to
* convert to node form.
*/
- else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <
+ else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
needbytes) {
/*
* Just checking or no space reservation, give up.
@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname(
* There are stale entries, so we'll need log-low and log-high
* impossibly bad values later.
*/
- else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) {
- lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ else if (be16_to_cpu(leaf->hdr.stale)) {
+ lfloglow = be16_to_cpu(leaf->hdr.count);
lfloghigh = -1;
}
/*
@@ -358,13 +358,13 @@ xfs_dir2_leaf_addname(
* If we're adding a new data block on the end we need to
* extend the bests table. Copy it up one entry.
*/
- if (use_block >= INT_GET(ltp->bestcount, ARCH_CONVERT)) {
+ if (use_block >= be32_to_cpu(ltp->bestcount)) {
bestsp--;
memmove(&bestsp[0], &bestsp[1],
- INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(bestsp[0]));
- INT_MOD(ltp->bestcount, ARCH_CONVERT, +1);
+ be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0]));
+ be32_add(&ltp->bestcount, 1);
xfs_dir2_leaf_log_tail(tp, lbp);
- xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
+ xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
}
/*
* If we're filling in a previously empty block just log it.
@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname(
else
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
data = dbp->data;
- INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT);
+ bestsp[use_block] = data->hdr.bestfree[0].length;
grown = 1;
}
/*
@@ -394,8 +394,8 @@ xfs_dir2_leaf_addname(
* Point to the biggest freespace in our data block.
*/
dup = (xfs_dir2_data_unused_t *)
- ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT));
- ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length);
+ ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
+ ASSERT(be16_to_cpu(dup->length) >= length);
needscan = needlog = 0;
/*
* Mark the initial part of our freespace in use for the new entry.
@@ -411,7 +411,7 @@ xfs_dir2_leaf_addname(
dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data));
+ *tagp = cpu_to_be16((char *)dep - (char *)data);
/*
* Need to scan fix up the bestfree table.
*/
@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname(
* If the bests table needs to be changed, do it.
* Log the change unless we've already done that.
*/
- if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) {
- INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT);
+ if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(data->hdr.bestfree[0].length)) {
+ bestsp[use_block] = data->hdr.bestfree[0].length;
if (!grown)
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
}
@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname(
/*
* lep is still good as the index leaf entry.
*/
- if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT))
+ if (index < be16_to_cpu(leaf->hdr.count))
memmove(lep + 1, lep,
- (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep));
+ (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
/*
* Record low and high logging indices for the leaf.
*/
lfloglow = index;
- lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT);
- INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1);
+ lfloghigh = be16_to_cpu(leaf->hdr.count);
+ be16_add(&leaf->hdr.count, 1);
}
/*
* There are stale entries.
@@ -468,7 +468,7 @@ xfs_dir2_leaf_addname(
*/
for (lowstale = index - 1;
lowstale >= 0 &&
- INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) !=
+ be32_to_cpu(leaf->ents[lowstale].address) !=
XFS_DIR2_NULL_DATAPTR;
lowstale--)
continue;
@@ -478,8 +478,8 @@ xfs_dir2_leaf_addname(
* lowstale entry would be better.
*/
for (highstale = index;
- highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) &&
- INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
+ highstale < be16_to_cpu(leaf->hdr.count) &&
+ be32_to_cpu(leaf->ents[highstale].address) !=
XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 ||
index - lowstale - 1 >= highstale - index);
@@ -490,10 +490,10 @@ xfs_dir2_leaf_addname(
* If the low one is better, use it.
*/
if (lowstale >= 0 &&
- (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
+ (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) {
ASSERT(index - lowstale - 1 >= 0);
- ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(leaf->ents[lowstale].address) ==
XFS_DIR2_NULL_DATAPTR);
/*
* Copy entries up to cover the stale entry
@@ -512,7 +512,7 @@ xfs_dir2_leaf_addname(
*/
else {
ASSERT(highstale - index >= 0);
- ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(leaf->ents[highstale].address) ==
XFS_DIR2_NULL_DATAPTR);
/*
* Copy entries down to copver the stale entry
@@ -526,13 +526,14 @@ xfs_dir2_leaf_addname(
lfloglow = MIN(index, lfloglow);
lfloghigh = MAX(highstale, lfloghigh);
}
- INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1);
+ be16_add(&leaf->hdr.stale, -1);
}
/*
* Fill in the new leaf entry.
*/
- INT_SET(lep->hashval, ARCH_CONVERT, args->hashval);
- INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block, INT_GET(*tagp, ARCH_CONVERT)));
+ lep->hashval = cpu_to_be32(args->hashval);
+ lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp, use_block,
+ be16_to_cpu(*tagp)));
/*
* Log the leaf fields and give up the buffers.
*/
@@ -563,30 +564,30 @@ xfs_dir2_leaf_check(
leaf = bp->data;
mp = dp->i_mount;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
/*
* This value is not restrictive enough.
* Should factor in the size of the bests table as well.
* We can deduce a value for that from di_size.
*/
- ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
+ ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
/*
* Leaves and bests don't overlap.
*/
- ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <=
+ ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
(char *)XFS_DIR2_LEAF_BESTS_P(ltp));
/*
* Check hash value order, count stale entries.
*/
- for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) {
- if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT))
- ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
- INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
- if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
+ if (i + 1 < be16_to_cpu(leaf->hdr.count))
+ ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
+ be32_to_cpu(leaf->ents[i + 1].hashval));
+ if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
stale++;
}
- ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale);
+ ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
}
#endif /* DEBUG */
@@ -611,8 +612,8 @@ xfs_dir2_leaf_compact(
/*
* Compress out the stale entries in place.
*/
- for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
- if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) {
+ if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR)
continue;
/*
* Only actually copy the entries that are different.
@@ -627,8 +628,8 @@ xfs_dir2_leaf_compact(
/*
* Update and log the header, log the leaf entries.
*/
- ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to);
- INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT)));
+ ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to);
+ be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale)));
leaf->hdr.stale = 0;
xfs_dir2_leaf_log_header(args->trans, bp);
if (loglow != -1)
@@ -662,14 +663,14 @@ xfs_dir2_leaf_compact_x1(
int to; /* destination copy index */
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1);
+ ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
index = *indexp;
/*
* Find the first stale entry before our index, if any.
*/
for (lowstale = index - 1;
lowstale >= 0 &&
- INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR;
+ be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR;
lowstale--)
continue;
/*
@@ -677,8 +678,8 @@ xfs_dir2_leaf_compact_x1(
* Stop if the answer would be worse than lowstale.
*/
for (highstale = index;
- highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) &&
- INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
+ highstale < be16_to_cpu(leaf->hdr.count) &&
+ be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 || index - lowstale > highstale - index);
highstale++)
continue;
@@ -686,7 +687,7 @@ xfs_dir2_leaf_compact_x1(
* Pick the better of lowstale and highstale.
*/
if (lowstale >= 0 &&
- (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
+ (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale <= highstale - index))
keepstale = lowstale;
else
@@ -695,14 +696,14 @@ xfs_dir2_leaf_compact_x1(
* Copy the entries in place, removing all the stale entries
* except keepstale.
*/
- for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
+ for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
/*
* Notice the new value of index.
*/
if (index == from)
newindex = to;
if (from != keepstale &&
- INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) {
+ be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) {
if (from == to)
*lowlogp = to;
continue;
@@ -730,8 +731,8 @@ xfs_dir2_leaf_compact_x1(
/*
* Adjust the leaf header values.
*/
- INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to));
- INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1);
+ be16_add(&leaf->hdr.count, -(from - to));
+ leaf->hdr.stale = cpu_to_be16(1);
/*
* Remember the low/high stale value only in the "right"
* direction.
@@ -739,8 +740,8 @@ xfs_dir2_leaf_compact_x1(
if (lowstale >= newindex)
lowstale = -1;
else
- highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT);
- *highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1;
+ highstale = be16_to_cpu(leaf->hdr.count);
+ *highlogp = be16_to_cpu(leaf->hdr.count) - 1;
*lowstalep = lowstale;
*highstalep = highstale;
}
@@ -766,7 +767,7 @@ xfs_dir2_leaf_getdents(
xfs_dir2_data_entry_t *dep; /* data entry */
xfs_dir2_data_unused_t *dup; /* unused entry */
int eof; /* reached end of directory */
- int error=0; /* error return value */
+ int error = 0; /* error return value */
int i; /* temporary loop index */
int j; /* temporary loop index */
int length; /* temporary length value */
@@ -778,8 +779,8 @@ xfs_dir2_leaf_getdents(
xfs_mount_t *mp; /* filesystem mount point */
xfs_dir2_off_t newoff; /* new curoff after new blk */
int nmap; /* mappings to ask xfs_bmapi */
- xfs_dir2_put_args_t p; /* formatting arg bundle */
- char *ptr=NULL; /* pointer to current data */
+ xfs_dir2_put_args_t *p; /* formatting arg bundle */
+ char *ptr = NULL; /* pointer to current data */
int ra_current; /* number of read-ahead blks */
int ra_index; /* *map index for read-ahead */
int ra_offset; /* map entry offset for ra */
@@ -797,9 +798,10 @@ xfs_dir2_leaf_getdents(
/*
* Setup formatting arguments.
*/
- p.dbp = dbp;
- p.put = put;
- p.uio = uio;
+ p = kmem_alloc(sizeof(*p), KM_SLEEP);
+ p->dbp = dbp;
+ p->put = put;
+ p->uio = uio;
/*
* Set up to bmap a number of blocks based on the caller's
* buffer size, the directory block size, and the filesystem
@@ -1046,11 +1048,10 @@ xfs_dir2_leaf_getdents(
while ((char *)ptr - (char *)data < byteoff) {
dup = (xfs_dir2_data_unused_t *)ptr;
- if (INT_GET(dup->freetag, ARCH_CONVERT)
+ if (be16_to_cpu(dup->freetag)
== XFS_DIR2_DATA_FREE_TAG) {
- length = INT_GET(dup->length,
- ARCH_CONVERT);
+ length = be16_to_cpu(dup->length);
ptr += length;
continue;
}
@@ -1079,9 +1080,8 @@ xfs_dir2_leaf_getdents(
/*
* No, it's unused, skip over it.
*/
- if (INT_GET(dup->freetag, ARCH_CONVERT)
- == XFS_DIR2_DATA_FREE_TAG) {
- length = INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ length = be16_to_cpu(dup->length);
ptr += length;
curoff += length;
continue;
@@ -1092,24 +1092,24 @@ xfs_dir2_leaf_getdents(
*/
dep = (xfs_dir2_data_entry_t *)ptr;
- p.namelen = dep->namelen;
+ p->namelen = dep->namelen;
- length = XFS_DIR2_DATA_ENTSIZE(p.namelen);
+ length = XFS_DIR2_DATA_ENTSIZE(p->namelen);
- p.cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length);
+ p->cook = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff + length);
- p.ino = INT_GET(dep->inumber, ARCH_CONVERT);
+ p->ino = INT_GET(dep->inumber, ARCH_CONVERT);
#if XFS_BIG_INUMS
- p.ino += mp->m_inoadd;
+ p->ino += mp->m_inoadd;
#endif
- p.name = (char *)dep->name;
+ p->name = (char *)dep->name;
- error = p.put(&p);
+ error = p->put(p);
/*
* Won't fit. Return to caller.
*/
- if (!p.done) {
+ if (!p->done) {
eof = 0;
break;
}
@@ -1129,6 +1129,7 @@ xfs_dir2_leaf_getdents(
else
uio->uio_offset = XFS_DIR2_BYTE_TO_DATAPTR(mp, curoff);
kmem_free(map, map_size * sizeof(*map));
+ kmem_free(p, sizeof(*p));
if (bp)
xfs_da_brelse(tp, bp);
return error;
@@ -1171,7 +1172,7 @@ xfs_dir2_leaf_init(
/*
* Initialize the header.
*/
- INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic);
+ leaf->hdr.info.magic = cpu_to_be16(magic);
leaf->hdr.info.forw = 0;
leaf->hdr.info.back = 0;
leaf->hdr.count = 0;
@@ -1201,13 +1202,13 @@ xfs_dir2_leaf_log_bests(
int first, /* first entry to log */
int last) /* last entry to log */
{
- xfs_dir2_data_off_t *firstb; /* pointer to first entry */
- xfs_dir2_data_off_t *lastb; /* pointer to last entry */
+ __be16 *firstb; /* pointer to first entry */
+ __be16 *lastb; /* pointer to last entry */
xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf);
firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first;
lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last;
@@ -1230,8 +1231,8 @@ xfs_dir2_leaf_log_ents(
xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
- INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
+ be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
firstlep = &leaf->ents[first];
lastlep = &leaf->ents[last];
xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
@@ -1249,8 +1250,8 @@ xfs_dir2_leaf_log_header(
xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
- INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
+ be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
(uint)(sizeof(leaf->hdr) - 1));
}
@@ -1269,7 +1270,7 @@ xfs_dir2_leaf_log_tail(
mp = tp->t_mountp;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
(uint)(mp->m_dirblksize - 1));
@@ -1314,7 +1315,7 @@ xfs_dir2_leaf_lookup(
*/
dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data +
- XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT)));
+ XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address)));
/*
* Return the found inode number.
*/
@@ -1373,17 +1374,17 @@ xfs_dir2_leaf_lookup_int(
* looking to match the name.
*/
for (lep = &leaf->ents[index], dbp = NULL, curdb = -1;
- index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
+ index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
lep++, index++) {
/*
* Skip over stale leaf entries.
*/
- if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
/*
* Get the new data block number.
*/
- newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+ newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
/*
* If it's not the same as the old data block number,
* need to pitch the old one and read the new one.
@@ -1406,7 +1407,7 @@ xfs_dir2_leaf_lookup_int(
*/
dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data +
- XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
+ XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
/*
* If it matches then return it.
*/
@@ -1435,7 +1436,7 @@ int /* error */
xfs_dir2_leaf_removename(
xfs_da_args_t *args) /* operation arguments */
{
- xfs_dir2_data_off_t *bestsp; /* leaf block best freespace */
+ __be16 *bestsp; /* leaf block best freespace */
xfs_dir2_data_t *data; /* data block structure */
xfs_dir2_db_t db; /* data block number */
xfs_dabuf_t *dbp; /* data block buffer */
@@ -1471,14 +1472,14 @@ xfs_dir2_leaf_removename(
* Point to the leaf entry, use that to point to the data entry.
*/
lep = &leaf->ents[index];
- db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+ db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
dep = (xfs_dir2_data_entry_t *)
- ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
+ ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
needscan = needlog = 0;
- oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT);
+ oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
- ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest);
+ ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
/*
* Mark the former data entry unused.
*/
@@ -1488,9 +1489,9 @@ xfs_dir2_leaf_removename(
/*
* We just mark the leaf entry stale by putting a null in it.
*/
- INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1);
+ be16_add(&leaf->hdr.stale, 1);
xfs_dir2_leaf_log_header(tp, lbp);
- INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
+ lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
xfs_dir2_leaf_log_ents(tp, lbp, index, index);
/*
* Scan the freespace in the data block again if necessary,
@@ -1504,15 +1505,15 @@ xfs_dir2_leaf_removename(
* If the longest freespace in the data block has changed,
* put the new value in the bests table and log that.
*/
- if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) {
- INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT);
+ if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) {
+ bestsp[db] = data->hdr.bestfree[0].length;
xfs_dir2_leaf_log_bests(tp, lbp, db, db);
}
xfs_dir2_data_check(dp, dbp);
/*
* If the data block is now empty then get rid of the data block.
*/
- if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) ==
+ if (be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)) {
ASSERT(db != mp->m_dirdatablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
@@ -1535,12 +1536,12 @@ xfs_dir2_leaf_removename(
* If this is the last data block then compact the
* bests table by getting rid of entries.
*/
- if (db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1) {
+ if (db == be32_to_cpu(ltp->bestcount) - 1) {
/*
* Look for the last active entry (i).
*/
for (i = db - 1; i > 0; i--) {
- if (INT_GET(bestsp[i], ARCH_CONVERT) != NULLDATAOFF)
+ if (be16_to_cpu(bestsp[i]) != NULLDATAOFF)
break;
}
/*
@@ -1548,12 +1549,12 @@ xfs_dir2_leaf_removename(
* end are removed.
*/
memmove(&bestsp[db - i], bestsp,
- (INT_GET(ltp->bestcount, ARCH_CONVERT) - (db - i)) * sizeof(*bestsp));
- INT_MOD(ltp->bestcount, ARCH_CONVERT, -(db - i));
+ (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp));
+ be32_add(&ltp->bestcount, -(db - i));
xfs_dir2_leaf_log_tail(tp, lbp);
- xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
+ xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
} else
- INT_SET(bestsp[db], ARCH_CONVERT, NULLDATAOFF);
+ bestsp[db] = cpu_to_be16(NULLDATAOFF);
}
/*
* If the data block was not the first one, drop it.
@@ -1604,7 +1605,7 @@ xfs_dir2_leaf_replace(
*/
dep = (xfs_dir2_data_entry_t *)
((char *)dbp->data +
- XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, INT_GET(lep->address, ARCH_CONVERT)));
+ XFS_DIR2_DATAPTR_TO_OFF(dp->i_mount, be32_to_cpu(lep->address)));
ASSERT(args->inumber != INT_GET(dep->inumber, ARCH_CONVERT));
/*
* Put the new inode number in, log it.
@@ -1645,11 +1646,11 @@ xfs_dir2_leaf_search_hash(
* Note, the table cannot be empty, so we have to go through the loop.
* Binary search the leaf entries looking for our hash value.
*/
- for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1,
+ for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1,
hashwant = args->hashval;
low <= high; ) {
mid = (low + high) >> 1;
- if ((hash = INT_GET(lep[mid].hashval, ARCH_CONVERT)) == hashwant)
+ if ((hash = be32_to_cpu(lep[mid].hashval)) == hashwant)
break;
if (hash < hashwant)
low = mid + 1;
@@ -1660,7 +1661,7 @@ xfs_dir2_leaf_search_hash(
* Found one, back up through all the equal hash values.
*/
if (hash == hashwant) {
- while (mid > 0 && INT_GET(lep[mid - 1].hashval, ARCH_CONVERT) == hashwant) {
+ while (mid > 0 && be32_to_cpu(lep[mid - 1].hashval) == hashwant) {
mid--;
}
}
@@ -1682,7 +1683,7 @@ xfs_dir2_leaf_trim_data(
xfs_dabuf_t *lbp, /* leaf buffer */
xfs_dir2_db_t db) /* data block number */
{
- xfs_dir2_data_off_t *bestsp; /* leaf bests table */
+ __be16 *bestsp; /* leaf bests table */
#ifdef DEBUG
xfs_dir2_data_t *data; /* data block structure */
#endif
@@ -1706,7 +1707,7 @@ xfs_dir2_leaf_trim_data(
}
#ifdef DEBUG
data = dbp->data;
- ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC);
+ ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
#endif
/* this seems to be an error
* data is only valid if DEBUG is defined?
@@ -1715,9 +1716,9 @@ xfs_dir2_leaf_trim_data(
leaf = lbp->data;
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
- ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) ==
+ ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr));
- ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
+ ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
/*
* Get rid of the data block.
*/
@@ -1730,10 +1731,10 @@ xfs_dir2_leaf_trim_data(
* Eliminate the last bests entry from the table.
*/
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
- INT_MOD(ltp->bestcount, ARCH_CONVERT, -1);
- memmove(&bestsp[1], &bestsp[0], INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(*bestsp));
+ be32_add(&ltp->bestcount, -1);
+ memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp));
xfs_dir2_leaf_log_tail(tp, lbp);
- xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
+ xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
return 0;
}
@@ -1805,7 +1806,7 @@ xfs_dir2_node_to_leaf(
return 0;
lbp = state->path.blk[0].bp;
leaf = lbp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
/*
* Read the freespace block.
*/
@@ -1814,15 +1815,15 @@ xfs_dir2_node_to_leaf(
return error;
}
free = fbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
ASSERT(!free->hdr.firstdb);
/*
* Now see if the leafn and free data will fit in a leaf1.
* If not, release the buffer and give up.
*/
if ((uint)sizeof(leaf->hdr) +
- (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) +
- INT_GET(free->hdr.nvalid, ARCH_CONVERT) * (uint)sizeof(leaf->bests[0]) +
+ (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) +
+ be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) +
(uint)sizeof(leaf->tail) >
mp->m_dirblksize) {
xfs_da_brelse(tp, fbp);
@@ -1832,22 +1833,22 @@ xfs_dir2_node_to_leaf(
* If the leaf has any stale entries in it, compress them out.
* The compact routine will log the header.
*/
- if (INT_GET(leaf->hdr.stale, ARCH_CONVERT))
+ if (be16_to_cpu(leaf->hdr.stale))
xfs_dir2_leaf_compact(args, lbp);
else
xfs_dir2_leaf_log_header(tp, lbp);
- INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC);
+ leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC);
/*
* Set up the leaf tail from the freespace block.
*/
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
- INT_COPY(ltp->bestcount, free->hdr.nvalid, ARCH_CONVERT);
+ ltp->bestcount = free->hdr.nvalid;
/*
* Set up the leaf bests table.
*/
memcpy(XFS_DIR2_LEAF_BESTS_P(ltp), free->bests,
- INT_GET(ltp->bestcount, ARCH_CONVERT) * sizeof(leaf->bests[0]));
- xfs_dir2_leaf_log_bests(tp, lbp, 0, INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
+ be32_to_cpu(ltp->bestcount) * sizeof(leaf->bests[0]));
+ xfs_dir2_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
xfs_dir2_leaf_log_tail(tp, lbp);
xfs_dir2_leaf_check(dp, lbp);
/*
diff --git a/fs/xfs/xfs_dir2_leaf.h b/fs/xfs/xfs_dir2_leaf.h
index 1393993d61e..f57ca116241 100644
--- a/fs/xfs/xfs_dir2_leaf.h
+++ b/fs/xfs/xfs_dir2_leaf.h
@@ -46,23 +46,23 @@ typedef __uint32_t xfs_dir2_dataptr_t;
*/
typedef struct xfs_dir2_leaf_hdr {
xfs_da_blkinfo_t info; /* header for da routines */
- __uint16_t count; /* count of entries */
- __uint16_t stale; /* count of stale entries */
+ __be16 count; /* count of entries */
+ __be16 stale; /* count of stale entries */
} xfs_dir2_leaf_hdr_t;
/*
* Leaf block entry.
*/
typedef struct xfs_dir2_leaf_entry {
- xfs_dahash_t hashval; /* hash value of name */
- xfs_dir2_dataptr_t address; /* address of data entry */
+ __be32 hashval; /* hash value of name */
+ __be32 address; /* address of data entry */
} xfs_dir2_leaf_entry_t;
/*
* Leaf block tail.
*/
typedef struct xfs_dir2_leaf_tail {
- __uint32_t bestcount;
+ __be32 bestcount;
} xfs_dir2_leaf_tail_t;
/*
@@ -105,11 +105,10 @@ xfs_dir2_leaf_tail_p(struct xfs_mount *mp, xfs_dir2_leaf_t *lp)
* Get address of the bests array in the single-leaf block.
*/
#define XFS_DIR2_LEAF_BESTS_P(ltp) xfs_dir2_leaf_bests_p(ltp)
-static inline xfs_dir2_data_off_t *
+static inline __be16 *
xfs_dir2_leaf_bests_p(xfs_dir2_leaf_tail_t *ltp)
{
- return (xfs_dir2_data_off_t *)
- (ltp) - INT_GET((ltp)->bestcount, ARCH_CONVERT);
+ return (__be16 *)ltp - be32_to_cpu(ltp->bestcount);
}
/*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 641f8633d25..af556f16a0c 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -76,7 +76,7 @@ xfs_dir2_free_log_bests(
xfs_dir2_free_t *free; /* freespace structure */
free = bp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
xfs_da_log_buf(tp, bp,
(uint)((char *)&free->bests[first] - (char *)free),
(uint)((char *)&free->bests[last] - (char *)free +
@@ -94,7 +94,7 @@ xfs_dir2_free_log_header(
xfs_dir2_free_t *free; /* freespace structure */
free = bp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
(uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
}
@@ -114,14 +114,14 @@ xfs_dir2_leaf_to_node(
xfs_dabuf_t *fbp; /* freespace buffer */
xfs_dir2_db_t fdb; /* freespace block number */
xfs_dir2_free_t *free; /* freespace structure */
- xfs_dir2_data_off_t *from; /* pointer to freespace entry */
+ __be16 *from; /* pointer to freespace entry */
int i; /* leaf freespace index */
xfs_dir2_leaf_t *leaf; /* leaf structure */
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
xfs_mount_t *mp; /* filesystem mount point */
int n; /* count of live freespc ents */
xfs_dir2_data_off_t off; /* freespace entry value */
- xfs_dir2_data_off_t *to; /* pointer to freespace entry */
+ __be16 *to; /* pointer to freespace entry */
xfs_trans_t *tp; /* transaction pointer */
xfs_dir2_trace_args_b("leaf_to_node", args, lbp);
@@ -149,28 +149,28 @@ xfs_dir2_leaf_to_node(
/*
* Initialize the freespace block header.
*/
- INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC);
+ free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
free->hdr.firstdb = 0;
- ASSERT(INT_GET(ltp->bestcount, ARCH_CONVERT) <= (uint)dp->i_d.di_size / mp->m_dirblksize);
- INT_COPY(free->hdr.nvalid, ltp->bestcount, ARCH_CONVERT);
+ ASSERT(be32_to_cpu(ltp->bestcount) <= (uint)dp->i_d.di_size / mp->m_dirblksize);
+ free->hdr.nvalid = ltp->bestcount;
/*
* Copy freespace entries from the leaf block to the new block.
* Count active entries.
*/
for (i = n = 0, from = XFS_DIR2_LEAF_BESTS_P(ltp), to = free->bests;
- i < INT_GET(ltp->bestcount, ARCH_CONVERT); i++, from++, to++) {
- if ((off = INT_GET(*from, ARCH_CONVERT)) != NULLDATAOFF)
+ i < be32_to_cpu(ltp->bestcount); i++, from++, to++) {
+ if ((off = be16_to_cpu(*from)) != NULLDATAOFF)
n++;
- INT_SET(*to, ARCH_CONVERT, off);
+ *to = cpu_to_be16(off);
}
- INT_SET(free->hdr.nused, ARCH_CONVERT, n);
- INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAFN_MAGIC);
+ free->hdr.nused = cpu_to_be32(n);
+ leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC);
/*
* Log everything.
*/
xfs_dir2_leaf_log_header(tp, lbp);
xfs_dir2_free_log_header(tp, fbp);
- xfs_dir2_free_log_bests(tp, fbp, 0, INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1);
+ xfs_dir2_free_log_bests(tp, fbp, 0, be32_to_cpu(free->hdr.nvalid) - 1);
xfs_da_buf_done(fbp);
xfs_dir2_leafn_check(dp, lbp);
return 0;
@@ -217,15 +217,15 @@ xfs_dir2_leafn_add(
* a compact.
*/
- if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
+ if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
if (!leaf->hdr.stale)
return XFS_ERROR(ENOSPC);
- compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1;
+ compact = be16_to_cpu(leaf->hdr.stale) > 1;
} else
compact = 0;
- ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval);
- ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
- INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval);
+ ASSERT(index == 0 || be32_to_cpu(leaf->ents[index - 1].hashval) <= args->hashval);
+ ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
+ be32_to_cpu(leaf->ents[index].hashval) >= args->hashval);
if (args->justcheck)
return 0;
@@ -242,7 +242,7 @@ xfs_dir2_leafn_add(
* Set impossible logging indices for this case.
*/
else if (leaf->hdr.stale) {
- lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ lfloglow = be16_to_cpu(leaf->hdr.count);
lfloghigh = -1;
}
/*
@@ -250,12 +250,12 @@ xfs_dir2_leafn_add(
*/
if (!leaf->hdr.stale) {
lep = &leaf->ents[index];
- if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT))
+ if (index < be16_to_cpu(leaf->hdr.count))
memmove(lep + 1, lep,
- (INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep));
+ (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
lfloglow = index;
- lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT);
- INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1);
+ lfloghigh = be16_to_cpu(leaf->hdr.count);
+ be16_add(&leaf->hdr.count, 1);
}
/*
* There are stale entries. We'll use one for the new entry.
@@ -271,7 +271,7 @@ xfs_dir2_leafn_add(
*/
for (lowstale = index - 1;
lowstale >= 0 &&
- INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) !=
+ be32_to_cpu(leaf->ents[lowstale].address) !=
XFS_DIR2_NULL_DATAPTR;
lowstale--)
continue;
@@ -281,8 +281,8 @@ xfs_dir2_leafn_add(
* lowstale already found.
*/
for (highstale = index;
- highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) &&
- INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
+ highstale < be16_to_cpu(leaf->hdr.count) &&
+ be32_to_cpu(leaf->ents[highstale].address) !=
XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 ||
index - lowstale - 1 >= highstale - index);
@@ -294,9 +294,9 @@ xfs_dir2_leafn_add(
* Shift entries up toward the stale slot.
*/
if (lowstale >= 0 &&
- (highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) ||
+ (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) {
- ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(leaf->ents[lowstale].address) ==
XFS_DIR2_NULL_DATAPTR);
ASSERT(index - lowstale - 1 >= 0);
if (index - lowstale - 1 > 0)
@@ -312,7 +312,7 @@ xfs_dir2_leafn_add(
* Shift entries down toward the stale slot.
*/
else {
- ASSERT(INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(leaf->ents[highstale].address) ==
XFS_DIR2_NULL_DATAPTR);
ASSERT(highstale - index >= 0);
if (highstale - index > 0)
@@ -323,13 +323,14 @@ xfs_dir2_leafn_add(
lfloglow = MIN(index, lfloglow);
lfloghigh = MAX(highstale, lfloghigh);
}
- INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1);
+ be16_add(&leaf->hdr.stale, -1);
}
/*
* Insert the new entry, log everything.
*/
- INT_SET(lep->hashval, ARCH_CONVERT, args->hashval);
- INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_DB_OFF_TO_DATAPTR(mp, args->blkno, args->index));
+ lep->hashval = cpu_to_be32(args->hashval);
+ lep->address = cpu_to_be32(XFS_DIR2_DB_OFF_TO_DATAPTR(mp,
+ args->blkno, args->index));
xfs_dir2_leaf_log_header(tp, bp);
xfs_dir2_leaf_log_ents(tp, bp, lfloglow, lfloghigh);
xfs_dir2_leafn_check(dp, bp);
@@ -352,17 +353,17 @@ xfs_dir2_leafn_check(
leaf = bp->data;
mp = dp->i_mount;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
- ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
- for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) {
- if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
- ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
- INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
+ for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
+ if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
+ ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
+ be32_to_cpu(leaf->ents[i + 1].hashval));
}
- if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
stale++;
}
- ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale);
+ ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
}
#endif /* DEBUG */
@@ -378,12 +379,12 @@ xfs_dir2_leafn_lasthash(
xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
if (count)
- *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
+ *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count)
return 0;
- return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
+ return be32_to_cpu(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval);
}
/*
@@ -419,9 +420,9 @@ xfs_dir2_leafn_lookup_int(
tp = args->trans;
mp = dp->i_mount;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
#ifdef __KERNEL__
- ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) > 0);
+ ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
#endif
xfs_dir2_leafn_check(dp, bp);
/*
@@ -443,7 +444,7 @@ xfs_dir2_leafn_lookup_int(
curdb = -1;
length = XFS_DIR2_DATA_ENTSIZE(args->namelen);
if ((free = (curbp ? curbp->data : NULL)))
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
}
/*
* For others, it's a data block buffer, get the block number.
@@ -456,17 +457,17 @@ xfs_dir2_leafn_lookup_int(
* Loop over leaf entries with the right hash value.
*/
for (lep = &leaf->ents[index];
- index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
+ index < be16_to_cpu(leaf->hdr.count) && be32_to_cpu(lep->hashval) == args->hashval;
lep++, index++) {
/*
* Skip stale leaf entries.
*/
- if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
/*
* Pull the data block number from the entry.
*/
- newdb = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+ newdb = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
/*
* For addname, we're looking for a place to put the new entry.
* We want to use a data block with an entry of equal
@@ -506,15 +507,15 @@ xfs_dir2_leafn_lookup_int(
}
curfdb = newfdb;
free = curbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(free->hdr.magic) ==
XFS_DIR2_FREE_MAGIC);
- ASSERT((INT_GET(free->hdr.firstdb, ARCH_CONVERT) %
+ ASSERT((be32_to_cpu(free->hdr.firstdb) %
XFS_DIR2_MAX_FREE_BESTS(mp)) ==
0);
- ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) <= curdb);
+ ASSERT(be32_to_cpu(free->hdr.firstdb) <= curdb);
ASSERT(curdb <
- INT_GET(free->hdr.firstdb, ARCH_CONVERT) +
- INT_GET(free->hdr.nvalid, ARCH_CONVERT));
+ be32_to_cpu(free->hdr.firstdb) +
+ be32_to_cpu(free->hdr.nvalid));
}
/*
* Get the index for our entry.
@@ -523,12 +524,12 @@ xfs_dir2_leafn_lookup_int(
/*
* If it has room, return it.
*/
- if (unlikely(INT_GET(free->bests[fi], ARCH_CONVERT) == NULLDATAOFF)) {
+ if (unlikely(be16_to_cpu(free->bests[fi]) == NULLDATAOFF)) {
XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
XFS_ERRLEVEL_LOW, mp);
return XFS_ERROR(EFSCORRUPTED);
}
- if (INT_GET(free->bests[fi], ARCH_CONVERT) >= length) {
+ if (be16_to_cpu(free->bests[fi]) >= length) {
*indexp = index;
state->extravalid = 1;
state->extrablk.bp = curbp;
@@ -572,7 +573,7 @@ xfs_dir2_leafn_lookup_int(
*/
dep = (xfs_dir2_data_entry_t *)
((char *)curbp->data +
- XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
+ XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address)));
/*
* Compare the entry, return it if it matches.
*/
@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_int(
* Return the final index, that will be the insertion point.
*/
*indexp = index;
- ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent);
+ ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent);
return XFS_ERROR(ENOENT);
}
@@ -657,12 +658,12 @@ xfs_dir2_leafn_moveents(
* destination leaf entries, open up a hole in the destination
* to hold the new entries.
*/
- if (start_d < INT_GET(leaf_d->hdr.count, ARCH_CONVERT)) {
+ if (start_d < be16_to_cpu(leaf_d->hdr.count)) {
memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d],
- (INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - start_d) *
+ (be16_to_cpu(leaf_d->hdr.count) - start_d) *
sizeof(xfs_dir2_leaf_entry_t));
xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count,
- count + INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - 1);
+ count + be16_to_cpu(leaf_d->hdr.count) - 1);
}
/*
* If the source has stale leaves, count the ones in the copy range
@@ -672,7 +673,7 @@ xfs_dir2_leafn_moveents(
int i; /* temp leaf index */
for (i = start_s, stale = 0; i < start_s + count; i++) {
- if (INT_GET(leaf_s->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
+ if (be32_to_cpu(leaf_s->ents[i].address) == XFS_DIR2_NULL_DATAPTR)
stale++;
}
} else
@@ -687,7 +688,7 @@ xfs_dir2_leafn_moveents(
* If there are source entries after the ones we copied,
* delete the ones we copied by sliding the next ones down.
*/
- if (start_s + count < INT_GET(leaf_s->hdr.count, ARCH_CONVERT)) {
+ if (start_s + count < be16_to_cpu(leaf_s->hdr.count)) {
memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count],
count * sizeof(xfs_dir2_leaf_entry_t));
xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1);
@@ -695,10 +696,10 @@ xfs_dir2_leafn_moveents(
/*
* Update the headers and log them.
*/
- INT_MOD(leaf_s->hdr.count, ARCH_CONVERT, -(count));
- INT_MOD(leaf_s->hdr.stale, ARCH_CONVERT, -(stale));
- INT_MOD(leaf_d->hdr.count, ARCH_CONVERT, count);
- INT_MOD(leaf_d->hdr.stale, ARCH_CONVERT, stale);
+ be16_add(&leaf_s->hdr.count, -(count));
+ be16_add(&leaf_s->hdr.stale, -(stale));
+ be16_add(&leaf_d->hdr.count, count);
+ be16_add(&leaf_d->hdr.stale, stale);
xfs_dir2_leaf_log_header(tp, bp_s);
xfs_dir2_leaf_log_header(tp, bp_d);
xfs_dir2_leafn_check(args->dp, bp_s);
@@ -719,13 +720,13 @@ xfs_dir2_leafn_order(
leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data;
- ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
- ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
- if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0 &&
- INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0 &&
- (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) ||
- INT_GET(leaf2->ents[INT_GET(leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT) <
- INT_GET(leaf1->ents[INT_GET(leaf1->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT)))
+ ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
+ if (be16_to_cpu(leaf1->hdr.count) > 0 &&
+ be16_to_cpu(leaf2->hdr.count) > 0 &&
+ (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) ||
+ be32_to_cpu(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval) <
+ be32_to_cpu(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval)))
return 1;
return 0;
}
@@ -768,9 +769,9 @@ xfs_dir2_leafn_rebalance(
}
leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data;
- oldsum = INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT);
+ oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
#ifdef DEBUG
- oldstale = INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT);
+ oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
#endif
mid = oldsum >> 1;
/*
@@ -780,10 +781,10 @@ xfs_dir2_leafn_rebalance(
if (oldsum & 1) {
xfs_dahash_t midhash; /* middle entry hash value */
- if (mid >= INT_GET(leaf1->hdr.count, ARCH_CONVERT))
- midhash = INT_GET(leaf2->ents[mid - INT_GET(leaf1->hdr.count, ARCH_CONVERT)].hashval, ARCH_CONVERT);
+ if (mid >= be16_to_cpu(leaf1->hdr.count))
+ midhash = be32_to_cpu(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval);
else
- midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT);
+ midhash = be32_to_cpu(leaf1->ents[mid].hashval);
isleft = args->hashval <= midhash;
}
/*
@@ -797,30 +798,30 @@ xfs_dir2_leafn_rebalance(
* Calculate moved entry count. Positive means left-to-right,
* negative means right-to-left. Then move the entries.
*/
- count = INT_GET(leaf1->hdr.count, ARCH_CONVERT) - mid + (isleft == 0);
+ count = be16_to_cpu(leaf1->hdr.count) - mid + (isleft == 0);
if (count > 0)
xfs_dir2_leafn_moveents(args, blk1->bp,
- INT_GET(leaf1->hdr.count, ARCH_CONVERT) - count, blk2->bp, 0, count);
+ be16_to_cpu(leaf1->hdr.count) - count, blk2->bp, 0, count);
else if (count < 0)
xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp,
- INT_GET(leaf1->hdr.count, ARCH_CONVERT), count);
- ASSERT(INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT) == oldsum);
- ASSERT(INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT) == oldstale);
+ be16_to_cpu(leaf1->hdr.count), count);
+ ASSERT(be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count) == oldsum);
+ ASSERT(be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale) == oldstale);
/*
* Mark whether we're inserting into the old or new leaf.
*/
- if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) < INT_GET(leaf2->hdr.count, ARCH_CONVERT))
+ if (be16_to_cpu(leaf1->hdr.count) < be16_to_cpu(leaf2->hdr.count))
state->inleaf = swap;
- else if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > INT_GET(leaf2->hdr.count, ARCH_CONVERT))
+ else if (be16_to_cpu(leaf1->hdr.count) > be16_to_cpu(leaf2->hdr.count))
state->inleaf = !swap;
else
state->inleaf =
- swap ^ (blk1->index <= INT_GET(leaf1->hdr.count, ARCH_CONVERT));
+ swap ^ (blk1->index <= be16_to_cpu(leaf1->hdr.count));
/*
* Adjust the expected index for insertion.
*/
if (!state->inleaf)
- blk2->index = blk1->index - INT_GET(leaf1->hdr.count, ARCH_CONVERT);
+ blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
/*
* Finally sanity check just to make sure we are not returning a negative index
@@ -867,7 +868,7 @@ xfs_dir2_leafn_remove(
tp = args->trans;
mp = dp->i_mount;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
/*
* Point to the entry we're removing.
*/
@@ -875,17 +876,17 @@ xfs_dir2_leafn_remove(
/*
* Extract the data block and offset from the entry.
*/
- db = XFS_DIR2_DATAPTR_TO_DB(mp, INT_GET(lep->address, ARCH_CONVERT));
+ db = XFS_DIR2_DATAPTR_TO_DB(mp, be32_to_cpu(lep->address));
ASSERT(dblk->blkno == db);
- off = XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT));
+ off = XFS_DIR2_DATAPTR_TO_OFF(mp, be32_to_cpu(lep->address));
ASSERT(dblk->index == off);
/*
* Kill the leaf entry by marking it stale.
* Log the leaf block changes.
*/
- INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1);
+ be16_add(&leaf->hdr.stale, 1);
xfs_dir2_leaf_log_header(tp, bp);
- INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
+ lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
xfs_dir2_leaf_log_ents(tp, bp, index, index);
/*
* Make the data entry free. Keep track of the longest freespace
@@ -894,7 +895,7 @@ xfs_dir2_leafn_remove(
dbp = dblk->bp;
data = dbp->data;
dep = (xfs_dir2_data_entry_t *)((char *)data + off);
- longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT);
+ longest = be16_to_cpu(data->hdr.bestfree[0].length);
needlog = needscan = 0;
xfs_dir2_data_make_free(tp, dbp, off,
XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan);
@@ -911,7 +912,7 @@ xfs_dir2_leafn_remove(
* If the longest data block freespace changes, need to update
* the corresponding freeblock entry.
*/
- if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) {
+ if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) {
int error; /* error return value */
xfs_dabuf_t *fbp; /* freeblock buffer */
xfs_dir2_db_t fdb; /* freeblock block number */
@@ -929,15 +930,15 @@ xfs_dir2_leafn_remove(
return error;
}
free = fbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
- ASSERT(INT_GET(free->hdr.firstdb, ARCH_CONVERT) ==
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.firstdb) ==
XFS_DIR2_MAX_FREE_BESTS(mp) *
(fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
/*
* Calculate which entry we need to fix.
*/
findex = XFS_DIR2_DB_TO_FDINDEX(mp, db);
- longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT);
+ longest = be16_to_cpu(data->hdr.bestfree[0].length);
/*
* If the data block is now empty we can get rid of it
* (usually).
@@ -969,7 +970,7 @@ xfs_dir2_leafn_remove(
/*
* One less used entry in the free table.
*/
- INT_MOD(free->hdr.nused, ARCH_CONVERT, -1);
+ free->hdr.nused = cpu_to_be32(-1);
xfs_dir2_free_log_header(tp, fbp);
/*
* If this was the last entry in the table, we can
@@ -977,21 +978,21 @@ xfs_dir2_leafn_remove(
* entries at the end referring to non-existent
* data blocks, get those too.
*/
- if (findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT) - 1) {
+ if (findex == be32_to_cpu(free->hdr.nvalid) - 1) {
int i; /* free entry index */
for (i = findex - 1;
- i >= 0 && INT_GET(free->bests[i], ARCH_CONVERT) == NULLDATAOFF;
+ i >= 0 && be16_to_cpu(free->bests[i]) == NULLDATAOFF;
i--)
continue;
- INT_SET(free->hdr.nvalid, ARCH_CONVERT, i + 1);
+ free->hdr.nvalid = cpu_to_be32(i + 1);
logfree = 0;
}
/*
* Not the last entry, just punch it out.
*/
else {
- INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF);
+ free->bests[findex] = cpu_to_be16(NULLDATAOFF);
logfree = 1;
}
/*
@@ -1017,7 +1018,7 @@ xfs_dir2_leafn_remove(
* the new value.
*/
else {
- INT_SET(free->bests[findex], ARCH_CONVERT, longest);
+ free->bests[findex] = cpu_to_be16(longest);
logfree = 1;
}
/*
@@ -1039,7 +1040,7 @@ xfs_dir2_leafn_remove(
*rval =
((uint)sizeof(leaf->hdr) +
(uint)sizeof(leaf->ents[0]) *
- (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT))) <
+ (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale))) <
mp->m_dir_magicpct;
return 0;
}
@@ -1138,9 +1139,9 @@ xfs_dir2_leafn_toosmall(
*/
blk = &state->path.blk[state->path.active - 1];
info = blk->bp->data;
- ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC);
leaf = (xfs_dir2_leaf_t *)info;
- count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT);
+ count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]);
if (bytes > (state->blocksize >> 1)) {
/*
@@ -1160,7 +1161,7 @@ xfs_dir2_leafn_toosmall(
* Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one).
*/
- forward = info->forw;
+ forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward, 0,
&rval);
@@ -1176,9 +1177,9 @@ xfs_dir2_leafn_toosmall(
* We prefer coalescing with the lower numbered sibling so as
* to shrink a directory over time.
*/
- forward = INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT);
+ forward = be32_to_cpu(info->forw) < be32_to_cpu(info->back);
for (i = 0, bp = NULL; i < 2; forward = !forward, i++) {
- blkno = forward ?INT_GET( info->forw, ARCH_CONVERT) : INT_GET(info->back, ARCH_CONVERT);
+ blkno = forward ? be32_to_cpu(info->forw) : be32_to_cpu(info->back);
if (blkno == 0)
continue;
/*
@@ -1194,11 +1195,11 @@ xfs_dir2_leafn_toosmall(
* Count bytes in the two blocks combined.
*/
leaf = (xfs_dir2_leaf_t *)info;
- count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT);
+ count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = state->blocksize - (state->blocksize >> 2);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
- count += INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
+ count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes -= count * (uint)sizeof(leaf->ents[0]);
/*
* Fits with at least 25% to spare.
@@ -1256,27 +1257,27 @@ xfs_dir2_leafn_unbalance(
ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
- ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
- ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
+ ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
/*
* If there are any stale leaf entries, take this opportunity
* to purge them.
*/
- if (INT_GET(drop_leaf->hdr.stale, ARCH_CONVERT))
+ if (drop_leaf->hdr.stale)
xfs_dir2_leaf_compact(args, drop_blk->bp);
- if (INT_GET(save_leaf->hdr.stale, ARCH_CONVERT))
+ if (save_leaf->hdr.stale)
xfs_dir2_leaf_compact(args, save_blk->bp);
/*
* Move the entries from drop to the appropriate end of save.
*/
- drop_blk->hashval = INT_GET(drop_leaf->ents[INT_GET(drop_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
+ drop_blk->hashval = be32_to_cpu(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval);
if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0,
- INT_GET(drop_leaf->hdr.count, ARCH_CONVERT));
+ be16_to_cpu(drop_leaf->hdr.count));
else
xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp,
- INT_GET(save_leaf->hdr.count, ARCH_CONVERT), INT_GET(drop_leaf->hdr.count, ARCH_CONVERT));
- save_blk->hashval = INT_GET(save_leaf->ents[INT_GET(save_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
+ be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count));
+ save_blk->hashval = be32_to_cpu(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval);
xfs_dir2_leafn_check(args->dp, save_blk->bp);
}
@@ -1378,7 +1379,7 @@ xfs_dir2_node_addname_int(
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log data header */
int needscan; /* need to rescan data frees */
- xfs_dir2_data_off_t *tagp; /* data entry tag pointer */
+ __be16 *tagp; /* data entry tag pointer */
xfs_trans_t *tp; /* transaction pointer */
dp = args->dp;
@@ -1397,7 +1398,7 @@ xfs_dir2_node_addname_int(
*/
ifbno = fblk->blkno;
free = fbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
findex = fblk->index;
/*
* This means the free entry showed that the data block had
@@ -1405,10 +1406,10 @@ xfs_dir2_node_addname_int(
* Use that data block.
*/
if (findex >= 0) {
- ASSERT(findex < INT_GET(free->hdr.nvalid, ARCH_CONVERT));
- ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF);
- ASSERT(INT_GET(free->bests[findex], ARCH_CONVERT) >= length);
- dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex;
+ ASSERT(findex < be32_to_cpu(free->hdr.nvalid));
+ ASSERT(be16_to_cpu(free->bests[findex]) != NULLDATAOFF);
+ ASSERT(be16_to_cpu(free->bests[findex]) >= length);
+ dbno = be32_to_cpu(free->hdr.firstdb) + findex;
}
/*
* The data block looked at didn't have enough room.
@@ -1481,20 +1482,20 @@ xfs_dir2_node_addname_int(
continue;
}
free = fbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
findex = 0;
}
/*
* Look at the current free entry. Is it good enough?
*/
- if (INT_GET(free->bests[findex], ARCH_CONVERT) != NULLDATAOFF &&
- INT_GET(free->bests[findex], ARCH_CONVERT) >= length)
- dbno = INT_GET(free->hdr.firstdb, ARCH_CONVERT) + findex;
+ if (be16_to_cpu(free->bests[findex]) != NULLDATAOFF &&
+ be16_to_cpu(free->bests[findex]) >= length)
+ dbno = be32_to_cpu(free->hdr.firstdb) + findex;
else {
/*
* Are we done with the freeblock?
*/
- if (++findex == INT_GET(free->hdr.nvalid, ARCH_CONVERT)) {
+ if (++findex == be32_to_cpu(free->hdr.nvalid)) {
/*
* Drop the block.
*/
@@ -1608,15 +1609,15 @@ xfs_dir2_node_addname_int(
* its first slot as our empty slot.
*/
free = fbp->data;
- INT_SET(free->hdr.magic, ARCH_CONVERT, XFS_DIR2_FREE_MAGIC);
- INT_SET(free->hdr.firstdb, ARCH_CONVERT,
+ free->hdr.magic = cpu_to_be32(XFS_DIR2_FREE_MAGIC);
+ free->hdr.firstdb = cpu_to_be32(
(fbno - XFS_DIR2_FREE_FIRSTDB(mp)) *
XFS_DIR2_MAX_FREE_BESTS(mp));
free->hdr.nvalid = 0;
free->hdr.nused = 0;
} else {
free = fbp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
}
/*
@@ -1627,20 +1628,20 @@ xfs_dir2_node_addname_int(
* If it's after the end of the current entries in the
* freespace block, extend that table.
*/
- if (findex >= INT_GET(free->hdr.nvalid, ARCH_CONVERT)) {
+ if (findex >= be32_to_cpu(free->hdr.nvalid)) {
ASSERT(findex < XFS_DIR2_MAX_FREE_BESTS(mp));
- INT_SET(free->hdr.nvalid, ARCH_CONVERT, findex + 1);
+ free->hdr.nvalid = cpu_to_be32(findex + 1);
/*
* Tag new entry so nused will go up.
*/
- INT_SET(free->bests[findex], ARCH_CONVERT, NULLDATAOFF);
+ free->bests[findex] = cpu_to_be16(NULLDATAOFF);
}
/*
* If this entry was for an empty data block
* (this should always be true) then update the header.
*/
- if (INT_GET(free->bests[findex], ARCH_CONVERT) == NULLDATAOFF) {
- INT_MOD(free->hdr.nused, ARCH_CONVERT, +1);
+ if (be16_to_cpu(free->bests[findex]) == NULLDATAOFF) {
+ be32_add(&free->hdr.nused, 1);
xfs_dir2_free_log_header(tp, fbp);
}
/*
@@ -1649,7 +1650,7 @@ xfs_dir2_node_addname_int(
* change again.
*/
data = dbp->data;
- INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT);
+ free->bests[findex] = data->hdr.bestfree[0].length;
logfree = 1;
}
/*
@@ -1677,12 +1678,12 @@ xfs_dir2_node_addname_int(
data = dbp->data;
logfree = 0;
}
- ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length);
+ ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length);
/*
* Point to the existing unused space.
*/
dup = (xfs_dir2_data_unused_t *)
- ((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT));
+ ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
needscan = needlog = 0;
/*
* Mark the first part of the unused space, inuse for us.
@@ -1698,7 +1699,7 @@ xfs_dir2_node_addname_int(
dep->namelen = args->namelen;
memcpy(dep->name, args->name, dep->namelen);
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
- INT_SET(*tagp, ARCH_CONVERT, (xfs_dir2_data_off_t)((char *)dep - (char *)data));
+ *tagp = cpu_to_be16((char *)dep - (char *)data);
xfs_dir2_data_log_entry(tp, dbp, dep);
/*
* Rescan the block for bestfree if needed.
@@ -1713,8 +1714,8 @@ xfs_dir2_node_addname_int(
/*
* If the freespace entry is now wrong, update it.
*/
- if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) {
- INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT);
+ if (be16_to_cpu(free->bests[findex]) != be16_to_cpu(data->hdr.bestfree[0].length)) {
+ free->bests[findex] = data->hdr.bestfree[0].length;
logfree = 1;
}
/*
@@ -1731,7 +1732,7 @@ xfs_dir2_node_addname_int(
* Return the data block and offset in args, then drop the data block.
*/
args->blkno = (xfs_dablk_t)dbno;
- args->index = INT_GET(*tagp, ARCH_CONVERT);
+ args->index = be16_to_cpu(*tagp);
xfs_da_buf_done(dbp);
return 0;
}
@@ -1900,10 +1901,10 @@ xfs_dir2_node_replace(
* Point to the data entry.
*/
data = state->extrablk.bp->data;
- ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC);
+ ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
dep = (xfs_dir2_data_entry_t *)
((char *)data +
- XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT)));
+ XFS_DIR2_DATAPTR_TO_OFF(state->mp, be32_to_cpu(lep->address)));
ASSERT(inum != INT_GET(dep->inumber, ARCH_CONVERT));
/*
* Fill in the new inode number and log the entry.
@@ -1966,11 +1967,11 @@ xfs_dir2_node_trim_free(
return 0;
}
free = bp->data;
- ASSERT(INT_GET(free->hdr.magic, ARCH_CONVERT) == XFS_DIR2_FREE_MAGIC);
+ ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC);
/*
* If there are used entries, there's nothing to do.
*/
- if (INT_GET(free->hdr.nused, ARCH_CONVERT) > 0) {
+ if (be32_to_cpu(free->hdr.nused) > 0) {
xfs_da_brelse(tp, bp);
*rvalp = 0;
return 0;
diff --git a/fs/xfs/xfs_dir2_node.h b/fs/xfs/xfs_dir2_node.h
index 0ab8fbd5951..c7c870ee785 100644
--- a/fs/xfs/xfs_dir2_node.h
+++ b/fs/xfs/xfs_dir2_node.h
@@ -41,15 +41,15 @@ struct xfs_trans;
#define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F */
typedef struct xfs_dir2_free_hdr {
- __uint32_t magic; /* XFS_DIR2_FREE_MAGIC */
- __int32_t firstdb; /* db of first entry */
- __int32_t nvalid; /* count of valid entries */
- __int32_t nused; /* count of used entries */
+ __be32 magic; /* XFS_DIR2_FREE_MAGIC */
+ __be32 firstdb; /* db of first entry */
+ __be32 nvalid; /* count of valid entries */
+ __be32 nused; /* count of used entries */
} xfs_dir2_free_hdr_t;
typedef struct xfs_dir2_free {
xfs_dir2_free_hdr_t hdr; /* block header */
- xfs_dir2_data_off_t bests[1]; /* best free counts */
+ __be16 bests[1]; /* best free counts */
/* unused entries are -1 */
} xfs_dir2_free_t;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index ec8e7476c8b..d98a41d1fe6 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -98,8 +98,8 @@ xfs_dir2_block_sfsize(
/*
* Iterate over the block's data entries by using the leaf pointers.
*/
- for (i = 0; i < INT_GET(btp->count, ARCH_CONVERT); i++) {
- if ((addr = INT_GET(blp[i].address, ARCH_CONVERT)) == XFS_DIR2_NULL_DATAPTR)
+ for (i = 0; i < be32_to_cpu(btp->count); i++) {
+ if ((addr = be32_to_cpu(blp[i].address)) == XFS_DIR2_NULL_DATAPTR)
continue;
/*
* Calculate the pointer to the entry at hand.
@@ -220,8 +220,8 @@ xfs_dir2_block_to_sf(
* If it's unused, just skip over it.
*/
dup = (xfs_dir2_data_unused_t *)ptr;
- if (INT_GET(dup->freetag, ARCH_CONVERT) == XFS_DIR2_DATA_FREE_TAG) {
- ptr += INT_GET(dup->length, ARCH_CONVERT);
+ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+ ptr += be16_to_cpu(dup->length);
continue;
}
dep = (xfs_dir2_data_entry_t *)ptr;
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c
index e83074016ab..ee88751c3be 100644
--- a/fs/xfs/xfs_dir_leaf.c
+++ b/fs/xfs/xfs_dir_leaf.c
@@ -176,7 +176,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
ASSERT(dp->i_df.if_u1.if_data != NULL);
sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
sfe = &sf->list[0];
- for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) {
+ for (i = sf->hdr.count-1; i >= 0; i--) {
if (sfe->namelen == args->namelen &&
args->name[0] == sfe->name[0] &&
memcmp(args->name, sfe->name, args->namelen) == 0)
@@ -193,7 +193,7 @@ xfs_dir_shortform_addname(xfs_da_args_t *args)
XFS_DIR_SF_PUT_DIRINO(&args->inumber, &sfe->inumber);
sfe->namelen = args->namelen;
memcpy(sfe->name, args->name, sfe->namelen);
- INT_MOD(sf->hdr.count, ARCH_CONVERT, +1);
+ sf->hdr.count++;
dp->i_d.di_size += size;
xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA);
@@ -227,7 +227,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
base = sizeof(xfs_dir_sf_hdr_t);
sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
sfe = &sf->list[0];
- for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) {
+ for (i = sf->hdr.count-1; i >= 0; i--) {
size = XFS_DIR_SF_ENTSIZE_BYENTRY(sfe);
if (sfe->namelen == args->namelen &&
sfe->name[0] == args->name[0] &&
@@ -245,7 +245,7 @@ xfs_dir_shortform_removename(xfs_da_args_t *args)
memmove(&((char *)sf)[base], &((char *)sf)[base+size],
dp->i_d.di_size - (base+size));
}
- INT_MOD(sf->hdr.count, ARCH_CONVERT, -1);
+ sf->hdr.count--;
xfs_idata_realloc(dp, -size, XFS_DATA_FORK);
dp->i_d.di_size -= size;
@@ -288,7 +288,7 @@ xfs_dir_shortform_lookup(xfs_da_args_t *args)
return(XFS_ERROR(EEXIST));
}
sfe = &sf->list[0];
- for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) {
+ for (i = sf->hdr.count-1; i >= 0; i--) {
if (sfe->namelen == args->namelen &&
sfe->name[0] == args->name[0] &&
memcmp(args->name, sfe->name, args->namelen) == 0) {
@@ -375,7 +375,7 @@ xfs_dir_shortform_to_leaf(xfs_da_args_t *iargs)
goto out;
sfe = &sf->list[0];
- for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+ for (i = 0; i < sf->hdr.count; i++) {
args.name = (char *)(sfe->name);
args.namelen = sfe->namelen;
args.hashval = xfs_da_hashname((char *)(sfe->name),
@@ -428,7 +428,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,
sf = (xfs_dir_shortform_t *)dp->i_df.if_u1.if_data;
cookhash = XFS_DA_COOKIE_HASH(mp, uio->uio_offset);
want_entno = XFS_DA_COOKIE_ENTRY(mp, uio->uio_offset);
- nsbuf = INT_GET(sf->hdr.count, ARCH_CONVERT) + 2;
+ nsbuf = sf->hdr.count + 2;
sbsize = (nsbuf + 1) * sizeof(*sbuf);
sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);
@@ -460,8 +460,7 @@ xfs_dir_shortform_getdents(xfs_inode_t *dp, uio_t *uio, int *eofp,
/*
* Scan the directory data for the rest of the entries.
*/
- for (i = 0, sfe = &sf->list[0];
- i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
+ for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
if (unlikely(
((char *)sfe < (char *)sf) ||
@@ -600,7 +599,7 @@ xfs_dir_shortform_replace(xfs_da_args_t *args)
}
ASSERT(args->namelen != 1 || args->name[0] != '.');
sfe = &sf->list[0];
- for (i = INT_GET(sf->hdr.count, ARCH_CONVERT)-1; i >= 0; i--) {
+ for (i = sf->hdr.count-1; i >= 0; i--) {
if (sfe->namelen == args->namelen &&
sfe->name[0] == args->name[0] &&
memcmp(args->name, sfe->name, args->namelen) == 0) {
@@ -644,7 +643,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
ASSERT(bp != NULL);
memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
leaf = (xfs_dir_leafblock_t *)tmpbuffer;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
/*
@@ -742,11 +741,13 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
}
node = bp1->data;
leaf = bp2->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
- INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT));
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
+ node->btree[0].hashval = cpu_to_be32(
+ INT_GET(leaf->entries[
+ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
xfs_da_buf_done(bp2);
- INT_SET(node->btree[0].before, ARCH_CONVERT, blkno);
- INT_SET(node->hdr.count, ARCH_CONVERT, 1);
+ node->btree[0].before = cpu_to_be32(blkno);
+ node->hdr.count = cpu_to_be16(1);
xfs_da_log_buf(args->trans, bp1,
XFS_DA_LOGRANGE(node, &node->btree[0], sizeof(node->btree[0])));
xfs_da_buf_done(bp1);
@@ -781,7 +782,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
leaf = bp->data;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
hdr = &leaf->hdr;
- INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC);
+ hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC);
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
if (!hdr->firstused)
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1);
@@ -860,7 +861,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
int tablesize, entsize, sum, i, tmp, error;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr;
entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen);
@@ -940,7 +941,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
int tmp, i;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr = &leaf->hdr;
ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE));
ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT)));
@@ -1097,8 +1098,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC);
leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data;
- ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
/*
* Check ordering of blocks, reverse if it makes things simpler.
@@ -1325,7 +1326,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
*/
blk = &state->path.blk[ state->path.active-1 ];
info = blk->bp->data;
- ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC);
leaf = (xfs_dir_leafblock_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) +
@@ -1348,7 +1349,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one).
*/
- forward = info->forw;
+ forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval);
@@ -1369,12 +1370,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
* We prefer coalescing with the lower numbered sibling so as
* to shrink a directory over time.
*/
- forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */
+ forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); /* start with smaller blk num */
for (i = 0; i < 2; forward = !forward, i++) {
if (forward)
- blkno = INT_GET(info->forw, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->forw);
else
- blkno = INT_GET(info->back, ARCH_CONVERT);
+ blkno = be32_to_cpu(info->back);
if (blkno == 0)
continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp,
@@ -1389,7 +1390,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
bytes = state->blocksize - (state->blocksize>>2);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1);
@@ -1447,7 +1448,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
xfs_mount_t *mp;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr = &leaf->hdr;
mp = trans->t_mountp;
ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
@@ -1599,8 +1600,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
- ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
- ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr;
@@ -1695,7 +1696,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
xfs_dahash_t hashval;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8));
/*
@@ -1782,8 +1783,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s,
/*
* Set up environment.
*/
- ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
- ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr;
ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
@@ -1883,8 +1884,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data;
- ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) &&
- (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC));
+ ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) &&
+ (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC));
if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) &&
((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) ||
@@ -1904,7 +1905,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count)
xfs_dir_leafblock_t *leaf;
leaf = bp->data;
- ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
+ ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
if (count)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
if (!leaf->hdr.count)
@@ -1940,7 +1941,7 @@ xfs_dir_leaf_getdents_int(
mp = dp->i_mount;
leaf = bp->data;
- if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) {
+ if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) {
*eobp = 1;
return XFS_ERROR(ENOENT); /* XXX wrong code */
}
@@ -1992,7 +1993,7 @@ xfs_dir_leaf_getdents_int(
if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
xfs_dir_trace_g_du("leaf: hash not found", dp, uio);
- if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT))
+ if (!leaf->hdr.info.forw)
uio->uio_offset =
XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH);
/*
@@ -2047,8 +2048,7 @@ xfs_dir_leaf_getdents_int(
xfs_dir_trace_g_duc("leaf: middle cookie ",
dp, uio, p.cook.o);
- } else if ((thishash = INT_GET(leaf->hdr.info.forw,
- ARCH_CONVERT))) {
+ } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) {
xfs_dabuf_t *bp2;
xfs_dir_leafblock_t *leaf2;
@@ -2064,9 +2064,9 @@ xfs_dir_leaf_getdents_int(
leaf2 = bp2->data;
if (unlikely(
- (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
+ (be16_to_cpu(leaf2->hdr.info.magic)
!= XFS_DIR_LEAF_MAGIC)
- || (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT)
+ || (be32_to_cpu(leaf2->hdr.info.back)
!= bno))) { /* GROT */
XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)",
XFS_ERRLEVEL_LOW, mp,
diff --git a/fs/xfs/xfs_dir_sf.h b/fs/xfs/xfs_dir_sf.h
index fe44c6f4d56..5b20b4d3f57 100644
--- a/fs/xfs/xfs_dir_sf.h
+++ b/fs/xfs/xfs_dir_sf.h
@@ -35,19 +35,21 @@ typedef struct { __uint8_t i[sizeof(xfs_ino_t)]; } xfs_dir_ino_t;
* and the elements much be memcpy'd out into a work area to get correct
* alignment for the inode number fields.
*/
+typedef struct xfs_dir_sf_hdr { /* constant-structure header block */
+ xfs_dir_ino_t parent; /* parent dir inode number */
+ __uint8_t count; /* count of active entries */
+} xfs_dir_sf_hdr_t;
+
+typedef struct xfs_dir_sf_entry {
+ xfs_dir_ino_t inumber; /* referenced inode number */
+ __uint8_t namelen; /* actual length of name (no NULL) */
+ __uint8_t name[1]; /* name */
+} xfs_dir_sf_entry_t;
+
typedef struct xfs_dir_shortform {
- struct xfs_dir_sf_hdr { /* constant-structure header block */
- xfs_dir_ino_t parent; /* parent dir inode number */
- __uint8_t count; /* count of active entries */
- } hdr;
- struct xfs_dir_sf_entry {
- xfs_dir_ino_t inumber; /* referenced inode number */
- __uint8_t namelen; /* actual length of name (no NULL) */
- __uint8_t name[1]; /* name */
- } list[1]; /* variable sized array */
+ xfs_dir_sf_hdr_t hdr;
+ xfs_dir_sf_entry_t list[1]; /* variable sized array */
} xfs_dir_shortform_t;
-typedef struct xfs_dir_sf_hdr xfs_dir_sf_hdr_t;
-typedef struct xfs_dir_sf_entry xfs_dir_sf_entry_t;
/*
* We generate this then sort it, so that readdirs are returned in
diff --git a/fs/xfs/xfs_dmapi.h b/fs/xfs/xfs_dmapi.h
index b4c7f2bc55a..00b1540f810 100644
--- a/fs/xfs/xfs_dmapi.h
+++ b/fs/xfs/xfs_dmapi.h
@@ -191,14 +191,4 @@ typedef enum {
extern struct bhv_vfsops xfs_dmops;
-#ifdef CONFIG_XFS_DMAPI
-void xfs_dm_init(struct file_system_type *);
-void xfs_dm_exit(struct file_system_type *);
-#define XFS_DM_INIT(fstype) xfs_dm_init(fstype)
-#define XFS_DM_EXIT(fstype) xfs_dm_exit(fstype)
-#else
-#define XFS_DM_INIT(fstype)
-#define XFS_DM_EXIT(fstype)
-#endif
-
#endif /* __XFS_DMAPI_H__ */
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index b4d971b0158..56caa88713a 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -462,6 +462,7 @@ xfs_fs_counts(
{
unsigned long s;
+ xfs_icsb_sync_counters_lazy(mp);
s = XFS_SB_LOCK(mp);
cnt->freedata = mp->m_sb.sb_fdblocks;
cnt->freertx = mp->m_sb.sb_frextents;
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index 8f3fae1aa98..0024892841a 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -138,8 +138,6 @@ xfs_ialloc_ag_alloc(
int version; /* inode version number to use */
int isaligned; /* inode allocation at stripe unit */
/* boundary */
- xfs_dinode_core_t dic; /* a dinode_core to copy to new */
- /* inodes */
args.tp = tp;
args.mp = tp->t_mountp;
@@ -250,10 +248,6 @@ xfs_ialloc_ag_alloc(
else
version = XFS_DINODE_VERSION_1;
- memset(&dic, 0, sizeof(xfs_dinode_core_t));
- INT_SET(dic.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC);
- INT_SET(dic.di_version, ARCH_CONVERT, version);
-
for (j = 0; j < nbufs; j++) {
/*
* Get the block.
@@ -266,12 +260,13 @@ xfs_ialloc_ag_alloc(
ASSERT(fbuf);
ASSERT(!XFS_BUF_GETERROR(fbuf));
/*
- * Loop over the inodes in this buffer.
+ * Set initial values for the inodes in this buffer.
*/
-
+ xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog);
for (i = 0; i < ninodes; i++) {
free = XFS_MAKE_IPTR(args.mp, fbuf, i);
- memcpy(&(free->di_core), &dic, sizeof(xfs_dinode_core_t));
+ INT_SET(free->di_core.di_magic, ARCH_CONVERT, XFS_DINODE_MAGIC);
+ INT_SET(free->di_core.di_version, ARCH_CONVERT, version);
INT_SET(free->di_next_unlinked, ARCH_CONVERT, NULLAGINO);
xfs_ialloc_log_di(tp, fbuf, i,
XFS_DI_CORE_BITS | XFS_DI_NEXT_UNLINKED);
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 8e380a1fb79..3ce35a6f700 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -258,7 +258,7 @@ again:
goto finish_inode;
} else if (vp != inode_vp) {
- struct inode *inode = LINVFS_GET_IP(inode_vp);
+ struct inode *inode = vn_to_inode(inode_vp);
/* The inode is being torn down, pause and
* try again.
@@ -495,7 +495,7 @@ retry:
if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) {
xfs_inode_t *ip;
- vp = LINVFS_GET_VP(inode);
+ vp = vn_from_inode(inode);
if (inode->i_state & I_NEW) {
vn_initialize(inode);
error = xfs_iget_core(vp, mp, tp, ino, flags,
@@ -617,7 +617,7 @@ xfs_iput_new(xfs_inode_t *ip,
uint lock_flags)
{
vnode_t *vp = XFS_ITOV(ip);
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
vn_trace_entry(vp, "xfs_iput_new", (inst_t *)__return_address);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 1d7f5a7e063..88a517fad07 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -76,16 +76,18 @@ STATIC int xfs_iformat_btree(xfs_inode_t *, xfs_dinode_t *, int);
*/
STATIC void
xfs_validate_extents(
- xfs_bmbt_rec_t *ep,
+ xfs_ifork_t *ifp,
int nrecs,
int disk,
xfs_exntfmt_t fmt)
{
+ xfs_bmbt_rec_t *ep;
xfs_bmbt_irec_t irec;
xfs_bmbt_rec_t rec;
int i;
for (i = 0; i < nrecs; i++) {
+ ep = xfs_iext_get_ext(ifp, i);
rec.l0 = get_unaligned((__uint64_t*)&ep->l0);
rec.l1 = get_unaligned((__uint64_t*)&ep->l1);
if (disk)
@@ -94,11 +96,10 @@ xfs_validate_extents(
xfs_bmbt_get_all(&rec, &irec);
if (fmt == XFS_EXTFMT_NOSTATE)
ASSERT(irec.br_state == XFS_EXT_NORM);
- ep++;
}
}
#else /* DEBUG */
-#define xfs_validate_extents(ep, nrecs, disk, fmt)
+#define xfs_validate_extents(ifp, nrecs, disk, fmt)
#endif /* DEBUG */
/*
@@ -252,7 +253,8 @@ xfs_itobp(
xfs_inode_t *ip,
xfs_dinode_t **dipp,
xfs_buf_t **bpp,
- xfs_daddr_t bno)
+ xfs_daddr_t bno,
+ uint imap_flags)
{
xfs_buf_t *bp;
int error;
@@ -268,10 +270,9 @@ xfs_itobp(
* inode on disk.
*/
imap.im_blkno = bno;
- error = xfs_imap(mp, tp, ip->i_ino, &imap, XFS_IMAP_LOOKUP);
- if (error != 0) {
+ if ((error = xfs_imap(mp, tp, ip->i_ino, &imap,
+ XFS_IMAP_LOOKUP | imap_flags)))
return error;
- }
/*
* If the inode number maps to a block outside the bounds
@@ -335,9 +336,10 @@ xfs_itobp(
* (if DEBUG kernel) or the first inode in the buffer, otherwise.
*/
#ifdef DEBUG
- ni = BBTOB(imap.im_len) >> mp->m_sb.sb_inodelog;
+ ni = (imap_flags & XFS_IMAP_BULKSTAT) ? 0 :
+ (BBTOB(imap.im_len) >> mp->m_sb.sb_inodelog);
#else
- ni = 1;
+ ni = (imap_flags & XFS_IMAP_BULKSTAT) ? 0 : 1;
#endif
for (i = 0; i < ni; i++) {
int di_ok;
@@ -504,7 +506,7 @@ xfs_iformat(
switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) {
case XFS_DINODE_FMT_LOCAL:
atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
- size = (int)INT_GET(atp->hdr.totsize, ARCH_CONVERT);
+ size = be16_to_cpu(atp->hdr.totsize);
error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
break;
case XFS_DINODE_FMT_EXTENTS:
@@ -597,7 +599,6 @@ xfs_iformat_extents(
xfs_bmbt_rec_t *ep, *dp;
xfs_ifork_t *ifp;
int nex;
- int real_size;
int size;
int i;
@@ -619,23 +620,20 @@ xfs_iformat_extents(
return XFS_ERROR(EFSCORRUPTED);
}
- real_size = 0;
+ ifp->if_real_bytes = 0;
if (nex == 0)
ifp->if_u1.if_extents = NULL;
else if (nex <= XFS_INLINE_EXTS)
ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
- else {
- ifp->if_u1.if_extents = kmem_alloc(size, KM_SLEEP);
- ASSERT(ifp->if_u1.if_extents != NULL);
- real_size = size;
- }
+ else
+ xfs_iext_add(ifp, 0, nex);
+
ifp->if_bytes = size;
- ifp->if_real_bytes = real_size;
if (size) {
dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork);
- xfs_validate_extents(dp, nex, 1, XFS_EXTFMT_INODE(ip));
- ep = ifp->if_u1.if_extents;
- for (i = 0; i < nex; i++, ep++, dp++) {
+ xfs_validate_extents(ifp, nex, 1, XFS_EXTFMT_INODE(ip));
+ for (i = 0; i < nex; i++, dp++) {
+ ep = xfs_iext_get_ext(ifp, i);
ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0),
ARCH_CONVERT);
ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1),
@@ -646,7 +644,7 @@ xfs_iformat_extents(
if (whichfork != XFS_DATA_FORK ||
XFS_EXTFMT_INODE(ip) == XFS_EXTFMT_NOSTATE)
if (unlikely(xfs_check_nostate_extents(
- ifp->if_u1.if_extents, nex))) {
+ ifp, 0, nex))) {
XFS_ERROR_REPORT("xfs_iformat_extents(2)",
XFS_ERRLEVEL_LOW,
ip->i_mount);
@@ -871,9 +869,8 @@ xfs_iread(
* return NULL as well. Set i_blkno to 0 so that xfs_itobp() will
* know that this is a new incore inode.
*/
- error = xfs_itobp(mp, tp, ip, &dip, &bp, bno);
-
- if (error != 0) {
+ error = xfs_itobp(mp, tp, ip, &dip, &bp, bno, 0);
+ if (error) {
kmem_zone_free(xfs_inode_zone, ip);
return error;
}
@@ -1015,6 +1012,7 @@ xfs_iread_extents(
{
int error;
xfs_ifork_t *ifp;
+ xfs_extnum_t nextents;
size_t size;
if (unlikely(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE)) {
@@ -1022,26 +1020,24 @@ xfs_iread_extents(
ip->i_mount);
return XFS_ERROR(EFSCORRUPTED);
}
- size = XFS_IFORK_NEXTENTS(ip, whichfork) * (uint)sizeof(xfs_bmbt_rec_t);
+ nextents = XFS_IFORK_NEXTENTS(ip, whichfork);
+ size = nextents * sizeof(xfs_bmbt_rec_t);
ifp = XFS_IFORK_PTR(ip, whichfork);
+
/*
* We know that the size is valid (it's checked in iformat_btree)
*/
- ifp->if_u1.if_extents = kmem_alloc(size, KM_SLEEP);
- ASSERT(ifp->if_u1.if_extents != NULL);
ifp->if_lastex = NULLEXTNUM;
- ifp->if_bytes = ifp->if_real_bytes = (int)size;
+ ifp->if_bytes = ifp->if_real_bytes = 0;
ifp->if_flags |= XFS_IFEXTENTS;
+ xfs_iext_add(ifp, 0, nextents);
error = xfs_bmap_read_extents(tp, ip, whichfork);
if (error) {
- kmem_free(ifp->if_u1.if_extents, size);
- ifp->if_u1.if_extents = NULL;
- ifp->if_bytes = ifp->if_real_bytes = 0;
+ xfs_iext_destroy(ifp);
ifp->if_flags &= ~XFS_IFEXTENTS;
return error;
}
- xfs_validate_extents((xfs_bmbt_rec_t *)ifp->if_u1.if_extents,
- XFS_IFORK_NEXTENTS(ip, whichfork), 0, XFS_EXTFMT_INODE(ip));
+ xfs_validate_extents(ifp, nextents, 0, XFS_EXTFMT_INODE(ip));
return 0;
}
@@ -1376,10 +1372,10 @@ xfs_itrunc_trace(
(void*)(unsigned long)((toss_finish >> 32) & 0xffffffff),
(void*)(unsigned long)(toss_finish & 0xffffffff),
(void*)(unsigned long)current_cpu(),
- (void*)0,
- (void*)0,
- (void*)0,
- (void*)0);
+ (void*)(unsigned long)current_pid(),
+ (void*)NULL,
+ (void*)NULL,
+ (void*)NULL);
}
#else
#define xfs_itrunc_trace(tag, ip, flag, new_size, toss_start, toss_finish)
@@ -1397,6 +1393,16 @@ xfs_itrunc_trace(
* calling into the buffer/page cache code and we can't hold the
* inode lock when we do so.
*
+ * We need to wait for any direct I/Os in flight to complete before we
+ * proceed with the truncate. This is needed to prevent the extents
+ * being read or written by the direct I/Os from being removed while the
+ * I/O is in flight as there is no other method of synchronising
+ * direct I/O with the truncate operation. Also, because we hold
+ * the IOLOCK in exclusive mode, we prevent new direct I/Os from being
+ * started until the truncate completes and drops the lock. Essentially,
+ * the vn_iowait() call forms an I/O barrier that provides strict ordering
+ * between direct I/Os and the truncate operation.
+ *
* The flags parameter can have either the value XFS_ITRUNC_DEFINITE
* or XFS_ITRUNC_MAYBE. The XFS_ITRUNC_MAYBE value should be used
* in the case that the caller is locking things out of order and
@@ -1424,6 +1430,9 @@ xfs_itruncate_start(
mp = ip->i_mount;
vp = XFS_ITOV(ip);
+
+ vn_iowait(vp); /* wait for the completion of any pending DIOs */
+
/*
* Call VOP_TOSS_PAGES() or VOP_FLUSHINVAL_PAGES() to get rid of pages and buffers
* overlapping the region being removed. We have to use
@@ -1899,7 +1908,7 @@ xfs_iunlink(
* Here we put the head pointer into our next pointer,
* and then we fall through to point the head at us.
*/
- error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
+ error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
if (error) {
return error;
}
@@ -2008,7 +2017,7 @@ xfs_iunlink_remove(
* of dealing with the buffer when there is no need to
* change it.
*/
- error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
+ error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
if (error) {
cmn_err(CE_WARN,
"xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.",
@@ -2070,7 +2079,7 @@ xfs_iunlink_remove(
* Now last_ibp points to the buffer previous to us on
* the unlinked list. Pull us from the list.
*/
- error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0);
+ error = xfs_itobp(mp, tp, ip, &dip, &ibp, 0, 0);
if (error) {
cmn_err(CE_WARN,
"xfs_iunlink_remove: xfs_itobp() returned an error %d on %s. Returning error.",
@@ -2476,92 +2485,6 @@ xfs_iroot_realloc(
/*
- * This is called when the amount of space needed for if_extents
- * is increased or decreased. The change in size is indicated by
- * the number of extents that need to be added or deleted in the
- * ext_diff parameter.
- *
- * If the amount of space needed has decreased below the size of the
- * inline buffer, then switch to using the inline buffer. Otherwise,
- * use kmem_realloc() or kmem_alloc() to adjust the size of the buffer
- * to what is needed.
- *
- * ip -- the inode whose if_extents area is changing
- * ext_diff -- the change in the number of extents, positive or negative,
- * requested for the if_extents array.
- */
-void
-xfs_iext_realloc(
- xfs_inode_t *ip,
- int ext_diff,
- int whichfork)
-{
- int byte_diff;
- xfs_ifork_t *ifp;
- int new_size;
- uint rnew_size;
-
- if (ext_diff == 0) {
- return;
- }
-
- ifp = XFS_IFORK_PTR(ip, whichfork);
- byte_diff = ext_diff * (uint)sizeof(xfs_bmbt_rec_t);
- new_size = (int)ifp->if_bytes + byte_diff;
- ASSERT(new_size >= 0);
-
- if (new_size == 0) {
- if (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext) {
- ASSERT(ifp->if_real_bytes != 0);
- kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes);
- }
- ifp->if_u1.if_extents = NULL;
- rnew_size = 0;
- } else if (new_size <= sizeof(ifp->if_u2.if_inline_ext)) {
- /*
- * If the valid extents can fit in if_inline_ext,
- * copy them from the malloc'd vector and free it.
- */
- if (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext) {
- /*
- * For now, empty files are format EXTENTS,
- * so the if_extents pointer is null.
- */
- if (ifp->if_u1.if_extents) {
- memcpy(ifp->if_u2.if_inline_ext,
- ifp->if_u1.if_extents, new_size);
- kmem_free(ifp->if_u1.if_extents,
- ifp->if_real_bytes);
- }
- ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
- }
- rnew_size = 0;
- } else {
- rnew_size = new_size;
- if ((rnew_size & (rnew_size - 1)) != 0)
- rnew_size = xfs_iroundup(rnew_size);
- /*
- * Stuck with malloc/realloc.
- */
- if (ifp->if_u1.if_extents == ifp->if_u2.if_inline_ext) {
- ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
- kmem_alloc(rnew_size, KM_SLEEP);
- memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext,
- sizeof(ifp->if_u2.if_inline_ext));
- } else if (rnew_size != ifp->if_real_bytes) {
- ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
- kmem_realloc(ifp->if_u1.if_extents,
- rnew_size,
- ifp->if_real_bytes,
- KM_NOFS);
- }
- }
- ifp->if_real_bytes = rnew_size;
- ifp->if_bytes = new_size;
-}
-
-
-/*
* This is called when the amount of space needed for if_data
* is increased or decreased. The change in size is indicated by
* the number of bytes that need to be added or deleted in the
@@ -2720,12 +2643,11 @@ xfs_idestroy_fork(
ifp->if_real_bytes = 0;
}
} else if ((ifp->if_flags & XFS_IFEXTENTS) &&
- (ifp->if_u1.if_extents != NULL) &&
- (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext)) {
+ ((ifp->if_flags & XFS_IFEXTIREC) ||
+ ((ifp->if_u1.if_extents != NULL) &&
+ (ifp->if_u1.if_extents != ifp->if_u2.if_inline_ext)))) {
ASSERT(ifp->if_real_bytes != 0);
- kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes);
- ifp->if_u1.if_extents = NULL;
- ifp->if_real_bytes = 0;
+ xfs_iext_destroy(ifp);
}
ASSERT(ifp->if_u1.if_extents == NULL ||
ifp->if_u1.if_extents == ifp->if_u2.if_inline_ext);
@@ -2814,7 +2736,7 @@ xfs_iunpin(
/* make sync come back and flush this inode */
if (vp) {
- struct inode *inode = LINVFS_GET_IP(vp);
+ struct inode *inode = vn_to_inode(vp);
if (!(inode->i_state & I_NEW))
mark_inode_dirty_sync(inode);
@@ -2902,16 +2824,15 @@ xfs_iextents_copy(
* the delayed ones. There must be at least one
* non-delayed extent.
*/
- ep = ifp->if_u1.if_extents;
dest_ep = buffer;
copied = 0;
for (i = 0; i < nrecs; i++) {
+ ep = xfs_iext_get_ext(ifp, i);
start_block = xfs_bmbt_get_startblock(ep);
if (ISNULLSTARTBLOCK(start_block)) {
/*
* It's a delayed allocation extent, so skip it.
*/
- ep++;
continue;
}
@@ -2921,11 +2842,10 @@ xfs_iextents_copy(
put_unaligned(INT_GET(ep->l1, ARCH_CONVERT),
(__uint64_t*)&dest_ep->l1);
dest_ep++;
- ep++;
copied++;
}
ASSERT(copied != 0);
- xfs_validate_extents(buffer, copied, 1, XFS_EXTFMT_INODE(ip));
+ xfs_validate_extents(ifp, copied, 1, XFS_EXTFMT_INODE(ip));
return (copied * (uint)sizeof(xfs_bmbt_rec_t));
}
@@ -2995,8 +2915,10 @@ xfs_iflush_fork(
case XFS_DINODE_FMT_EXTENTS:
ASSERT((ifp->if_flags & XFS_IFEXTENTS) ||
!(iip->ili_format.ilf_fields & extflag[whichfork]));
- ASSERT((ifp->if_u1.if_extents != NULL) || (ifp->if_bytes == 0));
- ASSERT((ifp->if_u1.if_extents == NULL) || (ifp->if_bytes > 0));
+ ASSERT((xfs_iext_get_ext(ifp, 0) != NULL) ||
+ (ifp->if_bytes == 0));
+ ASSERT((xfs_iext_get_ext(ifp, 0) == NULL) ||
+ (ifp->if_bytes > 0));
if ((iip->ili_format.ilf_fields & extflag[whichfork]) &&
(ifp->if_bytes > 0)) {
ASSERT(XFS_IFORK_NEXTENTS(ip, whichfork) > 0);
@@ -3114,8 +3036,8 @@ xfs_iflush(
/*
* Get the buffer containing the on-disk inode.
*/
- error = xfs_itobp(mp, NULL, ip, &dip, &bp, 0);
- if (error != 0) {
+ error = xfs_itobp(mp, NULL, ip, &dip, &bp, 0, 0);
+ if (error) {
xfs_ifunlock(ip);
return error;
}
@@ -3610,7 +3532,7 @@ xfs_iaccess(
{
int error;
mode_t orgmode = mode;
- struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
+ struct inode *inode = vn_to_inode(XFS_ITOV(ip));
if (mode & S_IWUSR) {
umode_t imode = inode->i_mode;
@@ -3704,3 +3626,1100 @@ xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
}
#endif
+
+/*
+ * Return a pointer to the extent record at file index idx.
+ */
+xfs_bmbt_rec_t *
+xfs_iext_get_ext(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx) /* index of target extent */
+{
+ ASSERT(idx >= 0);
+ if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
+ return ifp->if_u1.if_ext_irec->er_extbuf;
+ } else if (ifp->if_flags & XFS_IFEXTIREC) {
+ xfs_ext_irec_t *erp; /* irec pointer */
+ int erp_idx = 0; /* irec index */
+ xfs_extnum_t page_idx = idx; /* ext index in target list */
+
+ erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0);
+ return &erp->er_extbuf[page_idx];
+ } else if (ifp->if_bytes) {
+ return &ifp->if_u1.if_extents[idx];
+ } else {
+ return NULL;
+ }
+}
+
+/*
+ * Insert new item(s) into the extent records for incore inode
+ * fork 'ifp'. 'count' new items are inserted at index 'idx'.
+ */
+void
+xfs_iext_insert(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* starting index of new items */
+ xfs_extnum_t count, /* number of inserted items */
+ xfs_bmbt_irec_t *new) /* items to insert */
+{
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
+ xfs_extnum_t i; /* extent record index */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTENTS);
+ xfs_iext_add(ifp, idx, count);
+ for (i = idx; i < idx + count; i++, new++) {
+ ep = xfs_iext_get_ext(ifp, i);
+ xfs_bmbt_set_all(ep, new);
+ }
+}
+
+/*
+ * This is called when the amount of space required for incore file
+ * extents needs to be increased. The ext_diff parameter stores the
+ * number of new extents being added and the idx parameter contains
+ * the extent index where the new extents will be added. If the new
+ * extents are being appended, then we just need to (re)allocate and
+ * initialize the space. Otherwise, if the new extents are being
+ * inserted into the middle of the existing entries, a bit more work
+ * is required to make room for the new extents to be inserted. The
+ * caller is responsible for filling in the new extent entries upon
+ * return.
+ */
+void
+xfs_iext_add(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* index to begin adding exts */
+ int ext_diff) /* nubmer of extents to add */
+{
+ int byte_diff; /* new bytes being added */
+ int new_size; /* size of extents after adding */
+ xfs_extnum_t nextents; /* number of extents in file */
+
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ ASSERT((idx >= 0) && (idx <= nextents));
+ byte_diff = ext_diff * sizeof(xfs_bmbt_rec_t);
+ new_size = ifp->if_bytes + byte_diff;
+ /*
+ * If the new number of extents (nextents + ext_diff)
+ * fits inside the inode, then continue to use the inline
+ * extent buffer.
+ */
+ if (nextents + ext_diff <= XFS_INLINE_EXTS) {
+ if (idx < nextents) {
+ memmove(&ifp->if_u2.if_inline_ext[idx + ext_diff],
+ &ifp->if_u2.if_inline_ext[idx],
+ (nextents - idx) * sizeof(xfs_bmbt_rec_t));
+ memset(&ifp->if_u2.if_inline_ext[idx], 0, byte_diff);
+ }
+ ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
+ ifp->if_real_bytes = 0;
+ ifp->if_lastex = nextents + ext_diff;
+ }
+ /*
+ * Otherwise use a linear (direct) extent list.
+ * If the extents are currently inside the inode,
+ * xfs_iext_realloc_direct will switch us from
+ * inline to direct extent allocation mode.
+ */
+ else if (nextents + ext_diff <= XFS_LINEAR_EXTS) {
+ xfs_iext_realloc_direct(ifp, new_size);
+ if (idx < nextents) {
+ memmove(&ifp->if_u1.if_extents[idx + ext_diff],
+ &ifp->if_u1.if_extents[idx],
+ (nextents - idx) * sizeof(xfs_bmbt_rec_t));
+ memset(&ifp->if_u1.if_extents[idx], 0, byte_diff);
+ }
+ }
+ /* Indirection array */
+ else {
+ xfs_ext_irec_t *erp;
+ int erp_idx = 0;
+ int page_idx = idx;
+
+ ASSERT(nextents + ext_diff > XFS_LINEAR_EXTS);
+ if (ifp->if_flags & XFS_IFEXTIREC) {
+ erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 1);
+ } else {
+ xfs_iext_irec_init(ifp);
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ erp = ifp->if_u1.if_ext_irec;
+ }
+ /* Extents fit in target extent page */
+ if (erp && erp->er_extcount + ext_diff <= XFS_LINEAR_EXTS) {
+ if (page_idx < erp->er_extcount) {
+ memmove(&erp->er_extbuf[page_idx + ext_diff],
+ &erp->er_extbuf[page_idx],
+ (erp->er_extcount - page_idx) *
+ sizeof(xfs_bmbt_rec_t));
+ memset(&erp->er_extbuf[page_idx], 0, byte_diff);
+ }
+ erp->er_extcount += ext_diff;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff);
+ }
+ /* Insert a new extent page */
+ else if (erp) {
+ xfs_iext_add_indirect_multi(ifp,
+ erp_idx, page_idx, ext_diff);
+ }
+ /*
+ * If extent(s) are being appended to the last page in
+ * the indirection array and the new extent(s) don't fit
+ * in the page, then erp is NULL and erp_idx is set to
+ * the next index needed in the indirection array.
+ */
+ else {
+ int count = ext_diff;
+
+ while (count) {
+ erp = xfs_iext_irec_new(ifp, erp_idx);
+ erp->er_extcount = count;
+ count -= MIN(count, (int)XFS_LINEAR_EXTS);
+ if (count) {
+ erp_idx++;
+ }
+ }
+ }
+ }
+ ifp->if_bytes = new_size;
+}
+
+/*
+ * This is called when incore extents are being added to the indirection
+ * array and the new extents do not fit in the target extent list. The
+ * erp_idx parameter contains the irec index for the target extent list
+ * in the indirection array, and the idx parameter contains the extent
+ * index within the list. The number of extents being added is stored
+ * in the count parameter.
+ *
+ * |-------| |-------|
+ * | | | | idx - number of extents before idx
+ * | idx | | count |
+ * | | | | count - number of extents being inserted at idx
+ * |-------| |-------|
+ * | count | | nex2 | nex2 - number of extents after idx + count
+ * |-------| |-------|
+ */
+void
+xfs_iext_add_indirect_multi(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int erp_idx, /* target extent irec index */
+ xfs_extnum_t idx, /* index within target list */
+ int count) /* new extents being added */
+{
+ int byte_diff; /* new bytes being added */
+ xfs_ext_irec_t *erp; /* pointer to irec entry */
+ xfs_extnum_t ext_diff; /* number of extents to add */
+ xfs_extnum_t ext_cnt; /* new extents still needed */
+ xfs_extnum_t nex2; /* extents after idx + count */
+ xfs_bmbt_rec_t *nex2_ep = NULL; /* temp list for nex2 extents */
+ int nlists; /* number of irec's (lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ nex2 = erp->er_extcount - idx;
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+
+ /*
+ * Save second part of target extent list
+ * (all extents past */
+ if (nex2) {
+ byte_diff = nex2 * sizeof(xfs_bmbt_rec_t);
+ nex2_ep = (xfs_bmbt_rec_t *) kmem_alloc(byte_diff, KM_SLEEP);
+ memmove(nex2_ep, &erp->er_extbuf[idx], byte_diff);
+ erp->er_extcount -= nex2;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -nex2);
+ memset(&erp->er_extbuf[idx], 0, byte_diff);
+ }
+
+ /*
+ * Add the new extents to the end of the target
+ * list, then allocate new irec record(s) and
+ * extent buffer(s) as needed to store the rest
+ * of the new extents.
+ */
+ ext_cnt = count;
+ ext_diff = MIN(ext_cnt, (int)XFS_LINEAR_EXTS - erp->er_extcount);
+ if (ext_diff) {
+ erp->er_extcount += ext_diff;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff);
+ ext_cnt -= ext_diff;
+ }
+ while (ext_cnt) {
+ erp_idx++;
+ erp = xfs_iext_irec_new(ifp, erp_idx);
+ ext_diff = MIN(ext_cnt, (int)XFS_LINEAR_EXTS);
+ erp->er_extcount = ext_diff;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, ext_diff);
+ ext_cnt -= ext_diff;
+ }
+
+ /* Add nex2 extents back to indirection array */
+ if (nex2) {
+ xfs_extnum_t ext_avail;
+ int i;
+
+ byte_diff = nex2 * sizeof(xfs_bmbt_rec_t);
+ ext_avail = XFS_LINEAR_EXTS - erp->er_extcount;
+ i = 0;
+ /*
+ * If nex2 extents fit in the current page, append
+ * nex2_ep after the new extents.
+ */
+ if (nex2 <= ext_avail) {
+ i = erp->er_extcount;
+ }
+ /*
+ * Otherwise, check if space is available in the
+ * next page.
+ */
+ else if ((erp_idx < nlists - 1) &&
+ (nex2 <= (ext_avail = XFS_LINEAR_EXTS -
+ ifp->if_u1.if_ext_irec[erp_idx+1].er_extcount))) {
+ erp_idx++;
+ erp++;
+ /* Create a hole for nex2 extents */
+ memmove(&erp->er_extbuf[nex2], erp->er_extbuf,
+ erp->er_extcount * sizeof(xfs_bmbt_rec_t));
+ }
+ /*
+ * Final choice, create a new extent page for
+ * nex2 extents.
+ */
+ else {
+ erp_idx++;
+ erp = xfs_iext_irec_new(ifp, erp_idx);
+ }
+ memmove(&erp->er_extbuf[i], nex2_ep, byte_diff);
+ kmem_free(nex2_ep, byte_diff);
+ erp->er_extcount += nex2;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, nex2);
+ }
+}
+
+/*
+ * This is called when the amount of space required for incore file
+ * extents needs to be decreased. The ext_diff parameter stores the
+ * number of extents to be removed and the idx parameter contains
+ * the extent index where the extents will be removed from.
+ *
+ * If the amount of space needed has decreased below the linear
+ * limit, XFS_IEXT_BUFSZ, then switch to using the contiguous
+ * extent array. Otherwise, use kmem_realloc() to adjust the
+ * size to what is needed.
+ */
+void
+xfs_iext_remove(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* index to begin removing exts */
+ int ext_diff) /* number of extents to remove */
+{
+ xfs_extnum_t nextents; /* number of extents in file */
+ int new_size; /* size of extents after removal */
+
+ ASSERT(ext_diff > 0);
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ new_size = (nextents - ext_diff) * sizeof(xfs_bmbt_rec_t);
+
+ if (new_size == 0) {
+ xfs_iext_destroy(ifp);
+ } else if (ifp->if_flags & XFS_IFEXTIREC) {
+ xfs_iext_remove_indirect(ifp, idx, ext_diff);
+ } else if (ifp->if_real_bytes) {
+ xfs_iext_remove_direct(ifp, idx, ext_diff);
+ } else {
+ xfs_iext_remove_inline(ifp, idx, ext_diff);
+ }
+ ifp->if_bytes = new_size;
+}
+
+/*
+ * This removes ext_diff extents from the inline buffer, beginning
+ * at extent index idx.
+ */
+void
+xfs_iext_remove_inline(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* index to begin removing exts */
+ int ext_diff) /* number of extents to remove */
+{
+ int nextents; /* number of extents in file */
+
+ ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
+ ASSERT(idx < XFS_INLINE_EXTS);
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ ASSERT(((nextents - ext_diff) > 0) &&
+ (nextents - ext_diff) < XFS_INLINE_EXTS);
+
+ if (idx + ext_diff < nextents) {
+ memmove(&ifp->if_u2.if_inline_ext[idx],
+ &ifp->if_u2.if_inline_ext[idx + ext_diff],
+ (nextents - (idx + ext_diff)) *
+ sizeof(xfs_bmbt_rec_t));
+ memset(&ifp->if_u2.if_inline_ext[nextents - ext_diff],
+ 0, ext_diff * sizeof(xfs_bmbt_rec_t));
+ } else {
+ memset(&ifp->if_u2.if_inline_ext[idx], 0,
+ ext_diff * sizeof(xfs_bmbt_rec_t));
+ }
+}
+
+/*
+ * This removes ext_diff extents from a linear (direct) extent list,
+ * beginning at extent index idx. If the extents are being removed
+ * from the end of the list (ie. truncate) then we just need to re-
+ * allocate the list to remove the extra space. Otherwise, if the
+ * extents are being removed from the middle of the existing extent
+ * entries, then we first need to move the extent records beginning
+ * at idx + ext_diff up in the list to overwrite the records being
+ * removed, then remove the extra space via kmem_realloc.
+ */
+void
+xfs_iext_remove_direct(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* index to begin removing exts */
+ int ext_diff) /* number of extents to remove */
+{
+ xfs_extnum_t nextents; /* number of extents in file */
+ int new_size; /* size of extents after removal */
+
+ ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
+ new_size = ifp->if_bytes -
+ (ext_diff * sizeof(xfs_bmbt_rec_t));
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+
+ if (new_size == 0) {
+ xfs_iext_destroy(ifp);
+ return;
+ }
+ /* Move extents up in the list (if needed) */
+ if (idx + ext_diff < nextents) {
+ memmove(&ifp->if_u1.if_extents[idx],
+ &ifp->if_u1.if_extents[idx + ext_diff],
+ (nextents - (idx + ext_diff)) *
+ sizeof(xfs_bmbt_rec_t));
+ }
+ memset(&ifp->if_u1.if_extents[nextents - ext_diff],
+ 0, ext_diff * sizeof(xfs_bmbt_rec_t));
+ /*
+ * Reallocate the direct extent list. If the extents
+ * will fit inside the inode then xfs_iext_realloc_direct
+ * will switch from direct to inline extent allocation
+ * mode for us.
+ */
+ xfs_iext_realloc_direct(ifp, new_size);
+ ifp->if_bytes = new_size;
+}
+
+/*
+ * This is called when incore extents are being removed from the
+ * indirection array and the extents being removed span multiple extent
+ * buffers. The idx parameter contains the file extent index where we
+ * want to begin removing extents, and the count parameter contains
+ * how many extents need to be removed.
+ *
+ * |-------| |-------|
+ * | nex1 | | | nex1 - number of extents before idx
+ * |-------| | count |
+ * | | | | count - number of extents being removed at idx
+ * | count | |-------|
+ * | | | nex2 | nex2 - number of extents after idx + count
+ * |-------| |-------|
+ */
+void
+xfs_iext_remove_indirect(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t idx, /* index to begin removing extents */
+ int count) /* number of extents to remove */
+{
+ xfs_ext_irec_t *erp; /* indirection array pointer */
+ int erp_idx = 0; /* indirection array index */
+ xfs_extnum_t ext_cnt; /* extents left to remove */
+ xfs_extnum_t ext_diff; /* extents to remove in current list */
+ xfs_extnum_t nex1; /* number of extents before idx */
+ xfs_extnum_t nex2; /* extents after idx + count */
+ int nlists; /* entries in indirecton array */
+ int page_idx = idx; /* index in target extent list */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0);
+ ASSERT(erp != NULL);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ nex1 = page_idx;
+ ext_cnt = count;
+ while (ext_cnt) {
+ nex2 = MAX((erp->er_extcount - (nex1 + ext_cnt)), 0);
+ ext_diff = MIN(ext_cnt, (erp->er_extcount - nex1));
+ /*
+ * Check for deletion of entire list;
+ * xfs_iext_irec_remove() updates extent offsets.
+ */
+ if (ext_diff == erp->er_extcount) {
+ xfs_iext_irec_remove(ifp, erp_idx);
+ ext_cnt -= ext_diff;
+ nex1 = 0;
+ if (ext_cnt) {
+ ASSERT(erp_idx < ifp->if_real_bytes /
+ XFS_IEXT_BUFSZ);
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ nex1 = 0;
+ continue;
+ } else {
+ break;
+ }
+ }
+ /* Move extents up (if needed) */
+ if (nex2) {
+ memmove(&erp->er_extbuf[nex1],
+ &erp->er_extbuf[nex1 + ext_diff],
+ nex2 * sizeof(xfs_bmbt_rec_t));
+ }
+ /* Zero out rest of page */
+ memset(&erp->er_extbuf[nex1 + nex2], 0, (XFS_IEXT_BUFSZ -
+ ((nex1 + nex2) * sizeof(xfs_bmbt_rec_t))));
+ /* Update remaining counters */
+ erp->er_extcount -= ext_diff;
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1, -ext_diff);
+ ext_cnt -= ext_diff;
+ nex1 = 0;
+ erp_idx++;
+ erp++;
+ }
+ ifp->if_bytes -= count * sizeof(xfs_bmbt_rec_t);
+ xfs_iext_irec_compact(ifp);
+}
+
+/*
+ * Create, destroy, or resize a linear (direct) block of extents.
+ */
+void
+xfs_iext_realloc_direct(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int new_size) /* new size of extents */
+{
+ int rnew_size; /* real new size of extents */
+
+ rnew_size = new_size;
+
+ ASSERT(!(ifp->if_flags & XFS_IFEXTIREC) ||
+ ((new_size >= 0) && (new_size <= XFS_IEXT_BUFSZ) &&
+ (new_size != ifp->if_real_bytes)));
+
+ /* Free extent records */
+ if (new_size == 0) {
+ xfs_iext_destroy(ifp);
+ }
+ /* Resize direct extent list and zero any new bytes */
+ else if (ifp->if_real_bytes) {
+ /* Check if extents will fit inside the inode */
+ if (new_size <= XFS_INLINE_EXTS * sizeof(xfs_bmbt_rec_t)) {
+ xfs_iext_direct_to_inline(ifp, new_size /
+ (uint)sizeof(xfs_bmbt_rec_t));
+ ifp->if_bytes = new_size;
+ return;
+ }
+ if ((new_size & (new_size - 1)) != 0) {
+ rnew_size = xfs_iroundup(new_size);
+ }
+ if (rnew_size != ifp->if_real_bytes) {
+ ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
+ kmem_realloc(ifp->if_u1.if_extents,
+ rnew_size,
+ ifp->if_real_bytes,
+ KM_SLEEP);
+ }
+ if (rnew_size > ifp->if_real_bytes) {
+ memset(&ifp->if_u1.if_extents[ifp->if_bytes /
+ (uint)sizeof(xfs_bmbt_rec_t)], 0,
+ rnew_size - ifp->if_real_bytes);
+ }
+ }
+ /*
+ * Switch from the inline extent buffer to a direct
+ * extent list. Be sure to include the inline extent
+ * bytes in new_size.
+ */
+ else {
+ new_size += ifp->if_bytes;
+ if ((new_size & (new_size - 1)) != 0) {
+ rnew_size = xfs_iroundup(new_size);
+ }
+ xfs_iext_inline_to_direct(ifp, rnew_size);
+ }
+ ifp->if_real_bytes = rnew_size;
+ ifp->if_bytes = new_size;
+}
+
+/*
+ * Switch from linear (direct) extent records to inline buffer.
+ */
+void
+xfs_iext_direct_to_inline(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t nextents) /* number of extents in file */
+{
+ ASSERT(ifp->if_flags & XFS_IFEXTENTS);
+ ASSERT(nextents <= XFS_INLINE_EXTS);
+ /*
+ * The inline buffer was zeroed when we switched
+ * from inline to direct extent allocation mode,
+ * so we don't need to clear it here.
+ */
+ memcpy(ifp->if_u2.if_inline_ext, ifp->if_u1.if_extents,
+ nextents * sizeof(xfs_bmbt_rec_t));
+ kmem_free(ifp->if_u1.if_extents, KM_SLEEP);
+ ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
+ ifp->if_real_bytes = 0;
+}
+
+/*
+ * Switch from inline buffer to linear (direct) extent records.
+ * new_size should already be rounded up to the next power of 2
+ * by the caller (when appropriate), so use new_size as it is.
+ * However, since new_size may be rounded up, we can't update
+ * if_bytes here. It is the caller's responsibility to update
+ * if_bytes upon return.
+ */
+void
+xfs_iext_inline_to_direct(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int new_size) /* number of extents in file */
+{
+ ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
+ kmem_alloc(new_size, KM_SLEEP);
+ memset(ifp->if_u1.if_extents, 0, new_size);
+ if (ifp->if_bytes) {
+ memcpy(ifp->if_u1.if_extents, ifp->if_u2.if_inline_ext,
+ ifp->if_bytes);
+ memset(ifp->if_u2.if_inline_ext, 0, XFS_INLINE_EXTS *
+ sizeof(xfs_bmbt_rec_t));
+ }
+ ifp->if_real_bytes = new_size;
+}
+
+/*
+ * Resize an extent indirection array to new_size bytes.
+ */
+void
+xfs_iext_realloc_indirect(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int new_size) /* new indirection array size */
+{
+ int nlists; /* number of irec's (ex lists) */
+ int size; /* current indirection array size */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ size = nlists * sizeof(xfs_ext_irec_t);
+ ASSERT(ifp->if_real_bytes);
+ ASSERT((new_size >= 0) && (new_size != size));
+ if (new_size == 0) {
+ xfs_iext_destroy(ifp);
+ } else {
+ ifp->if_u1.if_ext_irec = (xfs_ext_irec_t *)
+ kmem_realloc(ifp->if_u1.if_ext_irec,
+ new_size, size, KM_SLEEP);
+ }
+}
+
+/*
+ * Switch from indirection array to linear (direct) extent allocations.
+ */
+void
+xfs_iext_indirect_to_direct(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ xfs_bmbt_rec_t *ep; /* extent record pointer */
+ xfs_extnum_t nextents; /* number of extents in file */
+ int size; /* size of file extents */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ ASSERT(nextents <= XFS_LINEAR_EXTS);
+ size = nextents * sizeof(xfs_bmbt_rec_t);
+
+ xfs_iext_irec_compact_full(ifp);
+ ASSERT(ifp->if_real_bytes == XFS_IEXT_BUFSZ);
+
+ ep = ifp->if_u1.if_ext_irec->er_extbuf;
+ kmem_free(ifp->if_u1.if_ext_irec, sizeof(xfs_ext_irec_t));
+ ifp->if_flags &= ~XFS_IFEXTIREC;
+ ifp->if_u1.if_extents = ep;
+ ifp->if_bytes = size;
+ if (nextents < XFS_LINEAR_EXTS) {
+ xfs_iext_realloc_direct(ifp, size);
+ }
+}
+
+/*
+ * Free incore file extents.
+ */
+void
+xfs_iext_destroy(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ if (ifp->if_flags & XFS_IFEXTIREC) {
+ int erp_idx;
+ int nlists;
+
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ for (erp_idx = nlists - 1; erp_idx >= 0 ; erp_idx--) {
+ xfs_iext_irec_remove(ifp, erp_idx);
+ }
+ ifp->if_flags &= ~XFS_IFEXTIREC;
+ } else if (ifp->if_real_bytes) {
+ kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes);
+ } else if (ifp->if_bytes) {
+ memset(ifp->if_u2.if_inline_ext, 0, XFS_INLINE_EXTS *
+ sizeof(xfs_bmbt_rec_t));
+ }
+ ifp->if_u1.if_extents = NULL;
+ ifp->if_real_bytes = 0;
+ ifp->if_bytes = 0;
+}
+
+/*
+ * Return a pointer to the extent record for file system block bno.
+ */
+xfs_bmbt_rec_t * /* pointer to found extent record */
+xfs_iext_bno_to_ext(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_fileoff_t bno, /* block number to search for */
+ xfs_extnum_t *idxp) /* index of target extent */
+{
+ xfs_bmbt_rec_t *base; /* pointer to first extent */
+ xfs_filblks_t blockcount = 0; /* number of blocks in extent */
+ xfs_bmbt_rec_t *ep = NULL; /* pointer to target extent */
+ xfs_ext_irec_t *erp = NULL; /* indirection array pointer */
+ int high; /* upper boundry in search */
+ xfs_extnum_t idx = 0; /* index of target extent */
+ int low; /* lower boundry in search */
+ xfs_extnum_t nextents; /* number of file extents */
+ xfs_fileoff_t startoff = 0; /* start offset of extent */
+
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ if (nextents == 0) {
+ *idxp = 0;
+ return NULL;
+ }
+ low = 0;
+ if (ifp->if_flags & XFS_IFEXTIREC) {
+ /* Find target extent list */
+ int erp_idx = 0;
+ erp = xfs_iext_bno_to_irec(ifp, bno, &erp_idx);
+ base = erp->er_extbuf;
+ high = erp->er_extcount - 1;
+ } else {
+ base = ifp->if_u1.if_extents;
+ high = nextents - 1;
+ }
+ /* Binary search extent records */
+ while (low <= high) {
+ idx = (low + high) >> 1;
+ ep = base + idx;
+ startoff = xfs_bmbt_get_startoff(ep);
+ blockcount = xfs_bmbt_get_blockcount(ep);
+ if (bno < startoff) {
+ high = idx - 1;
+ } else if (bno >= startoff + blockcount) {
+ low = idx + 1;
+ } else {
+ /* Convert back to file-based extent index */
+ if (ifp->if_flags & XFS_IFEXTIREC) {
+ idx += erp->er_extoff;
+ }
+ *idxp = idx;
+ return ep;
+ }
+ }
+ /* Convert back to file-based extent index */
+ if (ifp->if_flags & XFS_IFEXTIREC) {
+ idx += erp->er_extoff;
+ }
+ if (bno >= startoff + blockcount) {
+ if (++idx == nextents) {
+ ep = NULL;
+ } else {
+ ep = xfs_iext_get_ext(ifp, idx);
+ }
+ }
+ *idxp = idx;
+ return ep;
+}
+
+/*
+ * Return a pointer to the indirection array entry containing the
+ * extent record for filesystem block bno. Store the index of the
+ * target irec in *erp_idxp.
+ */
+xfs_ext_irec_t * /* pointer to found extent record */
+xfs_iext_bno_to_irec(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_fileoff_t bno, /* block number to search for */
+ int *erp_idxp) /* irec index of target ext list */
+{
+ xfs_ext_irec_t *erp = NULL; /* indirection array pointer */
+ xfs_ext_irec_t *erp_next; /* next indirection array entry */
+ int erp_idx; /* indirection array index */
+ int nlists; /* number of extent irec's (lists) */
+ int high; /* binary search upper limit */
+ int low; /* binary search lower limit */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ erp_idx = 0;
+ low = 0;
+ high = nlists - 1;
+ while (low <= high) {
+ erp_idx = (low + high) >> 1;
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ erp_next = erp_idx < nlists - 1 ? erp + 1 : NULL;
+ if (bno < xfs_bmbt_get_startoff(erp->er_extbuf)) {
+ high = erp_idx - 1;
+ } else if (erp_next && bno >=
+ xfs_bmbt_get_startoff(erp_next->er_extbuf)) {
+ low = erp_idx + 1;
+ } else {
+ break;
+ }
+ }
+ *erp_idxp = erp_idx;
+ return erp;
+}
+
+/*
+ * Return a pointer to the indirection array entry containing the
+ * extent record at file extent index *idxp. Store the index of the
+ * target irec in *erp_idxp and store the page index of the target
+ * extent record in *idxp.
+ */
+xfs_ext_irec_t *
+xfs_iext_idx_to_irec(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ xfs_extnum_t *idxp, /* extent index (file -> page) */
+ int *erp_idxp, /* pointer to target irec */
+ int realloc) /* new bytes were just added */
+{
+ xfs_ext_irec_t *prev; /* pointer to previous irec */
+ xfs_ext_irec_t *erp = NULL; /* pointer to current irec */
+ int erp_idx; /* indirection array index */
+ int nlists; /* number of irec's (ex lists) */
+ int high; /* binary search upper limit */
+ int low; /* binary search lower limit */
+ xfs_extnum_t page_idx = *idxp; /* extent index in target list */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ ASSERT(page_idx >= 0 && page_idx <=
+ ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t));
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ erp_idx = 0;
+ low = 0;
+ high = nlists - 1;
+
+ /* Binary search extent irec's */
+ while (low <= high) {
+ erp_idx = (low + high) >> 1;
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ prev = erp_idx > 0 ? erp - 1 : NULL;
+ if (page_idx < erp->er_extoff || (page_idx == erp->er_extoff &&
+ realloc && prev && prev->er_extcount < XFS_LINEAR_EXTS)) {
+ high = erp_idx - 1;
+ } else if (page_idx > erp->er_extoff + erp->er_extcount ||
+ (page_idx == erp->er_extoff + erp->er_extcount &&
+ !realloc)) {
+ low = erp_idx + 1;
+ } else if (page_idx == erp->er_extoff + erp->er_extcount &&
+ erp->er_extcount == XFS_LINEAR_EXTS) {
+ ASSERT(realloc);
+ page_idx = 0;
+ erp_idx++;
+ erp = erp_idx < nlists ? erp + 1 : NULL;
+ break;
+ } else {
+ page_idx -= erp->er_extoff;
+ break;
+ }
+ }
+ *idxp = page_idx;
+ *erp_idxp = erp_idx;
+ return(erp);
+}
+
+/*
+ * Allocate and initialize an indirection array once the space needed
+ * for incore extents increases above XFS_IEXT_BUFSZ.
+ */
+void
+xfs_iext_irec_init(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ xfs_ext_irec_t *erp; /* indirection array pointer */
+ xfs_extnum_t nextents; /* number of extents in file */
+
+ ASSERT(!(ifp->if_flags & XFS_IFEXTIREC));
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+ ASSERT(nextents <= XFS_LINEAR_EXTS);
+
+ erp = (xfs_ext_irec_t *)
+ kmem_alloc(sizeof(xfs_ext_irec_t), KM_SLEEP);
+
+ if (nextents == 0) {
+ ifp->if_u1.if_extents = (xfs_bmbt_rec_t *)
+ kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
+ } else if (!ifp->if_real_bytes) {
+ xfs_iext_inline_to_direct(ifp, XFS_IEXT_BUFSZ);
+ } else if (ifp->if_real_bytes < XFS_IEXT_BUFSZ) {
+ xfs_iext_realloc_direct(ifp, XFS_IEXT_BUFSZ);
+ }
+ erp->er_extbuf = ifp->if_u1.if_extents;
+ erp->er_extcount = nextents;
+ erp->er_extoff = 0;
+
+ ifp->if_flags |= XFS_IFEXTIREC;
+ ifp->if_real_bytes = XFS_IEXT_BUFSZ;
+ ifp->if_bytes = nextents * sizeof(xfs_bmbt_rec_t);
+ ifp->if_u1.if_ext_irec = erp;
+
+ return;
+}
+
+/*
+ * Allocate and initialize a new entry in the indirection array.
+ */
+xfs_ext_irec_t *
+xfs_iext_irec_new(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int erp_idx) /* index for new irec */
+{
+ xfs_ext_irec_t *erp; /* indirection array pointer */
+ int i; /* loop counter */
+ int nlists; /* number of irec's (ex lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+
+ /* Resize indirection array */
+ xfs_iext_realloc_indirect(ifp, ++nlists *
+ sizeof(xfs_ext_irec_t));
+ /*
+ * Move records down in the array so the
+ * new page can use erp_idx.
+ */
+ erp = ifp->if_u1.if_ext_irec;
+ for (i = nlists - 1; i > erp_idx; i--) {
+ memmove(&erp[i], &erp[i-1], sizeof(xfs_ext_irec_t));
+ }
+ ASSERT(i == erp_idx);
+
+ /* Initialize new extent record */
+ erp = ifp->if_u1.if_ext_irec;
+ erp[erp_idx].er_extbuf = (xfs_bmbt_rec_t *)
+ kmem_alloc(XFS_IEXT_BUFSZ, KM_SLEEP);
+ ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ;
+ memset(erp[erp_idx].er_extbuf, 0, XFS_IEXT_BUFSZ);
+ erp[erp_idx].er_extcount = 0;
+ erp[erp_idx].er_extoff = erp_idx > 0 ?
+ erp[erp_idx-1].er_extoff + erp[erp_idx-1].er_extcount : 0;
+ return (&erp[erp_idx]);
+}
+
+/*
+ * Remove a record from the indirection array.
+ */
+void
+xfs_iext_irec_remove(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int erp_idx) /* irec index to remove */
+{
+ xfs_ext_irec_t *erp; /* indirection array pointer */
+ int i; /* loop counter */
+ int nlists; /* number of irec's (ex lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ if (erp->er_extbuf) {
+ xfs_iext_irec_update_extoffs(ifp, erp_idx + 1,
+ -erp->er_extcount);
+ kmem_free(erp->er_extbuf, XFS_IEXT_BUFSZ);
+ }
+ /* Compact extent records */
+ erp = ifp->if_u1.if_ext_irec;
+ for (i = erp_idx; i < nlists - 1; i++) {
+ memmove(&erp[i], &erp[i+1], sizeof(xfs_ext_irec_t));
+ }
+ /*
+ * Manually free the last extent record from the indirection
+ * array. A call to xfs_iext_realloc_indirect() with a size
+ * of zero would result in a call to xfs_iext_destroy() which
+ * would in turn call this function again, creating a nasty
+ * infinite loop.
+ */
+ if (--nlists) {
+ xfs_iext_realloc_indirect(ifp,
+ nlists * sizeof(xfs_ext_irec_t));
+ } else {
+ kmem_free(ifp->if_u1.if_ext_irec,
+ sizeof(xfs_ext_irec_t));
+ }
+ ifp->if_real_bytes = nlists * XFS_IEXT_BUFSZ;
+}
+
+/*
+ * This is called to clean up large amounts of unused memory allocated
+ * by the indirection array. Before compacting anything though, verify
+ * that the indirection array is still needed and switch back to the
+ * linear extent list (or even the inline buffer) if possible. The
+ * compaction policy is as follows:
+ *
+ * Full Compaction: Extents fit into a single page (or inline buffer)
+ * Full Compaction: Extents occupy less than 10% of allocated space
+ * Partial Compaction: Extents occupy > 10% and < 50% of allocated space
+ * No Compaction: Extents occupy at least 50% of allocated space
+ */
+void
+xfs_iext_irec_compact(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ xfs_extnum_t nextents; /* number of extents in file */
+ int nlists; /* number of irec's (ex lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ nextents = ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t);
+
+ if (nextents == 0) {
+ xfs_iext_destroy(ifp);
+ } else if (nextents <= XFS_INLINE_EXTS) {
+ xfs_iext_indirect_to_direct(ifp);
+ xfs_iext_direct_to_inline(ifp, nextents);
+ } else if (nextents <= XFS_LINEAR_EXTS) {
+ xfs_iext_indirect_to_direct(ifp);
+ } else if (nextents < (nlists * XFS_LINEAR_EXTS) >> 3) {
+ xfs_iext_irec_compact_full(ifp);
+ } else if (nextents < (nlists * XFS_LINEAR_EXTS) >> 1) {
+ xfs_iext_irec_compact_pages(ifp);
+ }
+}
+
+/*
+ * Combine extents from neighboring extent pages.
+ */
+void
+xfs_iext_irec_compact_pages(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ xfs_ext_irec_t *erp, *erp_next;/* pointers to irec entries */
+ int erp_idx = 0; /* indirection array index */
+ int nlists; /* number of irec's (ex lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ while (erp_idx < nlists - 1) {
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ erp_next = erp + 1;
+ if (erp_next->er_extcount <=
+ (XFS_LINEAR_EXTS - erp->er_extcount)) {
+ memmove(&erp->er_extbuf[erp->er_extcount],
+ erp_next->er_extbuf, erp_next->er_extcount *
+ sizeof(xfs_bmbt_rec_t));
+ erp->er_extcount += erp_next->er_extcount;
+ /*
+ * Free page before removing extent record
+ * so er_extoffs don't get modified in
+ * xfs_iext_irec_remove.
+ */
+ kmem_free(erp_next->er_extbuf, XFS_IEXT_BUFSZ);
+ erp_next->er_extbuf = NULL;
+ xfs_iext_irec_remove(ifp, erp_idx + 1);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ } else {
+ erp_idx++;
+ }
+ }
+}
+
+/*
+ * Fully compact the extent records managed by the indirection array.
+ */
+void
+xfs_iext_irec_compact_full(
+ xfs_ifork_t *ifp) /* inode fork pointer */
+{
+ xfs_bmbt_rec_t *ep, *ep_next; /* extent record pointers */
+ xfs_ext_irec_t *erp, *erp_next; /* extent irec pointers */
+ int erp_idx = 0; /* extent irec index */
+ int ext_avail; /* empty entries in ex list */
+ int ext_diff; /* number of exts to add */
+ int nlists; /* number of irec's (ex lists) */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ erp = ifp->if_u1.if_ext_irec;
+ ep = &erp->er_extbuf[erp->er_extcount];
+ erp_next = erp + 1;
+ ep_next = erp_next->er_extbuf;
+ while (erp_idx < nlists - 1) {
+ ext_avail = XFS_LINEAR_EXTS - erp->er_extcount;
+ ext_diff = MIN(ext_avail, erp_next->er_extcount);
+ memcpy(ep, ep_next, ext_diff * sizeof(xfs_bmbt_rec_t));
+ erp->er_extcount += ext_diff;
+ erp_next->er_extcount -= ext_diff;
+ /* Remove next page */
+ if (erp_next->er_extcount == 0) {
+ /*
+ * Free page before removing extent record
+ * so er_extoffs don't get modified in
+ * xfs_iext_irec_remove.
+ */
+ kmem_free(erp_next->er_extbuf,
+ erp_next->er_extcount * sizeof(xfs_bmbt_rec_t));
+ erp_next->er_extbuf = NULL;
+ xfs_iext_irec_remove(ifp, erp_idx + 1);
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ /* Update next page */
+ } else {
+ /* Move rest of page up to become next new page */
+ memmove(erp_next->er_extbuf, ep_next,
+ erp_next->er_extcount * sizeof(xfs_bmbt_rec_t));
+ ep_next = erp_next->er_extbuf;
+ memset(&ep_next[erp_next->er_extcount], 0,
+ (XFS_LINEAR_EXTS - erp_next->er_extcount) *
+ sizeof(xfs_bmbt_rec_t));
+ }
+ if (erp->er_extcount == XFS_LINEAR_EXTS) {
+ erp_idx++;
+ if (erp_idx < nlists)
+ erp = &ifp->if_u1.if_ext_irec[erp_idx];
+ else
+ break;
+ }
+ ep = &erp->er_extbuf[erp->er_extcount];
+ erp_next = erp + 1;
+ ep_next = erp_next->er_extbuf;
+ }
+}
+
+/*
+ * This is called to update the er_extoff field in the indirection
+ * array when extents have been added or removed from one of the
+ * extent lists. erp_idx contains the irec index to begin updating
+ * at and ext_diff contains the number of extents that were added
+ * or removed.
+ */
+void
+xfs_iext_irec_update_extoffs(
+ xfs_ifork_t *ifp, /* inode fork pointer */
+ int erp_idx, /* irec index to update */
+ int ext_diff) /* number of new extents */
+{
+ int i; /* loop counter */
+ int nlists; /* number of irec's (ex lists */
+
+ ASSERT(ifp->if_flags & XFS_IFEXTIREC);
+ nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
+ for (i = erp_idx; i < nlists; i++) {
+ ifp->if_u1.if_ext_irec[i].er_extoff += ext_diff;
+ }
+}
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 1cfbcf18ce8..39ef9c36ea5 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -25,10 +25,37 @@
#define XFS_ATTR_FORK 1
/*
+ * The following xfs_ext_irec_t struct introduces a second (top) level
+ * to the in-core extent allocation scheme. These structs are allocated
+ * in a contiguous block, creating an indirection array where each entry
+ * (irec) contains a pointer to a buffer of in-core extent records which
+ * it manages. Each extent buffer is 4k in size, since 4k is the system
+ * page size on Linux i386 and systems with larger page sizes don't seem
+ * to gain much, if anything, by using their native page size as the
+ * extent buffer size. Also, using 4k extent buffers everywhere provides
+ * a consistent interface for CXFS across different platforms.
+ *
+ * There is currently no limit on the number of irec's (extent lists)
+ * allowed, so heavily fragmented files may require an indirection array
+ * which spans multiple system pages of memory. The number of extents
+ * which would require this amount of contiguous memory is very large
+ * and should not cause problems in the foreseeable future. However,
+ * if the memory needed for the contiguous array ever becomes a problem,
+ * it is possible that a third level of indirection may be required.
+ */
+typedef struct xfs_ext_irec {
+ xfs_bmbt_rec_t *er_extbuf; /* block of extent records */
+ xfs_extnum_t er_extoff; /* extent offset in file */
+ xfs_extnum_t er_extcount; /* number of extents in page/block */
+} xfs_ext_irec_t;
+
+/*
* File incore extent information, present for each of data & attr forks.
*/
-#define XFS_INLINE_EXTS 2
-#define XFS_INLINE_DATA 32
+#define XFS_IEXT_BUFSZ 4096
+#define XFS_LINEAR_EXTS (XFS_IEXT_BUFSZ / (uint)sizeof(xfs_bmbt_rec_t))
+#define XFS_INLINE_EXTS 2
+#define XFS_INLINE_DATA 32
typedef struct xfs_ifork {
int if_bytes; /* bytes in if_u1 */
int if_real_bytes; /* bytes allocated in if_u1 */
@@ -39,6 +66,7 @@ typedef struct xfs_ifork {
xfs_extnum_t if_lastex; /* last if_extents used */
union {
xfs_bmbt_rec_t *if_extents; /* linear map file exts */
+ xfs_ext_irec_t *if_ext_irec; /* irec map file exts */
char *if_data; /* inline file data */
} if_u1;
union {
@@ -61,20 +89,16 @@ typedef struct xfs_ifork {
/*
* Per-fork incore inode flags.
*/
-#define XFS_IFINLINE 0x0001 /* Inline data is read in */
-#define XFS_IFEXTENTS 0x0002 /* All extent pointers are read in */
-#define XFS_IFBROOT 0x0004 /* i_broot points to the bmap b-tree root */
+#define XFS_IFINLINE 0x01 /* Inline data is read in */
+#define XFS_IFEXTENTS 0x02 /* All extent pointers are read in */
+#define XFS_IFBROOT 0x04 /* i_broot points to the bmap b-tree root */
+#define XFS_IFEXTIREC 0x08 /* Indirection array of extent blocks */
/*
- * Flags for xfs_imap() and xfs_dilocate().
+ * Flags for xfs_itobp(), xfs_imap() and xfs_dilocate().
*/
-#define XFS_IMAP_LOOKUP 0x1
-
-/*
- * Maximum number of extent pointers in if_u1.if_extents.
- */
-#define XFS_MAX_INCORE_EXTENTS 32768
-
+#define XFS_IMAP_LOOKUP 0x1
+#define XFS_IMAP_BULKSTAT 0x2
#ifdef __KERNEL__
struct bhv_desc;
@@ -398,7 +422,7 @@ int xfs_finish_reclaim_all(struct xfs_mount *, int);
*/
int xfs_itobp(struct xfs_mount *, struct xfs_trans *,
xfs_inode_t *, xfs_dinode_t **, struct xfs_buf **,
- xfs_daddr_t);
+ xfs_daddr_t, uint);
int xfs_iread(struct xfs_mount *, struct xfs_trans *, xfs_ino_t,
xfs_inode_t **, xfs_daddr_t);
int xfs_iread_extents(struct xfs_trans *, xfs_inode_t *, int);
@@ -440,6 +464,32 @@ xfs_inode_t *xfs_vtoi(struct vnode *vp);
void xfs_synchronize_atime(xfs_inode_t *);
+xfs_bmbt_rec_t *xfs_iext_get_ext(xfs_ifork_t *, xfs_extnum_t);
+void xfs_iext_insert(xfs_ifork_t *, xfs_extnum_t, xfs_extnum_t,
+ xfs_bmbt_irec_t *);
+void xfs_iext_add(xfs_ifork_t *, xfs_extnum_t, int);
+void xfs_iext_add_indirect_multi(xfs_ifork_t *, int, xfs_extnum_t, int);
+void xfs_iext_remove(xfs_ifork_t *, xfs_extnum_t, int);
+void xfs_iext_remove_inline(xfs_ifork_t *, xfs_extnum_t, int);
+void xfs_iext_remove_direct(xfs_ifork_t *, xfs_extnum_t, int);
+void xfs_iext_remove_indirect(xfs_ifork_t *, xfs_extnum_t, int);
+void xfs_iext_realloc_direct(xfs_ifork_t *, int);
+void xfs_iext_realloc_indirect(xfs_ifork_t *, int);
+void xfs_iext_indirect_to_direct(xfs_ifork_t *);
+void xfs_iext_direct_to_inline(xfs_ifork_t *, xfs_extnum_t);
+void xfs_iext_inline_to_direct(xfs_ifork_t *, int);
+void xfs_iext_destroy(xfs_ifork_t *);
+xfs_bmbt_rec_t *xfs_iext_bno_to_ext(xfs_ifork_t *, xfs_fileoff_t, int *);
+xfs_ext_irec_t *xfs_iext_bno_to_irec(xfs_ifork_t *, xfs_fileoff_t, int *);
+xfs_ext_irec_t *xfs_iext_idx_to_irec(xfs_ifork_t *, xfs_extnum_t *, int *, int);
+void xfs_iext_irec_init(xfs_ifork_t *);
+xfs_ext_irec_t *xfs_iext_irec_new(xfs_ifork_t *, int);
+void xfs_iext_irec_remove(xfs_ifork_t *, int);
+void xfs_iext_irec_compact(xfs_ifork_t *);
+void xfs_iext_irec_compact_pages(xfs_ifork_t *);
+void xfs_iext_irec_compact_full(xfs_ifork_t *);
+void xfs_iext_irec_update_extoffs(xfs_ifork_t *, int, int);
+
#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
#ifdef DEBUG
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index 788917f355c..d5dfedcb892 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -76,7 +76,7 @@ xfs_iomap_enter_trace(
(void *)((unsigned long)count),
(void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
(void *)((unsigned long)(io->io_new_size & 0xffffffff)),
- (void *)NULL,
+ (void *)((unsigned long)current_pid()),
(void *)NULL,
(void *)NULL,
(void *)NULL,
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index c59450e1be4..32247b6bfee 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -562,7 +562,8 @@ xfs_bulkstat(
if (bp)
xfs_buf_relse(bp);
error = xfs_itobp(mp, NULL, ip,
- &dip, &bp, bno);
+ &dip, &bp, bno,
+ XFS_IMAP_BULKSTAT);
if (!error)
clustidx = ip->i_boffset / mp->m_sb.sb_inodesize;
kmem_zone_free(xfs_inode_zone, ip);
@@ -570,6 +571,8 @@ xfs_bulkstat(
mp, XFS_ERRTAG_BULKSTAT_READ_CHUNK,
XFS_RANDOM_BULKSTAT_READ_CHUNK)) {
bp = NULL;
+ ubleft = 0;
+ rval = error;
break;
}
}
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 7d46cbd6a07..add13f507ed 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3249,7 +3249,7 @@ xlog_recover_process_iunlinks(
* next inode in the bucket.
*/
error = xfs_itobp(mp, NULL, ip, &dip,
- &ibp, 0);
+ &ibp, 0, 0);
ASSERT(error || (dip != NULL));
}
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 62188ea392c..20e8abc16d1 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -51,11 +51,32 @@ STATIC int xfs_uuid_mount(xfs_mount_t *);
STATIC void xfs_uuid_unmount(xfs_mount_t *mp);
STATIC void xfs_unmountfs_wait(xfs_mount_t *);
+
+#ifdef HAVE_PERCPU_SB
+STATIC void xfs_icsb_destroy_counters(xfs_mount_t *);
+STATIC void xfs_icsb_balance_counter(xfs_mount_t *, xfs_sb_field_t, int);
+STATIC void xfs_icsb_sync_counters(xfs_mount_t *);
+STATIC int xfs_icsb_modify_counters(xfs_mount_t *, xfs_sb_field_t,
+ int, int);
+STATIC int xfs_icsb_modify_counters_locked(xfs_mount_t *, xfs_sb_field_t,
+ int, int);
+STATIC int xfs_icsb_disable_counter(xfs_mount_t *, xfs_sb_field_t);
+
+#else
+
+#define xfs_icsb_destroy_counters(mp) do { } while (0)
+#define xfs_icsb_balance_counter(mp, a, b) do { } while (0)
+#define xfs_icsb_sync_counters(mp) do { } while (0)
+#define xfs_icsb_modify_counters(mp, a, b, c) do { } while (0)
+#define xfs_icsb_modify_counters_locked(mp, a, b, c) do { } while (0)
+
+#endif
+
static const struct {
- short offset;
- short type; /* 0 = integer
- * 1 = binary / string (no translation)
- */
+ short offset;
+ short type; /* 0 = integer
+ * 1 = binary / string (no translation)
+ */
} xfs_sb_info[] = {
{ offsetof(xfs_sb_t, sb_magicnum), 0 },
{ offsetof(xfs_sb_t, sb_blocksize), 0 },
@@ -113,7 +134,11 @@ xfs_mount_init(void)
{
xfs_mount_t *mp;
- mp = kmem_zalloc(sizeof(*mp), KM_SLEEP);
+ mp = kmem_zalloc(sizeof(xfs_mount_t), KM_SLEEP);
+
+ if (xfs_icsb_init_counters(mp)) {
+ mp->m_flags |= XFS_MOUNT_NO_PERCPU_SB;
+ }
AIL_LOCKINIT(&mp->m_ail_lock, "xfs_ail");
spinlock_init(&mp->m_sb_lock, "xfs_sb");
@@ -136,8 +161,8 @@ xfs_mount_init(void)
*/
void
xfs_mount_free(
- xfs_mount_t *mp,
- int remove_bhv)
+ xfs_mount_t *mp,
+ int remove_bhv)
{
if (mp->m_ihash)
xfs_ihash_free(mp);
@@ -177,6 +202,7 @@ xfs_mount_free(
VFS_REMOVEBHV(vfsp, &mp->m_bhv);
}
+ xfs_icsb_destroy_counters(mp);
kmem_free(mp, sizeof(xfs_mount_t));
}
@@ -242,9 +268,12 @@ xfs_mount_validate_sb(
sbp->sb_blocklog > XFS_MAX_BLOCKSIZE_LOG ||
sbp->sb_inodesize < XFS_DINODE_MIN_SIZE ||
sbp->sb_inodesize > XFS_DINODE_MAX_SIZE ||
+ sbp->sb_inodelog < XFS_DINODE_MIN_LOG ||
+ sbp->sb_inodelog > XFS_DINODE_MAX_LOG ||
+ (sbp->sb_blocklog - sbp->sb_inodelog != sbp->sb_inopblog) ||
(sbp->sb_rextsize * sbp->sb_blocksize > XFS_MAX_RTEXTSIZE) ||
(sbp->sb_rextsize * sbp->sb_blocksize < XFS_MIN_RTEXTSIZE) ||
- sbp->sb_imax_pct > 100)) {
+ (sbp->sb_imax_pct > 100 || sbp->sb_imax_pct < 1))) {
cmn_err(CE_WARN, "XFS: SB sanity check 1 failed");
XFS_CORRUPTION_ERROR("xfs_mount_validate_sb(3)",
XFS_ERRLEVEL_LOW, mp, sbp);
@@ -527,6 +556,10 @@ xfs_readsb(xfs_mount_t *mp)
ASSERT(XFS_BUF_VALUSEMA(bp) <= 0);
}
+ xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
+ xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
+ xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
+
mp->m_sb_bp = bp;
xfs_buf_relse(bp);
ASSERT(XFS_BUF_VALUSEMA(bp) > 0);
@@ -1154,6 +1187,9 @@ xfs_unmountfs_writesb(xfs_mount_t *mp)
sbp = xfs_getsb(mp, 0);
if (!(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY ||
XFS_FORCED_SHUTDOWN(mp))) {
+
+ xfs_icsb_sync_counters(mp);
+
/*
* mark shared-readonly if desired
*/
@@ -1227,7 +1263,6 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
xfs_trans_log_buf(tp, bp, first, last);
}
-
/*
* xfs_mod_incore_sb_unlocked() is a utility routine common used to apply
* a delta to a specified field in the in-core superblock. Simply
@@ -1237,7 +1272,7 @@ xfs_mod_sb(xfs_trans_t *tp, __int64_t fields)
*
* The SB_LOCK must be held when this routine is called.
*/
-STATIC int
+int
xfs_mod_incore_sb_unlocked(xfs_mount_t *mp, xfs_sb_field_t field,
int delta, int rsvd)
{
@@ -1406,9 +1441,26 @@ xfs_mod_incore_sb(xfs_mount_t *mp, xfs_sb_field_t field, int delta, int rsvd)
unsigned long s;
int status;
- s = XFS_SB_LOCK(mp);
- status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
- XFS_SB_UNLOCK(mp, s);
+ /* check for per-cpu counters */
+ switch (field) {
+#ifdef HAVE_PERCPU_SB
+ case XFS_SBS_ICOUNT:
+ case XFS_SBS_IFREE:
+ case XFS_SBS_FDBLOCKS:
+ if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) {
+ status = xfs_icsb_modify_counters(mp, field,
+ delta, rsvd);
+ break;
+ }
+ /* FALLTHROUGH */
+#endif
+ default:
+ s = XFS_SB_LOCK(mp);
+ status = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
+ XFS_SB_UNLOCK(mp, s);
+ break;
+ }
+
return status;
}
@@ -1445,8 +1497,26 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
* from the loop so we'll fall into the undo loop
* below.
*/
- status = xfs_mod_incore_sb_unlocked(mp, msbp->msb_field,
- msbp->msb_delta, rsvd);
+ switch (msbp->msb_field) {
+#ifdef HAVE_PERCPU_SB
+ case XFS_SBS_ICOUNT:
+ case XFS_SBS_IFREE:
+ case XFS_SBS_FDBLOCKS:
+ if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) {
+ status = xfs_icsb_modify_counters_locked(mp,
+ msbp->msb_field,
+ msbp->msb_delta, rsvd);
+ break;
+ }
+ /* FALLTHROUGH */
+#endif
+ default:
+ status = xfs_mod_incore_sb_unlocked(mp,
+ msbp->msb_field,
+ msbp->msb_delta, rsvd);
+ break;
+ }
+
if (status != 0) {
break;
}
@@ -1463,8 +1533,28 @@ xfs_mod_incore_sb_batch(xfs_mount_t *mp, xfs_mod_sb_t *msb, uint nmsb, int rsvd)
if (status != 0) {
msbp--;
while (msbp >= msb) {
- status = xfs_mod_incore_sb_unlocked(mp,
- msbp->msb_field, -(msbp->msb_delta), rsvd);
+ switch (msbp->msb_field) {
+#ifdef HAVE_PERCPU_SB
+ case XFS_SBS_ICOUNT:
+ case XFS_SBS_IFREE:
+ case XFS_SBS_FDBLOCKS:
+ if (!(mp->m_flags & XFS_MOUNT_NO_PERCPU_SB)) {
+ status =
+ xfs_icsb_modify_counters_locked(mp,
+ msbp->msb_field,
+ -(msbp->msb_delta),
+ rsvd);
+ break;
+ }
+ /* FALLTHROUGH */
+#endif
+ default:
+ status = xfs_mod_incore_sb_unlocked(mp,
+ msbp->msb_field,
+ -(msbp->msb_delta),
+ rsvd);
+ break;
+ }
ASSERT(status == 0);
msbp--;
}
@@ -1577,3 +1667,525 @@ xfs_mount_log_sbunit(
xfs_mod_sb(tp, fields);
xfs_trans_commit(tp, 0, NULL);
}
+
+
+#ifdef HAVE_PERCPU_SB
+/*
+ * Per-cpu incore superblock counters
+ *
+ * Simple concept, difficult implementation
+ *
+ * Basically, replace the incore superblock counters with a distributed per cpu
+ * counter for contended fields (e.g. free block count).
+ *
+ * Difficulties arise in that the incore sb is used for ENOSPC checking, and
+ * hence needs to be accurately read when we are running low on space. Hence
+ * there is a method to enable and disable the per-cpu counters based on how
+ * much "stuff" is available in them.
+ *
+ * Basically, a counter is enabled if there is enough free resource to justify
+ * running a per-cpu fast-path. If the per-cpu counter runs out (i.e. a local
+ * ENOSPC), then we disable the counters to synchronise all callers and
+ * re-distribute the available resources.
+ *
+ * If, once we redistributed the available resources, we still get a failure,
+ * we disable the per-cpu counter and go through the slow path.
+ *
+ * The slow path is the current xfs_mod_incore_sb() function. This means that
+ * when we disable a per-cpu counter, we need to drain it's resources back to
+ * the global superblock. We do this after disabling the counter to prevent
+ * more threads from queueing up on the counter.
+ *
+ * Essentially, this means that we still need a lock in the fast path to enable
+ * synchronisation between the global counters and the per-cpu counters. This
+ * is not a problem because the lock will be local to a CPU almost all the time
+ * and have little contention except when we get to ENOSPC conditions.
+ *
+ * Basically, this lock becomes a barrier that enables us to lock out the fast
+ * path while we do things like enabling and disabling counters and
+ * synchronising the counters.
+ *
+ * Locking rules:
+ *
+ * 1. XFS_SB_LOCK() before picking up per-cpu locks
+ * 2. per-cpu locks always picked up via for_each_online_cpu() order
+ * 3. accurate counter sync requires XFS_SB_LOCK + per cpu locks
+ * 4. modifying per-cpu counters requires holding per-cpu lock
+ * 5. modifying global counters requires holding XFS_SB_LOCK
+ * 6. enabling or disabling a counter requires holding the XFS_SB_LOCK
+ * and _none_ of the per-cpu locks.
+ *
+ * Disabled counters are only ever re-enabled by a balance operation
+ * that results in more free resources per CPU than a given threshold.
+ * To ensure counters don't remain disabled, they are rebalanced when
+ * the global resource goes above a higher threshold (i.e. some hysteresis
+ * is present to prevent thrashing).
+ */
+
+/*
+ * hot-plug CPU notifier support.
+ *
+ * We cannot use the hotcpu_register() function because it does
+ * not allow notifier instances. We need a notifier per filesystem
+ * as we need to be able to identify the filesystem to balance
+ * the counters out. This is acheived by having a notifier block
+ * embedded in the xfs_mount_t and doing pointer magic to get the
+ * mount pointer from the notifier block address.
+ */
+STATIC int
+xfs_icsb_cpu_notify(
+ struct notifier_block *nfb,
+ unsigned long action,
+ void *hcpu)
+{
+ xfs_icsb_cnts_t *cntp;
+ xfs_mount_t *mp;
+ int s;
+
+ mp = (xfs_mount_t *)container_of(nfb, xfs_mount_t, m_icsb_notifier);
+ cntp = (xfs_icsb_cnts_t *)
+ per_cpu_ptr(mp->m_sb_cnts, (unsigned long)hcpu);
+ switch (action) {
+ case CPU_UP_PREPARE:
+ /* Easy Case - initialize the area and locks, and
+ * then rebalance when online does everything else for us. */
+ memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
+ break;
+ case CPU_ONLINE:
+ xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, 0);
+ xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, 0);
+ xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, 0);
+ break;
+ case CPU_DEAD:
+ /* Disable all the counters, then fold the dead cpu's
+ * count into the total on the global superblock and
+ * re-enable the counters. */
+ s = XFS_SB_LOCK(mp);
+ xfs_icsb_disable_counter(mp, XFS_SBS_ICOUNT);
+ xfs_icsb_disable_counter(mp, XFS_SBS_IFREE);
+ xfs_icsb_disable_counter(mp, XFS_SBS_FDBLOCKS);
+
+ mp->m_sb.sb_icount += cntp->icsb_icount;
+ mp->m_sb.sb_ifree += cntp->icsb_ifree;
+ mp->m_sb.sb_fdblocks += cntp->icsb_fdblocks;
+
+ memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
+
+ xfs_icsb_balance_counter(mp, XFS_SBS_ICOUNT, XFS_ICSB_SB_LOCKED);
+ xfs_icsb_balance_counter(mp, XFS_SBS_IFREE, XFS_ICSB_SB_LOCKED);
+ xfs_icsb_balance_counter(mp, XFS_SBS_FDBLOCKS, XFS_ICSB_SB_LOCKED);
+ XFS_SB_UNLOCK(mp, s);
+ break;
+ }
+
+ return NOTIFY_OK;
+}
+
+int
+xfs_icsb_init_counters(
+ xfs_mount_t *mp)
+{
+ xfs_icsb_cnts_t *cntp;
+ int i;
+
+ mp->m_sb_cnts = alloc_percpu(xfs_icsb_cnts_t);
+ if (mp->m_sb_cnts == NULL)
+ return -ENOMEM;
+
+ mp->m_icsb_notifier.notifier_call = xfs_icsb_cpu_notify;
+ mp->m_icsb_notifier.priority = 0;
+ register_cpu_notifier(&mp->m_icsb_notifier);
+
+ for_each_online_cpu(i) {
+ cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ memset(cntp, 0, sizeof(xfs_icsb_cnts_t));
+ }
+ /*
+ * start with all counters disabled so that the
+ * initial balance kicks us off correctly
+ */
+ mp->m_icsb_counters = -1;
+ return 0;
+}
+
+STATIC void
+xfs_icsb_destroy_counters(
+ xfs_mount_t *mp)
+{
+ if (mp->m_sb_cnts) {
+ unregister_cpu_notifier(&mp->m_icsb_notifier);
+ free_percpu(mp->m_sb_cnts);
+ }
+}
+
+STATIC inline void
+xfs_icsb_lock_cntr(
+ xfs_icsb_cnts_t *icsbp)
+{
+ while (test_and_set_bit(XFS_ICSB_FLAG_LOCK, &icsbp->icsb_flags)) {
+ ndelay(1000);
+ }
+}
+
+STATIC inline void
+xfs_icsb_unlock_cntr(
+ xfs_icsb_cnts_t *icsbp)
+{
+ clear_bit(XFS_ICSB_FLAG_LOCK, &icsbp->icsb_flags);
+}
+
+
+STATIC inline void
+xfs_icsb_lock_all_counters(
+ xfs_mount_t *mp)
+{
+ xfs_icsb_cnts_t *cntp;
+ int i;
+
+ for_each_online_cpu(i) {
+ cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ xfs_icsb_lock_cntr(cntp);
+ }
+}
+
+STATIC inline void
+xfs_icsb_unlock_all_counters(
+ xfs_mount_t *mp)
+{
+ xfs_icsb_cnts_t *cntp;
+ int i;
+
+ for_each_online_cpu(i) {
+ cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ xfs_icsb_unlock_cntr(cntp);
+ }
+}
+
+STATIC void
+xfs_icsb_count(
+ xfs_mount_t *mp,
+ xfs_icsb_cnts_t *cnt,
+ int flags)
+{
+ xfs_icsb_cnts_t *cntp;
+ int i;
+
+ memset(cnt, 0, sizeof(xfs_icsb_cnts_t));
+
+ if (!(flags & XFS_ICSB_LAZY_COUNT))
+ xfs_icsb_lock_all_counters(mp);
+
+ for_each_online_cpu(i) {
+ cntp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, i);
+ cnt->icsb_icount += cntp->icsb_icount;
+ cnt->icsb_ifree += cntp->icsb_ifree;
+ cnt->icsb_fdblocks += cntp->icsb_fdblocks;
+ }
+
+ if (!(flags & XFS_ICSB_LAZY_COUNT))
+ xfs_icsb_unlock_all_counters(mp);
+}
+
+STATIC int
+xfs_icsb_counter_disabled(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field)
+{
+ ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS));
+ return test_bit(field, &mp->m_icsb_counters);
+}
+
+STATIC int
+xfs_icsb_disable_counter(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field)
+{
+ xfs_icsb_cnts_t cnt;
+
+ ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS));
+
+ xfs_icsb_lock_all_counters(mp);
+ if (!test_and_set_bit(field, &mp->m_icsb_counters)) {
+ /* drain back to superblock */
+
+ xfs_icsb_count(mp, &cnt, XFS_ICSB_SB_LOCKED|XFS_ICSB_LAZY_COUNT);
+ switch(field) {
+ case XFS_SBS_ICOUNT:
+ mp->m_sb.sb_icount = cnt.icsb_icount;
+ break;
+ case XFS_SBS_IFREE:
+ mp->m_sb.sb_ifree = cnt.icsb_ifree;
+ break;
+ case XFS_SBS_FDBLOCKS:
+ mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks;
+ break;
+ default:
+ BUG();
+ }
+ }
+
+ xfs_icsb_unlock_all_counters(mp);
+
+ return 0;
+}
+
+STATIC void
+xfs_icsb_enable_counter(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field,
+ uint64_t count,
+ uint64_t resid)
+{
+ xfs_icsb_cnts_t *cntp;
+ int i;
+
+ ASSERT((field >= XFS_SBS_ICOUNT) && (field <= XFS_SBS_FDBLOCKS));
+
+ xfs_icsb_lock_all_counters(mp);
+ for_each_online_cpu(i) {
+ cntp = per_cpu_ptr(mp->m_sb_cnts, i);
+ switch (field) {
+ case XFS_SBS_ICOUNT:
+ cntp->icsb_icount = count + resid;
+ break;
+ case XFS_SBS_IFREE:
+ cntp->icsb_ifree = count + resid;
+ break;
+ case XFS_SBS_FDBLOCKS:
+ cntp->icsb_fdblocks = count + resid;
+ break;
+ default:
+ BUG();
+ break;
+ }
+ resid = 0;
+ }
+ clear_bit(field, &mp->m_icsb_counters);
+ xfs_icsb_unlock_all_counters(mp);
+}
+
+STATIC void
+xfs_icsb_sync_counters_int(
+ xfs_mount_t *mp,
+ int flags)
+{
+ xfs_icsb_cnts_t cnt;
+ int s;
+
+ /* Pass 1: lock all counters */
+ if ((flags & XFS_ICSB_SB_LOCKED) == 0)
+ s = XFS_SB_LOCK(mp);
+
+ xfs_icsb_count(mp, &cnt, flags);
+
+ /* Step 3: update mp->m_sb fields */
+ if (!xfs_icsb_counter_disabled(mp, XFS_SBS_ICOUNT))
+ mp->m_sb.sb_icount = cnt.icsb_icount;
+ if (!xfs_icsb_counter_disabled(mp, XFS_SBS_IFREE))
+ mp->m_sb.sb_ifree = cnt.icsb_ifree;
+ if (!xfs_icsb_counter_disabled(mp, XFS_SBS_FDBLOCKS))
+ mp->m_sb.sb_fdblocks = cnt.icsb_fdblocks;
+
+ if ((flags & XFS_ICSB_SB_LOCKED) == 0)
+ XFS_SB_UNLOCK(mp, s);
+}
+
+/*
+ * Accurate update of per-cpu counters to incore superblock
+ */
+STATIC void
+xfs_icsb_sync_counters(
+ xfs_mount_t *mp)
+{
+ xfs_icsb_sync_counters_int(mp, 0);
+}
+
+/*
+ * lazy addition used for things like df, background sb syncs, etc
+ */
+void
+xfs_icsb_sync_counters_lazy(
+ xfs_mount_t *mp)
+{
+ xfs_icsb_sync_counters_int(mp, XFS_ICSB_LAZY_COUNT);
+}
+
+/*
+ * Balance and enable/disable counters as necessary.
+ *
+ * Thresholds for re-enabling counters are somewhat magic.
+ * inode counts are chosen to be the same number as single
+ * on disk allocation chunk per CPU, and free blocks is
+ * something far enough zero that we aren't going thrash
+ * when we get near ENOSPC.
+ */
+#define XFS_ICSB_INO_CNTR_REENABLE 64
+#define XFS_ICSB_FDBLK_CNTR_REENABLE 512
+STATIC void
+xfs_icsb_balance_counter(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field,
+ int flags)
+{
+ uint64_t count, resid = 0;
+ int weight = num_online_cpus();
+ int s;
+
+ if (!(flags & XFS_ICSB_SB_LOCKED))
+ s = XFS_SB_LOCK(mp);
+
+ /* disable counter and sync counter */
+ xfs_icsb_disable_counter(mp, field);
+
+ /* update counters - first CPU gets residual*/
+ switch (field) {
+ case XFS_SBS_ICOUNT:
+ count = mp->m_sb.sb_icount;
+ resid = do_div(count, weight);
+ if (count < XFS_ICSB_INO_CNTR_REENABLE)
+ goto out;
+ break;
+ case XFS_SBS_IFREE:
+ count = mp->m_sb.sb_ifree;
+ resid = do_div(count, weight);
+ if (count < XFS_ICSB_INO_CNTR_REENABLE)
+ goto out;
+ break;
+ case XFS_SBS_FDBLOCKS:
+ count = mp->m_sb.sb_fdblocks;
+ resid = do_div(count, weight);
+ if (count < XFS_ICSB_FDBLK_CNTR_REENABLE)
+ goto out;
+ break;
+ default:
+ BUG();
+ break;
+ }
+
+ xfs_icsb_enable_counter(mp, field, count, resid);
+out:
+ if (!(flags & XFS_ICSB_SB_LOCKED))
+ XFS_SB_UNLOCK(mp, s);
+}
+
+STATIC int
+xfs_icsb_modify_counters_int(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field,
+ int delta,
+ int rsvd,
+ int flags)
+{
+ xfs_icsb_cnts_t *icsbp;
+ long long lcounter; /* long counter for 64 bit fields */
+ int cpu, s, locked = 0;
+ int ret = 0, balance_done = 0;
+
+again:
+ cpu = get_cpu();
+ icsbp = (xfs_icsb_cnts_t *)per_cpu_ptr(mp->m_sb_cnts, cpu),
+ xfs_icsb_lock_cntr(icsbp);
+ if (unlikely(xfs_icsb_counter_disabled(mp, field)))
+ goto slow_path;
+
+ switch (field) {
+ case XFS_SBS_ICOUNT:
+ lcounter = icsbp->icsb_icount;
+ lcounter += delta;
+ if (unlikely(lcounter < 0))
+ goto slow_path;
+ icsbp->icsb_icount = lcounter;
+ break;
+
+ case XFS_SBS_IFREE:
+ lcounter = icsbp->icsb_ifree;
+ lcounter += delta;
+ if (unlikely(lcounter < 0))
+ goto slow_path;
+ icsbp->icsb_ifree = lcounter;
+ break;
+
+ case XFS_SBS_FDBLOCKS:
+ BUG_ON((mp->m_resblks - mp->m_resblks_avail) != 0);
+
+ lcounter = icsbp->icsb_fdblocks;
+ lcounter += delta;
+ if (unlikely(lcounter < 0))
+ goto slow_path;
+ icsbp->icsb_fdblocks = lcounter;
+ break;
+ default:
+ BUG();
+ break;
+ }
+ xfs_icsb_unlock_cntr(icsbp);
+ put_cpu();
+ if (locked)
+ XFS_SB_UNLOCK(mp, s);
+ return 0;
+
+ /*
+ * The slow path needs to be run with the SBLOCK
+ * held so that we prevent other threads from
+ * attempting to run this path at the same time.
+ * this provides exclusion for the balancing code,
+ * and exclusive fallback if the balance does not
+ * provide enough resources to continue in an unlocked
+ * manner.
+ */
+slow_path:
+ xfs_icsb_unlock_cntr(icsbp);
+ put_cpu();
+
+ /* need to hold superblock incase we need
+ * to disable a counter */
+ if (!(flags & XFS_ICSB_SB_LOCKED)) {
+ s = XFS_SB_LOCK(mp);
+ locked = 1;
+ flags |= XFS_ICSB_SB_LOCKED;
+ }
+ if (!balance_done) {
+ xfs_icsb_balance_counter(mp, field, flags);
+ balance_done = 1;
+ goto again;
+ } else {
+ /*
+ * we might not have enough on this local
+ * cpu to allocate for a bulk request.
+ * We need to drain this field from all CPUs
+ * and disable the counter fastpath
+ */
+ xfs_icsb_disable_counter(mp, field);
+ }
+
+ ret = xfs_mod_incore_sb_unlocked(mp, field, delta, rsvd);
+
+ if (locked)
+ XFS_SB_UNLOCK(mp, s);
+ return ret;
+}
+
+STATIC int
+xfs_icsb_modify_counters(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field,
+ int delta,
+ int rsvd)
+{
+ return xfs_icsb_modify_counters_int(mp, field, delta, rsvd, 0);
+}
+
+/*
+ * Called when superblock is already locked
+ */
+STATIC int
+xfs_icsb_modify_counters_locked(
+ xfs_mount_t *mp,
+ xfs_sb_field_t field,
+ int delta,
+ int rsvd)
+{
+ return xfs_icsb_modify_counters_int(mp, field, delta,
+ rsvd, XFS_ICSB_SB_LOCKED);
+}
+#endif
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index cd3cf9613a0..ebd73960e9d 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -267,6 +267,34 @@ typedef struct xfs_ioops {
#define XFS_IODONE(vfsp) \
(*(mp)->m_io_ops.xfs_iodone)(vfsp)
+#ifdef HAVE_PERCPU_SB
+
+/*
+ * Valid per-cpu incore superblock counters. Note that if you add new counters,
+ * you may need to define new counter disabled bit field descriptors as there
+ * are more possible fields in the superblock that can fit in a bitfield on a
+ * 32 bit platform. The XFS_SBS_* values for the current current counters just
+ * fit.
+ */
+typedef struct xfs_icsb_cnts {
+ uint64_t icsb_fdblocks;
+ uint64_t icsb_ifree;
+ uint64_t icsb_icount;
+ unsigned long icsb_flags;
+} xfs_icsb_cnts_t;
+
+#define XFS_ICSB_FLAG_LOCK (1 << 0) /* counter lock bit */
+
+#define XFS_ICSB_SB_LOCKED (1 << 0) /* sb already locked */
+#define XFS_ICSB_LAZY_COUNT (1 << 1) /* accuracy not needed */
+
+extern int xfs_icsb_init_counters(struct xfs_mount *);
+extern void xfs_icsb_sync_counters_lazy(struct xfs_mount *);
+
+#else
+#define xfs_icsb_init_counters(mp) (0)
+#define xfs_icsb_sync_counters_lazy(mp) do { } while (0)
+#endif
typedef struct xfs_mount {
bhv_desc_t m_bhv; /* vfs xfs behavior */
@@ -372,6 +400,11 @@ typedef struct xfs_mount {
struct xfs_qmops m_qm_ops; /* vector of XQM ops */
struct xfs_ioops m_io_ops; /* vector of I/O ops */
atomic_t m_active_trans; /* number trans frozen */
+#ifdef HAVE_PERCPU_SB
+ xfs_icsb_cnts_t *m_sb_cnts; /* per-cpu superblock counters */
+ unsigned long m_icsb_counters; /* disabled per-cpu counters */
+ struct notifier_block m_icsb_notifier; /* hotplug cpu notifier */
+#endif
} xfs_mount_t;
/*
@@ -386,8 +419,6 @@ typedef struct xfs_mount {
#define XFS_MOUNT_FS_SHUTDOWN (1ULL << 4) /* atomic stop of all filesystem
operations, typically for
disk errors in metadata */
-#define XFS_MOUNT_NOATIME (1ULL << 5) /* don't modify inode access
- times on reads */
#define XFS_MOUNT_RETERR (1ULL << 6) /* return alignment errors to
user */
#define XFS_MOUNT_NOALIGN (1ULL << 7) /* turn off stripe alignment
@@ -411,6 +442,8 @@ typedef struct xfs_mount {
#define XFS_MOUNT_DIRSYNC (1ULL << 21) /* synchronous directory ops */
#define XFS_MOUNT_COMPAT_IOSIZE (1ULL << 22) /* don't report large preferred
* I/O size in stat() */
+#define XFS_MOUNT_NO_PERCPU_SB (1ULL << 23) /* don't use per-cpu superblock
+ counters */
/*
@@ -473,11 +506,6 @@ xfs_preferred_iosize(xfs_mount_t *mp)
#define XFS_SHUTDOWN_REMOTE_REQ 0x10 /* Shutdown came from remote cell */
/*
- * xflags for xfs_syncsub
- */
-#define XFS_XSYNC_RELOC 0x01
-
-/*
* Flags for xfs_mountfs
*/
#define XFS_MFSI_SECOND 0x01 /* Secondary mount -- skip stuff */
@@ -548,6 +576,8 @@ extern void xfs_unmountfs_close(xfs_mount_t *, struct cred *);
extern int xfs_unmountfs_writesb(xfs_mount_t *);
extern int xfs_unmount_flush(xfs_mount_t *, int);
extern int xfs_mod_incore_sb(xfs_mount_t *, xfs_sb_field_t, int, int);
+extern int xfs_mod_incore_sb_unlocked(xfs_mount_t *, xfs_sb_field_t,
+ int, int);
extern int xfs_mod_incore_sb_batch(xfs_mount_t *, xfs_mod_sb_t *,
uint, int);
extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int);
diff --git a/fs/xfs/xfs_rw.h b/fs/xfs/xfs_rw.h
index de85eefb796..e6379564447 100644
--- a/fs/xfs/xfs_rw.h
+++ b/fs/xfs/xfs_rw.h
@@ -89,6 +89,7 @@ extern void xfs_ioerror_alert(char *func, struct xfs_mount *mp,
*/
extern int xfs_rwlock(bhv_desc_t *bdp, vrwlock_t write_lock);
extern void xfs_rwunlock(bhv_desc_t *bdp, vrwlock_t write_lock);
+extern int xfs_setattr(bhv_desc_t *bdp, vattr_t *vap, int flags, cred_t *credp);
extern int xfs_change_file_space(bhv_desc_t *bdp, int cmd, xfs_flock64_t *bf,
xfs_off_t offset, cred_t *credp, int flags);
extern int xfs_set_dmattrs(bhv_desc_t *bdp, u_int evmask, u_int16_t state,
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index d3d714e6b32..2918956553a 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -55,10 +55,141 @@ STATIC void xfs_trans_committed(xfs_trans_t *, int);
STATIC void xfs_trans_chunk_committed(xfs_log_item_chunk_t *, xfs_lsn_t, int);
STATIC void xfs_trans_free(xfs_trans_t *);
-kmem_zone_t *xfs_trans_zone;
+kmem_zone_t *xfs_trans_zone;
/*
+ * Reservation functions here avoid a huge stack in xfs_trans_init
+ * due to register overflow from temporaries in the calculations.
+ */
+
+STATIC uint
+xfs_calc_write_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_itruncate_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_rename_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_link_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_LINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_remove_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_symlink_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_create_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_mkdir_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_ifree_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_ichange_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_growdata_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_GROWDATA_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtalloc_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_GROWRTALLOC_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtzero_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_GROWRTZERO_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_growrtfree_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_GROWRTFREE_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_swrite_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_SWRITE_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_writeid_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_WRITEID_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_addafork_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_attrinval_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ATTRINVAL_LOG_RES(mp);
+}
+
+STATIC uint
+xfs_calc_attrset_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_attrrm_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp);
+}
+
+STATIC uint
+xfs_calc_clear_agi_bucket_reservation(xfs_mount_t *mp)
+{
+ return XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp);
+}
+
+/*
* Initialize the precomputed transaction reservation values
* in the mount structure.
*/
@@ -69,39 +200,27 @@ xfs_trans_init(
xfs_trans_reservations_t *resp;
resp = &(mp->m_reservations);
- resp->tr_write =
- (uint)(XFS_CALC_WRITE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_itruncate =
- (uint)(XFS_CALC_ITRUNCATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_rename =
- (uint)(XFS_CALC_RENAME_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_link = (uint)XFS_CALC_LINK_LOG_RES(mp);
- resp->tr_remove =
- (uint)(XFS_CALC_REMOVE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_symlink =
- (uint)(XFS_CALC_SYMLINK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_create =
- (uint)(XFS_CALC_CREATE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_mkdir =
- (uint)(XFS_CALC_MKDIR_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_ifree =
- (uint)(XFS_CALC_IFREE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_ichange =
- (uint)(XFS_CALC_ICHANGE_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_growdata = (uint)XFS_CALC_GROWDATA_LOG_RES(mp);
- resp->tr_swrite = (uint)XFS_CALC_SWRITE_LOG_RES(mp);
- resp->tr_writeid = (uint)XFS_CALC_WRITEID_LOG_RES(mp);
- resp->tr_addafork =
- (uint)(XFS_CALC_ADDAFORK_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_attrinval = (uint)XFS_CALC_ATTRINVAL_LOG_RES(mp);
- resp->tr_attrset =
- (uint)(XFS_CALC_ATTRSET_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_attrrm =
- (uint)(XFS_CALC_ATTRRM_LOG_RES(mp) + XFS_DQUOT_LOGRES(mp));
- resp->tr_clearagi = (uint)XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp);
- resp->tr_growrtalloc = (uint)XFS_CALC_GROWRTALLOC_LOG_RES(mp);
- resp->tr_growrtzero = (uint)XFS_CALC_GROWRTZERO_LOG_RES(mp);
- resp->tr_growrtfree = (uint)XFS_CALC_GROWRTFREE_LOG_RES(mp);
+ resp->tr_write = xfs_calc_write_reservation(mp);
+ resp->tr_itruncate = xfs_calc_itruncate_reservation(mp);
+ resp->tr_rename = xfs_calc_rename_reservation(mp);
+ resp->tr_link = xfs_calc_link_reservation(mp);
+ resp->tr_remove = xfs_calc_remove_reservation(mp);
+ resp->tr_symlink = xfs_calc_symlink_reservation(mp);
+ resp->tr_create = xfs_calc_create_reservation(mp);
+ resp->tr_mkdir = xfs_calc_mkdir_reservation(mp);
+ resp->tr_ifree = xfs_calc_ifree_reservation(mp);
+ resp->tr_ichange = xfs_calc_ichange_reservation(mp);
+ resp->tr_growdata = xfs_calc_growdata_reservation(mp);
+ resp->tr_swrite = xfs_calc_swrite_reservation(mp);
+ resp->tr_writeid = xfs_calc_writeid_reservation(mp);
+ resp->tr_addafork = xfs_calc_addafork_reservation(mp);
+ resp->tr_attrinval = xfs_calc_attrinval_reservation(mp);
+ resp->tr_attrset = xfs_calc_attrset_reservation(mp);
+ resp->tr_attrrm = xfs_calc_attrrm_reservation(mp);
+ resp->tr_clearagi = xfs_calc_clear_agi_bucket_reservation(mp);
+ resp->tr_growrtalloc = xfs_calc_growrtalloc_reservation(mp);
+ resp->tr_growrtzero = xfs_calc_growrtzero_reservation(mp);
+ resp->tr_growrtfree = xfs_calc_growrtfree_reservation(mp);
}
/*
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index d77901c07f6..e48befa4e33 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -380,7 +380,7 @@ typedef struct xfs_trans {
xfs_trans_header_t t_header; /* header for in-log trans */
unsigned int t_busy_free; /* busy descs free */
xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */
- xfs_pflags_t t_pflags; /* saved pflags state */
+ unsigned long t_pflags; /* saved process flags state */
} xfs_trans_t;
#endif /* __KERNEL__ */
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index b6ad370fab3..d4ec4dfaf19 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -55,7 +55,7 @@
#include "xfs_clnt.h"
#include "xfs_fsops.h"
-STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
+STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
int
xfs_init(void)
@@ -77,11 +77,12 @@ xfs_init(void)
"xfs_bmap_free_item");
xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
"xfs_btree_cur");
- xfs_inode_zone = kmem_zone_init(sizeof(xfs_inode_t), "xfs_inode");
xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
xfs_da_state_zone =
kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state");
xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
+ xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
+ xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
/*
* The size of the zone allocated buf log item is the maximum
@@ -93,17 +94,30 @@ xfs_init(void)
(((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
NBWORD) * sizeof(int))),
"xfs_buf_item");
- xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
- ((XFS_EFD_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))),
+ xfs_efd_zone =
+ kmem_zone_init((sizeof(xfs_efd_log_item_t) +
+ ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
+ sizeof(xfs_extent_t))),
"xfs_efd_item");
- xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
- ((XFS_EFI_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))),
+ xfs_efi_zone =
+ kmem_zone_init((sizeof(xfs_efi_log_item_t) +
+ ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
+ sizeof(xfs_extent_t))),
"xfs_efi_item");
- xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
- xfs_ili_zone = kmem_zone_init(sizeof(xfs_inode_log_item_t), "xfs_ili");
- xfs_chashlist_zone = kmem_zone_init(sizeof(xfs_chashlist_t),
- "xfs_chashlist");
- xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
+
+ /*
+ * These zones warrant special memory allocator hints
+ */
+ xfs_inode_zone =
+ kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
+ KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
+ KM_ZONE_SPREAD, NULL);
+ xfs_ili_zone =
+ kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
+ KM_ZONE_SPREAD, NULL);
+ xfs_chashlist_zone =
+ kmem_zone_init_flags(sizeof(xfs_chashlist_t), "xfs_chashlist",
+ KM_ZONE_SPREAD, NULL);
/*
* Allocate global trace buffers.
@@ -176,18 +190,18 @@ xfs_cleanup(void)
ktrace_free(xfs_alloc_trace_buf);
#endif
- kmem_cache_destroy(xfs_bmap_free_item_zone);
- kmem_cache_destroy(xfs_btree_cur_zone);
- kmem_cache_destroy(xfs_inode_zone);
- kmem_cache_destroy(xfs_trans_zone);
- kmem_cache_destroy(xfs_da_state_zone);
- kmem_cache_destroy(xfs_dabuf_zone);
- kmem_cache_destroy(xfs_buf_item_zone);
- kmem_cache_destroy(xfs_efd_zone);
- kmem_cache_destroy(xfs_efi_zone);
- kmem_cache_destroy(xfs_ifork_zone);
- kmem_cache_destroy(xfs_ili_zone);
- kmem_cache_destroy(xfs_chashlist_zone);
+ kmem_zone_destroy(xfs_bmap_free_item_zone);
+ kmem_zone_destroy(xfs_btree_cur_zone);
+ kmem_zone_destroy(xfs_inode_zone);
+ kmem_zone_destroy(xfs_trans_zone);
+ kmem_zone_destroy(xfs_da_state_zone);
+ kmem_zone_destroy(xfs_dabuf_zone);
+ kmem_zone_destroy(xfs_buf_item_zone);
+ kmem_zone_destroy(xfs_efd_zone);
+ kmem_zone_destroy(xfs_efi_zone);
+ kmem_zone_destroy(xfs_ifork_zone);
+ kmem_zone_destroy(xfs_ili_zone);
+ kmem_zone_destroy(xfs_chashlist_zone);
}
/*
@@ -258,8 +272,6 @@ xfs_start_flags(
mp->m_inoadd = XFS_INO64_OFFSET;
}
#endif
- if (ap->flags & XFSMNT_NOATIME)
- mp->m_flags |= XFS_MOUNT_NOATIME;
if (ap->flags & XFSMNT_RETERR)
mp->m_flags |= XFS_MOUNT_RETERR;
if (ap->flags & XFSMNT_NOALIGN)
@@ -620,7 +632,7 @@ xfs_quiesce_fs(
xfs_mount_t *mp)
{
int count = 0, pincount;
-
+
xfs_refcache_purge_mp(mp);
xfs_flush_buftarg(mp->m_ddev_targp, 0);
xfs_finish_reclaim_all(mp, 0);
@@ -631,7 +643,7 @@ xfs_quiesce_fs(
* meta data (typically directory updates).
* Which then must be flushed and logged before
* we can write the unmount record.
- */
+ */
do {
xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL);
pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
@@ -654,11 +666,6 @@ xfs_mntupdate(
xfs_mount_t *mp = XFS_BHVTOM(bdp);
int error;
- if (args->flags & XFSMNT_NOATIME)
- mp->m_flags |= XFS_MOUNT_NOATIME;
- else
- mp->m_flags &= ~XFS_MOUNT_NOATIME;
-
if (args->flags & XFSMNT_BARRIER)
mp->m_flags |= XFS_MOUNT_BARRIER;
else
@@ -814,6 +821,7 @@ xfs_statvfs(
statp->f_type = XFS_SB_MAGIC;
+ xfs_icsb_sync_counters_lazy(mp);
s = XFS_SB_LOCK(mp);
statp->f_bsize = sbp->sb_blocksize;
lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
@@ -1221,7 +1229,7 @@ xfs_sync_inodes(
xfs_iunlock(ip, XFS_ILOCK_SHARED);
error = xfs_itobp(mp, NULL, ip,
- &dip, &bp, 0);
+ &dip, &bp, 0, 0);
if (!error) {
xfs_buf_relse(bp);
} else {
@@ -1690,10 +1698,7 @@ xfs_parseargs(
int iosize;
args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
-
-#if 0 /* XXX: off by default, until some remaining issues ironed out */
- args->flags |= XFSMNT_IDELETE; /* default to on */
-#endif
+ args->flags |= XFSMNT_IDELETE;
if (!options)
goto done;
@@ -1903,7 +1908,6 @@ xfs_showargs(
{ XFS_MOUNT_NOUUID, "," MNTOPT_NOUUID },
{ XFS_MOUNT_NORECOVERY, "," MNTOPT_NORECOVERY },
{ XFS_MOUNT_OSYNCISOSYNC, "," MNTOPT_OSYNCISOSYNC },
- { XFS_MOUNT_IDELETE, "," MNTOPT_NOIKEEP },
{ 0, NULL }
};
struct proc_xfs_info *xfs_infop;
@@ -1939,6 +1943,8 @@ xfs_showargs(
seq_printf(m, "," MNTOPT_SWIDTH "=%d",
(int)XFS_FSB_TO_BB(mp, mp->m_swidth));
+ if (!(mp->m_flags & XFS_MOUNT_IDELETE))
+ seq_printf(m, "," MNTOPT_IKEEP);
if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
seq_printf(m, "," MNTOPT_LARGEIO);
if (mp->m_flags & XFS_MOUNT_BARRIER)
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index eaab355f5a8..0f0a64e81db 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -615,6 +615,7 @@ xfs_setattr(
code = xfs_igrow_start(ip, vap->va_size, credp);
}
xfs_iunlock(ip, XFS_ILOCK_EXCL);
+ vn_iowait(vp); /* wait for the completion of any pending DIOs */
if (!code)
code = xfs_itruncate_data(ip, vap->va_size);
if (code) {
@@ -1334,7 +1335,7 @@ xfs_inactive_symlink_rmt(
*/
done = 0;
XFS_BMAP_INIT(&free_list, &first_block);
- nmaps = sizeof(mval) / sizeof(mval[0]);
+ nmaps = ARRAY_SIZE(mval);
if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size),
XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps,
&free_list)))
@@ -1556,7 +1557,7 @@ xfs_release(
if ((error = xfs_inactive_free_eofblocks(mp, ip)))
return error;
/* Update linux inode block count after free above */
- LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp,
+ vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp,
ip->i_d.di_nblocks + ip->i_delayed_blks);
}
}
@@ -1637,7 +1638,7 @@ xfs_inactive(
if ((error = xfs_inactive_free_eofblocks(mp, ip)))
return VN_INACTIVE_CACHE;
/* Update linux inode block count after free above */
- LINVFS_GET_IP(vp)->i_blocks = XFS_FSB_TO_BB(mp,
+ vn_to_inode(vp)->i_blocks = XFS_FSB_TO_BB(mp,
ip->i_d.di_nblocks + ip->i_delayed_blks);
}
goto out;
@@ -3186,7 +3187,7 @@ xfs_rmdir(
/* Fall through to std_return with error = 0 or the errno
* from xfs_trans_commit. */
-std_return:
+ std_return:
if (DM_EVENT_ENABLED(dir_vp->v_vfsp, dp, DM_EVENT_POSTREMOVE)) {
(void) XFS_SEND_NAMESP(mp, DM_EVENT_POSTREMOVE,
dir_vp, DM_RIGHT_NULL,
@@ -3196,12 +3197,12 @@ std_return:
}
return error;
-error1:
+ error1:
xfs_bmap_cancel(&free_list);
cancel_flags |= XFS_TRANS_ABORT;
/* FALLTHROUGH */
-error_return:
+ error_return:
xfs_trans_cancel(tp, cancel_flags);
goto std_return;
}
@@ -4310,8 +4311,10 @@ xfs_free_file_space(
ASSERT(attr_flags & ATTR_NOLOCK ? attr_flags & ATTR_DMI : 1);
if (attr_flags & ATTR_NOLOCK)
need_iolock = 0;
- if (need_iolock)
+ if (need_iolock) {
xfs_ilock(ip, XFS_IOLOCK_EXCL);
+ vn_iowait(vp); /* wait for the completion of any pending DIOs */
+ }
rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog),
(__uint8_t)NBPP);
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 0b54e9a4a8a..6dca3d54208 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -269,7 +269,7 @@ struct acpi_device_wakeup_state {
struct acpi_device_wakeup {
acpi_handle gpe_device;
- acpi_integer gpe_number;;
+ acpi_integer gpe_number;
acpi_integer sleep_state;
struct acpi_handle_list resources;
struct acpi_device_wakeup_state state;
@@ -330,6 +330,7 @@ int acpi_bus_register_driver(struct acpi_driver *driver);
int acpi_bus_unregister_driver(struct acpi_driver *driver);
int acpi_bus_add(struct acpi_device **child, struct acpi_device *parent,
acpi_handle handle, int type);
+int acpi_bus_trim(struct acpi_device *start, int rmdevice);
int acpi_bus_start(struct acpi_device *device);
int acpi_match_ids(struct acpi_device *device, char *ids);
diff --git a/include/asm-alpha/io.h b/include/asm-alpha/io.h
index 871dd7ad909..3ebbeee753e 100644
--- a/include/asm-alpha/io.h
+++ b/include/asm-alpha/io.h
@@ -534,9 +534,6 @@ extern void outsl (unsigned long port, const void *src, unsigned long count);
#define eth_io_copy_and_sum(skb,src,len,unused) \
memcpy_fromio((skb)->data,src,len)
-#define isa_eth_io_copy_and_sum(skb,src,len,unused) \
- isa_memcpy_fromio((skb)->data,src,len)
-
static inline int
check_signature(const volatile void __iomem *io_addr,
const unsigned char *signature, int length)
@@ -550,87 +547,6 @@ check_signature(const volatile void __iomem *io_addr,
return 1;
}
-
-/*
- * ISA space is mapped to some machine-specific location on Alpha.
- * Call into the existing hooks to get the address translated.
- */
-
-static inline u8
-isa_readb(unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 1);
- u8 ret = readb(addr);
- iounmap(addr);
- return ret;
-}
-
-static inline u16
-isa_readw(unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 2);
- u16 ret = readw(addr);
- iounmap(addr);
- return ret;
-}
-
-static inline u32
-isa_readl(unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 2);
- u32 ret = readl(addr);
- iounmap(addr);
- return ret;
-}
-
-static inline void
-isa_writeb(u8 b, unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 2);
- writeb(b, addr);
- iounmap(addr);
-}
-
-static inline void
-isa_writew(u16 w, unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 2);
- writew(w, addr);
- iounmap(addr);
-}
-
-static inline void
-isa_writel(u32 l, unsigned long offset)
-{
- void __iomem *addr = ioremap(offset, 2);
- writel(l, addr);
- iounmap(addr);
-}
-
-static inline void
-isa_memset_io(unsigned long offset, u8 val, long n)
-{
- void __iomem *addr = ioremap(offset, n);
- memset_io(addr, val, n);
- iounmap(addr);
-}
-
-static inline void
-isa_memcpy_fromio(void *dest, unsigned long offset, long n)
-{
- void __iomem *addr = ioremap(offset, n);
- memcpy_fromio(dest, addr, n);
- iounmap(addr);
-}
-
-static inline void
-isa_memcpy_toio(unsigned long offset, const void *src, long n)
-{
- void __iomem *addr = ioremap(offset, n);
- memcpy_toio(addr, src, n);
- iounmap(addr);
-}
-
/*
* The Alpha Jensen hardware for some rather strange reason puts
* the RTC clock at 0x170 instead of 0x70. Probably due to some
diff --git a/include/asm-alpha/mmu_context.h b/include/asm-alpha/mmu_context.h
index 6f92482cc96..0c017fc181c 100644
--- a/include/asm-alpha/mmu_context.h
+++ b/include/asm-alpha/mmu_context.h
@@ -231,9 +231,8 @@ init_new_context(struct task_struct *tsk, struct mm_struct *mm)
{
int i;
- for (i = 0; i < NR_CPUS; i++)
- if (cpu_online(i))
- mm->context[i] = 0;
+ for_each_online_cpu(i)
+ mm->context[i] = 0;
if (tsk != current)
task_thread_info(tsk)->pcb.ptbr
= ((unsigned long)mm->pgd - IDENT_ADDR) >> PAGE_SHIFT;
diff --git a/include/asm-alpha/poll.h b/include/asm-alpha/poll.h
index 34f333b762a..95707182b3e 100644
--- a/include/asm-alpha/poll.h
+++ b/include/asm-alpha/poll.h
@@ -13,6 +13,8 @@
#define POLLWRBAND (1 << 9)
#define POLLMSG (1 << 10)
#define POLLREMOVE (1 << 11)
+#define POLLRDHUP (1 << 12)
+
struct pollfd {
int fd;
diff --git a/include/asm-alpha/topology.h b/include/asm-alpha/topology.h
index eb740e280d9..420ccde6b91 100644
--- a/include/asm-alpha/topology.h
+++ b/include/asm-alpha/topology.h
@@ -27,8 +27,8 @@ static inline cpumask_t node_to_cpumask(int node)
cpumask_t node_cpu_mask = CPU_MASK_NONE;
int cpu;
- for(cpu = 0; cpu < NR_CPUS; cpu++) {
- if (cpu_online(cpu) && (cpu_to_node(cpu) == node))
+ for_each_online_cpu(cpu) {
+ if (cpu_to_node(cpu) == node)
cpu_set(cpu, node_cpu_mask);
}
diff --git a/include/asm-arm/arch-aaec2000/param.h b/include/asm-arm/arch-aaec2000/param.h
deleted file mode 100644
index 139936c2faf..00000000000
--- a/include/asm-arm/arch-aaec2000/param.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * linux/include/asm-arm/arch-aaec2000/param.h
- *
- * Copyright (c) 2005 Nicolas Bellido Y Ortega
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARCH_PARAM_H
-#define __ASM_ARCH_PARAM_H
-
-#endif /* __ASM_ARCH_PARAM_H */
-
diff --git a/include/asm-arm/arch-at91rm9200/at91rm9200_emac.h b/include/asm-arm/arch-at91rm9200/at91rm9200_emac.h
new file mode 100644
index 00000000000..fbc091e61e2
--- /dev/null
+++ b/include/asm-arm/arch-at91rm9200/at91rm9200_emac.h
@@ -0,0 +1,138 @@
+/*
+ * include/asm-arm/arch-at91rm9200/at91rm9200_emac.h
+ *
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * Ethernet MAC registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef AT91RM9200_EMAC_H
+#define AT91RM9200_EMAC_H
+
+#define AT91_EMAC_CTL 0x00 /* Control Register */
+#define AT91_EMAC_LB (1 << 0) /* Loopback */
+#define AT91_EMAC_LBL (1 << 1) /* Loopback Local */
+#define AT91_EMAC_RE (1 << 2) /* Receive Enable */
+#define AT91_EMAC_TE (1 << 3) /* Transmit Enable */
+#define AT91_EMAC_MPE (1 << 4) /* Management Port Enable */
+#define AT91_EMAC_CSR (1 << 5) /* Clear Statistics Registers */
+#define AT91_EMAC_INCSTAT (1 << 6) /* Increment Statistics Registers */
+#define AT91_EMAC_WES (1 << 7) /* Write Enable for Statistics Registers */
+#define AT91_EMAC_BP (1 << 8) /* Back Pressure */
+
+#define AT91_EMAC_CFG 0x04 /* Configuration Register */
+#define AT91_EMAC_SPD (1 << 0) /* Speed */
+#define AT91_EMAC_FD (1 << 1) /* Full Duplex */
+#define AT91_EMAC_BR (1 << 2) /* Bit Rate */
+#define AT91_EMAC_CAF (1 << 4) /* Copy All Frames */
+#define AT91_EMAC_NBC (1 << 5) /* No Broadcast */
+#define AT91_EMAC_MTI (1 << 6) /* Multicast Hash Enable */
+#define AT91_EMAC_UNI (1 << 7) /* Unicast Hash Enable */
+#define AT91_EMAC_BIG (1 << 8) /* Receive 1522 Bytes */
+#define AT91_EMAC_EAE (1 << 9) /* External Address Match Enable */
+#define AT91_EMAC_CLK (3 << 10) /* MDC Clock Divisor */
+#define AT91_EMAC_CLK_DIV8 (0 << 10)
+#define AT91_EMAC_CLK_DIV16 (1 << 10)
+#define AT91_EMAC_CLK_DIV32 (2 << 10)
+#define AT91_EMAC_CLK_DIV64 (3 << 10)
+#define AT91_EMAC_RTY (1 << 12) /* Retry Test */
+#define AT91_EMAC_RMII (1 << 13) /* Reduce MII (RMII) */
+
+#define AT91_EMAC_SR 0x08 /* Status Register */
+#define AT91_EMAC_SR_LINK (1 << 0) /* Link */
+#define AT91_EMAC_SR_MDIO (1 << 1) /* MDIO pin */
+#define AT91_EMAC_SR_IDLE (1 << 2) /* PHY idle */
+
+#define AT91_EMAC_TAR 0x0c /* Transmit Address Register */
+
+#define AT91_EMAC_TCR 0x10 /* Transmit Control Register */
+#define AT91_EMAC_LEN (0x7ff << 0) /* Transmit Frame Length */
+#define AT91_EMAC_NCRC (1 << 15) /* No CRC */
+
+#define AT91_EMAC_TSR 0x14 /* Transmit Status Register */
+#define AT91_EMAC_TSR_OVR (1 << 0) /* Transmit Buffer Overrun */
+#define AT91_EMAC_TSR_COL (1 << 1) /* Collision Occurred */
+#define AT91_EMAC_TSR_RLE (1 << 2) /* Retry Limit Exceeded */
+#define AT91_EMAC_TSR_IDLE (1 << 3) /* Transmitter Idle */
+#define AT91_EMAC_TSR_BNQ (1 << 4) /* Transmit Buffer not Queued */
+#define AT91_EMAC_TSR_COMP (1 << 5) /* Transmit Complete */
+#define AT91_EMAC_TSR_UND (1 << 6) /* Transmit Underrun */
+
+#define AT91_EMAC_RBQP 0x18 /* Receive Buffer Queue Pointer */
+
+#define AT91_EMAC_RSR 0x20 /* Receive Status Register */
+#define AT91_EMAC_RSR_BNA (1 << 0) /* Buffer Not Available */
+#define AT91_EMAC_RSR_REC (1 << 1) /* Frame Received */
+#define AT91_EMAC_RSR_OVR (1 << 2) /* RX Overrun */
+
+#define AT91_EMAC_ISR 0x24 /* Interrupt Status Register */
+#define AT91_EMAC_DONE (1 << 0) /* Management Done */
+#define AT91_EMAC_RCOM (1 << 1) /* Receive Complete */
+#define AT91_EMAC_RBNA (1 << 2) /* Receive Buffer Not Available */
+#define AT91_EMAC_TOVR (1 << 3) /* Transmit Buffer Overrun */
+#define AT91_EMAC_TUND (1 << 4) /* Transmit Buffer Underrun */
+#define AT91_EMAC_RTRY (1 << 5) /* Retry Limit */
+#define AT91_EMAC_TBRE (1 << 6) /* Transmit Buffer Register Empty */
+#define AT91_EMAC_TCOM (1 << 7) /* Transmit Complete */
+#define AT91_EMAC_TIDLE (1 << 8) /* Transmit Idle */
+#define AT91_EMAC_LINK (1 << 9) /* Link */
+#define AT91_EMAC_ROVR (1 << 10) /* RX Overrun */
+#define AT91_EMAC_ABT (1 << 11) /* Abort */
+
+#define AT91_EMAC_IER 0x28 /* Interrupt Enable Register */
+#define AT91_EMAC_IDR 0x2c /* Interrupt Disable Register */
+#define AT91_EMAC_IMR 0x30 /* Interrupt Mask Register */
+
+#define AT91_EMAC_MAN 0x34 /* PHY Maintenance Register */
+#define AT91_EMAC_DATA (0xffff << 0) /* MDIO Data */
+#define AT91_EMAC_REGA (0x1f << 18) /* MDIO Register */
+#define AT91_EMAC_PHYA (0x1f << 23) /* MDIO PHY Address */
+#define AT91_EMAC_RW (3 << 28) /* Read/Write operation */
+#define AT91_EMAC_RW_W (1 << 28)
+#define AT91_EMAC_RW_R (2 << 28)
+#define AT91_EMAC_MAN_802_3 0x40020000 /* IEEE 802.3 value */
+
+/*
+ * Statistics Registers.
+ */
+#define AT91_EMAC_FRA 0x40 /* Frames Transmitted OK */
+#define AT91_EMAC_SCOL 0x44 /* Single Collision Frame */
+#define AT91_EMAC_MCOL 0x48 /* Multiple Collision Frame */
+#define AT91_EMAC_OK 0x4c /* Frames Received OK */
+#define AT91_EMAC_SEQE 0x50 /* Frame Check Sequence Error */
+#define AT91_EMAC_ALE 0x54 /* Alignmemt Error */
+#define AT91_EMAC_DTE 0x58 /* Deffered Transmission Frame */
+#define AT91_EMAC_LCOL 0x5c /* Late Collision */
+#define AT91_EMAC_ECOL 0x60 /* Excessive Collision */
+#define AT91_EMAC_TUE 0x64 /* Transmit Underrun Error */
+#define AT91_EMAC_CSE 0x68 /* Carrier Sense Error */
+#define AT91_EMAC_DRFC 0x6c /* Discard RX Frame */
+#define AT91_EMAC_ROV 0x70 /* Receive Overrun */
+#define AT91_EMAC_CDE 0x74 /* Code Error */
+#define AT91_EMAC_ELR 0x78 /* Excessive Length Error */
+#define AT91_EMAC_RJB 0x7c /* Receive Jabber */
+#define AT91_EMAC_USF 0x80 /* Undersize Frame */
+#define AT91_EMAC_SQEE 0x84 /* SQE Test Error */
+
+/*
+ * Address Registers.
+ */
+#define AT91_EMAC_HSL 0x90 /* Hash Address Low [31:0] */
+#define AT91_EMAC_HSH 0x94 /* Hash Address High [63:32] */
+#define AT91_EMAC_SA1L 0x98 /* Specific Address 1 Low, bytes 0-3 */
+#define AT91_EMAC_SA1H 0x9c /* Specific Address 1 High, bytes 4-5 */
+#define AT91_EMAC_SA2L 0xa0 /* Specific Address 2 Low, bytes 0-3 */
+#define AT91_EMAC_SA2H 0xa4 /* Specific Address 2 High, bytes 4-5 */
+#define AT91_EMAC_SA3L 0xa8 /* Specific Address 3 Low, bytes 0-3 */
+#define AT91_EMAC_SA3H 0xac /* Specific Address 3 High, bytes 4-5 */
+#define AT91_EMAC_SA4L 0xb0 /* Specific Address 4 Low, bytes 0-3 */
+#define AT91_EMAC_SA4H 0xb4 /* Specific Address 4 High, bytes 4-5 */
+
+#endif
diff --git a/include/asm-arm/arch-at91rm9200/param.h b/include/asm-arm/arch-at91rm9200/param.h
deleted file mode 100644
index 9480f844685..00000000000
--- a/include/asm-arm/arch-at91rm9200/param.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * include/asm-arm/arch-at91rm9200/param.h
- *
- * Copyright (C) 2003 SAN People
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __ASM_ARCH_PARAM_H
-#define __ASM_ARCH_PARAM_H
-
-/*
- * We use default params
- */
-
-#endif
diff --git a/include/asm-arm/arch-cl7500/debug-macro.S b/include/asm-arm/arch-cl7500/debug-macro.S
index a5d489d7955..9a2b67d2409 100644
--- a/include/asm-arm/arch-cl7500/debug-macro.S
+++ b/include/asm-arm/arch-cl7500/debug-macro.S
@@ -17,15 +17,5 @@
orr \rx, \rx, #0x00000be0
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro busyuart,rd,rx
- .endm
-
- .macro waituart,rd,rx
-1001: ldrb \rd, [\rx, #0x14]
- tst \rd, #0x20
- beq 1001b
- .endm
+#define UART_SHIFT 2
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-cl7500/param.h b/include/asm-arm/arch-cl7500/param.h
deleted file mode 100644
index 974bf69fbb1..00000000000
--- a/include/asm-arm/arch-cl7500/param.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- * linux/include/asm-arm/arch-cl7500/param.h
- *
- * Copyright (C) 1999 Nexus Electronics Ltd
- */
diff --git a/include/asm-arm/arch-clps711x/param.h b/include/asm-arm/arch-clps711x/param.h
deleted file mode 100644
index 86f6bd29623..00000000000
--- a/include/asm-arm/arch-clps711x/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-clps711x/param.h
- *
- * Copyright (C) 2000 Deep Blue Solutions Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/include/asm-arm/arch-ebsa110/debug-macro.S b/include/asm-arm/arch-ebsa110/debug-macro.S
index dcd03a40c50..f61cadabe0e 100644
--- a/include/asm-arm/arch-ebsa110/debug-macro.S
+++ b/include/asm-arm/arch-ebsa110/debug-macro.S
@@ -16,19 +16,6 @@
orr \rx, \rx, #0x00000be0
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro busyuart,rd,rx
-1002: ldrb \rd, [\rx, #0x14]
- and \rd, \rd, #0x60
- teq \rd, #0x60
- bne 1002b
- .endm
-
- .macro waituart,rd,rx
-1001: ldrb \rd, [\rx, #0x18]
- tst \rd, #0x10
- beq 1001b
- .endm
+#define UART_SHIFT 2
+#define FLOW_CONTROL
+#include <asm/hardware/debug-8250.h>
diff --git a/include/asm-arm/arch-ebsa110/param.h b/include/asm-arm/arch-ebsa110/param.h
deleted file mode 100644
index be19b08d1c7..00000000000
--- a/include/asm-arm/arch-ebsa110/param.h
+++ /dev/null
@@ -1,4 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ebsa110/param.h
- */
-#define HZ 200
diff --git a/include/asm-arm/arch-ebsa285/debug-macro.S b/include/asm-arm/arch-ebsa285/debug-macro.S
index 97d15fc629a..b48cec4a0c4 100644
--- a/include/asm-arm/arch-ebsa285/debug-macro.S
+++ b/include/asm-arm/arch-ebsa285/debug-macro.S
@@ -23,22 +23,10 @@
orr \rx, \rx, #0x000003f8
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
+#define UART_SHIFT 0
+#define FLOW_CONTROL
+#include <asm/hardware/debug-8250.S>
- .macro busyuart,rd,rx
-1002: ldrb \rd, [\rx, #0x5]
- and \rd, \rd, #0x60
- teq \rd, #0x60
- bne 1002b
- .endm
-
- .macro waituart,rd,rx
-1001: ldrb \rd, [\rx, #0x6]
- tst \rd, #0x10
- beq 1001b
- .endm
#else
/* For EBSA285 debugging */
.equ dc21285_high, ARMCSR_BASE & 0xff000000
diff --git a/include/asm-arm/arch-ebsa285/param.h b/include/asm-arm/arch-ebsa285/param.h
deleted file mode 100644
index 3827103b27a..00000000000
--- a/include/asm-arm/arch-ebsa285/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ebsa285/param.h
- */
diff --git a/include/asm-arm/arch-ep93xx/debug-macro.S b/include/asm-arm/arch-ep93xx/debug-macro.S
new file mode 100644
index 00000000000..397565a0c67
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/debug-macro.S
@@ -0,0 +1,22 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/debug-macro.S
+ * Debugging macro include header
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+#include <asm/arch/ep93xx-regs.h>
+
+ .macro addruart,rx
+ mrc p15, 0, \rx, c1, c0
+ tst \rx, #1 @ MMU enabled?
+ ldreq \rx, =EP93XX_APB_PHYS_BASE @ Physical base
+ ldrne \rx, =EP93XX_APB_VIRT_BASE @ virtual base
+ orr \rx, \rx, #0x000c0000
+ .endm
+
+#include <asm/hardware/debug-pl01x.S>
diff --git a/include/asm-arm/arch-ep93xx/dma.h b/include/asm-arm/arch-ep93xx/dma.h
new file mode 100644
index 00000000000..898b3ab7fd4
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/dma.h
@@ -0,0 +1,3 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/dma.h
+ */
diff --git a/include/asm-arm/arch-ep93xx/entry-macro.S b/include/asm-arm/arch-ep93xx/entry-macro.S
new file mode 100644
index 00000000000..84140a28dfc
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/entry-macro.S
@@ -0,0 +1,53 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/entry-macro.S
+ * IRQ demultiplexing for EP93xx
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+#include <asm/arch/ep93xx-regs.h>
+
+ .macro disable_fiq
+ .endm
+
+ .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
+ ldr \base, =(EP93XX_AHB_VIRT_BASE)
+ orr \base, \base, #0x000b0000
+ mov \irqnr, #0
+ ldr \irqstat, [\base] @ lower 32 interrupts
+ cmp \irqstat, #0
+ bne 1001f
+
+ eor \base, \base, #0x00070000
+ ldr \irqstat, [\base] @ upper 32 interrupts
+ cmp \irqstat, #0
+ beq 1002f
+ mov \irqnr, #0x20
+
+1001:
+ movs \tmp, \irqstat, lsl #16
+ movne \irqstat, \tmp
+ addeq \irqnr, \irqnr, #16
+
+ movs \tmp, \irqstat, lsl #8
+ movne \irqstat, \tmp
+ addeq \irqnr, \irqnr, #8
+
+ movs \tmp, \irqstat, lsl #4
+ movne \irqstat, \tmp
+ addeq \irqnr, \irqnr, #4
+
+ movs \tmp, \irqstat, lsl #2
+ movne \irqstat, \tmp
+ addeq \irqnr, \irqnr, #2
+
+ movs \tmp, \irqstat, lsl #1
+ addeq \irqnr, \irqnr, #1
+ orrs \base, \base, #1
+
+1002:
+ .endm
diff --git a/include/asm-arm/arch-ep93xx/ep93xx-regs.h b/include/asm-arm/arch-ep93xx/ep93xx-regs.h
new file mode 100644
index 00000000000..71cea0b5841
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/ep93xx-regs.h
@@ -0,0 +1,125 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/ep93xx-regs.h
+ */
+
+#ifndef __ASM_ARCH_EP93XX_REGS_H
+#define __ASM_ARCH_EP93XX_REGS_H
+
+/*
+ * EP93xx linux memory map:
+ *
+ * virt phys size
+ * fe800000 5M per-platform mappings
+ * fed00000 80800000 2M APB
+ * fef00000 80000000 1M AHB
+ */
+
+#define EP93XX_AHB_PHYS_BASE 0x80000000
+#define EP93XX_AHB_VIRT_BASE 0xfef00000
+#define EP93XX_AHB_SIZE 0x00100000
+
+#define EP93XX_APB_PHYS_BASE 0x80800000
+#define EP93XX_APB_VIRT_BASE 0xfed00000
+#define EP93XX_APB_SIZE 0x00200000
+
+
+/* AHB peripherals */
+#define EP93XX_DMA_BASE (EP93XX_AHB_VIRT_BASE + 0x00000000)
+
+#define EP93XX_ETHERNET_BASE (EP93XX_AHB_VIRT_BASE + 0x00010000)
+
+#define EP93XX_USB_BASE (EP93XX_AHB_VIRT_BASE + 0x00020000)
+#define EP93XX_USB_PHYS_BASE (EP93XX_AHB_PHYS_BASE + 0x00020000)
+
+#define EP93XX_RASTER_BASE (EP93XX_AHB_VIRT_BASE + 0x00030000)
+
+#define EP93XX_GRAPHICS_ACCEL_BASE (EP93XX_AHB_VIRT_BASE + 0x00040000)
+
+#define EP93XX_SDRAM_CONTROLLER_BASE (EP93XX_AHB_VIRT_BASE + 0x00060000)
+
+#define EP93XX_PCMCIA_CONTROLLER_BASE (EP93XX_AHB_VIRT_BASE + 0x00080000)
+
+#define EP93XX_BOOT_ROM_BASE (EP93XX_AHB_VIRT_BASE + 0x00090000)
+
+#define EP93XX_IDE_BASE (EP93XX_AHB_VIRT_BASE + 0x000a0000)
+
+#define EP93XX_VIC1_BASE (EP93XX_AHB_VIRT_BASE + 0x000b0000)
+
+#define EP93XX_VIC2_BASE (EP93XX_AHB_VIRT_BASE + 0x000c0000)
+
+
+/* APB peripherals */
+#define EP93XX_TIMER_BASE (EP93XX_APB_VIRT_BASE + 0x00010000)
+#define EP93XX_TIMER_REG(x) (EP93XX_TIMER_BASE + (x))
+#define EP93XX_TIMER1_LOAD EP93XX_TIMER_REG(0x00)
+#define EP93XX_TIMER1_VALUE EP93XX_TIMER_REG(0x04)
+#define EP93XX_TIMER1_CONTROL EP93XX_TIMER_REG(0x08)
+#define EP93XX_TIMER1_CLEAR EP93XX_TIMER_REG(0x0c)
+#define EP93XX_TIMER2_LOAD EP93XX_TIMER_REG(0x20)
+#define EP93XX_TIMER2_VALUE EP93XX_TIMER_REG(0x24)
+#define EP93XX_TIMER2_CONTROL EP93XX_TIMER_REG(0x28)
+#define EP93XX_TIMER2_CLEAR EP93XX_TIMER_REG(0x2c)
+#define EP93XX_TIMER4_VALUE_LOW EP93XX_TIMER_REG(0x60)
+#define EP93XX_TIMER4_VALUE_HIGH EP93XX_TIMER_REG(0x64)
+#define EP93XX_TIMER3_LOAD EP93XX_TIMER_REG(0x80)
+#define EP93XX_TIMER3_VALUE EP93XX_TIMER_REG(0x84)
+#define EP93XX_TIMER3_CONTROL EP93XX_TIMER_REG(0x88)
+#define EP93XX_TIMER3_CLEAR EP93XX_TIMER_REG(0x8c)
+
+#define EP93XX_I2S_BASE (EP93XX_APB_VIRT_BASE + 0x00020000)
+
+#define EP93XX_SECURITY_BASE (EP93XX_APB_VIRT_BASE + 0x00030000)
+
+#define EP93XX_GPIO_BASE (EP93XX_APB_VIRT_BASE + 0x00040000)
+#define EP93XX_GPIO_REG(x) (EP93XX_GPIO_BASE + (x))
+#define EP93XX_GPIO_A_INT_TYPE1 EP93XX_GPIO_REG(0x90)
+#define EP93XX_GPIO_A_INT_TYPE2 EP93XX_GPIO_REG(0x94)
+#define EP93XX_GPIO_A_INT_ACK EP93XX_GPIO_REG(0x98)
+#define EP93XX_GPIO_A_INT_ENABLE EP93XX_GPIO_REG(0x9c)
+#define EP93XX_GPIO_A_INT_STATUS EP93XX_GPIO_REG(0xa0)
+#define EP93XX_GPIO_B_INT_TYPE1 EP93XX_GPIO_REG(0xac)
+#define EP93XX_GPIO_B_INT_TYPE2 EP93XX_GPIO_REG(0xb0)
+#define EP93XX_GPIO_B_INT_ACK EP93XX_GPIO_REG(0xb4)
+#define EP93XX_GPIO_B_INT_ENABLE EP93XX_GPIO_REG(0xb8)
+#define EP93XX_GPIO_B_INT_STATUS EP93XX_GPIO_REG(0xbc)
+
+#define EP93XX_AAC_BASE (EP93XX_APB_VIRT_BASE + 0x00080000)
+
+#define EP93XX_SPI_BASE (EP93XX_APB_VIRT_BASE + 0x000a0000)
+
+#define EP93XX_IRDA_BASE (EP93XX_APB_VIRT_BASE + 0x000b0000)
+
+#define EP93XX_UART1_BASE (EP93XX_APB_VIRT_BASE + 0x000c0000)
+#define EP93XX_UART1_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000c0000)
+
+#define EP93XX_UART2_BASE (EP93XX_APB_VIRT_BASE + 0x000d0000)
+#define EP93XX_UART2_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000d0000)
+
+#define EP93XX_UART3_BASE (EP93XX_APB_VIRT_BASE + 0x000e0000)
+#define EP93XX_UART3_PHYS_BASE (EP93XX_APB_PHYS_BASE + 0x000e0000)
+
+#define EP93XX_KEY_MATRIX_BASE (EP93XX_APB_VIRT_BASE + 0x000f0000)
+
+#define EP93XX_ADC_BASE (EP93XX_APB_VIRT_BASE + 0x00100000)
+#define EP93XX_TOUCHSCREEN_BASE (EP93XX_APB_VIRT_BASE + 0x00100000)
+
+#define EP93XX_PWM_BASE (EP93XX_APB_VIRT_BASE + 0x00110000)
+
+#define EP93XX_RTC_BASE (EP93XX_APB_VIRT_BASE + 0x00120000)
+
+#define EP93XX_SYSCON_BASE (EP93XX_APB_VIRT_BASE + 0x00130000)
+#define EP93XX_SYSCON_REG(x) (EP93XX_SYSCON_BASE + (x))
+#define EP93XX_SYSCON_POWER_STATE EP93XX_SYSCON_REG(0x00)
+#define EP93XX_SYSCON_CLOCK_CONTROL EP93XX_SYSCON_REG(0x04)
+#define EP93XX_SYSCON_CLOCK_UARTBAUD 0x20000000
+#define EP93XX_SYSCON_CLOCK_USH_EN 0x10000000
+#define EP93XX_SYSCON_HALT EP93XX_SYSCON_REG(0x08)
+#define EP93XX_SYSCON_STANDBY EP93XX_SYSCON_REG(0x0c)
+#define EP93XX_SYSCON_DEVICE_CONFIG EP93XX_SYSCON_REG(0x80)
+#define EP93XX_SYSCON_DEVICE_CONFIG_CRUNCH_ENABLE 0x00800000
+#define EP93XX_SYSCON_SWLOCK EP93XX_SYSCON_REG(0xc0)
+
+#define EP93XX_WATCHDOG_BASE (EP93XX_APB_VIRT_BASE + 0x00140000)
+
+
+#endif
diff --git a/include/asm-arm/arch-ep93xx/gesbc9312.h b/include/asm-arm/arch-ep93xx/gesbc9312.h
new file mode 100644
index 00000000000..4d0b3023bff
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/gesbc9312.h
@@ -0,0 +1,3 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/gesbc9312.h
+ */
diff --git a/include/asm-arm/arch-ep93xx/gpio.h b/include/asm-arm/arch-ep93xx/gpio.h
new file mode 100644
index 00000000000..1ee14a14cba
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/gpio.h
@@ -0,0 +1,107 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/gpio.h
+ */
+
+#ifndef __ASM_ARCH_GPIO_H
+#define __ASM_ARCH_GPIO_H
+
+#define GPIO_IN 0
+#define GPIO_OUT 1
+
+#define EP93XX_GPIO_LOW 0
+#define EP93XX_GPIO_HIGH 1
+
+extern void gpio_line_config(int line, int direction);
+extern int gpio_line_get(int line);
+extern void gpio_line_set(int line, int value);
+
+/* GPIO port A. */
+#define EP93XX_GPIO_LINE_A(x) ((x) + 0)
+#define EP93XX_GPIO_LINE_EGPIO0 EP93XX_GPIO_LINE_A(0)
+#define EP93XX_GPIO_LINE_EGPIO1 EP93XX_GPIO_LINE_A(1)
+#define EP93XX_GPIO_LINE_EGPIO2 EP93XX_GPIO_LINE_A(2)
+#define EP93XX_GPIO_LINE_EGPIO3 EP93XX_GPIO_LINE_A(3)
+#define EP93XX_GPIO_LINE_EGPIO4 EP93XX_GPIO_LINE_A(4)
+#define EP93XX_GPIO_LINE_EGPIO5 EP93XX_GPIO_LINE_A(5)
+#define EP93XX_GPIO_LINE_EGPIO6 EP93XX_GPIO_LINE_A(6)
+#define EP93XX_GPIO_LINE_EGPIO7 EP93XX_GPIO_LINE_A(7)
+
+/* GPIO port B. */
+#define EP93XX_GPIO_LINE_B(x) ((x) + 8)
+#define EP93XX_GPIO_LINE_EGPIO8 EP93XX_GPIO_LINE_B(0)
+#define EP93XX_GPIO_LINE_EGPIO9 EP93XX_GPIO_LINE_B(1)
+#define EP93XX_GPIO_LINE_EGPIO10 EP93XX_GPIO_LINE_B(2)
+#define EP93XX_GPIO_LINE_EGPIO11 EP93XX_GPIO_LINE_B(3)
+#define EP93XX_GPIO_LINE_EGPIO12 EP93XX_GPIO_LINE_B(4)
+#define EP93XX_GPIO_LINE_EGPIO13 EP93XX_GPIO_LINE_B(5)
+#define EP93XX_GPIO_LINE_EGPIO14 EP93XX_GPIO_LINE_B(6)
+#define EP93XX_GPIO_LINE_EGPIO15 EP93XX_GPIO_LINE_B(7)
+
+/* GPIO port C. */
+#define EP93XX_GPIO_LINE_C(x) ((x) + 16)
+#define EP93XX_GPIO_LINE_ROW0 EP93XX_GPIO_LINE_C(0)
+#define EP93XX_GPIO_LINE_ROW1 EP93XX_GPIO_LINE_C(1)
+#define EP93XX_GPIO_LINE_ROW2 EP93XX_GPIO_LINE_C(2)
+#define EP93XX_GPIO_LINE_ROW3 EP93XX_GPIO_LINE_C(3)
+#define EP93XX_GPIO_LINE_ROW4 EP93XX_GPIO_LINE_C(4)
+#define EP93XX_GPIO_LINE_ROW5 EP93XX_GPIO_LINE_C(5)
+#define EP93XX_GPIO_LINE_ROW6 EP93XX_GPIO_LINE_C(6)
+#define EP93XX_GPIO_LINE_ROW7 EP93XX_GPIO_LINE_C(7)
+
+/* GPIO port D. */
+#define EP93XX_GPIO_LINE_D(x) ((x) + 24)
+#define EP93XX_GPIO_LINE_COL0 EP93XX_GPIO_LINE_D(0)
+#define EP93XX_GPIO_LINE_COL1 EP93XX_GPIO_LINE_D(1)
+#define EP93XX_GPIO_LINE_COL2 EP93XX_GPIO_LINE_D(2)
+#define EP93XX_GPIO_LINE_COL3 EP93XX_GPIO_LINE_D(3)
+#define EP93XX_GPIO_LINE_COL4 EP93XX_GPIO_LINE_D(4)
+#define EP93XX_GPIO_LINE_COL5 EP93XX_GPIO_LINE_D(5)
+#define EP93XX_GPIO_LINE_COL6 EP93XX_GPIO_LINE_D(6)
+#define EP93XX_GPIO_LINE_COL7 EP93XX_GPIO_LINE_D(7)
+
+/* GPIO port E. */
+#define EP93XX_GPIO_LINE_E(x) ((x) + 32)
+#define EP93XX_GPIO_LINE_GRLED EP93XX_GPIO_LINE_E(0)
+#define EP93XX_GPIO_LINE_RDLED EP93XX_GPIO_LINE_E(1)
+#define EP93XX_GPIO_LINE_DIORn EP93XX_GPIO_LINE_E(2)
+#define EP93XX_GPIO_LINE_IDECS1n EP93XX_GPIO_LINE_E(3)
+#define EP93XX_GPIO_LINE_IDECS2n EP93XX_GPIO_LINE_E(4)
+#define EP93XX_GPIO_LINE_IDEDA0 EP93XX_GPIO_LINE_E(5)
+#define EP93XX_GPIO_LINE_IDEDA1 EP93XX_GPIO_LINE_E(6)
+#define EP93XX_GPIO_LINE_IDEDA2 EP93XX_GPIO_LINE_E(7)
+
+/* GPIO port F. */
+#define EP93XX_GPIO_LINE_F(x) ((x) + 40)
+#define EP93XX_GPIO_LINE_WP EP93XX_GPIO_LINE_F(0)
+#define EP93XX_GPIO_LINE_MCCD1 EP93XX_GPIO_LINE_F(1)
+#define EP93XX_GPIO_LINE_MCCD2 EP93XX_GPIO_LINE_F(2)
+#define EP93XX_GPIO_LINE_MCBVD1 EP93XX_GPIO_LINE_F(3)
+#define EP93XX_GPIO_LINE_MCBVD2 EP93XX_GPIO_LINE_F(4)
+#define EP93XX_GPIO_LINE_VS1 EP93XX_GPIO_LINE_F(5)
+#define EP93XX_GPIO_LINE_READY EP93XX_GPIO_LINE_F(6)
+#define EP93XX_GPIO_LINE_VS2 EP93XX_GPIO_LINE_F(7)
+
+/* GPIO port G. */
+#define EP93XX_GPIO_LINE_G(x) ((x) + 48)
+#define EP93XX_GPIO_LINE_EECLK EP93XX_GPIO_LINE_G(0)
+#define EP93XX_GPIO_LINE_EEDAT EP93XX_GPIO_LINE_G(1)
+#define EP93XX_GPIO_LINE_SLA0 EP93XX_GPIO_LINE_G(2)
+#define EP93XX_GPIO_LINE_SLA1 EP93XX_GPIO_LINE_G(3)
+#define EP93XX_GPIO_LINE_DD12 EP93XX_GPIO_LINE_G(4)
+#define EP93XX_GPIO_LINE_DD13 EP93XX_GPIO_LINE_G(5)
+#define EP93XX_GPIO_LINE_DD14 EP93XX_GPIO_LINE_G(6)
+#define EP93XX_GPIO_LINE_DD15 EP93XX_GPIO_LINE_G(7)
+
+/* GPIO port H. */
+#define EP93XX_GPIO_LINE_H(x) ((x) + 56)
+#define EP93XX_GPIO_LINE_DD0 EP93XX_GPIO_LINE_H(0)
+#define EP93XX_GPIO_LINE_DD1 EP93XX_GPIO_LINE_H(1)
+#define EP93XX_GPIO_LINE_DD2 EP93XX_GPIO_LINE_H(2)
+#define EP93XX_GPIO_LINE_DD3 EP93XX_GPIO_LINE_H(3)
+#define EP93XX_GPIO_LINE_DD4 EP93XX_GPIO_LINE_H(4)
+#define EP93XX_GPIO_LINE_DD5 EP93XX_GPIO_LINE_H(5)
+#define EP93XX_GPIO_LINE_DD6 EP93XX_GPIO_LINE_H(6)
+#define EP93XX_GPIO_LINE_DD7 EP93XX_GPIO_LINE_H(7)
+
+
+#endif
diff --git a/include/asm-arm/arch-ep93xx/hardware.h b/include/asm-arm/arch-ep93xx/hardware.h
new file mode 100644
index 00000000000..9b69f454065
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/hardware.h
@@ -0,0 +1,12 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/hardware.h
+ */
+
+#include "ep93xx-regs.h"
+
+#define pcibios_assign_all_busses() 0
+
+#include "platform.h"
+
+#include "gesbc9312.h"
+#include "ts72xx.h"
diff --git a/include/asm-arm/arch-ep93xx/io.h b/include/asm-arm/arch-ep93xx/io.h
new file mode 100644
index 00000000000..7b4d25e2906
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/io.h
@@ -0,0 +1,8 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/io.h
+ */
+
+#define IO_SPACE_LIMIT 0xffffffff
+
+#define __io(p) ((void __iomem *)(p))
+#define __mem_pci(p) (p)
diff --git a/include/asm-arm/arch-ep93xx/irqs.h b/include/asm-arm/arch-ep93xx/irqs.h
new file mode 100644
index 00000000000..9a42f5de9e5
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/irqs.h
@@ -0,0 +1,80 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/irqs.h
+ */
+
+#ifndef __ASM_ARCH_IRQS_H
+#define __ASM_ARCH_IRQS_H
+
+#define IRQ_EP93XX_COMMRX 2
+#define IRQ_EP93XX_COMMTX 3
+#define IRQ_EP93XX_TIMER1 4
+#define IRQ_EP93XX_TIMER2 5
+#define IRQ_EP93XX_AACINTR 6
+#define IRQ_EP93XX_DMAM2P0 7
+#define IRQ_EP93XX_DMAM2P1 8
+#define IRQ_EP93XX_DMAM2P2 9
+#define IRQ_EP93XX_DMAM2P3 10
+#define IRQ_EP93XX_DMAM2P4 11
+#define IRQ_EP93XX_DMAM2P5 12
+#define IRQ_EP93XX_DMAM2P6 13
+#define IRQ_EP93XX_DMAM2P7 14
+#define IRQ_EP93XX_DMAM2P8 15
+#define IRQ_EP93XX_DMAM2P9 16
+#define IRQ_EP93XX_DMAM2M0 17
+#define IRQ_EP93XX_DMAM2M1 18
+#define IRQ_EP93XX_GPIO0MUX 20
+#define IRQ_EP93XX_GPIO1MUX 21
+#define IRQ_EP93XX_GPIO2MUX 22
+#define IRQ_EP93XX_GPIO3MUX 22
+#define IRQ_EP93XX_UART1RX 23
+#define IRQ_EP93XX_UART1TX 24
+#define IRQ_EP93XX_UART2RX 25
+#define IRQ_EP93XX_UART2TX 26
+#define IRQ_EP93XX_UART3RX 27
+#define IRQ_EP93XX_UART3TX 28
+#define IRQ_EP93XX_KEY 29
+#define IRQ_EP93XX_TOUCH 30
+#define EP93XX_VIC1_VALID_IRQ_MASK 0x7ffffffc
+
+#define IRQ_EP93XX_EXT0 32
+#define IRQ_EP93XX_EXT1 33
+#define IRQ_EP93XX_EXT2 34
+#define IRQ_EP93XX_64HZ 35
+#define IRQ_EP93XX_WATCHDOG 36
+#define IRQ_EP93XX_RTC 37
+#define IRQ_EP93XX_IRDA 38
+#define IRQ_EP93XX_ETHERNET 39
+#define IRQ_EP93XX_EXT3 40
+#define IRQ_EP93XX_PROG 41
+#define IRQ_EP93XX_1HZ 42
+#define IRQ_EP93XX_VSYNC 43
+#define IRQ_EP93XX_VIDEO_FIFO 44
+#define IRQ_EP93XX_SSP1RX 45
+#define IRQ_EP93XX_SSP1TX 46
+#define IRQ_EP93XX_GPIO4MUX 47
+#define IRQ_EP93XX_GPIO5MUX 48
+#define IRQ_EP93XX_GPIO6MUX 49
+#define IRQ_EP93XX_GPIO7MUX 50
+#define IRQ_EP93XX_TIMER3 51
+#define IRQ_EP93XX_UART1 52
+#define IRQ_EP93XX_SSP 53
+#define IRQ_EP93XX_UART2 54
+#define IRQ_EP93XX_UART3 55
+#define IRQ_EP93XX_USB 56
+#define IRQ_EP93XX_ETHERNET_PME 57
+#define IRQ_EP93XX_DSP 58
+#define IRQ_EP93XX_GPIO_AB 59
+#define IRQ_EP93XX_SAI 60
+#define EP93XX_VIC2_VALID_IRQ_MASK 0x1fffffff
+
+#define IRQ_EP93XX_GPIO(x) (64 + (x))
+
+#define NR_EP93XX_IRQS IRQ_EP93XX_GPIO(16)
+
+#define EP93XX_BOARD_IRQ(x) (NR_EP93XX_IRQS + (x))
+#define EP93XX_BOARD_IRQS 32
+
+#define NR_IRQS (NR_EP93XX_IRQS + EP93XX_BOARD_IRQS)
+
+
+#endif
diff --git a/include/asm-arm/arch-ep93xx/memory.h b/include/asm-arm/arch-ep93xx/memory.h
new file mode 100644
index 00000000000..4b1a5c7c836
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/memory.h
@@ -0,0 +1,14 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/memory.h
+ */
+
+#ifndef __ASM_ARCH_MEMORY_H
+#define __ASM_ARCH_MEMORY_H
+
+#define PHYS_OFFSET UL(0x00000000)
+
+#define __bus_to_virt(x) __phys_to_virt(x)
+#define __virt_to_bus(x) __virt_to_phys(x)
+
+
+#endif
diff --git a/include/asm-arm/arch-ep93xx/platform.h b/include/asm-arm/arch-ep93xx/platform.h
new file mode 100644
index 00000000000..df9cbb6ef66
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/platform.h
@@ -0,0 +1,14 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/platform.h
+ */
+
+#ifndef __ASSEMBLY__
+
+void ep93xx_map_io(void);
+void ep93xx_init_irq(void);
+void ep93xx_init_time(unsigned long);
+void ep93xx_init_devices(void);
+extern struct sys_timer ep93xx_timer;
+
+
+#endif
diff --git a/include/asm-arm/arch-ep93xx/system.h b/include/asm-arm/arch-ep93xx/system.h
new file mode 100644
index 00000000000..79b71858674
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/system.h
@@ -0,0 +1,26 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/system.h
+ */
+
+#include <asm/hardware.h>
+
+static inline void arch_idle(void)
+{
+ cpu_do_idle();
+}
+
+static inline void arch_reset(char mode)
+{
+ u32 devicecfg;
+
+ local_irq_disable();
+
+ devicecfg = __raw_readl(EP93XX_SYSCON_DEVICE_CONFIG);
+ __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
+ __raw_writel(devicecfg | 0x80000000, EP93XX_SYSCON_DEVICE_CONFIG);
+ __raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
+ __raw_writel(devicecfg & ~0x80000000, EP93XX_SYSCON_DEVICE_CONFIG);
+
+ while (1)
+ ;
+}
diff --git a/include/asm-arm/arch-ep93xx/timex.h b/include/asm-arm/arch-ep93xx/timex.h
new file mode 100644
index 00000000000..4140bddc97e
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/timex.h
@@ -0,0 +1,5 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/timex.h
+ */
+
+#define CLOCK_TICK_RATE 983040
diff --git a/include/asm-arm/arch-ep93xx/ts72xx.h b/include/asm-arm/arch-ep93xx/ts72xx.h
new file mode 100644
index 00000000000..412215e77f4
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/ts72xx.h
@@ -0,0 +1,90 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/ts72xx.h
+ */
+
+/*
+ * TS72xx memory map:
+ *
+ * virt phys size
+ * febff000 22000000 4K model number register
+ * febfe000 22400000 4K options register
+ * febfd000 22800000 4K options register #2
+ * febfc000 [67]0000000 4K NAND data register
+ * febfb000 [67]0400000 4K NAND control register
+ * febfa000 [67]0800000 4K NAND busy register
+ */
+
+#define TS72XX_MODEL_PHYS_BASE 0x22000000
+#define TS72XX_MODEL_VIRT_BASE 0xfebff000
+#define TS72XX_MODEL_SIZE 0x00001000
+
+#define TS72XX_MODEL_TS7200 0x00
+#define TS72XX_MODEL_TS7250 0x01
+#define TS72XX_MODEL_TS7260 0x02
+
+
+#define TS72XX_OPTIONS_PHYS_BASE 0x22400000
+#define TS72XX_OPTIONS_VIRT_BASE 0xfebfe000
+#define TS72XX_OPTIONS_SIZE 0x00001000
+
+#define TS72XX_OPTIONS_COM2_RS485 0x02
+#define TS72XX_OPTIONS_MAX197 0x01
+
+
+#define TS72XX_OPTIONS2_PHYS_BASE 0x22800000
+#define TS72XX_OPTIONS2_VIRT_BASE 0xfebfd000
+#define TS72XX_OPTIONS2_SIZE 0x00001000
+
+#define TS72XX_OPTIONS2_TS9420 0x04
+#define TS72XX_OPTIONS2_TS9420_BOOT 0x02
+
+
+#define TS72XX_NOR_PHYS_BASE 0x60000000
+#define TS72XX_NOR2_PHYS_BASE 0x62000000
+
+#define TS72XX_NAND1_DATA_PHYS_BASE 0x60000000
+#define TS72XX_NAND2_DATA_PHYS_BASE 0x70000000
+#define TS72XX_NAND_DATA_VIRT_BASE 0xfebfc000
+#define TS72XX_NAND_DATA_SIZE 0x00001000
+
+#define TS72XX_NAND1_CONTROL_PHYS_BASE 0x60400000
+#define TS72XX_NAND2_CONTROL_PHYS_BASE 0x70400000
+#define TS72XX_NAND_CONTROL_VIRT_BASE 0xfebfb000
+#define TS72XX_NAND_CONTROL_SIZE 0x00001000
+
+#define TS72XX_NAND1_BUSY_PHYS_BASE 0x60800000
+#define TS72XX_NAND2_BUSY_PHYS_BASE 0x70800000
+#define TS72XX_NAND_BUSY_VIRT_BASE 0xfebfa000
+#define TS72XX_NAND_BUSY_SIZE 0x00001000
+
+
+#ifndef __ASSEMBLY__
+#include <asm/io.h>
+
+static inline int board_is_ts7200(void)
+{
+ return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7200;
+}
+
+static inline int board_is_ts7250(void)
+{
+ return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7250;
+}
+
+static inline int board_is_ts7260(void)
+{
+ return __raw_readb(TS72XX_MODEL_VIRT_BASE) == TS72XX_MODEL_TS7260;
+}
+
+static inline int is_max197_installed(void)
+{
+ return !!(__raw_readb(TS72XX_OPTIONS_VIRT_BASE) &
+ TS72XX_OPTIONS_MAX197);
+}
+
+static inline int is_ts9420_installed(void)
+{
+ return !!(__raw_readb(TS72XX_OPTIONS2_VIRT_BASE) &
+ TS72XX_OPTIONS2_TS9420);
+}
+#endif
diff --git a/include/asm-arm/arch-ep93xx/uncompress.h b/include/asm-arm/arch-ep93xx/uncompress.h
new file mode 100644
index 00000000000..4410d217077
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/uncompress.h
@@ -0,0 +1,53 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/uncompress.h
+ *
+ * Copyright (C) 2006 Lennert Buytenhek <buytenh@wantstofly.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <asm/arch/ep93xx-regs.h>
+
+static unsigned char __raw_readb(unsigned int ptr)
+{
+ return *((volatile unsigned char *)ptr);
+}
+
+static void __raw_writeb(unsigned char value, unsigned int ptr)
+{
+ *((volatile unsigned char *)ptr) = value;
+}
+
+
+#define PHYS_UART1_DATA 0x808c0000
+#define PHYS_UART1_FLAG 0x808c0018
+#define UART1_FLAG_TXFF 0x20
+
+static __inline__ void putc(char c)
+{
+ int i;
+
+ for (i = 0; i < 1000; i++) {
+ /* Transmit fifo not full? */
+ if (!(__raw_readb(PHYS_UART1_FLAG) & UART1_FLAG_TXFF))
+ break;
+ }
+
+ __raw_writeb(c, PHYS_UART1_DATA);
+}
+
+static void putstr(const char *s)
+{
+ while (*s) {
+ putc(*s);
+ if (*s == '\n')
+ putc('\r');
+ s++;
+ }
+}
+
+#define arch_decomp_setup()
+#define arch_decomp_wdog()
diff --git a/include/asm-arm/arch-ep93xx/vmalloc.h b/include/asm-arm/arch-ep93xx/vmalloc.h
new file mode 100644
index 00000000000..205ea6b1cf5
--- /dev/null
+++ b/include/asm-arm/arch-ep93xx/vmalloc.h
@@ -0,0 +1,5 @@
+/*
+ * linux/include/asm-arm/arch-ep93xx/vmalloc.h
+ */
+
+#define VMALLOC_END 0xfe800000
diff --git a/include/asm-arm/arch-h720x/irq.h b/include/asm-arm/arch-h720x/irq.h
deleted file mode 100644
index b3821e957aa..00000000000
--- a/include/asm-arm/arch-h720x/irq.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * include/asm-arm/arch-h720x/irq.h
- *
- * Copyright (C) 2000-2002 Jungjun Kim
- * (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>
- * (C) 2003 Thomas Gleixner <tglx@linutronix.de>
- */
-
-#ifndef __ASM_ARCH_IRQ_H
-#define __ASM_ARCH_IRQ_H
-
-extern void __init h720x_init_irq (void);
-
-#endif /* __ASM_ARCH_IRQ_H */
diff --git a/include/asm-arm/arch-h720x/param.h b/include/asm-arm/arch-h720x/param.h
deleted file mode 100644
index 2b80235f984..00000000000
--- a/include/asm-arm/arch-h720x/param.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * linux/include/asm-arm/arch-h720x/param.h
- *
- * Copyright (C) 2000 Jungjun Kim
- */
-
-#ifndef __ASM_ARCH_PARAM_H
-#define __ASM_ARCH_PARAM_H
-
-#endif
diff --git a/include/asm-arm/arch-imx/irq.h b/include/asm-arm/arch-imx/irq.h
deleted file mode 100644
index 545e065d232..00000000000
--- a/include/asm-arm/arch-imx/irq.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * linux/include/asm-arm/arch-imxads/irq.h
- *
- * Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#define fixup_irq(i) (i)
diff --git a/include/asm-arm/arch-imx/param.h b/include/asm-arm/arch-imx/param.h
deleted file mode 100644
index 7c724f03333..00000000000
--- a/include/asm-arm/arch-imx/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-imx/param.h
- *
- * Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/include/asm-arm/arch-integrator/debug-macro.S b/include/asm-arm/arch-integrator/debug-macro.S
index 031d3094179..85b327c352d 100644
--- a/include/asm-arm/arch-integrator/debug-macro.S
+++ b/include/asm-arm/arch-integrator/debug-macro.S
@@ -11,8 +11,6 @@
*
*/
-#include <linux/amba/serial.h>
-
.macro addruart,rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
@@ -21,18 +19,4 @@
addne \rx, \rx, #0x16000000 >> 4
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx, #UART01x_DR]
- .endm
-
- .macro waituart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
- bne 1001b
- .endm
-
- .macro busyuart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
- bne 1001b
- .endm
+#include <asm/hardware/debug-pl01x.S>
diff --git a/include/asm-arm/arch-integrator/param.h b/include/asm-arm/arch-integrator/param.h
deleted file mode 100644
index afa582ff371..00000000000
--- a/include/asm-arm/arch-integrator/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-integrator/param.h
- *
- * Copyright (C) 1999 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/include/asm-arm/arch-iop3xx/debug-macro.S b/include/asm-arm/arch-iop3xx/debug-macro.S
index cc15f80ebd9..ce007e53199 100644
--- a/include/asm-arm/arch-iop3xx/debug-macro.S
+++ b/include/asm-arm/arch-iop3xx/debug-macro.S
@@ -28,21 +28,8 @@
#endif
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro busyuart,rd,rx
-1002: ldrb \rd, [\rx, #0x5]
- and \rd, \rd, #0x60
- teq \rd, #0x60
- bne 1002b
- .endm
-
- .macro waituart,rd,rx
#if !defined(CONFIG_ARCH_IQ80321) || !defined(CONFIG_ARCH_IQ31244) || !defined(CONFIG_ARCH_IQ80331)
-1001: ldrb \rd, [\rx, #0x6]
- tst \rd, #0x10
- beq 1001b
+#define FLOW_CONTROL
#endif
- .endm
+#define UART_SHIFT 0
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-iop3xx/param.h b/include/asm-arm/arch-iop3xx/param.h
deleted file mode 100644
index acf404e8735..00000000000
--- a/include/asm-arm/arch-iop3xx/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-iop3xx/param.h
- */
diff --git a/include/asm-arm/arch-ixp2000/debug-macro.S b/include/asm-arm/arch-ixp2000/debug-macro.S
index 5631e088986..bc8b3965479 100644
--- a/include/asm-arm/arch-ixp2000/debug-macro.S
+++ b/include/asm-arm/arch-ixp2000/debug-macro.S
@@ -23,18 +23,5 @@
#endif
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro busyuart,rd,rx
-1002: ldrb \rd, [\rx, #0x14]
- tst \rd, #0x20
- beq 1002b
- .endm
-
- .macro waituart,rd,rx
- nop
- nop
- nop
- .endm
+#define UART_SHIFT 2
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-ixp2000/irq.h b/include/asm-arm/arch-ixp2000/irq.h
deleted file mode 100644
index ba00b23f982..00000000000
--- a/include/asm-arm/arch-ixp2000/irq.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ixp2000/irq.h
- *
- * Copyright (C) 2002 Intel Corp.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define fixup_irq(irq) (irq)
-
-
diff --git a/include/asm-arm/arch-ixp2000/ixdp2x00.h b/include/asm-arm/arch-ixp2000/ixdp2x00.h
index 229381c6428..546e2e8e27b 100644
--- a/include/asm-arm/arch-ixp2000/ixdp2x00.h
+++ b/include/asm-arm/arch-ixp2000/ixdp2x00.h
@@ -72,12 +72,11 @@
#ifndef __ASSEMBLY__
/*
- * Master NPU will always have flash and be PCI master.
- * Slave NPU may or may not have flash but will never be PCI master.
+ * The master NPU is always PCI master.
*/
static inline unsigned int ixdp2x00_master_npu(void)
{
- return ((ixp2000_has_flash()) && (ixp2000_is_pcimaster()));
+ return !!ixp2000_is_pcimaster();
}
/*
diff --git a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
index 2b57f91b4eb..ccae4bec92c 100644
--- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h
+++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h
@@ -353,8 +353,8 @@
* Masks and shifts for various fields in the WTC and RTC registers.
*/
#define SLOWPORT_WRTC_MASK_HD 0x0003
-#define SLOWPORT_WRTC_MASK_SU 0x003c
-#define SLOWPORT_WRTC_MASK_PW 0x03c0
+#define SLOWPORT_WRTC_MASK_PW 0x003c
+#define SLOWPORT_WRTC_MASK_SU 0x03c0
#define SLOWPORT_WRTC_SHIFT_HD 0x00
#define SLOWPORT_WRTC_SHIFT_SU 0x02
diff --git a/include/asm-arm/arch-ixp2000/param.h b/include/asm-arm/arch-ixp2000/param.h
deleted file mode 100644
index 2646d9e5919..00000000000
--- a/include/asm-arm/arch-ixp2000/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ixp2000/param.h
- */
diff --git a/include/asm-arm/arch-ixp2000/system.h b/include/asm-arm/arch-ixp2000/system.h
index ddbbb34b5f9..3cc9a04f68c 100644
--- a/include/asm-arm/arch-ixp2000/system.h
+++ b/include/asm-arm/arch-ixp2000/system.h
@@ -37,7 +37,7 @@ static inline void arch_reset(char mode)
* to cause a complete reset of the CPU and all external devices
* and move the flash bank register back to 0.
*/
- if (machine_is_ixdp2801()) {
+ if (machine_is_ixdp2801() || machine_is_ixdp28x5()) {
unsigned long reset_reg = *IXDP2X01_CPLD_RESET_REG;
reset_reg = 0x55AA0000 | (reset_reg & 0x0000FFFF);
diff --git a/include/asm-arm/arch-ixp4xx/debug-macro.S b/include/asm-arm/arch-ixp4xx/debug-macro.S
index 2e23651e217..37bc8ef23e6 100644
--- a/include/asm-arm/arch-ixp4xx/debug-macro.S
+++ b/include/asm-arm/arch-ixp4xx/debug-macro.S
@@ -20,16 +20,5 @@
@ byte writes used - Big Endian.
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro waituart,rd,rx
-1002: ldrb \rd, [\rx, #0x14]
- and \rd, \rd, #0x60 @ check THRE and TEMT bits
- teq \rd, #0x60
- bne 1002b
- .endm
-
- .macro busyuart,rd,rx
- .endm
+#define UART_SHIFT 2
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-ixp4xx/irq.h b/include/asm-arm/arch-ixp4xx/irq.h
deleted file mode 100644
index 87da70695f0..00000000000
--- a/include/asm-arm/arch-ixp4xx/irq.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * irq.h
- *
- * Copyright (C) 2002 Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
-
-#define fixup_irq(irq) (irq)
-
diff --git a/include/asm-arm/arch-ixp4xx/param.h b/include/asm-arm/arch-ixp4xx/param.h
deleted file mode 100644
index 8a757125e5e..00000000000
--- a/include/asm-arm/arch-ixp4xx/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-ixp4xx/param.h
- */
diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h
index daf9790645c..13aee17b047 100644
--- a/include/asm-arm/arch-ixp4xx/platform.h
+++ b/include/asm-arm/arch-ixp4xx/platform.h
@@ -38,6 +38,33 @@ extern unsigned long ixp4xx_exp_bus_size;
#define IXP4XX_EXP_BUS_BASE(region)\
(IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size))
+#define IXP4XX_EXP_BUS_END(region)\
+ (IXP4XX_EXP_BUS_BASE(region) + ixp4xx_exp_bus_size - 1)
+
+/* Those macros can be used to adjust timing and configure
+ * other features for each region.
+ */
+
+#define IXP4XX_EXP_BUS_RECOVERY_T(x) (((x) & 0x0f) << 16)
+#define IXP4XX_EXP_BUS_HOLD_T(x) (((x) & 0x03) << 20)
+#define IXP4XX_EXP_BUS_STROBE_T(x) (((x) & 0x0f) << 22)
+#define IXP4XX_EXP_BUS_SETUP_T(x) (((x) & 0x03) << 26)
+#define IXP4XX_EXP_BUS_ADDR_T(x) (((x) & 0x03) << 28)
+#define IXP4XX_EXP_BUS_SIZE(x) (((x) & 0x0f) << 10)
+#define IXP4XX_EXP_BUS_CYCLES(x) (((x) & 0x03) << 14)
+
+#define IXP4XX_EXP_BUS_CS_EN (1L << 31)
+#define IXP4XX_EXP_BUS_BYTE_RD16 (1L << 6)
+#define IXP4XX_EXP_BUS_HRDY_POL (1L << 5)
+#define IXP4XX_EXP_BUS_MUX_EN (1L << 4)
+#define IXP4XX_EXP_BUS_SPLT_EN (1L << 3)
+#define IXP4XX_EXP_BUS_WR_EN (1L << 1)
+#define IXP4XX_EXP_BUS_BYTE_EN (1L << 0)
+
+#define IXP4XX_EXP_BUS_CYCLES_INTEL 0x00
+#define IXP4XX_EXP_BUS_CYCLES_MOTOROLA 0x01
+#define IXP4XX_EXP_BUS_CYCLES_HPI 0x02
+
#define IXP4XX_FLASH_WRITABLE (0x2)
#define IXP4XX_FLASH_DEFAULT (0xbcd23c40)
#define IXP4XX_FLASH_WRITE (0xbcd23c42)
diff --git a/include/asm-arm/arch-l7200/param.h b/include/asm-arm/arch-l7200/param.h
deleted file mode 100644
index 9962a12ab15..00000000000
--- a/include/asm-arm/arch-l7200/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-l7200/param.h
- *
- * Copyright (C) 2000 Rob Scott (rscott@mtrob.fdns.net)
- * Steve Hill (sjhill@cotw.com)
- *
- * This file contains the hardware definitions for the
- * LinkUp Systems L7200 SOC development board.
- *
- * Changelog:
- * 04-21-2000 RS Created L7200 version
- * 04-25-2000 SJH Cleaned up file
- * 05-03-2000 SJH Change comments and rate
- */
-
-/*
- * See 'time.h' for how the RTC HZ rate is set
- */
-#define HZ 128
diff --git a/include/asm-arm/arch-lh7a40x/irq.h b/include/asm-arm/arch-lh7a40x/irq.h
deleted file mode 100644
index 0f5f0b10f6c..00000000000
--- a/include/asm-arm/arch-lh7a40x/irq.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* include/asm-arm/arch-lh7a40x/irq.h
- *
- * Copyright (C) 2004 Logic Product Development
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- */
-
-void __init lh7a40x_init_board_irq (void);
diff --git a/include/asm-arm/arch-lh7a40x/param.h b/include/asm-arm/arch-lh7a40x/param.h
deleted file mode 100644
index acad0bc5deb..00000000000
--- a/include/asm-arm/arch-lh7a40x/param.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* include/asm-arm/arch-lh7a40x/param.h
- *
- * Copyright (C) 2004 Coastal Environmental Systems
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- */
diff --git a/include/asm-arm/arch-omap/param.h b/include/asm-arm/arch-omap/param.h
deleted file mode 100644
index face9ad41e9..00000000000
--- a/include/asm-arm/arch-omap/param.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
- * linux/include/asm-arm/arch-omap/param.h
- *
- */
-
-#ifdef CONFIG_OMAP_32K_TIMER_HZ
-#define HZ CONFIG_OMAP_32K_TIMER_HZ
-#endif
diff --git a/include/asm-arm/arch-pxa/debug-macro.S b/include/asm-arm/arch-pxa/debug-macro.S
index b6ec6887917..9012cbc0ad8 100644
--- a/include/asm-arm/arch-pxa/debug-macro.S
+++ b/include/asm-arm/arch-pxa/debug-macro.S
@@ -21,18 +21,5 @@
orr \rx, \rx, #0x00100000
.endm
- .macro senduart,rd,rx
- str \rd, [\rx, #0]
- .endm
-
- .macro busyuart,rd,rx
-1002: ldr \rd, [\rx, #0x14]
- tst \rd, #(1 << 6)
- beq 1002b
- .endm
-
- .macro waituart,rd,rx
-1001: ldr \rd, [\rx, #0x14]
- tst \rd, #(1 << 5)
- beq 1001b
- .endm
+#define UART_SHIFT 2
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-pxa/irq.h b/include/asm-arm/arch-pxa/irq.h
deleted file mode 100644
index 48c60f5eff6..00000000000
--- a/include/asm-arm/arch-pxa/irq.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * linux/include/asm-arm/arch-pxa/irq.h
- *
- * Author: Nicolas Pitre
- * Created: Jun 15, 2001
- * Copyright: MontaVista Software Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#define fixup_irq(x) (x)
-
diff --git a/include/asm-arm/arch-pxa/param.h b/include/asm-arm/arch-pxa/param.h
deleted file mode 100644
index 3197d82d757..00000000000
--- a/include/asm-arm/arch-pxa/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-pxa/param.h
- */
diff --git a/include/asm-arm/arch-realview/debug-macro.S b/include/asm-arm/arch-realview/debug-macro.S
index 017ad996848..f17efc65518 100644
--- a/include/asm-arm/arch-realview/debug-macro.S
+++ b/include/asm-arm/arch-realview/debug-macro.S
@@ -11,8 +11,6 @@
*
*/
-#include <linux/amba/serial.h>
-
.macro addruart,rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
@@ -21,18 +19,4 @@
orr \rx, \rx, #0x00009000
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx, #UART01x_DR]
- .endm
-
- .macro waituart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
- bne 1001b
- .endm
-
- .macro busyuart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
- bne 1001b
- .endm
+#include <asm/hardware/debug-pl01x.S>
diff --git a/include/asm-arm/arch-realview/param.h b/include/asm-arm/arch-realview/param.h
deleted file mode 100644
index 89b1235d32b..00000000000
--- a/include/asm-arm/arch-realview/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-realview/param.h
- *
- * Copyright (C) 2002 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/include/asm-arm/arch-rpc/debug-macro.S b/include/asm-arm/arch-rpc/debug-macro.S
index 456d3d754c3..c634c8d8f4a 100644
--- a/include/asm-arm/arch-rpc/debug-macro.S
+++ b/include/asm-arm/arch-rpc/debug-macro.S
@@ -20,19 +20,6 @@
orr \rx, \rx, #0x00000fe0
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx]
- .endm
-
- .macro busyuart,rd,rx
-1001: ldrb \rd, [\rx, #0x14]
- and \rd, \rd, #0x60
- teq \rd, #0x60
- bne 1001b
- .endm
-
- .macro waituart,rd,rx
-1001: ldrb \rd, [\rx, #0x18]
- tst \rd, #0x10
- beq 1001b
- .endm
+#define UART_SHIFT 2
+#define FLOW_CONTROL
+#include <asm/hardware/debug-8250.S>
diff --git a/include/asm-arm/arch-rpc/param.h b/include/asm-arm/arch-rpc/param.h
deleted file mode 100644
index 721dcd65885..00000000000
--- a/include/asm-arm/arch-rpc/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-rpc/param.h
- */
diff --git a/include/asm-arm/arch-s3c2410/osiris-cpld.h b/include/asm-arm/arch-s3c2410/osiris-cpld.h
new file mode 100644
index 00000000000..e9d1ae1f354
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/osiris-cpld.h
@@ -0,0 +1,25 @@
+/* linux/include/asm-arm/arch-s3c2410/osiris-cpld.h
+ *
+ * (c) 2005 Simtec Electronics
+ * http://www.simtec.co.uk/products/
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * OSIRIS - CPLD control constants
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+*/
+
+#ifndef __ASM_ARCH_OSIRISCPLD_H
+#define __ASM_ARCH_OSIRISCPLD_H
+
+/* CTRL1 - NAND WP control */
+
+#define OSIRIS_CTRL1_NANDSEL (0x3)
+#define OSIRIS_CTRL1_BOOT_INT (1<<3)
+#define OSIRIS_CTRL1_PCMCIA (1<<4)
+#define OSIRIS_CTRL1_PCMCIA_nWAIT (1<<6)
+#define OSIRIS_CTRL1_PCMCIA_nIOIS16 (1<<7)
+
+#endif /* __ASM_ARCH_OSIRISCPLD_H */
diff --git a/include/asm-arm/arch-s3c2410/osiris-map.h b/include/asm-arm/arch-s3c2410/osiris-map.h
new file mode 100644
index 00000000000..7c4b0cd2d14
--- /dev/null
+++ b/include/asm-arm/arch-s3c2410/osiris-map.h
@@ -0,0 +1,41 @@
+/* linux/include/asm-arm/arch-s3c2410/osiris-map.h
+ *
+ * (c) 2005 Simtec Electronics
+ * http://www.simtec.co.uk/products/
+ * Ben Dooks <ben@simtec.co.uk>
+ *
+ * OSIRIS - Memory map definitions
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Changelog:
+*/
+
+/* needs arch/map.h including with this */
+
+#ifndef __ASM_ARCH_OSIRISMAP_H
+#define __ASM_ARCH_OSIRISMAP_H
+
+/* start peripherals off after the S3C2410 */
+
+#define OSIRIS_IOADDR(x) (S3C2410_ADDR((x) + 0x05000000))
+
+#define OSIRIS_PA_CPLD (S3C2410_CS1 | (3<<25))
+
+/* we put the CPLD registers next, to get them out of the way */
+
+#define OSIRIS_VA_CTRL1 OSIRIS_IOADDR(0x00000000) /* 0x01300000 */
+#define OSIRIS_PA_CTRL1 (OSIRIS_PA_CPLD)
+
+#define OSIRIS_VA_CTRL2 OSIRIS_IOADDR(0x00100000) /* 0x01400000 */
+#define OSIRIS_PA_CTRL2 (OSIRIS_PA_CPLD + (1<<24))
+
+#define OSIRIS_VA_CTRL3 OSIRIS_IOADDR(0x00200000) /* 0x01500000 */
+#define OSIRIS_PA_CTRL3 (OSIRIS_PA_CPLD + (2<<24))
+
+#define OSIRIS_VA_CTRL4 OSIRIS_IOADDR(0x00300000) /* 0x01600000 */
+#define OSIRIS_PA_CTRL4 (OSIRIS_PA_CPLD + (3<<24))
+
+#endif /* __ASM_ARCH_OSIRISMAP_H */
diff --git a/include/asm-arm/arch-s3c2410/param.h b/include/asm-arm/arch-s3c2410/param.h
deleted file mode 100644
index 483d3f14988..00000000000
--- a/include/asm-arm/arch-s3c2410/param.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* linux/include/asm-arm/arch-s3c2410/param.h
- *
- * (c) 2003 Simtec Electronics
- * Ben Dooks <ben@simtec.co.uk>
- *
- * S3C2410 - Machine parameters
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 02-Sep-2003 BJD Created file
- * 12-Mar-2004 BJD Added include protection
-*/
-
-#ifndef __ASM_ARCH_PARAM_H
-#define __ASM_ARCH_PARAM_H
-
-/* we cannot get our timer down to 100Hz with the setup as is, but we can
- * manage 200 clock ticks per second... if this is a problem, we can always
- * add a software pre-scaler to the evil timer systems.
-*/
-
-#define HZ 200
-
-#endif /* __ASM_ARCH_PARAM_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-gpio.h b/include/asm-arm/arch-s3c2410/regs-gpio.h
index 9697f93afe7..d2574084697 100644
--- a/include/asm-arm/arch-s3c2410/regs-gpio.h
+++ b/include/asm-arm/arch-s3c2410/regs-gpio.h
@@ -979,6 +979,7 @@
#define S3C2410_MISCCR_CLK0_HCLK (3<<4)
#define S3C2410_MISCCR_CLK0_PCLK (4<<4)
#define S3C2410_MISCCR_CLK0_DCLK0 (5<<4)
+#define S3C2410_MISCCR_CLK0_MASK (7<<4)
#define S3C2410_MISCCR_CLK1_MPLL (0<<8)
#define S3C2410_MISCCR_CLK1_UPLL (1<<8)
@@ -986,6 +987,7 @@
#define S3C2410_MISCCR_CLK1_HCLK (3<<8)
#define S3C2410_MISCCR_CLK1_PCLK (4<<8)
#define S3C2410_MISCCR_CLK1_DCLK1 (5<<8)
+#define S3C2410_MISCCR_CLK1_MASK (7<<8)
#define S3C2410_MISCCR_USBSUSPND0 (1<<12)
#define S3C2410_MISCCR_USBSUSPND1 (1<<13)
diff --git a/include/asm-arm/arch-sa1100/debug-macro.S b/include/asm-arm/arch-sa1100/debug-macro.S
index 755fa345386..267c317a740 100644
--- a/include/asm-arm/arch-sa1100/debug-macro.S
+++ b/include/asm-arm/arch-sa1100/debug-macro.S
@@ -10,6 +10,7 @@
* published by the Free Software Foundation.
*
*/
+#include <asm/hardware.h>
.macro addruart,rx
mrc p15, 0, \rx, c1, c0
diff --git a/include/asm-arm/arch-sa1100/param.h b/include/asm-arm/arch-sa1100/param.h
deleted file mode 100644
index 867488909ec..00000000000
--- a/include/asm-arm/arch-sa1100/param.h
+++ /dev/null
@@ -1,3 +0,0 @@
-/*
- * linux/include/asm-arm/arch-sa1100/param.h
- */
diff --git a/include/asm-arm/arch-shark/param.h b/include/asm-arm/arch-shark/param.h
deleted file mode 100644
index 997eeb71de0..00000000000
--- a/include/asm-arm/arch-shark/param.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/*
- * linux/include/asm-arm/arch-shark/param.h
- *
- * by Alexander Schulz
- */
diff --git a/include/asm-arm/arch-versatile/debug-macro.S b/include/asm-arm/arch-versatile/debug-macro.S
index ef6167116db..fe106d184e6 100644
--- a/include/asm-arm/arch-versatile/debug-macro.S
+++ b/include/asm-arm/arch-versatile/debug-macro.S
@@ -11,8 +11,6 @@
*
*/
-#include <linux/amba/serial.h>
-
.macro addruart,rx
mrc p15, 0, \rx, c1, c0
tst \rx, #1 @ MMU enabled?
@@ -22,18 +20,4 @@
orr \rx, \rx, #0x00001000
.endm
- .macro senduart,rd,rx
- strb \rd, [\rx, #UART01x_DR]
- .endm
-
- .macro waituart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 5 @ UARTFLGUTXFF - 1 when full
- bne 1001b
- .endm
-
- .macro busyuart,rd,rx
-1001: ldr \rd, [\rx, #0x18] @ UARTFLG
- tst \rd, #1 << 3 @ UARTFLGUBUSY - 1 when busy
- bne 1001b
- .endm
+#include <asm/hardware/debug-pl01x.S>
diff --git a/include/asm-arm/arch-versatile/param.h b/include/asm-arm/arch-versatile/param.h
deleted file mode 100644
index 34b897335f8..00000000000
--- a/include/asm-arm/arch-versatile/param.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * linux/include/asm-arm/arch-versatile/param.h
- *
- * Copyright (C) 2002 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
diff --git a/include/asm-arm/delay.h b/include/asm-arm/delay.h
index 1704360e969..b2deda18154 100644
--- a/include/asm-arm/delay.h
+++ b/include/asm-arm/delay.h
@@ -6,6 +6,8 @@
#ifndef __ASM_ARM_DELAY_H
#define __ASM_ARM_DELAY_H
+#include <asm/param.h> /* HZ */
+
extern void __delay(int loops);
/*
@@ -13,7 +15,7 @@ extern void __delay(int loops);
* it, it means that you're calling udelay() with an out of range value.
*
* With currently imposed limits, this means that we support a max delay
- * of 2000us and 671 bogomips
+ * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
*/
extern void __bad_udelay(void);
@@ -32,10 +34,10 @@ extern void __const_udelay(unsigned long);
#define MAX_UDELAY_MS 2
-#define udelay(n) \
- (__builtin_constant_p(n) ? \
- ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
- __const_udelay((n) * 0x68dbul)) : \
+#define udelay(n) \
+ (__builtin_constant_p(n) ? \
+ ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() : \
+ __const_udelay((n) * ((2199023U*HZ)>>11))) : \
__udelay(n))
#endif /* defined(_ARM_DELAY_H) */
diff --git a/include/asm-arm/hardware/debug-8250.S b/include/asm-arm/hardware/debug-8250.S
new file mode 100644
index 00000000000..4594fea91ec
--- /dev/null
+++ b/include/asm-arm/hardware/debug-8250.S
@@ -0,0 +1,29 @@
+/*
+ * linux/include/asm-arm/hardware/debug-8250.h
+ *
+ * Copyright (C) 1994-1999 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/serial_reg.h>
+
+ .macro senduart,rd,rx
+ strb \rd, [\rx, #UART_TX << UART_SHIFT]
+ .endm
+
+ .macro busyuart,rd,rx
+1002: ldrb \rd, [\rx, #UART_LSR << UART_SHIFT]
+ and \rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
+ teq \rd, #UART_LSR_TEMT | UART_LSR_THRE
+ bne 1002b
+ .endm
+
+ .macro waituart,rd,rx
+#ifdef FLOW_CONTROL
+1001: ldrb \rd, [\rx, #UART_MSR << UART_SHIFT]
+ tst \rd, #UART_MSR_CTS
+ beq 1001b
+#endif
+ .endm
diff --git a/include/asm-arm/hardware/debug-pl01x.S b/include/asm-arm/hardware/debug-pl01x.S
new file mode 100644
index 00000000000..db0d0f7de5e
--- /dev/null
+++ b/include/asm-arm/hardware/debug-pl01x.S
@@ -0,0 +1,29 @@
+/* linux/include/asm-arm/arch-integrator/debug-macro.S
+ *
+ * Debugging macro include header
+ *
+ * Copyright (C) 1994-1999 Russell King
+ * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+*/
+#include <linux/amba/serial.h>
+
+ .macro senduart,rd,rx
+ strb \rd, [\rx, #UART01x_DR]
+ .endm
+
+ .macro waituart,rd,rx
+1001: ldr \rd, [\rx, #UART01x_FR]
+ tst \rd, #UART01x_FR_TXFF
+ bne 1001b
+ .endm
+
+ .macro busyuart,rd,rx
+1001: ldr \rd, [\rx, #UART01x_FR]
+ tst \rd, #UART01x_FR_BUSY
+ bne 1001b
+ .endm
diff --git a/include/asm-arm/arch-ixp2000/uengine.h b/include/asm-arm/hardware/uengine.h
index b442d65c659..b442d65c659 100644
--- a/include/asm-arm/arch-ixp2000/uengine.h
+++ b/include/asm-arm/hardware/uengine.h
diff --git a/include/asm-arm/hardware/vic.h b/include/asm-arm/hardware/vic.h
index 81825eb54c9..ed9ca3736a0 100644
--- a/include/asm-arm/hardware/vic.h
+++ b/include/asm-arm/hardware/vic.h
@@ -39,7 +39,7 @@
#define VIC_VECT_CNTL_ENABLE (1 << 5)
#ifndef __ASSEMBLY__
-void vic_init(void __iomem *base, u32 vic_sources);
+void vic_init(void __iomem *base, unsigned int irq_start, u32 vic_sources);
#endif
#endif
diff --git a/include/asm-arm/io.h b/include/asm-arm/io.h
index fd0147e52db..b3479fc1cc8 100644
--- a/include/asm-arm/io.h
+++ b/include/asm-arm/io.h
@@ -226,42 +226,6 @@ out:
#endif /* __mem_pci */
/*
- * If this architecture has ISA IO, then define the isa_read/isa_write
- * macros.
- */
-#ifdef __mem_isa
-
-#define isa_readb(addr) __raw_readb(__mem_isa(addr))
-#define isa_readw(addr) __raw_readw(__mem_isa(addr))
-#define isa_readl(addr) __raw_readl(__mem_isa(addr))
-#define isa_writeb(val,addr) __raw_writeb(val,__mem_isa(addr))
-#define isa_writew(val,addr) __raw_writew(val,__mem_isa(addr))
-#define isa_writel(val,addr) __raw_writel(val,__mem_isa(addr))
-#define isa_memset_io(a,b,c) _memset_io(__mem_isa(a),(b),(c))
-#define isa_memcpy_fromio(a,b,c) _memcpy_fromio((a),__mem_isa(b),(c))
-#define isa_memcpy_toio(a,b,c) _memcpy_toio(__mem_isa((a)),(b),(c))
-
-#define isa_eth_io_copy_and_sum(a,b,c,d) \
- eth_copy_and_sum((a),__mem_isa(b),(c),(d))
-
-#else /* __mem_isa */
-
-#define isa_readb(addr) (__readwrite_bug("isa_readb"),0)
-#define isa_readw(addr) (__readwrite_bug("isa_readw"),0)
-#define isa_readl(addr) (__readwrite_bug("isa_readl"),0)
-#define isa_writeb(val,addr) __readwrite_bug("isa_writeb")
-#define isa_writew(val,addr) __readwrite_bug("isa_writew")
-#define isa_writel(val,addr) __readwrite_bug("isa_writel")
-#define isa_memset_io(a,b,c) __readwrite_bug("isa_memset_io")
-#define isa_memcpy_fromio(a,b,c) __readwrite_bug("isa_memcpy_fromio")
-#define isa_memcpy_toio(a,b,c) __readwrite_bug("isa_memcpy_toio")
-
-#define isa_eth_io_copy_and_sum(a,b,c,d) \
- __readwrite_bug("isa_eth_io_copy_and_sum")
-
-#endif /* __mem_isa */
-
-/*
* ioremap and friends.
*
* ioremap takes a PCI memory address, as specified in
diff --git a/include/asm-arm/mach/arch.h b/include/asm-arm/mach/arch.h
index 2cd57b4d64d..fd2f9bf4dcc 100644
--- a/include/asm-arm/mach/arch.h
+++ b/include/asm-arm/mach/arch.h
@@ -10,19 +10,16 @@
#ifndef __ASSEMBLY__
-#include <linux/compiler.h>
-
struct tag;
struct meminfo;
struct sys_timer;
struct machine_desc {
/*
- * Note! The first five elements are used
+ * Note! The first four elements are used
* by assembler code in head-armv.S
*/
unsigned int nr; /* architecture number */
- unsigned int __deprecated phys_ram; /* start of physical ram */
unsigned int phys_io; /* start of physical io */
unsigned int io_pg_offst; /* byte offset for io
* page tabe entry */
diff --git a/include/asm-arm/mach/irq.h b/include/asm-arm/mach/irq.h
index 0ce6ca588d8..d4d420ecf3a 100644
--- a/include/asm-arm/mach/irq.h
+++ b/include/asm-arm/mach/irq.h
@@ -61,7 +61,7 @@ struct irqdesc {
struct irqchip *chip;
struct irqaction *action;
struct list_head pend;
- void *chipdata;
+ void __iomem *base;
void *data;
unsigned int disable_depth;
@@ -74,6 +74,7 @@ struct irqdesc {
unsigned int noautoenable : 1; /* don't automatically enable IRQ */
unsigned int unused :25;
+ unsigned int irqs_unhandled;
struct proc_dir_entry *procdir;
#ifdef CONFIG_SMP
@@ -113,8 +114,8 @@ void __set_irq_handler(unsigned int irq, irq_handler_t, int);
#define set_irq_handler(irq,handler) __set_irq_handler(irq,handler,0)
#define set_irq_chained_handler(irq,handler) __set_irq_handler(irq,handler,1)
#define set_irq_data(irq,d) do { irq_desc[irq].data = d; } while (0)
-#define set_irq_chipdata(irq,d) do { irq_desc[irq].chipdata = d; } while (0)
-#define get_irq_chipdata(irq) (irq_desc[irq].chipdata)
+#define set_irq_chipdata(irq,d) do { irq_desc[irq].base = d; } while (0)
+#define get_irq_chipdata(irq) (irq_desc[irq].base)
void set_irq_chip(unsigned int irq, struct irqchip *);
void set_irq_flags(unsigned int irq, unsigned int flags);
diff --git a/include/asm-arm/param.h b/include/asm-arm/param.h
index 94223d4d7e8..15806468ba7 100644
--- a/include/asm-arm/param.h
+++ b/include/asm-arm/param.h
@@ -11,12 +11,7 @@
#define __ASM_PARAM_H
#ifdef __KERNEL__
-# include <asm/arch/param.h> /* for kernel version of HZ */
-
-# ifndef HZ
-# define HZ 100 /* Internal kernel timer frequency */
-# endif
-
+# define HZ CONFIG_HZ /* Internal kernel timer frequency */
# define USER_HZ 100 /* User interfaces are in "ticks" */
# define CLOCKS_PER_SEC (USER_HZ) /* like times() */
#else
diff --git a/include/asm-arm/poll.h b/include/asm-arm/poll.h
index 2744ca831f5..5030b2b232a 100644
--- a/include/asm-arm/poll.h
+++ b/include/asm-arm/poll.h
@@ -16,6 +16,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-arm26/poll.h b/include/asm-arm26/poll.h
index fdfdab064a6..9ccb7f4190c 100644
--- a/include/asm-arm26/poll.h
+++ b/include/asm-arm26/poll.h
@@ -15,6 +15,7 @@
#define POLLWRNORM 0x0100
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-cris/poll.h b/include/asm-cris/poll.h
index 1c0efc3e4be..1b25d4cf498 100644
--- a/include/asm-cris/poll.h
+++ b/include/asm-cris/poll.h
@@ -15,6 +15,7 @@
#define POLLWRBAND 512
#define POLLMSG 1024
#define POLLREMOVE 4096
+#define POLLRDHUP 8192
struct pollfd {
int fd;
diff --git a/include/asm-cris/system.h b/include/asm-cris/system.h
index d48670107a8..1d63c2aa8ec 100644
--- a/include/asm-cris/system.h
+++ b/include/asm-cris/system.h
@@ -71,4 +71,6 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
#define arch_align_stack(x) (x)
+void default_idle(void);
+
#endif
diff --git a/include/asm-frv/poll.h b/include/asm-frv/poll.h
index 8cbcd60e334..c8fe8801d07 100644
--- a/include/asm-frv/poll.h
+++ b/include/asm-frv/poll.h
@@ -12,6 +12,7 @@
#define POLLRDBAND 128
#define POLLWRBAND 256
#define POLLMSG 0x0400
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 400c2b41896..1a565a9d2fa 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -7,7 +7,7 @@
#ifdef CONFIG_BUG
#ifndef HAVE_ARCH_BUG
#define BUG() do { \
- printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
+ printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
panic("BUG!"); \
} while (0)
#endif
@@ -19,7 +19,7 @@
#ifndef HAVE_ARCH_WARN_ON
#define WARN_ON(condition) do { \
if (unlikely((condition)!=0)) { \
- printk("Badness in %s at %s:%d\n", __FUNCTION__, __FILE__, __LINE__); \
+ printk("BUG: warning at %s:%d/%s()\n", __FILE__, __LINE__, __FUNCTION__); \
dump_stack(); \
} \
} while (0)
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 9044aeb3782..78cf45547e3 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -19,10 +19,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for (__i = 0; __i < NR_CPUS; __i++) \
- if (cpu_possible(__i)) \
- memcpy((pcpudst)+__per_cpu_offset[__i], \
- (src), (size)); \
+ for_each_cpu(__i) \
+ memcpy((pcpudst)+__per_cpu_offset[__i], \
+ (src), (size)); \
} while (0)
#else /* ! SMP */
diff --git a/include/asm-h8300/poll.h b/include/asm-h8300/poll.h
index bf49ab8ad6d..fc52103b276 100644
--- a/include/asm-h8300/poll.h
+++ b/include/asm-h8300/poll.h
@@ -12,6 +12,7 @@
#define POLLRDBAND 128
#define POLLWRBAND 256
#define POLLMSG 0x0400
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-i386/alternative.h b/include/asm-i386/alternative.h
new file mode 100644
index 00000000000..e201decea0c
--- /dev/null
+++ b/include/asm-i386/alternative.h
@@ -0,0 +1,129 @@
+#ifndef _I386_ALTERNATIVE_H
+#define _I386_ALTERNATIVE_H
+
+#ifdef __KERNEL__
+
+struct alt_instr {
+ u8 *instr; /* original instruction */
+ u8 *replacement;
+ u8 cpuid; /* cpuid bit set for replacement */
+ u8 instrlen; /* length of original instruction */
+ u8 replacementlen; /* length of new instruction, <= instrlen */
+ u8 pad;
+};
+
+extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end);
+
+struct module;
+extern void alternatives_smp_module_add(struct module *mod, char *name,
+ void *locks, void *locks_end,
+ void *text, void *text_end);
+extern void alternatives_smp_module_del(struct module *mod);
+extern void alternatives_smp_switch(int smp);
+
+#endif
+
+/*
+ * Alternative instructions for different CPU types or capabilities.
+ *
+ * This allows to use optimized instructions even on generic binary
+ * kernels.
+ *
+ * length of oldinstr must be longer or equal the length of newinstr
+ * It can be padded with nops as needed.
+ *
+ * For non barrier like inlines please define new variants
+ * without volatile and memory clobber.
+ */
+#define alternative(oldinstr, newinstr, feature) \
+ asm volatile ("661:\n\t" oldinstr "\n662:\n" \
+ ".section .altinstructions,\"a\"\n" \
+ " .align 4\n" \
+ " .long 661b\n" /* label */ \
+ " .long 663f\n" /* new instruction */ \
+ " .byte %c0\n" /* feature bit */ \
+ " .byte 662b-661b\n" /* sourcelen */ \
+ " .byte 664f-663f\n" /* replacementlen */ \
+ ".previous\n" \
+ ".section .altinstr_replacement,\"ax\"\n" \
+ "663:\n\t" newinstr "\n664:\n" /* replacement */\
+ ".previous" :: "i" (feature) : "memory")
+
+/*
+ * Alternative inline assembly with input.
+ *
+ * Pecularities:
+ * No memory clobber here.
+ * Argument numbers start with 1.
+ * Best is to use constraints that are fixed size (like (%1) ... "r")
+ * If you use variable sized constraints like "m" or "g" in the
+ * replacement maake sure to pad to the worst case length.
+ */
+#define alternative_input(oldinstr, newinstr, feature, input...) \
+ asm volatile ("661:\n\t" oldinstr "\n662:\n" \
+ ".section .altinstructions,\"a\"\n" \
+ " .align 4\n" \
+ " .long 661b\n" /* label */ \
+ " .long 663f\n" /* new instruction */ \
+ " .byte %c0\n" /* feature bit */ \
+ " .byte 662b-661b\n" /* sourcelen */ \
+ " .byte 664f-663f\n" /* replacementlen */ \
+ ".previous\n" \
+ ".section .altinstr_replacement,\"ax\"\n" \
+ "663:\n\t" newinstr "\n664:\n" /* replacement */\
+ ".previous" :: "i" (feature), ##input)
+
+/*
+ * Alternative inline assembly for SMP.
+ *
+ * alternative_smp() takes two versions (SMP first, UP second) and is
+ * for more complex stuff such as spinlocks.
+ *
+ * The LOCK_PREFIX macro defined here replaces the LOCK and
+ * LOCK_PREFIX macros used everywhere in the source tree.
+ *
+ * SMP alternatives use the same data structures as the other
+ * alternatives and the X86_FEATURE_UP flag to indicate the case of a
+ * UP system running a SMP kernel. The existing apply_alternatives()
+ * works fine for patching a SMP kernel for UP.
+ *
+ * The SMP alternative tables can be kept after boot and contain both
+ * UP and SMP versions of the instructions to allow switching back to
+ * SMP at runtime, when hotplugging in a new CPU, which is especially
+ * useful in virtualized environments.
+ *
+ * The very common lock prefix is handled as special case in a
+ * separate table which is a pure address list without replacement ptr
+ * and size information. That keeps the table sizes small.
+ */
+
+#ifdef CONFIG_SMP
+#define alternative_smp(smpinstr, upinstr, args...) \
+ asm volatile ("661:\n\t" smpinstr "\n662:\n" \
+ ".section .smp_altinstructions,\"a\"\n" \
+ " .align 4\n" \
+ " .long 661b\n" /* label */ \
+ " .long 663f\n" /* new instruction */ \
+ " .byte 0x68\n" /* X86_FEATURE_UP */ \
+ " .byte 662b-661b\n" /* sourcelen */ \
+ " .byte 664f-663f\n" /* replacementlen */ \
+ ".previous\n" \
+ ".section .smp_altinstr_replacement,\"awx\"\n" \
+ "663:\n\t" upinstr "\n" /* replacement */ \
+ "664:\n\t.fill 662b-661b,1,0x42\n" /* space for original */ \
+ ".previous" : args)
+
+#define LOCK_PREFIX \
+ ".section .smp_locks,\"a\"\n" \
+ " .align 4\n" \
+ " .long 661f\n" /* address */ \
+ ".previous\n" \
+ "661:\n\tlock; "
+
+#else /* ! CONFIG_SMP */
+#define alternative_smp(smpinstr, upinstr, args...) \
+ asm volatile (upinstr : args)
+#define LOCK_PREFIX ""
+#endif
+
+#endif /* _I386_ALTERNATIVE_H */
diff --git a/include/asm-i386/arch_hooks.h b/include/asm-i386/arch_hooks.h
index 28b96a6fb9f..238cf4275b9 100644
--- a/include/asm-i386/arch_hooks.h
+++ b/include/asm-i386/arch_hooks.h
@@ -24,4 +24,7 @@ extern void trap_init_hook(void);
extern void time_init_hook(void);
extern void mca_nmi_hook(void);
+extern int setup_early_printk(char *);
+extern void early_printk(const char *fmt, ...) __attribute__((format(printf,1,2)));
+
#endif
diff --git a/include/asm-i386/atomic.h b/include/asm-i386/atomic.h
index de649d3aa2d..22d80ece95c 100644
--- a/include/asm-i386/atomic.h
+++ b/include/asm-i386/atomic.h
@@ -10,12 +10,6 @@
* resource counting etc..
*/
-#ifdef CONFIG_SMP
-#define LOCK "lock ; "
-#else
-#define LOCK ""
-#endif
-
/*
* Make sure gcc doesn't try to be clever and move things around
* on us. We need to use _exactly_ the address the user gave us,
@@ -52,7 +46,7 @@ typedef struct { volatile int counter; } atomic_t;
static __inline__ void atomic_add(int i, atomic_t *v)
{
__asm__ __volatile__(
- LOCK "addl %1,%0"
+ LOCK_PREFIX "addl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}
@@ -67,7 +61,7 @@ static __inline__ void atomic_add(int i, atomic_t *v)
static __inline__ void atomic_sub(int i, atomic_t *v)
{
__asm__ __volatile__(
- LOCK "subl %1,%0"
+ LOCK_PREFIX "subl %1,%0"
:"=m" (v->counter)
:"ir" (i), "m" (v->counter));
}
@@ -86,7 +80,7 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
unsigned char c;
__asm__ __volatile__(
- LOCK "subl %2,%0; sete %1"
+ LOCK_PREFIX "subl %2,%0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"ir" (i), "m" (v->counter) : "memory");
return c;
@@ -101,7 +95,7 @@ static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
static __inline__ void atomic_inc(atomic_t *v)
{
__asm__ __volatile__(
- LOCK "incl %0"
+ LOCK_PREFIX "incl %0"
:"=m" (v->counter)
:"m" (v->counter));
}
@@ -115,7 +109,7 @@ static __inline__ void atomic_inc(atomic_t *v)
static __inline__ void atomic_dec(atomic_t *v)
{
__asm__ __volatile__(
- LOCK "decl %0"
+ LOCK_PREFIX "decl %0"
:"=m" (v->counter)
:"m" (v->counter));
}
@@ -133,7 +127,7 @@ static __inline__ int atomic_dec_and_test(atomic_t *v)
unsigned char c;
__asm__ __volatile__(
- LOCK "decl %0; sete %1"
+ LOCK_PREFIX "decl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"m" (v->counter) : "memory");
return c != 0;
@@ -152,7 +146,7 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)
unsigned char c;
__asm__ __volatile__(
- LOCK "incl %0; sete %1"
+ LOCK_PREFIX "incl %0; sete %1"
:"=m" (v->counter), "=qm" (c)
:"m" (v->counter) : "memory");
return c != 0;
@@ -172,7 +166,7 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
unsigned char c;
__asm__ __volatile__(
- LOCK "addl %2,%0; sets %1"
+ LOCK_PREFIX "addl %2,%0; sets %1"
:"=m" (v->counter), "=qm" (c)
:"ir" (i), "m" (v->counter) : "memory");
return c;
@@ -195,7 +189,7 @@ static __inline__ int atomic_add_return(int i, atomic_t *v)
/* Modern 486+ processor */
__i = i;
__asm__ __volatile__(
- LOCK "xaddl %0, %1;"
+ LOCK_PREFIX "xaddl %0, %1;"
:"=r"(i)
:"m"(v->counter), "0"(i));
return i + __i;
@@ -231,8 +225,14 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
({ \
int c, old; \
c = atomic_read(v); \
- while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ for (;;) { \
+ if (unlikely(c == (u))) \
+ break; \
+ old = atomic_cmpxchg((v), c, c + (a)); \
+ if (likely(old == c)) \
+ break; \
c = old; \
+ } \
c != (u); \
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
@@ -242,11 +242,11 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
/* These are x86-specific, used by some header files */
#define atomic_clear_mask(mask, addr) \
-__asm__ __volatile__(LOCK "andl %0,%1" \
+__asm__ __volatile__(LOCK_PREFIX "andl %0,%1" \
: : "r" (~(mask)),"m" (*addr) : "memory")
#define atomic_set_mask(mask, addr) \
-__asm__ __volatile__(LOCK "orl %0,%1" \
+__asm__ __volatile__(LOCK_PREFIX "orl %0,%1" \
: : "r" (mask),"m" (*(addr)) : "memory")
/* Atomic operations are already serializing on x86 */
diff --git a/include/asm-i386/bitops.h b/include/asm-i386/bitops.h
index 88e6ca248cd..7d20b95edb3 100644
--- a/include/asm-i386/bitops.h
+++ b/include/asm-i386/bitops.h
@@ -7,6 +7,7 @@
#include <linux/config.h>
#include <linux/compiler.h>
+#include <asm/alternative.h>
/*
* These have to be done with inline assembly: that way the bit-setting
@@ -16,12 +17,6 @@
* bit 0 is the LSB of addr; bit 32 is the LSB of (addr+1).
*/
-#ifdef CONFIG_SMP
-#define LOCK_PREFIX "lock ; "
-#else
-#define LOCK_PREFIX ""
-#endif
-
#define ADDR (*(volatile long *) addr)
/**
diff --git a/include/asm-i386/cache.h b/include/asm-i386/cache.h
index 615911e5bd2..ca15c9c665c 100644
--- a/include/asm-i386/cache.h
+++ b/include/asm-i386/cache.h
@@ -10,4 +10,6 @@
#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
#endif
diff --git a/include/asm-i386/cpufeature.h b/include/asm-i386/cpufeature.h
index c4ec2a4d8fd..5c0b5876b93 100644
--- a/include/asm-i386/cpufeature.h
+++ b/include/asm-i386/cpufeature.h
@@ -70,6 +70,7 @@
#define X86_FEATURE_P3 (3*32+ 6) /* P3 */
#define X86_FEATURE_P4 (3*32+ 7) /* P4 */
#define X86_FEATURE_CONSTANT_TSC (3*32+ 8) /* TSC ticks at a constant rate */
+#define X86_FEATURE_UP (3*32+ 9) /* smp kernel running on up */
/* Intel-defined CPU features, CPUID level 0x00000001 (ecx), word 4 */
#define X86_FEATURE_XMM3 (4*32+ 0) /* Streaming SIMD Extensions-3 */
diff --git a/include/asm-i386/io.h b/include/asm-i386/io.h
index 03233c2ab82..79670bb4b0c 100644
--- a/include/asm-i386/io.h
+++ b/include/asm-i386/io.h
@@ -219,23 +219,11 @@ static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int
*/
#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
-#define isa_readb(a) readb(__ISA_IO_base + (a))
-#define isa_readw(a) readw(__ISA_IO_base + (a))
-#define isa_readl(a) readl(__ISA_IO_base + (a))
-#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
-#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
-#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
-#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
-#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
-#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
-
-
/*
* Again, i386 does not require mem IO specific function.
*/
#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(b),(c),(d))
-#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void __force *)(__ISA_IO_base + (b)),(c),(d))
/**
* check_signature - find BIOS signatures
diff --git a/include/asm-i386/mach-default/do_timer.h b/include/asm-i386/mach-default/do_timer.h
index 56211414fc9..6312c3e7981 100644
--- a/include/asm-i386/mach-default/do_timer.h
+++ b/include/asm-i386/mach-default/do_timer.h
@@ -18,7 +18,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
{
do_timer(regs);
#ifndef CONFIG_SMP
- update_process_times(user_mode(regs));
+ update_process_times(user_mode_vm(regs));
#endif
/*
* In the SMP case we use the local APIC timer interrupt to do the
diff --git a/include/asm-i386/mach-es7000/mach_mpparse.h b/include/asm-i386/mach-es7000/mach_mpparse.h
index 4a0637a3e20..99f66be240b 100644
--- a/include/asm-i386/mach-es7000/mach_mpparse.h
+++ b/include/asm-i386/mach-es7000/mach_mpparse.h
@@ -30,7 +30,8 @@ static inline int mps_oem_check(struct mp_config_table *mpc, char *oem,
return 0;
}
-static inline int es7000_check_dsdt()
+#ifdef CONFIG_ACPI
+static inline int es7000_check_dsdt(void)
{
struct acpi_table_header *header = NULL;
if(!acpi_get_table_header_early(ACPI_DSDT, &header))
@@ -54,6 +55,11 @@ static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
}
return 0;
}
-
+#else
+static inline int acpi_madt_oem_check(char *oem_id, char *oem_table_id)
+{
+ return 0;
+}
+#endif
#endif /* __ASM_MACH_MPPARSE_H */
diff --git a/include/asm-i386/mach-visws/do_timer.h b/include/asm-i386/mach-visws/do_timer.h
index 92d638fc8b1..95568e6ca91 100644
--- a/include/asm-i386/mach-visws/do_timer.h
+++ b/include/asm-i386/mach-visws/do_timer.h
@@ -11,7 +11,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
do_timer(regs);
#ifndef CONFIG_SMP
- update_process_times(user_mode(regs));
+ update_process_times(user_mode_vm(regs));
#endif
/*
* In the SMP case we use the local APIC timer interrupt to do the
diff --git a/include/asm-i386/mach-voyager/do_timer.h b/include/asm-i386/mach-voyager/do_timer.h
index ae510e5d0d7..eaf51809898 100644
--- a/include/asm-i386/mach-voyager/do_timer.h
+++ b/include/asm-i386/mach-voyager/do_timer.h
@@ -5,7 +5,7 @@ static inline void do_timer_interrupt_hook(struct pt_regs *regs)
{
do_timer(regs);
#ifndef CONFIG_SMP
- update_process_times(user_mode(regs));
+ update_process_times(user_mode_vm(regs));
#endif
voyager_timer_interrupt(regs);
diff --git a/include/asm-i386/mpspec.h b/include/asm-i386/mpspec.h
index 64a0b8e6afe..62113d3bfdc 100644
--- a/include/asm-i386/mpspec.h
+++ b/include/asm-i386/mpspec.h
@@ -22,7 +22,6 @@ extern int mp_bus_id_to_type [MAX_MP_BUSSES];
extern int mp_irq_entries;
extern struct mpc_config_intsrc mp_irqs [MAX_IRQ_SOURCES];
extern int mpc_default_type;
-extern int mp_bus_id_to_pci_bus [MAX_MP_BUSSES];
extern unsigned long mp_lapic_addr;
extern int pic_mode;
extern int using_apic_timer;
diff --git a/include/asm-i386/mtrr.h b/include/asm-i386/mtrr.h
index 5b6ceda68c5..64cf937c7e3 100644
--- a/include/asm-i386/mtrr.h
+++ b/include/asm-i386/mtrr.h
@@ -25,6 +25,7 @@
#include <linux/config.h>
#include <linux/ioctl.h>
+#include <linux/errno.h>
#define MTRR_IOCTL_BASE 'M'
diff --git a/include/asm-i386/mutex.h b/include/asm-i386/mutex.h
index 9b2199e829f..05a53853122 100644
--- a/include/asm-i386/mutex.h
+++ b/include/asm-i386/mutex.h
@@ -9,6 +9,8 @@
#ifndef _ASM_MUTEX_H
#define _ASM_MUTEX_H
+#include "asm/alternative.h"
+
/**
* __mutex_fastpath_lock - try to take the lock by moving the count
* from 1 to a 0 value
@@ -27,7 +29,7 @@ do { \
typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \
\
__asm__ __volatile__( \
- LOCK " decl (%%eax) \n" \
+ LOCK_PREFIX " decl (%%eax) \n" \
" js 2f \n" \
"1: \n" \
\
@@ -83,7 +85,7 @@ do { \
typecheck_fn(fastcall void (*)(atomic_t *), fail_fn); \
\
__asm__ __volatile__( \
- LOCK " incl (%%eax) \n" \
+ LOCK_PREFIX " incl (%%eax) \n" \
" jle 2f \n" \
"1: \n" \
\
diff --git a/include/asm-i386/pgtable-2level.h b/include/asm-i386/pgtable-2level.h
index 74ef721b534..27bde973abc 100644
--- a/include/asm-i386/pgtable-2level.h
+++ b/include/asm-i386/pgtable-2level.h
@@ -61,4 +61,6 @@ static inline int pte_exec_kernel(pte_t pte)
#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+void vmalloc_sync_all(void);
+
#endif /* _I386_PGTABLE_2LEVEL_H */
diff --git a/include/asm-i386/pgtable-3level.h b/include/asm-i386/pgtable-3level.h
index f1a8b454920..36a5aa63cbb 100644
--- a/include/asm-i386/pgtable-3level.h
+++ b/include/asm-i386/pgtable-3level.h
@@ -152,4 +152,6 @@ static inline pmd_t pfn_pmd(unsigned long page_nr, pgprot_t pgprot)
#define __pmd_free_tlb(tlb, x) do { } while (0)
+#define vmalloc_sync_all() ((void)0)
+
#endif /* _I386_PGTABLE_3LEVEL_H */
diff --git a/include/asm-i386/poll.h b/include/asm-i386/poll.h
index aecc80a15d3..2cd4929abd4 100644
--- a/include/asm-i386/poll.h
+++ b/include/asm-i386/poll.h
@@ -16,6 +16,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-i386/rwlock.h b/include/asm-i386/rwlock.h
index b57cc7afdf7..94f00195d54 100644
--- a/include/asm-i386/rwlock.h
+++ b/include/asm-i386/rwlock.h
@@ -21,21 +21,23 @@
#define RW_LOCK_BIAS_STR "0x01000000"
#define __build_read_lock_ptr(rw, helper) \
- asm volatile(LOCK "subl $1,(%0)\n\t" \
- "jns 1f\n" \
- "call " helper "\n\t" \
- "1:\n" \
- ::"a" (rw) : "memory")
+ alternative_smp("lock; subl $1,(%0)\n\t" \
+ "jns 1f\n" \
+ "call " helper "\n\t" \
+ "1:\n", \
+ "subl $1,(%0)\n\t", \
+ :"a" (rw) : "memory")
#define __build_read_lock_const(rw, helper) \
- asm volatile(LOCK "subl $1,%0\n\t" \
- "jns 1f\n" \
- "pushl %%eax\n\t" \
- "leal %0,%%eax\n\t" \
- "call " helper "\n\t" \
- "popl %%eax\n\t" \
- "1:\n" \
- :"=m" (*(volatile int *)rw) : : "memory")
+ alternative_smp("lock; subl $1,%0\n\t" \
+ "jns 1f\n" \
+ "pushl %%eax\n\t" \
+ "leal %0,%%eax\n\t" \
+ "call " helper "\n\t" \
+ "popl %%eax\n\t" \
+ "1:\n", \
+ "subl $1,%0\n\t", \
+ "=m" (*(volatile int *)rw) : : "memory")
#define __build_read_lock(rw, helper) do { \
if (__builtin_constant_p(rw)) \
@@ -45,21 +47,23 @@
} while (0)
#define __build_write_lock_ptr(rw, helper) \
- asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
- "jz 1f\n" \
- "call " helper "\n\t" \
- "1:\n" \
- ::"a" (rw) : "memory")
+ alternative_smp("lock; subl $" RW_LOCK_BIAS_STR ",(%0)\n\t" \
+ "jz 1f\n" \
+ "call " helper "\n\t" \
+ "1:\n", \
+ "subl $" RW_LOCK_BIAS_STR ",(%0)\n\t", \
+ :"a" (rw) : "memory")
#define __build_write_lock_const(rw, helper) \
- asm volatile(LOCK "subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
- "jz 1f\n" \
- "pushl %%eax\n\t" \
- "leal %0,%%eax\n\t" \
- "call " helper "\n\t" \
- "popl %%eax\n\t" \
- "1:\n" \
- :"=m" (*(volatile int *)rw) : : "memory")
+ alternative_smp("lock; subl $" RW_LOCK_BIAS_STR ",%0\n\t" \
+ "jz 1f\n" \
+ "pushl %%eax\n\t" \
+ "leal %0,%%eax\n\t" \
+ "call " helper "\n\t" \
+ "popl %%eax\n\t" \
+ "1:\n", \
+ "subl $" RW_LOCK_BIAS_STR ",%0\n\t", \
+ "=m" (*(volatile int *)rw) : : "memory")
#define __build_write_lock(rw, helper) do { \
if (__builtin_constant_p(rw)) \
diff --git a/include/asm-i386/semaphore.h b/include/asm-i386/semaphore.h
index 6a42b2142fd..f7a0f310c52 100644
--- a/include/asm-i386/semaphore.h
+++ b/include/asm-i386/semaphore.h
@@ -99,7 +99,7 @@ static inline void down(struct semaphore * sem)
might_sleep();
__asm__ __volatile__(
"# atomic down operation\n\t"
- LOCK "decl %0\n\t" /* --sem->count */
+ LOCK_PREFIX "decl %0\n\t" /* --sem->count */
"js 2f\n"
"1:\n"
LOCK_SECTION_START("")
@@ -123,7 +123,7 @@ static inline int down_interruptible(struct semaphore * sem)
might_sleep();
__asm__ __volatile__(
"# atomic interruptible down operation\n\t"
- LOCK "decl %1\n\t" /* --sem->count */
+ LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
@@ -148,7 +148,7 @@ static inline int down_trylock(struct semaphore * sem)
__asm__ __volatile__(
"# atomic interruptible down operation\n\t"
- LOCK "decl %1\n\t" /* --sem->count */
+ LOCK_PREFIX "decl %1\n\t" /* --sem->count */
"js 2f\n\t"
"xorl %0,%0\n"
"1:\n"
@@ -173,7 +173,7 @@ static inline void up(struct semaphore * sem)
{
__asm__ __volatile__(
"# atomic up operation\n\t"
- LOCK "incl %0\n\t" /* ++sem->count */
+ LOCK_PREFIX "incl %0\n\t" /* ++sem->count */
"jle 2f\n"
"1:\n"
LOCK_SECTION_START("")
diff --git a/include/asm-i386/spinlock.h b/include/asm-i386/spinlock.h
index 23604350cdf..d76b7693cf1 100644
--- a/include/asm-i386/spinlock.h
+++ b/include/asm-i386/spinlock.h
@@ -35,31 +35,41 @@
#define __raw_spin_lock_string_flags \
"\n1:\t" \
"lock ; decb %0\n\t" \
- "jns 4f\n\t" \
+ "jns 5f\n" \
"2:\t" \
"testl $0x200, %1\n\t" \
- "jz 3f\n\t" \
- "sti\n\t" \
+ "jz 4f\n\t" \
+ "sti\n" \
"3:\t" \
"rep;nop\n\t" \
"cmpb $0, %0\n\t" \
"jle 3b\n\t" \
"cli\n\t" \
"jmp 1b\n" \
- "4:\n\t"
+ "4:\t" \
+ "rep;nop\n\t" \
+ "cmpb $0, %0\n\t" \
+ "jg 1b\n\t" \
+ "jmp 4b\n" \
+ "5:\n\t"
+
+#define __raw_spin_lock_string_up \
+ "\n\tdecb %0"
static inline void __raw_spin_lock(raw_spinlock_t *lock)
{
- __asm__ __volatile__(
- __raw_spin_lock_string
- :"=m" (lock->slock) : : "memory");
+ alternative_smp(
+ __raw_spin_lock_string,
+ __raw_spin_lock_string_up,
+ "=m" (lock->slock) : : "memory");
}
static inline void __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
{
- __asm__ __volatile__(
- __raw_spin_lock_string_flags
- :"=m" (lock->slock) : "r" (flags) : "memory");
+ alternative_smp(
+ __raw_spin_lock_string_flags,
+ __raw_spin_lock_string_up,
+ "=m" (lock->slock) : "r" (flags) : "memory");
}
static inline int __raw_spin_trylock(raw_spinlock_t *lock)
@@ -178,12 +188,12 @@ static inline int __raw_write_trylock(raw_rwlock_t *lock)
static inline void __raw_read_unlock(raw_rwlock_t *rw)
{
- asm volatile("lock ; incl %0" :"=m" (rw->lock) : : "memory");
+ asm volatile(LOCK_PREFIX "incl %0" :"=m" (rw->lock) : : "memory");
}
static inline void __raw_write_unlock(raw_rwlock_t *rw)
{
- asm volatile("lock ; addl $" RW_LOCK_BIAS_STR ", %0"
+ asm volatile(LOCK_PREFIX "addl $" RW_LOCK_BIAS_STR ", %0"
: "=m" (rw->lock) : : "memory");
}
diff --git a/include/asm-i386/system.h b/include/asm-i386/system.h
index 399145a247f..19cc79c9a35 100644
--- a/include/asm-i386/system.h
+++ b/include/asm-i386/system.h
@@ -352,67 +352,6 @@ static inline unsigned long long __cmpxchg64(volatile void *ptr, unsigned long l
#endif
-#ifdef __KERNEL__
-struct alt_instr {
- __u8 *instr; /* original instruction */
- __u8 *replacement;
- __u8 cpuid; /* cpuid bit set for replacement */
- __u8 instrlen; /* length of original instruction */
- __u8 replacementlen; /* length of new instruction, <= instrlen */
- __u8 pad;
-};
-#endif
-
-/*
- * Alternative instructions for different CPU types or capabilities.
- *
- * This allows to use optimized instructions even on generic binary
- * kernels.
- *
- * length of oldinstr must be longer or equal the length of newinstr
- * It can be padded with nops as needed.
- *
- * For non barrier like inlines please define new variants
- * without volatile and memory clobber.
- */
-#define alternative(oldinstr, newinstr, feature) \
- asm volatile ("661:\n\t" oldinstr "\n662:\n" \
- ".section .altinstructions,\"a\"\n" \
- " .align 4\n" \
- " .long 661b\n" /* label */ \
- " .long 663f\n" /* new instruction */ \
- " .byte %c0\n" /* feature bit */ \
- " .byte 662b-661b\n" /* sourcelen */ \
- " .byte 664f-663f\n" /* replacementlen */ \
- ".previous\n" \
- ".section .altinstr_replacement,\"ax\"\n" \
- "663:\n\t" newinstr "\n664:\n" /* replacement */ \
- ".previous" :: "i" (feature) : "memory")
-
-/*
- * Alternative inline assembly with input.
- *
- * Pecularities:
- * No memory clobber here.
- * Argument numbers start with 1.
- * Best is to use constraints that are fixed size (like (%1) ... "r")
- * If you use variable sized constraints like "m" or "g" in the
- * replacement maake sure to pad to the worst case length.
- */
-#define alternative_input(oldinstr, newinstr, feature, input...) \
- asm volatile ("661:\n\t" oldinstr "\n662:\n" \
- ".section .altinstructions,\"a\"\n" \
- " .align 4\n" \
- " .long 661b\n" /* label */ \
- " .long 663f\n" /* new instruction */ \
- " .byte %c0\n" /* feature bit */ \
- " .byte 662b-661b\n" /* sourcelen */ \
- " .byte 664f-663f\n" /* replacementlen */ \
- ".previous\n" \
- ".section .altinstr_replacement,\"ax\"\n" \
- "663:\n\t" newinstr "\n664:\n" /* replacement */ \
- ".previous" :: "i" (feature), ##input)
-
/*
* Force strict CPU ordering.
* And yes, this is required on UP too when we're talking
@@ -558,5 +497,8 @@ static inline void sched_cacheflush(void)
}
extern unsigned long arch_align_stack(unsigned long sp);
+extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
+
+void default_idle(void);
#endif
diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
index 3f1337c3420..371457b1ceb 100644
--- a/include/asm-i386/uaccess.h
+++ b/include/asm-i386/uaccess.h
@@ -197,13 +197,15 @@ extern void __put_user_8(void);
#define put_user(x,ptr) \
({ int __ret_pu; \
+ __typeof__(*(ptr)) __pu_val; \
__chk_user_ptr(ptr); \
+ __pu_val = x; \
switch(sizeof(*(ptr))) { \
- case 1: __put_user_1(x, ptr); break; \
- case 2: __put_user_2(x, ptr); break; \
- case 4: __put_user_4(x, ptr); break; \
- case 8: __put_user_8(x, ptr); break; \
- default:__put_user_X(x, ptr); break; \
+ case 1: __put_user_1(__pu_val, ptr); break; \
+ case 2: __put_user_2(__pu_val, ptr); break; \
+ case 4: __put_user_4(__pu_val, ptr); break; \
+ case 8: __put_user_8(__pu_val, ptr); break; \
+ default:__put_user_X(__pu_val, ptr); break; \
} \
__ret_pu; \
})
diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h
index dc81a55dd94..d8afd0e3b81 100644
--- a/include/asm-i386/unistd.h
+++ b/include/asm-i386/unistd.h
@@ -347,9 +347,9 @@ __syscall_return(type,__res); \
type name(type1 arg1) \
{ \
long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
: "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)) : "memory"); \
+ : "0" (__NR_##name),"ri" ((long)(arg1)) : "memory"); \
__syscall_return(type,__res); \
}
@@ -357,9 +357,10 @@ __syscall_return(type,__res); \
type name(type1 arg1,type2 arg2) \
{ \
long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
: "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)) : "memory"); \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)) \
+ : "memory"); \
__syscall_return(type,__res); \
}
@@ -367,9 +368,9 @@ __syscall_return(type,__res); \
type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
: "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)) : "memory"); \
__syscall_return(type,__res); \
}
@@ -378,9 +379,9 @@ __syscall_return(type,__res); \
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" \
: "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
+ : "0" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
"d" ((long)(arg3)),"S" ((long)(arg4)) : "memory"); \
__syscall_return(type,__res); \
}
@@ -390,10 +391,12 @@ __syscall_return(type,__res); \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
{ \
long __res; \
-__asm__ volatile ("int $0x80" \
+__asm__ volatile ("push %%ebx ; movl %2,%%ebx ; movl %1,%%eax ; " \
+ "int $0x80 ; pop %%ebx" \
: "=a" (__res) \
- : "0" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) : "memory"); \
+ : "i" (__NR_##name),"ri" ((long)(arg1)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+ : "memory"); \
__syscall_return(type,__res); \
}
@@ -402,11 +405,14 @@ __syscall_return(type,__res); \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
{ \
long __res; \
-__asm__ volatile ("push %%ebp ; movl %%eax,%%ebp ; movl %1,%%eax ; int $0x80 ; pop %%ebp" \
+ struct { long __a1; long __a6; } __s = { (long)arg1, (long)arg6 }; \
+__asm__ volatile ("push %%ebp ; push %%ebx ; movl 4(%2),%%ebp ; " \
+ "movl 0(%2),%%ebx ; movl %1,%%eax ; int $0x80 ; " \
+ "pop %%ebx ; pop %%ebp" \
: "=a" (__res) \
- : "i" (__NR_##name),"b" ((long)(arg1)),"c" ((long)(arg2)), \
- "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)), \
- "0" ((long)(arg6)) : "memory"); \
+ : "i" (__NR_##name),"0" ((long)(&__s)),"c" ((long)(arg2)), \
+ "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)) \
+ : "memory"); \
__syscall_return(type,__res); \
}
diff --git a/include/asm-ia64/atomic.h b/include/asm-ia64/atomic.h
index d3e0dfa99e1..569ec7574ba 100644
--- a/include/asm-ia64/atomic.h
+++ b/include/asm-ia64/atomic.h
@@ -95,8 +95,14 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
({ \
int c, old; \
c = atomic_read(v); \
- while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ for (;;) { \
+ if (unlikely(c == (u))) \
+ break; \
+ old = atomic_cmpxchg((v), c, c + (a)); \
+ if (likely(old == c)) \
+ break; \
c = old; \
+ } \
c != (u); \
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-ia64/cache.h b/include/asm-ia64/cache.h
index 40dd25195d6..f0a104db8f2 100644
--- a/include/asm-ia64/cache.h
+++ b/include/asm-ia64/cache.h
@@ -25,4 +25,6 @@
# define SMP_CACHE_BYTES (1 << 3)
#endif
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
#endif /* _ASM_IA64_CACHE_H */
diff --git a/include/asm-ia64/linkage.h b/include/asm-ia64/linkage.h
index 14cd72cd800..ef22a45c189 100644
--- a/include/asm-ia64/linkage.h
+++ b/include/asm-ia64/linkage.h
@@ -1,6 +1,14 @@
#ifndef __ASM_LINKAGE_H
#define __ASM_LINKAGE_H
+#ifndef __ASSEMBLY__
+
#define asmlinkage CPP_ASMLINKAGE __attribute__((syscall_linkage))
+#else
+
+#include <asm/asmmacro.h>
+
+#endif
+
#endif
diff --git a/include/asm-ia64/poll.h b/include/asm-ia64/poll.h
index 160258a0528..bcaf9f14024 100644
--- a/include/asm-ia64/poll.h
+++ b/include/asm-ia64/poll.h
@@ -21,6 +21,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-ia64/sn/sn_sal.h b/include/asm-ia64/sn/sn_sal.h
index 246f43a796d..244449df741 100644
--- a/include/asm-ia64/sn/sn_sal.h
+++ b/include/asm-ia64/sn/sn_sal.h
@@ -1041,7 +1041,7 @@ ia64_sn_get_sn_info(int fc, u8 *shubtype, u16 *nasid_bitmask, u8 *nasid_shift,
/***** BEGIN HACK - temp til old proms no longer supported ********/
if (ret_stuff.status == SALRET_NOT_IMPLEMENTED) {
- int nasid = get_sapicid() & 0xfff;;
+ int nasid = get_sapicid() & 0xfff;
#define SH_SHUB_ID_NODES_PER_BIT_MASK 0x001f000000000000UL
#define SH_SHUB_ID_NODES_PER_BIT_SHFT 48
if (shubtype) *shubtype = 0;
diff --git a/include/asm-ia64/system.h b/include/asm-ia64/system.h
index cd4233d66f1..2f362059368 100644
--- a/include/asm-ia64/system.h
+++ b/include/asm-ia64/system.h
@@ -265,6 +265,8 @@ void sched_cacheflush(void);
#define arch_align_stack(x) (x)
+void default_idle(void);
+
#endif /* __KERNEL__ */
#endif /* __ASSEMBLY__ */
diff --git a/include/asm-m32r/poll.h b/include/asm-m32r/poll.h
index 43b7acf732d..9e0e700e727 100644
--- a/include/asm-m32r/poll.h
+++ b/include/asm-m32r/poll.h
@@ -21,6 +21,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-m68k/atomic.h b/include/asm-m68k/atomic.h
index 862e497c264..732d696d31a 100644
--- a/include/asm-m68k/atomic.h
+++ b/include/asm-m68k/atomic.h
@@ -175,8 +175,14 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
({ \
int c, old; \
c = atomic_read(v); \
- while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ for (;;) { \
+ if (unlikely(c == (u))) \
+ break; \
+ old = atomic_cmpxchg((v), c, c + (a)); \
+ if (likely(old == c)) \
+ break; \
c = old; \
+ } \
c != (u); \
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-m68k/poll.h b/include/asm-m68k/poll.h
index c4b69c4a87e..0fb8843647f 100644
--- a/include/asm-m68k/poll.h
+++ b/include/asm-m68k/poll.h
@@ -13,6 +13,7 @@
#define POLLWRBAND 256
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index 546a17e56a9..6b17eb9d79a 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -556,24 +556,11 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
*/
#define __ISA_IO_base ((char *)(isa_slot_offset))
-#define isa_readb(a) readb(__ISA_IO_base + (a))
-#define isa_readw(a) readw(__ISA_IO_base + (a))
-#define isa_readl(a) readl(__ISA_IO_base + (a))
-#define isa_readq(a) readq(__ISA_IO_base + (a))
-#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
-#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
-#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
-#define isa_writeq(q,a) writeq(q,__ISA_IO_base + (a))
-#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
-#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
-#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
-
/*
* We don't have csum_partial_copy_fromio() yet, so we cheat here and
* just copy it. The net code will then do the checksum later.
*/
#define eth_io_copy_and_sum(skb,src,len,unused) memcpy_fromio((skb)->data,(src),(len))
-#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(b),(c),(d))
/*
* check_signature - find BIOS signatures
diff --git a/include/asm-mips/linkage.h b/include/asm-mips/linkage.h
index 291c2d01c44..b6185d3cfe6 100644
--- a/include/asm-mips/linkage.h
+++ b/include/asm-mips/linkage.h
@@ -1,6 +1,8 @@
#ifndef __ASM_LINKAGE_H
#define __ASM_LINKAGE_H
-/* Nothing to see here... */
+#ifdef __ASSEMBLY__
+#include <asm/asm.h>
+#endif
#endif
diff --git a/include/asm-mips/poll.h b/include/asm-mips/poll.h
index a000f1f789e..70881f8c5c5 100644
--- a/include/asm-mips/poll.h
+++ b/include/asm-mips/poll.h
@@ -17,6 +17,7 @@
/* These seem to be more or less nonstandard ... */
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-parisc/cache.h b/include/asm-parisc/cache.h
index 93f179f13ce..ae50f8e12ee 100644
--- a/include/asm-parisc/cache.h
+++ b/include/asm-parisc/cache.h
@@ -29,6 +29,8 @@
#define SMP_CACHE_BYTES L1_CACHE_BYTES
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
extern void flush_data_cache_local(void *); /* flushes local data-cache only */
extern void flush_instruction_cache_local(void *); /* flushes local code-cache only */
#ifdef CONFIG_SMP
diff --git a/include/asm-parisc/io.h b/include/asm-parisc/io.h
index 0db00adc942..be0c7234a6d 100644
--- a/include/asm-parisc/io.h
+++ b/include/asm-parisc/io.h
@@ -294,22 +294,6 @@ void memset_io(volatile void __iomem *addr, unsigned char val, int count);
void memcpy_fromio(void *dst, const volatile void __iomem *src, int count);
void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
-/* Support old drivers which don't ioremap.
- * NB this interface is scheduled to disappear in 2.5
- */
-
-#define __isa_addr(x) (void __iomem *)(F_EXTEND(0xfc000000) | (x))
-#define isa_readb(a) readb(__isa_addr(a))
-#define isa_readw(a) readw(__isa_addr(a))
-#define isa_readl(a) readl(__isa_addr(a))
-#define isa_writeb(b,a) writeb((b), __isa_addr(a))
-#define isa_writew(b,a) writew((b), __isa_addr(a))
-#define isa_writel(b,a) writel((b), __isa_addr(a))
-#define isa_memset_io(a,b,c) memset_io(__isa_addr(a), (b), (c))
-#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a), __isa_addr(b), (c))
-#define isa_memcpy_toio(a,b,c) memcpy_toio(__isa_addr(a), (b), (c))
-
-
/*
* XXX - We don't have csum_partial_copy_fromio() yet, so we cheat here and
* just copy it. The net code will then do the checksum later. Presently
@@ -318,8 +302,6 @@ void memcpy_toio(volatile void __iomem *dst, const void *src, int count);
#define eth_io_copy_and_sum(skb,src,len,unused) \
memcpy_fromio((skb)->data,(src),(len))
-#define isa_eth_io_copy_and_sum(skb,src,len,unused) \
- isa_memcpy_fromio((skb)->data,(src),(len))
/* Port-space IO */
diff --git a/include/asm-parisc/poll.h b/include/asm-parisc/poll.h
index 1c1da86934c..20e4d03c74c 100644
--- a/include/asm-parisc/poll.h
+++ b/include/asm-parisc/poll.h
@@ -16,6 +16,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h
index 147a38dcc76..bb3c0ab7e66 100644
--- a/include/asm-powerpc/atomic.h
+++ b/include/asm-powerpc/atomic.h
@@ -8,6 +8,7 @@
typedef struct { volatile int counter; } atomic_t;
#ifdef __KERNEL__
+#include <linux/compiler.h>
#include <asm/synch.h>
#include <asm/asm-compat.h>
@@ -176,20 +177,29 @@ static __inline__ int atomic_dec_return(atomic_t *v)
* Atomically adds @a to @v, so long as it was not @u.
* Returns non-zero if @v was not @u, and zero otherwise.
*/
-#define atomic_add_unless(v, a, u) \
-({ \
- int c, old; \
- c = atomic_read(v); \
- for (;;) { \
- if (unlikely(c == (u))) \
- break; \
- old = atomic_cmpxchg((v), c, c + (a)); \
- if (likely(old == c)) \
- break; \
- c = old; \
- } \
- c != (u); \
-})
+static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
+{
+ int t;
+
+ __asm__ __volatile__ (
+ LWSYNC_ON_SMP
+"1: lwarx %0,0,%1 # atomic_add_unless\n\
+ cmpw 0,%0,%3 \n\
+ beq- 2f \n\
+ add %0,%2,%0 \n"
+ PPC405_ERR77(0,%2)
+" stwcx. %0,0,%1 \n\
+ bne- 1b \n"
+ ISYNC_ON_SMP
+" subf %0,%2,%0 \n\
+2:"
+ : "=&r" (t)
+ : "r" (&v->counter), "r" (a), "r" (u)
+ : "cc", "memory");
+
+ return t != u;
+}
+
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
index 5638518968c..fe45f6f3a4b 100644
--- a/include/asm-powerpc/cputable.h
+++ b/include/asm-powerpc/cputable.h
@@ -102,38 +102,40 @@ extern void do_cpu_ftr_fixups(unsigned long offset);
#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000)
#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000)
#define CPU_FTR_BIG_PHYS ASM_CONST(0x0000000000080000)
-#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000)
+#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000)
#ifdef __powerpc64__
/* Add the 64b processor unique features in the top half of the word */
-#define CPU_FTR_SLB ASM_CONST(0x0000000100000000)
-#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000)
-#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000)
-#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000)
-#define CPU_FTR_IABR ASM_CONST(0x0000002000000000)
-#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000)
+#define CPU_FTR_SLB ASM_CONST(0x0000000100000000)
+#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000)
+#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000)
+#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000)
+#define CPU_FTR_IABR ASM_CONST(0x0000002000000000)
+#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000)
#define CPU_FTR_CTRL ASM_CONST(0x0000008000000000)
-#define CPU_FTR_SMT ASM_CONST(0x0000010000000000)
-#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000)
+#define CPU_FTR_SMT ASM_CONST(0x0000010000000000)
+#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000)
#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000)
#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000)
#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0000100000000000)
#define CPU_FTR_PAUSE_ZERO ASM_CONST(0x0000200000000000)
+#define CPU_FTR_PURR ASM_CONST(0x0000400000000000)
#else
/* ensure on 32b processors the flags are available for compiling but
* don't do anything */
-#define CPU_FTR_SLB ASM_CONST(0x0)
-#define CPU_FTR_16M_PAGE ASM_CONST(0x0)
-#define CPU_FTR_TLBIEL ASM_CONST(0x0)
-#define CPU_FTR_NOEXECUTE ASM_CONST(0x0)
-#define CPU_FTR_IABR ASM_CONST(0x0)
-#define CPU_FTR_MMCRA ASM_CONST(0x0)
+#define CPU_FTR_SLB ASM_CONST(0x0)
+#define CPU_FTR_16M_PAGE ASM_CONST(0x0)
+#define CPU_FTR_TLBIEL ASM_CONST(0x0)
+#define CPU_FTR_NOEXECUTE ASM_CONST(0x0)
+#define CPU_FTR_IABR ASM_CONST(0x0)
+#define CPU_FTR_MMCRA ASM_CONST(0x0)
#define CPU_FTR_CTRL ASM_CONST(0x0)
-#define CPU_FTR_SMT ASM_CONST(0x0)
-#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0)
+#define CPU_FTR_SMT ASM_CONST(0x0)
+#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0)
#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0)
#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0)
#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0)
+#define CPU_FTR_PURR ASM_CONST(0x0)
#endif
#ifndef __ASSEMBLY__
@@ -318,7 +320,7 @@ enum {
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
CPU_FTR_MMCRA | CPU_FTR_SMT |
CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE |
- CPU_FTR_MMCRA_SIHV,
+ CPU_FTR_MMCRA_SIHV | CPU_FTR_PURR,
CPU_FTRS_CELL = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT |
diff --git a/include/asm-powerpc/cputime.h b/include/asm-powerpc/cputime.h
index 6d68ad7e0ea..a21185d4788 100644
--- a/include/asm-powerpc/cputime.h
+++ b/include/asm-powerpc/cputime.h
@@ -1 +1,203 @@
+/*
+ * Definitions for measuring cputime on powerpc machines.
+ *
+ * Copyright (C) 2006 Paul Mackerras, IBM Corp.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * If we have CONFIG_VIRT_CPU_ACCOUNTING, we measure cpu time in
+ * the same units as the timebase. Otherwise we measure cpu time
+ * in jiffies using the generic definitions.
+ */
+
+#ifndef __POWERPC_CPUTIME_H
+#define __POWERPC_CPUTIME_H
+
+#ifndef CONFIG_VIRT_CPU_ACCOUNTING
#include <asm-generic/cputime.h>
+#else
+
+#include <linux/types.h>
+#include <linux/time.h>
+#include <asm/div64.h>
+#include <asm/time.h>
+#include <asm/param.h>
+
+typedef u64 cputime_t;
+typedef u64 cputime64_t;
+
+#define cputime_zero ((cputime_t)0)
+#define cputime_max ((~((cputime_t)0) >> 1) - 1)
+#define cputime_add(__a, __b) ((__a) + (__b))
+#define cputime_sub(__a, __b) ((__a) - (__b))
+#define cputime_div(__a, __n) ((__a) / (__n))
+#define cputime_halve(__a) ((__a) >> 1)
+#define cputime_eq(__a, __b) ((__a) == (__b))
+#define cputime_gt(__a, __b) ((__a) > (__b))
+#define cputime_ge(__a, __b) ((__a) >= (__b))
+#define cputime_lt(__a, __b) ((__a) < (__b))
+#define cputime_le(__a, __b) ((__a) <= (__b))
+
+#define cputime64_zero ((cputime64_t)0)
+#define cputime64_add(__a, __b) ((__a) + (__b))
+#define cputime_to_cputime64(__ct) (__ct)
+
+#ifdef __KERNEL__
+
+/*
+ * Convert cputime <-> jiffies
+ */
+extern u64 __cputime_jiffies_factor;
+
+static inline unsigned long cputime_to_jiffies(const cputime_t ct)
+{
+ return mulhdu(ct, __cputime_jiffies_factor);
+}
+
+static inline cputime_t jiffies_to_cputime(const unsigned long jif)
+{
+ cputime_t ct;
+ unsigned long sec;
+
+ /* have to be a little careful about overflow */
+ ct = jif % HZ;
+ sec = jif / HZ;
+ if (ct) {
+ ct *= tb_ticks_per_sec;
+ do_div(ct, HZ);
+ }
+ if (sec)
+ ct += (cputime_t) sec * tb_ticks_per_sec;
+ return ct;
+}
+
+static inline u64 cputime64_to_jiffies64(const cputime_t ct)
+{
+ return mulhdu(ct, __cputime_jiffies_factor);
+}
+
+/*
+ * Convert cputime <-> milliseconds
+ */
+extern u64 __cputime_msec_factor;
+
+static inline unsigned long cputime_to_msecs(const cputime_t ct)
+{
+ return mulhdu(ct, __cputime_msec_factor);
+}
+
+static inline cputime_t msecs_to_cputime(const unsigned long ms)
+{
+ cputime_t ct;
+ unsigned long sec;
+
+ /* have to be a little careful about overflow */
+ ct = ms % 1000;
+ sec = ms / 1000;
+ if (ct) {
+ ct *= tb_ticks_per_sec;
+ do_div(ct, 1000);
+ }
+ if (sec)
+ ct += (cputime_t) sec * tb_ticks_per_sec;
+ return ct;
+}
+
+/*
+ * Convert cputime <-> seconds
+ */
+extern u64 __cputime_sec_factor;
+
+static inline unsigned long cputime_to_secs(const cputime_t ct)
+{
+ return mulhdu(ct, __cputime_sec_factor);
+}
+
+static inline cputime_t secs_to_cputime(const unsigned long sec)
+{
+ return (cputime_t) sec * tb_ticks_per_sec;
+}
+
+/*
+ * Convert cputime <-> timespec
+ */
+static inline void cputime_to_timespec(const cputime_t ct, struct timespec *p)
+{
+ u64 x = ct;
+ unsigned int frac;
+
+ frac = do_div(x, tb_ticks_per_sec);
+ p->tv_sec = x;
+ x = (u64) frac * 1000000000;
+ do_div(x, tb_ticks_per_sec);
+ p->tv_nsec = x;
+}
+
+static inline cputime_t timespec_to_cputime(const struct timespec *p)
+{
+ cputime_t ct;
+
+ ct = (u64) p->tv_nsec * tb_ticks_per_sec;
+ do_div(ct, 1000000000);
+ return ct + (u64) p->tv_sec * tb_ticks_per_sec;
+}
+
+/*
+ * Convert cputime <-> timeval
+ */
+static inline void cputime_to_timeval(const cputime_t ct, struct timeval *p)
+{
+ u64 x = ct;
+ unsigned int frac;
+
+ frac = do_div(x, tb_ticks_per_sec);
+ p->tv_sec = x;
+ x = (u64) frac * 1000000;
+ do_div(x, tb_ticks_per_sec);
+ p->tv_usec = x;
+}
+
+static inline cputime_t timeval_to_cputime(const struct timeval *p)
+{
+ cputime_t ct;
+
+ ct = (u64) p->tv_usec * tb_ticks_per_sec;
+ do_div(ct, 1000000);
+ return ct + (u64) p->tv_sec * tb_ticks_per_sec;
+}
+
+/*
+ * Convert cputime <-> clock_t (units of 1/USER_HZ seconds)
+ */
+extern u64 __cputime_clockt_factor;
+
+static inline unsigned long cputime_to_clock_t(const cputime_t ct)
+{
+ return mulhdu(ct, __cputime_clockt_factor);
+}
+
+static inline cputime_t clock_t_to_cputime(const unsigned long clk)
+{
+ cputime_t ct;
+ unsigned long sec;
+
+ /* have to be a little careful about overflow */
+ ct = clk % USER_HZ;
+ sec = clk / USER_HZ;
+ if (ct) {
+ ct *= tb_ticks_per_sec;
+ do_div(ct, USER_HZ);
+ }
+ if (sec)
+ ct += (cputime_t) sec * tb_ticks_per_sec;
+ return ct;
+}
+
+#define cputime64_to_clock_t(ct) cputime_to_clock_t((cputime_t)(ct))
+
+#endif /* __KERNEL__ */
+#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
+#endif /* __POWERPC_CPUTIME_H */
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
index f804b34cf06..ce3788224ed 100644
--- a/include/asm-powerpc/firmware.h
+++ b/include/asm-powerpc/firmware.h
@@ -41,6 +41,7 @@
#define FW_FEATURE_MULTITCE (1UL<<19)
#define FW_FEATURE_SPLPAR (1UL<<20)
#define FW_FEATURE_ISERIES (1UL<<21)
+#define FW_FEATURE_LPAR (1UL<<22)
enum {
#ifdef CONFIG_PPC64
@@ -51,10 +52,10 @@ enum {
FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE |
- FW_FEATURE_SPLPAR,
+ FW_FEATURE_SPLPAR | FW_FEATURE_LPAR,
FW_FEATURE_PSERIES_ALWAYS = 0,
- FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES,
- FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES,
+ FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
+ FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
FW_FEATURE_POSSIBLE =
#ifdef CONFIG_PPC_PSERIES
FW_FEATURE_PSERIES_POSSIBLE |
@@ -89,15 +90,6 @@ static inline unsigned long firmware_has_feature(unsigned long feature)
(FW_FEATURE_POSSIBLE & ppc64_firmware_features & feature);
}
-#ifdef CONFIG_PPC_PSERIES
-typedef struct {
- unsigned long val;
- char * name;
-} firmware_feature_t;
-
-extern firmware_feature_t firmware_features_table[];
-#endif
-
extern void system_reset_fwnmi(void);
extern void machine_check_fwnmi(void);
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
index 8eb7e857ec4..51f87d9993b 100644
--- a/include/asm-powerpc/irq.h
+++ b/include/asm-powerpc/irq.h
@@ -479,6 +479,10 @@ extern int distribute_irqs;
struct irqaction;
struct pt_regs;
+#define __ARCH_HAS_DO_SOFTIRQ
+
+extern void __do_softirq(void);
+
#ifdef CONFIG_IRQSTACKS
/*
* Per-cpu stacks for handling hard and soft interrupts.
@@ -491,8 +495,6 @@ extern void call_do_softirq(struct thread_info *tp);
extern int call___do_IRQ(int irq, struct pt_regs *regs,
struct thread_info *tp);
-#define __ARCH_HAS_DO_SOFTIRQ
-
#else
#define irq_ctx_init()
diff --git a/include/asm-powerpc/iseries/mf.h b/include/asm-powerpc/iseries/mf.h
index 857e5202fc7..eb851a9c9e5 100644
--- a/include/asm-powerpc/iseries/mf.h
+++ b/include/asm-powerpc/iseries/mf.h
@@ -41,16 +41,11 @@ extern void mf_deallocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
unsigned count, MFCompleteHandler hdlr, void *userToken);
extern void mf_power_off(void);
-extern void mf_reboot(void);
+extern void mf_reboot(char *cmd);
extern void mf_display_src(u32 word);
extern void mf_display_progress(u16 value);
-extern void mf_clear_src(void);
extern void mf_init(void);
-extern int mf_get_rtc(struct rtc_time *tm);
-extern int mf_get_boot_rtc(struct rtc_time *tm);
-extern int mf_set_rtc(struct rtc_time *tm);
-
#endif /* _ASM_POWERPC_ISERIES_MF_H */
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
index d3546c4c9f4..0c5880f7022 100644
--- a/include/asm-powerpc/lmb.h
+++ b/include/asm-powerpc/lmb.h
@@ -19,8 +19,6 @@
#define MAX_LMB_REGIONS 128
-#define LMB_ALLOC_ANYWHERE 0
-
struct lmb_property {
unsigned long base;
unsigned long size;
@@ -43,20 +41,19 @@ extern struct lmb lmb;
extern void __init lmb_init(void);
extern void __init lmb_analyze(void);
-extern long __init lmb_add(unsigned long, unsigned long);
-extern long __init lmb_reserve(unsigned long, unsigned long);
-extern unsigned long __init lmb_alloc(unsigned long, unsigned long);
-extern unsigned long __init lmb_alloc_base(unsigned long, unsigned long,
- unsigned long);
+extern long __init lmb_add(unsigned long base, unsigned long size);
+extern long __init lmb_reserve(unsigned long base, unsigned long size);
+extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
+extern unsigned long __init lmb_alloc_base(unsigned long size,
+ unsigned long align, unsigned long max_addr);
+extern unsigned long __init __lmb_alloc_base(unsigned long size,
+ unsigned long align, unsigned long max_addr);
extern unsigned long __init lmb_phys_mem_size(void);
extern unsigned long __init lmb_end_of_DRAM(void);
-extern unsigned long __init lmb_abs_to_phys(unsigned long);
-extern void __init lmb_enforce_memory_limit(unsigned long);
+extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
extern void lmb_dump_all(void);
-extern unsigned long io_hole_start;
-
static inline unsigned long
lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
{
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
index b0b9a3f8cdc..31f721994bd 100644
--- a/include/asm-powerpc/mmu.h
+++ b/include/asm-powerpc/mmu.h
@@ -236,7 +236,6 @@ extern void htab_initialize_secondary(void);
extern void hpte_init_native(void);
extern void hpte_init_lpar(void);
extern void hpte_init_iSeries(void);
-extern void mm_init_ppc64(void);
extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
unsigned long va, unsigned long prpn,
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
index c9add8f1ad9..4465b95ebef 100644
--- a/include/asm-powerpc/paca.h
+++ b/include/asm-powerpc/paca.h
@@ -54,7 +54,7 @@ struct paca_struct {
#endif /* CONFIG_PPC_ISERIES */
/*
- * MAGIC: the spinlock functions in arch/ppc64/lib/locks.c
+ * MAGIC: the spinlock functions in arch/powerpc/lib/locks.c
* load lock_token and paca_index with a single lwz
* instruction. They must travel together and be properly
* aligned.
@@ -96,6 +96,11 @@ struct paca_struct {
u64 saved_r1; /* r1 save for RTAS calls */
u64 saved_msr; /* MSR saved here by enter_rtas */
u8 proc_enabled; /* irq soft-enable flag */
+
+ /* Stuff for accurate time accounting */
+ u64 user_time; /* accumulated usermode TB ticks */
+ u64 system_time; /* accumulated system TB ticks */
+ u64 startpurr; /* PURR/TB value snapshot */
};
extern struct paca_struct paca[];
diff --git a/include/asm-powerpc/percpu.h b/include/asm-powerpc/percpu.h
index e31922c50e5..464301cd0d0 100644
--- a/include/asm-powerpc/percpu.h
+++ b/include/asm-powerpc/percpu.h
@@ -27,10 +27,9 @@
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for (__i = 0; __i < NR_CPUS; __i++) \
- if (cpu_possible(__i)) \
- memcpy((pcpudst)+__per_cpu_offset(__i), \
- (src), (size)); \
+ for_each_cpu(__i) \
+ memcpy((pcpudst)+__per_cpu_offset(__i), \
+ (src), (size)); \
} while (0)
extern void setup_per_cpu_areas(void);
diff --git a/include/asm-powerpc/pgtable-4k.h b/include/asm-powerpc/pgtable-4k.h
index 80a7832d272..b2e18629932 100644
--- a/include/asm-powerpc/pgtable-4k.h
+++ b/include/asm-powerpc/pgtable-4k.h
@@ -62,9 +62,14 @@
/* shift to put page number into pte */
#define PTE_RPN_SHIFT (17)
-#define __real_pte(e,p) ((real_pte_t)(e))
-#define __rpte_to_pte(r) (r)
-#define __rpte_to_hidx(r,index) (pte_val((r)) >> 12)
+#ifdef STRICT_MM_TYPECHECKS
+#define __real_pte(e,p) ((real_pte_t){(e)})
+#define __rpte_to_pte(r) ((r).pte)
+#else
+#define __real_pte(e,p) (e)
+#define __rpte_to_pte(r) (__pte(r))
+#endif
+#define __rpte_to_hidx(r,index) (pte_val(__rpte_to_pte(r)) >> 12)
#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
do { \
diff --git a/include/asm-powerpc/pgtable.h b/include/asm-powerpc/pgtable.h
index 185ee15963a..e9f1f4627e6 100644
--- a/include/asm-powerpc/pgtable.h
+++ b/include/asm-powerpc/pgtable.h
@@ -188,9 +188,13 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
#define pte_pfn(x) ((unsigned long)((pte_val(x)>>PTE_RPN_SHIFT)))
#define pte_page(x) pfn_to_page(pte_pfn(x))
+#define PMD_BAD_BITS (PTE_TABLE_SIZE-1)
+#define PUD_BAD_BITS (PMD_TABLE_SIZE-1)
+
#define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval))
#define pmd_none(pmd) (!pmd_val(pmd))
-#define pmd_bad(pmd) (pmd_val(pmd) == 0)
+#define pmd_bad(pmd) (!is_kernel_addr(pmd_val(pmd)) \
+ || (pmd_val(pmd) & PMD_BAD_BITS))
#define pmd_present(pmd) (pmd_val(pmd) != 0)
#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
#define pmd_page_kernel(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
@@ -198,7 +202,8 @@ static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
#define pud_none(pud) (!pud_val(pud))
-#define pud_bad(pud) ((pud_val(pud)) == 0)
+#define pud_bad(pud) (!is_kernel_addr(pud_val(pud)) \
+ || (pud_val(pud) & PUD_BAD_BITS))
#define pud_present(pud) (pud_val(pud) != 0)
#define pud_clear(pudp) (pud_val(*(pudp)) = 0)
#define pud_page(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
diff --git a/include/asm-powerpc/poll.h b/include/asm-powerpc/poll.h
index edd2054da86..9c7d1263103 100644
--- a/include/asm-powerpc/poll.h
+++ b/include/asm-powerpc/poll.h
@@ -13,6 +13,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
index ab8688d3902..dd1c0a913d5 100644
--- a/include/asm-powerpc/ppc_asm.h
+++ b/include/asm-powerpc/ppc_asm.h
@@ -15,6 +15,48 @@
#define SZL (BITS_PER_LONG/8)
/*
+ * Stuff for accurate CPU time accounting.
+ * These macros handle transitions between user and system state
+ * in exception entry and exit and accumulate time to the
+ * user_time and system_time fields in the paca.
+ */
+
+#ifndef CONFIG_VIRT_CPU_ACCOUNTING
+#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
+#define ACCOUNT_CPU_USER_EXIT(ra, rb)
+#else
+#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
+ beq 2f; /* if from kernel mode */ \
+BEGIN_FTR_SECTION; \
+ mfspr ra,SPRN_PURR; /* get processor util. reg */ \
+END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
+BEGIN_FTR_SECTION; \
+ mftb ra; /* or get TB if no PURR */ \
+END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
+ ld rb,PACA_STARTPURR(r13); \
+ std ra,PACA_STARTPURR(r13); \
+ subf rb,rb,ra; /* subtract start value */ \
+ ld ra,PACA_USER_TIME(r13); \
+ add ra,ra,rb; /* add on to user time */ \
+ std ra,PACA_USER_TIME(r13); \
+2:
+
+#define ACCOUNT_CPU_USER_EXIT(ra, rb) \
+BEGIN_FTR_SECTION; \
+ mfspr ra,SPRN_PURR; /* get processor util. reg */ \
+END_FTR_SECTION_IFSET(CPU_FTR_PURR); \
+BEGIN_FTR_SECTION; \
+ mftb ra; /* or get TB if no PURR */ \
+END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
+ ld rb,PACA_STARTPURR(r13); \
+ std ra,PACA_STARTPURR(r13); \
+ subf rb,rb,ra; /* subtract start value */ \
+ ld ra,PACA_SYSTEM_TIME(r13); \
+ add ra,ra,rb; /* add on to user time */ \
+ std ra,PACA_SYSTEM_TIME(r13);
+#endif
+
+/*
* Macros for storing registers into and loading registers from
* exception frames.
*/
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
index 415fa393b00..1c64a211cf1 100644
--- a/include/asm-powerpc/processor.h
+++ b/include/asm-powerpc/processor.h
@@ -52,7 +52,6 @@
#ifdef __KERNEL__
#define platform_is_pseries() (_machine == PLATFORM_PSERIES || \
_machine == PLATFORM_PSERIES_LPAR)
-#define platform_is_lpar() (!!(_machine & PLATFORM_LPAR))
#if defined(CONFIG_PPC_MULTIPLATFORM)
extern int _machine;
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index cbd297f44cc..782e13a070a 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -126,8 +126,14 @@ extern struct device_node *find_all_nodes(void);
/* New style node lookup */
extern struct device_node *of_find_node_by_name(struct device_node *from,
const char *name);
+#define for_each_node_by_name(dn, name) \
+ for (dn = of_find_node_by_name(NULL, name); dn; \
+ dn = of_find_node_by_name(dn, name))
extern struct device_node *of_find_node_by_type(struct device_node *from,
const char *type);
+#define for_each_node_by_type(dn, type) \
+ for (dn = of_find_node_by_type(NULL, type); dn; \
+ dn = of_find_node_by_type(dn, type))
extern struct device_node *of_find_compatible_node(struct device_node *from,
const char *type, const char *compat);
extern struct device_node *of_find_node_by_path(const char *path);
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h
index 79bae4933b7..2c2fe964759 100644
--- a/include/asm-powerpc/rwsem.h
+++ b/include/asm-powerpc/rwsem.h
@@ -4,7 +4,7 @@
#ifdef __KERNEL__
/*
- * include/asm-ppc64/rwsem.h: R/W semaphores for PPC using the stuff
+ * include/asm-powerpc/rwsem.h: R/W semaphores for PPC using the stuff
* in lib/rwsem.c. Adapted largely from include/asm-i386/rwsem.h
* by Paul Mackerras <paulus@samba.org>.
*/
diff --git a/include/asm-powerpc/synch.h b/include/asm-powerpc/synch.h
index c90d9d9aae7..2cda3c38a9f 100644
--- a/include/asm-powerpc/synch.h
+++ b/include/asm-powerpc/synch.h
@@ -15,7 +15,7 @@
#endif
#ifdef CONFIG_SMP
-#define ISYNC_ON_SMP "\n\tisync"
+#define ISYNC_ON_SMP "\n\tisync\n"
#define LWSYNC_ON_SMP __stringify(LWSYNC) "\n"
#else
#define ISYNC_ON_SMP
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
index d9bf53653b1..65f5a7b2646 100644
--- a/include/asm-powerpc/system.h
+++ b/include/asm-powerpc/system.h
@@ -171,6 +171,8 @@ extern u32 booke_wdt_period;
/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
extern unsigned char e2a(unsigned char);
+extern unsigned char* strne2a(unsigned char *dest,
+ const unsigned char *src, size_t n);
struct device_node;
extern void note_scsi_host(struct device_node *, void *);
@@ -424,5 +426,9 @@ static inline void create_function_call(unsigned long addr, void * func)
create_branch(addr, func_addr, BRANCH_SET_LINK);
}
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+extern void account_system_vtime(struct task_struct *);
+#endif
+
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_SYSTEM_H */
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
index baddc9ab57a..912118db13a 100644
--- a/include/asm-powerpc/time.h
+++ b/include/asm-powerpc/time.h
@@ -41,6 +41,7 @@ extern time_t last_rtc_update;
extern void generic_calibrate_decr(void);
extern void wakeup_decrementer(void);
+extern void snapshot_timebase(void);
/* Some sane defaults: 125 MHz timebase, 1GHz processor */
extern unsigned long ppc_proc_freq;
@@ -221,5 +222,19 @@ struct cpu_usage {
DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
+#ifdef CONFIG_VIRT_CPU_ACCOUNTING
+extern void account_process_vtime(struct task_struct *tsk);
+#else
+#define account_process_vtime(tsk) do { } while (0)
+#endif
+
+#if defined(CONFIG_VIRT_CPU_ACCOUNTING) && defined(CONFIG_PPC_SPLPAR)
+extern void calculate_steal_time(void);
+extern void snapshot_timebases(void);
+#else
+#define calculate_steal_time() do { } while (0)
+#define snapshot_timebases() do { } while (0)
+#endif
+
#endif /* __KERNEL__ */
#endif /* __PPC64_TIME_H */
diff --git a/include/asm-ppc/harrier.h b/include/asm-ppc/harrier.h
index 36c73ab7e43..7acd7fc126e 100644
--- a/include/asm-ppc/harrier.h
+++ b/include/asm-ppc/harrier.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/harrier.h
- *
* Definitions for Motorola MCG Harrier North Bridge & Memory controller
*
* Author: Dale Farnsworth
diff --git a/include/asm-ppc/ibm44x.h b/include/asm-ppc/ibm44x.h
index f835066fb3c..3acc382cc83 100644
--- a/include/asm-ppc/ibm44x.h
+++ b/include/asm-ppc/ibm44x.h
@@ -29,7 +29,7 @@
/* TLB entry offset/size used for pinning kernel lowmem */
#define PPC44x_PIN_SHIFT 28
-#define PPC44x_PIN_SIZE (1 << PPC44x_PIN_SHIFT)
+#define PPC_PIN_SIZE (1 << PPC44x_PIN_SHIFT)
/* Lowest TLB slot consumed by the default pinned TLBs */
#define PPC44x_LOW_SLOT 63
diff --git a/include/asm-ppc/ibm4xx.h b/include/asm-ppc/ibm4xx.h
index 6c28ae7807f..38f99710752 100644
--- a/include/asm-ppc/ibm4xx.h
+++ b/include/asm-ppc/ibm4xx.h
@@ -51,6 +51,10 @@
#include <platforms/4xx/xilinx_ml300.h>
#endif
+#if defined(CONFIG_XILINX_ML403)
+#include <platforms/4xx/xilinx_ml403.h>
+#endif
+
#ifndef __ASSEMBLY__
#ifdef CONFIG_40x
diff --git a/include/asm-ppc/io.h b/include/asm-ppc/io.h
index df9cf6ed189..b919d8fb7d9 100644
--- a/include/asm-ppc/io.h
+++ b/include/asm-ppc/io.h
@@ -575,4 +575,11 @@ extern void pci_iounmap(struct pci_dev *dev, void __iomem *);
*/
#define xlate_dev_kmem_ptr(p) p
+/* access ports */
+#define setbits32(_addr, _v) out_be32((_addr), in_be32(_addr) | (_v))
+#define clrbits32(_addr, _v) out_be32((_addr), in_be32(_addr) & ~(_v))
+
+#define setbits16(_addr, _v) out_be16((_addr), in_be16(_addr) | (_v))
+#define clrbits16(_addr, _v) out_be16((_addr), in_be16(_addr) & ~(_v))
+
#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/mpc10x.h b/include/asm-ppc/mpc10x.h
index 77b1e092c20..b30a6a3b5bd 100644
--- a/include/asm-ppc/mpc10x.h
+++ b/include/asm-ppc/mpc10x.h
@@ -1,6 +1,4 @@
/*
- * arch/ppc/kernel/mpc10x.h
- *
* Common routines for the Motorola SPS MPC106/8240/107 Host bridge/Mem
* ctlr/EPIC/etc.
*
@@ -165,6 +163,7 @@ enum ppc_sys_devices {
MPC10X_DMA1,
MPC10X_UART0,
MPC10X_UART1,
+ NUM_PPC_SYS_DEVS,
};
int mpc10x_bridge_init(struct pci_controller *hose,
diff --git a/include/asm-ppc/mpc52xx.h b/include/asm-ppc/mpc52xx.h
index a055e0756b9..6167f74635f 100644
--- a/include/asm-ppc/mpc52xx.h
+++ b/include/asm-ppc/mpc52xx.h
@@ -60,6 +60,7 @@ enum ppc_sys_devices {
MPC52xx_ATA,
MPC52xx_I2C1,
MPC52xx_I2C2,
+ NUM_PPC_SYS_DEVS,
};
diff --git a/include/asm-ppc/mpc8260.h b/include/asm-ppc/mpc8260.h
index 32145269503..6ba69a86b9d 100644
--- a/include/asm-ppc/mpc8260.h
+++ b/include/asm-ppc/mpc8260.h
@@ -83,6 +83,7 @@ enum ppc_sys_devices {
MPC82xx_CPM_SMC2,
MPC82xx_CPM_USB,
MPC82xx_SEC1,
+ NUM_PPC_SYS_DEVS,
};
#ifndef __ASSEMBLY__
diff --git a/include/asm-ppc/mpc83xx.h b/include/asm-ppc/mpc83xx.h
index 7cdf60fa69b..3c23fc43bfb 100644
--- a/include/asm-ppc/mpc83xx.h
+++ b/include/asm-ppc/mpc83xx.h
@@ -108,6 +108,7 @@ enum ppc_sys_devices {
MPC83xx_USB2_DR,
MPC83xx_USB2_MPH,
MPC83xx_MDIO,
+ NUM_PPC_SYS_DEVS,
};
#endif /* CONFIG_83xx */
diff --git a/include/asm-ppc/mpc85xx.h b/include/asm-ppc/mpc85xx.h
index c8a96aa44fb..f47002a60ed 100644
--- a/include/asm-ppc/mpc85xx.h
+++ b/include/asm-ppc/mpc85xx.h
@@ -139,6 +139,7 @@ enum ppc_sys_devices {
MPC85xx_eTSEC4,
MPC85xx_IIC2,
MPC85xx_MDIO,
+ NUM_PPC_SYS_DEVS,
};
/* Internal interrupts are all Level Sensitive, and Positive Polarity */
diff --git a/include/asm-ppc/mpc8xx.h b/include/asm-ppc/mpc8xx.h
index 46f159cf589..3515a7fa6c8 100644
--- a/include/asm-ppc/mpc8xx.h
+++ b/include/asm-ppc/mpc8xx.h
@@ -111,8 +111,11 @@ enum ppc_sys_devices {
MPC8xx_CPM_SMC1,
MPC8xx_CPM_SMC2,
MPC8xx_CPM_USB,
+ NUM_PPC_SYS_DEVS,
};
+#define PPC_PIN_SIZE (24 * 1024 * 1024) /* 24Mbytes of data pinned */
+
#ifndef BOARD_CHIP_NAME
#define BOARD_CHIP_NAME ""
#endif
diff --git a/include/asm-ppc/pgtable.h b/include/asm-ppc/pgtable.h
index 6d1c39e8a6a..e1c62da12e7 100644
--- a/include/asm-ppc/pgtable.h
+++ b/include/asm-ppc/pgtable.h
@@ -12,6 +12,7 @@
#include <asm/processor.h> /* For TASK_SIZE */
#include <asm/mmu.h>
#include <asm/page.h>
+#include <asm/io.h> /* For sub-arch specific PPC_PIN_SIZE */
struct mm_struct;
extern unsigned long va_to_phys(unsigned long address);
@@ -127,9 +128,8 @@ extern unsigned long ioremap_bot, ioremap_base;
* of RAM. -- Cort
*/
#define VMALLOC_OFFSET (0x1000000) /* 16M */
-#ifdef CONFIG_44x
-#include <asm/ibm44x.h>
-#define VMALLOC_START (((_ALIGN((long)high_memory, PPC44x_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
+#ifdef PPC_PIN_SIZE
+#define VMALLOC_START (((_ALIGN((long)high_memory, PPC_PIN_SIZE) + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
#else
#define VMALLOC_START ((((long)high_memory + VMALLOC_OFFSET) & ~(VMALLOC_OFFSET-1)))
#endif
diff --git a/include/asm-ppc/ppc_sys.h b/include/asm-ppc/ppc_sys.h
index 83d8c77c124..4b94f7059eb 100644
--- a/include/asm-ppc/ppc_sys.h
+++ b/include/asm-ppc/ppc_sys.h
@@ -33,6 +33,8 @@
#include <asm/mpc52xx.h>
#elif defined(CONFIG_MPC10X_BRIDGE)
#include <asm/mpc10x.h>
+#elif defined(CONFIG_XILINX_VIRTEX)
+#include <platforms/4xx/virtex.h>
#else
#error "need definition of ppc_sys_devices"
#endif
@@ -44,9 +46,26 @@ struct ppc_sys_spec {
u32 value;
u32 num_devices;
char *ppc_sys_name;
+ u8 config[NUM_PPC_SYS_DEVS];
enum ppc_sys_devices *device_list;
};
+struct platform_notify_dev_map {
+ const char *bus_id;
+ void (*rtn)(struct platform_device * pdev, int idx);
+};
+
+enum platform_device_func {
+ PPC_SYS_FUNC_DUMMY = 0,
+ PPC_SYS_FUNC_ETH = 1,
+ PPC_SYS_FUNC_UART = 2,
+ PPC_SYS_FUNC_HLDC = 3,
+ PPC_SYS_FUNC_USB = 4,
+ PPC_SYS_FUNC_IRDA = 5,
+};
+
+#define PPC_SYS_CONFIG_DISABLED 1
+
/* describes all specific chips and which devices they have on them */
extern struct ppc_sys_spec ppc_sys_specs[];
extern struct ppc_sys_spec *cur_ppc_sys_spec;
@@ -72,5 +91,20 @@ extern void *ppc_sys_get_pdata(enum ppc_sys_devices dev) __init;
/* remove a device from the system */
extern void ppc_sys_device_remove(enum ppc_sys_devices dev);
+/* Function assignment stuff */
+void ppc_sys_device_initfunc(void);
+void ppc_sys_device_setfunc(enum ppc_sys_devices dev,
+ enum platform_device_func func);
+void ppc_sys_device_set_func_all(enum platform_device_func func);
+
+void platform_notify_map(const struct platform_notify_dev_map *map,
+ struct device *dev);
+
+/* Enable / disable stuff */
+void ppc_sys_device_disable(enum ppc_sys_devices dev);
+void ppc_sys_device_enable(enum ppc_sys_devices dev);
+void ppc_sys_device_enable_all(void);
+void ppc_sys_device_disable_all(void);
+
#endif /* __ASM_PPC_SYS_H */
#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/time.h b/include/asm-ppc/time.h
index 321fb75b5f2..c86112323c9 100644
--- a/include/asm-ppc/time.h
+++ b/include/asm-ppc/time.h
@@ -153,5 +153,10 @@ extern __inline__ unsigned binary_tbl(void) {
({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
unsigned mulhwu_scale_factor(unsigned, unsigned);
+
+#define account_process_vtime(tsk) do { } while (0)
+#define calculate_steal_time() do { } while (0)
+#define snapshot_timebases() do { } while (0)
+
#endif /* __ASM_TIME_H__ */
#endif /* __KERNEL__ */
diff --git a/include/asm-ppc/todc.h b/include/asm-ppc/todc.h
index 84bae7d7681..937c7dbe6e5 100644
--- a/include/asm-ppc/todc.h
+++ b/include/asm-ppc/todc.h
@@ -1,6 +1,4 @@
/*
- * include/asm-ppc/todc.h
- *
* Definitions for the M48Txx and mc146818 series of Time of day/Real Time
* Clock chips.
*
diff --git a/include/asm-ppc/xparameters.h b/include/asm-ppc/xparameters.h
deleted file mode 100644
index fe4eac62913..00000000000
--- a/include/asm-ppc/xparameters.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * include/asm-ppc/xparameters.h
- *
- * This file includes the correct xparameters.h for the CONFIG'ed board
- *
- * Author: MontaVista Software, Inc.
- * source@mvista.com
- *
- * 2004 (c) MontaVista Software, Inc. This file is licensed under the terms
- * of the GNU General Public License version 2. This program is licensed
- * "as is" without any warranty of any kind, whether express or implied.
- */
-
-#include <linux/config.h>
-
-#if defined(CONFIG_XILINX_ML300)
-#include <platforms/4xx/xparameters/xparameters_ml300.h>
-#endif
diff --git a/include/asm-s390/atomic.h b/include/asm-s390/atomic.h
index be6fefe223d..de1d9926aa6 100644
--- a/include/asm-s390/atomic.h
+++ b/include/asm-s390/atomic.h
@@ -89,10 +89,15 @@ static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new)
static __inline__ int atomic_add_unless(atomic_t *v, int a, int u)
{
int c, old;
-
c = atomic_read(v);
- while (c != u && (old = atomic_cmpxchg(v, c, c + a)) != c)
+ for (;;) {
+ if (unlikely(c == u))
+ break;
+ old = atomic_cmpxchg(v, c, c + a);
+ if (likely(old == c))
+ break;
c = old;
+ }
return c != u;
}
@@ -167,10 +172,15 @@ static __inline__ int atomic64_add_unless(atomic64_t *v,
long long a, long long u)
{
long long c, old;
-
c = atomic64_read(v);
- while (c != u && (old = atomic64_cmpxchg(v, c, c + a)) != c)
+ for (;;) {
+ if (unlikely(c == u))
+ break;
+ old = atomic64_cmpxchg(v, c, c + a);
+ if (likely(old == c))
+ break;
c = old;
+ }
return c != u;
}
diff --git a/include/asm-s390/bug.h b/include/asm-s390/bug.h
index a2e7430aafa..7ddaa05b98d 100644
--- a/include/asm-s390/bug.h
+++ b/include/asm-s390/bug.h
@@ -4,9 +4,10 @@
#include <linux/kernel.h>
#ifdef CONFIG_BUG
+
#define BUG() do { \
- printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
- __asm__ __volatile__(".long 0"); \
+ printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
+ __builtin_trap(); \
} while (0)
#define HAVE_ARCH_BUG
diff --git a/include/asm-s390/percpu.h b/include/asm-s390/percpu.h
index 123fcaca295..e10ed87094f 100644
--- a/include/asm-s390/percpu.h
+++ b/include/asm-s390/percpu.h
@@ -46,10 +46,9 @@ extern unsigned long __per_cpu_offset[NR_CPUS];
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for (__i = 0; __i < NR_CPUS; __i++) \
- if (cpu_possible(__i)) \
- memcpy((pcpudst)+__per_cpu_offset[__i], \
- (src), (size)); \
+ for_each_cpu(__i) \
+ memcpy((pcpudst)+__per_cpu_offset[__i], \
+ (src), (size)); \
} while (0)
#else /* ! SMP */
diff --git a/include/asm-s390/poll.h b/include/asm-s390/poll.h
index e90a5ca4206..6f7f65ac7d2 100644
--- a/include/asm-s390/poll.h
+++ b/include/asm-s390/poll.h
@@ -24,6 +24,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-sh/io.h b/include/asm-sh/io.h
index b0b2937b6f8..2c3afe71323 100644
--- a/include/asm-sh/io.h
+++ b/include/asm-sh/io.h
@@ -174,20 +174,6 @@ static inline void __set_io_port_base(unsigned long pbase)
generic_io_base = pbase;
}
-#define isa_readb(a) readb(ioport_map(a, 1))
-#define isa_readw(a) readw(ioport_map(a, 2))
-#define isa_readl(a) readl(ioport_map(a, 4))
-#define isa_writeb(b,a) writeb(b,ioport_map(a, 1))
-#define isa_writew(w,a) writew(w,ioport_map(a, 2))
-#define isa_writel(l,a) writel(l,ioport_map(a, 4))
-
-#define isa_memset_io(a,b,c) \
- memset((void *)(ioport_map((unsigned long)(a), 1)),(b),(c))
-#define isa_memcpy_fromio(a,b,c) \
- memcpy((a),(void *)(ioport_map((unsigned long)(b), 1)),(c))
-#define isa_memcpy_toio(a,b,c) \
- memcpy((void *)(ioport_map((unsigned long)(a), 1)),(b),(c))
-
/* We really want to try and get these to memcpy etc */
extern void memcpy_fromio(void *, volatile void __iomem *, unsigned long);
extern void memcpy_toio(volatile void __iomem *, const void *, unsigned long);
diff --git a/include/asm-sh/poll.h b/include/asm-sh/poll.h
index 52f95b9188d..dbca9b32f4a 100644
--- a/include/asm-sh/poll.h
+++ b/include/asm-sh/poll.h
@@ -16,6 +16,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-sh64/poll.h b/include/asm-sh64/poll.h
index a420d14eb70..3a6cbad08d2 100644
--- a/include/asm-sh64/poll.h
+++ b/include/asm-sh64/poll.h
@@ -26,6 +26,7 @@
#define POLLWRNORM 0x0100
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-sparc/cpudata.h b/include/asm-sparc/cpudata.h
index ec0d9ef90a3..a2c4d51d36c 100644
--- a/include/asm-sparc/cpudata.h
+++ b/include/asm-sparc/cpudata.h
@@ -18,6 +18,7 @@ typedef struct {
unsigned int counter;
int prom_node;
int mid;
+ int next;
} cpuinfo_sparc;
DECLARE_PER_CPU(cpuinfo_sparc, __cpu_data);
diff --git a/include/asm-sparc/poll.h b/include/asm-sparc/poll.h
index 3ddcc6481f0..26f13fb3549 100644
--- a/include/asm-sparc/poll.h
+++ b/include/asm-sparc/poll.h
@@ -13,6 +13,7 @@
#define POLLWRBAND 256
#define POLLMSG 512
#define POLLREMOVE 1024
+#define POLLRDHUP 2048
struct pollfd {
int fd;
diff --git a/include/asm-sparc/smp.h b/include/asm-sparc/smp.h
index 580c51d011d..98c46e3fbe8 100644
--- a/include/asm-sparc/smp.h
+++ b/include/asm-sparc/smp.h
@@ -81,16 +81,9 @@ static inline int smp_call_function(void (*func)(void *info), void *info, int no
return 0;
}
-extern __volatile__ int __cpu_number_map[NR_CPUS];
-extern __volatile__ int __cpu_logical_map[NR_CPUS];
-
static inline int cpu_logical_map(int cpu)
{
- return __cpu_logical_map[cpu];
-}
-static inline int cpu_number_map(int cpu)
-{
- return __cpu_number_map[cpu];
+ return cpu;
}
static inline int hard_smp4m_processor_id(void)
diff --git a/include/asm-sparc/spinlock.h b/include/asm-sparc/spinlock.h
index e344c98a6f5..3350c90c786 100644
--- a/include/asm-sparc/spinlock.h
+++ b/include/asm-sparc/spinlock.h
@@ -94,7 +94,7 @@ static inline void __read_lock(raw_rwlock_t *rw)
#define __raw_read_lock(lock) \
do { unsigned long flags; \
local_irq_save(flags); \
- __raw_read_lock(lock); \
+ __read_lock(lock); \
local_irq_restore(flags); \
} while(0)
@@ -114,11 +114,11 @@ static inline void __read_unlock(raw_rwlock_t *rw)
#define __raw_read_unlock(lock) \
do { unsigned long flags; \
local_irq_save(flags); \
- __raw_read_unlock(lock); \
+ __read_unlock(lock); \
local_irq_restore(flags); \
} while(0)
-extern __inline__ void __raw_write_lock(raw_rwlock_t *rw)
+static inline void __raw_write_lock(raw_rwlock_t *rw)
{
register raw_rwlock_t *lp asm("g1");
lp = rw;
@@ -131,9 +131,28 @@ extern __inline__ void __raw_write_lock(raw_rwlock_t *rw)
: "g2", "g4", "memory", "cc");
}
+static inline int __raw_write_trylock(raw_rwlock_t *rw)
+{
+ unsigned int val;
+
+ __asm__ __volatile__("ldstub [%1 + 3], %0"
+ : "=r" (val)
+ : "r" (&rw->lock)
+ : "memory");
+
+ if (val == 0) {
+ val = rw->lock & ~0xff;
+ if (val)
+ ((volatile u8*)&rw->lock)[3] = 0;
+ }
+
+ return (val == 0);
+}
+
#define __raw_write_unlock(rw) do { (rw)->lock = 0; } while(0)
#define __raw_spin_lock_flags(lock, flags) __raw_spin_lock(lock)
+#define __raw_read_trylock(lock) generic__raw_read_trylock(lock)
#endif /* !(__ASSEMBLY__) */
diff --git a/include/asm-sparc64/atomic.h b/include/asm-sparc64/atomic.h
index 25256bdc8aa..468eb48d814 100644
--- a/include/asm-sparc64/atomic.h
+++ b/include/asm-sparc64/atomic.h
@@ -78,9 +78,15 @@ extern int atomic64_sub_ret(int, atomic64_t *);
({ \
int c, old; \
c = atomic_read(v); \
- while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ for (;;) { \
+ if (unlikely(c == (u))) \
+ break; \
+ old = atomic_cmpxchg((v), c, c + (a)); \
+ if (likely(old == c)) \
+ break; \
c = old; \
- c != (u); \
+ } \
+ likely(c != (u)); \
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-sparc64/cache.h b/include/asm-sparc64/cache.h
index f7d35a2ae9b..e9df17acedd 100644
--- a/include/asm-sparc64/cache.h
+++ b/include/asm-sparc64/cache.h
@@ -13,4 +13,6 @@
#define SMP_CACHE_BYTES_SHIFT 6
#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT) /* L2 cache line size. */
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
#endif
diff --git a/include/asm-sparc64/percpu.h b/include/asm-sparc64/percpu.h
index aea4e51e7cd..82032e159a7 100644
--- a/include/asm-sparc64/percpu.h
+++ b/include/asm-sparc64/percpu.h
@@ -26,10 +26,9 @@ register unsigned long __local_per_cpu_offset asm("g5");
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for (__i = 0; __i < NR_CPUS; __i++) \
- if (cpu_possible(__i)) \
- memcpy((pcpudst)+__per_cpu_offset(__i), \
- (src), (size)); \
+ for_each_cpu(__i) \
+ memcpy((pcpudst)+__per_cpu_offset(__i), \
+ (src), (size)); \
} while (0)
#else /* ! SMP */
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h
index 31b611aa746..ab6b0d1bb4a 100644
--- a/include/asm-sparc64/poll.h
+++ b/include/asm-sparc64/poll.h
@@ -13,6 +13,7 @@
#define POLLWRBAND 256
#define POLLMSG 512
#define POLLREMOVE 1024
+#define POLLRDHUP 2048
struct pollfd {
int fd;
diff --git a/include/asm-um/alternative.h b/include/asm-um/alternative.h
new file mode 100644
index 00000000000..b6434396bd4
--- /dev/null
+++ b/include/asm-um/alternative.h
@@ -0,0 +1,6 @@
+#ifndef __UM_ALTERNATIVE_H
+#define __UM_ALTERNATIVE_H
+
+#include "asm/arch/alternative.h"
+
+#endif
diff --git a/include/asm-v850/linkage.h b/include/asm-v850/linkage.h
index 291c2d01c44..b6185d3cfe6 100644
--- a/include/asm-v850/linkage.h
+++ b/include/asm-v850/linkage.h
@@ -1,6 +1,8 @@
#ifndef __ASM_LINKAGE_H
#define __ASM_LINKAGE_H
-/* Nothing to see here... */
+#ifdef __ASSEMBLY__
+#include <asm/asm.h>
+#endif
#endif
diff --git a/include/asm-v850/poll.h b/include/asm-v850/poll.h
index 0369562c7e1..c10176c2c28 100644
--- a/include/asm-v850/poll.h
+++ b/include/asm-v850/poll.h
@@ -13,6 +13,7 @@
#define POLLWRBAND 0x0100
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-x86_64/atomic.h b/include/asm-x86_64/atomic.h
index 4b5cd553e77..cecbf7baa6a 100644
--- a/include/asm-x86_64/atomic.h
+++ b/include/asm-x86_64/atomic.h
@@ -405,8 +405,14 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
({ \
int c, old; \
c = atomic_read(v); \
- while (c != (u) && (old = atomic_cmpxchg((v), c, c + (a))) != c) \
+ for (;;) { \
+ if (unlikely(c == (u))) \
+ break; \
+ old = atomic_cmpxchg((v), c, c + (a)); \
+ if (likely(old == c)) \
+ break; \
c = old; \
+ } \
c != (u); \
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
diff --git a/include/asm-x86_64/cache.h b/include/asm-x86_64/cache.h
index 263f0a211ed..c8043a16152 100644
--- a/include/asm-x86_64/cache.h
+++ b/include/asm-x86_64/cache.h
@@ -20,6 +20,8 @@
__attribute__((__section__(".data.page_aligned")))
#endif
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
#endif
#endif
diff --git a/include/asm-x86_64/io.h b/include/asm-x86_64/io.h
index 9dac18db829..a85fe837082 100644
--- a/include/asm-x86_64/io.h
+++ b/include/asm-x86_64/io.h
@@ -269,23 +269,11 @@ void memset_io(volatile void __iomem *a, int b, size_t c);
*/
#define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET))
-#define isa_readb(a) readb(__ISA_IO_base + (a))
-#define isa_readw(a) readw(__ISA_IO_base + (a))
-#define isa_readl(a) readl(__ISA_IO_base + (a))
-#define isa_writeb(b,a) writeb(b,__ISA_IO_base + (a))
-#define isa_writew(w,a) writew(w,__ISA_IO_base + (a))
-#define isa_writel(l,a) writel(l,__ISA_IO_base + (a))
-#define isa_memset_io(a,b,c) memset_io(__ISA_IO_base + (a),(b),(c))
-#define isa_memcpy_fromio(a,b,c) memcpy_fromio((a),__ISA_IO_base + (b),(c))
-#define isa_memcpy_toio(a,b,c) memcpy_toio(__ISA_IO_base + (a),(b),(c))
-
-
/*
* Again, x86-64 does not require mem IO specific function.
*/
#define eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(b),(c),(d))
-#define isa_eth_io_copy_and_sum(a,b,c,d) eth_copy_and_sum((a),(void *)(__ISA_IO_base + (b)),(c),(d))
/**
* check_signature - find BIOS signatures
diff --git a/include/asm-x86_64/mmu_context.h b/include/asm-x86_64/mmu_context.h
index 16e4be4de0c..19f0c83d079 100644
--- a/include/asm-x86_64/mmu_context.h
+++ b/include/asm-x86_64/mmu_context.h
@@ -34,12 +34,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
unsigned cpu = smp_processor_id();
if (likely(prev != next)) {
/* stop flush ipis for the previous mm */
- clear_bit(cpu, &prev->cpu_vm_mask);
+ cpu_clear(cpu, prev->cpu_vm_mask);
#ifdef CONFIG_SMP
write_pda(mmu_state, TLBSTATE_OK);
write_pda(active_mm, next);
#endif
- set_bit(cpu, &next->cpu_vm_mask);
+ cpu_set(cpu, next->cpu_vm_mask);
load_cr3(next->pgd);
if (unlikely(next->context.ldt != prev->context.ldt))
@@ -50,7 +50,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
write_pda(mmu_state, TLBSTATE_OK);
if (read_pda(active_mm) != next)
out_of_line_bug();
- if(!test_and_set_bit(cpu, &next->cpu_vm_mask)) {
+ if (!cpu_test_and_set(cpu, next->cpu_vm_mask)) {
/* We were in lazy tlb mode and leave_mm disabled
* tlb flush IPI delivery. We must reload CR3
* to make sure to use no freed page tables.
diff --git a/include/asm-x86_64/percpu.h b/include/asm-x86_64/percpu.h
index 29a6b0408f7..4405b4adeab 100644
--- a/include/asm-x86_64/percpu.h
+++ b/include/asm-x86_64/percpu.h
@@ -26,10 +26,9 @@
#define percpu_modcopy(pcpudst, src, size) \
do { \
unsigned int __i; \
- for (__i = 0; __i < NR_CPUS; __i++) \
- if (cpu_possible(__i)) \
- memcpy((pcpudst)+__per_cpu_offset(__i), \
- (src), (size)); \
+ for_each_cpu(__i) \
+ memcpy((pcpudst)+__per_cpu_offset(__i), \
+ (src), (size)); \
} while (0)
extern void setup_per_cpu_areas(void);
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index a617d364d08..def90328719 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -293,19 +293,19 @@ static inline int ptep_test_and_clear_dirty(struct vm_area_struct *vma, unsigned
{
if (!pte_dirty(*ptep))
return 0;
- return test_and_clear_bit(_PAGE_BIT_DIRTY, ptep);
+ return test_and_clear_bit(_PAGE_BIT_DIRTY, &ptep->pte);
}
static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep)
{
if (!pte_young(*ptep))
return 0;
- return test_and_clear_bit(_PAGE_BIT_ACCESSED, ptep);
+ return test_and_clear_bit(_PAGE_BIT_ACCESSED, &ptep->pte);
}
static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, pte_t *ptep)
{
- clear_bit(_PAGE_BIT_RW, ptep);
+ clear_bit(_PAGE_BIT_RW, &ptep->pte);
}
/*
diff --git a/include/asm-x86_64/poll.h b/include/asm-x86_64/poll.h
index c43cbba3191..c0475a9d8bb 100644
--- a/include/asm-x86_64/poll.h
+++ b/include/asm-x86_64/poll.h
@@ -16,6 +16,7 @@
#define POLLWRBAND 0x0200
#define POLLMSG 0x0400
#define POLLREMOVE 0x1000
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/asm-xtensa/poll.h b/include/asm-xtensa/poll.h
index dffe447534e..6fd94773e86 100644
--- a/include/asm-xtensa/poll.h
+++ b/include/asm-xtensa/poll.h
@@ -27,6 +27,7 @@
#define POLLMSG 0x0400
#define POLLREMOVE 0x0800
+#define POLLRDHUP 0x2000
struct pollfd {
int fd;
diff --git a/include/linux/ata.h b/include/linux/ata.h
index b02a16c435e..312a2c0c64e 100644
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -146,6 +146,8 @@ enum {
ATA_CMD_STANDBYNOW1 = 0xE0,
ATA_CMD_IDLEIMMEDIATE = 0xE1,
ATA_CMD_INIT_DEV_PARAMS = 0x91,
+ ATA_CMD_READ_NATIVE_MAX = 0xF8,
+ ATA_CMD_READ_NATIVE_MAX_EXT = 0x27,
/* SETFEATURES stuff */
SETFEATURES_XFER = 0x03,
@@ -204,7 +206,6 @@ enum ata_tf_protocols {
ATA_PROT_UNKNOWN, /* unknown/invalid */
ATA_PROT_NODATA, /* no data */
ATA_PROT_PIO, /* PIO single sector */
- ATA_PROT_PIO_MULT, /* PIO multiple sector */
ATA_PROT_DMA, /* DMA */
ATA_PROT_ATAPI, /* packet command, PIO data xfer*/
ATA_PROT_ATAPI_NODATA, /* packet command, no data */
@@ -247,18 +248,22 @@ struct ata_taskfile {
};
#define ata_id_is_ata(id) (((id)[0] & (1 << 15)) == 0)
+#define ata_id_is_cfa(id) ((id)[0] == 0x848A)
#define ata_id_is_sata(id) ((id)[93] == 0)
#define ata_id_rahead_enabled(id) ((id)[85] & (1 << 6))
#define ata_id_wcache_enabled(id) ((id)[85] & (1 << 5))
+#define ata_id_hpa_enabled(id) ((id)[85] & (1 << 10))
#define ata_id_has_fua(id) ((id)[84] & (1 << 6))
#define ata_id_has_flush(id) ((id)[83] & (1 << 12))
#define ata_id_has_flush_ext(id) ((id)[83] & (1 << 13))
#define ata_id_has_lba48(id) ((id)[83] & (1 << 10))
+#define ata_id_has_hpa(id) ((id)[82] & (1 << 10))
#define ata_id_has_wcache(id) ((id)[82] & (1 << 5))
#define ata_id_has_pm(id) ((id)[82] & (1 << 3))
#define ata_id_has_lba(id) ((id)[49] & (1 << 9))
#define ata_id_has_dma(id) ((id)[49] & (1 << 8))
#define ata_id_removeable(id) ((id)[0] & (1 << 7))
+#define ata_id_has_dword_io(id) ((id)[50] & (1 << 0))
#define ata_id_u32(id,n) \
(((u32) (id)[(n) + 1] << 16) | ((u32) (id)[(n)]))
#define ata_id_u64(id,n) \
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 7d8ff97b3e9..d9ed2796985 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -46,6 +46,9 @@
* bitmap_parse(ubuf, ulen, dst, nbits) Parse bitmap dst from user buf
* bitmap_scnlistprintf(buf, len, src, nbits) Print bitmap src as list to buf
* bitmap_parselist(buf, dst, nbits) Parse bitmap dst from list
+ * bitmap_find_free_region(bitmap, bits, order) Find and allocate bit region
+ * bitmap_release_region(bitmap, pos, order) Free specified bit region
+ * bitmap_allocate_region(bitmap, pos, order) Allocate specified bit region
*/
/*
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 208650b1ad3..f17525a963d 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -175,4 +175,11 @@ static inline __u32 ror32(__u32 word, unsigned int shift)
return (word >> shift) | (word << (32 - shift));
}
+static inline unsigned fls_long(unsigned long l)
+{
+ if (sizeof(l) == 4)
+ return fls(l);
+ return fls64(l);
+}
+
#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 56bb6a4e15f..c179966f1a2 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -22,6 +22,7 @@ typedef struct request_queue request_queue_t;
struct elevator_queue;
typedef struct elevator_queue elevator_t;
struct request_pm_state;
+struct blk_trace;
#define BLKDEV_MIN_RQ 4
#define BLKDEV_MAX_RQ 128 /* Default maximum */
@@ -416,6 +417,8 @@ struct request_queue
unsigned int sg_reserved_size;
int node;
+ struct blk_trace *blk_trace;
+
/*
* reserved for flush operations
*/
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
new file mode 100644
index 00000000000..b34d3e73d5e
--- /dev/null
+++ b/include/linux/blktrace_api.h
@@ -0,0 +1,277 @@
+#ifndef BLKTRACE_H
+#define BLKTRACE_H
+
+#include <linux/config.h>
+#include <linux/blkdev.h>
+#include <linux/relay.h>
+
+/*
+ * Trace categories
+ */
+enum blktrace_cat {
+ BLK_TC_READ = 1 << 0, /* reads */
+ BLK_TC_WRITE = 1 << 1, /* writes */
+ BLK_TC_BARRIER = 1 << 2, /* barrier */
+ BLK_TC_SYNC = 1 << 3, /* barrier */
+ BLK_TC_QUEUE = 1 << 4, /* queueing/merging */
+ BLK_TC_REQUEUE = 1 << 5, /* requeueing */
+ BLK_TC_ISSUE = 1 << 6, /* issue */
+ BLK_TC_COMPLETE = 1 << 7, /* completions */
+ BLK_TC_FS = 1 << 8, /* fs requests */
+ BLK_TC_PC = 1 << 9, /* pc requests */
+ BLK_TC_NOTIFY = 1 << 10, /* special message */
+
+ BLK_TC_END = 1 << 15, /* only 16-bits, reminder */
+};
+
+#define BLK_TC_SHIFT (16)
+#define BLK_TC_ACT(act) ((act) << BLK_TC_SHIFT)
+
+/*
+ * Basic trace actions
+ */
+enum blktrace_act {
+ __BLK_TA_QUEUE = 1, /* queued */
+ __BLK_TA_BACKMERGE, /* back merged to existing rq */
+ __BLK_TA_FRONTMERGE, /* front merge to existing rq */
+ __BLK_TA_GETRQ, /* allocated new request */
+ __BLK_TA_SLEEPRQ, /* sleeping on rq allocation */
+ __BLK_TA_REQUEUE, /* request requeued */
+ __BLK_TA_ISSUE, /* sent to driver */
+ __BLK_TA_COMPLETE, /* completed by driver */
+ __BLK_TA_PLUG, /* queue was plugged */
+ __BLK_TA_UNPLUG_IO, /* queue was unplugged by io */
+ __BLK_TA_UNPLUG_TIMER, /* queue was unplugged by timer */
+ __BLK_TA_INSERT, /* insert request */
+ __BLK_TA_SPLIT, /* bio was split */
+ __BLK_TA_BOUNCE, /* bio was bounced */
+ __BLK_TA_REMAP, /* bio was remapped */
+};
+
+/*
+ * Trace actions in full. Additionally, read or write is masked
+ */
+#define BLK_TA_QUEUE (__BLK_TA_QUEUE | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_BACKMERGE (__BLK_TA_BACKMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_FRONTMERGE (__BLK_TA_FRONTMERGE | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_GETRQ (__BLK_TA_GETRQ | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_SLEEPRQ (__BLK_TA_SLEEPRQ | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_REQUEUE (__BLK_TA_REQUEUE | BLK_TC_ACT(BLK_TC_REQUEUE))
+#define BLK_TA_ISSUE (__BLK_TA_ISSUE | BLK_TC_ACT(BLK_TC_ISSUE))
+#define BLK_TA_COMPLETE (__BLK_TA_COMPLETE| BLK_TC_ACT(BLK_TC_COMPLETE))
+#define BLK_TA_PLUG (__BLK_TA_PLUG | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_UNPLUG_IO (__BLK_TA_UNPLUG_IO | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_UNPLUG_TIMER (__BLK_TA_UNPLUG_TIMER | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_INSERT (__BLK_TA_INSERT | BLK_TC_ACT(BLK_TC_QUEUE))
+#define BLK_TA_SPLIT (__BLK_TA_SPLIT)
+#define BLK_TA_BOUNCE (__BLK_TA_BOUNCE)
+#define BLK_TA_REMAP (__BLK_TA_REMAP | BLK_TC_ACT(BLK_TC_QUEUE))
+
+#define BLK_IO_TRACE_MAGIC 0x65617400
+#define BLK_IO_TRACE_VERSION 0x07
+
+/*
+ * The trace itself
+ */
+struct blk_io_trace {
+ u32 magic; /* MAGIC << 8 | version */
+ u32 sequence; /* event number */
+ u64 time; /* in microseconds */
+ u64 sector; /* disk offset */
+ u32 bytes; /* transfer length */
+ u32 action; /* what happened */
+ u32 pid; /* who did it */
+ u32 device; /* device number */
+ u32 cpu; /* on what cpu did it happen */
+ u16 error; /* completion error */
+ u16 pdu_len; /* length of data after this trace */
+};
+
+/*
+ * The remap event
+ */
+struct blk_io_trace_remap {
+ u32 device;
+ u32 __pad;
+ u64 sector;
+};
+
+enum {
+ Blktrace_setup = 1,
+ Blktrace_running,
+ Blktrace_stopped,
+};
+
+struct blk_trace {
+ int trace_state;
+ struct rchan *rchan;
+ unsigned long *sequence;
+ u16 act_mask;
+ u64 start_lba;
+ u64 end_lba;
+ u32 pid;
+ u32 dev;
+ struct dentry *dir;
+ struct dentry *dropped_file;
+ atomic_t dropped;
+};
+
+/*
+ * User setup structure passed with BLKTRACESTART
+ */
+struct blk_user_trace_setup {
+ char name[BDEVNAME_SIZE]; /* output */
+ u16 act_mask; /* input */
+ u32 buf_size; /* input */
+ u32 buf_nr; /* input */
+ u64 start_lba;
+ u64 end_lba;
+ u32 pid;
+};
+
+#if defined(CONFIG_BLK_DEV_IO_TRACE)
+extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
+extern void blk_trace_shutdown(request_queue_t *);
+extern void __blk_add_trace(struct blk_trace *, sector_t, int, int, u32, int, int, void *);
+
+/**
+ * blk_add_trace_rq - Add a trace for a request oriented action
+ * @q: queue the io is for
+ * @rq: the source request
+ * @what: the action
+ *
+ * Description:
+ * Records an action against a request. Will log the bio offset + size.
+ *
+ **/
+static inline void blk_add_trace_rq(struct request_queue *q, struct request *rq,
+ u32 what)
+{
+ struct blk_trace *bt = q->blk_trace;
+ int rw = rq->flags & 0x07;
+
+ if (likely(!bt))
+ return;
+
+ if (blk_pc_request(rq)) {
+ what |= BLK_TC_ACT(BLK_TC_PC);
+ __blk_add_trace(bt, 0, rq->data_len, rw, what, rq->errors, sizeof(rq->cmd), rq->cmd);
+ } else {
+ what |= BLK_TC_ACT(BLK_TC_FS);
+ __blk_add_trace(bt, rq->hard_sector, rq->hard_nr_sectors << 9, rw, what, rq->errors, 0, NULL);
+ }
+}
+
+/**
+ * blk_add_trace_bio - Add a trace for a bio oriented action
+ * @q: queue the io is for
+ * @bio: the source bio
+ * @what: the action
+ *
+ * Description:
+ * Records an action against a bio. Will log the bio offset + size.
+ *
+ **/
+static inline void blk_add_trace_bio(struct request_queue *q, struct bio *bio,
+ u32 what)
+{
+ struct blk_trace *bt = q->blk_trace;
+
+ if (likely(!bt))
+ return;
+
+ __blk_add_trace(bt, bio->bi_sector, bio->bi_size, bio->bi_rw, what, !bio_flagged(bio, BIO_UPTODATE), 0, NULL);
+}
+
+/**
+ * blk_add_trace_generic - Add a trace for a generic action
+ * @q: queue the io is for
+ * @bio: the source bio
+ * @rw: the data direction
+ * @what: the action
+ *
+ * Description:
+ * Records a simple trace
+ *
+ **/
+static inline void blk_add_trace_generic(struct request_queue *q,
+ struct bio *bio, int rw, u32 what)
+{
+ struct blk_trace *bt = q->blk_trace;
+
+ if (likely(!bt))
+ return;
+
+ if (bio)
+ blk_add_trace_bio(q, bio, what);
+ else
+ __blk_add_trace(bt, 0, 0, rw, what, 0, 0, NULL);
+}
+
+/**
+ * blk_add_trace_pdu_int - Add a trace for a bio with an integer payload
+ * @q: queue the io is for
+ * @what: the action
+ * @bio: the source bio
+ * @pdu: the integer payload
+ *
+ * Description:
+ * Adds a trace with some integer payload. This might be an unplug
+ * option given as the action, with the depth at unplug time given
+ * as the payload
+ *
+ **/
+static inline void blk_add_trace_pdu_int(struct request_queue *q, u32 what,
+ struct bio *bio, unsigned int pdu)
+{
+ struct blk_trace *bt = q->blk_trace;
+ u64 rpdu = cpu_to_be64(pdu);
+
+ if (likely(!bt))
+ return;
+
+ if (bio)
+ __blk_add_trace(bt, bio->bi_sector, bio->bi_size, bio->bi_rw, what, !bio_flagged(bio, BIO_UPTODATE), sizeof(rpdu), &rpdu);
+ else
+ __blk_add_trace(bt, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu);
+}
+
+/**
+ * blk_add_trace_remap - Add a trace for a remap operation
+ * @q: queue the io is for
+ * @bio: the source bio
+ * @dev: target device
+ * @from: source sector
+ * @to: target sector
+ *
+ * Description:
+ * Device mapper or raid target sometimes need to split a bio because
+ * it spans a stripe (or similar). Add a trace for that action.
+ *
+ **/
+static inline void blk_add_trace_remap(struct request_queue *q, struct bio *bio,
+ dev_t dev, sector_t from, sector_t to)
+{
+ struct blk_trace *bt = q->blk_trace;
+ struct blk_io_trace_remap r;
+
+ if (likely(!bt))
+ return;
+
+ r.device = cpu_to_be32(dev);
+ r.sector = cpu_to_be64(to);
+
+ __blk_add_trace(bt, from, bio->bi_size, bio->bi_rw, BLK_TA_REMAP, !bio_flagged(bio, BIO_UPTODATE), sizeof(r), &r);
+}
+
+#else /* !CONFIG_BLK_DEV_IO_TRACE */
+#define blk_trace_ioctl(bdev, cmd, arg) (-ENOTTY)
+#define blk_trace_shutdown(q) do { } while (0)
+#define blk_add_trace_rq(q, rq, what) do { } while (0)
+#define blk_add_trace_bio(q, rq, what) do { } while (0)
+#define blk_add_trace_generic(q, rq, rw, what) do { } while (0)
+#define blk_add_trace_pdu_int(q, what, bio, pdu) do { } while (0)
+#define blk_add_trace_remap(q, bio, dev, f, t) do {} while (0)
+#endif /* CONFIG_BLK_DEV_IO_TRACE */
+
+#endif
diff --git a/include/linux/cache.h b/include/linux/cache.h
index d22e632f41f..cc4b3aafad9 100644
--- a/include/linux/cache.h
+++ b/include/linux/cache.h
@@ -13,9 +13,7 @@
#define SMP_CACHE_BYTES L1_CACHE_BYTES
#endif
-#if defined(CONFIG_X86) || defined(CONFIG_SPARC64) || defined(CONFIG_IA64) || defined(CONFIG_PARISC)
-#define __read_mostly __attribute__((__section__(".data.read_mostly")))
-#else
+#ifndef __read_mostly
#define __read_mostly
#endif
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 5a23ce75262..6548b35ab9f 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -357,7 +357,8 @@ static inline kernel_cap_t cap_invert(kernel_cap_t c)
#define cap_is_fs_cap(c) (CAP_TO_MASK(c) & CAP_FS_MASK)
-extern int capable(int cap);
+int capable(int cap);
+int __capable(struct task_struct *t, int cap);
#endif /* __KERNEL__ */
diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
index b68fdf1f315..3c9b0bc0512 100644
--- a/include/linux/cdrom.h
+++ b/include/linux/cdrom.h
@@ -378,7 +378,6 @@ struct cdrom_generic_command
#define CDC_MEDIA_CHANGED 0x80 /* media changed */
#define CDC_PLAY_AUDIO 0x100 /* audio functions */
#define CDC_RESET 0x200 /* hard reset device */
-#define CDC_IOCTLS 0x400 /* driver has non-standard ioctls */
#define CDC_DRIVE_STATUS 0x800 /* driver implements drive status */
#define CDC_GENERIC_PACKET 0x1000 /* driver implements generic packets */
#define CDC_CD_R 0x2000 /* drive is a CD-R */
@@ -974,9 +973,7 @@ struct cdrom_device_ops {
int (*reset) (struct cdrom_device_info *);
/* play stuff */
int (*audio_ioctl) (struct cdrom_device_info *,unsigned int, void *);
- /* dev-specific */
- int (*dev_ioctl) (struct cdrom_device_info *,
- unsigned int, unsigned long);
+
/* driver specifications */
const int capability; /* capability flags */
int n_minors; /* number of active minor devices */
diff --git a/include/linux/compat_ioctl.h b/include/linux/compat_ioctl.h
index ae7dfb790df..efb518f16bb 100644
--- a/include/linux/compat_ioctl.h
+++ b/include/linux/compat_ioctl.h
@@ -97,6 +97,10 @@ COMPATIBLE_IOCTL(BLKRRPART)
COMPATIBLE_IOCTL(BLKFLSBUF)
COMPATIBLE_IOCTL(BLKSECTSET)
COMPATIBLE_IOCTL(BLKSSZGET)
+COMPATIBLE_IOCTL(BLKTRACESTART)
+COMPATIBLE_IOCTL(BLKTRACESTOP)
+COMPATIBLE_IOCTL(BLKTRACESETUP)
+COMPATIBLE_IOCTL(BLKTRACETEARDOWN)
ULONG_IOCTL(BLKRASET)
ULONG_IOCTL(BLKFRASET)
/* RAID */
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index d612b89dce3..08d50c53aab 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -74,7 +74,6 @@ extern int lock_cpu_hotplug_interruptible(void);
register_cpu_notifier(&fn##_nb); \
}
int cpu_down(unsigned int cpu);
-extern int __attribute__((weak)) smp_prepare_cpu(int cpu);
#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
#else
#define lock_cpu_hotplug() do { } while (0)
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 60e56c6e03d..99e6115d8e5 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -212,17 +212,15 @@ static inline void __cpus_shift_left(cpumask_t *dstp,
bitmap_shift_left(dstp->bits, srcp->bits, n, nbits);
}
-#define first_cpu(src) __first_cpu(&(src), NR_CPUS)
-static inline int __first_cpu(const cpumask_t *srcp, int nbits)
-{
- return min_t(int, nbits, find_first_bit(srcp->bits, nbits));
-}
-
-#define next_cpu(n, src) __next_cpu((n), &(src), NR_CPUS)
-static inline int __next_cpu(int n, const cpumask_t *srcp, int nbits)
-{
- return min_t(int, nbits, find_next_bit(srcp->bits, nbits, n+1));
-}
+#ifdef CONFIG_SMP
+int __first_cpu(const cpumask_t *srcp);
+#define first_cpu(src) __first_cpu(&(src))
+int __next_cpu(int n, const cpumask_t *srcp);
+#define next_cpu(n, src) __next_cpu((n), &(src))
+#else
+#define first_cpu(src) 0
+#define next_cpu(n, src) 1
+#endif
#define cpumask_of_cpu(cpu) \
({ \
@@ -398,27 +396,17 @@ extern cpumask_t cpu_present_map;
#define cpu_present(cpu) ((cpu) == 0)
#endif
-#define any_online_cpu(mask) \
-({ \
- int cpu; \
- for_each_cpu_mask(cpu, (mask)) \
- if (cpu_online(cpu)) \
- break; \
- cpu; \
-})
+#ifdef CONFIG_SMP
+int highest_possible_processor_id(void);
+#define any_online_cpu(mask) __any_online_cpu(&(mask))
+int __any_online_cpu(const cpumask_t *mask);
+#else
+#define highest_possible_processor_id() 0
+#define any_online_cpu(mask) 0
+#endif
#define for_each_cpu(cpu) for_each_cpu_mask((cpu), cpu_possible_map)
#define for_each_online_cpu(cpu) for_each_cpu_mask((cpu), cpu_online_map)
#define for_each_present_cpu(cpu) for_each_cpu_mask((cpu), cpu_present_map)
-/* Find the highest possible smp_processor_id() */
-#define highest_possible_processor_id() \
-({ \
- unsigned int cpu, highest = 0; \
- for_each_cpu_mask(cpu, cpu_possible_map) \
- highest = cpu; \
- highest; \
-})
-
-
#endif /* __LINUX_CPUMASK_H */
diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 3bc60692711..9354722a921 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -4,7 +4,7 @@
* cpuset interface
*
* Copyright (C) 2003 BULL SA
- * Copyright (C) 2004 Silicon Graphics, Inc.
+ * Copyright (C) 2004-2006 Silicon Graphics, Inc.
*
*/
@@ -51,6 +51,18 @@ extern char *cpuset_task_status_allowed(struct task_struct *task, char *buffer);
extern void cpuset_lock(void);
extern void cpuset_unlock(void);
+extern int cpuset_mem_spread_node(void);
+
+static inline int cpuset_do_page_mem_spread(void)
+{
+ return current->flags & PF_SPREAD_PAGE;
+}
+
+static inline int cpuset_do_slab_mem_spread(void)
+{
+ return current->flags & PF_SPREAD_SLAB;
+}
+
#else /* !CONFIG_CPUSETS */
static inline int cpuset_init_early(void) { return 0; }
@@ -99,6 +111,21 @@ static inline char *cpuset_task_status_allowed(struct task_struct *task,
static inline void cpuset_lock(void) {}
static inline void cpuset_unlock(void) {}
+static inline int cpuset_mem_spread_node(void)
+{
+ return 0;
+}
+
+static inline int cpuset_do_page_mem_spread(void)
+{
+ return 0;
+}
+
+static inline int cpuset_do_slab_mem_spread(void)
+{
+ return 0;
+}
+
#endif /* !CONFIG_CPUSETS */
#endif /* _LINUX_CPUSET_H */
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 4361f378997..d10bd30c337 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -162,6 +162,8 @@ d_iput: no no no yes
#define DCACHE_REFERENCED 0x0008 /* Recently used, don't discard. */
#define DCACHE_UNHASHED 0x0010
+#define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */
+
extern spinlock_t dcache_lock;
/**
diff --git a/include/linux/dio.h b/include/linux/dio.h
index fae9395fcf4..1e65ebc2a3d 100644
--- a/include/linux/dio.h
+++ b/include/linux/dio.h
@@ -276,37 +276,5 @@ static inline void dio_set_drvdata (struct dio_dev *d, void *data)
dev_set_drvdata(&d->dev, data);
}
-/*
- * A helper function which helps ensure correct dio_driver
- * setup and cleanup for commonly-encountered hotplug/modular cases
- *
- * This MUST stay in a header, as it checks for -DMODULE
- */
-static inline int dio_module_init(struct dio_driver *drv)
-{
- int rc = dio_register_driver(drv);
-
- if (rc > 0)
- return 0;
-
- /* iff CONFIG_HOTPLUG and built into kernel, we should
- * leave the driver around for future hotplug events.
- * For the module case, a hotplug daemon of some sort
- * should load a module in response to an insert event. */
-#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
- if (rc == 0)
- return 0;
-#else
- if (rc == 0)
- rc = -ENODEV;
-#endif
-
- /* if we get here, we need to clean up DIO driver instance
- * and return some sort of error */
- dio_unregister_driver(drv);
-
- return rc;
-}
-
#endif /* __KERNEL__ */
#endif /* ndef _LINUX_DIO_H */
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 1289f0ec4c0..1e4bdfcf83a 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -52,7 +52,12 @@ struct file;
#ifdef CONFIG_EPOLL
/* Used to initialize the epoll bits inside the "struct file" */
-void eventpoll_init_file(struct file *file);
+static inline void eventpoll_init_file(struct file *file)
+{
+ INIT_LIST_HEAD(&file->f_ep_links);
+ spin_lock_init(&file->f_ep_lock);
+}
+
/* Used to release the epoll bits inside the "struct file" */
void eventpoll_release_file(struct file *file);
@@ -85,7 +90,6 @@ static inline void eventpoll_release(struct file *file)
eventpoll_release_file(file);
}
-
#else
static inline void eventpoll_init_file(struct file *file) {}
diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h
index c0272d73ab2..e7239f2f97a 100644
--- a/include/linux/ext3_fs.h
+++ b/include/linux/ext3_fs.h
@@ -772,9 +772,12 @@ extern unsigned long ext3_count_free (struct buffer_head *, unsigned);
/* inode.c */
-extern int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
-extern struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
-extern struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
+int ext3_forget(handle_t *, int, struct inode *, struct buffer_head *, int);
+struct buffer_head * ext3_getblk (handle_t *, struct inode *, long, int, int *);
+struct buffer_head * ext3_bread (handle_t *, struct inode *, int, int, int *);
+int ext3_get_block_handle(handle_t *handle, struct inode *inode,
+ sector_t iblock, struct buffer_head *bh_result, int create,
+ int extend_disksize);
extern void ext3_read_inode (struct inode *);
extern int ext3_write_inode (struct inode *, int);
diff --git a/include/linux/ext3_fs_i.h b/include/linux/ext3_fs_i.h
index e71dd98dbca..7abf9014718 100644
--- a/include/linux/ext3_fs_i.h
+++ b/include/linux/ext3_fs_i.h
@@ -19,6 +19,7 @@
#include <linux/rwsem.h>
#include <linux/rbtree.h>
#include <linux/seqlock.h>
+#include <linux/mutex.h>
struct ext3_reserve_window {
__u32 _rsv_start; /* First byte reserved */
@@ -122,16 +123,16 @@ struct ext3_inode_info {
__u16 i_extra_isize;
/*
- * truncate_sem is for serialising ext3_truncate() against
+ * truncate_mutex is for serialising ext3_truncate() against
* ext3_getblock(). In the 2.4 ext2 design, great chunks of inode's
* data tree are chopped off during truncate. We can't do that in
* ext3 because whenever we perform intermediate commits during
* truncate, the inode and all the metadata blocks *must* be in a
* consistent state which allows truncation of the orphans to restart
* during recovery. Hence we must fix the get_block-vs-truncate race
- * by other means, so we have truncate_sem.
+ * by other means, so we have truncate_mutex.
*/
- struct semaphore truncate_sem;
+ struct mutex truncate_mutex;
struct inode vfs_inode;
};
diff --git a/include/linux/fadvise.h b/include/linux/fadvise.h
index e8e747139b9..b2913bba35d 100644
--- a/include/linux/fadvise.h
+++ b/include/linux/fadvise.h
@@ -18,4 +18,10 @@
#define POSIX_FADV_NOREUSE 5 /* Data will be accessed once. */
#endif
+/*
+ * Linux-specific fadvise() extensions:
+ */
+#define LINUX_FADV_ASYNC_WRITE 32 /* Start writeout on range */
+#define LINUX_FADV_WRITE_WAIT 33 /* Wait upon writeout to range */
+
#endif /* FADVISE_H_INCLUDED */
diff --git a/include/linux/file.h b/include/linux/file.h
index 9901b850f2e..9f7c2513866 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -10,6 +10,7 @@
#include <linux/compiler.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
+#include <linux/types.h>
/*
* The default fd array needs to be at least BITS_PER_LONG,
@@ -17,10 +18,22 @@
*/
#define NR_OPEN_DEFAULT BITS_PER_LONG
+/*
+ * The embedded_fd_set is a small fd_set,
+ * suitable for most tasks (which open <= BITS_PER_LONG files)
+ */
+struct embedded_fd_set {
+ unsigned long fds_bits[1];
+};
+
+/*
+ * More than this number of fds: we use a separately allocated fd_set
+ */
+#define EMBEDDED_FD_SET_SIZE (BITS_PER_BYTE * sizeof(struct embedded_fd_set))
+
struct fdtable {
unsigned int max_fds;
int max_fdset;
- int next_fd;
struct file ** fd; /* current fd array */
fd_set *close_on_exec;
fd_set *open_fds;
@@ -33,13 +46,20 @@ struct fdtable {
* Open file table structure
*/
struct files_struct {
+ /*
+ * read mostly part
+ */
atomic_t count;
struct fdtable *fdt;
struct fdtable fdtab;
- fd_set close_on_exec_init;
- fd_set open_fds_init;
+ /*
+ * written part on a separate cache line in SMP
+ */
+ spinlock_t file_lock ____cacheline_aligned_in_smp;
+ int next_fd;
+ struct embedded_fd_set close_on_exec_init;
+ struct embedded_fd_set open_fds_init;
struct file * fd_array[NR_OPEN_DEFAULT];
- spinlock_t file_lock; /* Protects concurrent writers. Nests inside tsk->alloc_lock */
};
#define files_fdtable(files) (rcu_dereference((files)->fdt))
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 128d0082522..21e8cf795c3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -65,6 +65,11 @@ extern int dir_notify_enable;
#define FMODE_PREAD 8
#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
+/* File is being opened for execution. Primary users of this flag are
+ distributed filesystems that can use it to achieve correct ETXTBUSY
+ behavior for cross-node execution/opening_for_writing of files */
+#define FMODE_EXEC 16
+
#define RW_MASK 1
#define RWA_MASK 2
#define READ 0
@@ -103,7 +108,9 @@ extern int dir_notify_enable;
#define MS_BIND 4096
#define MS_MOVE 8192
#define MS_REC 16384
-#define MS_VERBOSE 32768
+#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
+ MS_VERBOSE is deprecated. */
+#define MS_SILENT 32768
#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
#define MS_UNBINDABLE (1<<17) /* change to unbindable */
#define MS_PRIVATE (1<<18) /* change to private */
@@ -197,6 +204,10 @@ extern int dir_notify_enable;
#define BLKBSZGET _IOR(0x12,112,size_t)
#define BLKBSZSET _IOW(0x12,113,size_t)
#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
+#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
+#define BLKTRACESTART _IO(0x12,116)
+#define BLKTRACESTOP _IO(0x12,117)
+#define BLKTRACETEARDOWN _IO(0x12,118)
#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
#define FIBMAP _IO(0x00,1) /* bmap access */
@@ -344,7 +355,7 @@ struct address_space_operations {
/* Write back some dirty pages from this mapping. */
int (*writepages)(struct address_space *, struct writeback_control *);
- /* Set a page dirty */
+ /* Set a page dirty. Return true if this dirtied it */
int (*set_page_dirty)(struct page *page);
int (*readpages)(struct file *filp, struct address_space *mapping,
@@ -397,8 +408,8 @@ struct block_device {
dev_t bd_dev; /* not a kdev_t - it's a search key */
struct inode * bd_inode; /* will die */
int bd_openers;
- struct semaphore bd_sem; /* open/close mutex */
- struct semaphore bd_mount_sem; /* mount mutex */
+ struct mutex bd_mutex; /* open/close mutex */
+ struct mutex bd_mount_mutex; /* mount mutex */
struct list_head bd_inodes;
void * bd_holder;
int bd_holders;
@@ -509,7 +520,7 @@ struct inode {
#ifdef CONFIG_INOTIFY
struct list_head inotify_watches; /* watches on this inode */
- struct semaphore inotify_sem; /* protects the watches list */
+ struct mutex inotify_mutex; /* protects the watches list */
#endif
unsigned long i_state;
@@ -847,7 +858,7 @@ struct super_block {
* The next field is for VFS *only*. No filesystems have any business
* even looking at it. You had been warned.
*/
- struct semaphore s_vfs_rename_sem; /* Kludge */
+ struct mutex s_vfs_rename_mutex; /* Kludge */
/* Granuality of c/m/atime in ns.
Cannot be worse than a second */
@@ -1115,6 +1126,18 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
__mark_inode_dirty(inode, I_DIRTY_SYNC);
}
+static inline void inode_inc_link_count(struct inode *inode)
+{
+ inode->i_nlink++;
+ mark_inode_dirty(inode);
+}
+
+static inline void inode_dec_link_count(struct inode *inode)
+{
+ inode->i_nlink--;
+ mark_inode_dirty(inode);
+}
+
extern void touch_atime(struct vfsmount *mnt, struct dentry *dentry);
static inline void file_accessed(struct file *file)
{
@@ -1455,6 +1478,12 @@ extern int filemap_fdatawait(struct address_space *);
extern int filemap_write_and_wait(struct address_space *mapping);
extern int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend);
+extern int wait_on_page_writeback_range(struct address_space *mapping,
+ pgoff_t start, pgoff_t end);
+extern int __filemap_fdatawrite_range(struct address_space *mapping,
+ loff_t start, loff_t end, int sync_mode);
+
+extern long do_fsync(struct file *file, int datasync);
extern void sync_supers(void);
extern void sync_filesystems(int wait);
extern void emergency_sync(void);
@@ -1534,7 +1563,6 @@ extern void destroy_inode(struct inode *);
extern struct inode *new_inode(struct super_block *);
extern int remove_suid(struct dentry *);
extern void remove_dquot_ref(struct super_block *, int, struct list_head *);
-extern struct semaphore iprune_sem;
extern void __insert_inode_hash(struct inode *, unsigned long hashval);
extern void remove_inode_hash(struct inode *);
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 03b8e7932b8..f7e517c1f1b 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -17,6 +17,25 @@
#include <linux/inotify.h>
/*
+ * fsnotify_d_instantiate - instantiate a dentry for inode
+ * Called with dcache_lock held.
+ */
+static inline void fsnotify_d_instantiate(struct dentry *entry,
+ struct inode *inode)
+{
+ inotify_d_instantiate(entry, inode);
+}
+
+/*
+ * fsnotify_d_move - entry has been moved
+ * Called with dcache_lock and entry->d_lock held.
+ */
+static inline void fsnotify_d_move(struct dentry *entry)
+{
+ inotify_d_move(entry);
+}
+
+/*
* fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
*/
static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
diff --git a/include/linux/generic_serial.h b/include/linux/generic_serial.h
index 0abe9d9a006..652611a4bdc 100644
--- a/include/linux/generic_serial.h
+++ b/include/linux/generic_serial.h
@@ -12,6 +12,8 @@
#ifndef GENERIC_SERIAL_H
#define GENERIC_SERIAL_H
+#include <linux/mutex.h>
+
struct real_driver {
void (*disable_tx_interrupts) (void *);
void (*enable_tx_interrupts) (void *);
@@ -34,7 +36,7 @@ struct gs_port {
int xmit_head;
int xmit_tail;
int xmit_cnt;
- struct semaphore port_write_sem;
+ struct mutex port_write_mutex;
int flags;
wait_queue_head_t open_wait;
wait_queue_head_t close_wait;
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index eef5ccdcd73..fd647fde5ec 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -149,22 +149,16 @@ struct disk_attribute {
({ \
typeof(gendiskp->dkstats->field) res = 0; \
int i; \
- for (i=0; i < NR_CPUS; i++) { \
- if (!cpu_possible(i)) \
- continue; \
+ for_each_cpu(i) \
res += per_cpu_ptr(gendiskp->dkstats, i)->field; \
- } \
res; \
})
static inline void disk_stat_set_all(struct gendisk *gendiskp, int value) {
int i;
- for (i=0; i < NR_CPUS; i++) {
- if (cpu_possible(i)) {
- memset(per_cpu_ptr(gendiskp->dkstats, i), value,
- sizeof (struct disk_stats));
- }
- }
+ for_each_cpu(i)
+ memset(per_cpu_ptr(gendiskp->dkstats, i), value,
+ sizeof (struct disk_stats));
}
#else
diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
index 7eb4004b360..a90c09d331c 100644
--- a/include/linux/hwmon-sysfs.h
+++ b/include/linux/hwmon-sysfs.h
@@ -27,11 +27,13 @@ struct sensor_device_attribute{
#define to_sensor_dev_attr(_dev_attr) \
container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
-#define SENSOR_DEVICE_ATTR(_name,_mode,_show,_store,_index) \
-struct sensor_device_attribute sensor_dev_attr_##_name = { \
- .dev_attr = __ATTR(_name,_mode,_show,_store), \
- .index = _index, \
-}
+#define SENSOR_ATTR(_name, _mode, _show, _store, _index) \
+ { .dev_attr = __ATTR(_name, _mode, _show, _store), \
+ .index = _index }
+
+#define SENSOR_DEVICE_ATTR(_name, _mode, _show, _store, _index) \
+struct sensor_device_attribute sensor_dev_attr_##_name \
+ = SENSOR_ATTR(_name, _mode, _show, _store, _index)
struct sensor_device_attribute_2 {
struct device_attribute dev_attr;
@@ -41,11 +43,13 @@ struct sensor_device_attribute_2 {
#define to_sensor_dev_attr_2(_dev_attr) \
container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
+#define SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index) \
+ { .dev_attr = __ATTR(_name, _mode, _show, _store), \
+ .index = _index, \
+ .nr = _nr }
+
#define SENSOR_DEVICE_ATTR_2(_name,_mode,_show,_store,_nr,_index) \
-struct sensor_device_attribute_2 sensor_dev_attr_##_name = { \
- .dev_attr = __ATTR(_name,_mode,_show,_store), \
- .index = _index, \
- .nr = _nr, \
-}
+struct sensor_device_attribute_2 sensor_dev_attr_##_name \
+ = SENSOR_ATTR_2(_name, _mode, _show, _store, _nr, _index)
#endif /* _LINUX_HWMON_SYSFS_H */
diff --git a/include/linux/i2c-id.h b/include/linux/i2c-id.h
index 474c8f4f5d4..679b46a6a56 100644
--- a/include/linux/i2c-id.h
+++ b/include/linux/i2c-id.h
@@ -172,7 +172,6 @@
#define I2C_HW_B_RIVA 0x010010 /* Riva based graphics cards */
#define I2C_HW_B_IOC 0x010011 /* IOC bit-wiggling */
#define I2C_HW_B_TSUNA 0x010012 /* DEC Tsunami chipset */
-#define I2C_HW_B_FRODO 0x010013 /* 2d3D SA-1110 Development Board */
#define I2C_HW_B_OMAHA 0x010014 /* Omaha I2C interface (ARM) */
#define I2C_HW_B_GUIDE 0x010015 /* Guide bit-basher */
#define I2C_HW_B_IXP2000 0x010016 /* GPIO on IXP2000 systems */
@@ -185,6 +184,7 @@
#define I2C_HW_B_SAVAGE 0x01001d /* savage framebuffer driver */
#define I2C_HW_B_RADEON 0x01001e /* radeon framebuffer driver */
#define I2C_HW_B_EM28XX 0x01001f /* em28xx video capture cards */
+#define I2C_HW_B_CX2341X 0x010020 /* Conexant CX2341X MPEG encoder cards */
/* --- PCF 8584 based algorithms */
#define I2C_HW_P_LP 0x020000 /* Parallel port interface */
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 63f1d63cc1d..1635ee25918 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -32,7 +32,7 @@
#include <linux/mod_devicetable.h>
#include <linux/device.h> /* for struct device */
#include <linux/sched.h> /* for completion */
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
/* --- For i2c-isa ---------------------------------------------------- */
@@ -225,8 +225,8 @@ struct i2c_adapter {
int (*client_unregister)(struct i2c_client *);
/* data fields that are valid for all devices */
- struct semaphore bus_lock;
- struct semaphore clist_lock;
+ struct mutex bus_lock;
+ struct mutex clist_lock;
int timeout;
int retries;
diff --git a/include/linux/ide.h b/include/linux/ide.h
index a7fc4cc79b2..8d2db412ba9 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -792,6 +792,7 @@ typedef struct hwif_s {
unsigned no_dsc : 1; /* 0 default, 1 dsc_overlap disabled */
unsigned auto_poll : 1; /* supports nop auto-poll */
unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */
+ unsigned no_io_32bit : 1; /* 1 = can not do 32-bit IO ops */
struct device gendev;
struct completion gendev_rel_comp; /* To deal with device release() */
diff --git a/include/linux/init.h b/include/linux/init.h
index ff8d8b8632f..ed0ac7c39fd 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -69,6 +69,10 @@ extern initcall_t __security_initcall_start[], __security_initcall_end[];
/* Defined in init/main.c */
extern char saved_command_line[];
+
+/* used by init/main.c */
+extern void setup_arch(char **);
+
#endif
#ifndef MODULE
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index dcfd2ecccb5..92146f3b742 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -7,11 +7,10 @@
#define INIT_FDTABLE \
{ \
.max_fds = NR_OPEN_DEFAULT, \
- .max_fdset = __FD_SETSIZE, \
- .next_fd = 0, \
+ .max_fdset = EMBEDDED_FD_SET_SIZE, \
.fd = &init_files.fd_array[0], \
- .close_on_exec = &init_files.close_on_exec_init, \
- .open_fds = &init_files.open_fds_init, \
+ .close_on_exec = (fd_set *)&init_files.close_on_exec_init, \
+ .open_fds = (fd_set *)&init_files.open_fds_init, \
.rcu = RCU_HEAD_INIT, \
.free_files = NULL, \
.next = NULL, \
@@ -20,9 +19,10 @@
#define INIT_FILES \
{ \
.count = ATOMIC_INIT(1), \
- .file_lock = SPIN_LOCK_UNLOCKED, \
.fdt = &init_files.fdtab, \
.fdtab = INIT_FDTABLE, \
+ .file_lock = SPIN_LOCK_UNLOCKED, \
+ .next_fd = 0, \
.close_on_exec_init = { { 0, } }, \
.open_fds_init = { { 0, } }, \
.fd_array = { NULL, } \
diff --git a/include/linux/inotify.h b/include/linux/inotify.h
index 267c88b5f74..09e00433c78 100644
--- a/include/linux/inotify.h
+++ b/include/linux/inotify.h
@@ -71,6 +71,8 @@ struct inotify_event {
#ifdef CONFIG_INOTIFY
+extern void inotify_d_instantiate(struct dentry *, struct inode *);
+extern void inotify_d_move(struct dentry *);
extern void inotify_inode_queue_event(struct inode *, __u32, __u32,
const char *);
extern void inotify_dentry_parent_queue_event(struct dentry *, __u32, __u32,
@@ -81,6 +83,15 @@ extern u32 inotify_get_cookie(void);
#else
+static inline void inotify_d_instantiate(struct dentry *dentry,
+ struct inode *inode)
+{
+}
+
+static inline void inotify_d_move(struct dentry *dentry)
+{
+}
+
static inline void inotify_inode_queue_event(struct inode *inode,
__u32 mask, __u32 cookie,
const char *filename)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 6c5d4c898cc..ee2a82a572f 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -114,53 +114,8 @@ static inline void set_native_irq_info(int irq, cpumask_t mask)
#if defined (CONFIG_GENERIC_PENDING_IRQ) || defined (CONFIG_IRQBALANCE)
extern cpumask_t pending_irq_cpumask[NR_IRQS];
-static inline void set_pending_irq(unsigned int irq, cpumask_t mask)
-{
- irq_desc_t *desc = irq_desc + irq;
- unsigned long flags;
-
- spin_lock_irqsave(&desc->lock, flags);
- desc->move_irq = 1;
- pending_irq_cpumask[irq] = mask;
- spin_unlock_irqrestore(&desc->lock, flags);
-}
-
-static inline void
-move_native_irq(int irq)
-{
- cpumask_t tmp;
- irq_desc_t *desc = irq_descp(irq);
-
- if (likely (!desc->move_irq))
- return;
-
- desc->move_irq = 0;
-
- if (likely(cpus_empty(pending_irq_cpumask[irq])))
- return;
-
- if (!desc->handler->set_affinity)
- return;
-
- /* note - we hold the desc->lock */
- cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
-
- /*
- * If there was a valid mask to work with, please
- * do the disable, re-program, enable sequence.
- * This is *not* particularly important for level triggered
- * but in a edge trigger case, we might be setting rte
- * when an active trigger is comming in. This could
- * cause some ioapics to mal-function.
- * Being paranoid i guess!
- */
- if (unlikely(!cpus_empty(tmp))) {
- desc->handler->disable(irq);
- desc->handler->set_affinity(irq,tmp);
- desc->handler->enable(irq);
- }
- cpus_clear(pending_irq_cpumask[irq]);
-}
+void set_pending_irq(unsigned int irq, cpumask_t mask);
+void move_native_irq(int irq);
#ifdef CONFIG_PCI_MSI
/*
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index 41ee79962bb..4fc7dffd66e 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -28,6 +28,9 @@
#include <linux/journal-head.h>
#include <linux/stddef.h>
#include <linux/bit_spinlock.h>
+#include <linux/mutex.h>
+#include <linux/timer.h>
+
#include <asm/semaphore.h>
#endif
@@ -575,7 +578,7 @@ struct transaction_s
* @j_wait_checkpoint: Wait queue to trigger checkpointing
* @j_wait_commit: Wait queue to trigger commit
* @j_wait_updates: Wait queue to wait for updates to complete
- * @j_checkpoint_sem: Semaphore for locking against concurrent checkpoints
+ * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints
* @j_head: Journal head - identifies the first unused block in the journal
* @j_tail: Journal tail - identifies the oldest still-used block in the
* journal.
@@ -645,7 +648,7 @@ struct journal_s
int j_barrier_count;
/* The barrier lock itself */
- struct semaphore j_barrier;
+ struct mutex j_barrier;
/*
* Transactions: The current running transaction...
@@ -687,7 +690,7 @@ struct journal_s
wait_queue_head_t j_wait_updates;
/* Semaphore for locking against concurrent checkpoints */
- struct semaphore j_checkpoint_sem;
+ struct mutex j_checkpoint_mutex;
/*
* Journal head: identifies the first unused block in the journal.
@@ -786,7 +789,7 @@ struct journal_s
unsigned long j_commit_interval;
/* The timer used to wakeup the commit thread: */
- struct timer_list *j_commit_timer;
+ struct timer_list j_commit_timer;
/*
* The revoke table: maintains the list of revoked blocks in the
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3b507bf05d0..03d6cfaa5b8 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -91,6 +91,9 @@ extern struct notifier_block *panic_notifier_list;
extern long (*panic_blink)(long time);
NORET_TYPE void panic(const char * fmt, ...)
__attribute__ ((NORET_AND format (printf, 1, 2)));
+extern void oops_enter(void);
+extern void oops_exit(void);
+extern int oops_may_print(void);
fastcall NORET_TYPE void do_exit(long error_code)
ATTRIB_NORET;
NORET_TYPE void complete_and_exit(struct completion *, long)
@@ -151,9 +154,10 @@ static inline int __attribute_pure__ long_log2(unsigned long x)
return r;
}
-static inline unsigned long __attribute_const__ roundup_pow_of_two(unsigned long x)
+static inline unsigned long
+__attribute_const__ roundup_pow_of_two(unsigned long x)
{
- return (1UL << fls(x - 1));
+ return 1UL << fls_long(x - 1);
}
extern int printk_ratelimit(void);
diff --git a/include/linux/kprobes.h b/include/linux/kprobes.h
index 669756bc20a..778adc0fa64 100644
--- a/include/linux/kprobes.h
+++ b/include/linux/kprobes.h
@@ -36,6 +36,7 @@
#include <linux/percpu.h>
#include <linux/spinlock.h>
#include <linux/rcupdate.h>
+#include <linux/mutex.h>
#ifdef CONFIG_KPROBES
#include <asm/kprobes.h>
@@ -152,7 +153,7 @@ struct kretprobe_instance {
};
extern spinlock_t kretprobe_lock;
-extern struct semaphore kprobe_mutex;
+extern struct mutex kprobe_mutex;
extern int arch_prepare_kprobe(struct kprobe *p);
extern void arch_arm_kprobe(struct kprobe *p);
extern void arch_disarm_kprobe(struct kprobe *p);
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 204c37a55f0..047192253c3 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -358,6 +358,11 @@ struct ata_device {
unsigned int max_sectors; /* per-device max sectors */
unsigned int cdb_len;
+ /* per-dev xfer mask */
+ unsigned int pio_mask;
+ unsigned int mwdma_mask;
+ unsigned int udma_mask;
+
/* for CHS addressing */
u16 cylinders; /* Number of cylinders */
u16 heads; /* Number of heads */
@@ -395,6 +400,7 @@ struct ata_port {
struct ata_host_stats stats;
struct ata_host_set *host_set;
+ struct device *dev;
struct work_struct port_task;
@@ -502,6 +508,7 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_i
extern void ata_pci_remove_one (struct pci_dev *pdev);
extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state);
extern int ata_pci_device_resume(struct pci_dev *pdev);
+extern int ata_pci_clear_simplex(struct pci_dev *pdev);
#endif /* CONFIG_PCI */
extern int ata_device_add(const struct ata_probe_ent *ent);
extern void ata_host_set_remove(struct ata_host_set *host_set);
@@ -514,9 +521,9 @@ extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
extern int ata_scsi_release(struct Scsi_Host *host);
extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc);
extern int ata_scsi_device_resume(struct scsi_device *);
-extern int ata_scsi_device_suspend(struct scsi_device *);
+extern int ata_scsi_device_suspend(struct scsi_device *, pm_message_t state);
extern int ata_device_resume(struct ata_port *, struct ata_device *);
-extern int ata_device_suspend(struct ata_port *, struct ata_device *);
+extern int ata_device_suspend(struct ata_port *, struct ata_device *, pm_message_t state);
extern int ata_ratelimit(void);
extern unsigned int ata_busy_sleep(struct ata_port *ap,
unsigned long timeout_pat,
@@ -542,6 +549,7 @@ extern void ata_port_stop (struct ata_port *ap);
extern void ata_host_stop (struct ata_host_set *host_set);
extern irqreturn_t ata_interrupt (int irq, void *dev_instance, struct pt_regs *regs);
extern void ata_qc_prep(struct ata_queued_cmd *qc);
+extern void ata_noop_qc_prep(struct ata_queued_cmd *qc);
extern unsigned int ata_qc_issue_prot(struct ata_queued_cmd *qc);
extern void ata_sg_init_one(struct ata_queued_cmd *qc, void *buf,
unsigned int buflen);
@@ -566,6 +574,8 @@ extern int ata_std_bios_param(struct scsi_device *sdev,
struct block_device *bdev,
sector_t capacity, int geom[]);
extern int ata_scsi_slave_config(struct scsi_device *sdev);
+extern struct ata_device *ata_dev_pair(struct ata_port *ap,
+ struct ata_device *adev);
/*
* Timing helpers
@@ -608,7 +618,7 @@ extern void ata_pci_host_stop (struct ata_host_set *host_set);
extern struct ata_probe_ent *
ata_pci_init_native_mode(struct pci_dev *pdev, struct ata_port_info **port, int portmask);
extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
-
+extern unsigned long ata_pci_default_filter(const struct ata_port *, struct ata_device *, unsigned long);
#endif /* CONFIG_PCI */
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 147eb01e0d4..c08c9983e84 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -28,17 +28,27 @@
#define ALIGN __ALIGN
#define ALIGN_STR __ALIGN_STR
+#ifndef ENTRY
#define ENTRY(name) \
.globl name; \
ALIGN; \
name:
+#endif
#define KPROBE_ENTRY(name) \
.section .kprobes.text, "ax"; \
- .globl name; \
- ALIGN; \
- name:
+ ENTRY(name)
+#ifndef END
+#define END(name) \
+ .size name, .-name
+#endif
+
+#ifndef ENDPROC
+#define ENDPROC(name) \
+ .type name, @function; \
+ END(name)
+#endif
#endif
diff --git a/include/linux/loop.h b/include/linux/loop.h
index f96506782eb..e76c7611d6c 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -17,6 +17,7 @@
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/spinlock.h>
+#include <linux/mutex.h>
/* Possible states of device */
enum {
@@ -60,7 +61,7 @@ struct loop_device {
int lo_state;
struct completion lo_done;
struct completion lo_bh_done;
- struct semaphore lo_ctl_mutex;
+ struct mutex lo_ctl_mutex;
int lo_pending;
request_queue_t *lo_queue;
diff --git a/include/linux/major.h b/include/linux/major.h
index e36a46702d9..0a74c52924c 100644
--- a/include/linux/major.h
+++ b/include/linux/major.h
@@ -113,6 +113,7 @@
#define UBD_MAJOR 98
+#define PP_MAJOR 99
#define JSFD_MAJOR 99
#define PHONE_MAJOR 100
diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
index bbd2221923c..6a7621b2b12 100644
--- a/include/linux/mempolicy.h
+++ b/include/linux/mempolicy.h
@@ -147,6 +147,7 @@ extern void mpol_rebind_policy(struct mempolicy *pol, const nodemask_t *new);
extern void mpol_rebind_task(struct task_struct *tsk,
const nodemask_t *new);
extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new);
+extern void mpol_fix_fork_child_flag(struct task_struct *p);
#define set_cpuset_being_rebound(x) (cpuset_being_rebound = (x))
#ifdef CONFIG_CPUSET
@@ -248,6 +249,10 @@ static inline void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new)
{
}
+static inline void mpol_fix_fork_child_flag(struct task_struct *p)
+{
+}
+
#define set_cpuset_being_rebound(x) do {} while (0)
static inline struct zonelist *huge_zonelist(struct vm_area_struct *vma,
diff --git a/include/linux/module.h b/include/linux/module.h
index 70bd843c71c..eaec13ddd66 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -183,6 +183,7 @@ void *__symbol_get_gpl(const char *symbol);
/* For every exported symbol, place a struct in the __ksymtab section */
#define __EXPORT_SYMBOL(sym, sec) \
+ extern typeof(sym) sym; \
__CRC_SYMBOL(sym, sec) \
static const char __kstrtab_##sym[] \
__attribute__((section("__ksymtab_strings"))) \
@@ -554,25 +555,6 @@ static inline void module_remove_driver(struct device_driver *driver)
/* BELOW HERE ALL THESE ARE OBSOLETE AND WILL VANISH */
-struct obsolete_modparm {
- char name[64];
- char type[64-sizeof(void *)];
- void *addr;
-};
-
-static inline void MODULE_PARM_(void) { }
-#ifdef MODULE
-/* DEPRECATED: Do not use. */
-#define MODULE_PARM(var,type) \
-extern struct obsolete_modparm __parm_##var \
-__attribute__((section("__obsparm"))); \
-struct obsolete_modparm __parm_##var = \
-{ __stringify(var), type, &MODULE_PARM_ }; \
-__MODULE_PARM_TYPE(var, type);
-#else
-#define MODULE_PARM(var,type) static void __attribute__((__unused__)) *__parm_##var = &MODULE_PARM_;
-#endif
-
#define __MODULE_STRING(x) __stringify(x)
/* Use symbol_get and symbol_put instead. You'll thank me. */
diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
index b5c98c43779..7c0c2c198f1 100644
--- a/include/linux/moduleparam.h
+++ b/include/linux/moduleparam.h
@@ -162,13 +162,6 @@ extern int param_array_get(char *buffer, struct kernel_param *kp);
extern int param_set_copystring(const char *val, struct kernel_param *kp);
extern int param_get_string(char *buffer, struct kernel_param *kp);
-int param_array(const char *name,
- const char *val,
- unsigned int min, unsigned int max,
- void *elem, int elemsize,
- int (*set)(const char *, struct kernel_param *kp),
- int *num);
-
/* for exporting parameters in /sys/parameters */
struct module;
diff --git a/include/linux/msdos_fs.h b/include/linux/msdos_fs.h
index 8bcd9450d92..779e6a5744c 100644
--- a/include/linux/msdos_fs.h
+++ b/include/linux/msdos_fs.h
@@ -184,6 +184,7 @@ struct fat_slot_info {
#include <linux/string.h>
#include <linux/nls.h>
#include <linux/fs.h>
+#include <linux/mutex.h>
struct fat_mount_options {
uid_t fs_uid;
@@ -226,7 +227,7 @@ struct msdos_sb_info {
unsigned long max_cluster; /* maximum cluster number */
unsigned long root_cluster; /* first cluster of the root directory */
unsigned long fsinfo_sector; /* sector number of FAT32 fsinfo */
- struct semaphore fat_lock;
+ struct mutex fat_lock;
unsigned int prev_free; /* previously allocated cluster number */
unsigned int free_clusters; /* -1 if undefined */
struct fat_mount_options options;
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index f95d51fae73..a6ce409ec6f 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
@@ -38,6 +38,7 @@ enum {
#ifdef __KERNEL__
#include <linux/wait.h>
+#include <linux/mutex.h>
/* values for flags field */
#define NBD_READ_ONLY 0x0001
@@ -57,7 +58,7 @@ struct nbd_device {
struct request *active_req;
wait_queue_head_t active_wq;
- struct semaphore tx_lock;
+ struct mutex tx_lock;
struct gendisk *disk;
int blksize;
u64 bytesize;
diff --git a/include/linux/ncp_fs_i.h b/include/linux/ncp_fs_i.h
index 415be1ec6f9..bdb4c8ae692 100644
--- a/include/linux/ncp_fs_i.h
+++ b/include/linux/ncp_fs_i.h
@@ -19,7 +19,7 @@ struct ncp_inode_info {
__le32 DosDirNum;
__u8 volNumber;
__le32 nwattr;
- struct semaphore open_sem;
+ struct mutex open_mutex;
atomic_t opened;
int access;
int flags;
diff --git a/include/linux/ncp_fs_sb.h b/include/linux/ncp_fs_sb.h
index cf858eb80f0..b089d950628 100644
--- a/include/linux/ncp_fs_sb.h
+++ b/include/linux/ncp_fs_sb.h
@@ -11,6 +11,7 @@
#include <linux/types.h>
#include <linux/ncp_mount.h>
#include <linux/net.h>
+#include <linux/mutex.h>
#ifdef __KERNEL__
@@ -51,7 +52,7 @@ struct ncp_server {
receive replies */
int lock; /* To prevent mismatch in protocols. */
- struct semaphore sem;
+ struct mutex mutex;
int current_size; /* for packet preparation */
int has_subfunction;
@@ -96,7 +97,7 @@ struct ncp_server {
struct {
struct work_struct tq; /* STREAM/DGRAM: data/error ready */
struct ncp_request_reply* creq; /* STREAM/DGRAM: awaiting reply from this request */
- struct semaphore creq_sem; /* DGRAM only: lock accesses to rcv.creq */
+ struct mutex creq_mutex; /* DGRAM only: lock accesses to rcv.creq */
unsigned int state; /* STREAM only: receiver state */
struct {
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 46a0f974f87..1350e47b023 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -4,6 +4,62 @@
#define XT_FUNCTION_MAXNAMELEN 30
#define XT_TABLE_MAXNAMELEN 32
+struct xt_entry_match
+{
+ union {
+ struct {
+ u_int16_t match_size;
+
+ /* Used by userspace */
+ char name[XT_FUNCTION_MAXNAMELEN-1];
+
+ u_int8_t revision;
+ } user;
+ struct {
+ u_int16_t match_size;
+
+ /* Used inside the kernel */
+ struct xt_match *match;
+ } kernel;
+
+ /* Total length */
+ u_int16_t match_size;
+ } u;
+
+ unsigned char data[0];
+};
+
+struct xt_entry_target
+{
+ union {
+ struct {
+ u_int16_t target_size;
+
+ /* Used by userspace */
+ char name[XT_FUNCTION_MAXNAMELEN-1];
+
+ u_int8_t revision;
+ } user;
+ struct {
+ u_int16_t target_size;
+
+ /* Used inside the kernel */
+ struct xt_target *target;
+ } kernel;
+
+ /* Total length */
+ u_int16_t target_size;
+ } u;
+
+ unsigned char data[0];
+};
+
+struct xt_standard_target
+{
+ struct xt_entry_target target;
+ int verdict;
+};
+
/* The argument to IPT_SO_GET_REVISION_*. Returns highest revision
* kernel supports, if >= revision. */
struct xt_get_revision
@@ -220,10 +276,10 @@ struct xt_table_info
char *entries[NR_CPUS];
};
-extern int xt_register_target(int af, struct xt_target *target);
-extern void xt_unregister_target(int af, struct xt_target *target);
-extern int xt_register_match(int af, struct xt_match *target);
-extern void xt_unregister_match(int af, struct xt_match *target);
+extern int xt_register_target(struct xt_target *target);
+extern void xt_unregister_target(struct xt_target *target);
+extern int xt_register_match(struct xt_match *target);
+extern void xt_unregister_match(struct xt_match *target);
extern int xt_check_match(const struct xt_match *match, unsigned short family,
unsigned int size, const char *table, unsigned int hook,
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h
index fd21796e513..62cc27daca4 100644
--- a/include/linux/netfilter_arp/arp_tables.h
+++ b/include/linux/netfilter_arp/arp_tables.h
@@ -65,35 +65,8 @@ struct arpt_arp {
u_int16_t invflags;
};
-struct arpt_entry_target
-{
- union {
- struct {
- u_int16_t target_size;
-
- /* Used by userspace */
- char name[ARPT_FUNCTION_MAXNAMELEN-1];
- u_int8_t revision;
- } user;
- struct {
- u_int16_t target_size;
-
- /* Used inside the kernel */
- struct arpt_target *target;
- } kernel;
-
- /* Total length */
- u_int16_t target_size;
- } u;
-
- unsigned char data[0];
-};
-
-struct arpt_standard_target
-{
- struct arpt_entry_target target;
- int verdict;
-};
+#define arpt_entry_target xt_entry_target
+#define arpt_standard_target xt_standard_target
/* Values for "flag" field in struct arpt_ip (general arp structure).
* No flags defined yet.
@@ -263,8 +236,10 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e
*/
#ifdef __KERNEL__
-#define arpt_register_target(tgt) xt_register_target(NF_ARP, tgt)
-#define arpt_unregister_target(tgt) xt_unregister_target(NF_ARP, tgt)
+#define arpt_register_target(tgt) \
+({ (tgt)->family = NF_ARP; \
+ xt_register_target(tgt); })
+#define arpt_unregister_target(tgt) xt_unregister_target(tgt)
extern int arpt_register_table(struct arpt_table *table,
const struct arpt_replace *repl);
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h
index 76ba24b6851..d5b8c0d6a12 100644
--- a/include/linux/netfilter_ipv4/ip_tables.h
+++ b/include/linux/netfilter_ipv4/ip_tables.h
@@ -52,61 +52,9 @@ struct ipt_ip {
u_int8_t invflags;
};
-struct ipt_entry_match
-{
- union {
- struct {
- u_int16_t match_size;
-
- /* Used by userspace */
- char name[IPT_FUNCTION_MAXNAMELEN-1];
-
- u_int8_t revision;
- } user;
- struct {
- u_int16_t match_size;
-
- /* Used inside the kernel */
- struct ipt_match *match;
- } kernel;
-
- /* Total length */
- u_int16_t match_size;
- } u;
-
- unsigned char data[0];
-};
-
-struct ipt_entry_target
-{
- union {
- struct {
- u_int16_t target_size;
-
- /* Used by userspace */
- char name[IPT_FUNCTION_MAXNAMELEN-1];
-
- u_int8_t revision;
- } user;
- struct {
- u_int16_t target_size;
-
- /* Used inside the kernel */
- struct ipt_target *target;
- } kernel;
-
- /* Total length */
- u_int16_t target_size;
- } u;
-
- unsigned char data[0];
-};
-
-struct ipt_standard_target
-{
- struct ipt_entry_target target;
- int verdict;
-};
+#define ipt_entry_match xt_entry_match
+#define ipt_entry_target xt_entry_target
+#define ipt_standard_target xt_standard_target
#define ipt_counters xt_counters
@@ -321,11 +269,15 @@ ipt_get_target(struct ipt_entry *e)
#include <linux/init.h>
extern void ipt_init(void) __init;
-#define ipt_register_target(tgt) xt_register_target(AF_INET, tgt)
-#define ipt_unregister_target(tgt) xt_unregister_target(AF_INET, tgt)
+#define ipt_register_target(tgt) \
+({ (tgt)->family = AF_INET; \
+ xt_register_target(tgt); })
+#define ipt_unregister_target(tgt) xt_unregister_target(tgt)
-#define ipt_register_match(mtch) xt_register_match(AF_INET, mtch)
-#define ipt_unregister_match(mtch) xt_unregister_match(AF_INET, mtch)
+#define ipt_register_match(mtch) \
+({ (mtch)->family = AF_INET; \
+ xt_register_match(mtch); })
+#define ipt_unregister_match(mtch) xt_unregister_match(mtch)
//#define ipt_register_table(tbl, repl) xt_register_table(AF_INET, tbl, repl)
//#define ipt_unregister_table(tbl) xt_unregister_table(AF_INET, tbl)
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h
index f249b574f0f..d0d5d1ee4be 100644
--- a/include/linux/netfilter_ipv6/ip6_tables.h
+++ b/include/linux/netfilter_ipv6/ip6_tables.h
@@ -56,60 +56,9 @@ struct ip6t_ip6 {
u_int8_t invflags;
};
-/* FIXME: If alignment in kernel different from userspace? --RR */
-struct ip6t_entry_match
-{
- union {
- struct {
- u_int16_t match_size;
-
- /* Used by userspace */
- char name[IP6T_FUNCTION_MAXNAMELEN-1];
- u_int8_t revision;
- } user;
- struct {
- u_int16_t match_size;
-
- /* Used inside the kernel */
- struct ip6t_match *match;
- } kernel;
-
- /* Total length */
- u_int16_t match_size;
- } u;
-
- unsigned char data[0];
-};
-
-struct ip6t_entry_target
-{
- union {
- struct {
- u_int16_t target_size;
-
- /* Used by userspace */
- char name[IP6T_FUNCTION_MAXNAMELEN-1];
- u_int8_t revision;
- } user;
- struct {
- u_int16_t target_size;
-
- /* Used inside the kernel */
- struct ip6t_target *target;
- } kernel;
-
- /* Total length */
- u_int16_t target_size;
- } u;
-
- unsigned char data[0];
-};
-
-struct ip6t_standard_target
-{
- struct ip6t_entry_target target;
- int verdict;
-};
+#define ip6t_entry_match xt_entry_match
+#define ip6t_entry_target xt_entry_target
+#define ip6t_standard_target xt_standard_target
#define ip6t_counters xt_counters
@@ -334,11 +283,15 @@ ip6t_get_target(struct ip6t_entry *e)
#include <linux/init.h>
extern void ip6t_init(void) __init;
-#define ip6t_register_target(tgt) xt_register_target(AF_INET6, tgt)
-#define ip6t_unregister_target(tgt) xt_unregister_target(AF_INET6, tgt)
+#define ip6t_register_target(tgt) \
+({ (tgt)->family = AF_INET6; \
+ xt_register_target(tgt); })
+#define ip6t_unregister_target(tgt) xt_unregister_target(tgt)
-#define ip6t_register_match(match) xt_register_match(AF_INET6, match)
-#define ip6t_unregister_match(match) xt_unregister_match(AF_INET6, match)
+#define ip6t_register_match(match) \
+({ (match)->family = AF_INET6; \
+ xt_register_match(match); })
+#define ip6t_unregister_match(match) xt_unregister_match(match)
extern int ip6t_register_table(struct ip6t_table *table,
const struct ip6t_replace *repl);
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h
index ee700c6eb44..839f0b3c23a 100644
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -51,6 +51,10 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask)
#define page_cache_release(page) put_page(page)
void release_pages(struct page **pages, int nr, int cold);
+#ifdef CONFIG_NUMA
+extern struct page *page_cache_alloc(struct address_space *x);
+extern struct page *page_cache_alloc_cold(struct address_space *x);
+#else
static inline struct page *page_cache_alloc(struct address_space *x)
{
return alloc_pages(mapping_gfp_mask(x), 0);
@@ -60,6 +64,7 @@ static inline struct page *page_cache_alloc_cold(struct address_space *x)
{
return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
}
+#endif
typedef int filler_t(void *, struct page *);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index fe1a2b02fc5..0aad5a378e9 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -95,6 +95,11 @@ enum pci_channel_state {
pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
};
+typedef unsigned short __bitwise pci_bus_flags_t;
+enum pci_bus_flags {
+ PCI_BUS_FLAGS_NO_MSI = (pci_bus_flags_t) 1,
+};
+
/*
* The pci_dev structure is used to describe PCI devices.
*/
@@ -203,7 +208,7 @@ struct pci_bus {
char name[48];
unsigned short bridge_ctl; /* manage NO_ISA/FBB/et al behaviors */
- unsigned short pad2;
+ pci_bus_flags_t bus_flags; /* Inherited by child busses */
struct device *bridge;
struct class_device class_dev;
struct bin_attribute *legacy_io; /* legacy I/O for this bus */
@@ -485,9 +490,9 @@ void pdev_sort_resources(struct pci_dev *, struct resource_list *);
void pci_fixup_irqs(u8 (*)(struct pci_dev *, u8 *),
int (*)(struct pci_dev *, u8, u8));
#define HAVE_PCI_REQ_REGIONS 2
-int pci_request_regions(struct pci_dev *, char *);
+int pci_request_regions(struct pci_dev *, const char *);
void pci_release_regions(struct pci_dev *);
-int pci_request_region(struct pci_dev *, int, char *);
+int pci_request_region(struct pci_dev *, int, const char *);
void pci_release_region(struct pci_dev *, int);
/* drivers/pci/bus.c */
@@ -516,6 +521,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass
void pci_walk_bus(struct pci_bus *top, void (*cb)(struct pci_dev *, void *),
void *userdata);
int pci_cfg_space_size(struct pci_dev *dev);
+unsigned char pci_bus_max_busnr(struct pci_bus* bus);
/* kmem_cache style wrapper around pci_alloc_consistent() */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index ec3c3293262..6f080ae5928 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -69,6 +69,7 @@
#define PCI_CLASS_SYSTEM_TIMER 0x0802
#define PCI_CLASS_SYSTEM_RTC 0x0803
#define PCI_CLASS_SYSTEM_PCI_HOTPLUG 0x0804
+#define PCI_CLASS_SYSTEM_SDHCI 0x0805
#define PCI_CLASS_SYSTEM_OTHER 0x0880
#define PCI_BASE_CLASS_INPUT 0x09
@@ -1371,6 +1372,7 @@
#define PCI_DEVICE_ID_SERVERWORKS_OSB4 0x0200
#define PCI_DEVICE_ID_SERVERWORKS_CSB5 0x0201
#define PCI_DEVICE_ID_SERVERWORKS_CSB6 0x0203
+#define PCI_DEVICE_ID_SERVERWORKS_HT1000SB 0x0205
#define PCI_DEVICE_ID_SERVERWORKS_OSB4IDE 0x0211
#define PCI_DEVICE_ID_SERVERWORKS_CSB5IDE 0x0212
#define PCI_DEVICE_ID_SERVERWORKS_CSB6IDE 0x0213
@@ -1864,11 +1866,13 @@
#define PCI_DEVICE_ID_TIGON3_5780S 0x166b
#define PCI_DEVICE_ID_TIGON3_5705F 0x166e
#define PCI_DEVICE_ID_TIGON3_5754M 0x1672
+#define PCI_DEVICE_ID_TIGON3_5755M 0x1673
#define PCI_DEVICE_ID_TIGON3_5750 0x1676
#define PCI_DEVICE_ID_TIGON3_5751 0x1677
#define PCI_DEVICE_ID_TIGON3_5715 0x1678
#define PCI_DEVICE_ID_TIGON3_5715S 0x1679
#define PCI_DEVICE_ID_TIGON3_5754 0x167a
+#define PCI_DEVICE_ID_TIGON3_5755 0x167b
#define PCI_DEVICE_ID_TIGON3_5750M 0x167c
#define PCI_DEVICE_ID_TIGON3_5751M 0x167d
#define PCI_DEVICE_ID_TIGON3_5751F 0x167e
diff --git a/include/linux/platform.h b/include/linux/platform.h
deleted file mode 100644
index 3c33084a6ec..00000000000
--- a/include/linux/platform.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * include/linux/platform.h - platform driver definitions
- *
- * Because of the prolific consumerism of the average American,
- * and the dominant marketing budgets of PC OEMs, we have been
- * blessed with frequent updates of the PC architecture.
- *
- * While most of these calls are singular per architecture, they
- * require an extra layer of abstraction on the x86 so the right
- * subsystem gets the right call.
- *
- * Basically, this consolidates the power off and reboot callbacks
- * into one structure, as well as adding power management hooks.
- *
- * When adding a platform driver, please make sure all callbacks are
- * filled. There are defaults defined below that do nothing; use those
- * if you do not support that callback.
- */
-
-#ifndef _PLATFORM_H_
-#define _PLATFORM_H_
-#ifdef __KERNEL__
-
-#include <linux/types.h>
-
-struct platform_t {
- char * name;
- u32 suspend_states;
- void (*reboot)(char * cmd);
- void (*halt)(void);
- void (*power_off)(void);
- int (*suspend)(int state, int flags);
- void (*idle)(void);
-};
-
-extern struct platform_t * platform;
-extern void default_reboot(char * cmd);
-extern void default_halt(void);
-extern int default_suspend(int state, int flags);
-extern void default_idle(void);
-
-#endif /* __KERNEL__ */
-#endif /* _PLATFORM_H */
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 5be87ba3b7a..6df2585c016 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -188,6 +188,8 @@ extern void device_power_up(void);
extern void device_resume(void);
#ifdef CONFIG_PM
+extern suspend_disk_method_t pm_disk_mode;
+
extern int device_suspend(pm_message_t state);
#define device_set_wakeup_enable(dev,val) \
@@ -215,7 +217,6 @@ static inline int dpm_runtime_suspend(struct device * dev, pm_message_t state)
static inline void dpm_runtime_resume(struct device * dev)
{
-
}
#endif
diff --git a/include/linux/ppdev.h b/include/linux/ppdev.h
index 141c9658682..f376a7598a7 100644
--- a/include/linux/ppdev.h
+++ b/include/linux/ppdev.h
@@ -14,8 +14,6 @@
* Added PPGETMODES/PPGETMODE/PPGETPHASE, Fred Barnes <frmb2@ukc.ac.uk>, 03/01/2001
*/
-#define PP_MAJOR 99
-
#define PP_IOCTL 'p'
/* Set mode for read/write (e.g. IEEE1284_MODE_EPP) */
diff --git a/include/linux/profile.h b/include/linux/profile.h
index 026969a5595..1f2fea6640a 100644
--- a/include/linux/profile.h
+++ b/include/linux/profile.h
@@ -14,6 +14,7 @@
struct proc_dir_entry;
struct pt_regs;
+struct notifier_block;
/* init basic kernel profiler */
void __init profile_init(void);
@@ -32,7 +33,6 @@ enum profile_type {
#ifdef CONFIG_PROFILING
-struct notifier_block;
struct task_struct;
struct mm_struct;
diff --git a/include/linux/quota.h b/include/linux/quota.h
index f33aeb22c26..2dab71e1c3d 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -38,6 +38,7 @@
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/spinlock.h>
+#include <linux/mutex.h>
#define __DQUOT_VERSION__ "dquot_6.5.1"
#define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
@@ -208,14 +209,13 @@ extern struct dqstats dqstats;
#define DQ_FAKE_B 3 /* no limits only usage */
#define DQ_READ_B 4 /* dquot was read into memory */
#define DQ_ACTIVE_B 5 /* dquot is active (dquot_release not called) */
-#define DQ_WAITFREE_B 6 /* dquot being waited (by invalidate_dquots) */
struct dquot {
struct hlist_node dq_hash; /* Hash list in memory */
struct list_head dq_inuse; /* List of all quotas */
struct list_head dq_free; /* Free list element */
struct list_head dq_dirty; /* List of dirty dquots */
- struct semaphore dq_lock; /* dquot IO lock */
+ struct mutex dq_lock; /* dquot IO lock */
atomic_t dq_count; /* Use count */
wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */
struct super_block *dq_sb; /* superblock this applies to */
@@ -285,8 +285,8 @@ struct quota_format_type {
struct quota_info {
unsigned int flags; /* Flags for diskquotas on this device */
- struct semaphore dqio_sem; /* lock device while I/O in progress */
- struct semaphore dqonoff_sem; /* Serialize quotaon & quotaoff */
+ struct mutex dqio_mutex; /* lock device while I/O in progress */
+ struct mutex dqonoff_mutex; /* Serialize quotaon & quotaoff */
struct rw_semaphore dqptr_sem; /* serialize ops using quota_info struct, pointers from inode to dquots */
struct inode *files[MAXQUOTAS]; /* inodes of quotafiles */
struct mem_dqinfo info[MAXQUOTAS]; /* Information for each quota type */
diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h
index c57ff2fcb30..dd83cca2800 100644
--- a/include/linux/radix-tree.h
+++ b/include/linux/radix-tree.h
@@ -45,6 +45,8 @@ do { \
(root)->rnode = NULL; \
} while (0)
+#define RADIX_TREE_MAX_TAGS 2
+
int radix_tree_insert(struct radix_tree_root *, unsigned long, void *);
void *radix_tree_lookup(struct radix_tree_root *, unsigned long);
void **radix_tree_lookup_slot(struct radix_tree_root *, unsigned long);
@@ -55,15 +57,16 @@ radix_tree_gang_lookup(struct radix_tree_root *root, void **results,
int radix_tree_preload(gfp_t gfp_mask);
void radix_tree_init(void);
void *radix_tree_tag_set(struct radix_tree_root *root,
- unsigned long index, int tag);
+ unsigned long index, unsigned int tag);
void *radix_tree_tag_clear(struct radix_tree_root *root,
- unsigned long index, int tag);
+ unsigned long index, unsigned int tag);
int radix_tree_tag_get(struct radix_tree_root *root,
- unsigned long index, int tag);
+ unsigned long index, unsigned int tag);
unsigned int
radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
- unsigned long first_index, unsigned int max_items, int tag);
-int radix_tree_tagged(struct radix_tree_root *root, int tag);
+ unsigned long first_index, unsigned int max_items,
+ unsigned int tag);
+int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag);
static inline void radix_tree_preload_end(void)
{
diff --git a/include/linux/raid/raid1.h b/include/linux/raid/raid1.h
index 9d5494aaac0..3009c813d83 100644
--- a/include/linux/raid/raid1.h
+++ b/include/linux/raid/raid1.h
@@ -130,6 +130,6 @@ struct r1bio_s {
* with failure when last write completes (and all failed).
* Record that bi_end_io was called with this flag...
*/
-#define R1BIO_Returned 4
+#define R1BIO_Returned 6
#endif
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h
index c2ec6c77874..5673008b61e 100644
--- a/include/linux/rcupdate.h
+++ b/include/linux/rcupdate.h
@@ -113,8 +113,6 @@ struct rcu_data {
DECLARE_PER_CPU(struct rcu_data, rcu_data);
DECLARE_PER_CPU(struct rcu_data, rcu_bh_data);
-extern struct rcu_ctrlblk rcu_ctrlblk;
-extern struct rcu_ctrlblk rcu_bh_ctrlblk;
/*
* Increment the quiescent state counter.
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index dad78cecfd2..912f1b7cb18 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -1704,6 +1704,11 @@ static inline int reiserfs_transaction_running(struct super_block *s)
return 0;
}
+static inline int reiserfs_transaction_free_space(struct reiserfs_transaction_handle *th)
+{
+ return th->t_blocks_allocated - th->t_blocks_logged;
+}
+
int reiserfs_async_progress_wait(struct super_block *s);
struct reiserfs_transaction_handle *reiserfs_persistent_transaction(struct
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h
index 87280eb6083..5353afb11db 100644
--- a/include/linux/reiserfs_xattr.h
+++ b/include/linux/reiserfs_xattr.h
@@ -101,13 +101,13 @@ static inline void reiserfs_mark_inode_private(struct inode *inode)
#else
#define is_reiserfs_priv_object(inode) 0
-#define reiserfs_mark_inode_private(inode)
+#define reiserfs_mark_inode_private(inode) do {;} while(0)
#define reiserfs_getxattr NULL
#define reiserfs_setxattr NULL
#define reiserfs_listxattr NULL
#define reiserfs_removexattr NULL
-#define reiserfs_write_lock_xattrs(sb)
-#define reiserfs_write_unlock_xattrs(sb)
+#define reiserfs_write_lock_xattrs(sb) do {;} while(0)
+#define reiserfs_write_unlock_xattrs(sb) do {;} while(0)
#define reiserfs_read_lock_xattrs(sb)
#define reiserfs_read_unlock_xattrs(sb)
diff --git a/include/linux/relay.h b/include/linux/relay.h
new file mode 100644
index 00000000000..4bcc1531d6a
--- /dev/null
+++ b/include/linux/relay.h
@@ -0,0 +1,281 @@
+/*
+ * linux/include/linux/relay.h
+ *
+ * Copyright (C) 2002, 2003 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour (karim@opersys.com)
+ *
+ * CONFIG_RELAY definitions and declarations
+ */
+
+#ifndef _LINUX_RELAY_H
+#define _LINUX_RELAY_H
+
+#include <linux/config.h>
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+#include <linux/list.h>
+#include <linux/fs.h>
+#include <linux/poll.h>
+#include <linux/kref.h>
+
+/* Needs a _much_ better name... */
+#define FIX_SIZE(x) ((((x) - 1) & PAGE_MASK) + PAGE_SIZE)
+
+/*
+ * Tracks changes to rchan/rchan_buf structs
+ */
+#define RELAYFS_CHANNEL_VERSION 6
+
+/*
+ * Per-cpu relay channel buffer
+ */
+struct rchan_buf
+{
+ void *start; /* start of channel buffer */
+ void *data; /* start of current sub-buffer */
+ size_t offset; /* current offset into sub-buffer */
+ size_t subbufs_produced; /* count of sub-buffers produced */
+ size_t subbufs_consumed; /* count of sub-buffers consumed */
+ struct rchan *chan; /* associated channel */
+ wait_queue_head_t read_wait; /* reader wait queue */
+ struct work_struct wake_readers; /* reader wake-up work struct */
+ struct dentry *dentry; /* channel file dentry */
+ struct kref kref; /* channel buffer refcount */
+ struct page **page_array; /* array of current buffer pages */
+ unsigned int page_count; /* number of current buffer pages */
+ unsigned int finalized; /* buffer has been finalized */
+ size_t *padding; /* padding counts per sub-buffer */
+ size_t prev_padding; /* temporary variable */
+ size_t bytes_consumed; /* bytes consumed in cur read subbuf */
+ unsigned int cpu; /* this buf's cpu */
+} ____cacheline_aligned;
+
+/*
+ * Relay channel data structure
+ */
+struct rchan
+{
+ u32 version; /* the version of this struct */
+ size_t subbuf_size; /* sub-buffer size */
+ size_t n_subbufs; /* number of sub-buffers per buffer */
+ size_t alloc_size; /* total buffer size allocated */
+ struct rchan_callbacks *cb; /* client callbacks */
+ struct kref kref; /* channel refcount */
+ void *private_data; /* for user-defined data */
+ size_t last_toobig; /* tried to log event > subbuf size */
+ struct rchan_buf *buf[NR_CPUS]; /* per-cpu channel buffers */
+};
+
+/*
+ * Relay channel client callbacks
+ */
+struct rchan_callbacks
+{
+ /*
+ * subbuf_start - called on buffer-switch to a new sub-buffer
+ * @buf: the channel buffer containing the new sub-buffer
+ * @subbuf: the start of the new sub-buffer
+ * @prev_subbuf: the start of the previous sub-buffer
+ * @prev_padding: unused space at the end of previous sub-buffer
+ *
+ * The client should return 1 to continue logging, 0 to stop
+ * logging.
+ *
+ * NOTE: subbuf_start will also be invoked when the buffer is
+ * created, so that the first sub-buffer can be initialized
+ * if necessary. In this case, prev_subbuf will be NULL.
+ *
+ * NOTE: the client can reserve bytes at the beginning of the new
+ * sub-buffer by calling subbuf_start_reserve() in this callback.
+ */
+ int (*subbuf_start) (struct rchan_buf *buf,
+ void *subbuf,
+ void *prev_subbuf,
+ size_t prev_padding);
+
+ /*
+ * buf_mapped - relay buffer mmap notification
+ * @buf: the channel buffer
+ * @filp: relay file pointer
+ *
+ * Called when a relay file is successfully mmapped
+ */
+ void (*buf_mapped)(struct rchan_buf *buf,
+ struct file *filp);
+
+ /*
+ * buf_unmapped - relay buffer unmap notification
+ * @buf: the channel buffer
+ * @filp: relay file pointer
+ *
+ * Called when a relay file is successfully unmapped
+ */
+ void (*buf_unmapped)(struct rchan_buf *buf,
+ struct file *filp);
+ /*
+ * create_buf_file - create file to represent a relay channel buffer
+ * @filename: the name of the file to create
+ * @parent: the parent of the file to create
+ * @mode: the mode of the file to create
+ * @buf: the channel buffer
+ * @is_global: outparam - set non-zero if the buffer should be global
+ *
+ * Called during relay_open(), once for each per-cpu buffer,
+ * to allow the client to create a file to be used to
+ * represent the corresponding channel buffer. If the file is
+ * created outside of relay, the parent must also exist in
+ * that filesystem.
+ *
+ * The callback should return the dentry of the file created
+ * to represent the relay buffer.
+ *
+ * Setting the is_global outparam to a non-zero value will
+ * cause relay_open() to create a single global buffer rather
+ * than the default set of per-cpu buffers.
+ *
+ * See Documentation/filesystems/relayfs.txt for more info.
+ */
+ struct dentry *(*create_buf_file)(const char *filename,
+ struct dentry *parent,
+ int mode,
+ struct rchan_buf *buf,
+ int *is_global);
+
+ /*
+ * remove_buf_file - remove file representing a relay channel buffer
+ * @dentry: the dentry of the file to remove
+ *
+ * Called during relay_close(), once for each per-cpu buffer,
+ * to allow the client to remove a file used to represent a
+ * channel buffer.
+ *
+ * The callback should return 0 if successful, negative if not.
+ */
+ int (*remove_buf_file)(struct dentry *dentry);
+};
+
+/*
+ * CONFIG_RELAY kernel API, kernel/relay.c
+ */
+
+struct rchan *relay_open(const char *base_filename,
+ struct dentry *parent,
+ size_t subbuf_size,
+ size_t n_subbufs,
+ struct rchan_callbacks *cb);
+extern void relay_close(struct rchan *chan);
+extern void relay_flush(struct rchan *chan);
+extern void relay_subbufs_consumed(struct rchan *chan,
+ unsigned int cpu,
+ size_t consumed);
+extern void relay_reset(struct rchan *chan);
+extern int relay_buf_full(struct rchan_buf *buf);
+
+extern size_t relay_switch_subbuf(struct rchan_buf *buf,
+ size_t length);
+
+/**
+ * relay_write - write data into the channel
+ * @chan: relay channel
+ * @data: data to be written
+ * @length: number of bytes to write
+ *
+ * Writes data into the current cpu's channel buffer.
+ *
+ * Protects the buffer by disabling interrupts. Use this
+ * if you might be logging from interrupt context. Try
+ * __relay_write() if you know you won't be logging from
+ * interrupt context.
+ */
+static inline void relay_write(struct rchan *chan,
+ const void *data,
+ size_t length)
+{
+ unsigned long flags;
+ struct rchan_buf *buf;
+
+ local_irq_save(flags);
+ buf = chan->buf[smp_processor_id()];
+ if (unlikely(buf->offset + length > chan->subbuf_size))
+ length = relay_switch_subbuf(buf, length);
+ memcpy(buf->data + buf->offset, data, length);
+ buf->offset += length;
+ local_irq_restore(flags);
+}
+
+/**
+ * __relay_write - write data into the channel
+ * @chan: relay channel
+ * @data: data to be written
+ * @length: number of bytes to write
+ *
+ * Writes data into the current cpu's channel buffer.
+ *
+ * Protects the buffer by disabling preemption. Use
+ * relay_write() if you might be logging from interrupt
+ * context.
+ */
+static inline void __relay_write(struct rchan *chan,
+ const void *data,
+ size_t length)
+{
+ struct rchan_buf *buf;
+
+ buf = chan->buf[get_cpu()];
+ if (unlikely(buf->offset + length > buf->chan->subbuf_size))
+ length = relay_switch_subbuf(buf, length);
+ memcpy(buf->data + buf->offset, data, length);
+ buf->offset += length;
+ put_cpu();
+}
+
+/**
+ * relay_reserve - reserve slot in channel buffer
+ * @chan: relay channel
+ * @length: number of bytes to reserve
+ *
+ * Returns pointer to reserved slot, NULL if full.
+ *
+ * Reserves a slot in the current cpu's channel buffer.
+ * Does not protect the buffer at all - caller must provide
+ * appropriate synchronization.
+ */
+static inline void *relay_reserve(struct rchan *chan, size_t length)
+{
+ void *reserved;
+ struct rchan_buf *buf = chan->buf[smp_processor_id()];
+
+ if (unlikely(buf->offset + length > buf->chan->subbuf_size)) {
+ length = relay_switch_subbuf(buf, length);
+ if (!length)
+ return NULL;
+ }
+ reserved = buf->data + buf->offset;
+ buf->offset += length;
+
+ return reserved;
+}
+
+/**
+ * subbuf_start_reserve - reserve bytes at the start of a sub-buffer
+ * @buf: relay channel buffer
+ * @length: number of bytes to reserve
+ *
+ * Helper function used to reserve bytes at the beginning of
+ * a sub-buffer in the subbuf_start() callback.
+ */
+static inline void subbuf_start_reserve(struct rchan_buf *buf,
+ size_t length)
+{
+ BUG_ON(length >= buf->chan->subbuf_size - 1);
+ buf->offset = length;
+}
+
+/*
+ * exported relay file operations, kernel/relay.c
+ */
+extern struct file_operations relay_file_operations;
+
+#endif /* _LINUX_RELAY_H */
+
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index d572d537631..df0cdd41085 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -839,6 +839,7 @@ enum
#define RTMGRP_IPV4_IFADDR 0x10
#define RTMGRP_IPV4_MROUTE 0x20
#define RTMGRP_IPV4_ROUTE 0x40
+#define RTMGRP_IPV4_RULE 0x80
#define RTMGRP_IPV6_IFADDR 0x100
#define RTMGRP_IPV6_MROUTE 0x200
@@ -869,7 +870,8 @@ enum rtnetlink_groups {
#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
RTNLGRP_IPV4_ROUTE,
#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
- RTNLGRP_NOP1,
+ RTNLGRP_IPV4_RULE,
+#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
RTNLGRP_IPV6_IFADDR,
#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
RTNLGRP_IPV6_MROUTE,
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 62e6314382f..e0054c1b9a0 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -206,11 +206,11 @@ extern void update_process_times(int user);
extern void scheduler_tick(void);
#ifdef CONFIG_DETECT_SOFTLOCKUP
-extern void softlockup_tick(struct pt_regs *regs);
+extern void softlockup_tick(void);
extern void spawn_softlockup_task(void);
extern void touch_softlockup_watchdog(void);
#else
-static inline void softlockup_tick(struct pt_regs *regs)
+static inline void softlockup_tick(void)
{
}
static inline void spawn_softlockup_task(void)
@@ -706,6 +706,7 @@ struct task_struct {
prio_array_t *array;
unsigned short ioprio;
+ unsigned int btrace_seq;
unsigned long sleep_avg;
unsigned long long timestamp, last_ran;
@@ -868,6 +869,7 @@ struct task_struct {
struct cpuset *cpuset;
nodemask_t mems_allowed;
int cpuset_mems_generation;
+ int cpuset_mem_spread_rotor;
#endif
atomic_t fs_excl; /* holding fs exclusive resources */
struct rcu_head rcu;
@@ -928,6 +930,9 @@ static inline void put_task_struct(struct task_struct *t)
#define PF_BORROWED_MM 0x00400000 /* I am a kthread doing use_mm */
#define PF_RANDOMIZE 0x00800000 /* randomize virtual address space */
#define PF_SWAPWRITE 0x01000000 /* Allowed to write to swap */
+#define PF_SPREAD_PAGE 0x04000000 /* Spread page cache over cpuset */
+#define PF_SPREAD_SLAB 0x08000000 /* Spread some slab caches over cpuset */
+#define PF_MEMPOLICY 0x10000000 /* Non-default NUMA mempolicy */
/*
* Only the _current_ task can read/write to tsk->flags, but other
diff --git a/include/linux/security.h b/include/linux/security.h
index b18eb8cfa63..3c19be35124 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1040,6 +1040,11 @@ struct swap_info_struct;
* @effective contains the effective capability set.
* @inheritable contains the inheritable capability set.
* @permitted contains the permitted capability set.
+ * @capable:
+ * Check whether the @tsk process has the @cap capability.
+ * @tsk contains the task_struct for the process.
+ * @cap contains the capability <include/linux/capability.h>.
+ * Return 0 if the capability is granted for @tsk.
* @acct:
* Check permission before enabling or disabling process accounting. If
* accounting is being enabled, then @file refers to the open file used to
@@ -1053,11 +1058,6 @@ struct swap_info_struct;
* @table contains the ctl_table structure for the sysctl variable.
* @op contains the operation (001 = search, 002 = write, 004 = read).
* Return 0 if permission is granted.
- * @capable:
- * Check whether the @tsk process has the @cap capability.
- * @tsk contains the task_struct for the process.
- * @cap contains the capability <include/linux/capability.h>.
- * Return 0 if the capability is granted for @tsk.
* @syslog:
* Check permission before accessing the kernel message ring or changing
* logging to the console.
@@ -1099,9 +1099,9 @@ struct security_operations {
kernel_cap_t * effective,
kernel_cap_t * inheritable,
kernel_cap_t * permitted);
+ int (*capable) (struct task_struct * tsk, int cap);
int (*acct) (struct file * file);
int (*sysctl) (struct ctl_table * table, int op);
- int (*capable) (struct task_struct * tsk, int cap);
int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
int (*quota_on) (struct dentry * dentry);
int (*syslog) (int type);
@@ -1347,6 +1347,11 @@ static inline void security_capset_set (struct task_struct *target,
security_ops->capset_set (target, effective, inheritable, permitted);
}
+static inline int security_capable(struct task_struct *tsk, int cap)
+{
+ return security_ops->capable(tsk, cap);
+}
+
static inline int security_acct (struct file *file)
{
return security_ops->acct (file);
@@ -2050,6 +2055,11 @@ static inline void security_capset_set (struct task_struct *target,
cap_capset_set (target, effective, inheritable, permitted);
}
+static inline int security_capable(struct task_struct *tsk, int cap)
+{
+ return cap_capable(tsk, cap);
+}
+
static inline int security_acct (struct file *file)
{
return 0;
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 850a974ee50..b95f6eb7254 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -4,7 +4,7 @@
#include <linux/types.h>
#include <linux/string.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
struct seq_operations;
struct file;
@@ -19,7 +19,7 @@ struct seq_file {
size_t count;
loff_t index;
loff_t version;
- struct semaphore sem;
+ struct mutex lock;
struct seq_operations *op;
void *private;
};
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 57abcea1cb5..c32e60e79de 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -369,6 +369,9 @@ void uart_parse_options(char *options, int *baud, int *parity, int *bits,
int uart_set_options(struct uart_port *port, struct console *co, int baud,
int parity, int bits, int flow);
struct tty_driver *uart_console_device(struct console *co, int *index);
+void uart_console_write(struct uart_port *port, const char *s,
+ unsigned int count,
+ void (*putchar)(struct uart_port *, int));
/*
* Port/driver registration/removal
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 2b28c849d75..15e1d9736b1 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -46,6 +46,7 @@ typedef struct kmem_cache kmem_cache_t;
what is reclaimable later*/
#define SLAB_PANIC 0x00040000UL /* panic if kmem_cache_create() fails */
#define SLAB_DESTROY_BY_RCU 0x00080000UL /* defer freeing pages to RCU */
+#define SLAB_MEM_SPREAD 0x00100000UL /* Spread some memory over cpuset */
/* flags passed to a constructor func */
#define SLAB_CTOR_CONSTRUCTOR 0x001UL /* if not set, then deconstructor */
@@ -63,6 +64,7 @@ extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned lo
extern int kmem_cache_destroy(kmem_cache_t *);
extern int kmem_cache_shrink(kmem_cache_t *);
extern void *kmem_cache_alloc(kmem_cache_t *, gfp_t);
+extern void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
extern void kmem_cache_free(kmem_cache_t *, void *);
extern unsigned int kmem_cache_size(kmem_cache_t *);
extern const char *kmem_cache_name(kmem_cache_t *);
@@ -76,11 +78,12 @@ struct cache_sizes {
};
extern struct cache_sizes malloc_sizes[];
-#ifndef CONFIG_DEBUG_SLAB
extern void *__kmalloc(size_t, gfp_t);
+#ifndef CONFIG_DEBUG_SLAB
+#define ____kmalloc(size, flags) __kmalloc(size, flags)
#else
extern void *__kmalloc_track_caller(size_t, gfp_t, void*);
-#define __kmalloc(size, flags) \
+#define ____kmalloc(size, flags) \
__kmalloc_track_caller(size, flags, __builtin_return_address(0))
#endif
@@ -107,7 +110,30 @@ found:
return __kmalloc(size, flags);
}
-extern void *kzalloc(size_t, gfp_t);
+extern void *__kzalloc(size_t, gfp_t);
+
+static inline void *kzalloc(size_t size, gfp_t flags)
+{
+ if (__builtin_constant_p(size)) {
+ int i = 0;
+#define CACHE(x) \
+ if (size <= x) \
+ goto found; \
+ else \
+ i++;
+#include "kmalloc_sizes.h"
+#undef CACHE
+ {
+ extern void __you_cannot_kzalloc_that_much(void);
+ __you_cannot_kzalloc_that_much();
+ }
+found:
+ return kmem_cache_zalloc((flags & GFP_DMA) ?
+ malloc_sizes[i].cs_dmacachep :
+ malloc_sizes[i].cs_cachep, flags);
+ }
+ return __kzalloc(size, flags);
+}
/**
* kcalloc - allocate memory for an array. The memory is set to zero.
@@ -154,17 +180,18 @@ struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t,
void (*)(void *, struct kmem_cache *, unsigned long));
int kmem_cache_destroy(struct kmem_cache *c);
void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags);
+void *kmem_cache_zalloc(struct kmem_cache *, gfp_t);
void kmem_cache_free(struct kmem_cache *c, void *b);
const char *kmem_cache_name(struct kmem_cache *);
void *kmalloc(size_t size, gfp_t flags);
-void *kzalloc(size_t size, gfp_t flags);
+void *__kzalloc(size_t size, gfp_t flags);
void kfree(const void *m);
unsigned int ksize(const void *m);
unsigned int kmem_cache_size(struct kmem_cache *c);
static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
{
- return kzalloc(n * size, flags);
+ return __kzalloc(n * size, flags);
}
#define kmem_cache_shrink(d) (0)
@@ -172,6 +199,8 @@ static inline void *kcalloc(size_t n, size_t size, gfp_t flags)
#define kmem_ptr_validate(a, b) (0)
#define kmem_cache_alloc_node(c, f, n) kmem_cache_alloc(c, f)
#define kmalloc_node(s, f, n) kmalloc(s, f)
+#define kzalloc(s, f) __kzalloc(s, f)
+#define ____kmalloc kmalloc
#endif /* CONFIG_SLOB */
diff --git a/include/linux/string.h b/include/linux/string.h
index 369be3264a5..dee221429ad 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -18,6 +18,8 @@ extern char * strsep(char **,const char *);
extern __kernel_size_t strspn(const char *,const char *);
extern __kernel_size_t strcspn(const char *,const char *);
+extern char *strndup_user(const char __user *, long);
+
/*
* Include machine specific inline routines
*/
diff --git a/include/linux/swap.h b/include/linux/swap.h
index 12415dd9445..54eac8a39a4 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -234,14 +234,15 @@ extern struct page * read_swap_cache_async(swp_entry_t, struct vm_area_struct *v
/* linux/mm/swapfile.c */
extern long total_swap_pages;
extern unsigned int nr_swapfiles;
-extern struct swap_info_struct swap_info[];
extern void si_swapinfo(struct sysinfo *);
extern swp_entry_t get_swap_page(void);
-extern swp_entry_t get_swap_page_of_type(int type);
+extern swp_entry_t get_swap_page_of_type(int);
extern int swap_duplicate(swp_entry_t);
extern int valid_swaphandles(swp_entry_t, unsigned long *);
extern void swap_free(swp_entry_t);
extern void free_swap_and_cache(swp_entry_t);
+extern int swap_type_of(dev_t);
+extern unsigned int count_swap_pages(int, int);
extern sector_t map_swap_page(struct swap_info_struct *, pgoff_t);
extern struct swap_info_struct *get_swap_info_struct(unsigned);
extern int can_share_swap_page(struct page *);
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index b9ea44ac0dd..e487e3b60f6 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -568,5 +568,6 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user * filename,
int flag);
asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
int flags, int mode);
+asmlinkage long sys_unshare(unsigned long unshare_flags);
#endif
diff --git a/include/linux/time.h b/include/linux/time.h
index d9cdba54b78..bf0e785e2e0 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -101,6 +101,7 @@ extern long do_utimes(int dfd, char __user *filename, struct timeval *times);
struct itimerval;
extern int do_setitimer(int which, struct itimerval *value,
struct itimerval *ovalue);
+extern unsigned int alarm_setitimer(unsigned int seconds);
extern int do_getitimer(int which, struct itimerval *value);
extern void getnstimeofday(struct timespec *tv);
diff --git a/include/linux/timer.h b/include/linux/timer.h
index 9b9877fd250..ee5a09e806e 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -69,13 +69,13 @@ extern unsigned long next_timer_interrupt(void);
* @timer: the timer to be added
*
* The kernel will do a ->function(->data) callback from the
- * timer interrupt at the ->expired point in the future. The
+ * timer interrupt at the ->expires point in the future. The
* current time is 'jiffies'.
*
- * The timer's ->expired, ->function (and if the handler uses it, ->data)
+ * The timer's ->expires, ->function (and if the handler uses it, ->data)
* fields must be set prior calling this function.
*
- * Timers with an ->expired field in the past will be executed in the next
+ * Timers with an ->expires field in the past will be executed in the next
* timer tick.
*/
static inline void add_timer(struct timer_list *timer)
diff --git a/include/linux/timex.h b/include/linux/timex.h
index b7ca1204e42..82dc9ae79d3 100644
--- a/include/linux/timex.h
+++ b/include/linux/timex.h
@@ -97,38 +97,11 @@
#define MAXPHASE 512000L /* max phase error (us) */
#define MAXFREQ (512L << SHIFT_USEC) /* max frequency error (ppm) */
-#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
#define MINSEC 16L /* min interval between updates (s) */
#define MAXSEC 1200L /* max interval between updates (s) */
#define NTP_PHASE_LIMIT (MAXPHASE << 5) /* beyond max. dispersion */
/*
- * The following defines are used only if a pulse-per-second (PPS)
- * signal is available and connected via a modem control lead, such as
- * produced by the optional ppsclock feature incorporated in the Sun
- * asynch driver. They establish the design parameters of the frequency-
- * lock loop used to discipline the CPU clock oscillator to the PPS
- * signal.
- *
- * PPS_AVG is the averaging factor for the frequency loop, as well as
- * the time and frequency dispersion.
- *
- * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
- * calibration intervals, respectively, in seconds as a power of two.
- *
- * PPS_VALID is the maximum interval before the PPS signal is considered
- * invalid and protocol updates used directly instead.
- *
- * MAXGLITCH is the maximum interval before a time offset of more than
- * MAXTIME is believed.
- */
-#define PPS_AVG 2 /* pps averaging constant (shift) */
-#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
-#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
-#define PPS_VALID 120 /* pps signal watchdog max (s) */
-#define MAXGLITCH 30 /* pps signal glitch max (s) */
-
-/*
* syscall interface - used (mainly by NTP daemon)
* to discipline kernel clock oscillator
*/
@@ -246,20 +219,6 @@ extern long time_reftime; /* time at last adjustment (s) */
extern long time_adjust; /* The amount of adjtime left */
extern long time_next_adjust; /* Value for time_adjust at next tick */
-/* interface variables pps->timer interrupt */
-extern long pps_offset; /* pps time offset (us) */
-extern long pps_jitter; /* time dispersion (jitter) (us) */
-extern long pps_freq; /* frequency offset (scaled ppm) */
-extern long pps_stabil; /* frequency dispersion (scaled ppm) */
-extern long pps_valid; /* pps signal watchdog counter */
-
-/* interface variables pps->adjtimex */
-extern int pps_shift; /* interval duration (s) (shift) */
-extern long pps_jitcnt; /* jitter limit exceeded */
-extern long pps_calcnt; /* calibration intervals */
-extern long pps_errcnt; /* calibration errors */
-extern long pps_stbcnt; /* stability limit exceeded */
-
/**
* ntp_clear - Clears the NTP state variables
*
diff --git a/include/linux/tty.h b/include/linux/tty.h
index f45cd74e6f2..f13f49afe19 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -24,6 +24,7 @@
#include <linux/tty_driver.h>
#include <linux/tty_ldisc.h>
#include <linux/screen_info.h>
+#include <linux/mutex.h>
#include <asm/system.h>
@@ -231,8 +232,8 @@ struct tty_struct {
int canon_data;
unsigned long canon_head;
unsigned int canon_column;
- struct semaphore atomic_read;
- struct semaphore atomic_write;
+ struct mutex atomic_read_lock;
+ struct mutex atomic_write_lock;
unsigned char *write_buf;
int write_cnt;
spinlock_t read_lock;
@@ -319,8 +320,7 @@ extern void tty_ldisc_put(int);
extern void tty_wakeup(struct tty_struct *tty);
extern void tty_ldisc_flush(struct tty_struct *tty);
-struct semaphore;
-extern struct semaphore tty_sem;
+extern struct mutex tty_mutex;
/* n_tty.c */
extern struct tty_ldisc tty_ldisc_N_TTY;
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h
index 222faf97d5f..0976a163b45 100644
--- a/include/linux/tty_flip.h
+++ b/include/linux/tty_flip.h
@@ -2,19 +2,13 @@
#define _LINUX_TTY_FLIP_H
extern int tty_buffer_request_room(struct tty_struct *tty, size_t size);
-extern int tty_insert_flip_string(struct tty_struct *tty, unsigned char *chars, size_t size);
-extern int tty_insert_flip_string_flags(struct tty_struct *tty, unsigned char *chars, char *flags, size_t size);
+extern int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size);
+extern int tty_insert_flip_string_flags(struct tty_struct *tty, const unsigned char *chars, const char *flags, size_t size);
extern int tty_prepare_flip_string(struct tty_struct *tty, unsigned char **chars, size_t size);
extern int tty_prepare_flip_string_flags(struct tty_struct *tty, unsigned char **chars, char **flags, size_t size);
-#ifdef INCLUDE_INLINE_FUNCS
-#define _INLINE_ extern
-#else
-#define _INLINE_ static __inline__
-#endif
-
-_INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
- unsigned char ch, char flag)
+static inline int tty_insert_flip_char(struct tty_struct *tty,
+ unsigned char ch, char flag)
{
struct tty_buffer *tb = tty->buf.tail;
if (tb && tb->active && tb->used < tb->size) {
@@ -25,7 +19,7 @@ _INLINE_ int tty_insert_flip_char(struct tty_struct *tty,
return tty_insert_flip_string_flags(tty, &ch, &flag, 1);
}
-_INLINE_ void tty_schedule_flip(struct tty_struct *tty)
+static inline void tty_schedule_flip(struct tty_struct *tty)
{
unsigned long flags;
spin_lock_irqsave(&tty->buf.lock, flags);
diff --git a/include/linux/udf_fs_i.h b/include/linux/udf_fs_i.h
index 1e7508420fc..ffaf05679ff 100644
--- a/include/linux/udf_fs_i.h
+++ b/include/linux/udf_fs_i.h
@@ -15,27 +15,6 @@
#ifdef __KERNEL__
-#ifndef _ECMA_167_H
-typedef struct
-{
- __u32 logicalBlockNum;
- __u16 partitionReferenceNum;
-} __attribute__ ((packed)) lb_addr;
-
-typedef struct
-{
- __u32 extLength;
- __u32 extPosition;
-} __attribute__ ((packed)) short_ad;
-
-typedef struct
-{
- __u32 extLength;
- lb_addr extLocation;
- __u8 impUse[6];
-} __attribute__ ((packed)) long_ad;
-#endif
-
struct udf_inode_info
{
struct timespec i_crtime;
diff --git a/include/linux/udf_fs_sb.h b/include/linux/udf_fs_sb.h
index b15ff2e99c9..80ae9ef940d 100644
--- a/include/linux/udf_fs_sb.h
+++ b/include/linux/udf_fs_sb.h
@@ -13,7 +13,7 @@
#ifndef _UDF_FS_SB_H
#define _UDF_FS_SB_H 1
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#pragma pack(1)
@@ -111,7 +111,7 @@ struct udf_sb_info
/* VAT inode */
struct inode *s_vat;
- struct semaphore s_alloc_sem;
+ struct mutex s_alloc_mutex;
};
#endif /* _UDF_FS_SB_H */
diff --git a/include/linux/videodev2.h b/include/linux/videodev2.h
index 724cfbf54b8..2275bfec5b6 100644
--- a/include/linux/videodev2.h
+++ b/include/linux/videodev2.h
@@ -883,6 +883,7 @@ struct v4l2_modulator
#define V4L2_TUNER_MODE_LANG2 0x0002
#define V4L2_TUNER_MODE_SAP 0x0002
#define V4L2_TUNER_MODE_LANG1 0x0003
+#define V4L2_TUNER_MODE_LANG1_LANG2 0x0004
struct v4l2_frequency
{
diff --git a/include/linux/vt_kern.h b/include/linux/vt_kern.h
index fab5aed8ca3..530ae3f4248 100644
--- a/include/linux/vt_kern.h
+++ b/include/linux/vt_kern.h
@@ -73,6 +73,11 @@ int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc);
int vt_waitactive(int vt);
void change_console(struct vc_data *new_vc);
void reset_vc(struct vc_data *vc);
+#ifdef CONFIG_VT
+int is_console_suspend_safe(void);
+#else
+static inline int is_console_suspend_safe(void) { return 1; }
+#endif
/*
* vc_screen.c shares this temporary buffer with the console write code so that
diff --git a/include/linux/wireless.h b/include/linux/wireless.h
index a555a0f7a7b..13588564b42 100644
--- a/include/linux/wireless.h
+++ b/include/linux/wireless.h
@@ -1,10 +1,10 @@
/*
* This file define a set of standard wireless extensions
*
- * Version : 19 18.3.05
+ * Version : 20 17.2.06
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
*/
#ifndef _LINUX_WIRELESS_H
@@ -80,7 +80,7 @@
* (there is some stuff that will be added in the future...)
* I just plan to increment with each new version.
*/
-#define WIRELESS_EXT 19
+#define WIRELESS_EXT 20
/*
* Changes :
@@ -204,6 +204,10 @@
* - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros
* - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM
* - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros
+ *
+ * V19 to V20
+ * ----------
+ * - RtNetlink requests support (SET/GET)
*/
/**************************** CONSTANTS ****************************/
diff --git a/include/linux/writeback.h b/include/linux/writeback.h
index beaef5c7a0e..56f92fcbe94 100644
--- a/include/linux/writeback.h
+++ b/include/linux/writeback.h
@@ -88,8 +88,8 @@ void throttle_vm_writeout(void);
/* These are exported to sysctl. */
extern int dirty_background_ratio;
extern int vm_dirty_ratio;
-extern int dirty_writeback_centisecs;
-extern int dirty_expire_centisecs;
+extern int dirty_writeback_interval;
+extern int dirty_expire_interval;
extern int block_dump;
extern int laptop_mode;
@@ -99,7 +99,15 @@ int dirty_writeback_centisecs_handler(struct ctl_table *, int, struct file *,
void __user *, size_t *, loff_t *);
void page_writeback_init(void);
-void balance_dirty_pages_ratelimited(struct address_space *mapping);
+void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
+ unsigned long nr_pages_dirtied);
+
+static inline void
+balance_dirty_pages_ratelimited(struct address_space *mapping)
+{
+ balance_dirty_pages_ratelimited_nr(mapping, 1);
+}
+
int pdflush_operation(void (*fn)(unsigned long), unsigned long arg0);
int do_writepages(struct address_space *mapping, struct writeback_control *wbc);
int sync_page_range(struct inode *inode, struct address_space *mapping,
diff --git a/include/linux/zorro.h b/include/linux/zorro.h
index ba5b72768bb..2f135cf6eef 100644
--- a/include/linux/zorro.h
+++ b/include/linux/zorro.h
@@ -271,39 +271,6 @@ static inline void zorro_set_drvdata (struct zorro_dev *z, void *data)
}
-/*
- * A helper function which helps ensure correct zorro_driver
- * setup and cleanup for commonly-encountered hotplug/modular cases
- *
- * This MUST stay in a header, as it checks for -DMODULE
- */
-static inline int zorro_module_init(struct zorro_driver *drv)
-{
- int rc = zorro_register_driver(drv);
-
- if (rc > 0)
- return 0;
-
- /* iff CONFIG_HOTPLUG and built into kernel, we should
- * leave the driver around for future hotplug events.
- * For the module case, a hotplug daemon of some sort
- * should load a module in response to an insert event. */
-#if defined(CONFIG_HOTPLUG) && !defined(MODULE)
- if (rc == 0)
- return 0;
-#else
- if (rc == 0)
- rc = -ENODEV;
-#endif
-
- /* if we get here, we need to clean up Zorro driver instance
- * and return some sort of error */
- zorro_unregister_driver(drv);
-
- return rc;
-}
-
-
/*
* Bitmask indicating portions of available Zorro II RAM that are unused
* by the system. Every bit represents a 64K chunk, for a maximum of 8MB
diff --git a/include/media/audiochip.h b/include/media/audiochip.h
index 295d256ee81..1fd4a220757 100644
--- a/include/media/audiochip.h
+++ b/include/media/audiochip.h
@@ -21,18 +21,4 @@ enum audiochip {
AUDIO_CHIP_MSP34XX
};
-/* ---------------------------------------------------------------------- */
-
-/* audio inputs */
-#define AUDIO_TUNER 0x00
-#define AUDIO_RADIO 0x01
-#define AUDIO_EXTERN 0x02
-#define AUDIO_INTERN 0x03
-#define AUDIO_OFF 0x04
-#define AUDIO_ON 0x05
-#define AUDIO_EXTERN_1 AUDIO_EXTERN
-#define AUDIO_EXTERN_2 0x06
-#define AUDIO_MUTE 0x80
-#define AUDIO_UNMUTE 0x81
-
#endif /* AUDIOCHIP_H */
diff --git a/include/media/cs53l32a.h b/include/media/cs53l32a.h
new file mode 100644
index 00000000000..bf76197d379
--- /dev/null
+++ b/include/media/cs53l32a.h
@@ -0,0 +1,34 @@
+/*
+ cs53l32a.h - definition for cs53l32a inputs and outputs
+
+ Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _CS53L32A_H_
+#define _CS53L32A_H_
+
+/* There are 2 physical inputs, but the second input can be
+ placed in two modes, the first mode bypasses the PGA (gain),
+ the second goes through the PGA. Hence there are three
+ possible inputs to choose from. */
+
+/* CS53L32A HW inputs */
+#define CS53L32A_IN0 0
+#define CS53L32A_IN1 1
+#define CS53L32A_IN2 2
+
+#endif
diff --git a/include/media/i2c-addr.h b/include/media/i2c-addr.h
new file mode 100644
index 00000000000..e7ff44a35ca
--- /dev/null
+++ b/include/media/i2c-addr.h
@@ -0,0 +1,44 @@
+/*
+ * V4L I2C address list
+ *
+ *
+ * Copyright (C) 2006 Mauro Carvalho Chehab <mchehab@infradead.org>
+ * Based on a previous mapping by
+ * Ralph Metzler (rjkm@thp.uni-koeln.de)
+ * Gerd Knorr <kraxel@goldbach.in-berlin.de>
+ *
+ */
+
+/* bttv address list */
+#define I2C_ADDR_TSA5522 0xc2
+#define I2C_ADDR_TDA7432 0x8a
+#define I2C_ADDR_BT832_ALT1 0x88
+#define I2C_ADDR_BT832_ALT2 0x8a // alternate setting
+#define I2C_ADDR_TDA8425 0x82
+#define I2C_ADDR_TDA9840 0x84
+#define I2C_ADDR_TDA9850 0xb6 /* also used by 9855,9873 */
+#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
+#define I2C_ADDR_TDA9875 0xb0
+#define I2C_ADDR_HAUPEE 0xa0
+#define I2C_ADDR_STBEE 0xae
+#define I2C_ADDR_VHX 0xc0
+#define I2C_ADDR_MSP3400 0x80
+#define I2C_ADDR_MSP3400_ALT 0x88
+#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
+#define I2C_ADDR_DPL3518 0x84
+#define I2C_ADDR_TDA9887 0x86
+
+/*
+ * i2c bus addresses for the chips supported by tvaudio.c
+ */
+
+#define I2C_ADDR_TDA8425 0x82
+#define I2C_ADDR_TDA9840 0x84 /* also used by TA8874Z */
+#define I2C_ADDR_TDA985x_L 0xb4 /* also used by 9873 */
+#define I2C_ADDR_TDA985x_H 0xb6
+#define I2C_ADDR_TDA9874 0xb0 /* also used by 9875 */
+
+#define I2C_ADDR_TEA6300 0x80 /* also used by 6320 */
+#define I2C_ADDR_TEA6420 0x98
+
+#define I2C_ADDR_PIC16C54 0x96 /* PV951 */
diff --git a/include/media/msp3400.h b/include/media/msp3400.h
new file mode 100644
index 00000000000..0be61a021d4
--- /dev/null
+++ b/include/media/msp3400.h
@@ -0,0 +1,226 @@
+/*
+ msp3400.h - definition for msp3400 inputs and outputs
+
+ Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _MSP3400_H_
+#define _MSP3400_H_
+
+/* msp3400 routing
+ ===============
+
+ The msp3400 has a complicated routing scheme with many possible
+ combinations. The details are all in the datasheets but I will try
+ to give a short description here.
+
+ Inputs
+ ======
+
+ There are 1) tuner inputs, 2) I2S inputs, 3) SCART inputs. You will have
+ to select which tuner input to use and which SCART input to use. The
+ selected tuner input, the selected SCART input and all I2S inputs go to
+ the DSP (the tuner input first goes through the demodulator).
+
+ The DSP handles things like volume, bass/treble, balance, and some chips
+ have support for surround sound. It has several outputs: MAIN, AUX, I2S
+ and SCART1/2. Each output can select which DSP input to use. So the MAIN
+ output can select the tuner input while at the same time the SCART1 output
+ uses the I2S input.
+
+ Outputs
+ =======
+
+ Most DSP outputs are also the outputs of the msp3400. However, the SCART
+ outputs of the msp3400 can select which input to use: either the SCART1 or
+ SCART2 output from the DSP, or the msp3400 SCART inputs, thus completely
+ bypassing the DSP.
+
+ Summary
+ =======
+
+ So to specify a complete routing scheme for the msp3400 you will have to
+ specify in the 'input' field of the v4l2_routing struct:
+
+ 1) which tuner input to use
+ 2) which SCART input to use
+ 3) which DSP input to use for each DSP output
+
+ And in the 'output' field of the v4l2_routing struct you specify:
+
+ 1) which SCART input to use for each SCART output
+
+ Depending on how the msp is wired to the other components you can
+ ignore or mute certain inputs or outputs.
+
+ Also, depending on the msp version only a subset of the inputs or
+ outputs may be present. At the end of this header some tables are
+ added containing a list of what is available for each msp version.
+ */
+
+/* Inputs to the DSP unit: two independent selections have to be made:
+ 1) the tuner (SIF) input
+ 2) the SCART input
+ Bits 0-2 are used for the SCART input select, bit 3 is used for the tuner
+ input, bits 4-7 are reserved.
+ */
+
+/* SCART input to DSP selection */
+#define MSP_IN_SCART_1 0 /* Pin SC1_IN */
+#define MSP_IN_SCART_2 1 /* Pin SC2_IN */
+#define MSP_IN_SCART_3 2 /* Pin SC3_IN */
+#define MSP_IN_SCART_4 3 /* Pin SC4_IN */
+#define MSP_IN_MONO 6 /* Pin MONO_IN */
+#define MSP_IN_MUTE 7 /* Mute DSP input */
+#define MSP_SCART_TO_DSP(in) (in)
+/* Tuner input to demodulator and DSP selection */
+#define MSP_IN_TUNER_1 0 /* Analog Sound IF input pin ANA_IN1 */
+#define MSP_IN_TUNER_2 1 /* Analog Sound IF input pin ANA_IN2 */
+#define MSP_TUNER_TO_DSP(in) ((in) << 3)
+
+/* The msp has up to 5 DSP outputs, each output can independently select
+ a DSP input.
+
+ The DSP outputs are: loudspeaker output (aka MAIN), headphones output
+ (aka AUX), SCART1 DA output, SCART2 DA output and an I2S output.
+ There also is a quasi-peak detector output, but that is not used by
+ this driver and is set to the same input as the loudspeaker output.
+ Not all outputs are supported by all msp models. Setting the input
+ of an unsupported output will be ignored by the driver.
+
+ There are up to 16 DSP inputs to choose from, so each output is
+ assigned 4 bits.
+
+ Note: the 44x8G can mix two inputs and feed the result back to the
+ DSP. This is currently not implemented. Also not implemented is the
+ multi-channel capable I2S3 input of the 44x0G. If someone can demonstrate
+ a need for one of those features then additional support can be added. */
+#define MSP_DSP_OUT_TUNER 0 /* Tuner output */
+#define MSP_DSP_OUT_SCART 2 /* SCART output */
+#define MSP_DSP_OUT_I2S1 5 /* I2S1 output */
+#define MSP_DSP_OUT_I2S2 6 /* I2S2 output */
+#define MSP_DSP_OUT_I2S3 7 /* I2S3 output */
+#define MSP_DSP_OUT_MAIN_AVC 11 /* MAIN AVC processed output */
+#define MSP_DSP_OUT_MAIN 12 /* MAIN output */
+#define MSP_DSP_OUT_AUX 13 /* AUX output */
+#define MSP_DSP_TO_MAIN(in) ((in) << 4)
+#define MSP_DSP_TO_AUX(in) ((in) << 8)
+#define MSP_DSP_TO_SCART1(in) ((in) << 12)
+#define MSP_DSP_TO_SCART2(in) ((in) << 16)
+#define MSP_DSP_TO_I2S(in) ((in) << 20)
+
+/* Output SCART select: the SCART outputs can select which input
+ to use. */
+#define MSP_OUT_SCART1 0 /* SCART1 input, bypassing the DSP */
+#define MSP_OUT_SCART2 1 /* SCART2 input, bypassing the DSP */
+#define MSP_OUT_SCART3 2 /* SCART3 input, bypassing the DSP */
+#define MSP_OUT_SCART4 3 /* SCART4 input, bypassing the DSP */
+#define MSP_OUT_SCART1_DA 4 /* DSP SCART1 output */
+#define MSP_OUT_SCART2_DA 5 /* DSP SCART2 output */
+#define MSP_OUT_MONO 6 /* MONO input, bypassing the DSP */
+#define MSP_OUT_MUTE 7 /* MUTE output */
+#define MSP_OUT_TO_SCART1(in) (in)
+#define MSP_OUT_TO_SCART2(in) ((in) << 4)
+
+/* Shortcut macros */
+#define MSP_INPUT(sc, t, main_aux_src, sc_i2s_src) \
+ (MSP_SCART_TO_DSP(sc) | \
+ MSP_TUNER_TO_DSP(t) | \
+ MSP_DSP_TO_MAIN(main_aux_src) | \
+ MSP_DSP_TO_AUX(main_aux_src) | \
+ MSP_DSP_TO_SCART1(sc_i2s_src) | \
+ MSP_DSP_TO_SCART2(sc_i2s_src) | \
+ MSP_DSP_TO_I2S(sc_i2s_src))
+#define MSP_INPUT_DEFAULT MSP_INPUT(MSP_IN_SCART_1, MSP_IN_TUNER_1, \
+ MSP_DSP_OUT_TUNER, MSP_DSP_OUT_TUNER)
+#define MSP_OUTPUT(sc) \
+ (MSP_OUT_TO_SCART1(sc) | \
+ MSP_OUT_TO_SCART2(sc))
+/* This equals the RESET position of the msp3400 ACB register */
+#define MSP_OUTPUT_DEFAULT (MSP_OUT_TO_SCART1(MSP_OUT_SCART3) | \
+ MSP_OUT_TO_SCART2(MSP_OUT_SCART1_DA))
+
+/* Tuner inputs vs. msp version */
+/* Chip TUNER_1 TUNER_2
+ -------------------------
+ msp34x0b y y
+ msp34x0c y y
+ msp34x0d y y
+ msp34x5d y n
+ msp34x7d y n
+ msp34x0g y y
+ msp34x1g y y
+ msp34x2g y y
+ msp34x5g y n
+ msp34x7g y n
+ msp44x0g y y
+ msp44x8g y y
+ */
+
+/* SCART inputs vs. msp version */
+/* Chip SC1 SC2 SC3 SC4
+ -------------------------
+ msp34x0b y y y n
+ msp34x0c y y y n
+ msp34x0d y y y y
+ msp34x5d y y n n
+ msp34x7d y n n n
+ msp34x0g y y y y
+ msp34x1g y y y y
+ msp34x2g y y y y
+ msp34x5g y y n n
+ msp34x7g y n n n
+ msp44x0g y y y y
+ msp44x8g y y y y
+ */
+
+/* DSP inputs vs. msp version (tuner and SCART inputs are always available) */
+/* Chip I2S1 I2S2 I2S3 MAIN_AVC MAIN AUX
+ ------------------------------------------
+ msp34x0b y n n n n n
+ msp34x0c y y n n n n
+ msp34x0d y y n n n n
+ msp34x5d y y n n n n
+ msp34x7d n n n n n n
+ msp34x0g y y n n n n
+ msp34x1g y y n n n n
+ msp34x2g y y n y y y
+ msp34x5g y y n n n n
+ msp34x7g n n n n n n
+ msp44x0g y y y y y y
+ msp44x8g y y y n n n
+ */
+
+/* DSP outputs vs. msp version */
+/* Chip MAIN AUX SCART1 SCART2 I2S
+ ------------------------------------
+ msp34x0b y y y n y
+ msp34x0c y y y n y
+ msp34x0d y y y y y
+ msp34x5d y n y n y
+ msp34x7d y n y n n
+ msp34x0g y y y y y
+ msp34x1g y y y y y
+ msp34x2g y y y y y
+ msp34x5g y n y n y
+ msp34x7g y n y n n
+ msp44x0g y y y y y
+ msp44x8g y y y y y
+ */
+
+#endif /* MSP3400_H */
+
diff --git a/drivers/media/video/rds.h b/include/media/rds.h
index 0d30eb744e6..951c1ae0be7 100644
--- a/drivers/media/video/rds.h
+++ b/include/media/rds.h
@@ -42,7 +42,3 @@ struct rds_command {
#define RDS_CMD_POLL _IOR('R',4,int)
#endif
-
-
-
-
diff --git a/include/media/saa7146_vv.h b/include/media/saa7146_vv.h
index e5e749e984e..4507cb61ae9 100644
--- a/include/media/saa7146_vv.h
+++ b/include/media/saa7146_vv.h
@@ -197,7 +197,8 @@ void saa7146_buffer_finish(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,
void saa7146_buffer_next(struct saa7146_dev *dev, struct saa7146_dmaqueue *q,int vbi);
int saa7146_buffer_queue(struct saa7146_dev *dev, struct saa7146_dmaqueue *q, struct saa7146_buf *buf);
void saa7146_buffer_timeout(unsigned long data);
-void saa7146_dma_free(struct saa7146_dev *dev,struct saa7146_buf *buf);
+void saa7146_dma_free(struct saa7146_dev* dev,struct videobuf_queue *q,
+ struct saa7146_buf *buf);
int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv);
int saa7146_vv_release(struct saa7146_dev* dev);
diff --git a/include/media/tvaudio.h b/include/media/tvaudio.h
new file mode 100644
index 00000000000..6915aafc875
--- /dev/null
+++ b/include/media/tvaudio.h
@@ -0,0 +1,30 @@
+/*
+ tvaudio.h - definition for tvaudio inputs
+
+ Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _TVAUDIO_H
+#define _TVAUDIO_H
+
+/* The tvaudio module accepts the following inputs: */
+#define TVAUDIO_INPUT_TUNER 0
+#define TVAUDIO_INPUT_RADIO 1
+#define TVAUDIO_INPUT_EXTERN 2
+#define TVAUDIO_INPUT_INTERN 3
+
+#endif
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 2360453e749..642520acdfa 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -123,17 +123,6 @@ enum v4l2_chip_ident {
/* v4l device was opened in Radio mode, to be replaced by VIDIOC_INT_S_TUNER_MODE */
#define AUDC_SET_RADIO _IO('d',88)
-/* select from TV,radio,extern,MUTE, to be replaced with VIDIOC_INT_S_AUDIO_ROUTING */
-#define AUDC_SET_INPUT _IOW('d',89,int)
-
-/* msp3400 ioctl: will be removed in the near future, to be replaced by
- VIDIOC_INT_S_AUDIO_ROUTING. */
-struct msp_matrix {
- int input;
- int output;
-};
-#define MSP_SET_MATRIX _IOW('m',17,struct msp_matrix)
-
/* tuner ioctls */
/* Sets tuner type and its I2C addr */
@@ -209,10 +198,10 @@ struct v4l2_routing {
};
/* These internal commands should be used to define the inputs and outputs
- of an audio/video chip. They will replace AUDC_SET_INPUT.
- The v4l2 API commands VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT,
- VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT are meant to be used by the
- user. Internally these commands should be used to switch inputs/outputs
+ of an audio/video chip. They will replace the v4l2 API commands
+ VIDIOC_S/G_INPUT, VIDIOC_S/G_OUTPUT, VIDIOC_S/G_AUDIO and VIDIOC_S/G_AUDOUT
+ that are meant to be used by the user.
+ The internal commands should be used to switch inputs/outputs
because only the driver knows how to map a 'Television' input to the precise
input/output routing of an A/D converter, or a DSP, or a video digitizer.
These four commands should only be sent directly to an i2c device, they
diff --git a/include/media/video-buf.h b/include/media/video-buf.h
index d90dec5484e..fff3fd0fbf9 100644
--- a/include/media/video-buf.h
+++ b/include/media/video-buf.h
@@ -1,15 +1,20 @@
/*
*
* generic helper functions for video4linux capture buffers, to handle
- * memory management and PCI DMA. Right now bttv + saa7134 use it.
+ * memory management and PCI DMA.
+ * Right now, bttv, saa7134, saa7146 and cx88 use it.
*
* The functions expect the hardware being able to scatter gatter
* (i.e. the buffers are not linear in physical memory, but fragmented
* into PAGE_SIZE chunks). They also assume the driver does not need
- * to touch the video data (thus it is probably not useful for USB as
- * data often must be uncompressed by the drivers).
+ * to touch the video data.
+ *
+ * device specific map/unmap/sync stuff now are mapped as file operations
+ * to allow its usage by USB and virtual devices.
*
* (c) 2001,02 Gerd Knorr <kraxel@bytesex.org>
+ * (c) 2006 Mauro Carvalho Chehab, <mchehab@infradead.org>
+ * (c) 2006 Ted Walther and John Sokol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,6 +43,9 @@ struct scatterlist* videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages);
struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
int offset);
+struct videobuf_buffer;
+struct videobuf_queue;
+
/* --------------------------------------------------------------------- */
/*
@@ -49,7 +57,7 @@ struct scatterlist* videobuf_pages_to_sg(struct page **pages, int nr_pages,
* pointer + length. The kernel version just wants the size and
* does memory allocation too using vmalloc_32().
*
- * videobuf_dma_pci_*()
+ * videobuf_dma_*()
* see Documentation/DMA-mapping.txt, these functions to
* basically the same. The map function does also build a
* scatterlist for the buffer (and unmap frees it ...)
@@ -86,12 +94,18 @@ int videobuf_dma_init_kernel(struct videobuf_dmabuf *dma, int direction,
int nr_pages);
int videobuf_dma_init_overlay(struct videobuf_dmabuf *dma, int direction,
dma_addr_t addr, int nr_pages);
-int videobuf_dma_pci_map(struct pci_dev *dev, struct videobuf_dmabuf *dma);
-int videobuf_dma_pci_sync(struct pci_dev *dev,
- struct videobuf_dmabuf *dma);
-int videobuf_dma_pci_unmap(struct pci_dev *dev, struct videobuf_dmabuf *dma);
int videobuf_dma_free(struct videobuf_dmabuf *dma);
+int videobuf_dma_map(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+int videobuf_dma_sync(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+int videobuf_dma_unmap(struct videobuf_queue* q,struct videobuf_dmabuf *dma);
+
+ /*FIXME: these variants are used only on *-alsa code, where videobuf is
+ * used without queue
+ */
+int videobuf_pci_dma_map(struct pci_dev *pci,struct videobuf_dmabuf *dma);
+int videobuf_pci_dma_unmap(struct pci_dev *pci,struct videobuf_dmabuf *dma);
+
/* --------------------------------------------------------------------- */
/*
@@ -115,9 +129,6 @@ int videobuf_dma_free(struct videobuf_dmabuf *dma);
*
*/
-struct videobuf_buffer;
-struct videobuf_queue;
-
struct videobuf_mapping {
unsigned int count;
unsigned long start;
@@ -164,6 +175,10 @@ struct videobuf_buffer {
struct timeval ts;
};
+typedef int (vb_map_sg_t)(void *dev,struct scatterlist *sglist,int nr_pages,
+ int direction);
+
+
struct videobuf_queue_ops {
int (*buf_setup)(struct videobuf_queue *q,
unsigned int *count, unsigned int *size);
@@ -174,12 +189,20 @@ struct videobuf_queue_ops {
struct videobuf_buffer *vb);
void (*buf_release)(struct videobuf_queue *q,
struct videobuf_buffer *vb);
+
+ /* Helper operations - device dependent.
+ * If null, videobuf_init defaults all to PCI handling
+ */
+
+ vb_map_sg_t *vb_map_sg;
+ vb_map_sg_t *vb_dma_sync_sg;
+ vb_map_sg_t *vb_unmap_sg;
};
struct videobuf_queue {
struct mutex lock;
spinlock_t *irqlock;
- struct pci_dev *pci;
+ void *dev; /* on pci, points to struct pci_dev */
enum v4l2_buf_type type;
unsigned int inputs; /* for V4L2_BUF_FLAG_INPUT */
@@ -204,12 +227,15 @@ struct videobuf_queue {
void* videobuf_alloc(unsigned int size);
int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr);
-int videobuf_iolock(struct pci_dev *pci, struct videobuf_buffer *vb,
- struct v4l2_framebuffer *fbuf);
+int videobuf_iolock(struct videobuf_queue* q, struct videobuf_buffer *vb,
+ struct v4l2_framebuffer *fbuf);
+
+/* Maps fops to PCI stuff */
+void videobuf_queue_pci(struct videobuf_queue* q);
void videobuf_queue_init(struct videobuf_queue *q,
struct videobuf_queue_ops *ops,
- struct pci_dev *pci,
+ void *dev,
spinlock_t *irqlock,
enum v4l2_buf_type type,
enum v4l2_field field,
diff --git a/include/media/wm8775.h b/include/media/wm8775.h
new file mode 100644
index 00000000000..60739c5a23a
--- /dev/null
+++ b/include/media/wm8775.h
@@ -0,0 +1,35 @@
+/*
+ wm8775.h - definition for wm8775 inputs and outputs
+
+ Copyright (C) 2006 Hans Verkuil (hverkuil@xs4all.nl)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _WM8775_H_
+#define _WM8775_H_
+
+/* The WM8775 has 4 inputs and one output. Zero or more inputs
+ are multiplexed together to the output. Hence there are
+ 16 combinations.
+ If only one input is active (the normal case) then the
+ input values 1, 2, 4 or 8 should be used. */
+
+#define WM8775_AIN1 1
+#define WM8775_AIN2 2
+#define WM8775_AIN3 4
+#define WM8775_AIN4 8
+
+#endif
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
new file mode 100644
index 00000000000..b971d8c82bd
--- /dev/null
+++ b/include/net/ieee80211softmac.h
@@ -0,0 +1,292 @@
+/*
+ * ieee80211softmac.h - public interface to the softmac
+ *
+ * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#ifndef IEEE80211SOFTMAC_H_
+#define IEEE80211SOFTMAC_H_
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <linux/workqueue.h>
+#include <linux/list.h>
+#include <net/ieee80211.h>
+
+/* Once the API is considered more or less stable,
+ * this should be incremented on API incompatible changes.
+ */
+#define IEEE80211SOFTMAC_API 0
+
+#define IEEE80211SOFTMAC_MAX_RATES_LEN 8
+#define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255
+
+struct ieee80211softmac_ratesinfo {
+ u8 count;
+ u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN];
+};
+
+/* internal structures */
+struct ieee80211softmac_network;
+struct ieee80211softmac_scaninfo;
+
+struct ieee80211softmac_essid {
+ u8 len;
+ char data[IW_ESSID_MAX_SIZE+1];
+};
+
+struct ieee80211softmac_wpa {
+ char *IE;
+ int IElen;
+ int IEbuflen;
+};
+
+/*
+ * Information about association
+ *
+ * Do we need a lock for this?
+ * We only ever use this structure inlined
+ * into our global struct. I've used its lock,
+ * but maybe we need a local one here?
+ */
+struct ieee80211softmac_assoc_info {
+ /*
+ * This is the requested ESSID. It is written
+ * only by the WX handlers.
+ *
+ */
+ struct ieee80211softmac_essid req_essid;
+ /*
+ * the ESSID of the network we're currently
+ * associated (or trying) to. This is
+ * updated to the network's actual ESSID
+ * even if the requested ESSID was 'ANY'
+ */
+ struct ieee80211softmac_essid associate_essid;
+
+ /* BSSID we're trying to associate to */
+ char bssid[ETH_ALEN];
+
+ /* some flags.
+ * static_essid is valid if the essid is constant,
+ * this is for use by the wx handlers only.
+ *
+ * associating is true, if the network has been
+ * auth'ed on and we are in the process of associating.
+ *
+ * bssvalid is true if we found a matching network
+ * and saved it's BSSID into the bssid above.
+ */
+ u8 static_essid:1,
+ associating:1,
+ bssvalid:1;
+
+ /* Scan retries remaining */
+ int scan_retry;
+
+ struct work_struct work;
+ struct work_struct timeout;
+};
+
+enum {
+ IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1,
+ IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2,
+};
+
+enum {
+ IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1,
+ IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2,
+ IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3,
+ IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4,
+};
+
+/* We should make these tunable
+ * AUTH_TIMEOUT seems really long, but that's what it is in BSD */
+#define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ)
+#define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5
+#define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3
+
+struct ieee80211softmac_txrates {
+ /* The Bit-Rate to be used for multicast frames. */
+ u8 mcast_rate;
+ /* The Bit-Rate to be used for multicast fallback
+ * (If the device supports fallback and hardware-retry)
+ */
+ u8 mcast_fallback;
+ /* The Bit-Rate to be used for any other (normal) data packet. */
+ u8 default_rate;
+ /* The Bit-Rate to be used for default fallback
+ * (If the device supports fallback and hardware-retry)
+ */
+ u8 default_fallback;
+};
+
+/* Bits for txrates_change callback. */
+#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */
+#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */
+#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */
+#define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /* mcast_fallback */
+
+struct ieee80211softmac_device {
+ /* 802.11 structure for data stuff */
+ struct ieee80211_device *ieee;
+ struct net_device *dev;
+
+ /* only valid if associated, then holds the Association ID */
+ u16 association_id;
+
+ /* the following methods are callbacks that the driver
+ * using this framework has to assign
+ */
+
+ /* always assign these */
+ void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid);
+ void (*set_channel)(struct net_device *dev, u8 channel);
+
+ /* assign if you need it, informational only */
+ void (*link_change)(struct net_device *dev);
+
+ /* If the hardware can do scanning, assign _all_ three of these callbacks.
+ * When the scan finishes, call ieee80211softmac_scan_finished().
+ */
+
+ /* when called, start_scan is guaranteed to not be called again
+ * until you call ieee80211softmac_scan_finished.
+ * Return 0 if scanning could start, error otherwise.
+ * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */
+ int (*start_scan)(struct net_device *dev);
+ /* this should block until after ieee80211softmac_scan_finished was called
+ * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */
+ void (*wait_for_scan)(struct net_device *dev);
+ /* stop_scan aborts a scan, but is asynchronous.
+ * if you want to wait for it too, use wait_for_scan
+ * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */
+ void (*stop_scan)(struct net_device *dev);
+
+ /* we'll need something about beacons here too, for AP or ad-hoc modes */
+
+ /* Transmission rates to be used by the driver.
+ * The SoftMAC figures out the best possible rates.
+ * The driver just needs to read them.
+ */
+ struct ieee80211softmac_txrates txrates;
+ /* If the driver needs to do stuff on TX rate changes, assign this callback. */
+ void (*txrates_change)(struct net_device *dev,
+ u32 changes, /* see IEEE80211SOFTMAC_TXRATECHG flags */
+ const struct ieee80211softmac_txrates *rates_before_change);
+
+ /* private stuff follows */
+ /* this lock protects this structure */
+ spinlock_t lock;
+
+ /* couple of flags */
+ u8 scanning:1, /* protects scanning from being done multiple times at once */
+ associated:1;
+
+ struct ieee80211softmac_scaninfo *scaninfo;
+ struct ieee80211softmac_assoc_info associnfo;
+
+ struct list_head auth_queue;
+ struct list_head events;
+
+ struct ieee80211softmac_ratesinfo ratesinfo;
+ int txrate_badness;
+
+ /* WPA stuff */
+ struct ieee80211softmac_wpa wpa;
+
+ /* we need to keep a list of network structs we copied */
+ struct list_head network_list;
+
+ /* This must be the last item so that it points to the data
+ * allocated beyond this structure by alloc_ieee80211 */
+ u8 priv[0];
+};
+
+extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm);
+
+static inline void * ieee80211softmac_priv(struct net_device *dev)
+{
+ return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv;
+}
+
+extern struct net_device * alloc_ieee80211softmac(int sizeof_priv);
+extern void free_ieee80211softmac(struct net_device *dev);
+
+/* Call this function if you detect a lost TX fragment.
+ * (If the device indicates failure of ACK RX, for example.)
+ * It is wise to call this function if you are able to detect lost packets,
+ * because it contributes to the TX Rates auto adjustment.
+ */
+extern void ieee80211softmac_fragment_lost(struct net_device *dev,
+ u16 wireless_sequence_number);
+/* Call this function before _start to tell the softmac what rates
+ * the hw supports. The rates parameter is copied, so you can
+ * free it right after calling this function.
+ * Note that the rates need to be sorted. */
+extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates);
+
+/* Start the SoftMAC. Call this after you initialized the device
+ * and it is ready to run.
+ */
+extern void ieee80211softmac_start(struct net_device *dev);
+/* Stop the SoftMAC. Call this before you shutdown the device. */
+extern void ieee80211softmac_stop(struct net_device *dev);
+
+/*
+ * Event system
+ */
+
+/* valid event types */
+#define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/
+#define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0
+#define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1
+#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2
+#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3
+#define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4
+#define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5
+#define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6
+#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7
+/* keep this updated! */
+#define IEEE80211SOFTMAC_EVENT_LAST 7
+/*
+ * If you want to be notified of certain events, you can call
+ * ieee80211softmac_notify[_atomic] with
+ * - event set to one of the constants below
+ * - fun set to a function pointer of the appropriate type
+ * - context set to the context data you want passed
+ * The return value is 0, or an error.
+ */
+typedef void (*notify_function_ptr)(struct net_device *dev, void *context);
+
+#define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
+#define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
+
+extern int ieee80211softmac_notify_gfp(struct net_device *dev,
+ int event, notify_function_ptr fun, void *context, gfp_t gfp_mask);
+
+/* To clear pending work (for ifconfig down, etc.) */
+extern void
+ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm);
+
+#endif /* IEEE80211SOFTMAC_H_ */
diff --git a/include/net/ieee80211softmac_wx.h b/include/net/ieee80211softmac_wx.h
new file mode 100644
index 00000000000..3e0be453ece
--- /dev/null
+++ b/include/net/ieee80211softmac_wx.h
@@ -0,0 +1,94 @@
+/*
+ * This file contains the prototypes for the wireless extension
+ * handlers that the softmac API provides. Include this file to
+ * use the wx handlers, you can assign these directly.
+ *
+ * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#ifndef _IEEE80211SOFTMAC_WX_H
+#define _IEEE80211SOFTMAC_WX_H
+
+#include <net/ieee80211softmac.h>
+#include <net/iw_handler.h>
+
+extern int
+ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_set_essid(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_get_essid(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_set_rate(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_get_rate(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_get_wap(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_set_wap(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_set_genie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra);
+
+extern int
+ieee80211softmac_wx_get_genie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra);
+#endif /* _IEEE80211SOFTMAC_WX */
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h
index a2c5e0b8842..10559e937d2 100644
--- a/include/net/iw_handler.h
+++ b/include/net/iw_handler.h
@@ -4,7 +4,7 @@
* Version : 7 18.3.05
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 2001-2005 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 2001-2006 Jean Tourrilhes, All Rights Reserved.
*/
#ifndef _IW_HANDLER_H
@@ -436,6 +436,16 @@ extern int dev_get_wireless_info(char * buffer, char **start, off_t offset,
/* Handle IOCTLs, called in net/core/dev.c */
extern int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd);
+/* Handle RtNetlink requests, called in net/core/rtnetlink.c */
+extern int wireless_rtnetlink_set(struct net_device * dev,
+ char * data,
+ int len);
+extern int wireless_rtnetlink_get(struct net_device * dev,
+ char * data,
+ int len,
+ char ** p_buf,
+ int * p_len);
+
/* Second : functions that may be called by driver modules */
/* Send a single event to user space */
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 2743c156caa..b6f0905a4ee 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -195,6 +195,10 @@ static inline void nf_ct_put(struct nf_conn *ct)
nf_conntrack_put(&ct->ct_general);
}
+/* Protocol module loading */
+extern int nf_ct_l3proto_try_module_get(unsigned short l3proto);
+extern void nf_ct_l3proto_module_put(unsigned short l3proto);
+
extern struct nf_conntrack_tuple_hash *
__nf_conntrack_find(const struct nf_conntrack_tuple *tuple,
const struct nf_conn *ignored_conntrack);
diff --git a/include/net/route.h b/include/net/route.h
index 9c04f15090d..98c915abdec 100644
--- a/include/net/route.h
+++ b/include/net/route.h
@@ -110,7 +110,7 @@ extern struct ip_rt_acct *ip_rt_acct;
struct in_device;
extern int ip_rt_init(void);
extern void ip_rt_redirect(u32 old_gw, u32 dst, u32 new_gw,
- u32 src, u8 tos, struct net_device *dev);
+ u32 src, struct net_device *dev);
extern void ip_rt_advice(struct rtable **rp, int advice);
extern void rt_cache_flush(int how);
extern int __ip_route_output_key(struct rtable **, const struct flowi *flp);
diff --git a/include/net/sock.h b/include/net/sock.h
index ec226f31dc2..2aa73c0ec6c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -210,6 +210,7 @@ struct sock {
gfp_t sk_allocation;
int sk_sndbuf;
int sk_route_caps;
+ int sk_rcvlowat;
unsigned long sk_flags;
unsigned long sk_lingertime;
/*
@@ -230,7 +231,6 @@ struct sock {
unsigned short sk_max_ack_backlog;
__u32 sk_priority;
struct ucred sk_peercred;
- int sk_rcvlowat;
long sk_rcvtimeo;
long sk_sndtimeo;
struct sk_filter *sk_filter;
diff --git a/include/net/tc_act/tc_ipt.h b/include/net/tc_act/tc_ipt.h
index 02eccebd55a..cb37ad08427 100644
--- a/include/net/tc_act/tc_ipt.h
+++ b/include/net/tc_act/tc_ipt.h
@@ -3,14 +3,14 @@
#include <net/act_api.h>
-struct ipt_entry_target;
+struct xt_entry_target;
struct tcf_ipt
{
tca_gen(ipt);
u32 hook;
char *tname;
- struct ipt_entry_target *t;
+ struct xt_entry_target *t;
};
#endif
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index a6cf3e535c0..dc6862d09e5 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -286,7 +286,7 @@ struct scsi_host_template {
* suspend support
*/
int (*resume)(struct scsi_device *);
- int (*suspend)(struct scsi_device *);
+ int (*suspend)(struct scsi_device *, pm_message_t state);
/*
* Name of proc directory
diff --git a/include/sound/opl3.h b/include/sound/opl3.h
index 444907166f9..82fdb093072 100644
--- a/include/sound/opl3.h
+++ b/include/sound/opl3.h
@@ -230,7 +230,6 @@
#define OPL3_HW_OPL3_CS 0x0302 /* CS4232/CS4236+ */
#define OPL3_HW_OPL3_FM801 0x0303 /* FM801 */
#define OPL3_HW_OPL3_CS4281 0x0304 /* CS4281 */
-#define OPL3_HW_OPL3_PC98 0x0305 /* PC9800 */
#define OPL3_HW_OPL4 0x0400 /* YMF278B/YMF295 */
#define OPL3_HW_OPL4_ML 0x0401 /* YMF704/YMF721 */
#define OPL3_HW_MASK 0xff00
diff --git a/include/video/pm3fb.h b/include/video/pm3fb.h
index 6f4ea808cf7..ac021379ac4 100644
--- a/include/video/pm3fb.h
+++ b/include/video/pm3fb.h
@@ -1128,10 +1128,7 @@
#endif
/* max number of simultaneous board */
-/* warning : make sure module array def's are coherent with PM3_MAX_BOARD */
#define PM3_MAX_BOARD 4
-#define PM3_MAX_BOARD_MODULE_ARRAY_SHORT "1-4h"
-#define PM3_MAX_BOARD_MODULE_ARRAY_STRING "1-4s"
/* max size of options */
#define PM3_OPTIONS_SIZE 256
diff --git a/init/Kconfig b/init/Kconfig
index 38416a199de..3b36a1d5365 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -214,6 +214,17 @@ config CPUSETS
Say N if unsure.
+config RELAY
+ bool "Kernel->user space relay support (formerly relayfs)"
+ help
+ This option enables support for relay interface support in
+ certain file systems (such as debugfs).
+ It is designed to provide an efficient mechanism for tools and
+ facilities to relay large amounts of data from kernel space to
+ user space.
+
+ If unsure, say N.
+
source "usr/Kconfig"
config UID16
@@ -354,43 +365,6 @@ config SHMEM
option replaces shmem and tmpfs with the much simpler ramfs code,
which may be appropriate on small systems without swap.
-config CC_ALIGN_FUNCTIONS
- int "Function alignment" if EMBEDDED
- default 0
- help
- Align the start of functions to the next power-of-two greater than n,
- skipping up to n bytes. For instance, 32 aligns functions
- to the next 32-byte boundary, but 24 would align to the next
- 32-byte boundary only if this can be done by skipping 23 bytes or less.
- Zero means use compiler's default.
-
-config CC_ALIGN_LABELS
- int "Label alignment" if EMBEDDED
- default 0
- help
- Align all branch targets to a power-of-two boundary, skipping
- up to n bytes like ALIGN_FUNCTIONS. This option can easily
- make code slower, because it must insert dummy operations for
- when the branch target is reached in the usual flow of the code.
- Zero means use compiler's default.
-
-config CC_ALIGN_LOOPS
- int "Loop alignment" if EMBEDDED
- default 0
- help
- Align loops to a power-of-two boundary, skipping up to n bytes.
- Zero means use compiler's default.
-
-config CC_ALIGN_JUMPS
- int "Jump alignment" if EMBEDDED
- default 0
- help
- Align branch targets to a power-of-two boundary, for branch
- targets where the targets can only be reached by jumping,
- skipping up to n bytes like ALIGN_FUNCTIONS. In this case,
- no dummy operations need be executed.
- Zero means use compiler's default.
-
config SLAB
default y
bool "Use full SLAB allocator" if EMBEDDED
@@ -459,15 +433,6 @@ config MODULE_FORCE_UNLOAD
rmmod). This is mainly for kernel developers and desperate users.
If unsure, say N.
-config OBSOLETE_MODPARM
- bool
- default y
- depends on MODULES
- help
- You need this option to use module parameters on modules which
- have not been converted to the new module parameter system yet.
- If unsure, say Y.
-
config MODVERSIONS
bool "Module versioning support"
depends on MODULES
diff --git a/init/do_mounts.c b/init/do_mounts.c
index b27c1106440..8b671fe68af 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -19,7 +19,7 @@ extern int get_filesystem_list(char * buf);
int __initdata rd_doload; /* 1 = load RAM disk, 0 = don't load */
-int root_mountflags = MS_RDONLY | MS_VERBOSE;
+int root_mountflags = MS_RDONLY | MS_SILENT;
char * __initdata root_device_name;
static char __initdata saved_root_name[64];
diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
index a05cabd0fd1..405f9031af8 100644
--- a/init/do_mounts_initrd.c
+++ b/init/do_mounts_initrd.c
@@ -56,6 +56,7 @@ static void __init handle_initrd(void)
sys_chroot(".");
mount_devfs_fs ();
+ current->flags |= PF_NOFREEZE;
pid = kernel_thread(do_linuxrc, "/linuxrc", SIGCHLD);
if (pid > 0) {
while (pid != sys_wait4(-1, NULL, 0, NULL))
diff --git a/init/initramfs.c b/init/initramfs.c
index 637344b0598..77b934cccef 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -506,6 +506,7 @@ void __init populate_rootfs(void)
panic(err);
#ifdef CONFIG_BLK_DEV_INITRD
if (initrd_start) {
+#ifdef CONFIG_BLK_DEV_RAM
int fd;
printk(KERN_INFO "checking if image is initramfs...");
err = unpack_to_rootfs((char *)initrd_start,
@@ -525,6 +526,15 @@ void __init populate_rootfs(void)
sys_close(fd);
free_initrd();
}
+#else
+ printk(KERN_INFO "Unpacking initramfs...");
+ err = unpack_to_rootfs((char *)initrd_start,
+ initrd_end - initrd_start, 0);
+ if (err)
+ panic(err);
+ printk(" done\n");
+ free_initrd();
+#endif
}
#endif
}
diff --git a/init/main.c b/init/main.c
index 4c194c47395..006dcd547dc 100644
--- a/init/main.c
+++ b/init/main.c
@@ -306,8 +306,6 @@ static int __init rdinit_setup(char *str)
}
__setup("rdinit=", rdinit_setup);
-extern void setup_arch(char **);
-
#ifndef CONFIG_SMP
#ifdef CONFIG_X86_LOCAL_APIC
@@ -325,7 +323,7 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
#else
#ifdef __GENERIC_PER_CPU
-unsigned long __per_cpu_offset[NR_CPUS];
+unsigned long __per_cpu_offset[NR_CPUS] __read_mostly;
EXPORT_SYMBOL(__per_cpu_offset);
@@ -333,6 +331,7 @@ static void __init setup_per_cpu_areas(void)
{
unsigned long size, i;
char *ptr;
+ unsigned long nr_possible_cpus = num_possible_cpus();
/* Copy section for each CPU (we discard the original) */
size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
@@ -340,12 +339,12 @@ static void __init setup_per_cpu_areas(void)
if (size < PERCPU_ENOUGH_ROOM)
size = PERCPU_ENOUGH_ROOM;
#endif
+ ptr = alloc_bootmem(size * nr_possible_cpus);
- ptr = alloc_bootmem(size * NR_CPUS);
-
- for (i = 0; i < NR_CPUS; i++, ptr += size) {
+ for_each_cpu(i) {
__per_cpu_offset[i] = ptr - __per_cpu_start;
memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+ ptr += size;
}
}
#endif /* !__GENERIC_PER_CPU */
@@ -438,6 +437,15 @@ void __init parse_early_param(void)
* Activate the first processor.
*/
+static void __init boot_cpu_init(void)
+{
+ int cpu = smp_processor_id();
+ /* Mark the boot cpu "present", "online" etc for SMP and UP case */
+ cpu_set(cpu, cpu_online_map);
+ cpu_set(cpu, cpu_present_map);
+ cpu_set(cpu, cpu_possible_map);
+}
+
asmlinkage void __init start_kernel(void)
{
char * command_line;
@@ -447,17 +455,13 @@ asmlinkage void __init start_kernel(void)
* enable them
*/
lock_kernel();
+ boot_cpu_init();
page_address_init();
printk(KERN_NOTICE);
printk(linux_banner);
setup_arch(&command_line);
setup_per_cpu_areas();
-
- /*
- * Mark the boot cpu "online" so that it can call console drivers in
- * printk() and can access its per-cpu storage.
- */
- smp_prepare_boot_cpu();
+ smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
/*
* Set up the scheduler prior starting any interrupts (such as the
@@ -565,17 +569,23 @@ static void __init do_initcalls(void)
int count = preempt_count();
for (call = __initcall_start; call < __initcall_end; call++) {
- char *msg;
+ char *msg = NULL;
+ char msgbuf[40];
+ int result;
if (initcall_debug) {
- printk(KERN_DEBUG "Calling initcall 0x%p", *call);
- print_fn_descriptor_symbol(": %s()", (unsigned long) *call);
+ printk("Calling initcall 0x%p", *call);
+ print_fn_descriptor_symbol(": %s()",
+ (unsigned long) *call);
printk("\n");
}
- (*call)();
+ result = (*call)();
- msg = NULL;
+ if (result && (result != -ENODEV || initcall_debug)) {
+ sprintf(msgbuf, "error code %d", result);
+ msg = msgbuf;
+ }
if (preempt_count() != count) {
msg = "preemption imbalance";
preempt_count() = count;
@@ -585,8 +595,10 @@ static void __init do_initcalls(void)
local_irq_enable();
}
if (msg) {
- printk(KERN_WARNING "error in initcall at 0x%p: "
- "returned with %s\n", *call, msg);
+ printk(KERN_WARNING "initcall at 0x%p", *call);
+ print_fn_descriptor_symbol(": %s()",
+ (unsigned long) *call);
+ printk(": returned with %s\n", msg);
}
}
diff --git a/ipc/msg.c b/ipc/msg.c
index fbf757064a3..60c1e5c2341 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -220,8 +220,7 @@ asmlinkage long sys_msgget (key_t key, int msgflg)
ret = -EEXIST;
} else {
msq = msg_lock(id);
- if(msq==NULL)
- BUG();
+ BUG_ON(msq==NULL);
if (ipcperms(&msq->q_perm, msgflg))
ret = -EACCES;
else {
diff --git a/ipc/shm.c b/ipc/shm.c
index 9162123a7b2..16fe2786087 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -814,6 +814,9 @@ asmlinkage long sys_shmdt(char __user *shmaddr)
loff_t size = 0;
int retval = -EINVAL;
+ if (addr & ~PAGE_MASK)
+ return retval;
+
down_write(&mm->mmap_sem);
/*
diff --git a/kernel/Makefile b/kernel/Makefile
index 4ae0fbde815..aebd7a78984 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -34,6 +34,7 @@ obj-$(CONFIG_DETECT_SOFTLOCKUP) += softlockup.o
obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
obj-$(CONFIG_SECCOMP) += seccomp.o
obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
+obj-$(CONFIG_RELAY) += relay.o
ifneq ($(CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER),y)
# According to Alan Modra <alan@linuxcare.com.au>, the -fno-omit-frame-pointer is
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index d7e7e637b92..c4394abcd5e 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -958,7 +958,7 @@ void audit_syscall_entry(struct task_struct *tsk, int arch, int major,
*
* i386 no
* x86_64 no
- * ppc64 yes (see arch/ppc64/kernel/misc.S)
+ * ppc64 yes (see arch/powerpc/platforms/iseries/misc.S)
*
* This also happens with vm86 emulation in a non-nested manner
* (entries without exits), so this case must be caught.
diff --git a/kernel/capability.c b/kernel/capability.c
index bfa3c92e16f..1a4d8a40d3f 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -233,3 +233,19 @@ out:
return ret;
}
+
+int __capable(struct task_struct *t, int cap)
+{
+ if (security_capable(t, cap) == 0) {
+ t->flags |= PF_SUPERPRIV;
+ return 1;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(__capable);
+
+int capable(int cap)
+{
+ return __capable(current, cap);
+}
+EXPORT_SYMBOL(capable);
diff --git a/kernel/cpu.c b/kernel/cpu.c
index e882c6babf4..8be22bd8093 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -223,8 +223,7 @@ int __devinit cpu_up(unsigned int cpu)
ret = __cpu_up(cpu);
if (ret != 0)
goto out_notify;
- if (!cpu_online(cpu))
- BUG();
+ BUG_ON(!cpu_online(cpu));
/* Now call notifier in preparation. */
notifier_call_chain(&cpu_chain, CPU_ONLINE, hcpu);
diff --git a/kernel/cpuset.c b/kernel/cpuset.c
index 12815d3f1a0..18aea1bd128 100644
--- a/kernel/cpuset.c
+++ b/kernel/cpuset.c
@@ -4,15 +4,14 @@
* Processor and Memory placement constraints for sets of tasks.
*
* Copyright (C) 2003 BULL SA.
- * Copyright (C) 2004 Silicon Graphics, Inc.
+ * Copyright (C) 2004-2006 Silicon Graphics, Inc.
*
* Portions derived from Patrick Mochel's sysfs code.
* sysfs is Copyright (c) 2001-3 Patrick Mochel
- * Portions Copyright (c) 2004 Silicon Graphics, Inc.
*
- * 2003-10-10 Written by Simon Derr <simon.derr@bull.net>
+ * 2003-10-10 Written by Simon Derr.
* 2003-10-22 Updates by Stephen Hemminger.
- * 2004 May-July Rework by Paul Jackson <pj@sgi.com>
+ * 2004 May-July Rework by Paul Jackson.
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file COPYING in the main directory of the Linux
@@ -53,7 +52,7 @@
#include <asm/uaccess.h>
#include <asm/atomic.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#define CPUSET_SUPER_MAGIC 0x27e0eb
@@ -108,37 +107,49 @@ typedef enum {
CS_MEM_EXCLUSIVE,
CS_MEMORY_MIGRATE,
CS_REMOVED,
- CS_NOTIFY_ON_RELEASE
+ CS_NOTIFY_ON_RELEASE,
+ CS_SPREAD_PAGE,
+ CS_SPREAD_SLAB,
} cpuset_flagbits_t;
/* convenient tests for these bits */
static inline int is_cpu_exclusive(const struct cpuset *cs)
{
- return !!test_bit(CS_CPU_EXCLUSIVE, &cs->flags);
+ return test_bit(CS_CPU_EXCLUSIVE, &cs->flags);
}
static inline int is_mem_exclusive(const struct cpuset *cs)
{
- return !!test_bit(CS_MEM_EXCLUSIVE, &cs->flags);
+ return test_bit(CS_MEM_EXCLUSIVE, &cs->flags);
}
static inline int is_removed(const struct cpuset *cs)
{
- return !!test_bit(CS_REMOVED, &cs->flags);
+ return test_bit(CS_REMOVED, &cs->flags);
}
static inline int notify_on_release(const struct cpuset *cs)
{
- return !!test_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
+ return test_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
}
static inline int is_memory_migrate(const struct cpuset *cs)
{
- return !!test_bit(CS_MEMORY_MIGRATE, &cs->flags);
+ return test_bit(CS_MEMORY_MIGRATE, &cs->flags);
+}
+
+static inline int is_spread_page(const struct cpuset *cs)
+{
+ return test_bit(CS_SPREAD_PAGE, &cs->flags);
+}
+
+static inline int is_spread_slab(const struct cpuset *cs)
+{
+ return test_bit(CS_SPREAD_SLAB, &cs->flags);
}
/*
- * Increment this atomic integer everytime any cpuset changes its
+ * Increment this integer everytime any cpuset changes its
* mems_allowed value. Users of cpusets can track this generation
* number, and avoid having to lock and reload mems_allowed unless
* the cpuset they're using changes generation.
@@ -152,8 +163,11 @@ static inline int is_memory_migrate(const struct cpuset *cs)
* on every visit to __alloc_pages(), to efficiently check whether
* its current->cpuset->mems_allowed has changed, requiring an update
* of its current->mems_allowed.
+ *
+ * Since cpuset_mems_generation is guarded by manage_mutex,
+ * there is no need to mark it atomic.
*/
-static atomic_t cpuset_mems_generation = ATOMIC_INIT(1);
+static int cpuset_mems_generation;
static struct cpuset top_cpuset = {
.flags = ((1 << CS_CPU_EXCLUSIVE) | (1 << CS_MEM_EXCLUSIVE)),
@@ -168,63 +182,57 @@ static struct vfsmount *cpuset_mount;
static struct super_block *cpuset_sb;
/*
- * We have two global cpuset semaphores below. They can nest.
- * It is ok to first take manage_sem, then nest callback_sem. We also
+ * We have two global cpuset mutexes below. They can nest.
+ * It is ok to first take manage_mutex, then nest callback_mutex. We also
* require taking task_lock() when dereferencing a tasks cpuset pointer.
* See "The task_lock() exception", at the end of this comment.
*
- * A task must hold both semaphores to modify cpusets. If a task
- * holds manage_sem, then it blocks others wanting that semaphore,
- * ensuring that it is the only task able to also acquire callback_sem
+ * A task must hold both mutexes to modify cpusets. If a task
+ * holds manage_mutex, then it blocks others wanting that mutex,
+ * ensuring that it is the only task able to also acquire callback_mutex
* and be able to modify cpusets. It can perform various checks on
* the cpuset structure first, knowing nothing will change. It can
- * also allocate memory while just holding manage_sem. While it is
+ * also allocate memory while just holding manage_mutex. While it is
* performing these checks, various callback routines can briefly
- * acquire callback_sem to query cpusets. Once it is ready to make
- * the changes, it takes callback_sem, blocking everyone else.
+ * acquire callback_mutex to query cpusets. Once it is ready to make
+ * the changes, it takes callback_mutex, blocking everyone else.
*
* Calls to the kernel memory allocator can not be made while holding
- * callback_sem, as that would risk double tripping on callback_sem
+ * callback_mutex, as that would risk double tripping on callback_mutex
* from one of the callbacks into the cpuset code from within
* __alloc_pages().
*
- * If a task is only holding callback_sem, then it has read-only
+ * If a task is only holding callback_mutex, then it has read-only
* access to cpusets.
*
* The task_struct fields mems_allowed and mems_generation may only
* be accessed in the context of that task, so require no locks.
*
* Any task can increment and decrement the count field without lock.
- * So in general, code holding manage_sem or callback_sem can't rely
+ * So in general, code holding manage_mutex or callback_mutex can't rely
* on the count field not changing. However, if the count goes to
- * zero, then only attach_task(), which holds both semaphores, can
+ * zero, then only attach_task(), which holds both mutexes, can
* increment it again. Because a count of zero means that no tasks
* are currently attached, therefore there is no way a task attached
* to that cpuset can fork (the other way to increment the count).
- * So code holding manage_sem or callback_sem can safely assume that
+ * So code holding manage_mutex or callback_mutex can safely assume that
* if the count is zero, it will stay zero. Similarly, if a task
- * holds manage_sem or callback_sem on a cpuset with zero count, it
+ * holds manage_mutex or callback_mutex on a cpuset with zero count, it
* knows that the cpuset won't be removed, as cpuset_rmdir() needs
- * both of those semaphores.
- *
- * A possible optimization to improve parallelism would be to make
- * callback_sem a R/W semaphore (rwsem), allowing the callback routines
- * to proceed in parallel, with read access, until the holder of
- * manage_sem needed to take this rwsem for exclusive write access
- * and modify some cpusets.
+ * both of those mutexes.
*
* The cpuset_common_file_write handler for operations that modify
- * the cpuset hierarchy holds manage_sem across the entire operation,
+ * the cpuset hierarchy holds manage_mutex across the entire operation,
* single threading all such cpuset modifications across the system.
*
- * The cpuset_common_file_read() handlers only hold callback_sem across
+ * The cpuset_common_file_read() handlers only hold callback_mutex across
* small pieces of code, such as when reading out possibly multi-word
* cpumasks and nodemasks.
*
* The fork and exit callbacks cpuset_fork() and cpuset_exit(), don't
- * (usually) take either semaphore. These are the two most performance
+ * (usually) take either mutex. These are the two most performance
* critical pieces of code here. The exception occurs on cpuset_exit(),
- * when a task in a notify_on_release cpuset exits. Then manage_sem
+ * when a task in a notify_on_release cpuset exits. Then manage_mutex
* is taken, and if the cpuset count is zero, a usermode call made
* to /sbin/cpuset_release_agent with the name of the cpuset (path
* relative to the root of cpuset file system) as the argument.
@@ -242,9 +250,9 @@ static struct super_block *cpuset_sb;
*
* The need for this exception arises from the action of attach_task(),
* which overwrites one tasks cpuset pointer with another. It does
- * so using both semaphores, however there are several performance
+ * so using both mutexes, however there are several performance
* critical places that need to reference task->cpuset without the
- * expense of grabbing a system global semaphore. Therefore except as
+ * expense of grabbing a system global mutex. Therefore except as
* noted below, when dereferencing or, as in attach_task(), modifying
* a tasks cpuset pointer we use task_lock(), which acts on a spinlock
* (task->alloc_lock) already in the task_struct routinely used for
@@ -256,8 +264,8 @@ static struct super_block *cpuset_sb;
* the routine cpuset_update_task_memory_state().
*/
-static DECLARE_MUTEX(manage_sem);
-static DECLARE_MUTEX(callback_sem);
+static DEFINE_MUTEX(manage_mutex);
+static DEFINE_MUTEX(callback_mutex);
/*
* A couple of forward declarations required, due to cyclic reference loop:
@@ -432,7 +440,7 @@ static inline struct cftype *__d_cft(struct dentry *dentry)
}
/*
- * Call with manage_sem held. Writes path of cpuset into buf.
+ * Call with manage_mutex held. Writes path of cpuset into buf.
* Returns 0 on success, -errno on error.
*/
@@ -484,11 +492,11 @@ static int cpuset_path(const struct cpuset *cs, char *buf, int buflen)
* status of the /sbin/cpuset_release_agent task, so no sense holding
* our caller up for that.
*
- * When we had only one cpuset semaphore, we had to call this
+ * When we had only one cpuset mutex, we had to call this
* without holding it, to avoid deadlock when call_usermodehelper()
* allocated memory. With two locks, we could now call this while
- * holding manage_sem, but we still don't, so as to minimize
- * the time manage_sem is held.
+ * holding manage_mutex, but we still don't, so as to minimize
+ * the time manage_mutex is held.
*/
static void cpuset_release_agent(const char *pathbuf)
@@ -520,15 +528,15 @@ static void cpuset_release_agent(const char *pathbuf)
* cs is notify_on_release() and now both the user count is zero and
* the list of children is empty, prepare cpuset path in a kmalloc'd
* buffer, to be returned via ppathbuf, so that the caller can invoke
- * cpuset_release_agent() with it later on, once manage_sem is dropped.
- * Call here with manage_sem held.
+ * cpuset_release_agent() with it later on, once manage_mutex is dropped.
+ * Call here with manage_mutex held.
*
* This check_for_release() routine is responsible for kmalloc'ing
* pathbuf. The above cpuset_release_agent() is responsible for
* kfree'ing pathbuf. The caller of these routines is responsible
* for providing a pathbuf pointer, initialized to NULL, then
- * calling check_for_release() with manage_sem held and the address
- * of the pathbuf pointer, then dropping manage_sem, then calling
+ * calling check_for_release() with manage_mutex held and the address
+ * of the pathbuf pointer, then dropping manage_mutex, then calling
* cpuset_release_agent() with pathbuf, as set by check_for_release().
*/
@@ -559,7 +567,7 @@ static void check_for_release(struct cpuset *cs, char **ppathbuf)
* One way or another, we guarantee to return some non-empty subset
* of cpu_online_map.
*
- * Call with callback_sem held.
+ * Call with callback_mutex held.
*/
static void guarantee_online_cpus(const struct cpuset *cs, cpumask_t *pmask)
@@ -583,7 +591,7 @@ static void guarantee_online_cpus(const struct cpuset *cs, cpumask_t *pmask)
* One way or another, we guarantee to return some non-empty subset
* of node_online_map.
*
- * Call with callback_sem held.
+ * Call with callback_mutex held.
*/
static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
@@ -608,12 +616,12 @@ static void guarantee_online_mems(const struct cpuset *cs, nodemask_t *pmask)
* current->cpuset if a task has its memory placement changed.
* Do not call this routine if in_interrupt().
*
- * Call without callback_sem or task_lock() held. May be called
- * with or without manage_sem held. Doesn't need task_lock to guard
+ * Call without callback_mutex or task_lock() held. May be called
+ * with or without manage_mutex held. Doesn't need task_lock to guard
* against another task changing a non-NULL cpuset pointer to NULL,
* as that is only done by a task on itself, and if the current task
* is here, it is not simultaneously in the exit code NULL'ing its
- * cpuset pointer. This routine also might acquire callback_sem and
+ * cpuset pointer. This routine also might acquire callback_mutex and
* current->mm->mmap_sem during call.
*
* Reading current->cpuset->mems_generation doesn't need task_lock
@@ -658,13 +666,21 @@ void cpuset_update_task_memory_state(void)
}
if (my_cpusets_mem_gen != tsk->cpuset_mems_generation) {
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
task_lock(tsk);
cs = tsk->cpuset; /* Maybe changed when task not locked */
guarantee_online_mems(cs, &tsk->mems_allowed);
tsk->cpuset_mems_generation = cs->mems_generation;
+ if (is_spread_page(cs))
+ tsk->flags |= PF_SPREAD_PAGE;
+ else
+ tsk->flags &= ~PF_SPREAD_PAGE;
+ if (is_spread_slab(cs))
+ tsk->flags |= PF_SPREAD_SLAB;
+ else
+ tsk->flags &= ~PF_SPREAD_SLAB;
task_unlock(tsk);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
mpol_rebind_task(tsk, &tsk->mems_allowed);
}
}
@@ -674,7 +690,7 @@ void cpuset_update_task_memory_state(void)
*
* One cpuset is a subset of another if all its allowed CPUs and
* Memory Nodes are a subset of the other, and its exclusive flags
- * are only set if the other's are set. Call holding manage_sem.
+ * are only set if the other's are set. Call holding manage_mutex.
*/
static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
@@ -692,7 +708,7 @@ static int is_cpuset_subset(const struct cpuset *p, const struct cpuset *q)
* If we replaced the flag and mask values of the current cpuset
* (cur) with those values in the trial cpuset (trial), would
* our various subset and exclusive rules still be valid? Presumes
- * manage_sem held.
+ * manage_mutex held.
*
* 'cur' is the address of an actual, in-use cpuset. Operations
* such as list traversal that depend on the actual address of the
@@ -746,7 +762,7 @@ static int validate_change(const struct cpuset *cur, const struct cpuset *trial)
* exclusive child cpusets
* Build these two partitions by calling partition_sched_domains
*
- * Call with manage_sem held. May nest a call to the
+ * Call with manage_mutex held. May nest a call to the
* lock_cpu_hotplug()/unlock_cpu_hotplug() pair.
*/
@@ -792,7 +808,7 @@ static void update_cpu_domains(struct cpuset *cur)
}
/*
- * Call with manage_sem held. May take callback_sem during call.
+ * Call with manage_mutex held. May take callback_mutex during call.
*/
static int update_cpumask(struct cpuset *cs, char *buf)
@@ -811,9 +827,9 @@ static int update_cpumask(struct cpuset *cs, char *buf)
if (retval < 0)
return retval;
cpus_unchanged = cpus_equal(cs->cpus_allowed, trialcs.cpus_allowed);
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
cs->cpus_allowed = trialcs.cpus_allowed;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
if (is_cpu_exclusive(cs) && !cpus_unchanged)
update_cpu_domains(cs);
return 0;
@@ -827,7 +843,7 @@ static int update_cpumask(struct cpuset *cs, char *buf)
* the cpuset is marked 'memory_migrate', migrate the tasks
* pages to the new memory.
*
- * Call with manage_sem held. May take callback_sem during call.
+ * Call with manage_mutex held. May take callback_mutex during call.
* Will take tasklist_lock, scan tasklist for tasks in cpuset cs,
* lock each such tasks mm->mmap_sem, scan its vma's and rebind
* their mempolicies to the cpusets new mems_allowed.
@@ -862,11 +878,10 @@ static int update_nodemask(struct cpuset *cs, char *buf)
if (retval < 0)
goto done;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
cs->mems_allowed = trialcs.mems_allowed;
- atomic_inc(&cpuset_mems_generation);
- cs->mems_generation = atomic_read(&cpuset_mems_generation);
- up(&callback_sem);
+ cs->mems_generation = cpuset_mems_generation++;
+ mutex_unlock(&callback_mutex);
set_cpuset_being_rebound(cs); /* causes mpol_copy() rebind */
@@ -922,7 +937,7 @@ static int update_nodemask(struct cpuset *cs, char *buf)
* tasklist_lock. Forks can happen again now - the mpol_copy()
* cpuset_being_rebound check will catch such forks, and rebind
* their vma mempolicies too. Because we still hold the global
- * cpuset manage_sem, we know that no other rebind effort will
+ * cpuset manage_mutex, we know that no other rebind effort will
* be contending for the global variable cpuset_being_rebound.
* It's ok if we rebind the same mm twice; mpol_rebind_mm()
* is idempotent. Also migrate pages in each mm to new nodes.
@@ -948,7 +963,7 @@ done:
}
/*
- * Call with manage_sem held.
+ * Call with manage_mutex held.
*/
static int update_memory_pressure_enabled(struct cpuset *cs, char *buf)
@@ -963,11 +978,12 @@ static int update_memory_pressure_enabled(struct cpuset *cs, char *buf)
/*
* update_flag - read a 0 or a 1 in a file and update associated flag
* bit: the bit to update (CS_CPU_EXCLUSIVE, CS_MEM_EXCLUSIVE,
- * CS_NOTIFY_ON_RELEASE, CS_MEMORY_MIGRATE)
+ * CS_NOTIFY_ON_RELEASE, CS_MEMORY_MIGRATE,
+ * CS_SPREAD_PAGE, CS_SPREAD_SLAB)
* cs: the cpuset to update
* buf: the buffer where we read the 0 or 1
*
- * Call with manage_sem held.
+ * Call with manage_mutex held.
*/
static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
@@ -989,12 +1005,12 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, char *buf)
return err;
cpu_exclusive_changed =
(is_cpu_exclusive(cs) != is_cpu_exclusive(&trialcs));
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
if (turning_on)
set_bit(bit, &cs->flags);
else
clear_bit(bit, &cs->flags);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
if (cpu_exclusive_changed)
update_cpu_domains(cs);
@@ -1104,7 +1120,7 @@ static int fmeter_getrate(struct fmeter *fmp)
* writing the path of the old cpuset in 'ppathbuf' if it needs to be
* notified on release.
*
- * Call holding manage_sem. May take callback_sem and task_lock of
+ * Call holding manage_mutex. May take callback_mutex and task_lock of
* the task 'pid' during call.
*/
@@ -1144,13 +1160,13 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf)
get_task_struct(tsk);
}
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
task_lock(tsk);
oldcs = tsk->cpuset;
if (!oldcs) {
task_unlock(tsk);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
put_task_struct(tsk);
return -ESRCH;
}
@@ -1164,7 +1180,7 @@ static int attach_task(struct cpuset *cs, char *pidbuf, char **ppathbuf)
from = oldcs->mems_allowed;
to = cs->mems_allowed;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
mm = get_task_mm(tsk);
if (mm) {
@@ -1194,6 +1210,8 @@ typedef enum {
FILE_NOTIFY_ON_RELEASE,
FILE_MEMORY_PRESSURE_ENABLED,
FILE_MEMORY_PRESSURE,
+ FILE_SPREAD_PAGE,
+ FILE_SPREAD_SLAB,
FILE_TASKLIST,
} cpuset_filetype_t;
@@ -1221,7 +1239,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
}
buffer[nbytes] = 0; /* nul-terminate */
- down(&manage_sem);
+ mutex_lock(&manage_mutex);
if (is_removed(cs)) {
retval = -ENODEV;
@@ -1253,6 +1271,14 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
case FILE_MEMORY_PRESSURE:
retval = -EACCES;
break;
+ case FILE_SPREAD_PAGE:
+ retval = update_flag(CS_SPREAD_PAGE, cs, buffer);
+ cs->mems_generation = cpuset_mems_generation++;
+ break;
+ case FILE_SPREAD_SLAB:
+ retval = update_flag(CS_SPREAD_SLAB, cs, buffer);
+ cs->mems_generation = cpuset_mems_generation++;
+ break;
case FILE_TASKLIST:
retval = attach_task(cs, buffer, &pathbuf);
break;
@@ -1264,7 +1290,7 @@ static ssize_t cpuset_common_file_write(struct file *file, const char __user *us
if (retval == 0)
retval = nbytes;
out2:
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
cpuset_release_agent(pathbuf);
out1:
kfree(buffer);
@@ -1304,9 +1330,9 @@ static int cpuset_sprintf_cpulist(char *page, struct cpuset *cs)
{
cpumask_t mask;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
mask = cs->cpus_allowed;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
return cpulist_scnprintf(page, PAGE_SIZE, mask);
}
@@ -1315,9 +1341,9 @@ static int cpuset_sprintf_memlist(char *page, struct cpuset *cs)
{
nodemask_t mask;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
mask = cs->mems_allowed;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
return nodelist_scnprintf(page, PAGE_SIZE, mask);
}
@@ -1362,6 +1388,12 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf,
case FILE_MEMORY_PRESSURE:
s += sprintf(s, "%d", fmeter_getrate(&cs->fmeter));
break;
+ case FILE_SPREAD_PAGE:
+ *s++ = is_spread_page(cs) ? '1' : '0';
+ break;
+ case FILE_SPREAD_SLAB:
+ *s++ = is_spread_slab(cs) ? '1' : '0';
+ break;
default:
retval = -EINVAL;
goto out;
@@ -1598,7 +1630,7 @@ static int pid_array_to_buf(char *buf, int sz, pid_t *a, int npids)
* Handle an open on 'tasks' file. Prepare a buffer listing the
* process id's of tasks currently attached to the cpuset being opened.
*
- * Does not require any specific cpuset semaphores, and does not take any.
+ * Does not require any specific cpuset mutexes, and does not take any.
*/
static int cpuset_tasks_open(struct inode *unused, struct file *file)
{
@@ -1725,6 +1757,16 @@ static struct cftype cft_memory_pressure = {
.private = FILE_MEMORY_PRESSURE,
};
+static struct cftype cft_spread_page = {
+ .name = "memory_spread_page",
+ .private = FILE_SPREAD_PAGE,
+};
+
+static struct cftype cft_spread_slab = {
+ .name = "memory_spread_slab",
+ .private = FILE_SPREAD_SLAB,
+};
+
static int cpuset_populate_dir(struct dentry *cs_dentry)
{
int err;
@@ -1743,6 +1785,10 @@ static int cpuset_populate_dir(struct dentry *cs_dentry)
return err;
if ((err = cpuset_add_file(cs_dentry, &cft_memory_pressure)) < 0)
return err;
+ if ((err = cpuset_add_file(cs_dentry, &cft_spread_page)) < 0)
+ return err;
+ if ((err = cpuset_add_file(cs_dentry, &cft_spread_slab)) < 0)
+ return err;
if ((err = cpuset_add_file(cs_dentry, &cft_tasks)) < 0)
return err;
return 0;
@@ -1754,7 +1800,7 @@ static int cpuset_populate_dir(struct dentry *cs_dentry)
* name: name of the new cpuset. Will be strcpy'ed.
* mode: mode to set on new inode
*
- * Must be called with the semaphore on the parent inode held
+ * Must be called with the mutex on the parent inode held
*/
static long cpuset_create(struct cpuset *parent, const char *name, int mode)
@@ -1766,44 +1812,47 @@ static long cpuset_create(struct cpuset *parent, const char *name, int mode)
if (!cs)
return -ENOMEM;
- down(&manage_sem);
+ mutex_lock(&manage_mutex);
cpuset_update_task_memory_state();
cs->flags = 0;
if (notify_on_release(parent))
set_bit(CS_NOTIFY_ON_RELEASE, &cs->flags);
+ if (is_spread_page(parent))
+ set_bit(CS_SPREAD_PAGE, &cs->flags);
+ if (is_spread_slab(parent))
+ set_bit(CS_SPREAD_SLAB, &cs->flags);
cs->cpus_allowed = CPU_MASK_NONE;
cs->mems_allowed = NODE_MASK_NONE;
atomic_set(&cs->count, 0);
INIT_LIST_HEAD(&cs->sibling);
INIT_LIST_HEAD(&cs->children);
- atomic_inc(&cpuset_mems_generation);
- cs->mems_generation = atomic_read(&cpuset_mems_generation);
+ cs->mems_generation = cpuset_mems_generation++;
fmeter_init(&cs->fmeter);
cs->parent = parent;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
list_add(&cs->sibling, &cs->parent->children);
number_of_cpusets++;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
err = cpuset_create_dir(cs, name, mode);
if (err < 0)
goto err;
/*
- * Release manage_sem before cpuset_populate_dir() because it
+ * Release manage_mutex before cpuset_populate_dir() because it
* will down() this new directory's i_mutex and if we race with
* another mkdir, we might deadlock.
*/
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
err = cpuset_populate_dir(cs->dentry);
/* If err < 0, we have a half-filled directory - oh well ;) */
return 0;
err:
list_del(&cs->sibling);
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
kfree(cs);
return err;
}
@@ -1825,18 +1874,18 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
/* the vfs holds both inode->i_mutex already */
- down(&manage_sem);
+ mutex_lock(&manage_mutex);
cpuset_update_task_memory_state();
if (atomic_read(&cs->count) > 0) {
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
return -EBUSY;
}
if (!list_empty(&cs->children)) {
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
return -EBUSY;
}
parent = cs->parent;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
set_bit(CS_REMOVED, &cs->flags);
if (is_cpu_exclusive(cs))
update_cpu_domains(cs);
@@ -1848,10 +1897,10 @@ static int cpuset_rmdir(struct inode *unused_dir, struct dentry *dentry)
cpuset_d_remove_dir(d);
dput(d);
number_of_cpusets--;
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
if (list_empty(&parent->children))
check_for_release(parent, &pathbuf);
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
cpuset_release_agent(pathbuf);
return 0;
}
@@ -1867,7 +1916,7 @@ int __init cpuset_init_early(void)
struct task_struct *tsk = current;
tsk->cpuset = &top_cpuset;
- tsk->cpuset->mems_generation = atomic_read(&cpuset_mems_generation);
+ tsk->cpuset->mems_generation = cpuset_mems_generation++;
return 0;
}
@@ -1886,8 +1935,7 @@ int __init cpuset_init(void)
top_cpuset.mems_allowed = NODE_MASK_ALL;
fmeter_init(&top_cpuset.fmeter);
- atomic_inc(&cpuset_mems_generation);
- top_cpuset.mems_generation = atomic_read(&cpuset_mems_generation);
+ top_cpuset.mems_generation = cpuset_mems_generation++;
init_task.cpuset = &top_cpuset;
@@ -1960,25 +2008,25 @@ void cpuset_fork(struct task_struct *child)
* Description: Detach cpuset from @tsk and release it.
*
* Note that cpusets marked notify_on_release force every task in
- * them to take the global manage_sem semaphore when exiting.
+ * them to take the global manage_mutex mutex when exiting.
* This could impact scaling on very large systems. Be reluctant to
* use notify_on_release cpusets where very high task exit scaling
* is required on large systems.
*
* Don't even think about derefencing 'cs' after the cpuset use count
- * goes to zero, except inside a critical section guarded by manage_sem
- * or callback_sem. Otherwise a zero cpuset use count is a license to
+ * goes to zero, except inside a critical section guarded by manage_mutex
+ * or callback_mutex. Otherwise a zero cpuset use count is a license to
* any other task to nuke the cpuset immediately, via cpuset_rmdir().
*
- * This routine has to take manage_sem, not callback_sem, because
- * it is holding that semaphore while calling check_for_release(),
- * which calls kmalloc(), so can't be called holding callback__sem().
+ * This routine has to take manage_mutex, not callback_mutex, because
+ * it is holding that mutex while calling check_for_release(),
+ * which calls kmalloc(), so can't be called holding callback_mutex().
*
* We don't need to task_lock() this reference to tsk->cpuset,
* because tsk is already marked PF_EXITING, so attach_task() won't
* mess with it, or task is a failed fork, never visible to attach_task.
*
- * Hack:
+ * the_top_cpuset_hack:
*
* Set the exiting tasks cpuset to the root cpuset (top_cpuset).
*
@@ -2017,15 +2065,15 @@ void cpuset_exit(struct task_struct *tsk)
struct cpuset *cs;
cs = tsk->cpuset;
- tsk->cpuset = &top_cpuset; /* Hack - see comment above */
+ tsk->cpuset = &top_cpuset; /* the_top_cpuset_hack - see above */
if (notify_on_release(cs)) {
char *pathbuf = NULL;
- down(&manage_sem);
+ mutex_lock(&manage_mutex);
if (atomic_dec_and_test(&cs->count))
check_for_release(cs, &pathbuf);
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
cpuset_release_agent(pathbuf);
} else {
atomic_dec(&cs->count);
@@ -2046,11 +2094,11 @@ cpumask_t cpuset_cpus_allowed(struct task_struct *tsk)
{
cpumask_t mask;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
task_lock(tsk);
guarantee_online_cpus(tsk->cpuset, &mask);
task_unlock(tsk);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
return mask;
}
@@ -2074,11 +2122,11 @@ nodemask_t cpuset_mems_allowed(struct task_struct *tsk)
{
nodemask_t mask;
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
task_lock(tsk);
guarantee_online_mems(tsk->cpuset, &mask);
task_unlock(tsk);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
return mask;
}
@@ -2104,7 +2152,7 @@ int cpuset_zonelist_valid_mems_allowed(struct zonelist *zl)
/*
* nearest_exclusive_ancestor() - Returns the nearest mem_exclusive
- * ancestor to the specified cpuset. Call holding callback_sem.
+ * ancestor to the specified cpuset. Call holding callback_mutex.
* If no ancestor is mem_exclusive (an unusual configuration), then
* returns the root cpuset.
*/
@@ -2131,12 +2179,12 @@ static const struct cpuset *nearest_exclusive_ancestor(const struct cpuset *cs)
* GFP_KERNEL allocations are not so marked, so can escape to the
* nearest mem_exclusive ancestor cpuset.
*
- * Scanning up parent cpusets requires callback_sem. The __alloc_pages()
+ * Scanning up parent cpusets requires callback_mutex. The __alloc_pages()
* routine only calls here with __GFP_HARDWALL bit _not_ set if
* it's a GFP_KERNEL allocation, and all nodes in the current tasks
* mems_allowed came up empty on the first pass over the zonelist.
* So only GFP_KERNEL allocations, if all nodes in the cpuset are
- * short of memory, might require taking the callback_sem semaphore.
+ * short of memory, might require taking the callback_mutex mutex.
*
* The first loop over the zonelist in mm/page_alloc.c:__alloc_pages()
* calls here with __GFP_HARDWALL always set in gfp_mask, enforcing
@@ -2157,7 +2205,7 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
{
int node; /* node that zone z is on */
const struct cpuset *cs; /* current cpuset ancestors */
- int allowed = 1; /* is allocation in zone z allowed? */
+ int allowed; /* is allocation in zone z allowed? */
if (in_interrupt())
return 1;
@@ -2171,31 +2219,31 @@ int __cpuset_zone_allowed(struct zone *z, gfp_t gfp_mask)
return 1;
/* Not hardwall and node outside mems_allowed: scan up cpusets */
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
task_lock(current);
cs = nearest_exclusive_ancestor(current->cpuset);
task_unlock(current);
allowed = node_isset(node, cs->mems_allowed);
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
return allowed;
}
/**
* cpuset_lock - lock out any changes to cpuset structures
*
- * The out of memory (oom) code needs to lock down cpusets
+ * The out of memory (oom) code needs to mutex_lock cpusets
* from being changed while it scans the tasklist looking for a
- * task in an overlapping cpuset. Expose callback_sem via this
+ * task in an overlapping cpuset. Expose callback_mutex via this
* cpuset_lock() routine, so the oom code can lock it, before
* locking the task list. The tasklist_lock is a spinlock, so
- * must be taken inside callback_sem.
+ * must be taken inside callback_mutex.
*/
void cpuset_lock(void)
{
- down(&callback_sem);
+ mutex_lock(&callback_mutex);
}
/**
@@ -2206,10 +2254,48 @@ void cpuset_lock(void)
void cpuset_unlock(void)
{
- up(&callback_sem);
+ mutex_unlock(&callback_mutex);
}
/**
+ * cpuset_mem_spread_node() - On which node to begin search for a page
+ *
+ * If a task is marked PF_SPREAD_PAGE or PF_SPREAD_SLAB (as for
+ * tasks in a cpuset with is_spread_page or is_spread_slab set),
+ * and if the memory allocation used cpuset_mem_spread_node()
+ * to determine on which node to start looking, as it will for
+ * certain page cache or slab cache pages such as used for file
+ * system buffers and inode caches, then instead of starting on the
+ * local node to look for a free page, rather spread the starting
+ * node around the tasks mems_allowed nodes.
+ *
+ * We don't have to worry about the returned node being offline
+ * because "it can't happen", and even if it did, it would be ok.
+ *
+ * The routines calling guarantee_online_mems() are careful to
+ * only set nodes in task->mems_allowed that are online. So it
+ * should not be possible for the following code to return an
+ * offline node. But if it did, that would be ok, as this routine
+ * is not returning the node where the allocation must be, only
+ * the node where the search should start. The zonelist passed to
+ * __alloc_pages() will include all nodes. If the slab allocator
+ * is passed an offline node, it will fall back to the local node.
+ * See kmem_cache_alloc_node().
+ */
+
+int cpuset_mem_spread_node(void)
+{
+ int node;
+
+ node = next_node(current->cpuset_mem_spread_rotor, current->mems_allowed);
+ if (node == MAX_NUMNODES)
+ node = first_node(current->mems_allowed);
+ current->cpuset_mem_spread_rotor = node;
+ return node;
+}
+EXPORT_SYMBOL_GPL(cpuset_mem_spread_node);
+
+/**
* cpuset_excl_nodes_overlap - Do we overlap @p's mem_exclusive ancestors?
* @p: pointer to task_struct of some other task.
*
@@ -2218,7 +2304,7 @@ void cpuset_unlock(void)
* determine if task @p's memory usage might impact the memory
* available to the current task.
*
- * Call while holding callback_sem.
+ * Call while holding callback_mutex.
**/
int cpuset_excl_nodes_overlap(const struct task_struct *p)
@@ -2289,13 +2375,13 @@ void __cpuset_memory_pressure_bump(void)
* - Used for /proc/<pid>/cpuset.
* - No need to task_lock(tsk) on this tsk->cpuset reference, as it
* doesn't really matter if tsk->cpuset changes after we read it,
- * and we take manage_sem, keeping attach_task() from changing it
- * anyway.
+ * and we take manage_mutex, keeping attach_task() from changing it
+ * anyway. No need to check that tsk->cpuset != NULL, thanks to
+ * the_top_cpuset_hack in cpuset_exit(), which sets an exiting tasks
+ * cpuset to top_cpuset.
*/
-
static int proc_cpuset_show(struct seq_file *m, void *v)
{
- struct cpuset *cs;
struct task_struct *tsk;
char *buf;
int retval = 0;
@@ -2305,20 +2391,14 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
return -ENOMEM;
tsk = m->private;
- down(&manage_sem);
- cs = tsk->cpuset;
- if (!cs) {
- retval = -EINVAL;
- goto out;
- }
-
- retval = cpuset_path(cs, buf, PAGE_SIZE);
+ mutex_lock(&manage_mutex);
+ retval = cpuset_path(tsk->cpuset, buf, PAGE_SIZE);
if (retval < 0)
goto out;
seq_puts(m, buf);
seq_putc(m, '\n');
out:
- up(&manage_sem);
+ mutex_unlock(&manage_mutex);
kfree(buf);
return retval;
}
diff --git a/kernel/exec_domain.c b/kernel/exec_domain.c
index 867d6dbeb57..c01cead2cfd 100644
--- a/kernel/exec_domain.c
+++ b/kernel/exec_domain.c
@@ -140,6 +140,7 @@ __set_personality(u_long personality)
ep = lookup_exec_domain(personality);
if (ep == current_thread_info()->exec_domain) {
current->personality = personality;
+ module_put(ep->module);
return 0;
}
diff --git a/kernel/exit.c b/kernel/exit.c
index d1e8d500a7e..8037405e136 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -345,9 +345,9 @@ void daemonize(const char *name, ...)
exit_mm(current);
set_special_pids(1, 1);
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
current->signal->tty = NULL;
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
/* Block and flush all signals */
sigfillset(&blocked);
diff --git a/kernel/fork.c b/kernel/fork.c
index 9bd7b65ee41..a02063903aa 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -181,6 +181,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
/* One for us, one for whoever does the "release_task()" (usually parent) */
atomic_set(&tsk->usage,2);
atomic_set(&tsk->fs_excl, 0);
+ tsk->btrace_seq = 0;
return tsk;
}
@@ -607,12 +608,12 @@ static struct files_struct *alloc_files(void)
atomic_set(&newf->count, 1);
spin_lock_init(&newf->file_lock);
+ newf->next_fd = 0;
fdt = &newf->fdtab;
- fdt->next_fd = 0;
fdt->max_fds = NR_OPEN_DEFAULT;
- fdt->max_fdset = __FD_SETSIZE;
- fdt->close_on_exec = &newf->close_on_exec_init;
- fdt->open_fds = &newf->open_fds_init;
+ fdt->max_fdset = EMBEDDED_FD_SET_SIZE;
+ fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init;
+ fdt->open_fds = (fd_set *)&newf->open_fds_init;
fdt->fd = &newf->fd_array[0];
INIT_RCU_HEAD(&fdt->rcu);
fdt->free_files = NULL;
@@ -1020,6 +1021,7 @@ static task_t *copy_process(unsigned long clone_flags,
p->mempolicy = NULL;
goto bad_fork_cleanup_cpuset;
}
+ mpol_fix_fork_child_flag(p);
#endif
#ifdef CONFIG_DEBUG_MUTEXES
diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile
index 49378738ff5..2b33f852be3 100644
--- a/kernel/irq/Makefile
+++ b/kernel/irq/Makefile
@@ -1,5 +1,4 @@
-obj-y := handle.o manage.o spurious.o
+obj-y := handle.o manage.o spurious.o migration.o
obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
obj-$(CONFIG_PROC_FS) += proc.o
-
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 97d5559997d..6edfcef291e 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -204,10 +204,14 @@ int setup_irq(unsigned int irq, struct irqaction * new)
p = &desc->action;
if ((old = *p) != NULL) {
/* Can't share interrupts unless both agree to */
- if (!(old->flags & new->flags & SA_SHIRQ)) {
- spin_unlock_irqrestore(&desc->lock,flags);
- return -EBUSY;
- }
+ if (!(old->flags & new->flags & SA_SHIRQ))
+ goto mismatch;
+
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+ /* All handlers must agree on per-cpuness */
+ if ((old->flags & IRQ_PER_CPU) != (new->flags & IRQ_PER_CPU))
+ goto mismatch;
+#endif
/* add new interrupt at end of irq queue */
do {
@@ -218,7 +222,10 @@ int setup_irq(unsigned int irq, struct irqaction * new)
}
*p = new;
-
+#if defined(ARCH_HAS_IRQ_PER_CPU) && defined(SA_PERCPU_IRQ)
+ if (new->flags & SA_PERCPU_IRQ)
+ desc->status |= IRQ_PER_CPU;
+#endif
if (!shared) {
desc->depth = 0;
desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT |
@@ -236,6 +243,12 @@ int setup_irq(unsigned int irq, struct irqaction * new)
register_handler_proc(irq, new);
return 0;
+
+mismatch:
+ spin_unlock_irqrestore(&desc->lock, flags);
+ printk(KERN_ERR "%s: irq handler mismatch\n", __FUNCTION__);
+ dump_stack();
+ return -EBUSY;
}
/**
diff --git a/kernel/irq/migration.c b/kernel/irq/migration.c
new file mode 100644
index 00000000000..52a8655fa08
--- /dev/null
+++ b/kernel/irq/migration.c
@@ -0,0 +1,65 @@
+#include <linux/irq.h>
+
+#if defined(CONFIG_GENERIC_PENDING_IRQ)
+
+void set_pending_irq(unsigned int irq, cpumask_t mask)
+{
+ irq_desc_t *desc = irq_desc + irq;
+ unsigned long flags;
+
+ spin_lock_irqsave(&desc->lock, flags);
+ desc->move_irq = 1;
+ pending_irq_cpumask[irq] = mask;
+ spin_unlock_irqrestore(&desc->lock, flags);
+}
+
+void move_native_irq(int irq)
+{
+ cpumask_t tmp;
+ irq_desc_t *desc = irq_descp(irq);
+
+ if (likely(!desc->move_irq))
+ return;
+
+ /*
+ * Paranoia: cpu-local interrupts shouldn't be calling in here anyway.
+ */
+ if (CHECK_IRQ_PER_CPU(desc->status)) {
+ WARN_ON(1);
+ return;
+ }
+
+ desc->move_irq = 0;
+
+ if (likely(cpus_empty(pending_irq_cpumask[irq])))
+ return;
+
+ if (!desc->handler->set_affinity)
+ return;
+
+ assert_spin_locked(&desc->lock);
+
+ cpus_and(tmp, pending_irq_cpumask[irq], cpu_online_map);
+
+ /*
+ * If there was a valid mask to work with, please
+ * do the disable, re-program, enable sequence.
+ * This is *not* particularly important for level triggered
+ * but in a edge trigger case, we might be setting rte
+ * when an active trigger is comming in. This could
+ * cause some ioapics to mal-function.
+ * Being paranoid i guess!
+ */
+ if (unlikely(!cpus_empty(tmp))) {
+ if (likely(!(desc->status & IRQ_DISABLED)))
+ desc->handler->disable(irq);
+
+ desc->handler->set_affinity(irq,tmp);
+
+ if (likely(!(desc->status & IRQ_DISABLED)))
+ desc->handler->enable(irq);
+ }
+ cpus_clear(pending_irq_cpumask[irq]);
+}
+
+#endif
diff --git a/kernel/itimer.c b/kernel/itimer.c
index 379be2f8c84..680e6b70c87 100644
--- a/kernel/itimer.c
+++ b/kernel/itimer.c
@@ -143,6 +143,60 @@ int it_real_fn(void *data)
return HRTIMER_NORESTART;
}
+/*
+ * We do not care about correctness. We just sanitize the values so
+ * the ktime_t operations which expect normalized values do not
+ * break. This converts negative values to long timeouts similar to
+ * the code in kernel versions < 2.6.16
+ *
+ * Print a limited number of warning messages when an invalid timeval
+ * is detected.
+ */
+static void fixup_timeval(struct timeval *tv, int interval)
+{
+ static int warnlimit = 10;
+ unsigned long tmp;
+
+ if (warnlimit > 0) {
+ warnlimit--;
+ printk(KERN_WARNING
+ "setitimer: %s (pid = %d) provided "
+ "invalid timeval %s: tv_sec = %ld tv_usec = %ld\n",
+ current->comm, current->pid,
+ interval ? "it_interval" : "it_value",
+ tv->tv_sec, (long) tv->tv_usec);
+ }
+
+ tmp = tv->tv_usec;
+ if (tmp >= USEC_PER_SEC) {
+ tv->tv_usec = tmp % USEC_PER_SEC;
+ tv->tv_sec += tmp / USEC_PER_SEC;
+ }
+
+ tmp = tv->tv_sec;
+ if (tmp > LONG_MAX)
+ tv->tv_sec = LONG_MAX;
+}
+
+/*
+ * Returns true if the timeval is in canonical form
+ */
+#define timeval_valid(t) \
+ (((t)->tv_sec >= 0) && (((unsigned long) (t)->tv_usec) < USEC_PER_SEC))
+
+/*
+ * Check for invalid timevals, sanitize them and print a limited
+ * number of warnings.
+ */
+static void check_itimerval(struct itimerval *value) {
+
+ if (unlikely(!timeval_valid(&value->it_value)))
+ fixup_timeval(&value->it_value, 0);
+
+ if (unlikely(!timeval_valid(&value->it_interval)))
+ fixup_timeval(&value->it_interval, 1);
+}
+
int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
{
struct task_struct *tsk = current;
@@ -150,6 +204,18 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
ktime_t expires;
cputime_t cval, cinterval, nval, ninterval;
+ /*
+ * Validate the timevals in value.
+ *
+ * Note: Although the spec requires that invalid values shall
+ * return -EINVAL, we just fixup the value and print a limited
+ * number of warnings in order not to break users of this
+ * historical misfeature.
+ *
+ * Scheduled for replacement in March 2007
+ */
+ check_itimerval(value);
+
switch (which) {
case ITIMER_REAL:
again:
@@ -226,6 +292,43 @@ again:
return 0;
}
+/**
+ * alarm_setitimer - set alarm in seconds
+ *
+ * @seconds: number of seconds until alarm
+ * 0 disables the alarm
+ *
+ * Returns the remaining time in seconds of a pending timer or 0 when
+ * the timer is not active.
+ *
+ * On 32 bit machines the seconds value is limited to (INT_MAX/2) to avoid
+ * negative timeval settings which would cause immediate expiry.
+ */
+unsigned int alarm_setitimer(unsigned int seconds)
+{
+ struct itimerval it_new, it_old;
+
+#if BITS_PER_LONG < 64
+ if (seconds > INT_MAX)
+ seconds = INT_MAX;
+#endif
+ it_new.it_value.tv_sec = seconds;
+ it_new.it_value.tv_usec = 0;
+ it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
+
+ do_setitimer(ITIMER_REAL, &it_new, &it_old);
+
+ /*
+ * We can't return 0 if we have an alarm pending ... And we'd
+ * better return too much than too little anyway
+ */
+ if ((!it_old.it_value.tv_sec && it_old.it_value.tv_usec) ||
+ it_old.it_value.tv_usec >= 500000)
+ it_old.it_value.tv_sec++;
+
+ return it_old.it_value.tv_sec;
+}
+
asmlinkage long sys_setitimer(int which,
struct itimerval __user *value,
struct itimerval __user *ovalue)
diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index fef1af8a73c..1fb9f753ef6 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -48,7 +48,7 @@
static struct hlist_head kprobe_table[KPROBE_TABLE_SIZE];
static struct hlist_head kretprobe_inst_table[KPROBE_TABLE_SIZE];
-DECLARE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
+DEFINE_MUTEX(kprobe_mutex); /* Protects kprobe_table */
DEFINE_SPINLOCK(kretprobe_lock); /* Protects kretprobe_inst_table */
static DEFINE_PER_CPU(struct kprobe *, kprobe_instance) = NULL;
@@ -460,7 +460,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
}
p->nmissed = 0;
- down(&kprobe_mutex);
+ mutex_lock(&kprobe_mutex);
old_p = get_kprobe(p->addr);
if (old_p) {
ret = register_aggr_kprobe(old_p, p);
@@ -477,7 +477,7 @@ static int __kprobes __register_kprobe(struct kprobe *p,
arch_arm_kprobe(p);
out:
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
if (ret && probed_mod)
module_put(probed_mod);
@@ -496,10 +496,10 @@ void __kprobes unregister_kprobe(struct kprobe *p)
struct kprobe *old_p, *list_p;
int cleanup_p;
- down(&kprobe_mutex);
+ mutex_lock(&kprobe_mutex);
old_p = get_kprobe(p->addr);
if (unlikely(!old_p)) {
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
return;
}
if (p != old_p) {
@@ -507,7 +507,7 @@ void __kprobes unregister_kprobe(struct kprobe *p)
if (list_p == p)
/* kprobe p is a valid probe */
goto valid_p;
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
return;
}
valid_p:
@@ -523,7 +523,7 @@ valid_p:
cleanup_p = 0;
}
- up(&kprobe_mutex);
+ mutex_unlock(&kprobe_mutex);
synchronize_sched();
if (p->mod_refcounted &&
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index f2690ed7453..f119e098e67 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -22,7 +22,7 @@ static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
static struct subsys_attribute _name##_attr = \
__ATTR(_name, 0644, _name##_show, _name##_store)
-#ifdef CONFIG_HOTPLUG
+#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
/* current uevent sequence number */
static ssize_t uevent_seqnum_show(struct subsystem *subsys, char *page)
{
@@ -52,7 +52,7 @@ decl_subsys(kernel, NULL, NULL);
EXPORT_SYMBOL_GPL(kernel_subsys);
static struct attribute * kernel_attrs[] = {
-#ifdef CONFIG_HOTPLUG
+#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
&uevent_seqnum_attr.attr,
&uevent_helper_attr.attr,
#endif
diff --git a/kernel/kthread.c b/kernel/kthread.c
index e75950a1092..c5f3c6613b6 100644
--- a/kernel/kthread.c
+++ b/kernel/kthread.c
@@ -12,6 +12,7 @@
#include <linux/unistd.h>
#include <linux/file.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <asm/semaphore.h>
/*
@@ -41,7 +42,7 @@ struct kthread_stop_info
/* Thread stopping is done by setthing this var: lock serializes
* multiple kthread_stop calls. */
-static DECLARE_MUTEX(kthread_stop_lock);
+static DEFINE_MUTEX(kthread_stop_lock);
static struct kthread_stop_info kthread_stop_info;
int kthread_should_stop(void)
@@ -114,7 +115,9 @@ static void keventd_create_kthread(void *_create)
create->result = ERR_PTR(pid);
} else {
wait_for_completion(&create->started);
+ read_lock(&tasklist_lock);
create->result = find_task_by_pid(pid);
+ read_unlock(&tasklist_lock);
}
complete(&create->done);
}
@@ -173,7 +176,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
{
int ret;
- down(&kthread_stop_lock);
+ mutex_lock(&kthread_stop_lock);
/* It could exit after stop_info.k set, but before wake_up_process. */
get_task_struct(k);
@@ -194,7 +197,7 @@ int kthread_stop_sem(struct task_struct *k, struct semaphore *s)
wait_for_completion(&kthread_stop_info.done);
kthread_stop_info.k = NULL;
ret = kthread_stop_info.err;
- up(&kthread_stop_lock);
+ mutex_unlock(&kthread_stop_lock);
return ret;
}
diff --git a/kernel/module.c b/kernel/module.c
index 77764f22f02..ddfe45ac2fd 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -39,6 +39,7 @@
#include <linux/device.h>
#include <linux/string.h>
#include <linux/sched.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
#include <asm/cacheflush.h>
@@ -60,18 +61,18 @@
static DEFINE_SPINLOCK(modlist_lock);
/* List of modules, protected by module_mutex AND modlist_lock */
-static DECLARE_MUTEX(module_mutex);
+static DEFINE_MUTEX(module_mutex);
static LIST_HEAD(modules);
-static DECLARE_MUTEX(notify_mutex);
+static DEFINE_MUTEX(notify_mutex);
static struct notifier_block * module_notify_list;
int register_module_notifier(struct notifier_block * nb)
{
int err;
- down(&notify_mutex);
+ mutex_lock(&notify_mutex);
err = notifier_chain_register(&module_notify_list, nb);
- up(&notify_mutex);
+ mutex_unlock(&notify_mutex);
return err;
}
EXPORT_SYMBOL(register_module_notifier);
@@ -79,9 +80,9 @@ EXPORT_SYMBOL(register_module_notifier);
int unregister_module_notifier(struct notifier_block * nb)
{
int err;
- down(&notify_mutex);
+ mutex_lock(&notify_mutex);
err = notifier_chain_unregister(&module_notify_list, nb);
- up(&notify_mutex);
+ mutex_unlock(&notify_mutex);
return err;
}
EXPORT_SYMBOL(unregister_module_notifier);
@@ -232,24 +233,6 @@ static unsigned long __find_symbol(const char *name,
return 0;
}
-/* Find a symbol in this elf symbol table */
-static unsigned long find_local_symbol(Elf_Shdr *sechdrs,
- unsigned int symindex,
- const char *strtab,
- const char *name)
-{
- unsigned int i;
- Elf_Sym *sym = (void *)sechdrs[symindex].sh_addr;
-
- /* Search (defined) internal symbols first. */
- for (i = 1; i < sechdrs[symindex].sh_size/sizeof(*sym); i++) {
- if (sym[i].st_shndx != SHN_UNDEF
- && strcmp(name, strtab + sym[i].st_name) == 0)
- return sym[i].st_value;
- }
- return 0;
-}
-
/* Search for module by name: must hold module_mutex. */
static struct module *find_module(const char *name)
{
@@ -601,7 +584,7 @@ static void free_module(struct module *mod);
static void wait_for_zero_refcount(struct module *mod)
{
/* Since we might sleep for some time, drop the semaphore first */
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
for (;;) {
DEBUGP("Looking at refcount...\n");
set_current_state(TASK_UNINTERRUPTIBLE);
@@ -610,7 +593,7 @@ static void wait_for_zero_refcount(struct module *mod)
schedule();
}
current->state = TASK_RUNNING;
- down(&module_mutex);
+ mutex_lock(&module_mutex);
}
asmlinkage long
@@ -627,7 +610,7 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
return -EFAULT;
name[MODULE_NAME_LEN-1] = '\0';
- if (down_interruptible(&module_mutex) != 0)
+ if (mutex_lock_interruptible(&module_mutex) != 0)
return -EINTR;
mod = find_module(name);
@@ -676,14 +659,14 @@ sys_delete_module(const char __user *name_user, unsigned int flags)
/* Final destruction now noone is using it. */
if (mod->exit != NULL) {
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
mod->exit();
- down(&module_mutex);
+ mutex_lock(&module_mutex);
}
free_module(mod);
out:
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
return ret;
}
@@ -784,139 +767,6 @@ static struct module_attribute *modinfo_attrs[] = {
NULL,
};
-#ifdef CONFIG_OBSOLETE_MODPARM
-/* Bounds checking done below */
-static int obsparm_copy_string(const char *val, struct kernel_param *kp)
-{
- strcpy(kp->arg, val);
- return 0;
-}
-
-static int set_obsolete(const char *val, struct kernel_param *kp)
-{
- unsigned int min, max;
- unsigned int size, maxsize;
- int dummy;
- char *endp;
- const char *p;
- struct obsolete_modparm *obsparm = kp->arg;
-
- if (!val) {
- printk(KERN_ERR "Parameter %s needs an argument\n", kp->name);
- return -EINVAL;
- }
-
- /* type is: [min[-max]]{b,h,i,l,s} */
- p = obsparm->type;
- min = simple_strtol(p, &endp, 10);
- if (endp == obsparm->type)
- min = max = 1;
- else if (*endp == '-') {
- p = endp+1;
- max = simple_strtol(p, &endp, 10);
- } else
- max = min;
- switch (*endp) {
- case 'b':
- return param_array(kp->name, val, min, max, obsparm->addr,
- 1, param_set_byte, &dummy);
- case 'h':
- return param_array(kp->name, val, min, max, obsparm->addr,
- sizeof(short), param_set_short, &dummy);
- case 'i':
- return param_array(kp->name, val, min, max, obsparm->addr,
- sizeof(int), param_set_int, &dummy);
- case 'l':
- return param_array(kp->name, val, min, max, obsparm->addr,
- sizeof(long), param_set_long, &dummy);
- case 's':
- return param_array(kp->name, val, min, max, obsparm->addr,
- sizeof(char *), param_set_charp, &dummy);
-
- case 'c':
- /* Undocumented: 1-5c50 means 1-5 strings of up to 49 chars,
- and the decl is "char xxx[5][50];" */
- p = endp+1;
- maxsize = simple_strtol(p, &endp, 10);
- /* We check lengths here (yes, this is a hack). */
- p = val;
- while (p[size = strcspn(p, ",")]) {
- if (size >= maxsize)
- goto oversize;
- p += size+1;
- }
- if (size >= maxsize)
- goto oversize;
- return param_array(kp->name, val, min, max, obsparm->addr,
- maxsize, obsparm_copy_string, &dummy);
- }
- printk(KERN_ERR "Unknown obsolete parameter type %s\n", obsparm->type);
- return -EINVAL;
- oversize:
- printk(KERN_ERR
- "Parameter %s doesn't fit in %u chars.\n", kp->name, maxsize);
- return -EINVAL;
-}
-
-static int obsolete_params(const char *name,
- char *args,
- struct obsolete_modparm obsparm[],
- unsigned int num,
- Elf_Shdr *sechdrs,
- unsigned int symindex,
- const char *strtab)
-{
- struct kernel_param *kp;
- unsigned int i;
- int ret;
-
- kp = kmalloc(sizeof(kp[0]) * num, GFP_KERNEL);
- if (!kp)
- return -ENOMEM;
-
- for (i = 0; i < num; i++) {
- char sym_name[128 + sizeof(MODULE_SYMBOL_PREFIX)];
-
- snprintf(sym_name, sizeof(sym_name), "%s%s",
- MODULE_SYMBOL_PREFIX, obsparm[i].name);
-
- kp[i].name = obsparm[i].name;
- kp[i].perm = 000;
- kp[i].set = set_obsolete;
- kp[i].get = NULL;
- obsparm[i].addr
- = (void *)find_local_symbol(sechdrs, symindex, strtab,
- sym_name);
- if (!obsparm[i].addr) {
- printk("%s: falsely claims to have parameter %s\n",
- name, obsparm[i].name);
- ret = -EINVAL;
- goto out;
- }
- kp[i].arg = &obsparm[i];
- }
-
- ret = parse_args(name, args, kp, num, NULL);
- out:
- kfree(kp);
- return ret;
-}
-#else
-static int obsolete_params(const char *name,
- char *args,
- struct obsolete_modparm obsparm[],
- unsigned int num,
- Elf_Shdr *sechdrs,
- unsigned int symindex,
- const char *strtab)
-{
- if (num != 0)
- printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
- name);
- return 0;
-}
-#endif /* CONFIG_OBSOLETE_MODPARM */
-
static const char vermagic[] = VERMAGIC_STRING;
#ifdef CONFIG_MODVERSIONS
@@ -1571,7 +1421,6 @@ static struct module *load_module(void __user *umod,
exportindex, modindex, obsparmindex, infoindex, gplindex,
crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
gplfuturecrcindex;
- long arglen;
struct module *mod;
long err = 0;
void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -1690,23 +1539,11 @@ static struct module *load_module(void __user *umod,
}
/* Now copy in args */
- arglen = strlen_user(uargs);
- if (!arglen) {
- err = -EFAULT;
- goto free_hdr;
- }
- args = kmalloc(arglen, GFP_KERNEL);
- if (!args) {
- err = -ENOMEM;
+ args = strndup_user(uargs, ~0UL >> 1);
+ if (IS_ERR(args)) {
+ err = PTR_ERR(args);
goto free_hdr;
}
- if (copy_from_user(args, uargs, arglen) != 0) {
- err = -EFAULT;
- goto free_mod;
- }
-
- /* Userspace could have altered the string after the strlen_user() */
- args[arglen - 1] = '\0';
if (find_module(mod->name)) {
err = -EEXIST;
@@ -1886,27 +1723,17 @@ static struct module *load_module(void __user *umod,
set_fs(old_fs);
mod->args = args;
- if (obsparmindex) {
- err = obsolete_params(mod->name, mod->args,
- (struct obsolete_modparm *)
- sechdrs[obsparmindex].sh_addr,
- sechdrs[obsparmindex].sh_size
- / sizeof(struct obsolete_modparm),
- sechdrs, symindex,
- (char *)sechdrs[strindex].sh_addr);
- if (setupindex)
- printk(KERN_WARNING "%s: Ignoring new-style "
- "parameters in presence of obsolete ones\n",
- mod->name);
- } else {
- /* Size of section 0 is 0, so this works well if no params */
- err = parse_args(mod->name, mod->args,
- (struct kernel_param *)
- sechdrs[setupindex].sh_addr,
- sechdrs[setupindex].sh_size
- / sizeof(struct kernel_param),
- NULL);
- }
+ if (obsparmindex)
+ printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
+ mod->name);
+
+ /* Size of section 0 is 0, so this works well if no params */
+ err = parse_args(mod->name, mod->args,
+ (struct kernel_param *)
+ sechdrs[setupindex].sh_addr,
+ sechdrs[setupindex].sh_size
+ / sizeof(struct kernel_param),
+ NULL);
if (err < 0)
goto arch_cleanup;
@@ -1972,13 +1799,13 @@ sys_init_module(void __user *umod,
return -EPERM;
/* Only one module load at a time, please */
- if (down_interruptible(&module_mutex) != 0)
+ if (mutex_lock_interruptible(&module_mutex) != 0)
return -EINTR;
/* Do all the hard work */
mod = load_module(umod, len, uargs);
if (IS_ERR(mod)) {
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
return PTR_ERR(mod);
}
@@ -1987,11 +1814,11 @@ sys_init_module(void __user *umod,
stop_machine_run(__link_module, mod, NR_CPUS);
/* Drop lock so they can recurse */
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
- down(&notify_mutex);
+ mutex_lock(&notify_mutex);
notifier_call_chain(&module_notify_list, MODULE_STATE_COMING, mod);
- up(&notify_mutex);
+ mutex_unlock(&notify_mutex);
/* Start the module */
if (mod->init != NULL)
@@ -2006,15 +1833,15 @@ sys_init_module(void __user *umod,
mod->name);
else {
module_put(mod);
- down(&module_mutex);
+ mutex_lock(&module_mutex);
free_module(mod);
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
}
return ret;
}
/* Now it's a first class citizen! */
- down(&module_mutex);
+ mutex_lock(&module_mutex);
mod->state = MODULE_STATE_LIVE;
/* Drop initial reference. */
module_put(mod);
@@ -2022,7 +1849,7 @@ sys_init_module(void __user *umod,
mod->module_init = NULL;
mod->init_size = 0;
mod->init_text_size = 0;
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
return 0;
}
@@ -2112,7 +1939,7 @@ struct module *module_get_kallsym(unsigned int symnum,
{
struct module *mod;
- down(&module_mutex);
+ mutex_lock(&module_mutex);
list_for_each_entry(mod, &modules, list) {
if (symnum < mod->num_symtab) {
*value = mod->symtab[symnum].st_value;
@@ -2120,12 +1947,12 @@ struct module *module_get_kallsym(unsigned int symnum,
strncpy(namebuf,
mod->strtab + mod->symtab[symnum].st_name,
127);
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
return mod;
}
symnum -= mod->num_symtab;
}
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
return NULL;
}
@@ -2168,7 +1995,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
struct list_head *i;
loff_t n = 0;
- down(&module_mutex);
+ mutex_lock(&module_mutex);
list_for_each(i, &modules) {
if (n++ == *pos)
break;
@@ -2189,7 +2016,7 @@ static void *m_next(struct seq_file *m, void *p, loff_t *pos)
static void m_stop(struct seq_file *m, void *p)
{
- up(&module_mutex);
+ mutex_unlock(&module_mutex);
}
static int m_show(struct seq_file *m, void *p)
diff --git a/kernel/panic.c b/kernel/panic.c
index 126dc43f1c7..acd95adddb9 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -20,10 +20,13 @@
#include <linux/nmi.h>
#include <linux/kexec.h>
-int panic_timeout;
int panic_on_oops;
int tainted;
+static int pause_on_oops;
+static int pause_on_oops_flag;
+static DEFINE_SPINLOCK(pause_on_oops_lock);
+int panic_timeout;
EXPORT_SYMBOL(panic_timeout);
struct notifier_block *panic_notifier_list;
@@ -174,3 +177,95 @@ void add_taint(unsigned flag)
tainted |= flag;
}
EXPORT_SYMBOL(add_taint);
+
+static int __init pause_on_oops_setup(char *str)
+{
+ pause_on_oops = simple_strtoul(str, NULL, 0);
+ return 1;
+}
+__setup("pause_on_oops=", pause_on_oops_setup);
+
+static void spin_msec(int msecs)
+{
+ int i;
+
+ for (i = 0; i < msecs; i++) {
+ touch_nmi_watchdog();
+ mdelay(1);
+ }
+}
+
+/*
+ * It just happens that oops_enter() and oops_exit() are identically
+ * implemented...
+ */
+static void do_oops_enter_exit(void)
+{
+ unsigned long flags;
+ static int spin_counter;
+
+ if (!pause_on_oops)
+ return;
+
+ spin_lock_irqsave(&pause_on_oops_lock, flags);
+ if (pause_on_oops_flag == 0) {
+ /* This CPU may now print the oops message */
+ pause_on_oops_flag = 1;
+ } else {
+ /* We need to stall this CPU */
+ if (!spin_counter) {
+ /* This CPU gets to do the counting */
+ spin_counter = pause_on_oops;
+ do {
+ spin_unlock(&pause_on_oops_lock);
+ spin_msec(MSEC_PER_SEC);
+ spin_lock(&pause_on_oops_lock);
+ } while (--spin_counter);
+ pause_on_oops_flag = 0;
+ } else {
+ /* This CPU waits for a different one */
+ while (spin_counter) {
+ spin_unlock(&pause_on_oops_lock);
+ spin_msec(1);
+ spin_lock(&pause_on_oops_lock);
+ }
+ }
+ }
+ spin_unlock_irqrestore(&pause_on_oops_lock, flags);
+}
+
+/*
+ * Return true if the calling CPU is allowed to print oops-related info. This
+ * is a bit racy..
+ */
+int oops_may_print(void)
+{
+ return pause_on_oops_flag == 0;
+}
+
+/*
+ * Called when the architecture enters its oops handler, before it prints
+ * anything. If this is the first CPU to oops, and it's oopsing the first time
+ * then let it proceed.
+ *
+ * This is all enabled by the pause_on_oops kernel boot option. We do all this
+ * to ensure that oopses don't scroll off the screen. It has the side-effect
+ * of preventing later-oopsing CPUs from mucking up the display, too.
+ *
+ * It turns out that the CPU which is allowed to print ends up pausing for the
+ * right duration, whereas all the other CPUs pause for twice as long: once in
+ * oops_enter(), once in oops_exit().
+ */
+void oops_enter(void)
+{
+ do_oops_enter_exit();
+}
+
+/*
+ * Called when the architecture exits its oops handler, after printing
+ * everything.
+ */
+void oops_exit(void)
+{
+ do_oops_enter_exit();
+}
diff --git a/kernel/params.c b/kernel/params.c
index a2915058231..9de637a5c8b 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -265,12 +265,12 @@ int param_get_invbool(char *buffer, struct kernel_param *kp)
}
/* We cheat here and temporarily mangle the string. */
-int param_array(const char *name,
- const char *val,
- unsigned int min, unsigned int max,
- void *elem, int elemsize,
- int (*set)(const char *, struct kernel_param *kp),
- int *num)
+static int param_array(const char *name,
+ const char *val,
+ unsigned int min, unsigned int max,
+ void *elem, int elemsize,
+ int (*set)(const char *, struct kernel_param *kp),
+ int *num)
{
int ret;
struct kernel_param kp;
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index fa895fc2ecf..9944379360b 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -35,6 +35,7 @@
#include <linux/interrupt.h>
#include <linux/slab.h>
#include <linux/time.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/semaphore.h>
diff --git a/kernel/power/Makefile b/kernel/power/Makefile
index 04be7d0d96a..8d0af3d37a4 100644
--- a/kernel/power/Makefile
+++ b/kernel/power/Makefile
@@ -5,7 +5,7 @@ endif
obj-y := main.o process.o console.o
obj-$(CONFIG_PM_LEGACY) += pm.o
-obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o
+obj-$(CONFIG_SOFTWARE_SUSPEND) += swsusp.o disk.o snapshot.o swap.o user.o
obj-$(CONFIG_SUSPEND_SMP) += smp.o
diff --git a/kernel/power/disk.c b/kernel/power/disk.c
index 0b43847dc98..81d4d982f3f 100644
--- a/kernel/power/disk.c
+++ b/kernel/power/disk.c
@@ -22,17 +22,6 @@
#include "power.h"
-extern suspend_disk_method_t pm_disk_mode;
-
-extern int swsusp_shrink_memory(void);
-extern int swsusp_suspend(void);
-extern int swsusp_write(struct pbe *pblist, unsigned int nr_pages);
-extern int swsusp_check(void);
-extern int swsusp_read(struct pbe **pblist_ptr);
-extern void swsusp_close(void);
-extern int swsusp_resume(void);
-
-
static int noresume = 0;
char resume_file[256] = CONFIG_PM_STD_PARTITION;
dev_t swsusp_resume_device;
@@ -70,10 +59,6 @@ static void power_down(suspend_disk_method_t mode)
while(1);
}
-
-static int in_suspend __nosavedata = 0;
-
-
static inline void platform_finish(void)
{
if (pm_disk_mode == PM_DISK_PLATFORM) {
@@ -87,7 +72,6 @@ static int prepare_processes(void)
int error;
pm_prepare_console();
- sys_sync();
disable_nonboot_cpus();
if (freeze_processes()) {
@@ -145,7 +129,7 @@ int pm_suspend_disk(void)
if (in_suspend) {
device_resume();
pr_debug("PM: writing image.\n");
- error = swsusp_write(pagedir_nosave, nr_copy_pages);
+ error = swsusp_write();
if (!error)
power_down(pm_disk_mode);
else {
@@ -216,7 +200,7 @@ static int software_resume(void)
pr_debug("PM: Reading swsusp image.\n");
- if ((error = swsusp_read(&pagedir_nosave))) {
+ if ((error = swsusp_read())) {
swsusp_free();
goto Thaw;
}
diff --git a/kernel/power/main.c b/kernel/power/main.c
index 9cb235cba4a..ee371f50cca 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -103,7 +103,7 @@ static int suspend_prepare(suspend_state_t state)
}
-static int suspend_enter(suspend_state_t state)
+int suspend_enter(suspend_state_t state)
{
int error = 0;
unsigned long flags;
diff --git a/kernel/power/pm.c b/kernel/power/pm.c
index 33c508e857d..0f6908cce1d 100644
--- a/kernel/power/pm.c
+++ b/kernel/power/pm.c
@@ -25,6 +25,7 @@
#include <linux/pm.h>
#include <linux/pm_legacy.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
int pm_active;
@@ -40,7 +41,7 @@ int pm_active;
* until a resume but that will be fine.
*/
-static DECLARE_MUTEX(pm_devs_lock);
+static DEFINE_MUTEX(pm_devs_lock);
static LIST_HEAD(pm_devs);
/**
@@ -67,9 +68,9 @@ struct pm_dev *pm_register(pm_dev_t type,
dev->id = id;
dev->callback = callback;
- down(&pm_devs_lock);
+ mutex_lock(&pm_devs_lock);
list_add(&dev->entry, &pm_devs);
- up(&pm_devs_lock);
+ mutex_unlock(&pm_devs_lock);
}
return dev;
}
@@ -85,9 +86,9 @@ struct pm_dev *pm_register(pm_dev_t type,
void pm_unregister(struct pm_dev *dev)
{
if (dev) {
- down(&pm_devs_lock);
+ mutex_lock(&pm_devs_lock);
list_del(&dev->entry);
- up(&pm_devs_lock);
+ mutex_unlock(&pm_devs_lock);
kfree(dev);
}
@@ -118,7 +119,7 @@ void pm_unregister_all(pm_callback callback)
if (!callback)
return;
- down(&pm_devs_lock);
+ mutex_lock(&pm_devs_lock);
entry = pm_devs.next;
while (entry != &pm_devs) {
struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
@@ -126,7 +127,7 @@ void pm_unregister_all(pm_callback callback)
if (dev->callback == callback)
__pm_unregister(dev);
}
- up(&pm_devs_lock);
+ mutex_unlock(&pm_devs_lock);
}
/**
@@ -234,7 +235,7 @@ int pm_send_all(pm_request_t rqst, void *data)
{
struct list_head *entry;
- down(&pm_devs_lock);
+ mutex_lock(&pm_devs_lock);
entry = pm_devs.next;
while (entry != &pm_devs) {
struct pm_dev *dev = list_entry(entry, struct pm_dev, entry);
@@ -246,13 +247,13 @@ int pm_send_all(pm_request_t rqst, void *data)
*/
if (rqst == PM_SUSPEND)
pm_undo_all(dev);
- up(&pm_devs_lock);
+ mutex_unlock(&pm_devs_lock);
return status;
}
}
entry = entry->next;
}
- up(&pm_devs_lock);
+ mutex_unlock(&pm_devs_lock);
return 0;
}
diff --git a/kernel/power/power.h b/kernel/power/power.h
index 388dba68084..f06f12f2176 100644
--- a/kernel/power/power.h
+++ b/kernel/power/power.h
@@ -8,6 +8,7 @@ struct swsusp_info {
int cpus;
unsigned long image_pages;
unsigned long pages;
+ unsigned long size;
} __attribute__((aligned(PAGE_SIZE)));
@@ -37,21 +38,79 @@ extern struct subsystem power_subsys;
/* References to section boundaries */
extern const void __nosave_begin, __nosave_end;
-extern unsigned int nr_copy_pages;
extern struct pbe *pagedir_nosave;
/* Preferred image size in bytes (default 500 MB) */
extern unsigned long image_size;
+extern int in_suspend;
+extern dev_t swsusp_resume_device;
extern asmlinkage int swsusp_arch_suspend(void);
extern asmlinkage int swsusp_arch_resume(void);
extern unsigned int count_data_pages(void);
-extern void free_pagedir(struct pbe *pblist);
-extern void release_eaten_pages(void);
-extern struct pbe *alloc_pagedir(unsigned nr_pages, gfp_t gfp_mask, int safe_needed);
+
+struct snapshot_handle {
+ loff_t offset;
+ unsigned int page;
+ unsigned int page_offset;
+ unsigned int prev;
+ struct pbe *pbe;
+ void *buffer;
+ unsigned int buf_offset;
+};
+
+#define data_of(handle) ((handle).buffer + (handle).buf_offset)
+
+extern int snapshot_read_next(struct snapshot_handle *handle, size_t count);
+extern int snapshot_write_next(struct snapshot_handle *handle, size_t count);
+int snapshot_image_loaded(struct snapshot_handle *handle);
+
+#define SNAPSHOT_IOC_MAGIC '3'
+#define SNAPSHOT_FREEZE _IO(SNAPSHOT_IOC_MAGIC, 1)
+#define SNAPSHOT_UNFREEZE _IO(SNAPSHOT_IOC_MAGIC, 2)
+#define SNAPSHOT_ATOMIC_SNAPSHOT _IOW(SNAPSHOT_IOC_MAGIC, 3, void *)
+#define SNAPSHOT_ATOMIC_RESTORE _IO(SNAPSHOT_IOC_MAGIC, 4)
+#define SNAPSHOT_FREE _IO(SNAPSHOT_IOC_MAGIC, 5)
+#define SNAPSHOT_SET_IMAGE_SIZE _IOW(SNAPSHOT_IOC_MAGIC, 6, unsigned long)
+#define SNAPSHOT_AVAIL_SWAP _IOR(SNAPSHOT_IOC_MAGIC, 7, void *)
+#define SNAPSHOT_GET_SWAP_PAGE _IOR(SNAPSHOT_IOC_MAGIC, 8, void *)
+#define SNAPSHOT_FREE_SWAP_PAGES _IO(SNAPSHOT_IOC_MAGIC, 9)
+#define SNAPSHOT_SET_SWAP_FILE _IOW(SNAPSHOT_IOC_MAGIC, 10, unsigned int)
+#define SNAPSHOT_S2RAM _IO(SNAPSHOT_IOC_MAGIC, 11)
+#define SNAPSHOT_IOC_MAXNR 11
+
+/**
+ * The bitmap is used for tracing allocated swap pages
+ *
+ * The entire bitmap consists of a number of bitmap_page
+ * structures linked with the help of the .next member.
+ * Thus each page can be allocated individually, so we only
+ * need to make 0-order memory allocations to create
+ * the bitmap.
+ */
+
+#define BITMAP_PAGE_SIZE (PAGE_SIZE - sizeof(void *))
+#define BITMAP_PAGE_CHUNKS (BITMAP_PAGE_SIZE / sizeof(long))
+#define BITS_PER_CHUNK (sizeof(long) * 8)
+#define BITMAP_PAGE_BITS (BITMAP_PAGE_CHUNKS * BITS_PER_CHUNK)
+
+struct bitmap_page {
+ unsigned long chunks[BITMAP_PAGE_CHUNKS];
+ struct bitmap_page *next;
+};
+
+extern void free_bitmap(struct bitmap_page *bitmap);
+extern struct bitmap_page *alloc_bitmap(unsigned int nr_bits);
+extern unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap);
+extern void free_all_swap_pages(int swap, struct bitmap_page *bitmap);
+
+extern int swsusp_check(void);
+extern int swsusp_shrink_memory(void);
extern void swsusp_free(void);
-extern int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed);
-extern unsigned int snapshot_nr_pages(void);
-extern struct pbe *snapshot_pblist(void);
-extern void snapshot_pblist_set(struct pbe *pblist);
+extern int swsusp_suspend(void);
+extern int swsusp_resume(void);
+extern int swsusp_read(void);
+extern int swsusp_write(void);
+extern void swsusp_close(void);
+extern int suspend_enter(suspend_state_t state);
diff --git a/kernel/power/process.c b/kernel/power/process.c
index 28de118f7a0..8ac7c35fad7 100644
--- a/kernel/power/process.c
+++ b/kernel/power/process.c
@@ -12,11 +12,12 @@
#include <linux/interrupt.h>
#include <linux/suspend.h>
#include <linux/module.h>
+#include <linux/syscalls.h>
/*
* Timeout for stopping processes
*/
-#define TIMEOUT (6 * HZ)
+#define TIMEOUT (20 * HZ)
static inline int freezeable(struct task_struct * p)
@@ -54,38 +55,62 @@ void refrigerator(void)
current->state = save;
}
+static inline void freeze_process(struct task_struct *p)
+{
+ unsigned long flags;
+
+ if (!freezing(p)) {
+ freeze(p);
+ spin_lock_irqsave(&p->sighand->siglock, flags);
+ signal_wake_up(p, 0);
+ spin_unlock_irqrestore(&p->sighand->siglock, flags);
+ }
+}
+
/* 0 = success, else # of processes that we failed to stop */
int freeze_processes(void)
{
- int todo;
+ int todo, nr_user, user_frozen;
unsigned long start_time;
struct task_struct *g, *p;
unsigned long flags;
printk( "Stopping tasks: " );
start_time = jiffies;
+ user_frozen = 0;
do {
- todo = 0;
+ nr_user = todo = 0;
read_lock(&tasklist_lock);
do_each_thread(g, p) {
if (!freezeable(p))
continue;
if (frozen(p))
continue;
-
- freeze(p);
- spin_lock_irqsave(&p->sighand->siglock, flags);
- signal_wake_up(p, 0);
- spin_unlock_irqrestore(&p->sighand->siglock, flags);
- todo++;
+ if (p->mm && !(p->flags & PF_BORROWED_MM)) {
+ /* The task is a user-space one.
+ * Freeze it unless there's a vfork completion
+ * pending
+ */
+ if (!p->vfork_done)
+ freeze_process(p);
+ nr_user++;
+ } else {
+ /* Freeze only if the user space is frozen */
+ if (user_frozen)
+ freeze_process(p);
+ todo++;
+ }
} while_each_thread(g, p);
read_unlock(&tasklist_lock);
+ todo += nr_user;
+ if (!user_frozen && !nr_user) {
+ sys_sync();
+ start_time = jiffies;
+ }
+ user_frozen = !nr_user;
yield(); /* Yield is okay here */
- if (todo && time_after(jiffies, start_time + TIMEOUT)) {
- printk( "\n" );
- printk(KERN_ERR " stopping tasks failed (%d tasks remaining)\n", todo );
+ if (todo && time_after(jiffies, start_time + TIMEOUT))
break;
- }
} while(todo);
/* This does not unfreeze processes that are already frozen
@@ -94,8 +119,14 @@ int freeze_processes(void)
* but it cleans up leftover PF_FREEZE requests.
*/
if (todo) {
+ printk( "\n" );
+ printk(KERN_ERR " stopping tasks timed out "
+ "after %d seconds (%d tasks remaining):\n",
+ TIMEOUT / HZ, todo);
read_lock(&tasklist_lock);
- do_each_thread(g, p)
+ do_each_thread(g, p) {
+ if (freezeable(p) && !frozen(p))
+ printk(KERN_ERR " %s\n", p->comm);
if (freezing(p)) {
pr_debug(" clean up: %s\n", p->comm);
p->flags &= ~PF_FREEZE;
@@ -103,7 +134,7 @@ int freeze_processes(void)
recalc_sigpending_tsk(p);
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}
- while_each_thread(g, p);
+ } while_each_thread(g, p);
read_unlock(&tasklist_lock);
return todo;
}
diff --git a/kernel/power/smp.c b/kernel/power/smp.c
index 911fc62b822..5957312b2d6 100644
--- a/kernel/power/smp.c
+++ b/kernel/power/smp.c
@@ -49,9 +49,7 @@ void enable_nonboot_cpus(void)
printk("Thawing cpus ...\n");
for_each_cpu_mask(cpu, frozen_cpus) {
- error = smp_prepare_cpu(cpu);
- if (!error)
- error = cpu_up(cpu);
+ error = cpu_up(cpu);
if (!error) {
printk("CPU%d is up\n", cpu);
continue;
diff --git a/kernel/power/snapshot.c b/kernel/power/snapshot.c
index 8d5a5986d62..c5863d02c89 100644
--- a/kernel/power/snapshot.c
+++ b/kernel/power/snapshot.c
@@ -10,6 +10,7 @@
*/
+#include <linux/version.h>
#include <linux/module.h>
#include <linux/mm.h>
#include <linux/suspend.h>
@@ -34,7 +35,9 @@
#include "power.h"
struct pbe *pagedir_nosave;
-unsigned int nr_copy_pages;
+static unsigned int nr_copy_pages;
+static unsigned int nr_meta_pages;
+static unsigned long *buffer;
#ifdef CONFIG_HIGHMEM
unsigned int count_highmem_pages(void)
@@ -80,7 +83,7 @@ static int save_highmem_zone(struct zone *zone)
void *kaddr;
unsigned long pfn = zone_pfn + zone->zone_start_pfn;
- if (!(pfn%1000))
+ if (!(pfn%10000))
printk(".");
if (!pfn_valid(pfn))
continue;
@@ -119,13 +122,15 @@ int save_highmem(void)
struct zone *zone;
int res = 0;
- pr_debug("swsusp: Saving Highmem\n");
+ pr_debug("swsusp: Saving Highmem");
+ drain_local_pages();
for_each_zone (zone) {
if (is_highmem(zone))
res = save_highmem_zone(zone);
if (res)
return res;
}
+ printk("\n");
return 0;
}
@@ -235,7 +240,7 @@ static void copy_data_pages(struct pbe *pblist)
* free_pagedir - free pages allocated with alloc_pagedir()
*/
-void free_pagedir(struct pbe *pblist)
+static void free_pagedir(struct pbe *pblist)
{
struct pbe *pbe;
@@ -301,7 +306,7 @@ struct eaten_page {
static struct eaten_page *eaten_pages = NULL;
-void release_eaten_pages(void)
+static void release_eaten_pages(void)
{
struct eaten_page *p, *q;
@@ -376,7 +381,6 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed
if (!nr_pages)
return NULL;
- pr_debug("alloc_pagedir(): nr_pages = %d\n", nr_pages);
pblist = alloc_image_page(gfp_mask, safe_needed);
/* FIXME: rewrite this ugly loop */
for (pbe = pblist, num = PBES_PER_PAGE; pbe && num < nr_pages;
@@ -388,7 +392,7 @@ struct pbe *alloc_pagedir(unsigned int nr_pages, gfp_t gfp_mask, int safe_needed
free_pagedir(pblist);
pblist = NULL;
} else
- create_pbe_list(pblist, nr_pages);
+ create_pbe_list(pblist, nr_pages);
return pblist;
}
@@ -414,6 +418,10 @@ void swsusp_free(void)
}
}
}
+ nr_copy_pages = 0;
+ nr_meta_pages = 0;
+ pagedir_nosave = NULL;
+ buffer = NULL;
}
@@ -437,7 +445,7 @@ static int enough_free_mem(unsigned int nr_pages)
(nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
}
-int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed)
+static int alloc_data_pages(struct pbe *pblist, gfp_t gfp_mask, int safe_needed)
{
struct pbe *p;
@@ -504,7 +512,318 @@ asmlinkage int swsusp_save(void)
*/
nr_copy_pages = nr_pages;
+ nr_meta_pages = (nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT;
printk("swsusp: critical section/: done (%d pages copied)\n", nr_pages);
return 0;
}
+
+static void init_header(struct swsusp_info *info)
+{
+ memset(info, 0, sizeof(struct swsusp_info));
+ info->version_code = LINUX_VERSION_CODE;
+ info->num_physpages = num_physpages;
+ memcpy(&info->uts, &system_utsname, sizeof(system_utsname));
+ info->cpus = num_online_cpus();
+ info->image_pages = nr_copy_pages;
+ info->pages = nr_copy_pages + nr_meta_pages + 1;
+ info->size = info->pages;
+ info->size <<= PAGE_SHIFT;
+}
+
+/**
+ * pack_orig_addresses - the .orig_address fields of the PBEs from the
+ * list starting at @pbe are stored in the array @buf[] (1 page)
+ */
+
+static inline struct pbe *pack_orig_addresses(unsigned long *buf, struct pbe *pbe)
+{
+ int j;
+
+ for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
+ buf[j] = pbe->orig_address;
+ pbe = pbe->next;
+ }
+ if (!pbe)
+ for (; j < PAGE_SIZE / sizeof(long); j++)
+ buf[j] = 0;
+ return pbe;
+}
+
+/**
+ * snapshot_read_next - used for reading the system memory snapshot.
+ *
+ * On the first call to it @handle should point to a zeroed
+ * snapshot_handle structure. The structure gets updated and a pointer
+ * to it should be passed to this function every next time.
+ *
+ * The @count parameter should contain the number of bytes the caller
+ * wants to read from the snapshot. It must not be zero.
+ *
+ * On success the function returns a positive number. Then, the caller
+ * is allowed to read up to the returned number of bytes from the memory
+ * location computed by the data_of() macro. The number returned
+ * may be smaller than @count, but this only happens if the read would
+ * cross a page boundary otherwise.
+ *
+ * The function returns 0 to indicate the end of data stream condition,
+ * and a negative number is returned on error. In such cases the
+ * structure pointed to by @handle is not updated and should not be used
+ * any more.
+ */
+
+int snapshot_read_next(struct snapshot_handle *handle, size_t count)
+{
+ if (handle->page > nr_meta_pages + nr_copy_pages)
+ return 0;
+ if (!buffer) {
+ /* This makes the buffer be freed by swsusp_free() */
+ buffer = alloc_image_page(GFP_ATOMIC, 0);
+ if (!buffer)
+ return -ENOMEM;
+ }
+ if (!handle->offset) {
+ init_header((struct swsusp_info *)buffer);
+ handle->buffer = buffer;
+ handle->pbe = pagedir_nosave;
+ }
+ if (handle->prev < handle->page) {
+ if (handle->page <= nr_meta_pages) {
+ handle->pbe = pack_orig_addresses(buffer, handle->pbe);
+ if (!handle->pbe)
+ handle->pbe = pagedir_nosave;
+ } else {
+ handle->buffer = (void *)handle->pbe->address;
+ handle->pbe = handle->pbe->next;
+ }
+ handle->prev = handle->page;
+ }
+ handle->buf_offset = handle->page_offset;
+ if (handle->page_offset + count >= PAGE_SIZE) {
+ count = PAGE_SIZE - handle->page_offset;
+ handle->page_offset = 0;
+ handle->page++;
+ } else {
+ handle->page_offset += count;
+ }
+ handle->offset += count;
+ return count;
+}
+
+/**
+ * mark_unsafe_pages - mark the pages that cannot be used for storing
+ * the image during resume, because they conflict with the pages that
+ * had been used before suspend
+ */
+
+static int mark_unsafe_pages(struct pbe *pblist)
+{
+ struct zone *zone;
+ unsigned long zone_pfn;
+ struct pbe *p;
+
+ if (!pblist) /* a sanity check */
+ return -EINVAL;
+
+ /* Clear page flags */
+ for_each_zone (zone) {
+ for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
+ if (pfn_valid(zone_pfn + zone->zone_start_pfn))
+ ClearPageNosaveFree(pfn_to_page(zone_pfn +
+ zone->zone_start_pfn));
+ }
+
+ /* Mark orig addresses */
+ for_each_pbe (p, pblist) {
+ if (virt_addr_valid(p->orig_address))
+ SetPageNosaveFree(virt_to_page(p->orig_address));
+ else
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+static void copy_page_backup_list(struct pbe *dst, struct pbe *src)
+{
+ /* We assume both lists contain the same number of elements */
+ while (src) {
+ dst->orig_address = src->orig_address;
+ dst = dst->next;
+ src = src->next;
+ }
+}
+
+static int check_header(struct swsusp_info *info)
+{
+ char *reason = NULL;
+
+ if (info->version_code != LINUX_VERSION_CODE)
+ reason = "kernel version";
+ if (info->num_physpages != num_physpages)
+ reason = "memory size";
+ if (strcmp(info->uts.sysname,system_utsname.sysname))
+ reason = "system type";
+ if (strcmp(info->uts.release,system_utsname.release))
+ reason = "kernel release";
+ if (strcmp(info->uts.version,system_utsname.version))
+ reason = "version";
+ if (strcmp(info->uts.machine,system_utsname.machine))
+ reason = "machine";
+ if (reason) {
+ printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason);
+ return -EPERM;
+ }
+ return 0;
+}
+
+/**
+ * load header - check the image header and copy data from it
+ */
+
+static int load_header(struct snapshot_handle *handle,
+ struct swsusp_info *info)
+{
+ int error;
+ struct pbe *pblist;
+
+ error = check_header(info);
+ if (!error) {
+ pblist = alloc_pagedir(info->image_pages, GFP_ATOMIC, 0);
+ if (!pblist)
+ return -ENOMEM;
+ pagedir_nosave = pblist;
+ handle->pbe = pblist;
+ nr_copy_pages = info->image_pages;
+ nr_meta_pages = info->pages - info->image_pages - 1;
+ }
+ return error;
+}
+
+/**
+ * unpack_orig_addresses - copy the elements of @buf[] (1 page) to
+ * the PBEs in the list starting at @pbe
+ */
+
+static inline struct pbe *unpack_orig_addresses(unsigned long *buf,
+ struct pbe *pbe)
+{
+ int j;
+
+ for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
+ pbe->orig_address = buf[j];
+ pbe = pbe->next;
+ }
+ return pbe;
+}
+
+/**
+ * create_image - use metadata contained in the PBE list
+ * pointed to by pagedir_nosave to mark the pages that will
+ * be overwritten in the process of restoring the system
+ * memory state from the image and allocate memory for
+ * the image avoiding these pages
+ */
+
+static int create_image(struct snapshot_handle *handle)
+{
+ int error = 0;
+ struct pbe *p, *pblist;
+
+ p = pagedir_nosave;
+ error = mark_unsafe_pages(p);
+ if (!error) {
+ pblist = alloc_pagedir(nr_copy_pages, GFP_ATOMIC, 1);
+ if (pblist)
+ copy_page_backup_list(pblist, p);
+ free_pagedir(p);
+ if (!pblist)
+ error = -ENOMEM;
+ }
+ if (!error)
+ error = alloc_data_pages(pblist, GFP_ATOMIC, 1);
+ if (!error) {
+ release_eaten_pages();
+ pagedir_nosave = pblist;
+ } else {
+ pagedir_nosave = NULL;
+ handle->pbe = NULL;
+ nr_copy_pages = 0;
+ nr_meta_pages = 0;
+ }
+ return error;
+}
+
+/**
+ * snapshot_write_next - used for writing the system memory snapshot.
+ *
+ * On the first call to it @handle should point to a zeroed
+ * snapshot_handle structure. The structure gets updated and a pointer
+ * to it should be passed to this function every next time.
+ *
+ * The @count parameter should contain the number of bytes the caller
+ * wants to write to the image. It must not be zero.
+ *
+ * On success the function returns a positive number. Then, the caller
+ * is allowed to write up to the returned number of bytes to the memory
+ * location computed by the data_of() macro. The number returned
+ * may be smaller than @count, but this only happens if the write would
+ * cross a page boundary otherwise.
+ *
+ * The function returns 0 to indicate the "end of file" condition,
+ * and a negative number is returned on error. In such cases the
+ * structure pointed to by @handle is not updated and should not be used
+ * any more.
+ */
+
+int snapshot_write_next(struct snapshot_handle *handle, size_t count)
+{
+ int error = 0;
+
+ if (handle->prev && handle->page > nr_meta_pages + nr_copy_pages)
+ return 0;
+ if (!buffer) {
+ /* This makes the buffer be freed by swsusp_free() */
+ buffer = alloc_image_page(GFP_ATOMIC, 0);
+ if (!buffer)
+ return -ENOMEM;
+ }
+ if (!handle->offset)
+ handle->buffer = buffer;
+ if (handle->prev < handle->page) {
+ if (!handle->prev) {
+ error = load_header(handle, (struct swsusp_info *)buffer);
+ if (error)
+ return error;
+ } else if (handle->prev <= nr_meta_pages) {
+ handle->pbe = unpack_orig_addresses(buffer, handle->pbe);
+ if (!handle->pbe) {
+ error = create_image(handle);
+ if (error)
+ return error;
+ handle->pbe = pagedir_nosave;
+ handle->buffer = (void *)handle->pbe->address;
+ }
+ } else {
+ handle->pbe = handle->pbe->next;
+ handle->buffer = (void *)handle->pbe->address;
+ }
+ handle->prev = handle->page;
+ }
+ handle->buf_offset = handle->page_offset;
+ if (handle->page_offset + count >= PAGE_SIZE) {
+ count = PAGE_SIZE - handle->page_offset;
+ handle->page_offset = 0;
+ handle->page++;
+ } else {
+ handle->page_offset += count;
+ }
+ handle->offset += count;
+ return count;
+}
+
+int snapshot_image_loaded(struct snapshot_handle *handle)
+{
+ return !(!handle->pbe || handle->pbe->next || !nr_copy_pages ||
+ handle->page <= nr_meta_pages + nr_copy_pages);
+}
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
new file mode 100644
index 00000000000..9177f3f73a6
--- /dev/null
+++ b/kernel/power/swap.c
@@ -0,0 +1,544 @@
+/*
+ * linux/kernel/power/swap.c
+ *
+ * This file provides functions for reading the suspend image from
+ * and writing it to a swap partition.
+ *
+ * Copyright (C) 1998,2001-2005 Pavel Machek <pavel@suse.cz>
+ * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
+ *
+ * This file is released under the GPLv2.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/smp_lock.h>
+#include <linux/file.h>
+#include <linux/utsname.h>
+#include <linux/version.h>
+#include <linux/delay.h>
+#include <linux/bitops.h>
+#include <linux/genhd.h>
+#include <linux/device.h>
+#include <linux/buffer_head.h>
+#include <linux/bio.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
+#include <linux/pm.h>
+
+#include "power.h"
+
+extern char resume_file[];
+
+#define SWSUSP_SIG "S1SUSPEND"
+
+static struct swsusp_header {
+ char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
+ swp_entry_t image;
+ char orig_sig[10];
+ char sig[10];
+} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
+
+/*
+ * Saving part...
+ */
+
+static unsigned short root_swap = 0xffff;
+
+static int mark_swapfiles(swp_entry_t start)
+{
+ int error;
+
+ rw_swap_page_sync(READ,
+ swp_entry(root_swap, 0),
+ virt_to_page((unsigned long)&swsusp_header));
+ if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
+ !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
+ memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
+ memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
+ swsusp_header.image = start;
+ error = rw_swap_page_sync(WRITE,
+ swp_entry(root_swap, 0),
+ virt_to_page((unsigned long)
+ &swsusp_header));
+ } else {
+ pr_debug("swsusp: Partition is not swap space.\n");
+ error = -ENODEV;
+ }
+ return error;
+}
+
+/**
+ * swsusp_swap_check - check if the resume device is a swap device
+ * and get its index (if so)
+ */
+
+static int swsusp_swap_check(void) /* This is called before saving image */
+{
+ int res = swap_type_of(swsusp_resume_device);
+
+ if (res >= 0) {
+ root_swap = res;
+ return 0;
+ }
+ return res;
+}
+
+/**
+ * write_page - Write one page to given swap location.
+ * @buf: Address we're writing.
+ * @offset: Offset of the swap page we're writing to.
+ */
+
+static int write_page(void *buf, unsigned long offset)
+{
+ swp_entry_t entry;
+ int error = -ENOSPC;
+
+ if (offset) {
+ entry = swp_entry(root_swap, offset);
+ error = rw_swap_page_sync(WRITE, entry, virt_to_page(buf));
+ }
+ return error;
+}
+
+/*
+ * The swap map is a data structure used for keeping track of each page
+ * written to a swap partition. It consists of many swap_map_page
+ * structures that contain each an array of MAP_PAGE_SIZE swap entries.
+ * These structures are stored on the swap and linked together with the
+ * help of the .next_swap member.
+ *
+ * The swap map is created during suspend. The swap map pages are
+ * allocated and populated one at a time, so we only need one memory
+ * page to set up the entire structure.
+ *
+ * During resume we also only need to use one swap_map_page structure
+ * at a time.
+ */
+
+#define MAP_PAGE_ENTRIES (PAGE_SIZE / sizeof(long) - 1)
+
+struct swap_map_page {
+ unsigned long entries[MAP_PAGE_ENTRIES];
+ unsigned long next_swap;
+};
+
+/**
+ * The swap_map_handle structure is used for handling swap in
+ * a file-alike way
+ */
+
+struct swap_map_handle {
+ struct swap_map_page *cur;
+ unsigned long cur_swap;
+ struct bitmap_page *bitmap;
+ unsigned int k;
+};
+
+static void release_swap_writer(struct swap_map_handle *handle)
+{
+ if (handle->cur)
+ free_page((unsigned long)handle->cur);
+ handle->cur = NULL;
+ if (handle->bitmap)
+ free_bitmap(handle->bitmap);
+ handle->bitmap = NULL;
+}
+
+static int get_swap_writer(struct swap_map_handle *handle)
+{
+ handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_KERNEL);
+ if (!handle->cur)
+ return -ENOMEM;
+ handle->bitmap = alloc_bitmap(count_swap_pages(root_swap, 0));
+ if (!handle->bitmap) {
+ release_swap_writer(handle);
+ return -ENOMEM;
+ }
+ handle->cur_swap = alloc_swap_page(root_swap, handle->bitmap);
+ if (!handle->cur_swap) {
+ release_swap_writer(handle);
+ return -ENOSPC;
+ }
+ handle->k = 0;
+ return 0;
+}
+
+static int swap_write_page(struct swap_map_handle *handle, void *buf)
+{
+ int error;
+ unsigned long offset;
+
+ if (!handle->cur)
+ return -EINVAL;
+ offset = alloc_swap_page(root_swap, handle->bitmap);
+ error = write_page(buf, offset);
+ if (error)
+ return error;
+ handle->cur->entries[handle->k++] = offset;
+ if (handle->k >= MAP_PAGE_ENTRIES) {
+ offset = alloc_swap_page(root_swap, handle->bitmap);
+ if (!offset)
+ return -ENOSPC;
+ handle->cur->next_swap = offset;
+ error = write_page(handle->cur, handle->cur_swap);
+ if (error)
+ return error;
+ memset(handle->cur, 0, PAGE_SIZE);
+ handle->cur_swap = offset;
+ handle->k = 0;
+ }
+ return 0;
+}
+
+static int flush_swap_writer(struct swap_map_handle *handle)
+{
+ if (handle->cur && handle->cur_swap)
+ return write_page(handle->cur, handle->cur_swap);
+ else
+ return -EINVAL;
+}
+
+/**
+ * save_image - save the suspend image data
+ */
+
+static int save_image(struct swap_map_handle *handle,
+ struct snapshot_handle *snapshot,
+ unsigned int nr_pages)
+{
+ unsigned int m;
+ int ret;
+ int error = 0;
+
+ printk("Saving image data pages (%u pages) ... ", nr_pages);
+ m = nr_pages / 100;
+ if (!m)
+ m = 1;
+ nr_pages = 0;
+ do {
+ ret = snapshot_read_next(snapshot, PAGE_SIZE);
+ if (ret > 0) {
+ error = swap_write_page(handle, data_of(*snapshot));
+ if (error)
+ break;
+ if (!(nr_pages % m))
+ printk("\b\b\b\b%3d%%", nr_pages / m);
+ nr_pages++;
+ }
+ } while (ret > 0);
+ if (!error)
+ printk("\b\b\b\bdone\n");
+ return error;
+}
+
+/**
+ * enough_swap - Make sure we have enough swap to save the image.
+ *
+ * Returns TRUE or FALSE after checking the total amount of swap
+ * space avaiable from the resume partition.
+ */
+
+static int enough_swap(unsigned int nr_pages)
+{
+ unsigned int free_swap = count_swap_pages(root_swap, 1);
+
+ pr_debug("swsusp: free swap pages: %u\n", free_swap);
+ return free_swap > (nr_pages + PAGES_FOR_IO +
+ (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
+}
+
+/**
+ * swsusp_write - Write entire image and metadata.
+ *
+ * It is important _NOT_ to umount filesystems at this point. We want
+ * them synced (in case something goes wrong) but we DO not want to mark
+ * filesystem clean: it is not. (And it does not matter, if we resume
+ * correctly, we'll mark system clean, anyway.)
+ */
+
+int swsusp_write(void)
+{
+ struct swap_map_handle handle;
+ struct snapshot_handle snapshot;
+ struct swsusp_info *header;
+ unsigned long start;
+ int error;
+
+ if ((error = swsusp_swap_check())) {
+ printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
+ return error;
+ }
+ memset(&snapshot, 0, sizeof(struct snapshot_handle));
+ error = snapshot_read_next(&snapshot, PAGE_SIZE);
+ if (error < PAGE_SIZE)
+ return error < 0 ? error : -EFAULT;
+ header = (struct swsusp_info *)data_of(snapshot);
+ if (!enough_swap(header->pages)) {
+ printk(KERN_ERR "swsusp: Not enough free swap\n");
+ return -ENOSPC;
+ }
+ error = get_swap_writer(&handle);
+ if (!error) {
+ start = handle.cur_swap;
+ error = swap_write_page(&handle, header);
+ }
+ if (!error)
+ error = save_image(&handle, &snapshot, header->pages - 1);
+ if (!error) {
+ flush_swap_writer(&handle);
+ printk("S");
+ error = mark_swapfiles(swp_entry(root_swap, start));
+ printk("|\n");
+ }
+ if (error)
+ free_all_swap_pages(root_swap, handle.bitmap);
+ release_swap_writer(&handle);
+ return error;
+}
+
+/*
+ * Using bio to read from swap.
+ * This code requires a bit more work than just using buffer heads
+ * but, it is the recommended way for 2.5/2.6.
+ * The following are to signal the beginning and end of I/O. Bios
+ * finish asynchronously, while we want them to happen synchronously.
+ * A simple atomic_t, and a wait loop take care of this problem.
+ */
+
+static atomic_t io_done = ATOMIC_INIT(0);
+
+static int end_io(struct bio *bio, unsigned int num, int err)
+{
+ if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
+ panic("I/O error reading memory image");
+ atomic_set(&io_done, 0);
+ return 0;
+}
+
+static struct block_device *resume_bdev;
+
+/**
+ * submit - submit BIO request.
+ * @rw: READ or WRITE.
+ * @off physical offset of page.
+ * @page: page we're reading or writing.
+ *
+ * Straight from the textbook - allocate and initialize the bio.
+ * If we're writing, make sure the page is marked as dirty.
+ * Then submit it and wait.
+ */
+
+static int submit(int rw, pgoff_t page_off, void *page)
+{
+ int error = 0;
+ struct bio *bio;
+
+ bio = bio_alloc(GFP_ATOMIC, 1);
+ if (!bio)
+ return -ENOMEM;
+ bio->bi_sector = page_off * (PAGE_SIZE >> 9);
+ bio->bi_bdev = resume_bdev;
+ bio->bi_end_io = end_io;
+
+ if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
+ printk("swsusp: ERROR: adding page to bio at %ld\n",page_off);
+ error = -EFAULT;
+ goto Done;
+ }
+
+ atomic_set(&io_done, 1);
+ submit_bio(rw | (1 << BIO_RW_SYNC), bio);
+ while (atomic_read(&io_done))
+ yield();
+ if (rw == READ)
+ bio_set_pages_dirty(bio);
+ Done:
+ bio_put(bio);
+ return error;
+}
+
+static int bio_read_page(pgoff_t page_off, void *page)
+{
+ return submit(READ, page_off, page);
+}
+
+static int bio_write_page(pgoff_t page_off, void *page)
+{
+ return submit(WRITE, page_off, page);
+}
+
+/**
+ * The following functions allow us to read data using a swap map
+ * in a file-alike way
+ */
+
+static void release_swap_reader(struct swap_map_handle *handle)
+{
+ if (handle->cur)
+ free_page((unsigned long)handle->cur);
+ handle->cur = NULL;
+}
+
+static int get_swap_reader(struct swap_map_handle *handle,
+ swp_entry_t start)
+{
+ int error;
+
+ if (!swp_offset(start))
+ return -EINVAL;
+ handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
+ if (!handle->cur)
+ return -ENOMEM;
+ error = bio_read_page(swp_offset(start), handle->cur);
+ if (error) {
+ release_swap_reader(handle);
+ return error;
+ }
+ handle->k = 0;
+ return 0;
+}
+
+static int swap_read_page(struct swap_map_handle *handle, void *buf)
+{
+ unsigned long offset;
+ int error;
+
+ if (!handle->cur)
+ return -EINVAL;
+ offset = handle->cur->entries[handle->k];
+ if (!offset)
+ return -EFAULT;
+ error = bio_read_page(offset, buf);
+ if (error)
+ return error;
+ if (++handle->k >= MAP_PAGE_ENTRIES) {
+ handle->k = 0;
+ offset = handle->cur->next_swap;
+ if (!offset)
+ release_swap_reader(handle);
+ else
+ error = bio_read_page(offset, handle->cur);
+ }
+ return error;
+}
+
+/**
+ * load_image - load the image using the swap map handle
+ * @handle and the snapshot handle @snapshot
+ * (assume there are @nr_pages pages to load)
+ */
+
+static int load_image(struct swap_map_handle *handle,
+ struct snapshot_handle *snapshot,
+ unsigned int nr_pages)
+{
+ unsigned int m;
+ int ret;
+ int error = 0;
+
+ printk("Loading image data pages (%u pages) ... ", nr_pages);
+ m = nr_pages / 100;
+ if (!m)
+ m = 1;
+ nr_pages = 0;
+ do {
+ ret = snapshot_write_next(snapshot, PAGE_SIZE);
+ if (ret > 0) {
+ error = swap_read_page(handle, data_of(*snapshot));
+ if (error)
+ break;
+ if (!(nr_pages % m))
+ printk("\b\b\b\b%3d%%", nr_pages / m);
+ nr_pages++;
+ }
+ } while (ret > 0);
+ if (!error)
+ printk("\b\b\b\bdone\n");
+ if (!snapshot_image_loaded(snapshot))
+ error = -ENODATA;
+ return error;
+}
+
+int swsusp_read(void)
+{
+ int error;
+ struct swap_map_handle handle;
+ struct snapshot_handle snapshot;
+ struct swsusp_info *header;
+
+ if (IS_ERR(resume_bdev)) {
+ pr_debug("swsusp: block device not initialised\n");
+ return PTR_ERR(resume_bdev);
+ }
+
+ memset(&snapshot, 0, sizeof(struct snapshot_handle));
+ error = snapshot_write_next(&snapshot, PAGE_SIZE);
+ if (error < PAGE_SIZE)
+ return error < 0 ? error : -EFAULT;
+ header = (struct swsusp_info *)data_of(snapshot);
+ error = get_swap_reader(&handle, swsusp_header.image);
+ if (!error)
+ error = swap_read_page(&handle, header);
+ if (!error)
+ error = load_image(&handle, &snapshot, header->pages - 1);
+ release_swap_reader(&handle);
+
+ blkdev_put(resume_bdev);
+
+ if (!error)
+ pr_debug("swsusp: Reading resume file was successful\n");
+ else
+ pr_debug("swsusp: Error %d resuming\n", error);
+ return error;
+}
+
+/**
+ * swsusp_check - Check for swsusp signature in the resume device
+ */
+
+int swsusp_check(void)
+{
+ int error;
+
+ resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
+ if (!IS_ERR(resume_bdev)) {
+ set_blocksize(resume_bdev, PAGE_SIZE);
+ memset(&swsusp_header, 0, sizeof(swsusp_header));
+ if ((error = bio_read_page(0, &swsusp_header)))
+ return error;
+ if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
+ memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
+ /* Reset swap signature now */
+ error = bio_write_page(0, &swsusp_header);
+ } else {
+ return -EINVAL;
+ }
+ if (error)
+ blkdev_put(resume_bdev);
+ else
+ pr_debug("swsusp: Signature found, resuming\n");
+ } else {
+ error = PTR_ERR(resume_bdev);
+ }
+
+ if (error)
+ pr_debug("swsusp: Error %d check for resume file\n", error);
+
+ return error;
+}
+
+/**
+ * swsusp_close - close swap device.
+ */
+
+void swsusp_close(void)
+{
+ if (IS_ERR(resume_bdev)) {
+ pr_debug("swsusp: block device not initialised\n");
+ return;
+ }
+
+ blkdev_put(resume_bdev);
+}
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c
index 2d9d08f72f7..c4016cbbd3e 100644
--- a/kernel/power/swsusp.c
+++ b/kernel/power/swsusp.c
@@ -31,41 +31,24 @@
* Fixed runaway init
*
* Rafael J. Wysocki <rjw@sisk.pl>
- * Added the swap map data structure and reworked the handling of swap
+ * Reworked the freeing of memory and the handling of swap
*
* More state savers are welcome. Especially for the scsi layer...
*
* For TODOs,FIXMEs also look in Documentation/power/swsusp.txt
*/
-#include <linux/module.h>
#include <linux/mm.h>
#include <linux/suspend.h>
-#include <linux/smp_lock.h>
-#include <linux/file.h>
-#include <linux/utsname.h>
-#include <linux/version.h>
-#include <linux/delay.h>
-#include <linux/bitops.h>
#include <linux/spinlock.h>
-#include <linux/genhd.h>
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/swap.h>
#include <linux/pm.h>
-#include <linux/device.h>
-#include <linux/buffer_head.h>
#include <linux/swapops.h>
#include <linux/bootmem.h>
#include <linux/syscalls.h>
#include <linux/highmem.h>
-#include <linux/bio.h>
-
-#include <asm/uaccess.h>
-#include <asm/mmu_context.h>
-#include <asm/pgtable.h>
-#include <asm/tlbflush.h>
-#include <asm/io.h>
#include "power.h"
@@ -77,6 +60,8 @@
*/
unsigned long image_size = 500 * 1024 * 1024;
+int in_suspend __nosavedata = 0;
+
#ifdef CONFIG_HIGHMEM
unsigned int count_highmem_pages(void);
int save_highmem(void);
@@ -87,471 +72,97 @@ static int restore_highmem(void) { return 0; }
static unsigned int count_highmem_pages(void) { return 0; }
#endif
-extern char resume_file[];
-
-#define SWSUSP_SIG "S1SUSPEND"
-
-static struct swsusp_header {
- char reserved[PAGE_SIZE - 20 - sizeof(swp_entry_t)];
- swp_entry_t image;
- char orig_sig[10];
- char sig[10];
-} __attribute__((packed, aligned(PAGE_SIZE))) swsusp_header;
-
-static struct swsusp_info swsusp_info;
-
-/*
- * Saving part...
- */
-
-static unsigned short root_swap = 0xffff;
-
-static int mark_swapfiles(swp_entry_t start)
-{
- int error;
-
- rw_swap_page_sync(READ,
- swp_entry(root_swap, 0),
- virt_to_page((unsigned long)&swsusp_header));
- if (!memcmp("SWAP-SPACE",swsusp_header.sig, 10) ||
- !memcmp("SWAPSPACE2",swsusp_header.sig, 10)) {
- memcpy(swsusp_header.orig_sig,swsusp_header.sig, 10);
- memcpy(swsusp_header.sig,SWSUSP_SIG, 10);
- swsusp_header.image = start;
- error = rw_swap_page_sync(WRITE,
- swp_entry(root_swap, 0),
- virt_to_page((unsigned long)
- &swsusp_header));
- } else {
- pr_debug("swsusp: Partition is not swap space.\n");
- error = -ENODEV;
- }
- return error;
-}
-
-/*
- * Check whether the swap device is the specified resume
- * device, irrespective of whether they are specified by
- * identical names.
- *
- * (Thus, device inode aliasing is allowed. You can say /dev/hda4
- * instead of /dev/ide/host0/bus0/target0/lun0/part4 [if using devfs]
- * and they'll be considered the same device. This is *necessary* for
- * devfs, since the resume code can only recognize the form /dev/hda4,
- * but the suspend code would see the long name.)
- */
-static inline int is_resume_device(const struct swap_info_struct *swap_info)
-{
- struct file *file = swap_info->swap_file;
- struct inode *inode = file->f_dentry->d_inode;
-
- return S_ISBLK(inode->i_mode) &&
- swsusp_resume_device == MKDEV(imajor(inode), iminor(inode));
-}
-
-static int swsusp_swap_check(void) /* This is called before saving image */
-{
- int i;
-
- spin_lock(&swap_lock);
- for (i = 0; i < MAX_SWAPFILES; i++) {
- if (!(swap_info[i].flags & SWP_WRITEOK))
- continue;
- if (!swsusp_resume_device || is_resume_device(swap_info + i)) {
- spin_unlock(&swap_lock);
- root_swap = i;
- return 0;
- }
- }
- spin_unlock(&swap_lock);
- return -ENODEV;
-}
-
-/**
- * write_page - Write one page to a fresh swap location.
- * @addr: Address we're writing.
- * @loc: Place to store the entry we used.
- *
- * Allocate a new swap entry and 'sync' it. Note we discard -EIO
- * errors. That is an artifact left over from swsusp. It did not
- * check the return of rw_swap_page_sync() at all, since most pages
- * written back to swap would return -EIO.
- * This is a partial improvement, since we will at least return other
- * errors, though we need to eventually fix the damn code.
- */
-static int write_page(unsigned long addr, swp_entry_t *loc)
-{
- swp_entry_t entry;
- int error = -ENOSPC;
-
- entry = get_swap_page_of_type(root_swap);
- if (swp_offset(entry)) {
- error = rw_swap_page_sync(WRITE, entry, virt_to_page(addr));
- if (!error || error == -EIO)
- *loc = entry;
- }
- return error;
-}
-
/**
- * Swap map-handling functions
- *
- * The swap map is a data structure used for keeping track of each page
- * written to the swap. It consists of many swap_map_page structures
- * that contain each an array of MAP_PAGE_SIZE swap entries.
- * These structures are linked together with the help of either the
- * .next (in memory) or the .next_swap (in swap) member.
+ * The following functions are used for tracing the allocated
+ * swap pages, so that they can be freed in case of an error.
*
- * The swap map is created during suspend. At that time we need to keep
- * it in memory, because we have to free all of the allocated swap
- * entries if an error occurs. The memory needed is preallocated
- * so that we know in advance if there's enough of it.
- *
- * The first swap_map_page structure is filled with the swap entries that
- * correspond to the first MAP_PAGE_SIZE data pages written to swap and
- * so on. After the all of the data pages have been written, the order
- * of the swap_map_page structures in the map is reversed so that they
- * can be read from swap in the original order. This causes the data
- * pages to be loaded in exactly the same order in which they have been
- * saved.
- *
- * During resume we only need to use one swap_map_page structure
- * at a time, which means that we only need to use two memory pages for
- * reading the image - one for reading the swap_map_page structures
- * and the second for reading the data pages from swap.
+ * The functions operate on a linked bitmap structure defined
+ * in power.h
*/
-#define MAP_PAGE_SIZE ((PAGE_SIZE - sizeof(swp_entry_t) - sizeof(void *)) \
- / sizeof(swp_entry_t))
-
-struct swap_map_page {
- swp_entry_t entries[MAP_PAGE_SIZE];
- swp_entry_t next_swap;
- struct swap_map_page *next;
-};
-
-static inline void free_swap_map(struct swap_map_page *swap_map)
+void free_bitmap(struct bitmap_page *bitmap)
{
- struct swap_map_page *swp;
+ struct bitmap_page *bp;
- while (swap_map) {
- swp = swap_map->next;
- free_page((unsigned long)swap_map);
- swap_map = swp;
+ while (bitmap) {
+ bp = bitmap->next;
+ free_page((unsigned long)bitmap);
+ bitmap = bp;
}
}
-static struct swap_map_page *alloc_swap_map(unsigned int nr_pages)
+struct bitmap_page *alloc_bitmap(unsigned int nr_bits)
{
- struct swap_map_page *swap_map, *swp;
- unsigned n = 0;
+ struct bitmap_page *bitmap, *bp;
+ unsigned int n;
- if (!nr_pages)
+ if (!nr_bits)
return NULL;
- pr_debug("alloc_swap_map(): nr_pages = %d\n", nr_pages);
- swap_map = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
- swp = swap_map;
- for (n = MAP_PAGE_SIZE; n < nr_pages; n += MAP_PAGE_SIZE) {
- swp->next = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
- swp = swp->next;
- if (!swp) {
- free_swap_map(swap_map);
+ bitmap = (struct bitmap_page *)get_zeroed_page(GFP_KERNEL);
+ bp = bitmap;
+ for (n = BITMAP_PAGE_BITS; n < nr_bits; n += BITMAP_PAGE_BITS) {
+ bp->next = (struct bitmap_page *)get_zeroed_page(GFP_KERNEL);
+ bp = bp->next;
+ if (!bp) {
+ free_bitmap(bitmap);
return NULL;
}
}
- return swap_map;
+ return bitmap;
}
-/**
- * reverse_swap_map - reverse the order of pages in the swap map
- * @swap_map
- */
-
-static inline struct swap_map_page *reverse_swap_map(struct swap_map_page *swap_map)
-{
- struct swap_map_page *prev, *next;
-
- prev = NULL;
- while (swap_map) {
- next = swap_map->next;
- swap_map->next = prev;
- prev = swap_map;
- swap_map = next;
- }
- return prev;
-}
-
-/**
- * free_swap_map_entries - free the swap entries allocated to store
- * the swap map @swap_map (this is only called in case of an error)
- */
-static inline void free_swap_map_entries(struct swap_map_page *swap_map)
-{
- while (swap_map) {
- if (swap_map->next_swap.val)
- swap_free(swap_map->next_swap);
- swap_map = swap_map->next;
- }
-}
-
-/**
- * save_swap_map - save the swap map used for tracing the data pages
- * stored in the swap
- */
-
-static int save_swap_map(struct swap_map_page *swap_map, swp_entry_t *start)
-{
- swp_entry_t entry = (swp_entry_t){0};
- int error;
-
- while (swap_map) {
- swap_map->next_swap = entry;
- if ((error = write_page((unsigned long)swap_map, &entry)))
- return error;
- swap_map = swap_map->next;
- }
- *start = entry;
- return 0;
-}
-
-/**
- * free_image_entries - free the swap entries allocated to store
- * the image data pages (this is only called in case of an error)
- */
-
-static inline void free_image_entries(struct swap_map_page *swp)
+static int bitmap_set(struct bitmap_page *bitmap, unsigned long bit)
{
- unsigned k;
+ unsigned int n;
- while (swp) {
- for (k = 0; k < MAP_PAGE_SIZE; k++)
- if (swp->entries[k].val)
- swap_free(swp->entries[k]);
- swp = swp->next;
+ n = BITMAP_PAGE_BITS;
+ while (bitmap && n <= bit) {
+ n += BITMAP_PAGE_BITS;
+ bitmap = bitmap->next;
}
-}
-
-/**
- * The swap_map_handle structure is used for handling the swap map in
- * a file-alike way
- */
-
-struct swap_map_handle {
- struct swap_map_page *cur;
- unsigned int k;
-};
-
-static inline void init_swap_map_handle(struct swap_map_handle *handle,
- struct swap_map_page *map)
-{
- handle->cur = map;
- handle->k = 0;
-}
-
-static inline int swap_map_write_page(struct swap_map_handle *handle,
- unsigned long addr)
-{
- int error;
-
- error = write_page(addr, handle->cur->entries + handle->k);
- if (error)
- return error;
- if (++handle->k >= MAP_PAGE_SIZE) {
- handle->cur = handle->cur->next;
- handle->k = 0;
+ if (!bitmap)
+ return -EINVAL;
+ n -= BITMAP_PAGE_BITS;
+ bit -= n;
+ n = 0;
+ while (bit >= BITS_PER_CHUNK) {
+ bit -= BITS_PER_CHUNK;
+ n++;
}
+ bitmap->chunks[n] |= (1UL << bit);
return 0;
}
-/**
- * save_image_data - save the data pages pointed to by the PBEs
- * from the list @pblist using the swap map handle @handle
- * (assume there are @nr_pages data pages to save)
- */
-
-static int save_image_data(struct pbe *pblist,
- struct swap_map_handle *handle,
- unsigned int nr_pages)
-{
- unsigned int m;
- struct pbe *p;
- int error = 0;
-
- printk("Saving image data pages (%u pages) ... ", nr_pages);
- m = nr_pages / 100;
- if (!m)
- m = 1;
- nr_pages = 0;
- for_each_pbe (p, pblist) {
- error = swap_map_write_page(handle, p->address);
- if (error)
- break;
- if (!(nr_pages % m))
- printk("\b\b\b\b%3d%%", nr_pages / m);
- nr_pages++;
- }
- if (!error)
- printk("\b\b\b\bdone\n");
- return error;
-}
-
-static void dump_info(void)
-{
- pr_debug(" swsusp: Version: %u\n",swsusp_info.version_code);
- pr_debug(" swsusp: Num Pages: %ld\n",swsusp_info.num_physpages);
- pr_debug(" swsusp: UTS Sys: %s\n",swsusp_info.uts.sysname);
- pr_debug(" swsusp: UTS Node: %s\n",swsusp_info.uts.nodename);
- pr_debug(" swsusp: UTS Release: %s\n",swsusp_info.uts.release);
- pr_debug(" swsusp: UTS Version: %s\n",swsusp_info.uts.version);
- pr_debug(" swsusp: UTS Machine: %s\n",swsusp_info.uts.machine);
- pr_debug(" swsusp: UTS Domain: %s\n",swsusp_info.uts.domainname);
- pr_debug(" swsusp: CPUs: %d\n",swsusp_info.cpus);
- pr_debug(" swsusp: Image: %ld Pages\n",swsusp_info.image_pages);
- pr_debug(" swsusp: Total: %ld Pages\n", swsusp_info.pages);
-}
-
-static void init_header(unsigned int nr_pages)
-{
- memset(&swsusp_info, 0, sizeof(swsusp_info));
- swsusp_info.version_code = LINUX_VERSION_CODE;
- swsusp_info.num_physpages = num_physpages;
- memcpy(&swsusp_info.uts, &system_utsname, sizeof(system_utsname));
-
- swsusp_info.cpus = num_online_cpus();
- swsusp_info.image_pages = nr_pages;
- swsusp_info.pages = nr_pages +
- ((nr_pages * sizeof(long) + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
-}
-
-/**
- * pack_orig_addresses - the .orig_address fields of the PBEs from the
- * list starting at @pbe are stored in the array @buf[] (1 page)
- */
-
-static inline struct pbe *pack_orig_addresses(unsigned long *buf,
- struct pbe *pbe)
-{
- int j;
-
- for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
- buf[j] = pbe->orig_address;
- pbe = pbe->next;
- }
- if (!pbe)
- for (; j < PAGE_SIZE / sizeof(long); j++)
- buf[j] = 0;
- return pbe;
-}
-
-/**
- * save_image_metadata - save the .orig_address fields of the PBEs
- * from the list @pblist using the swap map handle @handle
- */
-
-static int save_image_metadata(struct pbe *pblist,
- struct swap_map_handle *handle)
+unsigned long alloc_swap_page(int swap, struct bitmap_page *bitmap)
{
- unsigned long *buf;
- unsigned int n = 0;
- struct pbe *p;
- int error = 0;
+ unsigned long offset;
- printk("Saving image metadata ... ");
- buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC);
- if (!buf)
- return -ENOMEM;
- p = pblist;
- while (p) {
- p = pack_orig_addresses(buf, p);
- error = swap_map_write_page(handle, (unsigned long)buf);
- if (error)
- break;
- n++;
+ offset = swp_offset(get_swap_page_of_type(swap));
+ if (offset) {
+ if (bitmap_set(bitmap, offset)) {
+ swap_free(swp_entry(swap, offset));
+ offset = 0;
+ }
}
- free_page((unsigned long)buf);
- if (!error)
- printk("done (%u pages saved)\n", n);
- return error;
+ return offset;
}
-/**
- * enough_swap - Make sure we have enough swap to save the image.
- *
- * Returns TRUE or FALSE after checking the total amount of swap
- * space avaiable from the resume partition.
- */
-
-static int enough_swap(unsigned int nr_pages)
+void free_all_swap_pages(int swap, struct bitmap_page *bitmap)
{
- unsigned int free_swap = swap_info[root_swap].pages -
- swap_info[root_swap].inuse_pages;
-
- pr_debug("swsusp: free swap pages: %u\n", free_swap);
- return free_swap > (nr_pages + PAGES_FOR_IO +
- (nr_pages + PBES_PER_PAGE - 1) / PBES_PER_PAGE);
-}
+ unsigned int bit, n;
+ unsigned long test;
-/**
- * swsusp_write - Write entire image and metadata.
- *
- * It is important _NOT_ to umount filesystems at this point. We want
- * them synced (in case something goes wrong) but we DO not want to mark
- * filesystem clean: it is not. (And it does not matter, if we resume
- * correctly, we'll mark system clean, anyway.)
- */
-
-int swsusp_write(struct pbe *pblist, unsigned int nr_pages)
-{
- struct swap_map_page *swap_map;
- struct swap_map_handle handle;
- swp_entry_t start;
- int error;
-
- if ((error = swsusp_swap_check())) {
- printk(KERN_ERR "swsusp: Cannot find swap device, try swapon -a.\n");
- return error;
- }
- if (!enough_swap(nr_pages)) {
- printk(KERN_ERR "swsusp: Not enough free swap\n");
- return -ENOSPC;
+ bit = 0;
+ while (bitmap) {
+ for (n = 0; n < BITMAP_PAGE_CHUNKS; n++)
+ for (test = 1UL; test; test <<= 1) {
+ if (bitmap->chunks[n] & test)
+ swap_free(swp_entry(swap, bit));
+ bit++;
+ }
+ bitmap = bitmap->next;
}
-
- init_header(nr_pages);
- swap_map = alloc_swap_map(swsusp_info.pages);
- if (!swap_map)
- return -ENOMEM;
- init_swap_map_handle(&handle, swap_map);
-
- error = swap_map_write_page(&handle, (unsigned long)&swsusp_info);
- if (!error)
- error = save_image_metadata(pblist, &handle);
- if (!error)
- error = save_image_data(pblist, &handle, nr_pages);
- if (error)
- goto Free_image_entries;
-
- swap_map = reverse_swap_map(swap_map);
- error = save_swap_map(swap_map, &start);
- if (error)
- goto Free_map_entries;
-
- dump_info();
- printk( "S" );
- error = mark_swapfiles(start);
- printk( "|\n" );
- if (error)
- goto Free_map_entries;
-
-Free_swap_map:
- free_swap_map(swap_map);
- return error;
-
-Free_map_entries:
- free_swap_map_entries(swap_map);
-Free_image_entries:
- free_image_entries(swap_map);
- goto Free_swap_map;
}
/**
@@ -660,379 +271,3 @@ int swsusp_resume(void)
local_irq_enable();
return error;
}
-
-/**
- * mark_unsafe_pages - mark the pages that cannot be used for storing
- * the image during resume, because they conflict with the pages that
- * had been used before suspend
- */
-
-static void mark_unsafe_pages(struct pbe *pblist)
-{
- struct zone *zone;
- unsigned long zone_pfn;
- struct pbe *p;
-
- if (!pblist) /* a sanity check */
- return;
-
- /* Clear page flags */
- for_each_zone (zone) {
- for (zone_pfn = 0; zone_pfn < zone->spanned_pages; ++zone_pfn)
- if (pfn_valid(zone_pfn + zone->zone_start_pfn))
- ClearPageNosaveFree(pfn_to_page(zone_pfn +
- zone->zone_start_pfn));
- }
-
- /* Mark orig addresses */
- for_each_pbe (p, pblist)
- SetPageNosaveFree(virt_to_page(p->orig_address));
-
-}
-
-static void copy_page_backup_list(struct pbe *dst, struct pbe *src)
-{
- /* We assume both lists contain the same number of elements */
- while (src) {
- dst->orig_address = src->orig_address;
- dst = dst->next;
- src = src->next;
- }
-}
-
-/*
- * Using bio to read from swap.
- * This code requires a bit more work than just using buffer heads
- * but, it is the recommended way for 2.5/2.6.
- * The following are to signal the beginning and end of I/O. Bios
- * finish asynchronously, while we want them to happen synchronously.
- * A simple atomic_t, and a wait loop take care of this problem.
- */
-
-static atomic_t io_done = ATOMIC_INIT(0);
-
-static int end_io(struct bio *bio, unsigned int num, int err)
-{
- if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
- panic("I/O error reading memory image");
- atomic_set(&io_done, 0);
- return 0;
-}
-
-static struct block_device *resume_bdev;
-
-/**
- * submit - submit BIO request.
- * @rw: READ or WRITE.
- * @off physical offset of page.
- * @page: page we're reading or writing.
- *
- * Straight from the textbook - allocate and initialize the bio.
- * If we're writing, make sure the page is marked as dirty.
- * Then submit it and wait.
- */
-
-static int submit(int rw, pgoff_t page_off, void *page)
-{
- int error = 0;
- struct bio *bio;
-
- bio = bio_alloc(GFP_ATOMIC, 1);
- if (!bio)
- return -ENOMEM;
- bio->bi_sector = page_off * (PAGE_SIZE >> 9);
- bio->bi_bdev = resume_bdev;
- bio->bi_end_io = end_io;
-
- if (bio_add_page(bio, virt_to_page(page), PAGE_SIZE, 0) < PAGE_SIZE) {
- printk("swsusp: ERROR: adding page to bio at %ld\n",page_off);
- error = -EFAULT;
- goto Done;
- }
-
-
- atomic_set(&io_done, 1);
- submit_bio(rw | (1 << BIO_RW_SYNC), bio);
- while (atomic_read(&io_done))
- yield();
- if (rw == READ)
- bio_set_pages_dirty(bio);
- Done:
- bio_put(bio);
- return error;
-}
-
-static int bio_read_page(pgoff_t page_off, void *page)
-{
- return submit(READ, page_off, page);
-}
-
-static int bio_write_page(pgoff_t page_off, void *page)
-{
- return submit(WRITE, page_off, page);
-}
-
-/**
- * The following functions allow us to read data using a swap map
- * in a file-alike way
- */
-
-static inline void release_swap_map_reader(struct swap_map_handle *handle)
-{
- if (handle->cur)
- free_page((unsigned long)handle->cur);
- handle->cur = NULL;
-}
-
-static inline int get_swap_map_reader(struct swap_map_handle *handle,
- swp_entry_t start)
-{
- int error;
-
- if (!swp_offset(start))
- return -EINVAL;
- handle->cur = (struct swap_map_page *)get_zeroed_page(GFP_ATOMIC);
- if (!handle->cur)
- return -ENOMEM;
- error = bio_read_page(swp_offset(start), handle->cur);
- if (error) {
- release_swap_map_reader(handle);
- return error;
- }
- handle->k = 0;
- return 0;
-}
-
-static inline int swap_map_read_page(struct swap_map_handle *handle, void *buf)
-{
- unsigned long offset;
- int error;
-
- if (!handle->cur)
- return -EINVAL;
- offset = swp_offset(handle->cur->entries[handle->k]);
- if (!offset)
- return -EINVAL;
- error = bio_read_page(offset, buf);
- if (error)
- return error;
- if (++handle->k >= MAP_PAGE_SIZE) {
- handle->k = 0;
- offset = swp_offset(handle->cur->next_swap);
- if (!offset)
- release_swap_map_reader(handle);
- else
- error = bio_read_page(offset, handle->cur);
- }
- return error;
-}
-
-static int check_header(void)
-{
- char *reason = NULL;
-
- dump_info();
- if (swsusp_info.version_code != LINUX_VERSION_CODE)
- reason = "kernel version";
- if (swsusp_info.num_physpages != num_physpages)
- reason = "memory size";
- if (strcmp(swsusp_info.uts.sysname,system_utsname.sysname))
- reason = "system type";
- if (strcmp(swsusp_info.uts.release,system_utsname.release))
- reason = "kernel release";
- if (strcmp(swsusp_info.uts.version,system_utsname.version))
- reason = "version";
- if (strcmp(swsusp_info.uts.machine,system_utsname.machine))
- reason = "machine";
- if (reason) {
- printk(KERN_ERR "swsusp: Resume mismatch: %s\n", reason);
- return -EPERM;
- }
- return 0;
-}
-
-/**
- * load_image_data - load the image data using the swap map handle
- * @handle and store them using the page backup list @pblist
- * (assume there are @nr_pages pages to load)
- */
-
-static int load_image_data(struct pbe *pblist,
- struct swap_map_handle *handle,
- unsigned int nr_pages)
-{
- int error;
- unsigned int m;
- struct pbe *p;
-
- if (!pblist)
- return -EINVAL;
- printk("Loading image data pages (%u pages) ... ", nr_pages);
- m = nr_pages / 100;
- if (!m)
- m = 1;
- nr_pages = 0;
- p = pblist;
- while (p) {
- error = swap_map_read_page(handle, (void *)p->address);
- if (error)
- break;
- p = p->next;
- if (!(nr_pages % m))
- printk("\b\b\b\b%3d%%", nr_pages / m);
- nr_pages++;
- }
- if (!error)
- printk("\b\b\b\bdone\n");
- return error;
-}
-
-/**
- * unpack_orig_addresses - copy the elements of @buf[] (1 page) to
- * the PBEs in the list starting at @pbe
- */
-
-static inline struct pbe *unpack_orig_addresses(unsigned long *buf,
- struct pbe *pbe)
-{
- int j;
-
- for (j = 0; j < PAGE_SIZE / sizeof(long) && pbe; j++) {
- pbe->orig_address = buf[j];
- pbe = pbe->next;
- }
- return pbe;
-}
-
-/**
- * load_image_metadata - load the image metadata using the swap map
- * handle @handle and put them into the PBEs in the list @pblist
- */
-
-static int load_image_metadata(struct pbe *pblist, struct swap_map_handle *handle)
-{
- struct pbe *p;
- unsigned long *buf;
- unsigned int n = 0;
- int error = 0;
-
- printk("Loading image metadata ... ");
- buf = (unsigned long *)get_zeroed_page(GFP_ATOMIC);
- if (!buf)
- return -ENOMEM;
- p = pblist;
- while (p) {
- error = swap_map_read_page(handle, buf);
- if (error)
- break;
- p = unpack_orig_addresses(buf, p);
- n++;
- }
- free_page((unsigned long)buf);
- if (!error)
- printk("done (%u pages loaded)\n", n);
- return error;
-}
-
-int swsusp_read(struct pbe **pblist_ptr)
-{
- int error;
- struct pbe *p, *pblist;
- struct swap_map_handle handle;
- unsigned int nr_pages;
-
- if (IS_ERR(resume_bdev)) {
- pr_debug("swsusp: block device not initialised\n");
- return PTR_ERR(resume_bdev);
- }
-
- error = get_swap_map_reader(&handle, swsusp_header.image);
- if (!error)
- error = swap_map_read_page(&handle, &swsusp_info);
- if (!error)
- error = check_header();
- if (error)
- return error;
- nr_pages = swsusp_info.image_pages;
- p = alloc_pagedir(nr_pages, GFP_ATOMIC, 0);
- if (!p)
- return -ENOMEM;
- error = load_image_metadata(p, &handle);
- if (!error) {
- mark_unsafe_pages(p);
- pblist = alloc_pagedir(nr_pages, GFP_ATOMIC, 1);
- if (pblist)
- copy_page_backup_list(pblist, p);
- free_pagedir(p);
- if (!pblist)
- error = -ENOMEM;
-
- /* Allocate memory for the image and read the data from swap */
- if (!error)
- error = alloc_data_pages(pblist, GFP_ATOMIC, 1);
- if (!error) {
- release_eaten_pages();
- error = load_image_data(pblist, &handle, nr_pages);
- }
- if (!error)
- *pblist_ptr = pblist;
- }
- release_swap_map_reader(&handle);
-
- blkdev_put(resume_bdev);
-
- if (!error)
- pr_debug("swsusp: Reading resume file was successful\n");
- else
- pr_debug("swsusp: Error %d resuming\n", error);
- return error;
-}
-
-/**
- * swsusp_check - Check for swsusp signature in the resume device
- */
-
-int swsusp_check(void)
-{
- int error;
-
- resume_bdev = open_by_devnum(swsusp_resume_device, FMODE_READ);
- if (!IS_ERR(resume_bdev)) {
- set_blocksize(resume_bdev, PAGE_SIZE);
- memset(&swsusp_header, 0, sizeof(swsusp_header));
- if ((error = bio_read_page(0, &swsusp_header)))
- return error;
- if (!memcmp(SWSUSP_SIG, swsusp_header.sig, 10)) {
- memcpy(swsusp_header.sig, swsusp_header.orig_sig, 10);
- /* Reset swap signature now */
- error = bio_write_page(0, &swsusp_header);
- } else {
- return -EINVAL;
- }
- if (error)
- blkdev_put(resume_bdev);
- else
- pr_debug("swsusp: Signature found, resuming\n");
- } else {
- error = PTR_ERR(resume_bdev);
- }
-
- if (error)
- pr_debug("swsusp: Error %d check for resume file\n", error);
-
- return error;
-}
-
-/**
- * swsusp_close - close swap device.
- */
-
-void swsusp_close(void)
-{
- if (IS_ERR(resume_bdev)) {
- pr_debug("swsusp: block device not initialised\n");
- return;
- }
-
- blkdev_put(resume_bdev);
-}
diff --git a/kernel/power/user.c b/kernel/power/user.c
new file mode 100644
index 00000000000..3f1539fbe48
--- /dev/null
+++ b/kernel/power/user.c
@@ -0,0 +1,333 @@
+/*
+ * linux/kernel/power/user.c
+ *
+ * This file provides the user space interface for software suspend/resume.
+ *
+ * Copyright (C) 2006 Rafael J. Wysocki <rjw@sisk.pl>
+ *
+ * This file is released under the GPLv2.
+ *
+ */
+
+#include <linux/suspend.h>
+#include <linux/syscalls.h>
+#include <linux/string.h>
+#include <linux/device.h>
+#include <linux/miscdevice.h>
+#include <linux/mm.h>
+#include <linux/swap.h>
+#include <linux/swapops.h>
+#include <linux/pm.h>
+#include <linux/fs.h>
+
+#include <asm/uaccess.h>
+
+#include "power.h"
+
+#define SNAPSHOT_MINOR 231
+
+static struct snapshot_data {
+ struct snapshot_handle handle;
+ int swap;
+ struct bitmap_page *bitmap;
+ int mode;
+ char frozen;
+ char ready;
+} snapshot_state;
+
+static atomic_t device_available = ATOMIC_INIT(1);
+
+static int snapshot_open(struct inode *inode, struct file *filp)
+{
+ struct snapshot_data *data;
+
+ if (!atomic_add_unless(&device_available, -1, 0))
+ return -EBUSY;
+
+ if ((filp->f_flags & O_ACCMODE) == O_RDWR)
+ return -ENOSYS;
+
+ nonseekable_open(inode, filp);
+ data = &snapshot_state;
+ filp->private_data = data;
+ memset(&data->handle, 0, sizeof(struct snapshot_handle));
+ if ((filp->f_flags & O_ACCMODE) == O_RDONLY) {
+ data->swap = swsusp_resume_device ? swap_type_of(swsusp_resume_device) : -1;
+ data->mode = O_RDONLY;
+ } else {
+ data->swap = -1;
+ data->mode = O_WRONLY;
+ }
+ data->bitmap = NULL;
+ data->frozen = 0;
+ data->ready = 0;
+
+ return 0;
+}
+
+static int snapshot_release(struct inode *inode, struct file *filp)
+{
+ struct snapshot_data *data;
+
+ swsusp_free();
+ data = filp->private_data;
+ free_all_swap_pages(data->swap, data->bitmap);
+ free_bitmap(data->bitmap);
+ if (data->frozen) {
+ down(&pm_sem);
+ thaw_processes();
+ enable_nonboot_cpus();
+ up(&pm_sem);
+ }
+ atomic_inc(&device_available);
+ return 0;
+}
+
+static ssize_t snapshot_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *offp)
+{
+ struct snapshot_data *data;
+ ssize_t res;
+
+ data = filp->private_data;
+ res = snapshot_read_next(&data->handle, count);
+ if (res > 0) {
+ if (copy_to_user(buf, data_of(data->handle), res))
+ res = -EFAULT;
+ else
+ *offp = data->handle.offset;
+ }
+ return res;
+}
+
+static ssize_t snapshot_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *offp)
+{
+ struct snapshot_data *data;
+ ssize_t res;
+
+ data = filp->private_data;
+ res = snapshot_write_next(&data->handle, count);
+ if (res > 0) {
+ if (copy_from_user(data_of(data->handle), buf, res))
+ res = -EFAULT;
+ else
+ *offp = data->handle.offset;
+ }
+ return res;
+}
+
+static int snapshot_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ int error = 0;
+ struct snapshot_data *data;
+ loff_t offset, avail;
+
+ if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
+ return -ENOTTY;
+ if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
+ return -ENOTTY;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
+ data = filp->private_data;
+
+ switch (cmd) {
+
+ case SNAPSHOT_FREEZE:
+ if (data->frozen)
+ break;
+ down(&pm_sem);
+ disable_nonboot_cpus();
+ if (freeze_processes()) {
+ thaw_processes();
+ enable_nonboot_cpus();
+ error = -EBUSY;
+ }
+ up(&pm_sem);
+ if (!error)
+ data->frozen = 1;
+ break;
+
+ case SNAPSHOT_UNFREEZE:
+ if (!data->frozen)
+ break;
+ down(&pm_sem);
+ thaw_processes();
+ enable_nonboot_cpus();
+ up(&pm_sem);
+ data->frozen = 0;
+ break;
+
+ case SNAPSHOT_ATOMIC_SNAPSHOT:
+ if (data->mode != O_RDONLY || !data->frozen || data->ready) {
+ error = -EPERM;
+ break;
+ }
+ down(&pm_sem);
+ /* Free memory before shutting down devices. */
+ error = swsusp_shrink_memory();
+ if (!error) {
+ error = device_suspend(PMSG_FREEZE);
+ if (!error) {
+ in_suspend = 1;
+ error = swsusp_suspend();
+ device_resume();
+ }
+ }
+ up(&pm_sem);
+ if (!error)
+ error = put_user(in_suspend, (unsigned int __user *)arg);
+ if (!error)
+ data->ready = 1;
+ break;
+
+ case SNAPSHOT_ATOMIC_RESTORE:
+ if (data->mode != O_WRONLY || !data->frozen ||
+ !snapshot_image_loaded(&data->handle)) {
+ error = -EPERM;
+ break;
+ }
+ down(&pm_sem);
+ pm_prepare_console();
+ error = device_suspend(PMSG_FREEZE);
+ if (!error) {
+ error = swsusp_resume();
+ device_resume();
+ }
+ pm_restore_console();
+ up(&pm_sem);
+ break;
+
+ case SNAPSHOT_FREE:
+ swsusp_free();
+ memset(&data->handle, 0, sizeof(struct snapshot_handle));
+ data->ready = 0;
+ break;
+
+ case SNAPSHOT_SET_IMAGE_SIZE:
+ image_size = arg;
+ break;
+
+ case SNAPSHOT_AVAIL_SWAP:
+ avail = count_swap_pages(data->swap, 1);
+ avail <<= PAGE_SHIFT;
+ error = put_user(avail, (loff_t __user *)arg);
+ break;
+
+ case SNAPSHOT_GET_SWAP_PAGE:
+ if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
+ error = -ENODEV;
+ break;
+ }
+ if (!data->bitmap) {
+ data->bitmap = alloc_bitmap(count_swap_pages(data->swap, 0));
+ if (!data->bitmap) {
+ error = -ENOMEM;
+ break;
+ }
+ }
+ offset = alloc_swap_page(data->swap, data->bitmap);
+ if (offset) {
+ offset <<= PAGE_SHIFT;
+ error = put_user(offset, (loff_t __user *)arg);
+ } else {
+ error = -ENOSPC;
+ }
+ break;
+
+ case SNAPSHOT_FREE_SWAP_PAGES:
+ if (data->swap < 0 || data->swap >= MAX_SWAPFILES) {
+ error = -ENODEV;
+ break;
+ }
+ free_all_swap_pages(data->swap, data->bitmap);
+ free_bitmap(data->bitmap);
+ data->bitmap = NULL;
+ break;
+
+ case SNAPSHOT_SET_SWAP_FILE:
+ if (!data->bitmap) {
+ /*
+ * User space encodes device types as two-byte values,
+ * so we need to recode them
+ */
+ if (old_decode_dev(arg)) {
+ data->swap = swap_type_of(old_decode_dev(arg));
+ if (data->swap < 0)
+ error = -ENODEV;
+ } else {
+ data->swap = -1;
+ error = -EINVAL;
+ }
+ } else {
+ error = -EPERM;
+ }
+ break;
+
+ case SNAPSHOT_S2RAM:
+ if (!data->frozen) {
+ error = -EPERM;
+ break;
+ }
+
+ if (down_trylock(&pm_sem)) {
+ error = -EBUSY;
+ break;
+ }
+
+ if (pm_ops->prepare) {
+ error = pm_ops->prepare(PM_SUSPEND_MEM);
+ if (error)
+ goto OutS3;
+ }
+
+ /* Put devices to sleep */
+ error = device_suspend(PMSG_SUSPEND);
+ if (error) {
+ printk(KERN_ERR "Failed to suspend some devices.\n");
+ } else {
+ /* Enter S3, system is already frozen */
+ suspend_enter(PM_SUSPEND_MEM);
+
+ /* Wake up devices */
+ device_resume();
+ }
+
+ if (pm_ops->finish)
+ pm_ops->finish(PM_SUSPEND_MEM);
+
+OutS3:
+ up(&pm_sem);
+ break;
+
+ default:
+ error = -ENOTTY;
+
+ }
+
+ return error;
+}
+
+static struct file_operations snapshot_fops = {
+ .open = snapshot_open,
+ .release = snapshot_release,
+ .read = snapshot_read,
+ .write = snapshot_write,
+ .llseek = no_llseek,
+ .ioctl = snapshot_ioctl,
+};
+
+static struct miscdevice snapshot_device = {
+ .minor = SNAPSHOT_MINOR,
+ .name = "snapshot",
+ .fops = &snapshot_fops,
+};
+
+static int __init snapshot_device_init(void)
+{
+ return misc_register(&snapshot_device);
+};
+
+device_initcall(snapshot_device_init);
diff --git a/kernel/printk.c b/kernel/printk.c
index 13ced0f7828..8cc19431e74 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -122,44 +122,6 @@ static char *log_buf = __log_buf;
static int log_buf_len = __LOG_BUF_LEN;
static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */
-/*
- * Setup a list of consoles. Called from init/main.c
- */
-static int __init console_setup(char *str)
-{
- char name[sizeof(console_cmdline[0].name)];
- char *s, *options;
- int idx;
-
- /*
- * Decode str into name, index, options.
- */
- if (str[0] >= '0' && str[0] <= '9') {
- strcpy(name, "ttyS");
- strncpy(name + 4, str, sizeof(name) - 5);
- } else
- strncpy(name, str, sizeof(name) - 1);
- name[sizeof(name) - 1] = 0;
- if ((options = strchr(str, ',')) != NULL)
- *(options++) = 0;
-#ifdef __sparc__
- if (!strcmp(str, "ttya"))
- strcpy(name, "ttyS0");
- if (!strcmp(str, "ttyb"))
- strcpy(name, "ttyS1");
-#endif
- for (s = name; *s; s++)
- if ((*s >= '0' && *s <= '9') || *s == ',')
- break;
- idx = simple_strtoul(s, NULL, 10);
- *s = 0;
-
- add_preferred_console(name, idx, options);
- return 1;
-}
-
-__setup("console=", console_setup);
-
static int __init log_buf_len_setup(char *str)
{
unsigned long size = memparse(str, &str);
@@ -659,6 +621,44 @@ static void call_console_drivers(unsigned long start, unsigned long end)
#endif
+/*
+ * Set up a list of consoles. Called from init/main.c
+ */
+static int __init console_setup(char *str)
+{
+ char name[sizeof(console_cmdline[0].name)];
+ char *s, *options;
+ int idx;
+
+ /*
+ * Decode str into name, index, options.
+ */
+ if (str[0] >= '0' && str[0] <= '9') {
+ strcpy(name, "ttyS");
+ strncpy(name + 4, str, sizeof(name) - 5);
+ } else {
+ strncpy(name, str, sizeof(name) - 1);
+ }
+ name[sizeof(name) - 1] = 0;
+ if ((options = strchr(str, ',')) != NULL)
+ *(options++) = 0;
+#ifdef __sparc__
+ if (!strcmp(str, "ttya"))
+ strcpy(name, "ttyS0");
+ if (!strcmp(str, "ttyb"))
+ strcpy(name, "ttyS1");
+#endif
+ for (s = name; *s; s++)
+ if ((*s >= '0' && *s <= '9') || *s == ',')
+ break;
+ idx = simple_strtoul(s, NULL, 10);
+ *s = 0;
+
+ add_preferred_console(name, idx, options);
+ return 1;
+}
+__setup("console=", console_setup);
+
/**
* add_preferred_console - add a device to the list of preferred consoles.
* @name: device name
diff --git a/kernel/profile.c b/kernel/profile.c
index f89248e6d70..ad81f799a9b 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -23,6 +23,7 @@
#include <linux/cpu.h>
#include <linux/profile.h>
#include <linux/highmem.h>
+#include <linux/mutex.h>
#include <asm/sections.h>
#include <asm/semaphore.h>
@@ -44,7 +45,7 @@ static cpumask_t prof_cpu_mask = CPU_MASK_ALL;
#ifdef CONFIG_SMP
static DEFINE_PER_CPU(struct profile_hit *[2], cpu_profile_hits);
static DEFINE_PER_CPU(int, cpu_profile_flip);
-static DECLARE_MUTEX(profile_flip_mutex);
+static DEFINE_MUTEX(profile_flip_mutex);
#endif /* CONFIG_SMP */
static int __init profile_setup(char * str)
@@ -243,7 +244,7 @@ static void profile_flip_buffers(void)
{
int i, j, cpu;
- down(&profile_flip_mutex);
+ mutex_lock(&profile_flip_mutex);
j = per_cpu(cpu_profile_flip, get_cpu());
put_cpu();
on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -259,14 +260,14 @@ static void profile_flip_buffers(void)
hits[i].hits = hits[i].pc = 0;
}
}
- up(&profile_flip_mutex);
+ mutex_unlock(&profile_flip_mutex);
}
static void profile_discard_flip_buffers(void)
{
int i, cpu;
- down(&profile_flip_mutex);
+ mutex_lock(&profile_flip_mutex);
i = per_cpu(cpu_profile_flip, get_cpu());
put_cpu();
on_each_cpu(__profile_flip_buffers, NULL, 0, 1);
@@ -274,7 +275,7 @@ static void profile_discard_flip_buffers(void)
struct profile_hit *hits = per_cpu(cpu_profile_hits, cpu)[i];
memset(hits, 0, NR_PROFILE_HIT*sizeof(struct profile_hit));
}
- up(&profile_flip_mutex);
+ mutex_unlock(&profile_flip_mutex);
}
void profile_hit(int type, void *__pc)
diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
index fedf5e36975..13458bbaa1b 100644
--- a/kernel/rcupdate.c
+++ b/kernel/rcupdate.c
@@ -47,15 +47,16 @@
#include <linux/notifier.h>
#include <linux/rcupdate.h>
#include <linux/cpu.h>
+#include <linux/mutex.h>
/* Definition for rcupdate control block. */
-struct rcu_ctrlblk rcu_ctrlblk = {
+static struct rcu_ctrlblk rcu_ctrlblk = {
.cur = -300,
.completed = -300,
.lock = SPIN_LOCK_UNLOCKED,
.cpumask = CPU_MASK_NONE,
};
-struct rcu_ctrlblk rcu_bh_ctrlblk = {
+static struct rcu_ctrlblk rcu_bh_ctrlblk = {
.cur = -300,
.completed = -300,
.lock = SPIN_LOCK_UNLOCKED,
@@ -75,7 +76,7 @@ static int rsinterval = 1000;
#endif
static atomic_t rcu_barrier_cpu_count;
-static struct semaphore rcu_barrier_sema;
+static DEFINE_MUTEX(rcu_barrier_mutex);
static struct completion rcu_barrier_completion;
#ifdef CONFIG_SMP
@@ -207,13 +208,13 @@ static void rcu_barrier_func(void *notused)
void rcu_barrier(void)
{
BUG_ON(in_interrupt());
- /* Take cpucontrol semaphore to protect against CPU hotplug */
- down(&rcu_barrier_sema);
+ /* Take cpucontrol mutex to protect against CPU hotplug */
+ mutex_lock(&rcu_barrier_mutex);
init_completion(&rcu_barrier_completion);
atomic_set(&rcu_barrier_cpu_count, 0);
on_each_cpu(rcu_barrier_func, NULL, 0, 1);
wait_for_completion(&rcu_barrier_completion);
- up(&rcu_barrier_sema);
+ mutex_unlock(&rcu_barrier_mutex);
}
EXPORT_SYMBOL_GPL(rcu_barrier);
@@ -415,8 +416,8 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp,
rdp->curtail = &rdp->curlist;
}
- local_irq_disable();
if (rdp->nxtlist && !rdp->curlist) {
+ local_irq_disable();
rdp->curlist = rdp->nxtlist;
rdp->curtail = rdp->nxttail;
rdp->nxtlist = NULL;
@@ -441,9 +442,8 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp,
rcu_start_batch(rcp);
spin_unlock(&rcp->lock);
}
- } else {
- local_irq_enable();
}
+
rcu_check_quiescent_state(rcp, rdp);
if (rdp->donelist)
rcu_do_batch(rdp);
@@ -549,7 +549,6 @@ static struct notifier_block __devinitdata rcu_nb = {
*/
void __init rcu_init(void)
{
- sema_init(&rcu_barrier_sema, 1);
rcu_cpu_notify(&rcu_nb, CPU_UP_PREPARE,
(void *)(long)smp_processor_id());
/* Register notifier for non-boot CPUs */
diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
index 7712912dbc8..b4b362b5baf 100644
--- a/kernel/rcutorture.c
+++ b/kernel/rcutorture.c
@@ -54,15 +54,15 @@ static int verbose; /* Print more debug info. */
static int test_no_idle_hz; /* Test RCU's support for tickless idle CPUs. */
static int shuffle_interval = 5; /* Interval between shuffles (in sec)*/
-MODULE_PARM(nreaders, "i");
+module_param(nreaders, int, 0);
MODULE_PARM_DESC(nreaders, "Number of RCU reader threads");
-MODULE_PARM(stat_interval, "i");
+module_param(stat_interval, int, 0);
MODULE_PARM_DESC(stat_interval, "Number of seconds between stats printk()s");
-MODULE_PARM(verbose, "i");
+module_param(verbose, bool, 0);
MODULE_PARM_DESC(verbose, "Enable verbose debugging printk()s");
-MODULE_PARM(test_no_idle_hz, "i");
+module_param(test_no_idle_hz, bool, 0);
MODULE_PARM_DESC(test_no_idle_hz, "Test support for tickless idle CPUs");
-MODULE_PARM(shuffle_interval, "i");
+module_param(shuffle_interval, int, 0);
MODULE_PARM_DESC(shuffle_interval, "Number of seconds between shuffles");
#define TORTURE_FLAG "rcutorture: "
#define PRINTK_STRING(s) \
@@ -441,6 +441,16 @@ rcu_torture_shuffle(void *arg)
return 0;
}
+static inline void
+rcu_torture_print_module_parms(char *tag)
+{
+ printk(KERN_ALERT TORTURE_FLAG "--- %s: nreaders=%d "
+ "stat_interval=%d verbose=%d test_no_idle_hz=%d "
+ "shuffle_interval = %d\n",
+ tag, nrealreaders, stat_interval, verbose, test_no_idle_hz,
+ shuffle_interval);
+}
+
static void
rcu_torture_cleanup(void)
{
@@ -483,9 +493,10 @@ rcu_torture_cleanup(void)
rcu_barrier();
rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
- printk(KERN_ALERT TORTURE_FLAG
- "--- End of test: %s\n",
- atomic_read(&n_rcu_torture_error) == 0 ? "SUCCESS" : "FAILURE");
+ if (atomic_read(&n_rcu_torture_error))
+ rcu_torture_print_module_parms("End of test: FAILURE");
+ else
+ rcu_torture_print_module_parms("End of test: SUCCESS");
}
static int
@@ -501,11 +512,7 @@ rcu_torture_init(void)
nrealreaders = nreaders;
else
nrealreaders = 2 * num_online_cpus();
- printk(KERN_ALERT TORTURE_FLAG "--- Start of test: nreaders=%d "
- "stat_interval=%d verbose=%d test_no_idle_hz=%d "
- "shuffle_interval = %d\n",
- nrealreaders, stat_interval, verbose, test_no_idle_hz,
- shuffle_interval);
+ rcu_torture_print_module_parms("Start of test");
fullstop = 0;
/* Set up the freelist. */
diff --git a/kernel/relay.c b/kernel/relay.c
new file mode 100644
index 00000000000..33345e73485
--- /dev/null
+++ b/kernel/relay.c
@@ -0,0 +1,1012 @@
+/*
+ * Public API and common code for kernel->userspace relay file support.
+ *
+ * See Documentation/filesystems/relayfs.txt for an overview of relayfs.
+ *
+ * Copyright (C) 2002-2005 - Tom Zanussi (zanussi@us.ibm.com), IBM Corp
+ * Copyright (C) 1999-2005 - Karim Yaghmour (karim@opersys.com)
+ *
+ * Moved to kernel/relay.c by Paul Mundt, 2006.
+ *
+ * This file is released under the GPL.
+ */
+#include <linux/errno.h>
+#include <linux/stddef.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/string.h>
+#include <linux/relay.h>
+#include <linux/vmalloc.h>
+#include <linux/mm.h>
+
+/*
+ * close() vm_op implementation for relay file mapping.
+ */
+static void relay_file_mmap_close(struct vm_area_struct *vma)
+{
+ struct rchan_buf *buf = vma->vm_private_data;
+ buf->chan->cb->buf_unmapped(buf, vma->vm_file);
+}
+
+/*
+ * nopage() vm_op implementation for relay file mapping.
+ */
+static struct page *relay_buf_nopage(struct vm_area_struct *vma,
+ unsigned long address,
+ int *type)
+{
+ struct page *page;
+ struct rchan_buf *buf = vma->vm_private_data;
+ unsigned long offset = address - vma->vm_start;
+
+ if (address > vma->vm_end)
+ return NOPAGE_SIGBUS; /* Disallow mremap */
+ if (!buf)
+ return NOPAGE_OOM;
+
+ page = vmalloc_to_page(buf->start + offset);
+ if (!page)
+ return NOPAGE_OOM;
+ get_page(page);
+
+ if (type)
+ *type = VM_FAULT_MINOR;
+
+ return page;
+}
+
+/*
+ * vm_ops for relay file mappings.
+ */
+static struct vm_operations_struct relay_file_mmap_ops = {
+ .nopage = relay_buf_nopage,
+ .close = relay_file_mmap_close,
+};
+
+/**
+ * relay_mmap_buf: - mmap channel buffer to process address space
+ * @buf: relay channel buffer
+ * @vma: vm_area_struct describing memory to be mapped
+ *
+ * Returns 0 if ok, negative on error
+ *
+ * Caller should already have grabbed mmap_sem.
+ */
+int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma)
+{
+ unsigned long length = vma->vm_end - vma->vm_start;
+ struct file *filp = vma->vm_file;
+
+ if (!buf)
+ return -EBADF;
+
+ if (length != (unsigned long)buf->chan->alloc_size)
+ return -EINVAL;
+
+ vma->vm_ops = &relay_file_mmap_ops;
+ vma->vm_private_data = buf;
+ buf->chan->cb->buf_mapped(buf, filp);
+
+ return 0;
+}
+
+/**
+ * relay_alloc_buf - allocate a channel buffer
+ * @buf: the buffer struct
+ * @size: total size of the buffer
+ *
+ * Returns a pointer to the resulting buffer, NULL if unsuccessful. The
+ * passed in size will get page aligned, if it isn't already.
+ */
+static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size)
+{
+ void *mem;
+ unsigned int i, j, n_pages;
+
+ *size = PAGE_ALIGN(*size);
+ n_pages = *size >> PAGE_SHIFT;
+
+ buf->page_array = kcalloc(n_pages, sizeof(struct page *), GFP_KERNEL);
+ if (!buf->page_array)
+ return NULL;
+
+ for (i = 0; i < n_pages; i++) {
+ buf->page_array[i] = alloc_page(GFP_KERNEL);
+ if (unlikely(!buf->page_array[i]))
+ goto depopulate;
+ }
+ mem = vmap(buf->page_array, n_pages, VM_MAP, PAGE_KERNEL);
+ if (!mem)
+ goto depopulate;
+
+ memset(mem, 0, *size);
+ buf->page_count = n_pages;
+ return mem;
+
+depopulate:
+ for (j = 0; j < i; j++)
+ __free_page(buf->page_array[j]);
+ kfree(buf->page_array);
+ return NULL;
+}
+
+/**
+ * relay_create_buf - allocate and initialize a channel buffer
+ * @alloc_size: size of the buffer to allocate
+ * @n_subbufs: number of sub-buffers in the channel
+ *
+ * Returns channel buffer if successful, NULL otherwise
+ */
+struct rchan_buf *relay_create_buf(struct rchan *chan)
+{
+ struct rchan_buf *buf = kcalloc(1, sizeof(struct rchan_buf), GFP_KERNEL);
+ if (!buf)
+ return NULL;
+
+ buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
+ if (!buf->padding)
+ goto free_buf;
+
+ buf->start = relay_alloc_buf(buf, &chan->alloc_size);
+ if (!buf->start)
+ goto free_buf;
+
+ buf->chan = chan;
+ kref_get(&buf->chan->kref);
+ return buf;
+
+free_buf:
+ kfree(buf->padding);
+ kfree(buf);
+ return NULL;
+}
+
+/**
+ * relay_destroy_channel - free the channel struct
+ *
+ * Should only be called from kref_put().
+ */
+void relay_destroy_channel(struct kref *kref)
+{
+ struct rchan *chan = container_of(kref, struct rchan, kref);
+ kfree(chan);
+}
+
+/**
+ * relay_destroy_buf - destroy an rchan_buf struct and associated buffer
+ * @buf: the buffer struct
+ */
+void relay_destroy_buf(struct rchan_buf *buf)
+{
+ struct rchan *chan = buf->chan;
+ unsigned int i;
+
+ if (likely(buf->start)) {
+ vunmap(buf->start);
+ for (i = 0; i < buf->page_count; i++)
+ __free_page(buf->page_array[i]);
+ kfree(buf->page_array);
+ }
+ kfree(buf->padding);
+ kfree(buf);
+ kref_put(&chan->kref, relay_destroy_channel);
+}
+
+/**
+ * relay_remove_buf - remove a channel buffer
+ *
+ * Removes the file from the fileystem, which also frees the
+ * rchan_buf_struct and the channel buffer. Should only be called from
+ * kref_put().
+ */
+void relay_remove_buf(struct kref *kref)
+{
+ struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
+ buf->chan->cb->remove_buf_file(buf->dentry);
+ relay_destroy_buf(buf);
+}
+
+/**
+ * relay_buf_empty - boolean, is the channel buffer empty?
+ * @buf: channel buffer
+ *
+ * Returns 1 if the buffer is empty, 0 otherwise.
+ */
+int relay_buf_empty(struct rchan_buf *buf)
+{
+ return (buf->subbufs_produced - buf->subbufs_consumed) ? 0 : 1;
+}
+EXPORT_SYMBOL_GPL(relay_buf_empty);
+
+/**
+ * relay_buf_full - boolean, is the channel buffer full?
+ * @buf: channel buffer
+ *
+ * Returns 1 if the buffer is full, 0 otherwise.
+ */
+int relay_buf_full(struct rchan_buf *buf)
+{
+ size_t ready = buf->subbufs_produced - buf->subbufs_consumed;
+ return (ready >= buf->chan->n_subbufs) ? 1 : 0;
+}
+EXPORT_SYMBOL_GPL(relay_buf_full);
+
+/*
+ * High-level relay kernel API and associated functions.
+ */
+
+/*
+ * rchan_callback implementations defining default channel behavior. Used
+ * in place of corresponding NULL values in client callback struct.
+ */
+
+/*
+ * subbuf_start() default callback. Does nothing.
+ */
+static int subbuf_start_default_callback (struct rchan_buf *buf,
+ void *subbuf,
+ void *prev_subbuf,
+ size_t prev_padding)
+{
+ if (relay_buf_full(buf))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * buf_mapped() default callback. Does nothing.
+ */
+static void buf_mapped_default_callback(struct rchan_buf *buf,
+ struct file *filp)
+{
+}
+
+/*
+ * buf_unmapped() default callback. Does nothing.
+ */
+static void buf_unmapped_default_callback(struct rchan_buf *buf,
+ struct file *filp)
+{
+}
+
+/*
+ * create_buf_file_create() default callback. Does nothing.
+ */
+static struct dentry *create_buf_file_default_callback(const char *filename,
+ struct dentry *parent,
+ int mode,
+ struct rchan_buf *buf,
+ int *is_global)
+{
+ return NULL;
+}
+
+/*
+ * remove_buf_file() default callback. Does nothing.
+ */
+static int remove_buf_file_default_callback(struct dentry *dentry)
+{
+ return -EINVAL;
+}
+
+/* relay channel default callbacks */
+static struct rchan_callbacks default_channel_callbacks = {
+ .subbuf_start = subbuf_start_default_callback,
+ .buf_mapped = buf_mapped_default_callback,
+ .buf_unmapped = buf_unmapped_default_callback,
+ .create_buf_file = create_buf_file_default_callback,
+ .remove_buf_file = remove_buf_file_default_callback,
+};
+
+/**
+ * wakeup_readers - wake up readers waiting on a channel
+ * @private: the channel buffer
+ *
+ * This is the work function used to defer reader waking. The
+ * reason waking is deferred is that calling directly from write
+ * causes problems if you're writing from say the scheduler.
+ */
+static void wakeup_readers(void *private)
+{
+ struct rchan_buf *buf = private;
+ wake_up_interruptible(&buf->read_wait);
+}
+
+/**
+ * __relay_reset - reset a channel buffer
+ * @buf: the channel buffer
+ * @init: 1 if this is a first-time initialization
+ *
+ * See relay_reset for description of effect.
+ */
+static inline void __relay_reset(struct rchan_buf *buf, unsigned int init)
+{
+ size_t i;
+
+ if (init) {
+ init_waitqueue_head(&buf->read_wait);
+ kref_init(&buf->kref);
+ INIT_WORK(&buf->wake_readers, NULL, NULL);
+ } else {
+ cancel_delayed_work(&buf->wake_readers);
+ flush_scheduled_work();
+ }
+
+ buf->subbufs_produced = 0;
+ buf->subbufs_consumed = 0;
+ buf->bytes_consumed = 0;
+ buf->finalized = 0;
+ buf->data = buf->start;
+ buf->offset = 0;
+
+ for (i = 0; i < buf->chan->n_subbufs; i++)
+ buf->padding[i] = 0;
+
+ buf->chan->cb->subbuf_start(buf, buf->data, NULL, 0);
+}
+
+/**
+ * relay_reset - reset the channel
+ * @chan: the channel
+ *
+ * This has the effect of erasing all data from all channel buffers
+ * and restarting the channel in its initial state. The buffers
+ * are not freed, so any mappings are still in effect.
+ *
+ * NOTE: Care should be taken that the channel isn't actually
+ * being used by anything when this call is made.
+ */
+void relay_reset(struct rchan *chan)
+{
+ unsigned int i;
+ struct rchan_buf *prev = NULL;
+
+ if (!chan)
+ return;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
+ __relay_reset(chan->buf[i], 0);
+ prev = chan->buf[i];
+ }
+}
+EXPORT_SYMBOL_GPL(relay_reset);
+
+/**
+ * relay_open_buf - create a new relay channel buffer
+ *
+ * Internal - used by relay_open().
+ */
+static struct rchan_buf *relay_open_buf(struct rchan *chan,
+ const char *filename,
+ struct dentry *parent,
+ int *is_global)
+{
+ struct rchan_buf *buf;
+ struct dentry *dentry;
+
+ if (*is_global)
+ return chan->buf[0];
+
+ buf = relay_create_buf(chan);
+ if (!buf)
+ return NULL;
+
+ /* Create file in fs */
+ dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR,
+ buf, is_global);
+ if (!dentry) {
+ relay_destroy_buf(buf);
+ return NULL;
+ }
+
+ buf->dentry = dentry;
+ __relay_reset(buf, 1);
+
+ return buf;
+}
+
+/**
+ * relay_close_buf - close a channel buffer
+ * @buf: channel buffer
+ *
+ * Marks the buffer finalized and restores the default callbacks.
+ * The channel buffer and channel buffer data structure are then freed
+ * automatically when the last reference is given up.
+ */
+static inline void relay_close_buf(struct rchan_buf *buf)
+{
+ buf->finalized = 1;
+ cancel_delayed_work(&buf->wake_readers);
+ flush_scheduled_work();
+ kref_put(&buf->kref, relay_remove_buf);
+}
+
+static inline void setup_callbacks(struct rchan *chan,
+ struct rchan_callbacks *cb)
+{
+ if (!cb) {
+ chan->cb = &default_channel_callbacks;
+ return;
+ }
+
+ if (!cb->subbuf_start)
+ cb->subbuf_start = subbuf_start_default_callback;
+ if (!cb->buf_mapped)
+ cb->buf_mapped = buf_mapped_default_callback;
+ if (!cb->buf_unmapped)
+ cb->buf_unmapped = buf_unmapped_default_callback;
+ if (!cb->create_buf_file)
+ cb->create_buf_file = create_buf_file_default_callback;
+ if (!cb->remove_buf_file)
+ cb->remove_buf_file = remove_buf_file_default_callback;
+ chan->cb = cb;
+}
+
+/**
+ * relay_open - create a new relay channel
+ * @base_filename: base name of files to create
+ * @parent: dentry of parent directory, NULL for root directory
+ * @subbuf_size: size of sub-buffers
+ * @n_subbufs: number of sub-buffers
+ * @cb: client callback functions
+ *
+ * Returns channel pointer if successful, NULL otherwise.
+ *
+ * Creates a channel buffer for each cpu using the sizes and
+ * attributes specified. The created channel buffer files
+ * will be named base_filename0...base_filenameN-1. File
+ * permissions will be S_IRUSR.
+ */
+struct rchan *relay_open(const char *base_filename,
+ struct dentry *parent,
+ size_t subbuf_size,
+ size_t n_subbufs,
+ struct rchan_callbacks *cb)
+{
+ unsigned int i;
+ struct rchan *chan;
+ char *tmpname;
+ int is_global = 0;
+
+ if (!base_filename)
+ return NULL;
+
+ if (!(subbuf_size && n_subbufs))
+ return NULL;
+
+ chan = kcalloc(1, sizeof(struct rchan), GFP_KERNEL);
+ if (!chan)
+ return NULL;
+
+ chan->version = RELAYFS_CHANNEL_VERSION;
+ chan->n_subbufs = n_subbufs;
+ chan->subbuf_size = subbuf_size;
+ chan->alloc_size = FIX_SIZE(subbuf_size * n_subbufs);
+ setup_callbacks(chan, cb);
+ kref_init(&chan->kref);
+
+ tmpname = kmalloc(NAME_MAX + 1, GFP_KERNEL);
+ if (!tmpname)
+ goto free_chan;
+
+ for_each_online_cpu(i) {
+ sprintf(tmpname, "%s%d", base_filename, i);
+ chan->buf[i] = relay_open_buf(chan, tmpname, parent,
+ &is_global);
+ if (!chan->buf[i])
+ goto free_bufs;
+
+ chan->buf[i]->cpu = i;
+ }
+
+ kfree(tmpname);
+ return chan;
+
+free_bufs:
+ for (i = 0; i < NR_CPUS; i++) {
+ if (!chan->buf[i])
+ break;
+ relay_close_buf(chan->buf[i]);
+ if (is_global)
+ break;
+ }
+ kfree(tmpname);
+
+free_chan:
+ kref_put(&chan->kref, relay_destroy_channel);
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(relay_open);
+
+/**
+ * relay_switch_subbuf - switch to a new sub-buffer
+ * @buf: channel buffer
+ * @length: size of current event
+ *
+ * Returns either the length passed in or 0 if full.
+ *
+ * Performs sub-buffer-switch tasks such as invoking callbacks,
+ * updating padding counts, waking up readers, etc.
+ */
+size_t relay_switch_subbuf(struct rchan_buf *buf, size_t length)
+{
+ void *old, *new;
+ size_t old_subbuf, new_subbuf;
+
+ if (unlikely(length > buf->chan->subbuf_size))
+ goto toobig;
+
+ if (buf->offset != buf->chan->subbuf_size + 1) {
+ buf->prev_padding = buf->chan->subbuf_size - buf->offset;
+ old_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
+ buf->padding[old_subbuf] = buf->prev_padding;
+ buf->subbufs_produced++;
+ buf->dentry->d_inode->i_size += buf->chan->subbuf_size -
+ buf->padding[old_subbuf];
+ smp_mb();
+ if (waitqueue_active(&buf->read_wait)) {
+ PREPARE_WORK(&buf->wake_readers, wakeup_readers, buf);
+ schedule_delayed_work(&buf->wake_readers, 1);
+ }
+ }
+
+ old = buf->data;
+ new_subbuf = buf->subbufs_produced % buf->chan->n_subbufs;
+ new = buf->start + new_subbuf * buf->chan->subbuf_size;
+ buf->offset = 0;
+ if (!buf->chan->cb->subbuf_start(buf, new, old, buf->prev_padding)) {
+ buf->offset = buf->chan->subbuf_size + 1;
+ return 0;
+ }
+ buf->data = new;
+ buf->padding[new_subbuf] = 0;
+
+ if (unlikely(length + buf->offset > buf->chan->subbuf_size))
+ goto toobig;
+
+ return length;
+
+toobig:
+ buf->chan->last_toobig = length;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(relay_switch_subbuf);
+
+/**
+ * relay_subbufs_consumed - update the buffer's sub-buffers-consumed count
+ * @chan: the channel
+ * @cpu: the cpu associated with the channel buffer to update
+ * @subbufs_consumed: number of sub-buffers to add to current buf's count
+ *
+ * Adds to the channel buffer's consumed sub-buffer count.
+ * subbufs_consumed should be the number of sub-buffers newly consumed,
+ * not the total consumed.
+ *
+ * NOTE: kernel clients don't need to call this function if the channel
+ * mode is 'overwrite'.
+ */
+void relay_subbufs_consumed(struct rchan *chan,
+ unsigned int cpu,
+ size_t subbufs_consumed)
+{
+ struct rchan_buf *buf;
+
+ if (!chan)
+ return;
+
+ if (cpu >= NR_CPUS || !chan->buf[cpu])
+ return;
+
+ buf = chan->buf[cpu];
+ buf->subbufs_consumed += subbufs_consumed;
+ if (buf->subbufs_consumed > buf->subbufs_produced)
+ buf->subbufs_consumed = buf->subbufs_produced;
+}
+EXPORT_SYMBOL_GPL(relay_subbufs_consumed);
+
+/**
+ * relay_close - close the channel
+ * @chan: the channel
+ *
+ * Closes all channel buffers and frees the channel.
+ */
+void relay_close(struct rchan *chan)
+{
+ unsigned int i;
+ struct rchan_buf *prev = NULL;
+
+ if (!chan)
+ return;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
+ relay_close_buf(chan->buf[i]);
+ prev = chan->buf[i];
+ }
+
+ if (chan->last_toobig)
+ printk(KERN_WARNING "relay: one or more items not logged "
+ "[item size (%Zd) > sub-buffer size (%Zd)]\n",
+ chan->last_toobig, chan->subbuf_size);
+
+ kref_put(&chan->kref, relay_destroy_channel);
+}
+EXPORT_SYMBOL_GPL(relay_close);
+
+/**
+ * relay_flush - close the channel
+ * @chan: the channel
+ *
+ * Flushes all channel buffers i.e. forces buffer switch.
+ */
+void relay_flush(struct rchan *chan)
+{
+ unsigned int i;
+ struct rchan_buf *prev = NULL;
+
+ if (!chan)
+ return;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
+ relay_switch_subbuf(chan->buf[i], 0);
+ prev = chan->buf[i];
+ }
+}
+EXPORT_SYMBOL_GPL(relay_flush);
+
+/**
+ * relay_file_open - open file op for relay files
+ * @inode: the inode
+ * @filp: the file
+ *
+ * Increments the channel buffer refcount.
+ */
+static int relay_file_open(struct inode *inode, struct file *filp)
+{
+ struct rchan_buf *buf = inode->u.generic_ip;
+ kref_get(&buf->kref);
+ filp->private_data = buf;
+
+ return 0;
+}
+
+/**
+ * relay_file_mmap - mmap file op for relay files
+ * @filp: the file
+ * @vma: the vma describing what to map
+ *
+ * Calls upon relay_mmap_buf to map the file into user space.
+ */
+static int relay_file_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+ struct rchan_buf *buf = filp->private_data;
+ return relay_mmap_buf(buf, vma);
+}
+
+/**
+ * relay_file_poll - poll file op for relay files
+ * @filp: the file
+ * @wait: poll table
+ *
+ * Poll implemention.
+ */
+static unsigned int relay_file_poll(struct file *filp, poll_table *wait)
+{
+ unsigned int mask = 0;
+ struct rchan_buf *buf = filp->private_data;
+
+ if (buf->finalized)
+ return POLLERR;
+
+ if (filp->f_mode & FMODE_READ) {
+ poll_wait(filp, &buf->read_wait, wait);
+ if (!relay_buf_empty(buf))
+ mask |= POLLIN | POLLRDNORM;
+ }
+
+ return mask;
+}
+
+/**
+ * relay_file_release - release file op for relay files
+ * @inode: the inode
+ * @filp: the file
+ *
+ * Decrements the channel refcount, as the filesystem is
+ * no longer using it.
+ */
+static int relay_file_release(struct inode *inode, struct file *filp)
+{
+ struct rchan_buf *buf = filp->private_data;
+ kref_put(&buf->kref, relay_remove_buf);
+
+ return 0;
+}
+
+/**
+ * relay_file_read_consume - update the consumed count for the buffer
+ */
+static void relay_file_read_consume(struct rchan_buf *buf,
+ size_t read_pos,
+ size_t bytes_consumed)
+{
+ size_t subbuf_size = buf->chan->subbuf_size;
+ size_t n_subbufs = buf->chan->n_subbufs;
+ size_t read_subbuf;
+
+ if (buf->bytes_consumed + bytes_consumed > subbuf_size) {
+ relay_subbufs_consumed(buf->chan, buf->cpu, 1);
+ buf->bytes_consumed = 0;
+ }
+
+ buf->bytes_consumed += bytes_consumed;
+ read_subbuf = read_pos / buf->chan->subbuf_size;
+ if (buf->bytes_consumed + buf->padding[read_subbuf] == subbuf_size) {
+ if ((read_subbuf == buf->subbufs_produced % n_subbufs) &&
+ (buf->offset == subbuf_size))
+ return;
+ relay_subbufs_consumed(buf->chan, buf->cpu, 1);
+ buf->bytes_consumed = 0;
+ }
+}
+
+/**
+ * relay_file_read_avail - boolean, are there unconsumed bytes available?
+ */
+static int relay_file_read_avail(struct rchan_buf *buf, size_t read_pos)
+{
+ size_t subbuf_size = buf->chan->subbuf_size;
+ size_t n_subbufs = buf->chan->n_subbufs;
+ size_t produced = buf->subbufs_produced;
+ size_t consumed = buf->subbufs_consumed;
+
+ relay_file_read_consume(buf, read_pos, 0);
+
+ if (unlikely(buf->offset > subbuf_size)) {
+ if (produced == consumed)
+ return 0;
+ return 1;
+ }
+
+ if (unlikely(produced - consumed >= n_subbufs)) {
+ consumed = (produced / n_subbufs) * n_subbufs;
+ buf->subbufs_consumed = consumed;
+ }
+
+ produced = (produced % n_subbufs) * subbuf_size + buf->offset;
+ consumed = (consumed % n_subbufs) * subbuf_size + buf->bytes_consumed;
+
+ if (consumed > produced)
+ produced += n_subbufs * subbuf_size;
+
+ if (consumed == produced)
+ return 0;
+
+ return 1;
+}
+
+/**
+ * relay_file_read_subbuf_avail - return bytes available in sub-buffer
+ */
+static size_t relay_file_read_subbuf_avail(size_t read_pos,
+ struct rchan_buf *buf)
+{
+ size_t padding, avail = 0;
+ size_t read_subbuf, read_offset, write_subbuf, write_offset;
+ size_t subbuf_size = buf->chan->subbuf_size;
+
+ write_subbuf = (buf->data - buf->start) / subbuf_size;
+ write_offset = buf->offset > subbuf_size ? subbuf_size : buf->offset;
+ read_subbuf = read_pos / subbuf_size;
+ read_offset = read_pos % subbuf_size;
+ padding = buf->padding[read_subbuf];
+
+ if (read_subbuf == write_subbuf) {
+ if (read_offset + padding < write_offset)
+ avail = write_offset - (read_offset + padding);
+ } else
+ avail = (subbuf_size - padding) - read_offset;
+
+ return avail;
+}
+
+/**
+ * relay_file_read_start_pos - find the first available byte to read
+ *
+ * If the read_pos is in the middle of padding, return the
+ * position of the first actually available byte, otherwise
+ * return the original value.
+ */
+static size_t relay_file_read_start_pos(size_t read_pos,
+ struct rchan_buf *buf)
+{
+ size_t read_subbuf, padding, padding_start, padding_end;
+ size_t subbuf_size = buf->chan->subbuf_size;
+ size_t n_subbufs = buf->chan->n_subbufs;
+
+ read_subbuf = read_pos / subbuf_size;
+ padding = buf->padding[read_subbuf];
+ padding_start = (read_subbuf + 1) * subbuf_size - padding;
+ padding_end = (read_subbuf + 1) * subbuf_size;
+ if (read_pos >= padding_start && read_pos < padding_end) {
+ read_subbuf = (read_subbuf + 1) % n_subbufs;
+ read_pos = read_subbuf * subbuf_size;
+ }
+
+ return read_pos;
+}
+
+/**
+ * relay_file_read_end_pos - return the new read position
+ */
+static size_t relay_file_read_end_pos(struct rchan_buf *buf,
+ size_t read_pos,
+ size_t count)
+{
+ size_t read_subbuf, padding, end_pos;
+ size_t subbuf_size = buf->chan->subbuf_size;
+ size_t n_subbufs = buf->chan->n_subbufs;
+
+ read_subbuf = read_pos / subbuf_size;
+ padding = buf->padding[read_subbuf];
+ if (read_pos % subbuf_size + count + padding == subbuf_size)
+ end_pos = (read_subbuf + 1) * subbuf_size;
+ else
+ end_pos = read_pos + count;
+ if (end_pos >= subbuf_size * n_subbufs)
+ end_pos = 0;
+
+ return end_pos;
+}
+
+/**
+ * subbuf_read_actor - read up to one subbuf's worth of data
+ */
+static int subbuf_read_actor(size_t read_start,
+ struct rchan_buf *buf,
+ size_t avail,
+ read_descriptor_t *desc,
+ read_actor_t actor)
+{
+ void *from;
+ int ret = 0;
+
+ from = buf->start + read_start;
+ ret = avail;
+ if (copy_to_user(desc->arg.data, from, avail)) {
+ desc->error = -EFAULT;
+ ret = 0;
+ }
+ desc->arg.data += ret;
+ desc->written += ret;
+ desc->count -= ret;
+
+ return ret;
+}
+
+/**
+ * subbuf_send_actor - send up to one subbuf's worth of data
+ */
+static int subbuf_send_actor(size_t read_start,
+ struct rchan_buf *buf,
+ size_t avail,
+ read_descriptor_t *desc,
+ read_actor_t actor)
+{
+ unsigned long pidx, poff;
+ unsigned int subbuf_pages;
+ int ret = 0;
+
+ subbuf_pages = buf->chan->alloc_size >> PAGE_SHIFT;
+ pidx = (read_start / PAGE_SIZE) % subbuf_pages;
+ poff = read_start & ~PAGE_MASK;
+ while (avail) {
+ struct page *p = buf->page_array[pidx];
+ unsigned int len;
+
+ len = PAGE_SIZE - poff;
+ if (len > avail)
+ len = avail;
+
+ len = actor(desc, p, poff, len);
+ if (desc->error)
+ break;
+
+ avail -= len;
+ ret += len;
+ poff = 0;
+ pidx = (pidx + 1) % subbuf_pages;
+ }
+
+ return ret;
+}
+
+typedef int (*subbuf_actor_t) (size_t read_start,
+ struct rchan_buf *buf,
+ size_t avail,
+ read_descriptor_t *desc,
+ read_actor_t actor);
+
+/**
+ * relay_file_read_subbufs - read count bytes, bridging subbuf boundaries
+ */
+static inline ssize_t relay_file_read_subbufs(struct file *filp,
+ loff_t *ppos,
+ size_t count,
+ subbuf_actor_t subbuf_actor,
+ read_actor_t actor,
+ void *target)
+{
+ struct rchan_buf *buf = filp->private_data;
+ size_t read_start, avail;
+ read_descriptor_t desc;
+ int ret;
+
+ if (!count)
+ return 0;
+
+ desc.written = 0;
+ desc.count = count;
+ desc.arg.data = target;
+ desc.error = 0;
+
+ mutex_lock(&filp->f_dentry->d_inode->i_mutex);
+ do {
+ if (!relay_file_read_avail(buf, *ppos))
+ break;
+
+ read_start = relay_file_read_start_pos(*ppos, buf);
+ avail = relay_file_read_subbuf_avail(read_start, buf);
+ if (!avail)
+ break;
+
+ avail = min(desc.count, avail);
+ ret = subbuf_actor(read_start, buf, avail, &desc, actor);
+ if (desc.error < 0)
+ break;
+
+ if (ret) {
+ relay_file_read_consume(buf, read_start, ret);
+ *ppos = relay_file_read_end_pos(buf, read_start, ret);
+ }
+ } while (desc.count && ret);
+ mutex_unlock(&filp->f_dentry->d_inode->i_mutex);
+
+ return desc.written;
+}
+
+static ssize_t relay_file_read(struct file *filp,
+ char __user *buffer,
+ size_t count,
+ loff_t *ppos)
+{
+ return relay_file_read_subbufs(filp, ppos, count, subbuf_read_actor,
+ NULL, buffer);
+}
+
+static ssize_t relay_file_sendfile(struct file *filp,
+ loff_t *ppos,
+ size_t count,
+ read_actor_t actor,
+ void *target)
+{
+ return relay_file_read_subbufs(filp, ppos, count, subbuf_send_actor,
+ actor, target);
+}
+
+struct file_operations relay_file_operations = {
+ .open = relay_file_open,
+ .poll = relay_file_poll,
+ .mmap = relay_file_mmap,
+ .read = relay_file_read,
+ .llseek = no_llseek,
+ .release = relay_file_release,
+ .sendfile = relay_file_sendfile,
+};
+EXPORT_SYMBOL_GPL(relay_file_operations);
diff --git a/kernel/sched.c b/kernel/sched.c
index 6b6e0d70eb3..7ffaabd64f8 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -237,6 +237,7 @@ struct runqueue {
task_t *migration_thread;
struct list_head migration_queue;
+ int cpu;
#endif
#ifdef CONFIG_SCHEDSTATS
@@ -1654,6 +1655,9 @@ unsigned long nr_iowait(void)
/*
* double_rq_lock - safely lock two runqueues
*
+ * We must take them in cpu order to match code in
+ * dependent_sleeper and wake_dependent_sleeper.
+ *
* Note this does not disable interrupts like task_rq_lock,
* you need to do so manually before calling.
*/
@@ -1665,7 +1669,7 @@ static void double_rq_lock(runqueue_t *rq1, runqueue_t *rq2)
spin_lock(&rq1->lock);
__acquire(rq2->lock); /* Fake it out ;) */
} else {
- if (rq1 < rq2) {
+ if (rq1->cpu < rq2->cpu) {
spin_lock(&rq1->lock);
spin_lock(&rq2->lock);
} else {
@@ -1701,7 +1705,7 @@ static void double_lock_balance(runqueue_t *this_rq, runqueue_t *busiest)
__acquires(this_rq->lock)
{
if (unlikely(!spin_trylock(&busiest->lock))) {
- if (busiest < this_rq) {
+ if (busiest->cpu < this_rq->cpu) {
spin_unlock(&this_rq->lock);
spin_lock(&busiest->lock);
spin_lock(&this_rq->lock);
@@ -2869,7 +2873,7 @@ asmlinkage void __sched schedule(void)
*/
if (likely(!current->exit_state)) {
if (unlikely(in_atomic())) {
- printk(KERN_ERR "scheduling while atomic: "
+ printk(KERN_ERR "BUG: scheduling while atomic: "
"%s/0x%08x/%d\n",
current->comm, preempt_count(), current->pid);
dump_stack();
@@ -6029,6 +6033,7 @@ void __init sched_init(void)
rq->push_cpu = 0;
rq->migration_thread = NULL;
INIT_LIST_HEAD(&rq->migration_queue);
+ rq->cpu = i;
#endif
atomic_set(&rq->nr_iowait, 0);
@@ -6069,7 +6074,7 @@ void __might_sleep(char *file, int line)
if (time_before(jiffies, prev_jiffy + HZ) && prev_jiffy)
return;
prev_jiffy = jiffies;
- printk(KERN_ERR "Debug: sleeping function called from invalid"
+ printk(KERN_ERR "BUG: sleeping function called from invalid"
" context at %s:%d\n", file, line);
printk("in_atomic():%d, irqs_disabled():%d\n",
in_atomic(), irqs_disabled());
diff --git a/kernel/signal.c b/kernel/signal.c
index ea154104a00..75f7341b0c3 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1922,6 +1922,8 @@ int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka,
sigset_t *mask = &current->blocked;
int signr = 0;
+ try_to_freeze();
+
relock:
spin_lock_irq(&current->sighand->siglock);
for (;;) {
@@ -2099,10 +2101,11 @@ long do_no_restart_syscall(struct restart_block *param)
int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
{
int error;
- sigset_t old_block;
spin_lock_irq(&current->sighand->siglock);
- old_block = current->blocked;
+ if (oldset)
+ *oldset = current->blocked;
+
error = 0;
switch (how) {
case SIG_BLOCK:
@@ -2119,8 +2122,7 @@ int sigprocmask(int how, sigset_t *set, sigset_t *oldset)
}
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);
- if (oldset)
- *oldset = old_block;
+
return error;
}
@@ -2307,7 +2309,6 @@ sys_rt_sigtimedwait(const sigset_t __user *uthese,
timeout = schedule_timeout_interruptible(timeout);
- try_to_freeze();
spin_lock_irq(&current->sighand->siglock);
sig = dequeue_signal(current, &these, &info);
current->blocked = current->real_blocked;
diff --git a/kernel/softlockup.c b/kernel/softlockup.c
index c67189a25d5..d9b3d5847ed 100644
--- a/kernel/softlockup.c
+++ b/kernel/softlockup.c
@@ -1,12 +1,11 @@
/*
* Detect Soft Lockups
*
- * started by Ingo Molnar, (C) 2005, Red Hat
+ * started by Ingo Molnar, Copyright (C) 2005, 2006 Red Hat, Inc.
*
* this code detects soft lockups: incidents in where on a CPU
* the kernel does not reschedule for 10 seconds or more.
*/
-
#include <linux/mm.h>
#include <linux/cpu.h>
#include <linux/init.h>
@@ -17,13 +16,14 @@
static DEFINE_SPINLOCK(print_lock);
-static DEFINE_PER_CPU(unsigned long, timestamp) = 0;
-static DEFINE_PER_CPU(unsigned long, print_timestamp) = 0;
+static DEFINE_PER_CPU(unsigned long, touch_timestamp);
+static DEFINE_PER_CPU(unsigned long, print_timestamp);
static DEFINE_PER_CPU(struct task_struct *, watchdog_task);
static int did_panic = 0;
-static int softlock_panic(struct notifier_block *this, unsigned long event,
- void *ptr)
+
+static int
+softlock_panic(struct notifier_block *this, unsigned long event, void *ptr)
{
did_panic = 1;
@@ -36,7 +36,7 @@ static struct notifier_block panic_block = {
void touch_softlockup_watchdog(void)
{
- per_cpu(timestamp, raw_smp_processor_id()) = jiffies;
+ per_cpu(touch_timestamp, raw_smp_processor_id()) = jiffies;
}
EXPORT_SYMBOL(touch_softlockup_watchdog);
@@ -44,25 +44,35 @@ EXPORT_SYMBOL(touch_softlockup_watchdog);
* This callback runs from the timer interrupt, and checks
* whether the watchdog thread has hung or not:
*/
-void softlockup_tick(struct pt_regs *regs)
+void softlockup_tick(void)
{
int this_cpu = smp_processor_id();
- unsigned long timestamp = per_cpu(timestamp, this_cpu);
+ unsigned long touch_timestamp = per_cpu(touch_timestamp, this_cpu);
- if (per_cpu(print_timestamp, this_cpu) == timestamp)
+ /* prevent double reports: */
+ if (per_cpu(print_timestamp, this_cpu) == touch_timestamp ||
+ did_panic ||
+ !per_cpu(watchdog_task, this_cpu))
return;
- /* Do not cause a second panic when there already was one */
- if (did_panic)
+ /* do not print during early bootup: */
+ if (unlikely(system_state != SYSTEM_RUNNING)) {
+ touch_softlockup_watchdog();
return;
+ }
- if (time_after(jiffies, timestamp + 10*HZ)) {
- per_cpu(print_timestamp, this_cpu) = timestamp;
+ /* Wake up the high-prio watchdog task every second: */
+ if (time_after(jiffies, touch_timestamp + HZ))
+ wake_up_process(per_cpu(watchdog_task, this_cpu));
+
+ /* Warn about unreasonable 10+ seconds delays: */
+ if (time_after(jiffies, touch_timestamp + 10*HZ)) {
+ per_cpu(print_timestamp, this_cpu) = touch_timestamp;
spin_lock(&print_lock);
printk(KERN_ERR "BUG: soft lockup detected on CPU#%d!\n",
this_cpu);
- show_regs(regs);
+ dump_stack();
spin_unlock(&print_lock);
}
}
@@ -77,18 +87,16 @@ static int watchdog(void * __bind_cpu)
sched_setscheduler(current, SCHED_FIFO, &param);
current->flags |= PF_NOFREEZE;
- set_current_state(TASK_INTERRUPTIBLE);
-
/*
- * Run briefly once per second - if this gets delayed for
- * more than 10 seconds then the debug-printout triggers
- * in softlockup_tick():
+ * Run briefly once per second to reset the softlockup timestamp.
+ * If this gets delayed for more than 10 seconds then the
+ * debug-printout triggers in softlockup_tick().
*/
while (!kthread_should_stop()) {
- msleep_interruptible(1000);
+ set_current_state(TASK_INTERRUPTIBLE);
touch_softlockup_watchdog();
+ schedule();
}
- __set_current_state(TASK_RUNNING);
return 0;
}
@@ -110,11 +118,11 @@ cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
printk("watchdog for %i failed\n", hotcpu);
return NOTIFY_BAD;
}
+ per_cpu(touch_timestamp, hotcpu) = jiffies;
per_cpu(watchdog_task, hotcpu) = p;
kthread_bind(p, hotcpu);
break;
case CPU_ONLINE:
-
wake_up_process(per_cpu(watchdog_task, hotcpu));
break;
#ifdef CONFIG_HOTPLUG_CPU
@@ -146,4 +154,3 @@ __init void spawn_softlockup_task(void)
notifier_chain_register(&panic_notifier_list, &panic_block);
}
-
diff --git a/kernel/spinlock.c b/kernel/spinlock.c
index 0375fcd5921..d1b810782bc 100644
--- a/kernel/spinlock.c
+++ b/kernel/spinlock.c
@@ -179,16 +179,16 @@ EXPORT_SYMBOL(_write_lock);
#define BUILD_LOCK_OPS(op, locktype) \
void __lockfunc _##op##_lock(locktype##_t *lock) \
{ \
- preempt_disable(); \
for (;;) { \
+ preempt_disable(); \
if (likely(_raw_##op##_trylock(lock))) \
break; \
preempt_enable(); \
+ \
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
while (!op##_can_lock(lock) && (lock)->break_lock) \
cpu_relax(); \
- preempt_disable(); \
} \
(lock)->break_lock = 0; \
} \
@@ -199,19 +199,18 @@ unsigned long __lockfunc _##op##_lock_irqsave(locktype##_t *lock) \
{ \
unsigned long flags; \
\
- preempt_disable(); \
for (;;) { \
+ preempt_disable(); \
local_irq_save(flags); \
if (likely(_raw_##op##_trylock(lock))) \
break; \
local_irq_restore(flags); \
- \
preempt_enable(); \
+ \
if (!(lock)->break_lock) \
(lock)->break_lock = 1; \
while (!op##_can_lock(lock) && (lock)->break_lock) \
cpu_relax(); \
- preempt_disable(); \
} \
(lock)->break_lock = 0; \
return flags; \
diff --git a/kernel/sys.c b/kernel/sys.c
index f91218a5463..38bc73ede2b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -224,18 +224,6 @@ int unregister_reboot_notifier(struct notifier_block * nb)
EXPORT_SYMBOL(unregister_reboot_notifier);
-#ifndef CONFIG_SECURITY
-int capable(int cap)
-{
- if (cap_raised(current->cap_effective, cap)) {
- current->flags |= PF_SUPERPRIV;
- return 1;
- }
- return 0;
-}
-EXPORT_SYMBOL(capable);
-#endif
-
static int set_one_prio(struct task_struct *p, int niceval, int error)
{
int no_nice;
@@ -1227,7 +1215,7 @@ asmlinkage long sys_setsid(void)
struct pid *pid;
int err = -EPERM;
- down(&tty_sem);
+ mutex_lock(&tty_mutex);
write_lock_irq(&tasklist_lock);
pid = find_pid(PIDTYPE_PGID, group_leader->pid);
@@ -1241,7 +1229,7 @@ asmlinkage long sys_setsid(void)
err = process_group(group_leader);
out:
write_unlock_irq(&tasklist_lock);
- up(&tty_sem);
+ mutex_unlock(&tty_mutex);
return err;
}
@@ -1375,7 +1363,7 @@ static void groups_sort(struct group_info *group_info)
/* a simple bsearch */
int groups_search(struct group_info *group_info, gid_t grp)
{
- int left, right;
+ unsigned int left, right;
if (!group_info)
return 0;
@@ -1383,7 +1371,7 @@ int groups_search(struct group_info *group_info, gid_t grp)
left = 0;
right = group_info->ngroups;
while (left < right) {
- int mid = (left+right)/2;
+ unsigned int mid = (left+right)/2;
int cmp = grp - GROUP_AT(group_info, mid);
if (cmp > 0)
left = mid + 1;
@@ -1433,7 +1421,6 @@ asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)
return -EINVAL;
/* no need to grab task_lock here; it cannot change */
- get_group_info(current->group_info);
i = current->group_info->ngroups;
if (gidsetsize) {
if (i > gidsetsize) {
@@ -1446,7 +1433,6 @@ asmlinkage long sys_getgroups(int gidsetsize, gid_t __user *grouplist)
}
}
out:
- put_group_info(current->group_info);
return i;
}
@@ -1487,9 +1473,7 @@ int in_group_p(gid_t grp)
{
int retval = 1;
if (grp != current->fsgid) {
- get_group_info(current->group_info);
retval = groups_search(current->group_info, grp);
- put_group_info(current->group_info);
}
return retval;
}
@@ -1500,9 +1484,7 @@ int in_egroup_p(gid_t grp)
{
int retval = 1;
if (grp != current->egid) {
- get_group_info(current->group_info);
retval = groups_search(current->group_info, grp);
- put_group_info(current->group_info);
}
return retval;
}
@@ -1630,20 +1612,21 @@ asmlinkage long sys_old_getrlimit(unsigned int resource, struct rlimit __user *r
asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
{
struct rlimit new_rlim, *old_rlim;
+ unsigned long it_prof_secs;
int retval;
if (resource >= RLIM_NLIMITS)
return -EINVAL;
- if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
+ if (copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
return -EFAULT;
- if (new_rlim.rlim_cur > new_rlim.rlim_max)
- return -EINVAL;
+ if (new_rlim.rlim_cur > new_rlim.rlim_max)
+ return -EINVAL;
old_rlim = current->signal->rlim + resource;
if ((new_rlim.rlim_max > old_rlim->rlim_max) &&
!capable(CAP_SYS_RESOURCE))
return -EPERM;
if (resource == RLIMIT_NOFILE && new_rlim.rlim_max > NR_OPEN)
- return -EPERM;
+ return -EPERM;
retval = security_task_setrlimit(resource, &new_rlim);
if (retval)
@@ -1653,19 +1636,40 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
*old_rlim = new_rlim;
task_unlock(current->group_leader);
- if (resource == RLIMIT_CPU && new_rlim.rlim_cur != RLIM_INFINITY &&
- (cputime_eq(current->signal->it_prof_expires, cputime_zero) ||
- new_rlim.rlim_cur <= cputime_to_secs(
- current->signal->it_prof_expires))) {
- cputime_t cputime = secs_to_cputime(new_rlim.rlim_cur);
+ if (resource != RLIMIT_CPU)
+ goto out;
+
+ /*
+ * RLIMIT_CPU handling. Note that the kernel fails to return an error
+ * code if it rejected the user's attempt to set RLIMIT_CPU. This is a
+ * very long-standing error, and fixing it now risks breakage of
+ * applications, so we live with it
+ */
+ if (new_rlim.rlim_cur == RLIM_INFINITY)
+ goto out;
+
+ it_prof_secs = cputime_to_secs(current->signal->it_prof_expires);
+ if (it_prof_secs == 0 || new_rlim.rlim_cur <= it_prof_secs) {
+ unsigned long rlim_cur = new_rlim.rlim_cur;
+ cputime_t cputime;
+
+ if (rlim_cur == 0) {
+ /*
+ * The caller is asking for an immediate RLIMIT_CPU
+ * expiry. But we use the zero value to mean "it was
+ * never set". So let's cheat and make it one second
+ * instead
+ */
+ rlim_cur = 1;
+ }
+ cputime = secs_to_cputime(rlim_cur);
read_lock(&tasklist_lock);
spin_lock_irq(&current->sighand->siglock);
- set_process_cpu_timer(current, CPUCLOCK_PROF,
- &cputime, NULL);
+ set_process_cpu_timer(current, CPUCLOCK_PROF, &cputime, NULL);
spin_unlock_irq(&current->sighand->siglock);
read_unlock(&tasklist_lock);
}
-
+out:
return 0;
}
@@ -1677,9 +1681,6 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
* a lot simpler! (Which we're not doing right now because we're not
* measuring them yet).
*
- * This expects to be called with tasklist_lock read-locked or better,
- * and the siglock not locked. It may momentarily take the siglock.
- *
* When sampling multiple threads for RUSAGE_SELF, under SMP we might have
* races with threads incrementing their own counters. But since word
* reads are atomic, we either get new values or old values and we don't
@@ -1687,6 +1688,25 @@ asmlinkage long sys_setrlimit(unsigned int resource, struct rlimit __user *rlim)
* the c* fields from p->signal from races with exit.c updating those
* fields when reaping, so a sample either gets all the additions of a
* given child after it's reaped, or none so this sample is before reaping.
+ *
+ * tasklist_lock locking optimisation:
+ * If we are current and single threaded, we do not need to take the tasklist
+ * lock or the siglock. No one else can take our signal_struct away,
+ * no one else can reap the children to update signal->c* counters, and
+ * no one else can race with the signal-> fields.
+ * If we do not take the tasklist_lock, the signal-> fields could be read
+ * out of order while another thread was just exiting. So we place a
+ * read memory barrier when we avoid the lock. On the writer side,
+ * write memory barrier is implied in __exit_signal as __exit_signal releases
+ * the siglock spinlock after updating the signal-> fields.
+ *
+ * We don't really need the siglock when we access the non c* fields
+ * of the signal_struct (for RUSAGE_SELF) even in multithreaded
+ * case, since we take the tasklist lock for read and the non c* signal->
+ * fields are updated only in __exit_signal, which is called with
+ * tasklist_lock taken for write, hence these two threads cannot execute
+ * concurrently.
+ *
*/
static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
@@ -1694,13 +1714,23 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
struct task_struct *t;
unsigned long flags;
cputime_t utime, stime;
+ int need_lock = 0;
memset((char *) r, 0, sizeof *r);
+ utime = stime = cputime_zero;
- if (unlikely(!p->signal))
- return;
+ if (p != current || !thread_group_empty(p))
+ need_lock = 1;
- utime = stime = cputime_zero;
+ if (need_lock) {
+ read_lock(&tasklist_lock);
+ if (unlikely(!p->signal)) {
+ read_unlock(&tasklist_lock);
+ return;
+ }
+ } else
+ /* See locking comments above */
+ smp_rmb();
switch (who) {
case RUSAGE_BOTH:
@@ -1740,6 +1770,8 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
BUG();
}
+ if (need_lock)
+ read_unlock(&tasklist_lock);
cputime_to_timeval(utime, &r->ru_utime);
cputime_to_timeval(stime, &r->ru_stime);
}
@@ -1747,9 +1779,7 @@ static void k_getrusage(struct task_struct *p, int who, struct rusage *r)
int getrusage(struct task_struct *p, int who, struct rusage __user *ru)
{
struct rusage r;
- read_lock(&tasklist_lock);
k_getrusage(p, who, &r);
- read_unlock(&tasklist_lock);
return copy_to_user(ru, &r, sizeof(r)) ? -EFAULT : 0;
}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 32b48e8ee36..e82726faeef 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -742,18 +742,18 @@ static ctl_table vm_table[] = {
{
.ctl_name = VM_DIRTY_WB_CS,
.procname = "dirty_writeback_centisecs",
- .data = &dirty_writeback_centisecs,
- .maxlen = sizeof(dirty_writeback_centisecs),
+ .data = &dirty_writeback_interval,
+ .maxlen = sizeof(dirty_writeback_interval),
.mode = 0644,
.proc_handler = &dirty_writeback_centisecs_handler,
},
{
.ctl_name = VM_DIRTY_EXPIRE_CS,
.procname = "dirty_expire_centisecs",
- .data = &dirty_expire_centisecs,
- .maxlen = sizeof(dirty_expire_centisecs),
+ .data = &dirty_expire_interval,
+ .maxlen = sizeof(dirty_expire_interval),
.mode = 0644,
- .proc_handler = &proc_dointvec,
+ .proc_handler = &proc_dointvec_userhz_jiffies,
},
{
.ctl_name = VM_NR_PDFLUSH_THREADS,
@@ -848,9 +848,8 @@ static ctl_table vm_table[] = {
.data = &laptop_mode,
.maxlen = sizeof(laptop_mode),
.mode = 0644,
- .proc_handler = &proc_dointvec,
- .strategy = &sysctl_intvec,
- .extra1 = &zero,
+ .proc_handler = &proc_dointvec_jiffies,
+ .strategy = &sysctl_jiffies,
},
{
.ctl_name = VM_BLOCK_DUMP,
@@ -2054,6 +2053,8 @@ static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
int write, void *data)
{
if (write) {
+ if (*lvalp > LONG_MAX / HZ)
+ return 1;
*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
} else {
int val = *valp;
@@ -2075,6 +2076,8 @@ static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
int write, void *data)
{
if (write) {
+ if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
+ return 1;
*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
} else {
int val = *valp;
diff --git a/kernel/time.c b/kernel/time.c
index 804539165d8..e00a97b7724 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -202,24 +202,6 @@ asmlinkage long sys_settimeofday(struct timeval __user *tv,
return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
}
-long pps_offset; /* pps time offset (us) */
-long pps_jitter = MAXTIME; /* time dispersion (jitter) (us) */
-
-long pps_freq; /* frequency offset (scaled ppm) */
-long pps_stabil = MAXFREQ; /* frequency dispersion (scaled ppm) */
-
-long pps_valid = PPS_VALID; /* pps signal watchdog counter */
-
-int pps_shift = PPS_SHIFT; /* interval duration (s) (shift) */
-
-long pps_jitcnt; /* jitter limit exceeded */
-long pps_calcnt; /* calibration intervals */
-long pps_errcnt; /* calibration errors */
-long pps_stbcnt; /* stability limit exceeded */
-
-/* hook for a loadable hardpps kernel module */
-void (*hardpps_ptr)(struct timeval *);
-
/* we call this to notify the arch when the clock is being
* controlled. If no such arch routine, do nothing.
*/
@@ -279,7 +261,7 @@ int do_adjtimex(struct timex *txc)
result = -EINVAL;
goto leave;
}
- time_freq = txc->freq - pps_freq;
+ time_freq = txc->freq;
}
if (txc->modes & ADJ_MAXERROR) {
@@ -312,10 +294,8 @@ int do_adjtimex(struct timex *txc)
if ((time_next_adjust = txc->offset) == 0)
time_adjust = 0;
}
- else if ( time_status & (STA_PLL | STA_PPSTIME) ) {
- ltemp = (time_status & (STA_PPSTIME | STA_PPSSIGNAL)) ==
- (STA_PPSTIME | STA_PPSSIGNAL) ?
- pps_offset : txc->offset;
+ else if (time_status & STA_PLL) {
+ ltemp = txc->offset;
/*
* Scale the phase adjustment and
@@ -356,23 +336,14 @@ int do_adjtimex(struct timex *txc)
}
time_freq = min(time_freq, time_tolerance);
time_freq = max(time_freq, -time_tolerance);
- } /* STA_PLL || STA_PPSTIME */
+ } /* STA_PLL */
} /* txc->modes & ADJ_OFFSET */
if (txc->modes & ADJ_TICK) {
tick_usec = txc->tick;
tick_nsec = TICK_USEC_TO_NSEC(tick_usec);
}
} /* txc->modes */
-leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
- || ((time_status & (STA_PPSFREQ|STA_PPSTIME)) != 0
- && (time_status & STA_PPSSIGNAL) == 0)
- /* p. 24, (b) */
- || ((time_status & (STA_PPSTIME|STA_PPSJITTER))
- == (STA_PPSTIME|STA_PPSJITTER))
- /* p. 24, (c) */
- || ((time_status & STA_PPSFREQ) != 0
- && (time_status & (STA_PPSWANDER|STA_PPSERROR)) != 0))
- /* p. 24, (d) */
+leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
result = TIME_ERROR;
if ((txc->modes & ADJ_OFFSET_SINGLESHOT) == ADJ_OFFSET_SINGLESHOT)
@@ -380,7 +351,7 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
else {
txc->offset = shift_right(time_offset, SHIFT_UPDATE);
}
- txc->freq = time_freq + pps_freq;
+ txc->freq = time_freq;
txc->maxerror = time_maxerror;
txc->esterror = time_esterror;
txc->status = time_status;
@@ -388,14 +359,16 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0
txc->precision = time_precision;
txc->tolerance = time_tolerance;
txc->tick = tick_usec;
- txc->ppsfreq = pps_freq;
- txc->jitter = pps_jitter >> PPS_AVG;
- txc->shift = pps_shift;
- txc->stabil = pps_stabil;
- txc->jitcnt = pps_jitcnt;
- txc->calcnt = pps_calcnt;
- txc->errcnt = pps_errcnt;
- txc->stbcnt = pps_stbcnt;
+
+ /* PPS is not implemented, so these are zero */
+ txc->ppsfreq = 0;
+ txc->jitter = 0;
+ txc->shift = 0;
+ txc->stabil = 0;
+ txc->jitcnt = 0;
+ txc->calcnt = 0;
+ txc->errcnt = 0;
+ txc->stbcnt = 0;
write_sequnlock_irq(&xtime_lock);
do_gettimeofday(&txc->time);
notify_arch_cmos_timer();
diff --git a/kernel/timer.c b/kernel/timer.c
index 2410c18dbeb..ab189dd187c 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -86,7 +86,8 @@ struct tvec_t_base_s {
} ____cacheline_aligned_in_smp;
typedef struct tvec_t_base_s tvec_base_t;
-static DEFINE_PER_CPU(tvec_base_t, tvec_bases);
+static DEFINE_PER_CPU(tvec_base_t *, tvec_bases);
+static tvec_base_t boot_tvec_bases;
static inline void set_running_timer(tvec_base_t *base,
struct timer_list *timer)
@@ -157,7 +158,7 @@ EXPORT_SYMBOL(__init_timer_base);
void fastcall init_timer(struct timer_list *timer)
{
timer->entry.next = NULL;
- timer->base = &per_cpu(tvec_bases, raw_smp_processor_id()).t_base;
+ timer->base = &per_cpu(tvec_bases, raw_smp_processor_id())->t_base;
}
EXPORT_SYMBOL(init_timer);
@@ -218,7 +219,7 @@ int __mod_timer(struct timer_list *timer, unsigned long expires)
ret = 1;
}
- new_base = &__get_cpu_var(tvec_bases);
+ new_base = __get_cpu_var(tvec_bases);
if (base != &new_base->t_base) {
/*
@@ -258,7 +259,7 @@ EXPORT_SYMBOL(__mod_timer);
*/
void add_timer_on(struct timer_list *timer, int cpu)
{
- tvec_base_t *base = &per_cpu(tvec_bases, cpu);
+ tvec_base_t *base = per_cpu(tvec_bases, cpu);
unsigned long flags;
BUG_ON(timer_pending(timer) || !timer->function);
@@ -504,7 +505,7 @@ unsigned long next_timer_interrupt(void)
}
hr_expires += jiffies;
- base = &__get_cpu_var(tvec_bases);
+ base = __get_cpu_var(tvec_bases);
spin_lock(&base->t_base.lock);
expires = base->timer_jiffies + (LONG_MAX >> 1);
list = NULL;
@@ -696,18 +697,9 @@ static void second_overflow(void)
/*
* Compute the frequency estimate and additional phase adjustment due
- * to frequency error for the next second. When the PPS signal is
- * engaged, gnaw on the watchdog counter and update the frequency
- * computed by the pll and the PPS signal.
+ * to frequency error for the next second.
*/
- pps_valid++;
- if (pps_valid == PPS_VALID) { /* PPS signal lost */
- pps_jitter = MAXTIME;
- pps_stabil = MAXFREQ;
- time_status &= ~(STA_PPSSIGNAL | STA_PPSJITTER |
- STA_PPSWANDER | STA_PPSERROR);
- }
- ltemp = time_freq + pps_freq;
+ ltemp = time_freq;
time_adj += shift_right(ltemp,(SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE));
#if HZ == 100
@@ -901,7 +893,7 @@ EXPORT_SYMBOL(xtime_lock);
*/
static void run_timer_softirq(struct softirq_action *h)
{
- tvec_base_t *base = &__get_cpu_var(tvec_bases);
+ tvec_base_t *base = __get_cpu_var(tvec_bases);
hrtimer_run_queues();
if (time_after_eq(jiffies, base->timer_jiffies))
@@ -914,6 +906,7 @@ static void run_timer_softirq(struct softirq_action *h)
void run_local_timers(void)
{
raise_softirq(TIMER_SOFTIRQ);
+ softlockup_tick();
}
/*
@@ -944,7 +937,6 @@ void do_timer(struct pt_regs *regs)
/* prevent loading jiffies before storing new jiffies_64 value. */
barrier();
update_times();
- softlockup_tick(regs);
}
#ifdef __ARCH_WANT_SYS_ALARM
@@ -955,19 +947,7 @@ void do_timer(struct pt_regs *regs)
*/
asmlinkage unsigned long sys_alarm(unsigned int seconds)
{
- struct itimerval it_new, it_old;
- unsigned int oldalarm;
-
- it_new.it_interval.tv_sec = it_new.it_interval.tv_usec = 0;
- it_new.it_value.tv_sec = seconds;
- it_new.it_value.tv_usec = 0;
- do_setitimer(ITIMER_REAL, &it_new, &it_old);
- oldalarm = it_old.it_value.tv_sec;
- /* ehhh.. We can't return 0 if we have an alarm pending.. */
- /* And we'd better return too much than too little anyway */
- if ((!oldalarm && it_old.it_value.tv_usec) || it_old.it_value.tv_usec >= 500000)
- oldalarm++;
- return oldalarm;
+ return alarm_setitimer(seconds);
}
#endif
@@ -1256,12 +1236,32 @@ asmlinkage long sys_sysinfo(struct sysinfo __user *info)
return 0;
}
-static void __devinit init_timers_cpu(int cpu)
+static int __devinit init_timers_cpu(int cpu)
{
int j;
tvec_base_t *base;
- base = &per_cpu(tvec_bases, cpu);
+ base = per_cpu(tvec_bases, cpu);
+ if (!base) {
+ static char boot_done;
+
+ /*
+ * Cannot do allocation in init_timers as that runs before the
+ * allocator initializes (and would waste memory if there are
+ * more possible CPUs than will ever be installed/brought up).
+ */
+ if (boot_done) {
+ base = kmalloc_node(sizeof(*base), GFP_KERNEL,
+ cpu_to_node(cpu));
+ if (!base)
+ return -ENOMEM;
+ memset(base, 0, sizeof(*base));
+ } else {
+ base = &boot_tvec_bases;
+ boot_done = 1;
+ }
+ per_cpu(tvec_bases, cpu) = base;
+ }
spin_lock_init(&base->t_base.lock);
for (j = 0; j < TVN_SIZE; j++) {
INIT_LIST_HEAD(base->tv5.vec + j);
@@ -1273,6 +1273,7 @@ static void __devinit init_timers_cpu(int cpu)
INIT_LIST_HEAD(base->tv1.vec + j);
base->timer_jiffies = jiffies;
+ return 0;
}
#ifdef CONFIG_HOTPLUG_CPU
@@ -1295,8 +1296,8 @@ static void __devinit migrate_timers(int cpu)
int i;
BUG_ON(cpu_online(cpu));
- old_base = &per_cpu(tvec_bases, cpu);
- new_base = &get_cpu_var(tvec_bases);
+ old_base = per_cpu(tvec_bases, cpu);
+ new_base = get_cpu_var(tvec_bases);
local_irq_disable();
spin_lock(&new_base->t_base.lock);
@@ -1326,7 +1327,8 @@ static int __devinit timer_cpu_notify(struct notifier_block *self,
long cpu = (long)hcpu;
switch(action) {
case CPU_UP_PREPARE:
- init_timers_cpu(cpu);
+ if (init_timers_cpu(cpu) < 0)
+ return NOTIFY_BAD;
break;
#ifdef CONFIG_HOTPLUG_CPU
case CPU_DEAD:
diff --git a/kernel/user.c b/kernel/user.c
index d9deae43a9a..2116642f42c 100644
--- a/kernel/user.c
+++ b/kernel/user.c
@@ -105,15 +105,19 @@ void free_uid(struct user_struct *up)
{
unsigned long flags;
+ if (!up)
+ return;
+
local_irq_save(flags);
- if (up && atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
+ if (atomic_dec_and_lock(&up->__count, &uidhash_lock)) {
uid_hash_remove(up);
+ spin_unlock_irqrestore(&uidhash_lock, flags);
key_put(up->uid_keyring);
key_put(up->session_keyring);
kmem_cache_free(uid_cachep, up);
- spin_unlock(&uidhash_lock);
+ } else {
+ local_irq_restore(flags);
}
- local_irq_restore(flags);
}
struct user_struct * alloc_uid(uid_t uid)
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index a314e663d51..0bda3c5259f 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -78,13 +78,17 @@ config SCHEDSTATS
this adds.
config DEBUG_SLAB
- bool "Debug memory allocations"
+ bool "Debug slab memory allocations"
depends on DEBUG_KERNEL && SLAB
help
Say Y here to have the kernel do limited verification on memory
allocation as well as poisoning memory on free to catch use of freed
memory. This can make kmalloc/kfree-intensive workloads much slower.
+config DEBUG_SLAB_LEAK
+ bool "Memory leak debugging"
+ depends on DEBUG_SLAB
+
config DEBUG_PREEMPT
bool "Debug preemptible kernel"
depends on DEBUG_KERNEL && PREEMPT
@@ -195,6 +199,17 @@ config FRAME_POINTER
some architectures or if you use external debuggers.
If you don't debug the kernel, you can say N.
+config UNWIND_INFO
+ bool "Compile the kernel with frame unwind information"
+ depends on !IA64
+ depends on !MODULES || !(MIPS || PARISC || PPC || SUPERH || SPARC64 || V850)
+ default DEBUG_KERNEL
+ help
+ If you say Y here the resulting kernel image will be slightly larger
+ but not slower, and it will give very useful debugging information.
+ If you don't debug the kernel, you can say N, but we may not be able
+ to solve problems without frame unwind information or frame pointers.
+
config FORCED_INLINING
bool "Force gcc to inline functions marked 'inline'"
depends on DEBUG_KERNEL
diff --git a/lib/Makefile b/lib/Makefile
index 648b2c1242f..f827e3c24ec 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -7,6 +7,8 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
idr.o div64.o int_sqrt.o bitmap.o extable.o prio_tree.o \
sha1.o
+lib-$(CONFIG_SMP) += cpumask.o
+
lib-y += kobject.o kref.o kobject_uevent.o klist.o
obj-y += sort.o parser.o halfmd4.o iomap_copy.o
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 48e708381d4..8acab0e176e 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -676,84 +676,143 @@ int bitmap_bitremap(int oldbit, const unsigned long *old,
}
EXPORT_SYMBOL(bitmap_bitremap);
-/**
- * bitmap_find_free_region - find a contiguous aligned mem region
- * @bitmap: an array of unsigned longs corresponding to the bitmap
- * @bits: number of bits in the bitmap
- * @order: region size to find (size is actually 1<<order)
+/*
+ * Common code for bitmap_*_region() routines.
+ * bitmap: array of unsigned longs corresponding to the bitmap
+ * pos: the beginning of the region
+ * order: region size (log base 2 of number of bits)
+ * reg_op: operation(s) to perform on that region of bitmap
*
- * This is used to allocate a memory region from a bitmap. The idea is
- * that the region has to be 1<<order sized and 1<<order aligned (this
- * makes the search algorithm much faster).
+ * Can set, verify and/or release a region of bits in a bitmap,
+ * depending on which combination of REG_OP_* flag bits is set.
*
- * The region is marked as set bits in the bitmap if a free one is
- * found.
+ * A region of a bitmap is a sequence of bits in the bitmap, of
+ * some size '1 << order' (a power of two), aligned to that same
+ * '1 << order' power of two.
*
- * Returns either beginning of region or negative error
+ * Returns 1 if REG_OP_ISFREE succeeds (region is all zero bits).
+ * Returns 0 in all other cases and reg_ops.
*/
-int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
-{
- unsigned long mask;
- int pages = 1 << order;
- int i;
- if(pages > BITS_PER_LONG)
- return -EINVAL;
+enum {
+ REG_OP_ISFREE, /* true if region is all zero bits */
+ REG_OP_ALLOC, /* set all bits in region */
+ REG_OP_RELEASE, /* clear all bits in region */
+};
- /* make a mask of the order */
- mask = (1ul << (pages - 1));
+static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op)
+{
+ int nbits_reg; /* number of bits in region */
+ int index; /* index first long of region in bitmap */
+ int offset; /* bit offset region in bitmap[index] */
+ int nlongs_reg; /* num longs spanned by region in bitmap */
+ int nbitsinlong; /* num bits of region in each spanned long */
+ unsigned long mask; /* bitmask for one long of region */
+ int i; /* scans bitmap by longs */
+ int ret = 0; /* return value */
+
+ /*
+ * Either nlongs_reg == 1 (for small orders that fit in one long)
+ * or (offset == 0 && mask == ~0UL) (for larger multiword orders.)
+ */
+ nbits_reg = 1 << order;
+ index = pos / BITS_PER_LONG;
+ offset = pos - (index * BITS_PER_LONG);
+ nlongs_reg = BITS_TO_LONGS(nbits_reg);
+ nbitsinlong = min(nbits_reg, BITS_PER_LONG);
+
+ /*
+ * Can't do "mask = (1UL << nbitsinlong) - 1", as that
+ * overflows if nbitsinlong == BITS_PER_LONG.
+ */
+ mask = (1UL << (nbitsinlong - 1));
mask += mask - 1;
+ mask <<= offset;
- /* run up the bitmap pages bits at a time */
- for (i = 0; i < bits; i += pages) {
- int index = i/BITS_PER_LONG;
- int offset = i - (index * BITS_PER_LONG);
- if((bitmap[index] & (mask << offset)) == 0) {
- /* set region in bimap */
- bitmap[index] |= (mask << offset);
- return i;
+ switch (reg_op) {
+ case REG_OP_ISFREE:
+ for (i = 0; i < nlongs_reg; i++) {
+ if (bitmap[index + i] & mask)
+ goto done;
}
+ ret = 1; /* all bits in region free (zero) */
+ break;
+
+ case REG_OP_ALLOC:
+ for (i = 0; i < nlongs_reg; i++)
+ bitmap[index + i] |= mask;
+ break;
+
+ case REG_OP_RELEASE:
+ for (i = 0; i < nlongs_reg; i++)
+ bitmap[index + i] &= ~mask;
+ break;
}
- return -ENOMEM;
+done:
+ return ret;
+}
+
+/**
+ * bitmap_find_free_region - find a contiguous aligned mem region
+ * @bitmap: array of unsigned longs corresponding to the bitmap
+ * @bits: number of bits in the bitmap
+ * @order: region size (log base 2 of number of bits) to find
+ *
+ * Find a region of free (zero) bits in a @bitmap of @bits bits and
+ * allocate them (set them to one). Only consider regions of length
+ * a power (@order) of two, aligned to that power of two, which
+ * makes the search algorithm much faster.
+ *
+ * Return the bit offset in bitmap of the allocated region,
+ * or -errno on failure.
+ */
+int bitmap_find_free_region(unsigned long *bitmap, int bits, int order)
+{
+ int pos; /* scans bitmap by regions of size order */
+
+ for (pos = 0; pos < bits; pos += (1 << order))
+ if (__reg_op(bitmap, pos, order, REG_OP_ISFREE))
+ break;
+ if (pos == bits)
+ return -ENOMEM;
+ __reg_op(bitmap, pos, order, REG_OP_ALLOC);
+ return pos;
}
EXPORT_SYMBOL(bitmap_find_free_region);
/**
- * bitmap_release_region - release allocated bitmap region
- * @bitmap: a pointer to the bitmap
- * @pos: the beginning of the region
- * @order: the order of the bits to release (number is 1<<order)
+ * bitmap_release_region - release allocated bitmap region
+ * @bitmap: array of unsigned longs corresponding to the bitmap
+ * @pos: beginning of bit region to release
+ * @order: region size (log base 2 of number of bits) to release
*
* This is the complement to __bitmap_find_free_region and releases
* the found region (by clearing it in the bitmap).
+ *
+ * No return value.
*/
void bitmap_release_region(unsigned long *bitmap, int pos, int order)
{
- int pages = 1 << order;
- unsigned long mask = (1ul << (pages - 1));
- int index = pos/BITS_PER_LONG;
- int offset = pos - (index * BITS_PER_LONG);
- mask += mask - 1;
- bitmap[index] &= ~(mask << offset);
+ __reg_op(bitmap, pos, order, REG_OP_RELEASE);
}
EXPORT_SYMBOL(bitmap_release_region);
+/**
+ * bitmap_allocate_region - allocate bitmap region
+ * @bitmap: array of unsigned longs corresponding to the bitmap
+ * @pos: beginning of bit region to allocate
+ * @order: region size (log base 2 of number of bits) to allocate
+ *
+ * Allocate (set bits in) a specified region of a bitmap.
+ *
+ * Return 0 on success, or -EBUSY if specified region wasn't
+ * free (not all bits were zero).
+ */
int bitmap_allocate_region(unsigned long *bitmap, int pos, int order)
{
- int pages = 1 << order;
- unsigned long mask = (1ul << (pages - 1));
- int index = pos/BITS_PER_LONG;
- int offset = pos - (index * BITS_PER_LONG);
-
- /* We don't do regions of pages > BITS_PER_LONG. The
- * algorithm would be a simple look for multiple zeros in the
- * array, but there's no driver today that needs this. If you
- * trip this BUG(), you get to code it... */
- BUG_ON(pages > BITS_PER_LONG);
- mask += mask - 1;
- if (bitmap[index] & (mask << offset))
+ if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE))
return -EBUSY;
- bitmap[index] |= (mask << offset);
+ __reg_op(bitmap, pos, order, REG_OP_ALLOC);
return 0;
}
EXPORT_SYMBOL(bitmap_allocate_region);
diff --git a/lib/cpumask.c b/lib/cpumask.c
new file mode 100644
index 00000000000..3a67dc5ada7
--- /dev/null
+++ b/lib/cpumask.c
@@ -0,0 +1,45 @@
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/cpumask.h>
+#include <linux/module.h>
+
+int __first_cpu(const cpumask_t *srcp)
+{
+ return min_t(int, NR_CPUS, find_first_bit(srcp->bits, NR_CPUS));
+}
+EXPORT_SYMBOL(__first_cpu);
+
+int __next_cpu(int n, const cpumask_t *srcp)
+{
+ return min_t(int, NR_CPUS, find_next_bit(srcp->bits, NR_CPUS, n+1));
+}
+EXPORT_SYMBOL(__next_cpu);
+
+/*
+ * Find the highest possible smp_processor_id()
+ *
+ * Note: if we're prepared to assume that cpu_possible_map never changes
+ * (reasonable) then this function should cache its return value.
+ */
+int highest_possible_processor_id(void)
+{
+ unsigned int cpu;
+ unsigned highest = 0;
+
+ for_each_cpu_mask(cpu, cpu_possible_map)
+ highest = cpu;
+ return highest;
+}
+EXPORT_SYMBOL(highest_possible_processor_id);
+
+int __any_online_cpu(const cpumask_t *mask)
+{
+ int cpu;
+
+ for_each_cpu_mask(cpu, *mask) {
+ if (cpu_online(cpu))
+ break;
+ }
+ return cpu;
+}
+EXPORT_SYMBOL(__any_online_cpu);
diff --git a/lib/extable.c b/lib/extable.c
index 18df57c029d..01c08b5836f 100644
--- a/lib/extable.c
+++ b/lib/extable.c
@@ -1,5 +1,4 @@
/*
- * lib/extable.c
* Derived from arch/ppc/mm/extable.c and arch/i386/mm/extable.c.
*
* Copyright (C) 2004 Paul Mackerras, IBM Corp.
diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 1e5b17dc7e3..7097bb239e4 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -37,7 +37,6 @@
#else
#define RADIX_TREE_MAP_SHIFT 3 /* For more stressful testing */
#endif
-#define RADIX_TREE_TAGS 2
#define RADIX_TREE_MAP_SIZE (1UL << RADIX_TREE_MAP_SHIFT)
#define RADIX_TREE_MAP_MASK (RADIX_TREE_MAP_SIZE-1)
@@ -48,7 +47,7 @@
struct radix_tree_node {
unsigned int count;
void *slots[RADIX_TREE_MAP_SIZE];
- unsigned long tags[RADIX_TREE_TAGS][RADIX_TREE_TAG_LONGS];
+ unsigned long tags[RADIX_TREE_MAX_TAGS][RADIX_TREE_TAG_LONGS];
};
struct radix_tree_path {
@@ -135,17 +134,20 @@ out:
return ret;
}
-static inline void tag_set(struct radix_tree_node *node, int tag, int offset)
+static inline void tag_set(struct radix_tree_node *node, unsigned int tag,
+ int offset)
{
__set_bit(offset, node->tags[tag]);
}
-static inline void tag_clear(struct radix_tree_node *node, int tag, int offset)
+static inline void tag_clear(struct radix_tree_node *node, unsigned int tag,
+ int offset)
{
__clear_bit(offset, node->tags[tag]);
}
-static inline int tag_get(struct radix_tree_node *node, int tag, int offset)
+static inline int tag_get(struct radix_tree_node *node, unsigned int tag,
+ int offset)
{
return test_bit(offset, node->tags[tag]);
}
@@ -154,7 +156,7 @@ static inline int tag_get(struct radix_tree_node *node, int tag, int offset)
* Returns 1 if any slot in the node has this tag set.
* Otherwise returns 0.
*/
-static inline int any_tag_set(struct radix_tree_node *node, int tag)
+static inline int any_tag_set(struct radix_tree_node *node, unsigned int tag)
{
int idx;
for (idx = 0; idx < RADIX_TREE_TAG_LONGS; idx++) {
@@ -180,7 +182,7 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
{
struct radix_tree_node *node;
unsigned int height;
- char tags[RADIX_TREE_TAGS];
+ char tags[RADIX_TREE_MAX_TAGS];
int tag;
/* Figure out what the height should be. */
@@ -197,7 +199,7 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
* Prepare the tag status of the top-level node for propagation
* into the newly-pushed top-level node(s)
*/
- for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+ for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
tags[tag] = 0;
if (any_tag_set(root->rnode, tag))
tags[tag] = 1;
@@ -211,7 +213,7 @@ static int radix_tree_extend(struct radix_tree_root *root, unsigned long index)
node->slots[0] = root->rnode;
/* Propagate the aggregated tag info into the new root */
- for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+ for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
if (tags[tag])
tag_set(node, tag, 0);
}
@@ -349,14 +351,15 @@ EXPORT_SYMBOL(radix_tree_lookup);
* @index: index key
* @tag: tag index
*
- * Set the search tag corresponging to @index in the radix tree. From
+ * Set the search tag (which must be < RADIX_TREE_MAX_TAGS)
+ * corresponding to @index in the radix tree. From
* the root all the way down to the leaf node.
*
* Returns the address of the tagged item. Setting a tag on a not-present
* item is a bug.
*/
void *radix_tree_tag_set(struct radix_tree_root *root,
- unsigned long index, int tag)
+ unsigned long index, unsigned int tag)
{
unsigned int height, shift;
struct radix_tree_node *slot;
@@ -390,7 +393,8 @@ EXPORT_SYMBOL(radix_tree_tag_set);
* @index: index key
* @tag: tag index
*
- * Clear the search tag corresponging to @index in the radix tree. If
+ * Clear the search tag (which must be < RADIX_TREE_MAX_TAGS)
+ * corresponding to @index in the radix tree. If
* this causes the leaf node to have no tags set then clear the tag in the
* next-to-leaf node, etc.
*
@@ -398,7 +402,7 @@ EXPORT_SYMBOL(radix_tree_tag_set);
* has the same return value and semantics as radix_tree_lookup().
*/
void *radix_tree_tag_clear(struct radix_tree_root *root,
- unsigned long index, int tag)
+ unsigned long index, unsigned int tag)
{
struct radix_tree_path path[RADIX_TREE_MAX_PATH], *pathp = path;
struct radix_tree_node *slot;
@@ -450,7 +454,7 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
* radix_tree_tag_get - get a tag on a radix tree node
* @root: radix tree root
* @index: index key
- * @tag: tag index
+ * @tag: tag index (< RADIX_TREE_MAX_TAGS)
*
* Return values:
*
@@ -459,7 +463,7 @@ EXPORT_SYMBOL(radix_tree_tag_clear);
* -1: tag present, unset
*/
int radix_tree_tag_get(struct radix_tree_root *root,
- unsigned long index, int tag)
+ unsigned long index, unsigned int tag)
{
unsigned int height, shift;
struct radix_tree_node *slot;
@@ -592,7 +596,7 @@ EXPORT_SYMBOL(radix_tree_gang_lookup);
*/
static unsigned int
__lookup_tag(struct radix_tree_root *root, void **results, unsigned long index,
- unsigned int max_items, unsigned long *next_index, int tag)
+ unsigned int max_items, unsigned long *next_index, unsigned int tag)
{
unsigned int nr_found = 0;
unsigned int shift;
@@ -646,7 +650,7 @@ out:
* @results: where the results of the lookup are placed
* @first_index: start the lookup from this key
* @max_items: place up to this many items at *results
- * @tag: the tag index
+ * @tag: the tag index (< RADIX_TREE_MAX_TAGS)
*
* Performs an index-ascending scan of the tree for present items which
* have the tag indexed by @tag set. Places the items at *@results and
@@ -654,7 +658,8 @@ out:
*/
unsigned int
radix_tree_gang_lookup_tag(struct radix_tree_root *root, void **results,
- unsigned long first_index, unsigned int max_items, int tag)
+ unsigned long first_index, unsigned int max_items,
+ unsigned int tag)
{
const unsigned long max_index = radix_tree_maxindex(root->height);
unsigned long cur_index = first_index;
@@ -716,7 +721,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
struct radix_tree_node *slot;
unsigned int height, shift;
void *ret = NULL;
- char tags[RADIX_TREE_TAGS];
+ char tags[RADIX_TREE_MAX_TAGS];
int nr_cleared_tags;
int tag;
int offset;
@@ -751,7 +756,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
* Clear all tags associated with the just-deleted item
*/
nr_cleared_tags = 0;
- for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+ for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
tags[tag] = 1;
if (tag_get(pathp->node, tag, pathp->offset)) {
tag_clear(pathp->node, tag, pathp->offset);
@@ -763,7 +768,7 @@ void *radix_tree_delete(struct radix_tree_root *root, unsigned long index)
}
for (pathp--; nr_cleared_tags && pathp->node; pathp--) {
- for (tag = 0; tag < RADIX_TREE_TAGS; tag++) {
+ for (tag = 0; tag < RADIX_TREE_MAX_TAGS; tag++) {
if (tags[tag])
continue;
@@ -801,7 +806,7 @@ EXPORT_SYMBOL(radix_tree_delete);
* @root: radix tree root
* @tag: tag to test
*/
-int radix_tree_tagged(struct radix_tree_root *root, int tag)
+int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
{
struct radix_tree_node *rnode;
rnode = root->rnode;
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c
index f5fef948a41..f8ac9fa95de 100644
--- a/lib/reed_solomon/reed_solomon.c
+++ b/lib/reed_solomon/reed_solomon.c
@@ -44,12 +44,13 @@
#include <linux/module.h>
#include <linux/rslib.h>
#include <linux/slab.h>
+#include <linux/mutex.h>
#include <asm/semaphore.h>
/* This list holds all currently allocated rs control structures */
static LIST_HEAD (rslist);
/* Protection for the list */
-static DECLARE_MUTEX(rslistlock);
+static DEFINE_MUTEX(rslistlock);
/**
* rs_init - Initialize a Reed-Solomon codec
@@ -161,7 +162,7 @@ errrs:
*/
void free_rs(struct rs_control *rs)
{
- down(&rslistlock);
+ mutex_lock(&rslistlock);
rs->users--;
if(!rs->users) {
list_del(&rs->list);
@@ -170,7 +171,7 @@ void free_rs(struct rs_control *rs)
kfree(rs->genpoly);
kfree(rs);
}
- up(&rslistlock);
+ mutex_unlock(&rslistlock);
}
/**
@@ -201,7 +202,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
if (nroots < 0 || nroots >= (1<<symsize))
return NULL;
- down(&rslistlock);
+ mutex_lock(&rslistlock);
/* Walk through the list and look for a matching entry */
list_for_each(tmp, &rslist) {
@@ -228,7 +229,7 @@ struct rs_control *init_rs(int symsize, int gfpoly, int fcr, int prim,
list_add(&rs->list, &rslist);
}
out:
- up(&rslistlock);
+ mutex_unlock(&rslistlock);
return rs;
}
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 0af497b6b9a..10625785eef 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -296,8 +296,7 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
else
stride = 1;
- if (!nslots)
- BUG();
+ BUG_ON(!nslots);
/*
* Find suitable number of IO TLB entries size that will fit this
@@ -416,14 +415,14 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
case SYNC_FOR_CPU:
if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(buffer, dma_addr, size);
- else if (dir != DMA_TO_DEVICE)
- BUG();
+ else
+ BUG_ON(dir != DMA_TO_DEVICE);
break;
case SYNC_FOR_DEVICE:
if (likely(dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL))
memcpy(dma_addr, buffer, size);
- else if (dir != DMA_FROM_DEVICE)
- BUG();
+ else
+ BUG_ON(dir != DMA_FROM_DEVICE);
break;
default:
BUG();
@@ -529,8 +528,7 @@ swiotlb_map_single(struct device *hwdev, void *ptr, size_t size, int dir)
unsigned long dev_addr = virt_to_phys(ptr);
void *map;
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
/*
* If the pointer passed in happens to be in the device's DMA window,
* we can safely return the device addr and not worry about bounce
@@ -592,8 +590,7 @@ swiotlb_unmap_single(struct device *hwdev, dma_addr_t dev_addr, size_t size,
{
char *dma_addr = phys_to_virt(dev_addr);
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
unmap_single(hwdev, dma_addr, size, dir);
else if (dir == DMA_FROM_DEVICE)
@@ -616,8 +613,7 @@ swiotlb_sync_single(struct device *hwdev, dma_addr_t dev_addr,
{
char *dma_addr = phys_to_virt(dev_addr);
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE)
@@ -648,8 +644,7 @@ swiotlb_sync_single_range(struct device *hwdev, dma_addr_t dev_addr,
{
char *dma_addr = phys_to_virt(dev_addr) + offset;
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
if (dma_addr >= io_tlb_start && dma_addr < io_tlb_end)
sync_single(hwdev, dma_addr, size, dir, target);
else if (dir == DMA_FROM_DEVICE)
@@ -696,8 +691,7 @@ swiotlb_map_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
unsigned long dev_addr;
int i;
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
for (i = 0; i < nelems; i++, sg++) {
addr = SG_ENT_VIRT_ADDRESS(sg);
@@ -730,8 +724,7 @@ swiotlb_unmap_sg(struct device *hwdev, struct scatterlist *sg, int nelems,
{
int i;
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
for (i = 0; i < nelems; i++, sg++)
if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
@@ -753,8 +746,7 @@ swiotlb_sync_sg(struct device *hwdev, struct scatterlist *sg,
{
int i;
- if (dir == DMA_NONE)
- BUG();
+ BUG_ON(dir == DMA_NONE);
for (i = 0; i < nelems; i++, sg++)
if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
diff --git a/mm/Kconfig b/mm/Kconfig
index bd80460360d..332f5c29b53 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -138,8 +138,8 @@ config SPLIT_PTLOCK_CPUS
#
config MIGRATION
bool "Page migration"
- def_bool y if NUMA || SPARSEMEM || DISCONTIGMEM
- depends on SWAP
+ def_bool y if NUMA
+ depends on SWAP && NUMA
help
Allows the migration of the physical location of pages of processes
while the virtual addresses are not changed. This is useful for
diff --git a/mm/fadvise.c b/mm/fadvise.c
index d257c89e770..907c39257ca 100644
--- a/mm/fadvise.c
+++ b/mm/fadvise.c
@@ -15,6 +15,7 @@
#include <linux/backing-dev.h>
#include <linux/pagevec.h>
#include <linux/fadvise.h>
+#include <linux/writeback.h>
#include <linux/syscalls.h>
#include <asm/unistd.h>
@@ -22,13 +23,36 @@
/*
* POSIX_FADV_WILLNEED could set PG_Referenced, and POSIX_FADV_NOREUSE could
* deactivate the pages and clear PG_Referenced.
+ *
+ * LINUX_FADV_ASYNC_WRITE: start async writeout of any dirty pages between file
+ * offsets `offset' and `offset+len' inclusive. Any pages which are currently
+ * under writeout are skipped, whether or not they are dirty.
+ *
+ * LINUX_FADV_WRITE_WAIT: wait upon writeout of any dirty pages between file
+ * offsets `offset' and `offset+len'.
+ *
+ * By combining these two operations the application may do several things:
+ *
+ * LINUX_FADV_ASYNC_WRITE: push some or all of the dirty pages at the disk.
+ *
+ * LINUX_FADV_WRITE_WAIT, LINUX_FADV_ASYNC_WRITE: push all of the currently
+ * dirty pages at the disk.
+ *
+ * LINUX_FADV_WRITE_WAIT, LINUX_FADV_ASYNC_WRITE, LINUX_FADV_WRITE_WAIT: push
+ * all of the currently dirty pages at the disk, wait until they have been
+ * written.
+ *
+ * It should be noted that none of these operations write out the file's
+ * metadata. So unless the application is strictly performing overwrites of
+ * already-instantiated disk blocks, there are no guarantees here that the data
+ * will be available after a crash.
*/
asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
{
struct file *file = fget(fd);
struct address_space *mapping;
struct backing_dev_info *bdi;
- loff_t endbyte;
+ loff_t endbyte; /* inclusive */
pgoff_t start_index;
pgoff_t end_index;
unsigned long nrpages;
@@ -56,6 +80,8 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
endbyte = offset + len;
if (!len || endbyte < len)
endbyte = -1;
+ else
+ endbyte--; /* inclusive */
bdi = mapping->backing_dev_info;
@@ -78,7 +104,7 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
/* First and last PARTIAL page! */
start_index = offset >> PAGE_CACHE_SHIFT;
- end_index = (endbyte-1) >> PAGE_CACHE_SHIFT;
+ end_index = endbyte >> PAGE_CACHE_SHIFT;
/* Careful about overflow on the "+1" */
nrpages = end_index - start_index + 1;
@@ -96,11 +122,21 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
filemap_flush(mapping);
/* First and last FULL page! */
- start_index = (offset + (PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT;
+ start_index = (offset+(PAGE_CACHE_SIZE-1)) >> PAGE_CACHE_SHIFT;
end_index = (endbyte >> PAGE_CACHE_SHIFT);
- if (end_index > start_index)
- invalidate_mapping_pages(mapping, start_index, end_index-1);
+ if (end_index >= start_index)
+ invalidate_mapping_pages(mapping, start_index,
+ end_index);
+ break;
+ case LINUX_FADV_ASYNC_WRITE:
+ ret = __filemap_fdatawrite_range(mapping, offset, endbyte,
+ WB_SYNC_NONE);
+ break;
+ case LINUX_FADV_WRITE_WAIT:
+ ret = wait_on_page_writeback_range(mapping,
+ offset >> PAGE_CACHE_SHIFT,
+ endbyte >> PAGE_CACHE_SHIFT);
break;
default:
ret = -EINVAL;
diff --git a/mm/filemap.c b/mm/filemap.c
index e8f58f7dd7a..3ef20739e72 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -29,6 +29,7 @@
#include <linux/blkdev.h>
#include <linux/security.h>
#include <linux/syscalls.h>
+#include <linux/cpuset.h>
#include "filemap.h"
#include "internal.h"
@@ -174,7 +175,7 @@ static int sync_page(void *word)
* dirty pages that lie within the byte offsets <start, end>
* @mapping: address space structure to write
* @start: offset in bytes where the range starts
- * @end: offset in bytes where the range ends
+ * @end: offset in bytes where the range ends (inclusive)
* @sync_mode: enable synchronous operation
*
* If sync_mode is WB_SYNC_ALL then this is a "data integrity" operation, as
@@ -182,8 +183,8 @@ static int sync_page(void *word)
* these two operations is that if a dirty page/buffer is encountered, it must
* be waited upon, and not just skipped over.
*/
-static int __filemap_fdatawrite_range(struct address_space *mapping,
- loff_t start, loff_t end, int sync_mode)
+int __filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
+ loff_t end, int sync_mode)
{
int ret;
struct writeback_control wbc = {
@@ -212,8 +213,8 @@ int filemap_fdatawrite(struct address_space *mapping)
}
EXPORT_SYMBOL(filemap_fdatawrite);
-static int filemap_fdatawrite_range(struct address_space *mapping,
- loff_t start, loff_t end)
+static int filemap_fdatawrite_range(struct address_space *mapping, loff_t start,
+ loff_t end)
{
return __filemap_fdatawrite_range(mapping, start, end, WB_SYNC_ALL);
}
@@ -232,7 +233,7 @@ EXPORT_SYMBOL(filemap_flush);
* Wait for writeback to complete against pages indexed by start->end
* inclusive
*/
-static int wait_on_page_writeback_range(struct address_space *mapping,
+int wait_on_page_writeback_range(struct address_space *mapping,
pgoff_t start, pgoff_t end)
{
struct pagevec pvec;
@@ -367,6 +368,12 @@ int filemap_write_and_wait(struct address_space *mapping)
}
EXPORT_SYMBOL(filemap_write_and_wait);
+/*
+ * Write out and wait upon file offsets lstart->lend, inclusive.
+ *
+ * Note that `lend' is inclusive (describes the last byte to be written) so
+ * that this function can be used to write to the very end-of-file (end = -1).
+ */
int filemap_write_and_wait_range(struct address_space *mapping,
loff_t lstart, loff_t lend)
{
@@ -427,6 +434,28 @@ int add_to_page_cache_lru(struct page *page, struct address_space *mapping,
return ret;
}
+#ifdef CONFIG_NUMA
+struct page *page_cache_alloc(struct address_space *x)
+{
+ if (cpuset_do_page_mem_spread()) {
+ int n = cpuset_mem_spread_node();
+ return alloc_pages_node(n, mapping_gfp_mask(x), 0);
+ }
+ return alloc_pages(mapping_gfp_mask(x), 0);
+}
+EXPORT_SYMBOL(page_cache_alloc);
+
+struct page *page_cache_alloc_cold(struct address_space *x)
+{
+ if (cpuset_do_page_mem_spread()) {
+ int n = cpuset_mem_spread_node();
+ return alloc_pages_node(n, mapping_gfp_mask(x)|__GFP_COLD, 0);
+ }
+ return alloc_pages(mapping_gfp_mask(x)|__GFP_COLD, 0);
+}
+EXPORT_SYMBOL(page_cache_alloc_cold);
+#endif
+
/*
* In order to wait for pages to become available there must be
* waitqueues associated with pages. By using a hash table of
diff --git a/mm/highmem.c b/mm/highmem.c
index ce2e7e8bbfa..d0ea1eec6a9 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -26,6 +26,7 @@
#include <linux/init.h>
#include <linux/hash.h>
#include <linux/highmem.h>
+#include <linux/blktrace_api.h>
#include <asm/tlbflush.h>
static mempool_t *page_pool, *isa_page_pool;
@@ -483,6 +484,8 @@ void blk_queue_bounce(request_queue_t *q, struct bio **bio_orig)
pool = isa_page_pool;
}
+ blk_add_trace_bio(q, *bio_orig, BLK_TA_BOUNCE);
+
/*
* slow path
*/
diff --git a/mm/memory.c b/mm/memory.c
index 80c3fb370f9..e347e106ca3 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -395,12 +395,16 @@ struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr, pte_
return NULL;
}
-#ifdef CONFIG_DEBUG_VM
+ /*
+ * Add some anal sanity checks for now. Eventually,
+ * we should just do "return pfn_to_page(pfn)", but
+ * in the meantime we check that we get a valid pfn,
+ * and that the resulting page looks ok.
+ */
if (unlikely(!pfn_valid(pfn))) {
print_bad_pte(vma, pte, addr);
return NULL;
}
-#endif
/*
* NOTE! We still have PageReserved() pages in the page
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e93cc740c22..4f71cfd29c6 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -422,6 +422,37 @@ static int contextualize_policy(int mode, nodemask_t *nodes)
return mpol_check_policy(mode, nodes);
}
+
+/*
+ * Update task->flags PF_MEMPOLICY bit: set iff non-default
+ * mempolicy. Allows more rapid checking of this (combined perhaps
+ * with other PF_* flag bits) on memory allocation hot code paths.
+ *
+ * If called from outside this file, the task 'p' should -only- be
+ * a newly forked child not yet visible on the task list, because
+ * manipulating the task flags of a visible task is not safe.
+ *
+ * The above limitation is why this routine has the funny name
+ * mpol_fix_fork_child_flag().
+ *
+ * It is also safe to call this with a task pointer of current,
+ * which the static wrapper mpol_set_task_struct_flag() does,
+ * for use within this file.
+ */
+
+void mpol_fix_fork_child_flag(struct task_struct *p)
+{
+ if (p->mempolicy)
+ p->flags |= PF_MEMPOLICY;
+ else
+ p->flags &= ~PF_MEMPOLICY;
+}
+
+static void mpol_set_task_struct_flag(void)
+{
+ mpol_fix_fork_child_flag(current);
+}
+
/* Set the process memory policy */
long do_set_mempolicy(int mode, nodemask_t *nodes)
{
@@ -434,6 +465,7 @@ long do_set_mempolicy(int mode, nodemask_t *nodes)
return PTR_ERR(new);
mpol_free(current->mempolicy);
current->mempolicy = new;
+ mpol_set_task_struct_flag();
if (new && new->policy == MPOL_INTERLEAVE)
current->il_next = first_node(new->v.nodes);
return 0;
diff --git a/mm/mmap.c b/mm/mmap.c
index 0eb9894db6d..4f5b5709136 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1040,12 +1040,11 @@ munmap_back:
* specific mapper. the address has already been validated, but
* not unmapped, but the maps are removed from the list.
*/
- vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) {
error = -ENOMEM;
goto unacct_error;
}
- memset(vma, 0, sizeof(*vma));
vma->vm_mm = mm;
vma->vm_start = addr;
@@ -1896,12 +1895,11 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
/*
* create a vma struct for an anonymous mapping
*/
- vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+ vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
if (!vma) {
vm_unacct_memory(len >> PAGE_SHIFT);
return -ENOMEM;
}
- memset(vma, 0, sizeof(*vma));
vma->vm_mm = mm;
vma->vm_start = addr;
diff --git a/mm/msync.c b/mm/msync.c
index 3563a56e1a5..bc6c9537636 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -9,20 +9,24 @@
*/
#include <linux/slab.h>
#include <linux/pagemap.h>
+#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/mman.h>
#include <linux/hugetlb.h>
+#include <linux/writeback.h>
+#include <linux/file.h>
#include <linux/syscalls.h>
#include <asm/pgtable.h>
#include <asm/tlbflush.h>
-static void msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
+static unsigned long msync_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
unsigned long addr, unsigned long end)
{
pte_t *pte;
spinlock_t *ptl;
int progress = 0;
+ unsigned long ret = 0;
again:
pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
@@ -43,58 +47,64 @@ again:
if (!page)
continue;
if (ptep_clear_flush_dirty(vma, addr, pte) ||
- page_test_and_clear_dirty(page))
- set_page_dirty(page);
+ page_test_and_clear_dirty(page))
+ ret += set_page_dirty(page);
progress += 3;
} while (pte++, addr += PAGE_SIZE, addr != end);
pte_unmap_unlock(pte - 1, ptl);
cond_resched();
if (addr != end)
goto again;
+ return ret;
}
-static inline void msync_pmd_range(struct vm_area_struct *vma, pud_t *pud,
- unsigned long addr, unsigned long end)
+static inline unsigned long msync_pmd_range(struct vm_area_struct *vma,
+ pud_t *pud, unsigned long addr, unsigned long end)
{
pmd_t *pmd;
unsigned long next;
+ unsigned long ret = 0;
pmd = pmd_offset(pud, addr);
do {
next = pmd_addr_end(addr, end);
if (pmd_none_or_clear_bad(pmd))
continue;
- msync_pte_range(vma, pmd, addr, next);
+ ret += msync_pte_range(vma, pmd, addr, next);
} while (pmd++, addr = next, addr != end);
+ return ret;
}
-static inline void msync_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
- unsigned long addr, unsigned long end)
+static inline unsigned long msync_pud_range(struct vm_area_struct *vma,
+ pgd_t *pgd, unsigned long addr, unsigned long end)
{
pud_t *pud;
unsigned long next;
+ unsigned long ret = 0;
pud = pud_offset(pgd, addr);
do {
next = pud_addr_end(addr, end);
if (pud_none_or_clear_bad(pud))
continue;
- msync_pmd_range(vma, pud, addr, next);
+ ret += msync_pmd_range(vma, pud, addr, next);
} while (pud++, addr = next, addr != end);
+ return ret;
}
-static void msync_page_range(struct vm_area_struct *vma,
+static unsigned long msync_page_range(struct vm_area_struct *vma,
unsigned long addr, unsigned long end)
{
pgd_t *pgd;
unsigned long next;
+ unsigned long ret = 0;
/* For hugepages we can't go walking the page table normally,
* but that's ok, hugetlbfs is memory based, so we don't need
* to do anything more on an msync().
*/
if (vma->vm_flags & VM_HUGETLB)
- return;
+ return 0;
BUG_ON(addr >= end);
pgd = pgd_offset(vma->vm_mm, addr);
@@ -103,8 +113,9 @@ static void msync_page_range(struct vm_area_struct *vma,
next = pgd_addr_end(addr, end);
if (pgd_none_or_clear_bad(pgd))
continue;
- msync_pud_range(vma, pgd, addr, next);
+ ret += msync_pud_range(vma, pgd, addr, next);
} while (pgd++, addr = next, addr != end);
+ return ret;
}
/*
@@ -115,53 +126,31 @@ static void msync_page_range(struct vm_area_struct *vma,
* write out the dirty pages and wait on the writeout and check the result.
* Or the application may run fadvise(FADV_DONTNEED) against the fd to start
* async writeout immediately.
- * So my _not_ starting I/O in MS_ASYNC we provide complete flexibility to
+ * So by _not_ starting I/O in MS_ASYNC we provide complete flexibility to
* applications.
*/
-static int msync_interval(struct vm_area_struct *vma,
- unsigned long addr, unsigned long end, int flags)
+static int msync_interval(struct vm_area_struct *vma, unsigned long addr,
+ unsigned long end, int flags,
+ unsigned long *nr_pages_dirtied)
{
- int ret = 0;
struct file *file = vma->vm_file;
if ((flags & MS_INVALIDATE) && (vma->vm_flags & VM_LOCKED))
return -EBUSY;
- if (file && (vma->vm_flags & VM_SHARED)) {
- msync_page_range(vma, addr, end);
-
- if (flags & MS_SYNC) {
- struct address_space *mapping = file->f_mapping;
- int err;
-
- ret = filemap_fdatawrite(mapping);
- if (file->f_op && file->f_op->fsync) {
- /*
- * We don't take i_mutex here because mmap_sem
- * is already held.
- */
- err = file->f_op->fsync(file,file->f_dentry,1);
- if (err && !ret)
- ret = err;
- }
- err = filemap_fdatawait(mapping);
- if (!ret)
- ret = err;
- }
- }
- return ret;
+ if (file && (vma->vm_flags & VM_SHARED))
+ *nr_pages_dirtied = msync_page_range(vma, addr, end);
+ return 0;
}
asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
{
unsigned long end;
struct vm_area_struct *vma;
- int unmapped_error, error = -EINVAL;
-
- if (flags & MS_SYNC)
- current->flags |= PF_SYNCWRITE;
+ int unmapped_error = 0;
+ int error = -EINVAL;
+ int done = 0;
- down_read(&current->mm->mmap_sem);
if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
goto out;
if (start & ~PAGE_MASK)
@@ -180,13 +169,18 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
* If the interval [start,end) covers some unmapped address ranges,
* just ignore them, but return -ENOMEM at the end.
*/
+ down_read(&current->mm->mmap_sem);
+ if (flags & MS_SYNC)
+ current->flags |= PF_SYNCWRITE;
vma = find_vma(current->mm, start);
- unmapped_error = 0;
- for (;;) {
- /* Still start < end. */
+ if (!vma) {
error = -ENOMEM;
- if (!vma)
- goto out;
+ goto out_unlock;
+ }
+ do {
+ unsigned long nr_pages_dirtied = 0;
+ struct file *file;
+
/* Here start < vma->vm_end. */
if (start < vma->vm_start) {
unmapped_error = -ENOMEM;
@@ -195,22 +189,47 @@ asmlinkage long sys_msync(unsigned long start, size_t len, int flags)
/* Here vma->vm_start <= start < vma->vm_end. */
if (end <= vma->vm_end) {
if (start < end) {
- error = msync_interval(vma, start, end, flags);
+ error = msync_interval(vma, start, end, flags,
+ &nr_pages_dirtied);
if (error)
- goto out;
+ goto out_unlock;
}
error = unmapped_error;
- goto out;
+ done = 1;
+ } else {
+ /* Here vma->vm_start <= start < vma->vm_end < end. */
+ error = msync_interval(vma, start, vma->vm_end, flags,
+ &nr_pages_dirtied);
+ if (error)
+ goto out_unlock;
}
- /* Here vma->vm_start <= start < vma->vm_end < end. */
- error = msync_interval(vma, start, vma->vm_end, flags);
- if (error)
- goto out;
+ file = vma->vm_file;
start = vma->vm_end;
- vma = vma->vm_next;
- }
-out:
- up_read(&current->mm->mmap_sem);
+ if ((flags & MS_ASYNC) && file && nr_pages_dirtied) {
+ get_file(file);
+ up_read(&current->mm->mmap_sem);
+ balance_dirty_pages_ratelimited_nr(file->f_mapping,
+ nr_pages_dirtied);
+ fput(file);
+ down_read(&current->mm->mmap_sem);
+ vma = find_vma(current->mm, start);
+ } else if ((flags & MS_SYNC) && file &&
+ (vma->vm_flags & VM_SHARED)) {
+ get_file(file);
+ up_read(&current->mm->mmap_sem);
+ error = do_fsync(file, 0);
+ fput(file);
+ down_read(&current->mm->mmap_sem);
+ if (error)
+ goto out_unlock;
+ vma = find_vma(current->mm, start);
+ } else {
+ vma = vma->vm_next;
+ }
+ } while (vma && !done);
+out_unlock:
current->flags &= ~PF_SYNCWRITE;
+ up_read(&current->mm->mmap_sem);
+out:
return error;
}
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 945559fb63d..893d7677579 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -75,12 +75,12 @@ int vm_dirty_ratio = 40;
* The interval between `kupdate'-style writebacks, in centiseconds
* (hundredths of a second)
*/
-int dirty_writeback_centisecs = 5 * 100;
+int dirty_writeback_interval = 5 * HZ;
/*
* The longest number of centiseconds for which data is allowed to remain dirty
*/
-int dirty_expire_centisecs = 30 * 100;
+int dirty_expire_interval = 30 * HZ;
/*
* Flag that makes the machine dump writes/reads and block dirtyings.
@@ -88,7 +88,8 @@ int dirty_expire_centisecs = 30 * 100;
int block_dump;
/*
- * Flag that puts the machine in "laptop mode".
+ * Flag that puts the machine in "laptop mode". Doubles as a timeout in jiffies:
+ * a full sync is triggered after this time elapses without any disk activity.
*/
int laptop_mode;
@@ -255,8 +256,9 @@ static void balance_dirty_pages(struct address_space *mapping)
}
/**
- * balance_dirty_pages_ratelimited - balance dirty memory state
+ * balance_dirty_pages_ratelimited_nr - balance dirty memory state
* @mapping: address_space which was dirtied
+ * @nr_pages: number of pages which the caller has just dirtied
*
* Processes which are dirtying memory should call in here once for each page
* which was newly dirtied. The function will periodically check the system's
@@ -267,10 +269,12 @@ static void balance_dirty_pages(struct address_space *mapping)
* limit we decrease the ratelimiting by a lot, to prevent individual processes
* from overshooting the limit by (ratelimit_pages) each.
*/
-void balance_dirty_pages_ratelimited(struct address_space *mapping)
+void balance_dirty_pages_ratelimited_nr(struct address_space *mapping,
+ unsigned long nr_pages_dirtied)
{
- static DEFINE_PER_CPU(int, ratelimits) = 0;
- long ratelimit;
+ static DEFINE_PER_CPU(unsigned long, ratelimits) = 0;
+ unsigned long ratelimit;
+ unsigned long *p;
ratelimit = ratelimit_pages;
if (dirty_exceeded)
@@ -280,15 +284,18 @@ void balance_dirty_pages_ratelimited(struct address_space *mapping)
* Check the rate limiting. Also, we do not want to throttle real-time
* tasks in balance_dirty_pages(). Period.
*/
- if (get_cpu_var(ratelimits)++ >= ratelimit) {
- __get_cpu_var(ratelimits) = 0;
- put_cpu_var(ratelimits);
+ preempt_disable();
+ p = &__get_cpu_var(ratelimits);
+ *p += nr_pages_dirtied;
+ if (unlikely(*p >= ratelimit)) {
+ *p = 0;
+ preempt_enable();
balance_dirty_pages(mapping);
return;
}
- put_cpu_var(ratelimits);
+ preempt_enable();
}
-EXPORT_SYMBOL(balance_dirty_pages_ratelimited);
+EXPORT_SYMBOL(balance_dirty_pages_ratelimited_nr);
void throttle_vm_writeout(void)
{
@@ -380,8 +387,8 @@ static DEFINE_TIMER(laptop_mode_wb_timer, laptop_timer_fn, 0, 0);
* just walks the superblock inode list, writing back any inodes which are
* older than a specific point in time.
*
- * Try to run once per dirty_writeback_centisecs. But if a writeback event
- * takes longer than a dirty_writeback_centisecs interval, then leave a
+ * Try to run once per dirty_writeback_interval. But if a writeback event
+ * takes longer than a dirty_writeback_interval interval, then leave a
* one-second gap.
*
* older_than_this takes precedence over nr_to_write. So we'll only write back
@@ -406,9 +413,9 @@ static void wb_kupdate(unsigned long arg)
sync_supers();
get_writeback_state(&wbs);
- oldest_jif = jiffies - (dirty_expire_centisecs * HZ) / 100;
+ oldest_jif = jiffies - dirty_expire_interval;
start_jif = jiffies;
- next_jif = start_jif + (dirty_writeback_centisecs * HZ) / 100;
+ next_jif = start_jif + dirty_writeback_interval;
nr_to_write = wbs.nr_dirty + wbs.nr_unstable +
(inodes_stat.nr_inodes - inodes_stat.nr_unused);
while (nr_to_write > 0) {
@@ -425,7 +432,7 @@ static void wb_kupdate(unsigned long arg)
}
if (time_before(next_jif, jiffies + HZ))
next_jif = jiffies + HZ;
- if (dirty_writeback_centisecs)
+ if (dirty_writeback_interval)
mod_timer(&wb_timer, next_jif);
}
@@ -435,11 +442,11 @@ static void wb_kupdate(unsigned long arg)
int dirty_writeback_centisecs_handler(ctl_table *table, int write,
struct file *file, void __user *buffer, size_t *length, loff_t *ppos)
{
- proc_dointvec(table, write, file, buffer, length, ppos);
- if (dirty_writeback_centisecs) {
+ proc_dointvec_userhz_jiffies(table, write, file, buffer, length, ppos);
+ if (dirty_writeback_interval) {
mod_timer(&wb_timer,
- jiffies + (dirty_writeback_centisecs * HZ) / 100);
- } else {
+ jiffies + dirty_writeback_interval);
+ } else {
del_timer(&wb_timer);
}
return 0;
@@ -468,7 +475,7 @@ static void laptop_timer_fn(unsigned long unused)
*/
void laptop_io_completion(void)
{
- mod_timer(&laptop_mode_wb_timer, jiffies + laptop_mode * HZ);
+ mod_timer(&laptop_mode_wb_timer, jiffies + laptop_mode);
}
/*
@@ -544,7 +551,7 @@ void __init page_writeback_init(void)
if (vm_dirty_ratio <= 0)
vm_dirty_ratio = 1;
}
- mod_timer(&wb_timer, jiffies + (dirty_writeback_centisecs * HZ) / 100);
+ mod_timer(&wb_timer, jiffies + dirty_writeback_interval);
set_ratelimit();
register_cpu_notifier(&ratelimit_nb);
}
@@ -621,8 +628,6 @@ EXPORT_SYMBOL(write_one_page);
*/
int __set_page_dirty_nobuffers(struct page *page)
{
- int ret = 0;
-
if (!TestSetPageDirty(page)) {
struct address_space *mapping = page_mapping(page);
struct address_space *mapping2;
@@ -644,8 +649,9 @@ int __set_page_dirty_nobuffers(struct page *page)
I_DIRTY_PAGES);
}
}
+ return 1;
}
- return ret;
+ return 0;
}
EXPORT_SYMBOL(__set_page_dirty_nobuffers);
@@ -675,8 +681,10 @@ int fastcall set_page_dirty(struct page *page)
return (*spd)(page);
return __set_page_dirty_buffers(page);
}
- if (!PageDirty(page))
- SetPageDirty(page);
+ if (!PageDirty(page)) {
+ if (!TestSetPageDirty(page))
+ return 1;
+ }
return 0;
}
EXPORT_SYMBOL(set_page_dirty);
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index b7f14a4799a..338a02bb004 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -943,7 +943,8 @@ restart:
goto got_pg;
do {
- wakeup_kswapd(*z, order);
+ if (cpuset_zone_allowed(*z, gfp_mask))
+ wakeup_kswapd(*z, order);
} while (*(++z));
/*
@@ -2028,8 +2029,9 @@ static __meminit void zone_pcp_init(struct zone *zone)
setup_pageset(zone_pcp(zone,cpu), batch);
#endif
}
- printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n",
- zone->name, zone->present_pages, batch);
+ if (zone->present_pages)
+ printk(KERN_DEBUG " %s zone: %lu pages, LIFO batch:%lu\n",
+ zone->name, zone->present_pages, batch);
}
static __meminit void init_currently_empty_zone(struct zone *zone,
@@ -2700,8 +2702,7 @@ void *__init alloc_large_system_hash(const char *tablename,
else
numentries <<= (PAGE_SHIFT - scale);
}
- /* rounded up to nearest power of 2 in size */
- numentries = 1UL << (long_log2(numentries) + 1);
+ numentries = roundup_pow_of_two(numentries);
/* limit allocation size to 1/16 total memory by default */
if (max == 0) {
diff --git a/mm/readahead.c b/mm/readahead.c
index 301b36c4a0c..0f142a40984 100644
--- a/mm/readahead.c
+++ b/mm/readahead.c
@@ -555,6 +555,7 @@ recheck:
out:
return ra->prev_page + 1;
}
+EXPORT_SYMBOL_GPL(page_cache_readahead);
/*
* handle_ra_miss() is called when it is known that a page which should have
diff --git a/mm/slab.c b/mm/slab.c
index 1c8f5ee230d..681837499d7 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -94,6 +94,7 @@
#include <linux/interrupt.h>
#include <linux/init.h>
#include <linux/compiler.h>
+#include <linux/cpuset.h>
#include <linux/seq_file.h>
#include <linux/notifier.h>
#include <linux/kallsyms.h>
@@ -173,12 +174,12 @@
SLAB_CACHE_DMA | \
SLAB_MUST_HWCACHE_ALIGN | SLAB_STORE_USER | \
SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
- SLAB_DESTROY_BY_RCU)
+ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD)
#else
# define CREATE_MASK (SLAB_HWCACHE_ALIGN | \
SLAB_CACHE_DMA | SLAB_MUST_HWCACHE_ALIGN | \
SLAB_RECLAIM_ACCOUNT | SLAB_PANIC | \
- SLAB_DESTROY_BY_RCU)
+ SLAB_DESTROY_BY_RCU | SLAB_MEM_SPREAD)
#endif
/*
@@ -203,7 +204,8 @@
typedef unsigned int kmem_bufctl_t;
#define BUFCTL_END (((kmem_bufctl_t)(~0U))-0)
#define BUFCTL_FREE (((kmem_bufctl_t)(~0U))-1)
-#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-2)
+#define BUFCTL_ACTIVE (((kmem_bufctl_t)(~0U))-2)
+#define SLAB_LIMIT (((kmem_bufctl_t)(~0U))-3)
/* Max number of objs-per-slab for caches which use off-slab slabs.
* Needed to avoid a possible looping condition in cache_grow().
@@ -896,8 +898,33 @@ static struct array_cache *alloc_arraycache(int node, int entries,
return nc;
}
+/*
+ * Transfer objects in one arraycache to another.
+ * Locking must be handled by the caller.
+ *
+ * Return the number of entries transferred.
+ */
+static int transfer_objects(struct array_cache *to,
+ struct array_cache *from, unsigned int max)
+{
+ /* Figure out how many entries to transfer */
+ int nr = min(min(from->avail, max), to->limit - to->avail);
+
+ if (!nr)
+ return 0;
+
+ memcpy(to->entry + to->avail, from->entry + from->avail -nr,
+ sizeof(void *) *nr);
+
+ from->avail -= nr;
+ to->avail += nr;
+ to->touched = 1;
+ return nr;
+}
+
#ifdef CONFIG_NUMA
static void *__cache_alloc_node(struct kmem_cache *, gfp_t, int);
+static void *alternate_node_alloc(struct kmem_cache *, gfp_t);
static struct array_cache **alloc_alien_cache(int node, int limit)
{
@@ -944,6 +971,13 @@ static void __drain_alien_cache(struct kmem_cache *cachep,
if (ac->avail) {
spin_lock(&rl3->list_lock);
+ /*
+ * Stuff objects into the remote nodes shared array first.
+ * That way we could avoid the overhead of putting the objects
+ * into the free lists and getting them back later.
+ */
+ transfer_objects(rl3->shared, ac, ac->limit);
+
free_block(cachep, ac->entry, ac->avail, node);
ac->avail = 0;
spin_unlock(&rl3->list_lock);
@@ -959,8 +993,8 @@ static void reap_alien(struct kmem_cache *cachep, struct kmem_list3 *l3)
if (l3->alien) {
struct array_cache *ac = l3->alien[node];
- if (ac && ac->avail) {
- spin_lock_irq(&ac->lock);
+
+ if (ac && ac->avail && spin_trylock_irq(&ac->lock)) {
__drain_alien_cache(cachep, ac, node);
spin_unlock_irq(&ac->lock);
}
@@ -1987,10 +2021,9 @@ kmem_cache_create (const char *name, size_t size, size_t align,
align = ralign;
/* Get cache's description obj. */
- cachep = kmem_cache_alloc(&cache_cache, SLAB_KERNEL);
+ cachep = kmem_cache_zalloc(&cache_cache, SLAB_KERNEL);
if (!cachep)
goto oops;
- memset(cachep, 0, sizeof(struct kmem_cache));
#if DEBUG
cachep->obj_size = size;
@@ -2397,7 +2430,7 @@ static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp,
/* Verify that the slab belongs to the intended node */
WARN_ON(slabp->nodeid != nodeid);
- if (slab_bufctl(slabp)[objnr] != BUFCTL_FREE) {
+ if (slab_bufctl(slabp)[objnr] + 1 <= SLAB_LIMIT + 1) {
printk(KERN_ERR "slab: double free detected in cache "
"'%s', objp %p\n", cachep->name, objp);
BUG();
@@ -2603,6 +2636,9 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
*/
cachep->dtor(objp + obj_offset(cachep), cachep, 0);
}
+#ifdef CONFIG_DEBUG_SLAB_LEAK
+ slab_bufctl(slabp)[objnr] = BUFCTL_FREE;
+#endif
if (cachep->flags & SLAB_POISON) {
#ifdef CONFIG_DEBUG_PAGEALLOC
if ((cachep->buffer_size % PAGE_SIZE)==0 && OFF_SLAB(cachep)) {
@@ -2675,20 +2711,10 @@ retry:
BUG_ON(ac->avail > 0 || !l3);
spin_lock(&l3->list_lock);
- if (l3->shared) {
- struct array_cache *shared_array = l3->shared;
- if (shared_array->avail) {
- if (batchcount > shared_array->avail)
- batchcount = shared_array->avail;
- shared_array->avail -= batchcount;
- ac->avail = batchcount;
- memcpy(ac->entry,
- &(shared_array->entry[shared_array->avail]),
- sizeof(void *) * batchcount);
- shared_array->touched = 1;
- goto alloc_done;
- }
- }
+ /* See if we can refill from the shared array */
+ if (l3->shared && transfer_objects(ac, l3->shared, batchcount))
+ goto alloc_done;
+
while (batchcount > 0) {
struct list_head *entry;
struct slab *slabp;
@@ -2786,6 +2812,16 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
*dbg_redzone1(cachep, objp) = RED_ACTIVE;
*dbg_redzone2(cachep, objp) = RED_ACTIVE;
}
+#ifdef CONFIG_DEBUG_SLAB_LEAK
+ {
+ struct slab *slabp;
+ unsigned objnr;
+
+ slabp = page_get_slab(virt_to_page(objp));
+ objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
+ slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE;
+ }
+#endif
objp += obj_offset(cachep);
if (cachep->ctor && cachep->flags & SLAB_POISON) {
unsigned long ctor_flags = SLAB_CTOR_CONSTRUCTOR;
@@ -2807,11 +2843,10 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
struct array_cache *ac;
#ifdef CONFIG_NUMA
- if (unlikely(current->mempolicy && !in_interrupt())) {
- int nid = slab_node(current->mempolicy);
-
- if (nid != numa_node_id())
- return __cache_alloc_node(cachep, flags, nid);
+ if (unlikely(current->flags & (PF_SPREAD_SLAB | PF_MEMPOLICY))) {
+ objp = alternate_node_alloc(cachep, flags);
+ if (objp != NULL)
+ return objp;
}
#endif
@@ -2847,6 +2882,28 @@ static __always_inline void *__cache_alloc(struct kmem_cache *cachep,
#ifdef CONFIG_NUMA
/*
+ * Try allocating on another node if PF_SPREAD_SLAB|PF_MEMPOLICY.
+ *
+ * If we are in_interrupt, then process context, including cpusets and
+ * mempolicy, may not apply and should not be used for allocation policy.
+ */
+static void *alternate_node_alloc(struct kmem_cache *cachep, gfp_t flags)
+{
+ int nid_alloc, nid_here;
+
+ if (in_interrupt())
+ return NULL;
+ nid_alloc = nid_here = numa_node_id();
+ if (cpuset_do_slab_mem_spread() && (cachep->flags & SLAB_MEM_SPREAD))
+ nid_alloc = cpuset_mem_spread_node();
+ else if (current->mempolicy)
+ nid_alloc = slab_node(current->mempolicy);
+ if (nid_alloc != nid_here)
+ return __cache_alloc_node(cachep, flags, nid_alloc);
+ return NULL;
+}
+
+/*
* A interface to enable slab creation on nodeid
*/
static void *__cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
@@ -3071,6 +3128,23 @@ void *kmem_cache_alloc(struct kmem_cache *cachep, gfp_t flags)
EXPORT_SYMBOL(kmem_cache_alloc);
/**
+ * kmem_cache_alloc - Allocate an object. The memory is set to zero.
+ * @cache: The cache to allocate from.
+ * @flags: See kmalloc().
+ *
+ * Allocate an object from this cache and set the allocated memory to zero.
+ * The flags are only relevant if the cache has no available objects.
+ */
+void *kmem_cache_zalloc(struct kmem_cache *cache, gfp_t flags)
+{
+ void *ret = __cache_alloc(cache, flags, __builtin_return_address(0));
+ if (ret)
+ memset(ret, 0, obj_size(cache));
+ return ret;
+}
+EXPORT_SYMBOL(kmem_cache_zalloc);
+
+/**
* kmem_ptr_validate - check if an untrusted pointer might
* be a slab entry.
* @cachep: the cache we're checking against
@@ -3197,22 +3271,23 @@ static __always_inline void *__do_kmalloc(size_t size, gfp_t flags,
return __cache_alloc(cachep, flags, caller);
}
-#ifndef CONFIG_DEBUG_SLAB
void *__kmalloc(size_t size, gfp_t flags)
{
+#ifndef CONFIG_DEBUG_SLAB
return __do_kmalloc(size, flags, NULL);
+#else
+ return __do_kmalloc(size, flags, __builtin_return_address(0));
+#endif
}
EXPORT_SYMBOL(__kmalloc);
-#else
-
+#ifdef CONFIG_DEBUG_SLAB
void *__kmalloc_track_caller(size_t size, gfp_t flags, void *caller)
{
return __do_kmalloc(size, flags, caller);
}
EXPORT_SYMBOL(__kmalloc_track_caller);
-
#endif
#ifdef CONFIG_SMP
@@ -3343,63 +3418,86 @@ const char *kmem_cache_name(struct kmem_cache *cachep)
EXPORT_SYMBOL_GPL(kmem_cache_name);
/*
- * This initializes kmem_list3 for all nodes.
+ * This initializes kmem_list3 or resizes varioius caches for all nodes.
*/
static int alloc_kmemlist(struct kmem_cache *cachep)
{
int node;
struct kmem_list3 *l3;
- int err = 0;
+ struct array_cache *new_shared;
+ struct array_cache **new_alien;
for_each_online_node(node) {
- struct array_cache *nc = NULL, *new;
- struct array_cache **new_alien = NULL;
-#ifdef CONFIG_NUMA
+
new_alien = alloc_alien_cache(node, cachep->limit);
if (!new_alien)
goto fail;
-#endif
- new = alloc_arraycache(node, cachep->shared*cachep->batchcount,
+
+ new_shared = alloc_arraycache(node,
+ cachep->shared*cachep->batchcount,
0xbaadf00d);
- if (!new)
+ if (!new_shared) {
+ free_alien_cache(new_alien);
goto fail;
+ }
+
l3 = cachep->nodelists[node];
if (l3) {
+ struct array_cache *shared = l3->shared;
+
spin_lock_irq(&l3->list_lock);
- nc = cachep->nodelists[node]->shared;
- if (nc)
- free_block(cachep, nc->entry, nc->avail, node);
+ if (shared)
+ free_block(cachep, shared->entry,
+ shared->avail, node);
- l3->shared = new;
- if (!cachep->nodelists[node]->alien) {
+ l3->shared = new_shared;
+ if (!l3->alien) {
l3->alien = new_alien;
new_alien = NULL;
}
l3->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
spin_unlock_irq(&l3->list_lock);
- kfree(nc);
+ kfree(shared);
free_alien_cache(new_alien);
continue;
}
l3 = kmalloc_node(sizeof(struct kmem_list3), GFP_KERNEL, node);
- if (!l3)
+ if (!l3) {
+ free_alien_cache(new_alien);
+ kfree(new_shared);
goto fail;
+ }
kmem_list3_init(l3);
l3->next_reap = jiffies + REAPTIMEOUT_LIST3 +
((unsigned long)cachep) % REAPTIMEOUT_LIST3;
- l3->shared = new;
+ l3->shared = new_shared;
l3->alien = new_alien;
l3->free_limit = (1 + nr_cpus_node(node)) *
cachep->batchcount + cachep->num;
cachep->nodelists[node] = l3;
}
- return err;
+ return 0;
+
fail:
- err = -ENOMEM;
- return err;
+ if (!cachep->next.next) {
+ /* Cache is not active yet. Roll back what we did */
+ node--;
+ while (node >= 0) {
+ if (cachep->nodelists[node]) {
+ l3 = cachep->nodelists[node];
+
+ kfree(l3->shared);
+ free_alien_cache(l3->alien);
+ kfree(l3);
+ cachep->nodelists[node] = NULL;
+ }
+ node--;
+ }
+ }
+ return -ENOMEM;
}
struct ccupdate_struct {
@@ -3876,6 +3974,159 @@ ssize_t slabinfo_write(struct file *file, const char __user * buffer,
res = count;
return res;
}
+
+#ifdef CONFIG_DEBUG_SLAB_LEAK
+
+static void *leaks_start(struct seq_file *m, loff_t *pos)
+{
+ loff_t n = *pos;
+ struct list_head *p;
+
+ mutex_lock(&cache_chain_mutex);
+ p = cache_chain.next;
+ while (n--) {
+ p = p->next;
+ if (p == &cache_chain)
+ return NULL;
+ }
+ return list_entry(p, struct kmem_cache, next);
+}
+
+static inline int add_caller(unsigned long *n, unsigned long v)
+{
+ unsigned long *p;
+ int l;
+ if (!v)
+ return 1;
+ l = n[1];
+ p = n + 2;
+ while (l) {
+ int i = l/2;
+ unsigned long *q = p + 2 * i;
+ if (*q == v) {
+ q[1]++;
+ return 1;
+ }
+ if (*q > v) {
+ l = i;
+ } else {
+ p = q + 2;
+ l -= i + 1;
+ }
+ }
+ if (++n[1] == n[0])
+ return 0;
+ memmove(p + 2, p, n[1] * 2 * sizeof(unsigned long) - ((void *)p - (void *)n));
+ p[0] = v;
+ p[1] = 1;
+ return 1;
+}
+
+static void handle_slab(unsigned long *n, struct kmem_cache *c, struct slab *s)
+{
+ void *p;
+ int i;
+ if (n[0] == n[1])
+ return;
+ for (i = 0, p = s->s_mem; i < c->num; i++, p += c->buffer_size) {
+ if (slab_bufctl(s)[i] != BUFCTL_ACTIVE)
+ continue;
+ if (!add_caller(n, (unsigned long)*dbg_userword(c, p)))
+ return;
+ }
+}
+
+static void show_symbol(struct seq_file *m, unsigned long address)
+{
+#ifdef CONFIG_KALLSYMS
+ char *modname;
+ const char *name;
+ unsigned long offset, size;
+ char namebuf[KSYM_NAME_LEN+1];
+
+ name = kallsyms_lookup(address, &size, &offset, &modname, namebuf);
+
+ if (name) {
+ seq_printf(m, "%s+%#lx/%#lx", name, offset, size);
+ if (modname)
+ seq_printf(m, " [%s]", modname);
+ return;
+ }
+#endif
+ seq_printf(m, "%p", (void *)address);
+}
+
+static int leaks_show(struct seq_file *m, void *p)
+{
+ struct kmem_cache *cachep = p;
+ struct list_head *q;
+ struct slab *slabp;
+ struct kmem_list3 *l3;
+ const char *name;
+ unsigned long *n = m->private;
+ int node;
+ int i;
+
+ if (!(cachep->flags & SLAB_STORE_USER))
+ return 0;
+ if (!(cachep->flags & SLAB_RED_ZONE))
+ return 0;
+
+ /* OK, we can do it */
+
+ n[1] = 0;
+
+ for_each_online_node(node) {
+ l3 = cachep->nodelists[node];
+ if (!l3)
+ continue;
+
+ check_irq_on();
+ spin_lock_irq(&l3->list_lock);
+
+ list_for_each(q, &l3->slabs_full) {
+ slabp = list_entry(q, struct slab, list);
+ handle_slab(n, cachep, slabp);
+ }
+ list_for_each(q, &l3->slabs_partial) {
+ slabp = list_entry(q, struct slab, list);
+ handle_slab(n, cachep, slabp);
+ }
+ spin_unlock_irq(&l3->list_lock);
+ }
+ name = cachep->name;
+ if (n[0] == n[1]) {
+ /* Increase the buffer size */
+ mutex_unlock(&cache_chain_mutex);
+ m->private = kzalloc(n[0] * 4 * sizeof(unsigned long), GFP_KERNEL);
+ if (!m->private) {
+ /* Too bad, we are really out */
+ m->private = n;
+ mutex_lock(&cache_chain_mutex);
+ return -ENOMEM;
+ }
+ *(unsigned long *)m->private = n[0] * 2;
+ kfree(n);
+ mutex_lock(&cache_chain_mutex);
+ /* Now make sure this entry will be retried */
+ m->count = m->size;
+ return 0;
+ }
+ for (i = 0; i < n[1]; i++) {
+ seq_printf(m, "%s: %lu ", name, n[2*i+3]);
+ show_symbol(m, n[2*i+2]);
+ seq_putc(m, '\n');
+ }
+ return 0;
+}
+
+struct seq_operations slabstats_op = {
+ .start = leaks_start,
+ .next = s_next,
+ .stop = s_stop,
+ .show = leaks_show,
+};
+#endif
#endif
/**
diff --git a/mm/slob.c b/mm/slob.c
index a1f42bdc024..9bcc7e2cabf 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -294,6 +294,16 @@ void *kmem_cache_alloc(struct kmem_cache *c, gfp_t flags)
}
EXPORT_SYMBOL(kmem_cache_alloc);
+void *kmem_cache_zalloc(struct kmem_cache *c, gfp_t flags)
+{
+ void *ret = kmem_cache_alloc(c, flags);
+ if (ret)
+ memset(ret, 0, c->size);
+
+ return ret;
+}
+EXPORT_SYMBOL(kmem_cache_zalloc);
+
void kmem_cache_free(struct kmem_cache *c, void *b)
{
if (c->dtor)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 365ed6ff182..39aa9d12961 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -45,7 +45,7 @@ static const char Unused_offset[] = "Unused swap offset entry ";
struct swap_list_t swap_list = {-1, -1};
-struct swap_info_struct swap_info[MAX_SWAPFILES];
+static struct swap_info_struct swap_info[MAX_SWAPFILES];
static DEFINE_MUTEX(swapon_mutex);
@@ -417,6 +417,61 @@ void free_swap_and_cache(swp_entry_t entry)
}
}
+#ifdef CONFIG_SOFTWARE_SUSPEND
+/*
+ * Find the swap type that corresponds to given device (if any)
+ *
+ * This is needed for software suspend and is done in such a way that inode
+ * aliasing is allowed.
+ */
+int swap_type_of(dev_t device)
+{
+ int i;
+
+ spin_lock(&swap_lock);
+ for (i = 0; i < nr_swapfiles; i++) {
+ struct inode *inode;
+
+ if (!(swap_info[i].flags & SWP_WRITEOK))
+ continue;
+ if (!device) {
+ spin_unlock(&swap_lock);
+ return i;
+ }
+ inode = swap_info->swap_file->f_dentry->d_inode;
+ if (S_ISBLK(inode->i_mode) &&
+ device == MKDEV(imajor(inode), iminor(inode))) {
+ spin_unlock(&swap_lock);
+ return i;
+ }
+ }
+ spin_unlock(&swap_lock);
+ return -ENODEV;
+}
+
+/*
+ * Return either the total number of swap pages of given type, or the number
+ * of free pages of that type (depending on @free)
+ *
+ * This is needed for software suspend
+ */
+unsigned int count_swap_pages(int type, int free)
+{
+ unsigned int n = 0;
+
+ if (type < nr_swapfiles) {
+ spin_lock(&swap_lock);
+ if (swap_info[type].flags & SWP_WRITEOK) {
+ n = swap_info[type].pages;
+ if (free)
+ n -= swap_info[type].inuse_pages;
+ }
+ spin_unlock(&swap_lock);
+ }
+ return n;
+}
+#endif
+
/*
* No need to decide whether this PTE shares the swap entry with others,
* just let do_wp_page work it out if a write is requested later - to
diff --git a/mm/util.c b/mm/util.c
index 5f4bb59da63..7368479220b 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1,20 +1,22 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/module.h>
+#include <linux/err.h>
+#include <asm/uaccess.h>
/**
- * kzalloc - allocate memory. The memory is set to zero.
+ * __kzalloc - allocate memory. The memory is set to zero.
* @size: how many bytes of memory are required.
* @flags: the type of memory to allocate.
*/
-void *kzalloc(size_t size, gfp_t flags)
+void *__kzalloc(size_t size, gfp_t flags)
{
- void *ret = kmalloc(size, flags);
+ void *ret = ____kmalloc(size, flags);
if (ret)
memset(ret, 0, size);
return ret;
}
-EXPORT_SYMBOL(kzalloc);
+EXPORT_SYMBOL(__kzalloc);
/*
* kstrdup - allocate space for and copy an existing string
@@ -31,9 +33,44 @@ char *kstrdup(const char *s, gfp_t gfp)
return NULL;
len = strlen(s) + 1;
- buf = kmalloc(len, gfp);
+ buf = ____kmalloc(len, gfp);
if (buf)
memcpy(buf, s, len);
return buf;
}
EXPORT_SYMBOL(kstrdup);
+
+/*
+ * strndup_user - duplicate an existing string from user space
+ *
+ * @s: The string to duplicate
+ * @n: Maximum number of bytes to copy, including the trailing NUL.
+ */
+char *strndup_user(const char __user *s, long n)
+{
+ char *p;
+ long length;
+
+ length = strnlen_user(s, n);
+
+ if (!length)
+ return ERR_PTR(-EFAULT);
+
+ if (length > n)
+ return ERR_PTR(-EINVAL);
+
+ p = kmalloc(length, GFP_KERNEL);
+
+ if (!p)
+ return ERR_PTR(-ENOMEM);
+
+ if (copy_from_user(p, s, length)) {
+ kfree(p);
+ return ERR_PTR(-EFAULT);
+ }
+
+ p[length - 1] = '\0';
+
+ return p;
+}
+EXPORT_SYMBOL(strndup_user);
diff --git a/mm/vmscan.c b/mm/vmscan.c
index fd572bbdc9f..78865c849f8 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1356,7 +1356,9 @@ static int __init kswapd_init(void)
pid = kernel_thread(kswapd, pgdat, CLONE_KERNEL);
BUG_ON(pid < 0);
+ read_lock(&tasklist_lock);
pgdat->kswapd = find_task_by_pid(pid);
+ read_unlock(&tasklist_lock);
}
total_memory = nr_free_pagecache_pages();
hotcpu_notifier(cpu_callback, 0);
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index fb031fe9be9..469eda0f0df 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -238,6 +238,9 @@ unsigned int bt_sock_poll(struct file * file, struct socket *sock, poll_table *w
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ mask |= POLLRDHUP;
+
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 8934a54792b..a7ba0cce0b4 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -19,6 +19,7 @@
#include <linux/llc.h>
#include <net/llc.h>
#include <net/llc_pdu.h>
+#include <asm/unaligned.h>
#include "br_private.h"
#include "br_private_stp.h"
@@ -59,12 +60,12 @@ static inline void br_set_ticks(unsigned char *dest, int j)
{
unsigned long ticks = (STP_HZ * j)/ HZ;
- *((__be16 *) dest) = htons(ticks);
+ put_unaligned(htons(ticks), (__be16 *)dest);
}
static inline int br_get_ticks(const unsigned char *src)
{
- unsigned long ticks = ntohs(*(__be16 *)src);
+ unsigned long ticks = ntohs(get_unaligned((__be16 *)src));
return (ticks * HZ + STP_HZ - 1) / STP_HZ;
}
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b8ce6bf8118..aecddcc3040 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -500,6 +500,8 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
/* exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ mask |= POLLRDHUP;
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
diff --git a/net/core/dev.c b/net/core/dev.c
index 08dec6eb922..e0489ca731c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -977,7 +977,12 @@ int register_netdevice_notifier(struct notifier_block *nb)
int unregister_netdevice_notifier(struct notifier_block *nb)
{
- return notifier_chain_unregister(&netdev_chain, nb);
+ int err;
+
+ rtnl_lock();
+ err = notifier_chain_unregister(&netdev_chain, nb);
+ rtnl_unlock();
+ return err;
}
/**
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 8eedaedba74..c23e9c06ee2 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -106,6 +106,9 @@
*
* interruptible_sleep_on_timeout() replaced Nishanth Aravamudan <nacc@us.ibm.com>
* 050103
+ *
+ * MPLS support by Steven Whitehouse <steve@chygwyn.com>
+ *
*/
#include <linux/sys.h>
#include <linux/types.h>
@@ -154,7 +157,7 @@
#include <asm/div64.h> /* do_div */
#include <asm/timex.h>
-#define VERSION "pktgen v2.66: Packet Generator for packet performance testing.\n"
+#define VERSION "pktgen v2.67: Packet Generator for packet performance testing.\n"
/* #define PG_DEBUG(a) a */
#define PG_DEBUG(a)
@@ -162,6 +165,8 @@
/* The buckets are exponential in 'width' */
#define LAT_BUCKETS_MAX 32
#define IP_NAME_SZ 32
+#define MAX_MPLS_LABELS 16 /* This is the max label stack depth */
+#define MPLS_STACK_BOTTOM __constant_htonl(0x00000100)
/* Device flag bits */
#define F_IPSRC_RND (1<<0) /* IP-Src Random */
@@ -172,6 +177,7 @@
#define F_MACDST_RND (1<<5) /* MAC-Dst Random */
#define F_TXSIZE_RND (1<<6) /* Transmit size is random */
#define F_IPV6 (1<<7) /* Interface in IPV6 Mode */
+#define F_MPLS_RND (1<<8) /* Random MPLS labels */
/* Thread control flag bits */
#define T_TERMINATE (1<<0)
@@ -278,6 +284,10 @@ struct pktgen_dev {
__u16 udp_dst_min; /* inclusive, dest UDP port */
__u16 udp_dst_max; /* exclusive, dest UDP port */
+ /* MPLS */
+ unsigned nr_labels; /* Depth of stack, 0 = no MPLS */
+ __be32 labels[MAX_MPLS_LABELS];
+
__u32 src_mac_count; /* How many MACs to iterate through */
__u32 dst_mac_count; /* How many MACs to iterate through */
@@ -623,9 +633,19 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
pkt_dev->udp_dst_min, pkt_dev->udp_dst_max);
seq_printf(seq,
- " src_mac_count: %d dst_mac_count: %d \n Flags: ",
+ " src_mac_count: %d dst_mac_count: %d\n",
pkt_dev->src_mac_count, pkt_dev->dst_mac_count);
+ if (pkt_dev->nr_labels) {
+ unsigned i;
+ seq_printf(seq, " mpls: ");
+ for(i = 0; i < pkt_dev->nr_labels; i++)
+ seq_printf(seq, "%08x%s", ntohl(pkt_dev->labels[i]),
+ i == pkt_dev->nr_labels-1 ? "\n" : ", ");
+ }
+
+ seq_printf(seq, " Flags: ");
+
if (pkt_dev->flags & F_IPV6)
seq_printf(seq, "IPV6 ");
@@ -644,6 +664,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
if (pkt_dev->flags & F_UDPDST_RND)
seq_printf(seq, "UDPDST_RND ");
+ if (pkt_dev->flags & F_MPLS_RND)
+ seq_printf(seq, "MPLS_RND ");
+
if (pkt_dev->flags & F_MACSRC_RND)
seq_printf(seq, "MACSRC_RND ");
@@ -691,6 +714,29 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
return 0;
}
+
+static int hex32_arg(const char __user *user_buffer, __u32 *num)
+{
+ int i = 0;
+ *num = 0;
+
+ for(; i < 8; i++) {
+ char c;
+ *num <<= 4;
+ if (get_user(c, &user_buffer[i]))
+ return -EFAULT;
+ if ((c >= '0') && (c <= '9'))
+ *num |= c - '0';
+ else if ((c >= 'a') && (c <= 'f'))
+ *num |= c - 'a' + 10;
+ else if ((c >= 'A') && (c <= 'F'))
+ *num |= c - 'A' + 10;
+ else
+ break;
+ }
+ return i;
+}
+
static int count_trail_chars(const char __user * user_buffer,
unsigned int maxlen)
{
@@ -759,6 +805,35 @@ done_str:
return i;
}
+static ssize_t get_labels(const char __user *buffer, struct pktgen_dev *pkt_dev)
+{
+ unsigned n = 0;
+ char c;
+ ssize_t i = 0;
+ int len;
+
+ pkt_dev->nr_labels = 0;
+ do {
+ __u32 tmp;
+ len = hex32_arg(&buffer[i], &tmp);
+ if (len <= 0)
+ return len;
+ pkt_dev->labels[n] = htonl(tmp);
+ if (pkt_dev->labels[n] & MPLS_STACK_BOTTOM)
+ pkt_dev->flags |= F_MPLS_RND;
+ i += len;
+ if (get_user(c, &buffer[i]))
+ return -EFAULT;
+ i++;
+ n++;
+ if (n >= MAX_MPLS_LABELS)
+ return -E2BIG;
+ } while(c == ',');
+
+ pkt_dev->nr_labels = n;
+ return i;
+}
+
static ssize_t pktgen_if_write(struct file *file,
const char __user * user_buffer, size_t count,
loff_t * offset)
@@ -1059,6 +1134,12 @@ static ssize_t pktgen_if_write(struct file *file,
else if (strcmp(f, "!MACDST_RND") == 0)
pkt_dev->flags &= ~F_MACDST_RND;
+ else if (strcmp(f, "MPLS_RND") == 0)
+ pkt_dev->flags |= F_MPLS_RND;
+
+ else if (strcmp(f, "!MPLS_RND") == 0)
+ pkt_dev->flags &= ~F_MPLS_RND;
+
else {
sprintf(pg_result,
"Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
@@ -1354,6 +1435,19 @@ static ssize_t pktgen_if_write(struct file *file,
return count;
}
+ if (!strcmp(name, "mpls")) {
+ unsigned n, offset;
+ len = get_labels(&user_buffer[i], pkt_dev);
+ if (len < 0) { return len; }
+ i += len;
+ offset = sprintf(pg_result, "OK: mpls=");
+ for(n = 0; n < pkt_dev->nr_labels; n++)
+ offset += sprintf(pg_result + offset,
+ "%08x%s", ntohl(pkt_dev->labels[n]),
+ n == pkt_dev->nr_labels-1 ? "" : ",");
+ return count;
+ }
+
sprintf(pkt_dev->result, "No such parameter \"%s\"", name);
return -EINVAL;
}
@@ -1846,6 +1940,15 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
pkt_dev->hh[1] = tmp;
}
+ if (pkt_dev->flags & F_MPLS_RND) {
+ unsigned i;
+ for(i = 0; i < pkt_dev->nr_labels; i++)
+ if (pkt_dev->labels[i] & MPLS_STACK_BOTTOM)
+ pkt_dev->labels[i] = MPLS_STACK_BOTTOM |
+ (pktgen_random() &
+ htonl(0x000fffff));
+ }
+
if (pkt_dev->udp_src_min < pkt_dev->udp_src_max) {
if (pkt_dev->flags & F_UDPSRC_RND)
pkt_dev->cur_udp_src =
@@ -1968,6 +2071,16 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev)
pkt_dev->flows[flow].count++;
}
+static void mpls_push(__be32 *mpls, struct pktgen_dev *pkt_dev)
+{
+ unsigned i;
+ for(i = 0; i < pkt_dev->nr_labels; i++) {
+ *mpls++ = pkt_dev->labels[i] & ~MPLS_STACK_BOTTOM;
+ }
+ mpls--;
+ *mpls |= MPLS_STACK_BOTTOM;
+}
+
static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
struct pktgen_dev *pkt_dev)
{
@@ -1977,6 +2090,11 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
int datalen, iplen;
struct iphdr *iph;
struct pktgen_hdr *pgh = NULL;
+ __be16 protocol = __constant_htons(ETH_P_IP);
+ __be32 *mpls;
+
+ if (pkt_dev->nr_labels)
+ protocol = __constant_htons(ETH_P_MPLS_UC);
/* Update any of the values, used when we're incrementing various
* fields.
@@ -1984,7 +2102,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
mod_cur_headers(pkt_dev);
datalen = (odev->hard_header_len + 16) & ~0xf;
- skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen, GFP_ATOMIC);
+ skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + datalen +
+ pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC);
if (!skb) {
sprintf(pkt_dev->result, "No memory");
return NULL;
@@ -1994,13 +2113,18 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
/* Reserve for ethernet and IP header */
eth = (__u8 *) skb_push(skb, 14);
+ mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
+ if (pkt_dev->nr_labels)
+ mpls_push(mpls, pkt_dev);
iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr));
udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
memcpy(eth, pkt_dev->hh, 12);
- *(u16 *) & eth[12] = __constant_htons(ETH_P_IP);
+ *(u16 *) & eth[12] = protocol;
- datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8; /* Eth + IPh + UDPh */
+ /* Eth + IPh + UDPh + mpls */
+ datalen = pkt_dev->cur_pkt_size - 14 - 20 - 8 -
+ pkt_dev->nr_labels*sizeof(u32);
if (datalen < sizeof(struct pktgen_hdr))
datalen = sizeof(struct pktgen_hdr);
@@ -2021,8 +2145,8 @@ static struct sk_buff *fill_packet_ipv4(struct net_device *odev,
iph->tot_len = htons(iplen);
iph->check = 0;
iph->check = ip_fast_csum((void *)iph, iph->ihl);
- skb->protocol = __constant_htons(ETH_P_IP);
- skb->mac.raw = ((u8 *) iph) - 14;
+ skb->protocol = protocol;
+ skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32);
skb->dev = odev;
skb->pkt_type = PACKET_HOST;
@@ -2274,13 +2398,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
int datalen;
struct ipv6hdr *iph;
struct pktgen_hdr *pgh = NULL;
+ __be16 protocol = __constant_htons(ETH_P_IPV6);
+ __be32 *mpls;
+
+ if (pkt_dev->nr_labels)
+ protocol = __constant_htons(ETH_P_MPLS_UC);
/* Update any of the values, used when we're incrementing various
* fields.
*/
mod_cur_headers(pkt_dev);
- skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16, GFP_ATOMIC);
+ skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16 +
+ pkt_dev->nr_labels*sizeof(u32), GFP_ATOMIC);
if (!skb) {
sprintf(pkt_dev->result, "No memory");
return NULL;
@@ -2290,13 +2420,19 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
/* Reserve for ethernet and IP header */
eth = (__u8 *) skb_push(skb, 14);
+ mpls = (__be32 *)skb_put(skb, pkt_dev->nr_labels*sizeof(__u32));
+ if (pkt_dev->nr_labels)
+ mpls_push(mpls, pkt_dev);
iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr));
udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr));
memcpy(eth, pkt_dev->hh, 12);
*(u16 *) & eth[12] = __constant_htons(ETH_P_IPV6);
- datalen = pkt_dev->cur_pkt_size - 14 - sizeof(struct ipv6hdr) - sizeof(struct udphdr); /* Eth + IPh + UDPh */
+ /* Eth + IPh + UDPh + mpls */
+ datalen = pkt_dev->cur_pkt_size - 14 -
+ sizeof(struct ipv6hdr) - sizeof(struct udphdr) -
+ pkt_dev->nr_labels*sizeof(u32);
if (datalen < sizeof(struct pktgen_hdr)) {
datalen = sizeof(struct pktgen_hdr);
@@ -2320,8 +2456,8 @@ static struct sk_buff *fill_packet_ipv6(struct net_device *odev,
ipv6_addr_copy(&iph->daddr, &pkt_dev->cur_in6_daddr);
ipv6_addr_copy(&iph->saddr, &pkt_dev->cur_in6_saddr);
- skb->mac.raw = ((u8 *) iph) - 14;
- skb->protocol = __constant_htons(ETH_P_IPV6);
+ skb->mac.raw = ((u8 *) iph) - 14 - pkt_dev->nr_labels*sizeof(u32);
+ skb->protocol = protocol;
skb->dev = odev;
skb->pkt_type = PACKET_HOST;
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index ae10d3740fa..3fcfa9c59e1 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -51,6 +51,10 @@
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <net/netlink.h>
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+#include <linux/wireless.h>
+#include <net/iw_handler.h>
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
static DEFINE_MUTEX(rtnl_mutex);
@@ -467,6 +471,17 @@ static int do_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
goto out;
}
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+ if (ida[IFLA_WIRELESS - 1]) {
+
+ /* Call Wireless Extensions.
+ * Various stuff checked in there... */
+ err = wireless_rtnetlink_set(dev, RTA_DATA(ida[IFLA_WIRELESS - 1]), ida[IFLA_WIRELESS - 1]->rta_len);
+ if (err)
+ goto out;
+ }
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
+
err = 0;
out:
@@ -477,6 +492,83 @@ out:
return err;
}
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+static int do_getlink(struct sk_buff *in_skb, struct nlmsghdr* in_nlh, void *arg)
+{
+ struct ifinfomsg *ifm = NLMSG_DATA(in_nlh);
+ struct rtattr **ida = arg;
+ struct net_device *dev;
+ struct ifinfomsg *r;
+ struct nlmsghdr *nlh;
+ int err = -ENOBUFS;
+ struct sk_buff *skb;
+ unsigned char *b;
+ char *iw_buf = NULL;
+ int iw_buf_len = 0;
+
+ if (ifm->ifi_index >= 0)
+ dev = dev_get_by_index(ifm->ifi_index);
+ else
+ return -EINVAL;
+ if (!dev)
+ return -ENODEV;
+
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+ if (ida[IFLA_WIRELESS - 1]) {
+
+ /* Call Wireless Extensions. We need to know the size before
+ * we can alloc. Various stuff checked in there... */
+ err = wireless_rtnetlink_get(dev, RTA_DATA(ida[IFLA_WIRELESS - 1]), ida[IFLA_WIRELESS - 1]->rta_len, &iw_buf, &iw_buf_len);
+ if (err)
+ goto out;
+ }
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
+
+ /* Create a skb big enough to include all the data.
+ * Some requests are way bigger than 4k... Jean II */
+ skb = alloc_skb((NLMSG_LENGTH(sizeof(*r))) + (RTA_SPACE(iw_buf_len)),
+ GFP_KERNEL);
+ if (!skb)
+ goto out;
+ b = skb->tail;
+
+ /* Put in the message the usual good stuff */
+ nlh = NLMSG_PUT(skb, NETLINK_CB(in_skb).pid, in_nlh->nlmsg_seq,
+ RTM_NEWLINK, sizeof(*r));
+ r = NLMSG_DATA(nlh);
+ r->ifi_family = AF_UNSPEC;
+ r->__ifi_pad = 0;
+ r->ifi_type = dev->type;
+ r->ifi_index = dev->ifindex;
+ r->ifi_flags = dev->flags;
+ r->ifi_change = 0;
+
+ /* Put the wireless payload if it exist */
+ if(iw_buf != NULL)
+ RTA_PUT(skb, IFLA_WIRELESS, iw_buf_len,
+ iw_buf + IW_EV_POINT_OFF);
+
+ nlh->nlmsg_len = skb->tail - b;
+
+ /* Needed ? */
+ NETLINK_CB(skb).dst_pid = NETLINK_CB(in_skb).pid;
+
+ err = netlink_unicast(rtnl, skb, NETLINK_CB(in_skb).pid, MSG_DONTWAIT);
+ if (err > 0)
+ err = 0;
+out:
+ if(iw_buf != NULL)
+ kfree(iw_buf);
+ dev_put(dev);
+ return err;
+
+rtattr_failure:
+nlmsg_failure:
+ kfree_skb(skb);
+ goto out;
+}
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
+
static int rtnetlink_dump_all(struct sk_buff *skb, struct netlink_callback *cb)
{
int idx;
@@ -642,7 +734,11 @@ static void rtnetlink_rcv(struct sock *sk, int len)
static struct rtnetlink_link link_rtnetlink_table[RTM_NR_MSGTYPES] =
{
- [RTM_GETLINK - RTM_BASE] = { .dumpit = rtnetlink_dump_ifinfo },
+ [RTM_GETLINK - RTM_BASE] = {
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+ .doit = do_getlink,
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
+ .dumpit = rtnetlink_dump_ifinfo },
[RTM_SETLINK - RTM_BASE] = { .doit = do_setlink },
[RTM_GETADDR - RTM_BASE] = { .dumpit = rtnetlink_dump_all },
[RTM_GETROUTE - RTM_BASE] = { .dumpit = rtnetlink_dump_all },
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index c9f87845453..09464fa8d72 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -149,7 +149,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
/* Get the DATA. Size must match skb_add_mtu(). */
size = SKB_DATA_ALIGN(size);
- data = kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
+ data = ____kmalloc(size + sizeof(struct skb_shared_info), gfp_mask);
if (!data)
goto nodata;
diff --git a/net/core/sock.c b/net/core/sock.c
index 1a7e6eac90b..e110b900414 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -404,8 +404,9 @@ set_rcvbuf:
if (!valbool) {
sk->sk_bound_dev_if = 0;
} else {
- if (optlen > IFNAMSIZ)
- optlen = IFNAMSIZ;
+ if (optlen > IFNAMSIZ - 1)
+ optlen = IFNAMSIZ - 1;
+ memset(devname, 0, sizeof(devname));
if (copy_from_user(devname, optval, optlen)) {
ret = -EFAULT;
break;
diff --git a/net/core/wireless.c b/net/core/wireless.c
index 2add7ed609e..81d6995fcfd 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -2,7 +2,7 @@
* This file implement the Wireless Extensions APIs.
*
* Authors : Jean Tourrilhes - HPL - <jt@hpl.hp.com>
- * Copyright (c) 1997-2005 Jean Tourrilhes, All Rights Reserved.
+ * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
*
* (As all part of the Linux kernel, this file is GPL)
*/
@@ -65,6 +65,9 @@
* o Start deprecating dev->get_wireless_stats, output a warning
* o If IW_QUAL_DBM is set, show dBm values in /proc/net/wireless
* o Don't loose INVALID/DBM flags when clearing UPDATED flags (iwstats)
+ *
+ * v8 - 17.02.06 - Jean II
+ * o RtNetlink requests support (SET/GET)
*/
/***************************** INCLUDES *****************************/
@@ -89,11 +92,13 @@
/* Debugging stuff */
#undef WE_IOCTL_DEBUG /* Debug IOCTL API */
+#undef WE_RTNETLINK_DEBUG /* Debug RtNetlink API */
#undef WE_EVENT_DEBUG /* Debug Event dispatcher */
#undef WE_SPY_DEBUG /* Debug enhanced spy support */
/* Options */
-#define WE_EVENT_NETLINK /* Propagate events using rtnetlink */
+//CONFIG_NET_WIRELESS_RTNETLINK /* Wireless requests over RtNetlink */
+#define WE_EVENT_RTNETLINK /* Propagate events using RtNetlink */
#define WE_SET_EVENT /* Generate an event on some set commands */
/************************* GLOBAL VARIABLES *************************/
@@ -156,13 +161,18 @@ static const struct iw_ioctl_description standard_ioctl[] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWPRIV - SIOCIWFIRST] = { /* (handled directly by us) */
- .header_type = IW_HEADER_TYPE_NULL,
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = sizeof(struct iw_priv_args),
+ .max_tokens = 16,
+ .flags = IW_DESCR_FLAG_NOMAX,
},
[SIOCSIWSTATS - SIOCIWFIRST] = {
.header_type = IW_HEADER_TYPE_NULL,
},
[SIOCGIWSTATS - SIOCIWFIRST] = { /* (handled directly by us) */
- .header_type = IW_HEADER_TYPE_NULL,
+ .header_type = IW_HEADER_TYPE_POINT,
+ .token_size = 1,
+ .max_tokens = sizeof(struct iw_statistics),
.flags = IW_DESCR_FLAG_DUMP,
},
[SIOCSIWSPY - SIOCIWFIRST] = {
@@ -529,6 +539,70 @@ static inline int adjust_priv_size(__u16 args,
return num * iw_priv_type_size[type];
}
+/* ---------------------------------------------------------------- */
+/*
+ * Standard Wireless Handler : get wireless stats
+ * Allow programatic access to /proc/net/wireless even if /proc
+ * doesn't exist... Also more efficient...
+ */
+static int iw_handler_get_iwstats(struct net_device * dev,
+ struct iw_request_info * info,
+ union iwreq_data * wrqu,
+ char * extra)
+{
+ /* Get stats from the driver */
+ struct iw_statistics *stats;
+
+ stats = get_wireless_stats(dev);
+ if (stats != (struct iw_statistics *) NULL) {
+
+ /* Copy statistics to extra */
+ memcpy(extra, stats, sizeof(struct iw_statistics));
+ wrqu->data.length = sizeof(struct iw_statistics);
+
+ /* Check if we need to clear the updated flag */
+ if(wrqu->data.flags != 0)
+ stats->qual.updated &= ~IW_QUAL_ALL_UPDATED;
+ return 0;
+ } else
+ return -EOPNOTSUPP;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Standard Wireless Handler : get iwpriv definitions
+ * Export the driver private handler definition
+ * They will be picked up by tools like iwpriv...
+ */
+static int iw_handler_get_private(struct net_device * dev,
+ struct iw_request_info * info,
+ union iwreq_data * wrqu,
+ char * extra)
+{
+ /* Check if the driver has something to export */
+ if((dev->wireless_handlers->num_private_args == 0) ||
+ (dev->wireless_handlers->private_args == NULL))
+ return -EOPNOTSUPP;
+
+ /* Check if there is enough buffer up there */
+ if(wrqu->data.length < dev->wireless_handlers->num_private_args) {
+ /* User space can't know in advance how large the buffer
+ * needs to be. Give it a hint, so that we can support
+ * any size buffer we want somewhat efficiently... */
+ wrqu->data.length = dev->wireless_handlers->num_private_args;
+ return -E2BIG;
+ }
+
+ /* Set the number of available ioctls. */
+ wrqu->data.length = dev->wireless_handlers->num_private_args;
+
+ /* Copy structure to the user buffer. */
+ memcpy(extra, dev->wireless_handlers->private_args,
+ sizeof(struct iw_priv_args) * wrqu->data.length);
+
+ return 0;
+}
+
/******************** /proc/net/wireless SUPPORT ********************/
/*
@@ -630,81 +704,14 @@ int __init wireless_proc_init(void)
/* ---------------------------------------------------------------- */
/*
- * Allow programatic access to /proc/net/wireless even if /proc
- * doesn't exist... Also more efficient...
- */
-static inline int dev_iwstats(struct net_device *dev, struct ifreq *ifr)
-{
- /* Get stats from the driver */
- struct iw_statistics *stats;
-
- stats = get_wireless_stats(dev);
- if (stats != (struct iw_statistics *) NULL) {
- struct iwreq * wrq = (struct iwreq *)ifr;
-
- /* Copy statistics to the user buffer */
- if(copy_to_user(wrq->u.data.pointer, stats,
- sizeof(struct iw_statistics)))
- return -EFAULT;
-
- /* Check if we need to clear the updated flag */
- if(wrq->u.data.flags != 0)
- stats->qual.updated &= ~IW_QUAL_ALL_UPDATED;
- return 0;
- } else
- return -EOPNOTSUPP;
-}
-
-/* ---------------------------------------------------------------- */
-/*
- * Export the driver private handler definition
- * They will be picked up by tools like iwpriv...
- */
-static inline int ioctl_export_private(struct net_device * dev,
- struct ifreq * ifr)
-{
- struct iwreq * iwr = (struct iwreq *) ifr;
-
- /* Check if the driver has something to export */
- if((dev->wireless_handlers->num_private_args == 0) ||
- (dev->wireless_handlers->private_args == NULL))
- return -EOPNOTSUPP;
-
- /* Check NULL pointer */
- if(iwr->u.data.pointer == NULL)
- return -EFAULT;
-
- /* Check if there is enough buffer up there */
- if(iwr->u.data.length < dev->wireless_handlers->num_private_args) {
- /* User space can't know in advance how large the buffer
- * needs to be. Give it a hint, so that we can support
- * any size buffer we want somewhat efficiently... */
- iwr->u.data.length = dev->wireless_handlers->num_private_args;
- return -E2BIG;
- }
-
- /* Set the number of available ioctls. */
- iwr->u.data.length = dev->wireless_handlers->num_private_args;
-
- /* Copy structure to the user buffer. */
- if (copy_to_user(iwr->u.data.pointer,
- dev->wireless_handlers->private_args,
- sizeof(struct iw_priv_args) * iwr->u.data.length))
- return -EFAULT;
-
- return 0;
-}
-
-/* ---------------------------------------------------------------- */
-/*
* Wrapper to call a standard Wireless Extension handler.
* We do various checks and also take care of moving data between
* user space and kernel space.
*/
-static inline int ioctl_standard_call(struct net_device * dev,
- struct ifreq * ifr,
- unsigned int cmd,
- iw_handler handler)
+static int ioctl_standard_call(struct net_device * dev,
+ struct ifreq * ifr,
+ unsigned int cmd,
+ iw_handler handler)
{
struct iwreq * iwr = (struct iwreq *) ifr;
const struct iw_ioctl_description * descr;
@@ -1048,14 +1055,20 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
{
case SIOCGIWSTATS:
/* Get Wireless Stats */
- return dev_iwstats(dev, ifr);
+ return ioctl_standard_call(dev,
+ ifr,
+ cmd,
+ &iw_handler_get_iwstats);
case SIOCGIWPRIV:
/* Check if we have some wireless handlers defined */
if(dev->wireless_handlers != NULL) {
/* We export to user space the definition of
* the private handler ourselves */
- return ioctl_export_private(dev, ifr);
+ return ioctl_standard_call(dev,
+ ifr,
+ cmd,
+ &iw_handler_get_private);
}
// ## Fall-through for old API ##
default:
@@ -1088,16 +1101,739 @@ int wireless_process_ioctl(struct ifreq *ifr, unsigned int cmd)
return -EINVAL;
}
+/********************** RTNETLINK REQUEST API **********************/
+/*
+ * The alternate user space API to configure all those Wireless Extensions
+ * is through RtNetlink.
+ * This API support only the new driver API (iw_handler).
+ *
+ * This RtNetlink API use the same query/reply model as the ioctl API.
+ * Maximum effort has been done to fit in the RtNetlink model, and
+ * we support both RtNetlink Set and RtNelink Get operations.
+ * On the other hand, we don't offer Dump operations because of the
+ * following reasons :
+ * o Large number of parameters, most optional
+ * o Large size of some parameters (> 100 bytes)
+ * o Each parameters need to be extracted from hardware
+ * o Scan requests can take seconds and disable network activity.
+ * Because of this high cost/overhead, we want to return only the
+ * parameters the user application is really interested in.
+ * We could offer partial Dump using the IW_DESCR_FLAG_DUMP flag.
+ *
+ * The API uses the standard RtNetlink socket. When the RtNetlink code
+ * find a IFLA_WIRELESS field in a RtNetlink SET_LINK request,
+ * it calls here.
+ */
+
+#ifdef CONFIG_NET_WIRELESS_RTNETLINK
+/* ---------------------------------------------------------------- */
+/*
+ * Wrapper to call a standard Wireless Extension GET handler.
+ * We do various checks and call the handler with the proper args.
+ */
+static int rtnetlink_standard_get(struct net_device * dev,
+ struct iw_event * request,
+ int request_len,
+ iw_handler handler,
+ char ** p_buf,
+ int * p_len)
+{
+ const struct iw_ioctl_description * descr = NULL;
+ unsigned int cmd;
+ union iwreq_data * wrqu;
+ int hdr_len;
+ struct iw_request_info info;
+ char * buffer = NULL;
+ int buffer_size = 0;
+ int ret = -EINVAL;
+
+ /* Get the description of the Request */
+ cmd = request->cmd;
+ if((cmd - SIOCIWFIRST) >= standard_ioctl_num)
+ return -EOPNOTSUPP;
+ descr = &(standard_ioctl[cmd - SIOCIWFIRST]);
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Found standard handler for 0x%04X\n",
+ dev->name, cmd);
+ printk(KERN_DEBUG "%s (WE.r) : Header type : %d, Token type : %d, size : %d, token : %d\n", dev->name, descr->header_type, descr->token_type, descr->token_size, descr->max_tokens);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Check if wrqu is complete */
+ hdr_len = event_type_size[descr->header_type];
+ if(request_len < hdr_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG
+ "%s (WE.r) : Wireless request too short (%d)\n",
+ dev->name, request_len);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+ /* Prepare the call */
+ info.cmd = cmd;
+ info.flags = 0;
+
+ /* Check if we have extra data in the reply or not */
+ if(descr->header_type != IW_HEADER_TYPE_POINT) {
+
+ /* Create the kernel buffer that we will return.
+ * It's at an offset to match the TYPE_POINT case... */
+ buffer_size = request_len + IW_EV_POINT_OFF;
+ buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (buffer == NULL) {
+ return -ENOMEM;
+ }
+ /* Copy event data */
+ memcpy(buffer + IW_EV_POINT_OFF, request, request_len);
+ /* Use our own copy of wrqu */
+ wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF
+ + IW_EV_LCP_LEN);
+
+ /* No extra arguments. Trivial to handle */
+ ret = handler(dev, &info, wrqu, NULL);
+
+ } else {
+ union iwreq_data wrqu_point;
+ char * extra = NULL;
+ int extra_size = 0;
+
+ /* Get a temp copy of wrqu (skip pointer) */
+ memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
+ ((char *) request) + IW_EV_LCP_LEN,
+ IW_EV_POINT_LEN - IW_EV_LCP_LEN);
+
+ /* Calculate space needed by arguments. Always allocate
+ * for max space. Easier, and won't last long... */
+ extra_size = descr->max_tokens * descr->token_size;
+ /* Support for very large requests */
+ if((descr->flags & IW_DESCR_FLAG_NOMAX) &&
+ (wrqu_point.data.length > descr->max_tokens))
+ extra_size = (wrqu_point.data.length
+ * descr->token_size);
+ buffer_size = extra_size + IW_EV_POINT_LEN + IW_EV_POINT_OFF;
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n",
+ dev->name, extra_size, buffer_size);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Create the kernel buffer that we will return */
+ buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (buffer == NULL) {
+ return -ENOMEM;
+ }
+
+ /* Put wrqu in the right place (just before extra).
+ * Leave space for IWE header and dummy pointer...
+ * Note that IW_EV_LCP_LEN==4 bytes, so it's still aligned...
+ */
+ memcpy(buffer + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
+ ((char *) &wrqu_point) + IW_EV_POINT_OFF,
+ IW_EV_POINT_LEN - IW_EV_LCP_LEN);
+ wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_LEN);
+
+ /* Extra comes logically after that. Offset +12 bytes. */
+ extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_LEN;
+
+ /* Call the handler */
+ ret = handler(dev, &info, wrqu, extra);
+
+ /* Calculate real returned length */
+ extra_size = (wrqu->data.length * descr->token_size);
+ /* Re-adjust reply size */
+ request->len = extra_size + IW_EV_POINT_LEN;
+
+ /* Put the iwe header where it should, i.e. scrap the
+ * dummy pointer. */
+ memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_LEN);
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Check if there is enough buffer up there */
+ if(wrqu_point.data.length < wrqu->data.length)
+ ret = -E2BIG;
+ }
+
+ /* Return the buffer to the caller */
+ if (!ret) {
+ *p_buf = buffer;
+ *p_len = request->len;
+ } else {
+ /* Cleanup */
+ if(buffer)
+ kfree(buffer);
+ }
+
+ return ret;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Wrapper to call a standard Wireless Extension SET handler.
+ * We do various checks and call the handler with the proper args.
+ */
+static inline int rtnetlink_standard_set(struct net_device * dev,
+ struct iw_event * request,
+ int request_len,
+ iw_handler handler)
+{
+ const struct iw_ioctl_description * descr = NULL;
+ unsigned int cmd;
+ union iwreq_data * wrqu;
+ union iwreq_data wrqu_point;
+ int hdr_len;
+ char * extra = NULL;
+ int extra_size = 0;
+ struct iw_request_info info;
+ int ret = -EINVAL;
+
+ /* Get the description of the Request */
+ cmd = request->cmd;
+ if((cmd - SIOCIWFIRST) >= standard_ioctl_num)
+ return -EOPNOTSUPP;
+ descr = &(standard_ioctl[cmd - SIOCIWFIRST]);
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Found standard SET handler for 0x%04X\n",
+ dev->name, cmd);
+ printk(KERN_DEBUG "%s (WE.r) : Header type : %d, Token type : %d, size : %d, token : %d\n", dev->name, descr->header_type, descr->token_type, descr->token_size, descr->max_tokens);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Extract fixed header from request. This is properly aligned. */
+ wrqu = &request->u;
+
+ /* Check if wrqu is complete */
+ hdr_len = event_type_size[descr->header_type];
+ if(request_len < hdr_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG
+ "%s (WE.r) : Wireless request too short (%d)\n",
+ dev->name, request_len);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+ /* Prepare the call */
+ info.cmd = cmd;
+ info.flags = 0;
+
+ /* Check if we have extra data in the request or not */
+ if(descr->header_type != IW_HEADER_TYPE_POINT) {
+
+ /* No extra arguments. Trivial to handle */
+ ret = handler(dev, &info, wrqu, NULL);
+
+ } else {
+ int extra_len;
+
+ /* Put wrqu in the right place (skip pointer) */
+ memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
+ wrqu, IW_EV_POINT_LEN - IW_EV_LCP_LEN);
+ /* Don't forget about the event code... */
+ wrqu = &wrqu_point;
+
+ /* Check if number of token fits within bounds */
+ if(wrqu_point.data.length > descr->max_tokens)
+ return -E2BIG;
+ if(wrqu_point.data.length < descr->min_tokens)
+ return -EINVAL;
+
+ /* Real length of payload */
+ extra_len = wrqu_point.data.length * descr->token_size;
+
+ /* Check if request is self consistent */
+ if((request_len - hdr_len) < extra_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n",
+ dev->name, extra_size);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes\n",
+ dev->name, extra_size);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Always allocate for max space. Easier, and won't last
+ * long... */
+ extra_size = descr->max_tokens * descr->token_size;
+ extra = kmalloc(extra_size, GFP_KERNEL);
+ if (extra == NULL)
+ return -ENOMEM;
+
+ /* Copy extra in aligned buffer */
+ memcpy(extra, ((char *) request) + hdr_len, extra_len);
+
+ /* Call the handler */
+ ret = handler(dev, &info, &wrqu_point, extra);
+ }
+
+#ifdef WE_SET_EVENT
+ /* Generate an event to notify listeners of the change */
+ if((descr->flags & IW_DESCR_FLAG_EVENT) &&
+ ((ret == 0) || (ret == -EIWCOMMIT))) {
+ if(descr->flags & IW_DESCR_FLAG_RESTRICT)
+ /* If the event is restricted, don't
+ * export the payload */
+ wireless_send_event(dev, cmd, wrqu, NULL);
+ else
+ wireless_send_event(dev, cmd, wrqu, extra);
+ }
+#endif /* WE_SET_EVENT */
+
+ /* Cleanup - I told you it wasn't that long ;-) */
+ if(extra)
+ kfree(extra);
+
+ /* Call commit handler if needed and defined */
+ if(ret == -EIWCOMMIT)
+ ret = call_commit_handler(dev);
+
+ return ret;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Wrapper to call a private Wireless Extension GET handler.
+ * Same as above...
+ * It's not as nice and slimline as the standard wrapper. The cause
+ * is struct iw_priv_args, which was not really designed for the
+ * job we are going here.
+ *
+ * IMPORTANT : This function prevent to set and get data on the same
+ * IOCTL and enforce the SET/GET convention. Not doing it would be
+ * far too hairy...
+ * If you need to set and get data at the same time, please don't use
+ * a iw_handler but process it in your ioctl handler (i.e. use the
+ * old driver API).
+ */
+static inline int rtnetlink_private_get(struct net_device * dev,
+ struct iw_event * request,
+ int request_len,
+ iw_handler handler,
+ char ** p_buf,
+ int * p_len)
+{
+ const struct iw_priv_args * descr = NULL;
+ unsigned int cmd;
+ union iwreq_data * wrqu;
+ int hdr_len;
+ struct iw_request_info info;
+ int extra_size = 0;
+ int i;
+ char * buffer = NULL;
+ int buffer_size = 0;
+ int ret = -EINVAL;
+
+ /* Get the description of the Request */
+ cmd = request->cmd;
+ for(i = 0; i < dev->wireless_handlers->num_private_args; i++)
+ if(cmd == dev->wireless_handlers->private_args[i].cmd) {
+ descr = &(dev->wireless_handlers->private_args[i]);
+ break;
+ }
+ if(descr == NULL)
+ return -EOPNOTSUPP;
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Found private handler for 0x%04X\n",
+ dev->name, cmd);
+ printk(KERN_DEBUG "%s (WE.r) : Name %s, set %X, get %X\n",
+ dev->name, descr->name, descr->set_args, descr->get_args);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Compute the max size of the get arguments */
+ extra_size = get_priv_size(descr->get_args);
+
+ /* Does it fits in wrqu ? */
+ if((descr->get_args & IW_PRIV_SIZE_FIXED) &&
+ (extra_size <= IFNAMSIZ)) {
+ hdr_len = extra_size;
+ extra_size = 0;
+ } else {
+ hdr_len = IW_EV_POINT_LEN;
+ }
+
+ /* Check if wrqu is complete */
+ if(request_len < hdr_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG
+ "%s (WE.r) : Wireless request too short (%d)\n",
+ dev->name, request_len);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+ /* Prepare the call */
+ info.cmd = cmd;
+ info.flags = 0;
+
+ /* Check if we have a pointer to user space data or not. */
+ if(extra_size == 0) {
+
+ /* Create the kernel buffer that we will return.
+ * It's at an offset to match the TYPE_POINT case... */
+ buffer_size = request_len + IW_EV_POINT_OFF;
+ buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (buffer == NULL) {
+ return -ENOMEM;
+ }
+ /* Copy event data */
+ memcpy(buffer + IW_EV_POINT_OFF, request, request_len);
+ /* Use our own copy of wrqu */
+ wrqu = (union iwreq_data *) (buffer + IW_EV_POINT_OFF
+ + IW_EV_LCP_LEN);
+
+ /* No extra arguments. Trivial to handle */
+ ret = handler(dev, &info, wrqu, (char *) wrqu);
+
+ } else {
+ char * extra;
+
+ /* Buffer for full reply */
+ buffer_size = extra_size + IW_EV_POINT_LEN + IW_EV_POINT_OFF;
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes (%d bytes)\n",
+ dev->name, extra_size, buffer_size);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Create the kernel buffer that we will return */
+ buffer = kmalloc(buffer_size, GFP_KERNEL);
+ if (buffer == NULL) {
+ return -ENOMEM;
+ }
+
+ /* Put wrqu in the right place (just before extra).
+ * Leave space for IWE header and dummy pointer...
+ * Note that IW_EV_LCP_LEN==4 bytes, so it's still aligned...
+ */
+ memcpy(buffer + IW_EV_LCP_LEN + IW_EV_POINT_OFF,
+ ((char *) request) + IW_EV_LCP_LEN,
+ IW_EV_POINT_LEN - IW_EV_LCP_LEN);
+ wrqu = (union iwreq_data *) (buffer + IW_EV_LCP_LEN);
+
+ /* Extra comes logically after that. Offset +12 bytes. */
+ extra = buffer + IW_EV_POINT_OFF + IW_EV_POINT_LEN;
+
+ /* Call the handler */
+ ret = handler(dev, &info, wrqu, extra);
+
+ /* Adjust for the actual length if it's variable,
+ * avoid leaking kernel bits outside. */
+ if (!(descr->get_args & IW_PRIV_SIZE_FIXED))
+ extra_size = adjust_priv_size(descr->get_args, wrqu);
+ /* Re-adjust reply size */
+ request->len = extra_size + IW_EV_POINT_LEN;
+
+ /* Put the iwe header where it should, i.e. scrap the
+ * dummy pointer. */
+ memcpy(buffer + IW_EV_POINT_OFF, request, IW_EV_LCP_LEN);
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Reply 0x%04X, hdr_len %d, tokens %d, extra_size %d, buffer_size %d\n", dev->name, cmd, hdr_len, wrqu->data.length, extra_size, buffer_size);
+#endif /* WE_RTNETLINK_DEBUG */
+ }
+
+ /* Return the buffer to the caller */
+ if (!ret) {
+ *p_buf = buffer;
+ *p_len = request->len;
+ } else {
+ /* Cleanup */
+ if(buffer)
+ kfree(buffer);
+ }
+
+ return ret;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Wrapper to call a private Wireless Extension SET handler.
+ * Same as above...
+ * It's not as nice and slimline as the standard wrapper. The cause
+ * is struct iw_priv_args, which was not really designed for the
+ * job we are going here.
+ *
+ * IMPORTANT : This function prevent to set and get data on the same
+ * IOCTL and enforce the SET/GET convention. Not doing it would be
+ * far too hairy...
+ * If you need to set and get data at the same time, please don't use
+ * a iw_handler but process it in your ioctl handler (i.e. use the
+ * old driver API).
+ */
+static inline int rtnetlink_private_set(struct net_device * dev,
+ struct iw_event * request,
+ int request_len,
+ iw_handler handler)
+{
+ const struct iw_priv_args * descr = NULL;
+ unsigned int cmd;
+ union iwreq_data * wrqu;
+ union iwreq_data wrqu_point;
+ int hdr_len;
+ char * extra = NULL;
+ int extra_size = 0;
+ int offset = 0; /* For sub-ioctls */
+ struct iw_request_info info;
+ int i;
+ int ret = -EINVAL;
+
+ /* Get the description of the Request */
+ cmd = request->cmd;
+ for(i = 0; i < dev->wireless_handlers->num_private_args; i++)
+ if(cmd == dev->wireless_handlers->private_args[i].cmd) {
+ descr = &(dev->wireless_handlers->private_args[i]);
+ break;
+ }
+ if(descr == NULL)
+ return -EOPNOTSUPP;
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Found private handler for 0x%04X\n",
+ ifr->ifr_name, cmd);
+ printk(KERN_DEBUG "%s (WE.r) : Name %s, set %X, get %X\n",
+ dev->name, descr->name, descr->set_args, descr->get_args);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Compute the size of the set arguments */
+ /* Check for sub-ioctl handler */
+ if(descr->name[0] == '\0')
+ /* Reserve one int for sub-ioctl index */
+ offset = sizeof(__u32);
+
+ /* Size of set arguments */
+ extra_size = get_priv_size(descr->set_args);
+
+ /* Does it fits in wrqu ? */
+ if((descr->set_args & IW_PRIV_SIZE_FIXED) &&
+ (extra_size <= IFNAMSIZ)) {
+ hdr_len = IW_EV_LCP_LEN + extra_size;
+ extra_size = 0;
+ } else {
+ hdr_len = IW_EV_POINT_LEN;
+ }
+
+ /* Extract fixed header from request. This is properly aligned. */
+ wrqu = &request->u;
+
+ /* Check if wrqu is complete */
+ if(request_len < hdr_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG
+ "%s (WE.r) : Wireless request too short (%d)\n",
+ dev->name, request_len);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+ /* Prepare the call */
+ info.cmd = cmd;
+ info.flags = 0;
+
+ /* Check if we have a pointer to user space data or not. */
+ if(extra_size == 0) {
+
+ /* No extra arguments. Trivial to handle */
+ ret = handler(dev, &info, wrqu, (char *) wrqu);
+
+ } else {
+ int extra_len;
+
+ /* Put wrqu in the right place (skip pointer) */
+ memcpy(((char *) &wrqu_point) + IW_EV_POINT_OFF,
+ wrqu, IW_EV_POINT_LEN - IW_EV_LCP_LEN);
+
+ /* Does it fits within bounds ? */
+ if(wrqu_point.data.length > (descr->set_args &
+ IW_PRIV_SIZE_MASK))
+ return -E2BIG;
+
+ /* Real length of payload */
+ extra_len = adjust_priv_size(descr->set_args, &wrqu_point);
+
+ /* Check if request is self consistent */
+ if((request_len - hdr_len) < extra_len) {
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Wireless request data too short (%d)\n",
+ dev->name, extra_size);
+#endif /* WE_RTNETLINK_DEBUG */
+ return -EINVAL;
+ }
+
+#ifdef WE_RTNETLINK_DEBUG
+ printk(KERN_DEBUG "%s (WE.r) : Malloc %d bytes\n",
+ dev->name, extra_size);
+#endif /* WE_RTNETLINK_DEBUG */
+
+ /* Always allocate for max space. Easier, and won't last
+ * long... */
+ extra = kmalloc(extra_size, GFP_KERNEL);
+ if (extra == NULL)
+ return -ENOMEM;
+
+ /* Copy extra in aligned buffer */
+ memcpy(extra, ((char *) request) + hdr_len, extra_len);
+
+ /* Call the handler */
+ ret = handler(dev, &info, &wrqu_point, extra);
+
+ /* Cleanup - I told you it wasn't that long ;-) */
+ kfree(extra);
+ }
+
+ /* Call commit handler if needed and defined */
+ if(ret == -EIWCOMMIT)
+ ret = call_commit_handler(dev);
+
+ return ret;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Main RtNetlink dispatcher. Called from the main networking code
+ * (do_getlink() in net/core/rtnetlink.c).
+ * Check the type of Request and call the appropriate wrapper...
+ */
+int wireless_rtnetlink_get(struct net_device * dev,
+ char * data,
+ int len,
+ char ** p_buf,
+ int * p_len)
+{
+ struct iw_event * request = (struct iw_event *) data;
+ iw_handler handler;
+
+ /* Check length */
+ if(len < IW_EV_LCP_LEN) {
+ printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
+ dev->name, len);
+ return -EINVAL;
+ }
+
+ /* ReCheck length (len may have padding) */
+ if(request->len > len) {
+ printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n",
+ dev->name, request->len, len);
+ return -EINVAL;
+ }
+
+ /* Only accept GET requests in here */
+ if(!IW_IS_GET(request->cmd))
+ return -EOPNOTSUPP;
+
+ /* Special cases */
+ if(request->cmd == SIOCGIWSTATS)
+ /* Get Wireless Stats */
+ return rtnetlink_standard_get(dev,
+ request,
+ request->len,
+ &iw_handler_get_iwstats,
+ p_buf, p_len);
+ if(request->cmd == SIOCGIWPRIV) {
+ /* Check if we have some wireless handlers defined */
+ if(dev->wireless_handlers == NULL)
+ return -EOPNOTSUPP;
+ /* Get Wireless Stats */
+ return rtnetlink_standard_get(dev,
+ request,
+ request->len,
+ &iw_handler_get_private,
+ p_buf, p_len);
+ }
+
+ /* Basic check */
+ if (!netif_device_present(dev))
+ return -ENODEV;
+
+ /* Try to find the handler */
+ handler = get_handler(dev, request->cmd);
+ if(handler != NULL) {
+ /* Standard and private are not the same */
+ if(request->cmd < SIOCIWFIRSTPRIV)
+ return rtnetlink_standard_get(dev,
+ request,
+ request->len,
+ handler,
+ p_buf, p_len);
+ else
+ return rtnetlink_private_get(dev,
+ request,
+ request->len,
+ handler,
+ p_buf, p_len);
+ }
+
+ return -EOPNOTSUPP;
+}
+
+/* ---------------------------------------------------------------- */
+/*
+ * Main RtNetlink dispatcher. Called from the main networking code
+ * (do_setlink() in net/core/rtnetlink.c).
+ * Check the type of Request and call the appropriate wrapper...
+ */
+int wireless_rtnetlink_set(struct net_device * dev,
+ char * data,
+ int len)
+{
+ struct iw_event * request = (struct iw_event *) data;
+ iw_handler handler;
+
+ /* Check length */
+ if(len < IW_EV_LCP_LEN) {
+ printk(KERN_DEBUG "%s (WE.r) : RtNetlink request too short (%d)\n",
+ dev->name, len);
+ return -EINVAL;
+ }
+
+ /* ReCheck length (len may have padding) */
+ if(request->len > len) {
+ printk(KERN_DEBUG "%s (WE.r) : RtNetlink request len invalid (%d-%d)\n",
+ dev->name, request->len, len);
+ return -EINVAL;
+ }
+
+ /* Only accept SET requests in here */
+ if(!IW_IS_SET(request->cmd))
+ return -EOPNOTSUPP;
+
+ /* Basic check */
+ if (!netif_device_present(dev))
+ return -ENODEV;
+
+ /* New driver API : try to find the handler */
+ handler = get_handler(dev, request->cmd);
+ if(handler != NULL) {
+ /* Standard and private are not the same */
+ if(request->cmd < SIOCIWFIRSTPRIV)
+ return rtnetlink_standard_set(dev,
+ request,
+ request->len,
+ handler);
+ else
+ return rtnetlink_private_set(dev,
+ request,
+ request->len,
+ handler);
+ }
+
+ return -EOPNOTSUPP;
+}
+#endif /* CONFIG_NET_WIRELESS_RTNETLINK */
+
+
/************************* EVENT PROCESSING *************************/
/*
* Process events generated by the wireless layer or the driver.
* Most often, the event will be propagated through rtnetlink
*/
-#ifdef WE_EVENT_NETLINK
-/* "rtnl" is defined in net/core/rtnetlink.c, but we need it here.
- * It is declared in <linux/rtnetlink.h> */
-
+#ifdef WE_EVENT_RTNETLINK
/* ---------------------------------------------------------------- */
/*
* Fill a rtnetlink message with our event data.
@@ -1121,12 +1857,11 @@ static inline int rtnetlink_fill_iwinfo(struct sk_buff * skb,
r->__ifi_pad = 0;
r->ifi_type = dev->type;
r->ifi_index = dev->ifindex;
- r->ifi_flags = dev->flags;
+ r->ifi_flags = dev_get_flags(dev);
r->ifi_change = 0; /* Wireless changes don't affect those flags */
/* Add the wireless events in the netlink packet */
- RTA_PUT(skb, IFLA_WIRELESS,
- event_len, event);
+ RTA_PUT(skb, IFLA_WIRELESS, event_len, event);
nlh->nlmsg_len = skb->tail - b;
return skb->len;
@@ -1163,7 +1898,7 @@ static inline void rtmsg_iwinfo(struct net_device * dev,
NETLINK_CB(skb).dst_group = RTNLGRP_LINK;
netlink_broadcast(rtnl, skb, 0, RTNLGRP_LINK, GFP_ATOMIC);
}
-#endif /* WE_EVENT_NETLINK */
+#endif /* WE_EVENT_RTNETLINK */
/* ---------------------------------------------------------------- */
/*
@@ -1255,10 +1990,10 @@ void wireless_send_event(struct net_device * dev,
if(extra != NULL)
memcpy(((char *) event) + hdr_len, extra, extra_len);
-#ifdef WE_EVENT_NETLINK
- /* rtnetlink event channel */
+#ifdef WE_EVENT_RTNETLINK
+ /* Send via the RtNetlink event channel */
rtmsg_iwinfo(dev, (char *) event, event_len);
-#endif /* WE_EVENT_NETLINK */
+#endif /* WE_EVENT_RTNETLINK */
/* Cleanup */
kfree(event);
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index d4b293e1628..1ff7328b0e1 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -350,7 +350,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED)
mask |= POLLHUP;
if (sk->sk_shutdown & RCV_SHUTDOWN)
- mask |= POLLIN | POLLRDNORM;
+ mask |= POLLIN | POLLRDNORM | POLLRDHUP;
/* Connected? */
if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) {
diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig
index d18ccba3ea9..dbb08528ddf 100644
--- a/net/ieee80211/Kconfig
+++ b/net/ieee80211/Kconfig
@@ -66,3 +66,4 @@ config IEEE80211_CRYPT_TKIP
This can be compiled as a modules and it will be called
"ieee80211_crypt_tkip".
+source "net/ieee80211/softmac/Kconfig"
diff --git a/net/ieee80211/Makefile b/net/ieee80211/Makefile
index f988417121d..796a7c76ee4 100644
--- a/net/ieee80211/Makefile
+++ b/net/ieee80211/Makefile
@@ -10,3 +10,4 @@ ieee80211-objs := \
ieee80211_wx.o \
ieee80211_geo.o
+obj-$(CONFIG_IEEE80211_SOFTMAC) += softmac/
diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c
index a7f2a642a51..604b7b0097b 100644
--- a/net/ieee80211/ieee80211_rx.c
+++ b/net/ieee80211/ieee80211_rx.c
@@ -780,6 +780,80 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
return 0;
}
+/* Filter out unrelated packets, call ieee80211_rx[_mgt] */
+int ieee80211_rx_any(struct ieee80211_device *ieee,
+ struct sk_buff *skb, struct ieee80211_rx_stats *stats)
+{
+ struct ieee80211_hdr_4addr *hdr;
+ int is_packet_for_us;
+ u16 fc;
+
+ if (ieee->iw_mode == IW_MODE_MONITOR)
+ return ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL;
+
+ hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ fc = le16_to_cpu(hdr->frame_ctl);
+
+ if ((fc & IEEE80211_FCTL_VERS) != 0)
+ return -EINVAL;
+
+ switch (fc & IEEE80211_FCTL_FTYPE) {
+ case IEEE80211_FTYPE_MGMT:
+ ieee80211_rx_mgt(ieee, hdr, stats);
+ return 0;
+ case IEEE80211_FTYPE_DATA:
+ break;
+ case IEEE80211_FTYPE_CTL:
+ return 0;
+ default:
+ return -EINVAL;
+ }
+
+ is_packet_for_us = 0;
+ switch (ieee->iw_mode) {
+ case IW_MODE_ADHOC:
+ /* our BSS and not from/to DS */
+ if (memcmp(hdr->addr3, ieee->bssid, ETH_ALEN) == 0)
+ if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == 0) {
+ /* promisc: get all */
+ if (ieee->dev->flags & IFF_PROMISC)
+ is_packet_for_us = 1;
+ /* to us */
+ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
+ is_packet_for_us = 1;
+ /* mcast */
+ else if (is_multicast_ether_addr(hdr->addr1))
+ is_packet_for_us = 1;
+ }
+ break;
+ case IW_MODE_INFRA:
+ /* our BSS (== from our AP) and from DS */
+ if (memcmp(hdr->addr2, ieee->bssid, ETH_ALEN) == 0)
+ if ((fc & (IEEE80211_FCTL_TODS+IEEE80211_FCTL_FROMDS)) == IEEE80211_FCTL_FROMDS) {
+ /* promisc: get all */
+ if (ieee->dev->flags & IFF_PROMISC)
+ is_packet_for_us = 1;
+ /* to us */
+ else if (memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN) == 0)
+ is_packet_for_us = 1;
+ /* mcast */
+ else if (is_multicast_ether_addr(hdr->addr1)) {
+ /* not our own packet bcasted from AP */
+ if (memcmp(hdr->addr3, ieee->dev->dev_addr, ETH_ALEN))
+ is_packet_for_us = 1;
+ }
+ }
+ break;
+ default:
+ /* ? */
+ break;
+ }
+
+ if (is_packet_for_us)
+ return (ieee80211_rx(ieee, skb, stats) ? 0 : -EINVAL);
+ return 0;
+}
+
#define MGMT_FRAME_FIXED_PART_LENGTH 0x24
static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 };
diff --git a/net/ieee80211/softmac/Kconfig b/net/ieee80211/softmac/Kconfig
new file mode 100644
index 00000000000..6cd9f3427be
--- /dev/null
+++ b/net/ieee80211/softmac/Kconfig
@@ -0,0 +1,10 @@
+config IEEE80211_SOFTMAC
+ tristate "Software MAC add-on to the IEEE 802.11 networking stack"
+ depends on IEEE80211 && EXPERIMENTAL
+ ---help---
+ This option enables the hardware independent software MAC addon
+ for the IEEE 802.11 networking stack.
+
+config IEEE80211_SOFTMAC_DEBUG
+ bool "Enable full debugging output"
+ depends on IEEE80211_SOFTMAC
diff --git a/net/ieee80211/softmac/Makefile b/net/ieee80211/softmac/Makefile
new file mode 100644
index 00000000000..bfcb391bb2c
--- /dev/null
+++ b/net/ieee80211/softmac/Makefile
@@ -0,0 +1,9 @@
+obj-$(CONFIG_IEEE80211_SOFTMAC) += ieee80211softmac.o
+ieee80211softmac-objs := \
+ ieee80211softmac_io.o \
+ ieee80211softmac_auth.o \
+ ieee80211softmac_module.o \
+ ieee80211softmac_scan.o \
+ ieee80211softmac_wx.o \
+ ieee80211softmac_assoc.o \
+ ieee80211softmac_event.o
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c
new file mode 100644
index 00000000000..be61de78dfa
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -0,0 +1,396 @@
+/*
+ * This file contains the softmac's association logic.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include "ieee80211softmac_priv.h"
+
+/*
+ * Overview
+ *
+ * Before you can associate, you have to authenticate.
+ *
+ */
+
+/* Sends out an association request to the desired AP */
+static void
+ieee80211softmac_assoc(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
+{
+ unsigned long flags;
+
+ /* Switch to correct channel for this network */
+ mac->set_channel(mac->dev, net->channel);
+
+ /* Send association request */
+ ieee80211softmac_send_mgt_frame(mac, net, IEEE80211_STYPE_ASSOC_REQ, 0);
+
+ dprintk(KERN_INFO PFX "sent association request!\n");
+
+ /* Change the state to associating */
+ spin_lock_irqsave(&mac->lock, flags);
+ mac->associnfo.associating = 1;
+ mac->associated = 0; /* just to make sure */
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* Set a timer for timeout */
+ /* FIXME: make timeout configurable */
+ schedule_delayed_work(&mac->associnfo.timeout, 5 * HZ);
+}
+
+void
+ieee80211softmac_assoc_timeout(void *d)
+{
+ struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d;
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ /* we might race against ieee80211softmac_handle_assoc_response,
+ * so make sure only one of us does something */
+ if (!mac->associnfo.associating) {
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return;
+ }
+ mac->associnfo.associating = 0;
+ mac->associnfo.bssvalid = 0;
+ mac->associated = 0;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ dprintk(KERN_INFO PFX "assoc request timed out!\n");
+ /* FIXME: we need to know the network here. that requires a bit of restructuring */
+ ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT, NULL);
+}
+
+/* Sends out a disassociation request to the desired AP */
+static void
+ieee80211softmac_disassoc(struct ieee80211softmac_device *mac, u16 reason)
+{
+ unsigned long flags;
+ struct ieee80211softmac_network *found;
+
+ if (mac->associnfo.bssvalid && mac->associated) {
+ found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
+ if (found)
+ ieee80211softmac_send_mgt_frame(mac, found, IEEE80211_STYPE_DISASSOC, reason);
+ } else if (mac->associnfo.associating) {
+ cancel_delayed_work(&mac->associnfo.timeout);
+ }
+
+ /* Change our state */
+ spin_lock_irqsave(&mac->lock, flags);
+ /* Do NOT clear bssvalid as that will break ieee80211softmac_assoc_work! */
+ mac->associated = 0;
+ mac->associnfo.associating = 0;
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+
+static inline int
+we_support_all_basic_rates(struct ieee80211softmac_device *mac, u8 *from, u8 from_len)
+{
+ int idx, search, found;
+ u8 rate, search_rate;
+
+ for (idx = 0; idx < (from_len); idx++) {
+ rate = (from)[idx];
+ if (!(rate & IEEE80211_BASIC_RATE_MASK))
+ continue;
+ found = 0;
+ rate &= ~IEEE80211_BASIC_RATE_MASK;
+ for (search = 0; search < mac->ratesinfo.count; search++) {
+ search_rate = mac->ratesinfo.rates[search];
+ search_rate &= ~IEEE80211_BASIC_RATE_MASK;
+ if (rate == search_rate) {
+ found = 1;
+ break;
+ }
+ }
+ if (!found)
+ return 0;
+ }
+ return 1;
+}
+
+static int
+network_matches_request(struct ieee80211softmac_device *mac, struct ieee80211_network *net)
+{
+ /* we cannot associate to networks whose name we don't know */
+ if (ieee80211_is_empty_essid(net->ssid, net->ssid_len))
+ return 0;
+ /* do not associate to a network whose BSSBasicRateSet we cannot support */
+ if (!we_support_all_basic_rates(mac, net->rates, net->rates_len))
+ return 0;
+ /* do we really need to check the ex rates? */
+ if (!we_support_all_basic_rates(mac, net->rates_ex, net->rates_ex_len))
+ return 0;
+
+ /* if 'ANY' network requested, take any that doesn't have privacy enabled */
+ if (mac->associnfo.req_essid.len == 0
+ && !(net->capability & WLAN_CAPABILITY_PRIVACY))
+ return 1;
+ if (net->ssid_len != mac->associnfo.req_essid.len)
+ return 0;
+ if (!memcmp(net->ssid, mac->associnfo.req_essid.data, mac->associnfo.req_essid.len))
+ return 1;
+ return 0;
+}
+
+static void
+ieee80211softmac_assoc_notify(struct net_device *dev, void *context)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ ieee80211softmac_assoc_work((void*)mac);
+}
+
+/* This function is called to handle userspace requests (asynchronously) */
+void
+ieee80211softmac_assoc_work(void *d)
+{
+ struct ieee80211softmac_device *mac = (struct ieee80211softmac_device *)d;
+ struct ieee80211softmac_network *found = NULL;
+ struct ieee80211_network *net = NULL, *best = NULL;
+ unsigned long flags;
+
+ /* meh */
+ if (mac->associated)
+ ieee80211softmac_disassoc(mac, WLAN_REASON_DISASSOC_STA_HAS_LEFT);
+
+ /* try to find the requested network in our list, if we found one already */
+ if (mac->associnfo.bssvalid)
+ found = ieee80211softmac_get_network_by_bssid(mac, mac->associnfo.bssid);
+
+ /* Search the ieee80211 networks for this network if we didn't find it by bssid,
+ * but only if we've scanned at least once (to get a better list of networks to
+ * select from). If we have not scanned before, the !found logic below will be
+ * invoked and will scan. */
+ if (!found && (mac->associnfo.scan_retry < IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT))
+ {
+ s8 rssi = -128; /* if I don't initialise, gcc emits an invalid warning
+ because it cannot follow the best pointer logic. */
+ spin_lock_irqsave(&mac->ieee->lock, flags);
+ list_for_each_entry(net, &mac->ieee->network_list, list) {
+ /* we're supposed to find the network with
+ * the best signal here, as we're asked to join
+ * any network with a specific ESSID, and many
+ * different ones could have that.
+ *
+ * I'll for now just go with the reported rssi.
+ *
+ * We also should take into account the rateset
+ * here to find the best BSSID to try.
+ */
+ if (network_matches_request(mac, net)) {
+ if (!best) {
+ best = net;
+ rssi = best->stats.rssi;
+ continue;
+ }
+ /* we already had a matching network, so
+ * compare their properties to get the
+ * better of the two ... (see above)
+ */
+ if (rssi < net->stats.rssi) {
+ best = net;
+ rssi = best->stats.rssi;
+ }
+ }
+ }
+ /* if we unlock here, we might get interrupted and the `best'
+ * pointer could go stale */
+ if (best) {
+ found = ieee80211softmac_create_network(mac, best);
+ /* if found is still NULL, then we got -ENOMEM somewhere */
+ if (found)
+ ieee80211softmac_add_network(mac, found);
+ }
+ spin_unlock_irqrestore(&mac->ieee->lock, flags);
+ }
+
+ if (!found) {
+ if (mac->associnfo.scan_retry > 0) {
+ spin_lock_irqsave(&mac->lock, flags);
+ mac->associnfo.scan_retry--;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* We know of no such network. Let's scan.
+ * NB: this also happens if we had no memory to copy the network info...
+ * Maybe we can hope to have more memory after scanning finishes ;)
+ */
+ dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
+ ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify, NULL);
+ if (ieee80211softmac_start_scan(mac))
+ dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
+ return;
+ }
+ else {
+ spin_lock_irqsave(&mac->lock, flags);
+ mac->associnfo.associating = 0;
+ mac->associated = 0;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ dprintk(KERN_INFO PFX "Unable to find matching network after scan!\n");
+ ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND, NULL);
+ return;
+ }
+ }
+
+ mac->associnfo.bssvalid = 1;
+ memcpy(mac->associnfo.bssid, found->bssid, ETH_ALEN);
+ /* copy the ESSID for displaying it */
+ mac->associnfo.associate_essid.len = found->essid.len;
+ memcpy(mac->associnfo.associate_essid.data, found->essid.data, IW_ESSID_MAX_SIZE + 1);
+
+ /* we found a network! authenticate (if necessary) and associate to it. */
+ if (!found->authenticated) {
+ /* This relies on the fact that _auth_req only queues the work,
+ * otherwise adding the notification would be racy. */
+ if (!ieee80211softmac_auth_req(mac, found)) {
+ dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n");
+ ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL);
+ } else {
+ printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
+ ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
+ }
+ return;
+ }
+ /* finally! now we can start associating */
+ ieee80211softmac_assoc(mac, found);
+}
+
+/* call this to do whatever is necessary when we're associated */
+static void
+ieee80211softmac_associated(struct ieee80211softmac_device *mac,
+ struct ieee80211_assoc_response * resp,
+ struct ieee80211softmac_network *net)
+{
+ mac->associnfo.associating = 0;
+ mac->associated = 1;
+ if (mac->set_bssid_filter)
+ mac->set_bssid_filter(mac->dev, net->bssid);
+ memcpy(mac->ieee->bssid, net->bssid, ETH_ALEN);
+ netif_carrier_on(mac->dev);
+
+ mac->association_id = le16_to_cpup(&resp->aid);
+}
+
+/* received frame handling functions */
+int
+ieee80211softmac_handle_assoc_response(struct net_device * dev,
+ struct ieee80211_assoc_response * resp,
+ struct ieee80211_network * _ieee80211_network_do_not_use)
+{
+ /* NOTE: the network parameter has to be ignored by
+ * this code because it is the ieee80211's pointer
+ * to the struct, not ours (we made a copy)
+ */
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ u16 status = le16_to_cpup(&resp->status);
+ struct ieee80211softmac_network *network = NULL;
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+
+ if (!mac->associnfo.associating) {
+ /* we race against the timeout function, so make sure
+ * only one of us can do work */
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return 0;
+ }
+ network = ieee80211softmac_get_network_by_bssid_locked(mac, resp->header.addr3);
+
+ /* someone sending us things without us knowing him? Ignore. */
+ if (!network) {
+ dprintk(KERN_INFO PFX "Received unrequested assocation response from " MAC_FMT "\n", MAC_ARG(resp->header.addr3));
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return 0;
+ }
+
+ /* now that we know it was for us, we can cancel the timeout */
+ cancel_delayed_work(&mac->associnfo.timeout);
+
+ switch (status) {
+ case 0:
+ dprintk(KERN_INFO PFX "associated!\n");
+ ieee80211softmac_associated(mac, resp, network);
+ ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATED, network);
+ break;
+ case WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH:
+ if (!network->auth_desynced_once) {
+ /* there seem to be a few rare cases where our view of
+ * the world is obscured, or buggy APs that don't DEAUTH
+ * us properly. So we handle that, but allow it only once.
+ */
+ printkl(KERN_INFO PFX "We were not authenticated during association, retrying...\n");
+ network->authenticated = 0;
+ /* we don't want to do this more than once ... */
+ network->auth_desynced_once = 1;
+ schedule_work(&mac->associnfo.work);
+ break;
+ }
+ default:
+ dprintk(KERN_INFO PFX "associating failed (reason: 0x%x)!\n", status);
+ mac->associnfo.associating = 0;
+ mac->associnfo.bssvalid = 0;
+ mac->associated = 0;
+ ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, network);
+ }
+
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return 0;
+}
+
+int
+ieee80211softmac_handle_disassoc(struct net_device * dev,
+ struct ieee80211_disassoc *disassoc)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ unsigned long flags;
+ if (memcmp(disassoc->header.addr2, mac->associnfo.bssid, ETH_ALEN))
+ return 0;
+ if (memcmp(disassoc->header.addr1, mac->dev->dev_addr, ETH_ALEN))
+ return 0;
+ dprintk(KERN_INFO PFX "got disassoc frame\n");
+ netif_carrier_off(dev);
+ spin_lock_irqsave(&mac->lock, flags);
+ mac->associnfo.bssvalid = 0;
+ mac->associated = 0;
+ schedule_work(&mac->associnfo.work);
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ return 0;
+}
+
+int
+ieee80211softmac_handle_reassoc_req(struct net_device * dev,
+ struct ieee80211_reassoc_request * resp)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ struct ieee80211softmac_network *network;
+
+ network = ieee80211softmac_get_network_by_bssid(mac, resp->header.addr3);
+ if (!network) {
+ dprintkl(KERN_INFO PFX "reassoc request from unknown network\n");
+ return 0;
+ }
+ ieee80211softmac_assoc(mac, network);
+ return 0;
+}
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c
new file mode 100644
index 00000000000..9a0eac6c61e
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_auth.c
@@ -0,0 +1,364 @@
+/*
+ * This file contains the softmac's authentication logic.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include "ieee80211softmac_priv.h"
+
+static void ieee80211softmac_auth_queue(void *data);
+
+/* Queues an auth request to the desired AP */
+int
+ieee80211softmac_auth_req(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net)
+{
+ struct ieee80211softmac_auth_queue_item *auth;
+ unsigned long flags;
+
+ if (net->authenticating)
+ return 0;
+
+ /* Add the network if it's not already added */
+ ieee80211softmac_add_network(mac, net);
+
+ dprintk(KERN_NOTICE PFX "Queueing Authentication Request to "MAC_FMT"\n", MAC_ARG(net->bssid));
+ /* Queue the auth request */
+ auth = (struct ieee80211softmac_auth_queue_item *)
+ kmalloc(sizeof(struct ieee80211softmac_auth_queue_item), GFP_KERNEL);
+ if(auth == NULL)
+ return -ENOMEM;
+
+ auth->net = net;
+ auth->mac = mac;
+ auth->retry = IEEE80211SOFTMAC_AUTH_RETRY_LIMIT;
+ auth->state = IEEE80211SOFTMAC_AUTH_OPEN_REQUEST;
+ INIT_WORK(&auth->work, &ieee80211softmac_auth_queue, (void *)auth);
+
+ /* Lock (for list) */
+ spin_lock_irqsave(&mac->lock, flags);
+
+ /* add to list */
+ list_add_tail(&auth->list, &mac->auth_queue);
+ schedule_work(&auth->work);
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ return 0;
+}
+
+
+/* Sends an auth request to the desired AP and handles timeouts */
+static void
+ieee80211softmac_auth_queue(void *data)
+{
+ struct ieee80211softmac_device *mac;
+ struct ieee80211softmac_auth_queue_item *auth;
+ struct ieee80211softmac_network *net;
+ unsigned long flags;
+
+ auth = (struct ieee80211softmac_auth_queue_item *)data;
+ net = auth->net;
+ mac = auth->mac;
+
+ if(auth->retry > 0) {
+ /* Switch to correct channel for this network */
+ mac->set_channel(mac->dev, net->channel);
+
+ /* Lock and set flags */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticated = 0;
+ net->authenticating = 1;
+ /* add a timeout call so we eventually give up waiting for an auth reply */
+ schedule_delayed_work(&auth->work, IEEE80211SOFTMAC_AUTH_TIMEOUT);
+ auth->retry--;
+ spin_unlock_irqrestore(&mac->lock, flags);
+ if (ieee80211softmac_send_mgt_frame(mac, auth->net, IEEE80211_STYPE_AUTH, auth->state))
+ dprintk(KERN_NOTICE PFX "Sending Authentication Request to "MAC_FMT" failed (this shouldn't happen, wait for the timeout).\n", MAC_ARG(net->bssid));
+ else
+ dprintk(KERN_NOTICE PFX "Sent Authentication Request to "MAC_FMT".\n", MAC_ARG(net->bssid));
+ return;
+ }
+
+ printkl(KERN_WARNING PFX "Authentication timed out with "MAC_FMT"\n", MAC_ARG(net->bssid));
+ /* Remove this item from the queue */
+ spin_lock_irqsave(&mac->lock, flags);
+ ieee80211softmac_call_events_locked(mac, IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT, net);
+ cancel_delayed_work(&auth->work); /* just to make sure... */
+ list_del(&auth->list);
+ spin_unlock_irqrestore(&mac->lock, flags);
+ /* Free it */
+ kfree(auth);
+}
+
+/* Handle the auth response from the AP
+ * This should be registered with ieee80211 as handle_auth
+ */
+int
+ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth)
+{
+
+ struct list_head *list_ptr;
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ struct ieee80211softmac_auth_queue_item *aq = NULL;
+ struct ieee80211softmac_network *net = NULL;
+ unsigned long flags;
+ u8 * data;
+
+ /* Find correct auth queue item */
+ spin_lock_irqsave(&mac->lock, flags);
+ list_for_each(list_ptr, &mac->auth_queue) {
+ aq = list_entry(list_ptr, struct ieee80211softmac_auth_queue_item, list);
+ net = aq->net;
+ if (!memcmp(net->bssid, auth->header.addr2, ETH_ALEN))
+ break;
+ else
+ aq = NULL;
+ }
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* Make sure that we've got an auth queue item for this request */
+ if(aq == NULL)
+ {
+ printkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but no queue item exists.\n", MAC_ARG(auth->header.addr2));
+ /* Error #? */
+ return -1;
+ }
+
+ /* Check for out of order authentication */
+ if(!net->authenticating)
+ {
+ printkl(KERN_DEBUG PFX "Authentication response received from "MAC_FMT" but did not request authentication.\n",MAC_ARG(auth->header.addr2));
+ return -1;
+ }
+
+ /* Parse the auth packet */
+ switch(auth->algorithm) {
+ case WLAN_AUTH_OPEN:
+ /* Check the status code of the response */
+
+ switch(auth->status) {
+ case WLAN_STATUS_SUCCESS:
+ /* Update the status to Authenticated */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticating = 0;
+ net->authenticated = 1;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* Send event */
+ printkl(KERN_NOTICE PFX "Open Authentication completed with "MAC_FMT"\n", MAC_ARG(net->bssid));
+ ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_AUTHENTICATED, net);
+ break;
+ default:
+ /* Lock and reset flags */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticated = 0;
+ net->authenticating = 0;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ printkl(KERN_NOTICE PFX "Open Authentication with "MAC_FMT" failed, error code: %i\n",
+ MAC_ARG(net->bssid), le16_to_cpup(&auth->status));
+ /* Count the error? */
+ break;
+ }
+ goto free_aq;
+ break;
+ case WLAN_AUTH_SHARED_KEY:
+ /* Figure out where we are in the process */
+ switch(auth->transaction) {
+ case IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE:
+ /* Check to make sure we have a challenge IE */
+ data = (u8 *)auth->info_element;
+ if(*data++ != MFIE_TYPE_CHALLENGE){
+ printkl(KERN_NOTICE PFX "Shared Key Authentication failed due to a missing challenge.\n");
+ break;
+ }
+ /* Save the challenge */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->challenge_len = *data++;
+ if(net->challenge_len > WLAN_AUTH_CHALLENGE_LEN)
+ net->challenge_len = WLAN_AUTH_CHALLENGE_LEN;
+ if(net->challenge != NULL)
+ kfree(net->challenge);
+ net->challenge = kmalloc(net->challenge_len, GFP_ATOMIC);
+ memcpy(net->challenge, data, net->challenge_len);
+ aq->state = IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE;
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* Switch to correct channel for this network */
+ mac->set_channel(mac->dev, net->channel);
+
+ /* Send our response (How to encrypt?) */
+ ieee80211softmac_send_mgt_frame(mac, aq->net, IEEE80211_STYPE_AUTH, aq->state);
+ break;
+ case IEEE80211SOFTMAC_AUTH_SHARED_PASS:
+ /* Check the status code of the response */
+ switch(auth->status) {
+ case WLAN_STATUS_SUCCESS:
+ /* Update the status to Authenticated */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticating = 0;
+ net->authenticated = 1;
+ spin_unlock_irqrestore(&mac->lock, flags);
+ printkl(KERN_NOTICE PFX "Shared Key Authentication completed with "MAC_FMT"\n",
+ MAC_ARG(net->bssid));
+ break;
+ default:
+ printkl(KERN_NOTICE PFX "Shared Key Authentication with "MAC_FMT" failed, error code: %i\n",
+ MAC_ARG(net->bssid), le16_to_cpup(&auth->status));
+ /* Lock and reset flags */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticating = 0;
+ net->authenticated = 0;
+ spin_unlock_irqrestore(&mac->lock, flags);
+ /* Count the error? */
+ break;
+ }
+ goto free_aq;
+ break;
+ default:
+ printkl(KERN_WARNING PFX "Unhandled Authentication Step: %i\n", auth->transaction);
+ break;
+ }
+ goto free_aq;
+ break;
+ default:
+ /* ERROR */
+ goto free_aq;
+ break;
+ }
+ return 0;
+free_aq:
+ /* Cancel the timeout */
+ spin_lock_irqsave(&mac->lock, flags);
+ cancel_delayed_work(&aq->work);
+ /* Remove this item from the queue */
+ list_del(&aq->list);
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ /* Free it */
+ kfree(aq);
+ return 0;
+}
+
+/*
+ * Handle deauthorization
+ */
+static void
+ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net)
+{
+ struct ieee80211softmac_auth_queue_item *aq = NULL;
+ struct list_head *list_ptr;
+ unsigned long flags;
+
+ /* Lock and reset status flags */
+ spin_lock_irqsave(&mac->lock, flags);
+ net->authenticating = 0;
+ net->authenticated = 0;
+
+ /* Find correct auth queue item, if it exists */
+ list_for_each(list_ptr, &mac->auth_queue) {
+ aq = list_entry(list_ptr, struct ieee80211softmac_auth_queue_item, list);
+ if (!memcmp(net->bssid, aq->net->bssid, ETH_ALEN))
+ break;
+ else
+ aq = NULL;
+ }
+
+ /* Cancel pending work */
+ if(aq != NULL)
+ /* Not entirely safe? What about running work? */
+ cancel_delayed_work(&aq->work);
+
+ /* Free our network ref */
+ ieee80211softmac_del_network_locked(mac, net);
+ if(net->challenge != NULL)
+ kfree(net->challenge);
+ kfree(net);
+
+ /* can't transmit data right now... */
+ netif_carrier_off(mac->dev);
+ /* let's try to re-associate */
+ schedule_work(&mac->associnfo.work);
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+
+/*
+ * Sends a deauth request to the desired AP
+ */
+int
+ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net, int reason)
+{
+ int ret;
+
+ /* Make sure the network is authenticated */
+ if (!net->authenticated)
+ {
+ printkl(KERN_DEBUG PFX "Can't send deauthentication packet, network is not authenticated.\n");
+ /* Error okay? */
+ return -EPERM;
+ }
+
+ /* Send the de-auth packet */
+ if((ret = ieee80211softmac_send_mgt_frame(mac, net, IEEE80211_STYPE_DEAUTH, reason)))
+ return ret;
+
+ ieee80211softmac_deauth_from_net(mac, net);
+ return 0;
+}
+
+/*
+ * This should be registered with ieee80211 as handle_deauth
+ */
+int
+ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth)
+{
+
+ struct ieee80211softmac_network *net = NULL;
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+
+ if (!deauth) {
+ dprintk("deauth without deauth packet. eek!\n");
+ return 0;
+ }
+
+ net = ieee80211softmac_get_network_by_bssid(mac, deauth->header.addr2);
+
+ if (net == NULL) {
+ printkl(KERN_DEBUG PFX "Received deauthentication packet from "MAC_FMT", but that network is unknown.\n",
+ MAC_ARG(deauth->header.addr2));
+ return 0;
+ }
+
+ /* Make sure the network is authenticated */
+ if(!net->authenticated)
+ {
+ printkl(KERN_DEBUG PFX "Can't perform deauthentication, network is not authenticated.\n");
+ /* Error okay? */
+ return -EPERM;
+ }
+
+ ieee80211softmac_deauth_from_net(mac, net);
+ return 0;
+}
diff --git a/net/ieee80211/softmac/ieee80211softmac_event.c b/net/ieee80211/softmac/ieee80211softmac_event.c
new file mode 100644
index 00000000000..0a52bbda1e4
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -0,0 +1,159 @@
+/*
+ * Event system
+ * Also see comments in public header file and longer explanation below.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include "ieee80211softmac_priv.h"
+
+/*
+ * Each event has associated to it
+ * - an event type (see constants in public header)
+ * - an event context (see below)
+ * - the function to be called
+ * - a context (extra parameter to call the function with)
+ * - and the softmac struct
+ *
+ * The event context is private and can only be used from
+ * within this module. Its meaning varies with the event
+ * type:
+ * SCAN_FINISHED: no special meaning
+ * ASSOCIATED,
+ * ASSOCIATE_FAILED,
+ * ASSOCIATE_TIMEOUT,
+ * AUTHENTICATED,
+ * AUTH_FAILED,
+ * AUTH_TIMEOUT: a pointer to the network struct
+ * ...
+ * Code within this module can use the event context to be only
+ * called when the event is true for that specific context
+ * as per above table.
+ * If the event context is NULL, then the notification is always called,
+ * regardless of the event context. The event context is not passed to
+ * the callback, it is assumed that the context suffices.
+ *
+ * You can also use the event context only by setting the event type
+ * to -1 (private use only), in which case you'll be notified
+ * whenever the event context matches.
+ */
+
+static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
+ "scan finished",
+ "associated",
+ "associating failed",
+ "associating timed out",
+ "authenticated",
+ "authenticating failed",
+ "authenticating timed out",
+ "associating failed because no suitable network was found",
+};
+
+
+static void
+ieee80211softmac_notify_callback(void *d)
+{
+ struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d;
+ kfree(d);
+
+ event.fun(event.mac->dev, event.context);
+}
+
+int
+ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
+ int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask)
+{
+ struct ieee80211softmac_event *eventptr;
+ unsigned long flags;
+
+ if (event < -1 || event > IEEE80211SOFTMAC_EVENT_LAST)
+ return -ENOSYS;
+
+ if (!fun)
+ return -EINVAL;
+
+ eventptr = kmalloc(sizeof(struct ieee80211softmac_event), gfp_mask);
+ if (!eventptr)
+ return -ENOMEM;
+
+ eventptr->event_type = event;
+ INIT_WORK(&eventptr->work, ieee80211softmac_notify_callback, eventptr);
+ eventptr->fun = fun;
+ eventptr->context = context;
+ eventptr->mac = mac;
+ eventptr->event_context = event_context;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ list_add(&eventptr->list, &mac->events);
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ return 0;
+}
+
+int
+ieee80211softmac_notify_gfp(struct net_device *dev,
+ int event, notify_function_ptr fun, void *context, gfp_t gfp_mask)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+
+ if (event < 0 || event > IEEE80211SOFTMAC_EVENT_LAST)
+ return -ENOSYS;
+
+ return ieee80211softmac_notify_internal(mac, event, NULL, fun, context, gfp_mask);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_notify_gfp);
+
+/* private -- calling all callbacks that were specified */
+void
+ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_ctx)
+{
+ struct ieee80211softmac_event *eventptr, *tmp;
+ union iwreq_data wrqu;
+ char *msg;
+
+ if (event >= 0) {
+ msg = event_descriptions[event];
+ wrqu.data.length = strlen(msg);
+ wireless_send_event(mac->dev, IWEVCUSTOM, &wrqu, msg);
+ }
+
+ if (!list_empty(&mac->events))
+ list_for_each_entry_safe(eventptr, tmp, &mac->events, list) {
+ if ((eventptr->event_type == event || eventptr->event_type == -1)
+ && (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) {
+ list_del(&eventptr->list);
+ schedule_work(&eventptr->work);
+ }
+ }
+}
+
+void
+ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_ctx)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ ieee80211softmac_call_events_locked(mac, event, event_ctx);
+
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
diff --git a/net/ieee80211/softmac/ieee80211softmac_io.c b/net/ieee80211/softmac/ieee80211softmac_io.c
new file mode 100644
index 00000000000..febc51dbb41
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_io.c
@@ -0,0 +1,474 @@
+/*
+ * Some parts based on code from net80211
+ * Copyright (c) 2001 Atsushi Onoe
+ * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "ieee80211softmac_priv.h"
+
+/* Helper functions for inserting data into the frames */
+
+/*
+ * Adds an ESSID element to the frame
+ *
+ */
+static u8 *
+ieee80211softmac_add_essid(u8 *dst, struct ieee80211softmac_essid *essid)
+{
+ if (essid) {
+ *dst++ = MFIE_TYPE_SSID;
+ *dst++ = essid->len;
+ memcpy(dst, essid->data, essid->len);
+ return dst+essid->len;
+ } else {
+ *dst++ = MFIE_TYPE_SSID;
+ *dst++ = 0;
+ return dst;
+ }
+}
+
+/* Adds Supported Rates and if required Extended Rates Information Element
+ * to the frame, ASSUMES WE HAVE A SORTED LIST OF RATES */
+static u8 *
+ieee80211softmac_frame_add_rates(u8 *dst, const struct ieee80211softmac_ratesinfo *r)
+{
+ int cck_len, ofdm_len;
+ *dst++ = MFIE_TYPE_RATES;
+
+ for(cck_len=0; ieee80211_is_cck_rate(r->rates[cck_len]) && (cck_len < r->count);cck_len++);
+
+ if(cck_len > IEEE80211SOFTMAC_MAX_RATES_LEN)
+ cck_len = IEEE80211SOFTMAC_MAX_RATES_LEN;
+ *dst++ = cck_len;
+ memcpy(dst, r->rates, cck_len);
+ dst += cck_len;
+
+ if(cck_len < r->count){
+ for (ofdm_len=0; ieee80211_is_ofdm_rate(r->rates[ofdm_len + cck_len]) && (ofdm_len + cck_len < r->count); ofdm_len++);
+ if (ofdm_len > 0) {
+ if (ofdm_len > IEEE80211SOFTMAC_MAX_EX_RATES_LEN)
+ ofdm_len = IEEE80211SOFTMAC_MAX_EX_RATES_LEN;
+ *dst++ = MFIE_TYPE_RATES_EX;
+ *dst++ = ofdm_len;
+ memcpy(dst, r->rates + cck_len, ofdm_len);
+ dst += ofdm_len;
+ }
+ }
+ return dst;
+}
+
+/* Allocate a management frame */
+static u8 *
+ieee80211softmac_alloc_mgt(u32 size)
+{
+ u8 * data;
+
+ /* Add the header and FCS to the size */
+ size = size + IEEE80211_3ADDR_LEN;
+ if(size > IEEE80211_DATA_LEN)
+ return NULL;
+ /* Allocate the frame */
+ data = kmalloc(size, GFP_ATOMIC);
+ memset(data, 0, size);
+ return data;
+}
+
+/*
+ * Add a 2 Address Header
+ */
+static void
+ieee80211softmac_hdr_2addr(struct ieee80211softmac_device *mac,
+ struct ieee80211_hdr_2addr *header, u32 type, u8 *dest)
+{
+ /* Fill in the frame control flags */
+ header->frame_ctl = cpu_to_le16(type);
+ /* Control packets always have WEP turned off */
+ if(type > IEEE80211_STYPE_CFENDACK && type < IEEE80211_STYPE_PSPOLL)
+ header->frame_ctl |= mac->ieee->sec.level ? cpu_to_le16(IEEE80211_FCTL_PROTECTED) : 0;
+
+ /* Fill in the duration */
+ header->duration_id = 0;
+ /* FIXME: How do I find this?
+ * calculate. But most drivers just fill in 0 (except if it's a station id of course) */
+
+ /* Fill in the Destination Address */
+ if(dest == NULL)
+ memset(header->addr1, 0xFF, ETH_ALEN);
+ else
+ memcpy(header->addr1, dest, ETH_ALEN);
+ /* Fill in the Source Address */
+ memcpy(header->addr2, mac->ieee->dev->dev_addr, ETH_ALEN);
+
+}
+
+
+/* Add a 3 Address Header */
+static void
+ieee80211softmac_hdr_3addr(struct ieee80211softmac_device *mac,
+ struct ieee80211_hdr_3addr *header, u32 type, u8 *dest, u8 *bssid)
+{
+ /* This is common with 2addr, so use that instead */
+ ieee80211softmac_hdr_2addr(mac, (struct ieee80211_hdr_2addr *)header, type, dest);
+
+ /* Fill in the BSS ID */
+ if(bssid == NULL)
+ memset(header->addr3, 0xFF, ETH_ALEN);
+ else
+ memcpy(header->addr3, bssid, ETH_ALEN);
+
+ /* Fill in the sequence # */
+ /* FIXME: I need to add this to the softmac struct
+ * shouldn't the sequence number be in ieee80211? */
+}
+
+
+/*****************************************************************************
+ * Create Management packets
+ *****************************************************************************/
+
+/* Creates an association request packet */
+static u32
+ieee80211softmac_assoc_req(struct ieee80211_assoc_request **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
+{
+ u8 *data;
+ (*pkt) = (struct ieee80211_assoc_request *)ieee80211softmac_alloc_mgt(
+ 2 + /* Capability Info */
+ 2 + /* Listen Interval */
+ /* SSID IE */
+ 1 + 1 + IW_ESSID_MAX_SIZE +
+ /* Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +
+ /* Extended Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN +
+ /* WPA IE if present */
+ mac->wpa.IElen
+ /* Other IE's? Optional?
+ * Yeah, probably need an extra IE parameter -- lots of vendors like to
+ * fill in their own IEs */
+ );
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_ASSOC_REQ, net->bssid, net->bssid);
+
+ /* Fill in capability Info */
+ (*pkt)->capability = (mac->ieee->iw_mode == IW_MODE_MASTER) || (mac->ieee->iw_mode == IW_MODE_INFRA) ?
+ cpu_to_le16(WLAN_CAPABILITY_ESS) :
+ cpu_to_le16(WLAN_CAPABILITY_IBSS);
+ /* Need to add this
+ (*pkt)->capability |= mac->ieee->short_slot ?
+ cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
+ */
+ (*pkt)->capability |= mac->ieee->sec.level ? cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
+ /* Fill in Listen Interval (?) */
+ (*pkt)->listen_interval = cpu_to_le16(10);
+
+ data = (u8 *)(*pkt)->info_element;
+ /* Add SSID */
+ data = ieee80211softmac_add_essid(data, &net->essid);
+ /* Add Rates */
+ data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);
+ /* Add WPA IE */
+ if (mac->wpa.IElen && mac->wpa.IE) {
+ memcpy(data, mac->wpa.IE, mac->wpa.IElen);
+ data += mac->wpa.IElen;
+ }
+ /* Return the number of used bytes */
+ return (data - (u8*)(*pkt));
+}
+
+/* Create a reassociation request packet */
+static u32
+ieee80211softmac_reassoc_req(struct ieee80211_reassoc_request **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
+{
+ u8 *data;
+ (*pkt) = (struct ieee80211_reassoc_request *)ieee80211softmac_alloc_mgt(
+ 2 + /* Capability Info */
+ 2 + /* Listen Interval */
+ ETH_ALEN + /* AP MAC */
+ /* SSID IE */
+ 1 + 1 + IW_ESSID_MAX_SIZE +
+ /* Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +
+ /* Extended Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN
+ /* Other IE's? */
+ );
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_REASSOC_REQ, net->bssid, net->bssid);
+
+ /* Fill in capability Info */
+ (*pkt)->capability = mac->ieee->iw_mode == IW_MODE_MASTER ?
+ cpu_to_le16(WLAN_CAPABILITY_ESS) :
+ cpu_to_le16(WLAN_CAPABILITY_IBSS);
+ /*
+ (*pkt)->capability |= mac->ieee->short_slot ?
+ cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT_TIME) : 0;
+ */
+ (*pkt)->capability |= mac->ieee->sec.level ?
+ cpu_to_le16(WLAN_CAPABILITY_PRIVACY) : 0;
+
+ /* Fill in Listen Interval (?) */
+ (*pkt)->listen_interval = cpu_to_le16(10);
+ /* Fill in the current AP MAC */
+ memcpy((*pkt)->current_ap, mac->ieee->bssid, ETH_ALEN);
+
+ data = (u8 *)(*pkt)->info_element;
+ /* Add SSID */
+ data = ieee80211softmac_add_essid(data, &net->essid);
+ /* Add Rates */
+ data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);
+ /* Return packet size */
+ return (data - (u8 *)(*pkt));
+}
+
+/* Create an authentication packet */
+static u32
+ieee80211softmac_auth(struct ieee80211_auth **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
+ u16 transaction, u16 status)
+{
+ u8 *data;
+ /* Allocate Packet */
+ (*pkt) = (struct ieee80211_auth *)ieee80211softmac_alloc_mgt(
+ 2 + /* Auth Algorithm */
+ 2 + /* Auth Transaction Seq */
+ 2 + /* Status Code */
+ /* Challenge Text IE */
+ mac->ieee->open_wep ? 0 :
+ 1 + 1 + WLAN_AUTH_CHALLENGE_LEN
+ );
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_AUTH, net->bssid, net->bssid);
+
+ /* Algorithm */
+ (*pkt)->algorithm = mac->ieee->open_wep ?
+ cpu_to_le16(WLAN_AUTH_OPEN) :
+ cpu_to_le16(WLAN_AUTH_SHARED_KEY);
+ /* Transaction */
+ (*pkt)->transaction = cpu_to_le16(transaction);
+ /* Status */
+ (*pkt)->status = cpu_to_le16(status);
+
+ data = (u8 *)(*pkt)->info_element;
+ /* Challenge Text */
+ if(!mac->ieee->open_wep){
+ *data = MFIE_TYPE_CHALLENGE;
+ data++;
+
+ /* Copy the challenge in */
+ // *data = challenge length
+ // data += sizeof(u16);
+ // memcpy(data, challenge, challenge length);
+ // data += challenge length;
+
+ /* Add the full size to the packet length */
+ }
+
+ /* Return the packet size */
+ return (data - (u8 *)(*pkt));
+}
+
+/* Create a disassocation or deauthentication packet */
+static u32
+ieee80211softmac_disassoc_deauth(struct ieee80211_disassoc **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
+ u16 type, u16 reason)
+{
+ /* Allocate Packet */
+ (*pkt) = (struct ieee80211_disassoc *)ieee80211softmac_alloc_mgt(2);
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), type, net->bssid, net->bssid);
+ /* Reason */
+ (*pkt)->reason = cpu_to_le16(reason);
+ /* Return the packet size */
+ return (2 + IEEE80211_3ADDR_LEN);
+}
+
+/* Create a probe request packet */
+static u32
+ieee80211softmac_probe_req(struct ieee80211_probe_request **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_essid *essid)
+{
+ u8 *data;
+ /* Allocate Packet */
+ (*pkt) = (struct ieee80211_probe_request *)ieee80211softmac_alloc_mgt(
+ /* SSID of requested network */
+ 1 + 1 + IW_ESSID_MAX_SIZE +
+ /* Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_RATES_LEN +
+ /* Extended Rates IE */
+ 1 + 1 + IEEE80211SOFTMAC_MAX_EX_RATES_LEN
+ );
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_REQ, NULL, NULL);
+
+ data = (u8 *)(*pkt)->info_element;
+ /* Add ESSID (can be NULL) */
+ data = ieee80211softmac_add_essid(data, essid);
+ /* Add Rates */
+ data = ieee80211softmac_frame_add_rates(data, &mac->ratesinfo);
+ /* Return packet size */
+ return (data - (u8 *)(*pkt));
+}
+
+/* Create a probe response packet */
+/* FIXME: Not complete */
+static u32
+ieee80211softmac_probe_resp(struct ieee80211_probe_response **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net)
+{
+ u8 *data;
+ /* Allocate Packet */
+ (*pkt) = (struct ieee80211_probe_response *)ieee80211softmac_alloc_mgt(
+ 8 + /* Timestamp */
+ 2 + /* Beacon Interval */
+ 2 + /* Capability Info */
+ /* SSID IE */
+ 1 + 1 + IW_ESSID_MAX_SIZE +
+ 7 + /* FH Parameter Set */
+ 2 + /* DS Parameter Set */
+ 8 + /* CF Parameter Set */
+ 4 /* IBSS Parameter Set */
+ );
+ if (unlikely((*pkt) == NULL))
+ return 0;
+ ieee80211softmac_hdr_3addr(mac, &((*pkt)->header), IEEE80211_STYPE_PROBE_RESP, net->bssid, net->bssid);
+ data = (u8 *)(*pkt)->info_element;
+
+ /* Return the packet size */
+ return (data - (u8 *)(*pkt));
+}
+
+
+/* Sends a manangement packet
+ * FIXME: document the use of the arg parameter
+ * for _AUTH: (transaction #) | (status << 16)
+ */
+int
+ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
+ void *ptrarg, u32 type, u32 arg)
+{
+ void *pkt = NULL;
+ u32 pkt_size = 0;
+
+ switch(type) {
+ case IEEE80211_STYPE_ASSOC_REQ:
+ pkt_size = ieee80211softmac_assoc_req((struct ieee80211_assoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
+ break;
+ case IEEE80211_STYPE_REASSOC_REQ:
+ pkt_size = ieee80211softmac_reassoc_req((struct ieee80211_reassoc_request **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
+ break;
+ case IEEE80211_STYPE_AUTH:
+ pkt_size = ieee80211softmac_auth((struct ieee80211_auth **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, (u16)(arg & 0xFFFF), (u16) (arg >> 16));
+ break;
+ case IEEE80211_STYPE_DISASSOC:
+ case IEEE80211_STYPE_DEAUTH:
+ pkt_size = ieee80211softmac_disassoc_deauth((struct ieee80211_disassoc **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg, type, (u16)(arg & 0xFFFF));
+ break;
+ case IEEE80211_STYPE_PROBE_REQ:
+ pkt_size = ieee80211softmac_probe_req((struct ieee80211_probe_request **)(&pkt), mac, (struct ieee80211softmac_essid *)ptrarg);
+ break;
+ case IEEE80211_STYPE_PROBE_RESP:
+ pkt_size = ieee80211softmac_probe_resp((struct ieee80211_probe_response **)(&pkt), mac, (struct ieee80211softmac_network *)ptrarg);
+ break;
+ default:
+ printkl(KERN_DEBUG PFX "Unsupported Management Frame type: %i\n", type);
+ return -EINVAL;
+ };
+
+ if(pkt_size == 0 || pkt == NULL) {
+ printkl(KERN_DEBUG PFX "Error, packet is nonexistant or 0 length\n");
+ return -ENOMEM;
+ }
+
+ /* Send the packet to the ieee80211 layer for tx */
+ /* we defined softmac->mgmt_xmit for this. Should we keep it
+ * as it is (that means we'd need to wrap this into a txb),
+ * modify the prototype (so it matches this function),
+ * or get rid of it alltogether?
+ * Does this work for you now?
+ */
+ ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *)pkt, pkt_size);
+
+ kfree(pkt);
+ return 0;
+}
+
+
+/* Create an rts/cts frame */
+static u32
+ieee80211softmac_rts_cts(struct ieee80211_hdr_2addr **pkt,
+ struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net,
+ u32 type)
+{
+ /* Allocate Packet */
+ (*pkt) = kmalloc(IEEE80211_2ADDR_LEN, GFP_ATOMIC);
+ memset(*pkt, 0, IEEE80211_2ADDR_LEN);
+ if((*pkt) == NULL)
+ return 0;
+ ieee80211softmac_hdr_2addr(mac, (*pkt), type, net->bssid);
+ return IEEE80211_2ADDR_LEN;
+}
+
+
+/* Sends a control packet */
+static int
+ieee80211softmac_send_ctl_frame(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net, u32 type, u32 arg)
+{
+ void *pkt = NULL;
+ u32 pkt_size = 0;
+
+ switch(type) {
+ case IEEE80211_STYPE_RTS:
+ case IEEE80211_STYPE_CTS:
+ pkt_size = ieee80211softmac_rts_cts((struct ieee80211_hdr_2addr **)(&pkt), mac, net, type);
+ break;
+ default:
+ printkl(KERN_DEBUG PFX "Unsupported Control Frame type: %i\n", type);
+ return -EINVAL;
+ }
+
+ if(pkt_size == 0)
+ return -ENOMEM;
+
+ /* Send the packet to the ieee80211 layer for tx */
+ ieee80211_tx_frame(mac->ieee, (struct ieee80211_hdr *) pkt, pkt_size);
+
+ kfree(pkt);
+ return 0;
+}
diff --git a/net/ieee80211/softmac/ieee80211softmac_module.c b/net/ieee80211/softmac/ieee80211softmac_module.c
new file mode 100644
index 00000000000..6f99f781bff
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_module.c
@@ -0,0 +1,457 @@
+/*
+ * Contains some basic softmac functions along with module registration code etc.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include "ieee80211softmac_priv.h"
+#include <linux/sort.h>
+
+struct net_device *alloc_ieee80211softmac(int sizeof_priv)
+{
+ struct ieee80211softmac_device *softmac;
+ struct net_device *dev;
+
+ dev = alloc_ieee80211(sizeof(struct ieee80211softmac_device) + sizeof_priv);
+ softmac = ieee80211_priv(dev);
+ softmac->dev = dev;
+ softmac->ieee = netdev_priv(dev);
+ spin_lock_init(&softmac->lock);
+
+ softmac->ieee->handle_auth = ieee80211softmac_auth_resp;
+ softmac->ieee->handle_deauth = ieee80211softmac_deauth_resp;
+ softmac->ieee->handle_assoc_response = ieee80211softmac_handle_assoc_response;
+ softmac->ieee->handle_reassoc_request = ieee80211softmac_handle_reassoc_req;
+ softmac->ieee->handle_disassoc = ieee80211softmac_handle_disassoc;
+ softmac->scaninfo = NULL;
+
+ /* TODO: initialise all the other callbacks in the ieee struct
+ * (once they're written)
+ */
+
+ INIT_LIST_HEAD(&softmac->auth_queue);
+ INIT_LIST_HEAD(&softmac->network_list);
+ INIT_LIST_HEAD(&softmac->events);
+
+ INIT_WORK(&softmac->associnfo.work, ieee80211softmac_assoc_work, softmac);
+ INIT_WORK(&softmac->associnfo.timeout, ieee80211softmac_assoc_timeout, softmac);
+ softmac->start_scan = ieee80211softmac_start_scan_implementation;
+ softmac->wait_for_scan = ieee80211softmac_wait_for_scan_implementation;
+ softmac->stop_scan = ieee80211softmac_stop_scan_implementation;
+
+ //TODO: The mcast rate has to be assigned dynamically somewhere (in scanning, association. Not sure...)
+ // It has to be set to the highest rate all stations in the current network can handle.
+ softmac->txrates.mcast_rate = IEEE80211_CCK_RATE_1MB;
+ softmac->txrates.mcast_fallback = IEEE80211_CCK_RATE_1MB;
+ /* This is reassigned in ieee80211softmac_start to sane values. */
+ softmac->txrates.default_rate = IEEE80211_CCK_RATE_1MB;
+ softmac->txrates.default_fallback = IEEE80211_CCK_RATE_1MB;
+
+ /* to start with, we can't send anything ... */
+ netif_carrier_off(dev);
+
+ return dev;
+}
+EXPORT_SYMBOL_GPL(alloc_ieee80211softmac);
+
+/* Clears the pending work queue items, stops all scans, etc. */
+void
+ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm)
+{
+ unsigned long flags;
+ struct ieee80211softmac_event *eventptr, *eventtmp;
+ struct ieee80211softmac_auth_queue_item *authptr, *authtmp;
+ struct ieee80211softmac_network *netptr, *nettmp;
+
+ ieee80211softmac_stop_scan(sm);
+ ieee80211softmac_wait_for_scan(sm);
+
+ spin_lock_irqsave(&sm->lock, flags);
+ /* Free all pending assoc work items */
+ cancel_delayed_work(&sm->associnfo.work);
+
+ /* Free all pending scan work items */
+ if(sm->scaninfo != NULL)
+ cancel_delayed_work(&sm->scaninfo->softmac_scan);
+
+ /* Free all pending auth work items */
+ list_for_each_entry(authptr, &sm->auth_queue, list)
+ cancel_delayed_work(&authptr->work);
+
+ /* delete all pending event calls and work items */
+ list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list)
+ cancel_delayed_work(&eventptr->work);
+
+ spin_unlock_irqrestore(&sm->lock, flags);
+ flush_scheduled_work();
+
+ /* now we should be save and no longer need locking... */
+ spin_lock_irqsave(&sm->lock, flags);
+ /* Free all pending auth work items */
+ list_for_each_entry_safe(authptr, authtmp, &sm->auth_queue, list) {
+ list_del(&authptr->list);
+ kfree(authptr);
+ }
+
+ /* delete all pending event calls and work items */
+ list_for_each_entry_safe(eventptr, eventtmp, &sm->events, list) {
+ list_del(&eventptr->list);
+ kfree(eventptr);
+ }
+
+ /* Free all networks */
+ list_for_each_entry_safe(netptr, nettmp, &sm->network_list, list) {
+ ieee80211softmac_del_network_locked(sm, netptr);
+ if(netptr->challenge != NULL)
+ kfree(netptr->challenge);
+ kfree(netptr);
+ }
+
+ spin_unlock_irqrestore(&sm->lock, flags);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_clear_pending_work);
+
+void free_ieee80211softmac(struct net_device *dev)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(dev);
+ ieee80211softmac_clear_pending_work(sm);
+ kfree(sm->scaninfo);
+ kfree(sm->wpa.IE);
+ free_ieee80211(dev);
+}
+EXPORT_SYMBOL_GPL(free_ieee80211softmac);
+
+static void ieee80211softmac_start_check_rates(struct ieee80211softmac_device *mac)
+{
+ struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
+ /* I took out the sorting check, we're seperating by modulation now. */
+ if (ri->count)
+ return;
+ /* otherwise assume we hav'em all! */
+ if (mac->ieee->modulation & IEEE80211_CCK_MODULATION) {
+ ri->rates[ri->count++] = IEEE80211_CCK_RATE_1MB;
+ ri->rates[ri->count++] = IEEE80211_CCK_RATE_2MB;
+ ri->rates[ri->count++] = IEEE80211_CCK_RATE_5MB;
+ ri->rates[ri->count++] = IEEE80211_CCK_RATE_11MB;
+ }
+ if (mac->ieee->modulation & IEEE80211_OFDM_MODULATION) {
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_6MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_9MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_12MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_18MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_24MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_36MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_48MB;
+ ri->rates[ri->count++] = IEEE80211_OFDM_RATE_54MB;
+ }
+}
+
+void ieee80211softmac_start(struct net_device *dev)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ struct ieee80211_device *ieee = mac->ieee;
+ u32 change = 0;
+ struct ieee80211softmac_txrates oldrates;
+
+ ieee80211softmac_start_check_rates(mac);
+
+ /* TODO: We need some kind of state machine to lower the default rates
+ * if we loose too many packets.
+ */
+ /* Change the default txrate to the highest possible value.
+ * The txrate machine will lower it, if it is too high.
+ */
+ if (mac->txrates_change)
+ oldrates = mac->txrates;
+ if (ieee->modulation & IEEE80211_OFDM_MODULATION) {
+ mac->txrates.default_rate = IEEE80211_OFDM_RATE_54MB;
+ change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
+ mac->txrates.default_fallback = IEEE80211_OFDM_RATE_24MB;
+ change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
+ } else if (ieee->modulation & IEEE80211_CCK_MODULATION) {
+ mac->txrates.default_rate = IEEE80211_CCK_RATE_11MB;
+ change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
+ mac->txrates.default_fallback = IEEE80211_CCK_RATE_5MB;
+ change |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
+ } else
+ assert(0);
+ if (mac->txrates_change)
+ mac->txrates_change(dev, change, &oldrates);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_start);
+
+void ieee80211softmac_stop(struct net_device *dev)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+
+ ieee80211softmac_clear_pending_work(mac);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_stop);
+
+void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ memcpy(mac->ratesinfo.rates, rates, count);
+ mac->ratesinfo.count = count;
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_set_rates);
+
+static u8 raise_rate(struct ieee80211softmac_device *mac, u8 rate)
+{
+ int i;
+ struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
+
+ for (i=0; i<ri->count-1; i++) {
+ if (ri->rates[i] == rate)
+ return ri->rates[i+1];
+ }
+ /* I guess we can't go any higher... */
+ return ri->rates[ri->count];
+}
+
+u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta)
+{
+ int i;
+ struct ieee80211softmac_ratesinfo *ri = &mac->ratesinfo;
+
+ for (i=delta; i<ri->count; i++) {
+ if (ri->rates[i] == rate)
+ return ri->rates[i-delta];
+ }
+ /* I guess we can't go any lower... */
+ return ri->rates[0];
+}
+
+static void ieee80211softmac_add_txrates_badness(struct ieee80211softmac_device *mac,
+ int amount)
+{
+ struct ieee80211softmac_txrates oldrates;
+ u8 default_rate = mac->txrates.default_rate;
+ u8 default_fallback = mac->txrates.default_fallback;
+ u32 changes = 0;
+
+ //TODO: This is highly experimental code.
+ // Maybe the dynamic rate selection does not work
+ // and it has to be removed again.
+
+printk("badness %d\n", mac->txrate_badness);
+ mac->txrate_badness += amount;
+ if (mac->txrate_badness <= -1000) {
+ /* Very small badness. Try a faster bitrate. */
+ if (mac->txrates_change)
+ memcpy(&oldrates, &mac->txrates, sizeof(oldrates));
+ default_rate = raise_rate(mac, default_rate);
+ changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
+ default_fallback = get_fallback_rate(mac, default_rate);
+ changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
+ mac->txrate_badness = 0;
+printk("Bitrate raised to %u\n", default_rate);
+ } else if (mac->txrate_badness >= 10000) {
+ /* Very high badness. Try a slower bitrate. */
+ if (mac->txrates_change)
+ memcpy(&oldrates, &mac->txrates, sizeof(oldrates));
+ default_rate = lower_rate(mac, default_rate);
+ changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT;
+ default_fallback = get_fallback_rate(mac, default_rate);
+ changes |= IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK;
+ mac->txrate_badness = 0;
+printk("Bitrate lowered to %u\n", default_rate);
+ }
+
+ mac->txrates.default_rate = default_rate;
+ mac->txrates.default_fallback = default_fallback;
+
+ if (changes && mac->txrates_change)
+ mac->txrates_change(mac->dev, changes, &oldrates);
+}
+
+void ieee80211softmac_fragment_lost(struct net_device *dev,
+ u16 wl_seq)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ ieee80211softmac_add_txrates_badness(mac, 1000);
+ //TODO
+
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_fragment_lost);
+
+static int rate_cmp(const void *a_, const void *b_) {
+ u8 *a, *b;
+ a = (u8*)a_;
+ b = (u8*)b_;
+ return ((*a & ~IEEE80211_BASIC_RATE_MASK) - (*b & ~IEEE80211_BASIC_RATE_MASK));
+}
+
+/* Allocate a softmac network struct and fill it from a network */
+struct ieee80211softmac_network *
+ieee80211softmac_create_network(struct ieee80211softmac_device *mac,
+ struct ieee80211_network *net)
+{
+ struct ieee80211softmac_network *softnet;
+ softnet = kzalloc(sizeof(struct ieee80211softmac_network), GFP_ATOMIC);
+ if(softnet == NULL)
+ return NULL;
+ memcpy(softnet->bssid, net->bssid, ETH_ALEN);
+ softnet->channel = net->channel;
+ softnet->essid.len = net->ssid_len;
+ memcpy(softnet->essid.data, net->ssid, softnet->essid.len);
+
+ /* copy rates over */
+ softnet->supported_rates.count = net->rates_len;
+ memcpy(&softnet->supported_rates.rates[0], net->rates, net->rates_len);
+ memcpy(&softnet->supported_rates.rates[softnet->supported_rates.count], net->rates_ex, net->rates_ex_len);
+ softnet->supported_rates.count += net->rates_ex_len;
+ sort(softnet->supported_rates.rates, softnet->supported_rates.count, sizeof(softnet->supported_rates.rates[0]), rate_cmp, NULL);
+
+ softnet->capabilities = net->capability;
+ return softnet;
+}
+
+
+/* Add a network to the list, while locked */
+void
+ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *add_net)
+{
+ struct list_head *list_ptr;
+ struct ieee80211softmac_network *softmac_net = NULL;
+
+ list_for_each(list_ptr, &mac->network_list) {
+ softmac_net = list_entry(list_ptr, struct ieee80211softmac_network, list);
+ if(!memcmp(softmac_net->bssid, add_net->bssid, ETH_ALEN))
+ break;
+ else
+ softmac_net = NULL;
+ }
+ if(softmac_net == NULL)
+ list_add(&(add_net->list), &mac->network_list);
+}
+
+/* Add a network to the list, with locking */
+void
+ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *add_net)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&mac->lock, flags);
+ ieee80211softmac_add_network_locked(mac, add_net);
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+
+
+/* Delete a network from the list, while locked*/
+void
+ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *del_net)
+{
+ list_del(&(del_net->list));
+}
+
+/* Delete a network from the list with locking */
+void
+ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *del_net)
+{
+ unsigned long flags;
+ spin_lock_irqsave(&mac->lock, flags);
+ ieee80211softmac_del_network_locked(mac, del_net);
+ spin_unlock_irqrestore(&mac->lock, flags);
+}
+
+/* Get a network from the list by MAC while locked */
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_bssid_locked(struct ieee80211softmac_device *mac,
+ u8 *bssid)
+{
+ struct list_head *list_ptr;
+ struct ieee80211softmac_network *softmac_net = NULL;
+ list_for_each(list_ptr, &mac->network_list) {
+ softmac_net = list_entry(list_ptr, struct ieee80211softmac_network, list);
+ if(!memcmp(softmac_net->bssid, bssid, ETH_ALEN))
+ break;
+ else
+ softmac_net = NULL;
+ }
+ return softmac_net;
+}
+
+/* Get a network from the list by BSSID with locking */
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_bssid(struct ieee80211softmac_device *mac,
+ u8 *bssid)
+{
+ unsigned long flags;
+ struct ieee80211softmac_network *softmac_net;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ softmac_net = ieee80211softmac_get_network_by_bssid_locked(mac, bssid);
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return softmac_net;
+}
+
+/* Get a network from the list by ESSID while locked */
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_essid *essid)
+{
+ struct list_head *list_ptr;
+ struct ieee80211softmac_network *softmac_net = NULL;
+
+ list_for_each(list_ptr, &mac->network_list) {
+ softmac_net = list_entry(list_ptr, struct ieee80211softmac_network, list);
+ if (softmac_net->essid.len == essid->len &&
+ !memcmp(softmac_net->essid.data, essid->data, essid->len))
+ return softmac_net;
+ }
+ return NULL;
+}
+
+/* Get a network from the list by ESSID with locking */
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_essid *essid)
+{
+ unsigned long flags;
+ struct ieee80211softmac_network *softmac_net = NULL;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ softmac_net = ieee80211softmac_get_network_by_essid_locked(mac, essid);
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return softmac_net;
+}
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Johannes Berg");
+MODULE_AUTHOR("Joseph Jezak");
+MODULE_AUTHOR("Larry Finger");
+MODULE_AUTHOR("Danny van Dyk");
+MODULE_AUTHOR("Michael Buesch");
+MODULE_DESCRIPTION("802.11 software MAC");
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h
new file mode 100644
index 00000000000..9ba7dbd161e
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_priv.h
@@ -0,0 +1,230 @@
+/*
+ * Internal softmac API definitions.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#ifndef IEEE80211SOFTMAC_PRIV_H_
+#define IEEE80211SOFTMAC_PRIV_H_
+
+#include <net/ieee80211softmac.h>
+#include <net/ieee80211softmac_wx.h>
+#include <linux/kernel.h>
+#include <linux/stringify.h>
+
+
+#define PFX "SoftMAC: "
+
+#ifdef assert
+# undef assert
+#endif
+#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
+#define assert(expr) \
+ do { \
+ if (unlikely(!(expr))) { \
+ printkl(KERN_ERR PFX "ASSERTION FAILED (%s) at: %s:%d:%s()\n", #expr, \
+ __FILE__, __LINE__, __FUNCTION__); \
+ } \
+ } while (0)
+#else
+#define assert(expr) do {} while (0)
+#endif
+
+/* rate limited printk(). */
+#ifdef printkl
+# undef printkl
+#endif
+#define printkl(f, x...) do { if (printk_ratelimit()) printk(f ,##x); } while (0)
+/* rate limited printk() for debugging */
+#ifdef dprintkl
+# undef dprintkl
+#endif
+#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
+# define dprintkl printkl
+#else
+# define dprintkl(f, x...) do { /* nothing */ } while (0)
+#endif
+
+/* debugging printk() */
+#ifdef dprintk
+# undef dprintk
+#endif
+#ifdef CONFIG_IEEE80211_SOFTMAC_DEBUG
+# define dprintk(f, x...) do { printk(f ,##x); } while (0)
+#else
+# define dprintk(f, x...) do { /* nothing */ } while (0)
+#endif
+
+/* private definitions and prototypes */
+
+/*** prototypes from _scan.c */
+void ieee80211softmac_scan(void *sm);
+/* for internal use if scanning is needed */
+int ieee80211softmac_start_scan(struct ieee80211softmac_device *mac);
+void ieee80211softmac_stop_scan(struct ieee80211softmac_device *mac);
+void ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *mac);
+
+/* for use by _module.c to assign to the callbacks */
+int ieee80211softmac_start_scan_implementation(struct net_device *dev);
+void ieee80211softmac_stop_scan_implementation(struct net_device *dev);
+void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev);
+
+/*** Network prototypes from _module.c */
+struct ieee80211softmac_network * ieee80211softmac_create_network(
+ struct ieee80211softmac_device *mac, struct ieee80211_network *net);
+void ieee80211softmac_add_network_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net);
+void ieee80211softmac_add_network(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net);
+void ieee80211softmac_del_network_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net);
+void ieee80211softmac_del_network(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_network *net);
+struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid_locked(
+ struct ieee80211softmac_device *mac, u8 *ea);
+struct ieee80211softmac_network * ieee80211softmac_get_network_by_bssid(
+ struct ieee80211softmac_device *mac, u8 *ea);
+struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid_locked(
+ struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
+struct ieee80211softmac_network * ieee80211softmac_get_network_by_ssid(
+ struct ieee80211softmac_device *mac, u8 *ssid, u8 ssid_len);
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_essid_locked(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_essid *essid);
+struct ieee80211softmac_network *
+ieee80211softmac_get_network_by_essid(struct ieee80211softmac_device *mac,
+ struct ieee80211softmac_essid *essid);
+
+/* Rates related */
+u8 ieee80211softmac_lower_rate_delta(struct ieee80211softmac_device *mac, u8 rate, int delta);
+static inline u8 lower_rate(struct ieee80211softmac_device *mac, u8 rate) {
+ return ieee80211softmac_lower_rate_delta(mac, rate, 1);
+}
+
+static inline u8 get_fallback_rate(struct ieee80211softmac_device *mac, u8 rate)
+{
+ return ieee80211softmac_lower_rate_delta(mac, rate, 2);
+}
+
+
+/*** prototypes from _io.c */
+int ieee80211softmac_send_mgt_frame(struct ieee80211softmac_device *mac,
+ void* ptrarg, u32 type, u32 arg);
+
+/*** prototypes from _auth.c */
+/* do these have to go into the public header? */
+int ieee80211softmac_auth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net);
+int ieee80211softmac_deauth_req(struct ieee80211softmac_device *mac, struct ieee80211softmac_network *net, int reason);
+
+/* for use by _module.c to assign to the callbacks */
+int ieee80211softmac_auth_resp(struct net_device *dev, struct ieee80211_auth *auth);
+int ieee80211softmac_deauth_resp(struct net_device *dev, struct ieee80211_deauth *deauth);
+
+/*** prototypes from _assoc.c */
+void ieee80211softmac_assoc_work(void *d);
+int ieee80211softmac_handle_assoc_response(struct net_device * dev,
+ struct ieee80211_assoc_response * resp,
+ struct ieee80211_network * network);
+int ieee80211softmac_handle_disassoc(struct net_device * dev,
+ struct ieee80211_disassoc * disassoc);
+int ieee80211softmac_handle_reassoc_req(struct net_device * dev,
+ struct ieee80211_reassoc_request * reassoc);
+void ieee80211softmac_assoc_timeout(void *d);
+
+/* some helper functions */
+static inline int ieee80211softmac_scan_handlers_check_self(struct ieee80211softmac_device *sm)
+{
+ return (sm->start_scan == ieee80211softmac_start_scan_implementation) &&
+ (sm->stop_scan == ieee80211softmac_stop_scan_implementation) &&
+ (sm->wait_for_scan == ieee80211softmac_wait_for_scan_implementation);
+}
+
+static inline int ieee80211softmac_scan_sanity_check(struct ieee80211softmac_device *sm)
+{
+ return ((sm->start_scan != ieee80211softmac_start_scan_implementation) &&
+ (sm->stop_scan != ieee80211softmac_stop_scan_implementation) &&
+ (sm->wait_for_scan != ieee80211softmac_wait_for_scan_implementation)
+ ) || ieee80211softmac_scan_handlers_check_self(sm);
+}
+
+#define IEEE80211SOFTMAC_PROBE_DELAY HZ/2
+#define IEEE80211SOFTMAC_WORKQUEUE_NAME_LEN (17 + IFNAMSIZ)
+
+struct ieee80211softmac_network {
+ struct list_head list; /* List */
+ /* Network information copied from ieee80211_network */
+ u8 bssid[ETH_ALEN];
+ u8 channel;
+ struct ieee80211softmac_essid essid;
+
+ struct ieee80211softmac_ratesinfo supported_rates;
+
+ /* SoftMAC specific */
+ u16 authenticating:1, /* Status Flags */
+ authenticated:1,
+ auth_desynced_once:1;
+
+ u16 capabilities; /* Capabilities bitfield */
+ u8 challenge_len; /* Auth Challenge length */
+ char *challenge; /* Challenge Text */
+};
+
+/* structure used to keep track of networks we're auth'ing to */
+struct ieee80211softmac_auth_queue_item {
+ struct list_head list; /* List head */
+ struct ieee80211softmac_network *net; /* Network to auth */
+ struct ieee80211softmac_device *mac; /* SoftMAC device */
+ u8 retry; /* Retry limit */
+ u8 state; /* Auth State */
+ struct work_struct work; /* Work queue */
+};
+
+/* scanning information */
+struct ieee80211softmac_scaninfo {
+ u8 current_channel_idx,
+ number_channels;
+ struct ieee80211_channel *channels;
+ u8 started:1,
+ stop:1;
+ u8 skip_flags;
+ struct completion finished;
+ struct work_struct softmac_scan;
+};
+
+/* private event struct */
+struct ieee80211softmac_event {
+ struct list_head list;
+ int event_type;
+ void *event_context;
+ struct work_struct work;
+ notify_function_ptr fun;
+ void *context;
+ struct ieee80211softmac_device *mac;
+};
+
+void ieee80211softmac_call_events(struct ieee80211softmac_device *mac, int event, void *event_context);
+void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int event, void *event_context);
+int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac,
+ int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask);
+
+#endif /* IEEE80211SOFTMAC_PRIV_H_ */
diff --git a/net/ieee80211/softmac/ieee80211softmac_scan.c b/net/ieee80211/softmac/ieee80211softmac_scan.c
new file mode 100644
index 00000000000..bb9ab8b45d0
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_scan.c
@@ -0,0 +1,244 @@
+/*
+ * Scanning routines.
+ *
+ * These are not exported because they're assigned to the function pointers.
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include <linux/completion.h>
+#include "ieee80211softmac_priv.h"
+
+/* internal, use to trigger scanning if needed.
+ * Returns -EBUSY if already scanning,
+ * result of start_scan otherwise */
+int
+ieee80211softmac_start_scan(struct ieee80211softmac_device *sm)
+{
+ unsigned long flags;
+ int ret;
+
+ spin_lock_irqsave(&sm->lock, flags);
+ if (sm->scanning)
+ {
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return -EINPROGRESS;
+ }
+ sm->scanning = 1;
+ spin_unlock_irqrestore(&sm->lock, flags);
+
+ ret = sm->start_scan(sm->dev);
+ if (ret) {
+ spin_lock_irqsave(&sm->lock, flags);
+ sm->scanning = 0;
+ spin_unlock_irqrestore(&sm->lock, flags);
+ }
+ return ret;
+}
+
+void
+ieee80211softmac_stop_scan(struct ieee80211softmac_device *sm)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&sm->lock, flags);
+
+ if (!sm->scanning) {
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return;
+ }
+
+ spin_unlock_irqrestore(&sm->lock, flags);
+ sm->stop_scan(sm->dev);
+}
+
+void
+ieee80211softmac_wait_for_scan(struct ieee80211softmac_device *sm)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&sm->lock, flags);
+
+ if (!sm->scanning) {
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return;
+ }
+
+ spin_unlock_irqrestore(&sm->lock, flags);
+ sm->wait_for_scan(sm->dev);
+}
+
+
+/* internal scanning implementation follows */
+void ieee80211softmac_scan(void *d)
+{
+ int invalid_channel;
+ u8 current_channel_idx;
+ struct ieee80211softmac_device *sm = (struct ieee80211softmac_device *)d;
+ struct ieee80211softmac_scaninfo *si = sm->scaninfo;
+ unsigned long flags;
+
+ while (!(si->stop) && (si->current_channel_idx < si->number_channels)) {
+ current_channel_idx = si->current_channel_idx;
+ si->current_channel_idx++; /* go to the next channel */
+
+ invalid_channel = (si->skip_flags & si->channels[current_channel_idx].flags);
+
+ if (!invalid_channel) {
+ sm->set_channel(sm->dev, si->channels[current_channel_idx].channel);
+ // FIXME make this user configurable (active/passive)
+ if(ieee80211softmac_send_mgt_frame(sm, NULL, IEEE80211_STYPE_PROBE_REQ, 0))
+ printkl(KERN_DEBUG PFX "Sending Probe Request Failed\n");
+
+ /* also send directed management frame for the network we're looking for */
+ // TODO: is this if correct, or should we do this only if scanning from assoc request?
+ if (sm->associnfo.req_essid.len)
+ ieee80211softmac_send_mgt_frame(sm, &sm->associnfo.req_essid, IEEE80211_STYPE_PROBE_REQ, 0);
+ schedule_delayed_work(&si->softmac_scan, IEEE80211SOFTMAC_PROBE_DELAY);
+ return;
+ } else {
+ dprintk(PFX "Not probing Channel %d (not allowed here)\n", si->channels[current_channel_idx].channel);
+ }
+ }
+
+ spin_lock_irqsave(&sm->lock, flags);
+ cancel_delayed_work(&si->softmac_scan);
+ si->started = 0;
+ spin_unlock_irqrestore(&sm->lock, flags);
+
+ dprintk(PFX "Scanning finished\n");
+ ieee80211softmac_scan_finished(sm);
+ complete_all(&sm->scaninfo->finished);
+}
+
+static inline struct ieee80211softmac_scaninfo *allocate_scaninfo(struct ieee80211softmac_device *mac)
+{
+ /* ugh. can we call this without having the spinlock held? */
+ struct ieee80211softmac_scaninfo *info = kmalloc(sizeof(struct ieee80211softmac_scaninfo), GFP_ATOMIC);
+ if (unlikely(!info))
+ return NULL;
+ INIT_WORK(&info->softmac_scan, ieee80211softmac_scan, mac);
+ init_completion(&info->finished);
+ return info;
+}
+
+int ieee80211softmac_start_scan_implementation(struct net_device *dev)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(dev);
+ unsigned long flags;
+
+ if (!(dev->flags & IFF_UP))
+ return -ENODEV;
+
+ assert(ieee80211softmac_scan_handlers_check_self(sm));
+ if (!ieee80211softmac_scan_handlers_check_self(sm))
+ return -EINVAL;
+
+ spin_lock_irqsave(&sm->lock, flags);
+ /* it looks like we need to hold the lock here
+ * to make sure we don't allocate two of these... */
+ if (unlikely(!sm->scaninfo))
+ sm->scaninfo = allocate_scaninfo(sm);
+ if (unlikely(!sm->scaninfo)) {
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return -ENOMEM;
+ }
+
+ sm->scaninfo->skip_flags = IEEE80211_CH_INVALID;
+ if (0 /* not scanning in IEEE802.11b */)//TODO
+ sm->scaninfo->skip_flags |= IEEE80211_CH_B_ONLY;
+ if (0 /* IEEE802.11a */) {//TODO
+ sm->scaninfo->channels = sm->ieee->geo.a;
+ sm->scaninfo->number_channels = sm->ieee->geo.a_channels;
+ } else {
+ sm->scaninfo->channels = sm->ieee->geo.bg;
+ sm->scaninfo->number_channels = sm->ieee->geo.bg_channels;
+ }
+ dprintk(PFX "Start scanning with channel: %d\n", sm->scaninfo->channels[0].channel);
+ dprintk(PFX "Scanning %d channels\n", sm->scaninfo->number_channels);
+ sm->scaninfo->current_channel_idx = 0;
+ sm->scaninfo->started = 1;
+ sm->scaninfo->stop = 0;
+ INIT_COMPLETION(sm->scaninfo->finished);
+ schedule_work(&sm->scaninfo->softmac_scan);
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return 0;
+}
+
+void ieee80211softmac_stop_scan_implementation(struct net_device *dev)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(dev);
+ unsigned long flags;
+
+ assert(ieee80211softmac_scan_handlers_check_self(sm));
+ if (!ieee80211softmac_scan_handlers_check_self(sm))
+ return;
+
+ spin_lock_irqsave(&sm->lock, flags);
+ assert(sm->scaninfo != NULL);
+ if (sm->scaninfo) {
+ if (sm->scaninfo->started)
+ sm->scaninfo->stop = 1;
+ else
+ complete_all(&sm->scaninfo->finished);
+ }
+ spin_unlock_irqrestore(&sm->lock, flags);
+}
+
+void ieee80211softmac_wait_for_scan_implementation(struct net_device *dev)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(dev);
+ unsigned long flags;
+
+ assert(ieee80211softmac_scan_handlers_check_self(sm));
+ if (!ieee80211softmac_scan_handlers_check_self(sm))
+ return;
+
+ spin_lock_irqsave(&sm->lock, flags);
+ if (!sm->scaninfo->started) {
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return;
+ }
+ spin_unlock_irqrestore(&sm->lock, flags);
+ wait_for_completion(&sm->scaninfo->finished);
+}
+
+/* this is what drivers (that do scanning) call when they're done */
+void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&sm->lock, flags);
+ sm->scanning = 0;
+ spin_unlock_irqrestore(&sm->lock, flags);
+
+ if (sm->associnfo.bssvalid) {
+ struct ieee80211softmac_network *net;
+
+ net = ieee80211softmac_get_network_by_bssid(sm, sm->associnfo.bssid);
+ if (net)
+ sm->set_channel(sm->dev, net->channel);
+ }
+ ieee80211softmac_call_events(sm, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, NULL);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_scan_finished);
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c
new file mode 100644
index 00000000000..e1a9bc6d36f
--- /dev/null
+++ b/net/ieee80211/softmac/ieee80211softmac_wx.c
@@ -0,0 +1,412 @@
+/*
+ * This file contains our _wx handlers. Make sure you EXPORT_SYMBOL_GPL them
+ *
+ * Copyright (c) 2005, 2006 Johannes Berg <johannes@sipsolutions.net>
+ * Joseph Jezak <josejx@gentoo.org>
+ * Larry Finger <Larry.Finger@lwfinger.net>
+ * Danny van Dyk <kugelfang@gentoo.org>
+ * Michael Buesch <mbuesch@freenet.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * The full GNU General Public License is included in this distribution in the
+ * file called COPYING.
+ */
+
+#include "ieee80211softmac_priv.h"
+
+#include <net/iw_handler.h>
+
+
+int
+ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
+ return ieee80211softmac_start_scan(sm);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_trigger_scan);
+
+
+int
+ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
+ return ieee80211_wx_get_scan(sm->ieee, info, data, extra);
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_scan_results);
+
+int
+ieee80211softmac_wx_set_essid(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
+ int length = 0;
+ unsigned long flags;
+
+ spin_lock_irqsave(&sm->lock, flags);
+
+ sm->associnfo.static_essid = 0;
+
+ if (data->essid.flags && data->essid.length && extra /*required?*/) {
+ length = min(data->essid.length - 1, IW_ESSID_MAX_SIZE);
+ if (length) {
+ memcpy(sm->associnfo.req_essid.data, extra, length);
+ sm->associnfo.static_essid = 1;
+ }
+ }
+ sm->associnfo.scan_retry = IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT;
+
+ /* set our requested ESSID length.
+ * If applicable, we have already copied the data in */
+ sm->associnfo.req_essid.len = length;
+
+ /* queue lower level code to do work (if necessary) */
+ schedule_work(&sm->associnfo.work);
+
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_essid);
+
+int
+ieee80211softmac_wx_get_essid(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *sm = ieee80211_priv(net_dev);
+ unsigned long flags;
+
+ /* avoid getting inconsistent information */
+ spin_lock_irqsave(&sm->lock, flags);
+ /* If all fails, return ANY (empty) */
+ data->essid.length = 0;
+ data->essid.flags = 0; /* active */
+
+ /* If we have a statically configured ESSID then return it */
+ if (sm->associnfo.static_essid) {
+ data->essid.length = sm->associnfo.req_essid.len;
+ data->essid.flags = 1; /* active */
+ memcpy(extra, sm->associnfo.req_essid.data, sm->associnfo.req_essid.len);
+ }
+
+ /* If we're associating/associated, return that */
+ if (sm->associated || sm->associnfo.associating) {
+ data->essid.length = sm->associnfo.associate_essid.len;
+ data->essid.flags = 1; /* active */
+ memcpy(extra, sm->associnfo.associate_essid.data, sm->associnfo.associate_essid.len);
+ }
+ spin_unlock_irqrestore(&sm->lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_essid);
+
+int
+ieee80211softmac_wx_set_rate(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
+ struct ieee80211_device *ieee = mac->ieee;
+ unsigned long flags;
+ s32 in_rate = data->bitrate.value;
+ u8 rate;
+ int is_ofdm = 0;
+ int err = -EINVAL;
+
+ if (in_rate == -1) {
+ /* automatic detect */
+ if (ieee->modulation & IEEE80211_OFDM_MODULATION)
+ in_rate = 54000000;
+ else
+ in_rate = 11000000;
+ }
+
+ switch (in_rate) {
+ case 1000000:
+ rate = IEEE80211_CCK_RATE_1MB;
+ break;
+ case 2000000:
+ rate = IEEE80211_CCK_RATE_2MB;
+ break;
+ case 5500000:
+ rate = IEEE80211_CCK_RATE_5MB;
+ break;
+ case 11000000:
+ rate = IEEE80211_CCK_RATE_11MB;
+ break;
+ case 6000000:
+ rate = IEEE80211_OFDM_RATE_6MB;
+ is_ofdm = 1;
+ break;
+ case 9000000:
+ rate = IEEE80211_OFDM_RATE_9MB;
+ is_ofdm = 1;
+ break;
+ case 12000000:
+ rate = IEEE80211_OFDM_RATE_12MB;
+ is_ofdm = 1;
+ break;
+ case 18000000:
+ rate = IEEE80211_OFDM_RATE_18MB;
+ is_ofdm = 1;
+ break;
+ case 24000000:
+ rate = IEEE80211_OFDM_RATE_24MB;
+ is_ofdm = 1;
+ break;
+ case 36000000:
+ rate = IEEE80211_OFDM_RATE_36MB;
+ is_ofdm = 1;
+ break;
+ case 48000000:
+ rate = IEEE80211_OFDM_RATE_48MB;
+ is_ofdm = 1;
+ break;
+ case 54000000:
+ rate = IEEE80211_OFDM_RATE_54MB;
+ is_ofdm = 1;
+ break;
+ default:
+ goto out;
+ }
+
+ spin_lock_irqsave(&mac->lock, flags);
+
+ /* Check if correct modulation for this PHY. */
+ if (is_ofdm && !(ieee->modulation & IEEE80211_OFDM_MODULATION))
+ goto out_unlock;
+
+ mac->txrates.default_rate = rate;
+ mac->txrates.default_fallback = lower_rate(mac, rate);
+ err = 0;
+
+out_unlock:
+ spin_unlock_irqrestore(&mac->lock, flags);
+out:
+ return err;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_rate);
+
+int
+ieee80211softmac_wx_get_rate(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
+ unsigned long flags;
+ int err = -EINVAL;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ switch (mac->txrates.default_rate) {
+ case IEEE80211_CCK_RATE_1MB:
+ data->bitrate.value = 1000000;
+ break;
+ case IEEE80211_CCK_RATE_2MB:
+ data->bitrate.value = 2000000;
+ break;
+ case IEEE80211_CCK_RATE_5MB:
+ data->bitrate.value = 5500000;
+ break;
+ case IEEE80211_CCK_RATE_11MB:
+ data->bitrate.value = 11000000;
+ break;
+ case IEEE80211_OFDM_RATE_6MB:
+ data->bitrate.value = 6000000;
+ break;
+ case IEEE80211_OFDM_RATE_9MB:
+ data->bitrate.value = 9000000;
+ break;
+ case IEEE80211_OFDM_RATE_12MB:
+ data->bitrate.value = 12000000;
+ break;
+ case IEEE80211_OFDM_RATE_18MB:
+ data->bitrate.value = 18000000;
+ break;
+ case IEEE80211_OFDM_RATE_24MB:
+ data->bitrate.value = 24000000;
+ break;
+ case IEEE80211_OFDM_RATE_36MB:
+ data->bitrate.value = 36000000;
+ break;
+ case IEEE80211_OFDM_RATE_48MB:
+ data->bitrate.value = 48000000;
+ break;
+ case IEEE80211_OFDM_RATE_54MB:
+ data->bitrate.value = 54000000;
+ break;
+ default:
+ assert(0);
+ goto out_unlock;
+ }
+ err = 0;
+out_unlock:
+ spin_unlock_irqrestore(&mac->lock, flags);
+
+ return err;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_rate);
+
+int
+ieee80211softmac_wx_get_wap(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
+ int err = 0;
+ unsigned long flags;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ if (mac->associnfo.bssvalid)
+ memcpy(data->ap_addr.sa_data, mac->associnfo.bssid, ETH_ALEN);
+ else
+ memset(data->ap_addr.sa_data, 0xff, ETH_ALEN);
+ data->ap_addr.sa_family = ARPHRD_ETHER;
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return err;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_wap);
+
+int
+ieee80211softmac_wx_set_wap(struct net_device *net_dev,
+ struct iw_request_info *info,
+ union iwreq_data *data,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(net_dev);
+ static const unsigned char any[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ static const unsigned char off[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+ unsigned long flags;
+
+ /* sanity check */
+ if (data->ap_addr.sa_family != ARPHRD_ETHER) {
+ return -EINVAL;
+ }
+
+ spin_lock_irqsave(&mac->lock, flags);
+ if (!memcmp(any, data->ap_addr.sa_data, ETH_ALEN) ||
+ !memcmp(off, data->ap_addr.sa_data, ETH_ALEN)) {
+ schedule_work(&mac->associnfo.work);
+ goto out;
+ } else {
+ if (!memcmp(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN)) {
+ if (mac->associnfo.associating || mac->associated) {
+ /* bssid unchanged and associated or associating - just return */
+ goto out;
+ }
+ } else {
+ /* copy new value in data->ap_addr.sa_data to bssid */
+ memcpy(mac->associnfo.bssid, data->ap_addr.sa_data, ETH_ALEN);
+ }
+ /* queue associate if new bssid or (old one again and not associated) */
+ schedule_work(&mac->associnfo.work);
+ }
+
+out:
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_wap);
+
+int
+ieee80211softmac_wx_set_genie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ unsigned long flags;
+ int err = 0;
+ char *buf;
+ int i;
+
+ spin_lock_irqsave(&mac->lock, flags);
+ /* bleh. shouldn't be locked for that kmalloc... */
+
+ if (wrqu->data.length) {
+ if ((wrqu->data.length < 2) || (extra[1]+2 != wrqu->data.length)) {
+ /* this is an IE, so the length must be
+ * correct. Is it possible though that
+ * more than one IE is passed in?
+ */
+ err = -EINVAL;
+ goto out;
+ }
+ if (mac->wpa.IEbuflen <= wrqu->data.length) {
+ buf = kmalloc(wrqu->data.length, GFP_ATOMIC);
+ if (!buf) {
+ err = -ENOMEM;
+ goto out;
+ }
+ kfree(mac->wpa.IE);
+ mac->wpa.IE = buf;
+ mac->wpa.IEbuflen = wrqu->data.length;
+ }
+ memcpy(mac->wpa.IE, extra, wrqu->data.length);
+ dprintk(KERN_INFO PFX "generic IE set to ");
+ for (i=0;i<wrqu->data.length;i++)
+ dprintk("%.2x", mac->wpa.IE[i]);
+ dprintk("\n");
+ mac->wpa.IElen = wrqu->data.length;
+ } else {
+ kfree(mac->wpa.IE);
+ mac->wpa.IE = NULL;
+ mac->wpa.IElen = 0;
+ mac->wpa.IEbuflen = 0;
+ }
+
+ out:
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return err;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_set_genie);
+
+int
+ieee80211softmac_wx_get_genie(struct net_device *dev,
+ struct iw_request_info *info,
+ union iwreq_data *wrqu,
+ char *extra)
+{
+ struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+ unsigned long flags;
+ int err = 0;
+ int space = wrqu->data.length;
+
+ spin_lock_irqsave(&mac->lock, flags);
+
+ wrqu->data.length = 0;
+
+ if (mac->wpa.IE && mac->wpa.IElen) {
+ wrqu->data.length = mac->wpa.IElen;
+ if (mac->wpa.IElen <= space)
+ memcpy(extra, mac->wpa.IE, mac->wpa.IElen);
+ else
+ err = -E2BIG;
+ }
+ spin_unlock_irqrestore(&mac->lock, flags);
+ return err;
+}
+EXPORT_SYMBOL_GPL(ieee80211softmac_wx_get_genie);
+
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 768e8f5d7da..ec566f3e66c 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -104,6 +104,8 @@ static struct hlist_head fib_rules;
/* writer func called from netlink -- rtnl_sem hold*/
+static void rtmsg_rule(int, struct fib_rule *);
+
int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
{
struct rtattr **rta = arg;
@@ -131,6 +133,7 @@ int inet_rtm_delrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
hlist_del_rcu(&r->hlist);
r->r_dead = 1;
+ rtmsg_rule(RTM_DELRULE, r);
fib_rule_put(r);
err = 0;
break;
@@ -253,6 +256,7 @@ int inet_rtm_newrule(struct sk_buff *skb, struct nlmsghdr* nlh, void *arg)
else
hlist_add_before_rcu(&new_r->hlist, &r->hlist);
+ rtmsg_rule(RTM_NEWRULE, new_r);
return 0;
}
@@ -382,14 +386,14 @@ static struct notifier_block fib_rules_notifier = {
static __inline__ int inet_fill_rule(struct sk_buff *skb,
struct fib_rule *r,
- struct netlink_callback *cb,
+ u32 pid, u32 seq, int event,
unsigned int flags)
{
struct rtmsg *rtm;
struct nlmsghdr *nlh;
unsigned char *b = skb->tail;
- nlh = NLMSG_NEW_ANSWER(skb, cb, RTM_NEWRULE, sizeof(*rtm), flags);
+ nlh = NLMSG_NEW(skb, pid, seq, event, sizeof(*rtm), flags);
rtm = NLMSG_DATA(nlh);
rtm->rtm_family = AF_INET;
rtm->rtm_dst_len = r->r_dst_len;
@@ -430,6 +434,21 @@ rtattr_failure:
/* callers should hold rtnl semaphore */
+static void rtmsg_rule(int event, struct fib_rule *r)
+{
+ int size = NLMSG_SPACE(sizeof(struct rtmsg) + 128);
+ struct sk_buff *skb = alloc_skb(size, GFP_KERNEL);
+
+ if (!skb)
+ netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, ENOBUFS);
+ else if (inet_fill_rule(skb, r, 0, 0, event, 0) < 0) {
+ kfree_skb(skb);
+ netlink_set_err(rtnl, 0, RTNLGRP_IPV4_RULE, EINVAL);
+ } else {
+ netlink_broadcast(rtnl, skb, 0, RTNLGRP_IPV4_RULE, GFP_KERNEL);
+ }
+}
+
int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
{
int idx = 0;
@@ -442,7 +461,9 @@ int inet_dump_rules(struct sk_buff *skb, struct netlink_callback *cb)
if (idx < s_idx)
continue;
- if (inet_fill_rule(skb, r, cb, NLM_F_MULTI) < 0)
+ if (inet_fill_rule(skb, r, NETLINK_CB(cb->skb).pid,
+ cb->nlh->nlmsg_seq,
+ RTM_NEWRULE, NLM_F_MULTI) < 0)
break;
idx++;
}
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index e7bbff4340b..9831fd2c73a 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -753,7 +753,7 @@ static void icmp_redirect(struct sk_buff *skb)
case ICMP_REDIR_HOST:
case ICMP_REDIR_HOSTTOS:
ip_rt_redirect(skb->nh.iph->saddr, ip, skb->h.icmph->un.gateway,
- iph->saddr, iph->tos, skb->dev);
+ iph->saddr, skb->dev);
break;
}
out:
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 33228115cda..ef7366fc132 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -315,7 +315,7 @@ ok:
spin_unlock(&head->lock);
if (tw) {
- inet_twsk_deschedule(tw, death_row);;
+ inet_twsk_deschedule(tw, death_row);
inet_twsk_put(tw);
}
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 8ee4d016740..f75ff1d9655 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1249,11 +1249,7 @@ int ip_push_pending_frames(struct sock *sk)
iph->tos = inet->tos;
iph->tot_len = htons(skb->len);
iph->frag_off = df;
- if (!df) {
- __ip_select_ident(iph, &rt->u.dst, 0);
- } else {
- iph->id = htons(inet->id++);
- }
+ ip_select_ident(iph, &rt->u.dst, sk);
iph->ttl = ttl;
iph->protocol = sk->sk_protocol;
iph->saddr = rt->rt_src;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index f7efb3f27bf..ff0c594a419 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -1146,12 +1146,14 @@ void arpt_unregister_table(struct arpt_table *table)
static struct arpt_target arpt_standard_target = {
.name = ARPT_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = NF_ARP,
};
static struct arpt_target arpt_error_target = {
.name = ARPT_ERROR_TARGET,
.target = arpt_error,
.targetsize = ARPT_FUNCTION_MAXNAMELEN,
+ .family = NF_ARP,
};
static struct nf_sockopt_ops arpt_sockopts = {
@@ -1171,8 +1173,8 @@ static int __init init(void)
xt_proto_init(NF_ARP);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(NF_ARP, &arpt_standard_target);
- xt_register_target(NF_ARP, &arpt_error_target);
+ xt_register_target(&arpt_standard_target);
+ xt_register_target(&arpt_error_target);
/* Register setsockopt */
ret = nf_register_sockopt(&arpt_sockopts);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 84c66dbfeda..9e34034729a 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -77,8 +77,8 @@ unsigned int ip_ct_log_invalid;
static LIST_HEAD(unconfirmed);
static int ip_conntrack_vmalloc;
-static unsigned int ip_conntrack_next_id = 1;
-static unsigned int ip_conntrack_expect_next_id = 1;
+static unsigned int ip_conntrack_next_id;
+static unsigned int ip_conntrack_expect_next_id;
#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
struct notifier_block *ip_conntrack_chain;
struct notifier_block *ip_conntrack_expect_chain;
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 20da6730b86..daeb1395faa 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -639,8 +639,8 @@ void ip_conntrack_h245_expect(struct ip_conntrack *new,
}
/****************************************************************************/
-static int get_h225_addr(unsigned char *data, TransportAddress * addr,
- u_int32_t * ip, u_int16_t * port)
+int get_h225_addr(unsigned char *data, TransportAddress * addr,
+ u_int32_t * ip, u_int16_t * port)
{
unsigned char *p;
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 5ce2e3fc2c7..9b6e19bae90 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -4,7 +4,7 @@
* (C) 2001 by Jay Schulist <jschlst@samba.org>
* (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
* (C) 2003 by Patrick Mchardy <kaber@trash.net>
- * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
*
* I've reworked this stuff to use attributes instead of conntrack
* structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -53,20 +53,18 @@ static char __initdata version[] = "0.90";
static inline int
ctnetlink_dump_tuples_proto(struct sk_buff *skb,
- const struct ip_conntrack_tuple *tuple)
+ const struct ip_conntrack_tuple *tuple,
+ struct ip_conntrack_protocol *proto)
{
- struct ip_conntrack_protocol *proto;
int ret = 0;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
- /* If no protocol helper is found, this function will return the
- * generic protocol helper, so proto won't *ever* be NULL */
- proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
if (likely(proto->tuple_to_nfattr))
ret = proto->tuple_to_nfattr(skb, tuple);
- ip_conntrack_proto_put(proto);
+ NFA_NEST_END(skb, nest_parms);
return ret;
@@ -75,28 +73,41 @@ nfattr_failure:
}
static inline int
-ctnetlink_dump_tuples(struct sk_buff *skb,
- const struct ip_conntrack_tuple *tuple)
+ctnetlink_dump_tuples_ip(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple)
{
- struct nfattr *nest_parms;
- int ret;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
- nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip);
NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip);
- NFA_NEST_END(skb, nest_parms);
- nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
- ret = ctnetlink_dump_tuples_proto(skb, tuple);
NFA_NEST_END(skb, nest_parms);
- return ret;
+ return 0;
nfattr_failure:
return -1;
}
static inline int
+ctnetlink_dump_tuples(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple)
+{
+ int ret;
+ struct ip_conntrack_protocol *proto;
+
+ ret = ctnetlink_dump_tuples_ip(skb, tuple);
+ if (unlikely(ret < 0))
+ return ret;
+
+ proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
+ ip_conntrack_proto_put(proto);
+
+ return ret;
+}
+
+static inline int
ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct)
{
u_int32_t status = htonl((u_int32_t) ct->status);
@@ -1135,6 +1146,33 @@ nfattr_failure:
}
static inline int
+ctnetlink_exp_dump_mask(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple,
+ const struct ip_conntrack_tuple *mask)
+{
+ int ret;
+ struct ip_conntrack_protocol *proto;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
+
+ ret = ctnetlink_dump_tuples_ip(skb, mask);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
+ ip_conntrack_proto_put(proto);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ NFA_NEST_END(skb, nest_parms);
+
+ return 0;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
ctnetlink_exp_dump_expect(struct sk_buff *skb,
const struct ip_conntrack_expect *exp)
{
@@ -1144,7 +1182,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
goto nfattr_failure;
- if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0)
+ if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
goto nfattr_failure;
if (ctnetlink_exp_dump_tuple(skb,
&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c
index ab1f88fa21e..380aef3d786 100644
--- a/net/ipv4/netfilter/ip_nat_standalone.c
+++ b/net/ipv4/netfilter/ip_nat_standalone.c
@@ -394,7 +394,7 @@ static int init_or_cleanup(int init)
ret = nf_register_hook(&ip_nat_local_out_ops);
if (ret < 0) {
printk("ip_nat_init: can't register local out hook.\n");
- goto cleanup_adjustout_ops;;
+ goto cleanup_adjustout_ops;
}
ret = nf_register_hook(&ip_nat_local_in_ops);
if (ret < 0) {
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 39705f9bc15..a7b194c4d79 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1335,12 +1335,14 @@ icmp_checkentry(const char *tablename,
static struct ipt_target ipt_standard_target = {
.name = IPT_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = AF_INET,
};
static struct ipt_target ipt_error_target = {
.name = IPT_ERROR_TARGET,
.target = ipt_error,
.targetsize = IPT_FUNCTION_MAXNAMELEN,
+ .family = AF_INET,
};
static struct nf_sockopt_ops ipt_sockopts = {
@@ -1358,6 +1360,7 @@ static struct ipt_match icmp_matchstruct = {
.match = icmp_match,
.matchsize = sizeof(struct ipt_icmp),
.proto = IPPROTO_ICMP,
+ .family = AF_INET,
.checkentry = icmp_checkentry,
};
@@ -1368,9 +1371,9 @@ static int __init init(void)
xt_proto_init(AF_INET);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(AF_INET, &ipt_standard_target);
- xt_register_target(AF_INET, &ipt_error_target);
- xt_register_match(AF_INET, &icmp_matchstruct);
+ xt_register_target(&ipt_standard_target);
+ xt_register_target(&ipt_error_target);
+ xt_register_match(&icmp_matchstruct);
/* Register setsockopt */
ret = nf_register_sockopt(&ipt_sockopts);
@@ -1387,9 +1390,9 @@ static void __exit fini(void)
{
nf_unregister_sockopt(&ipt_sockopts);
- xt_unregister_match(AF_INET, &icmp_matchstruct);
- xt_unregister_target(AF_INET, &ipt_error_target);
- xt_unregister_target(AF_INET, &ipt_standard_target);
+ xt_unregister_match(&icmp_matchstruct);
+ xt_unregister_target(&ipt_error_target);
+ xt_unregister_target(&ipt_standard_target);
xt_proto_fini(AF_INET);
}
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index cb9c661f3f3..c8abc9d859b 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -568,6 +568,7 @@ static int init_or_cleanup(int init)
return ret;
}
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
MODULE_LICENSE("GPL");
static int __init init(void)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index fca5fe0cf94..94fcbc5e5a1 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -55,6 +55,8 @@
* Robert Olsson : Added rt_cache statistics
* Arnaldo C. Melo : Convert proc stuff to seq_file
* Eric Dumazet : hashed spinlocks and rt_check_expire() fixes.
+ * Ilia Sotnikov : Ignore TOS on PMTUD and Redirect
+ * Ilia Sotnikov : Removed TOS from hash calculations
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -247,9 +249,9 @@ static DEFINE_PER_CPU(struct rt_cache_stat, rt_cache_stat);
static int rt_intern_hash(unsigned hash, struct rtable *rth,
struct rtable **res);
-static unsigned int rt_hash_code(u32 daddr, u32 saddr, u8 tos)
+static unsigned int rt_hash_code(u32 daddr, u32 saddr)
{
- return (jhash_3words(daddr, saddr, (u32) tos, rt_hash_rnd)
+ return (jhash_2words(daddr, saddr, rt_hash_rnd)
& rt_hash_mask);
}
@@ -1111,7 +1113,7 @@ static void rt_del(unsigned hash, struct rtable *rt)
}
void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
- u32 saddr, u8 tos, struct net_device *dev)
+ u32 saddr, struct net_device *dev)
{
int i, k;
struct in_device *in_dev = in_dev_get(dev);
@@ -1119,8 +1121,6 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
u32 skeys[2] = { saddr, 0 };
int ikeys[2] = { dev->ifindex, 0 };
- tos &= IPTOS_RT_MASK;
-
if (!in_dev)
return;
@@ -1141,8 +1141,7 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
for (i = 0; i < 2; i++) {
for (k = 0; k < 2; k++) {
unsigned hash = rt_hash_code(daddr,
- skeys[i] ^ (ikeys[k] << 5),
- tos);
+ skeys[i] ^ (ikeys[k] << 5));
rthp=&rt_hash_table[hash].chain;
@@ -1152,7 +1151,6 @@ void ip_rt_redirect(u32 old_gw, u32 daddr, u32 new_gw,
if (rth->fl.fl4_dst != daddr ||
rth->fl.fl4_src != skeys[i] ||
- rth->fl.fl4_tos != tos ||
rth->fl.oif != ikeys[k] ||
rth->fl.iif != 0) {
rthp = &rth->u.rt_next;
@@ -1232,10 +1230,9 @@ reject_redirect:
if (IN_DEV_LOG_MARTIANS(in_dev) && net_ratelimit())
printk(KERN_INFO "Redirect from %u.%u.%u.%u on %s about "
"%u.%u.%u.%u ignored.\n"
- " Advised path = %u.%u.%u.%u -> %u.%u.%u.%u, "
- "tos %02x\n",
+ " Advised path = %u.%u.%u.%u -> %u.%u.%u.%u\n",
NIPQUAD(old_gw), dev->name, NIPQUAD(new_gw),
- NIPQUAD(saddr), NIPQUAD(daddr), tos);
+ NIPQUAD(saddr), NIPQUAD(daddr));
#endif
in_dev_put(in_dev);
}
@@ -1253,8 +1250,7 @@ static struct dst_entry *ipv4_negative_advice(struct dst_entry *dst)
rt->u.dst.expires) {
unsigned hash = rt_hash_code(rt->fl.fl4_dst,
rt->fl.fl4_src ^
- (rt->fl.oif << 5),
- rt->fl.fl4_tos);
+ (rt->fl.oif << 5));
#if RT_CACHE_DEBUG >= 1
printk(KERN_DEBUG "ip_rt_advice: redirect to "
"%u.%u.%u.%u/%02x dropped\n",
@@ -1391,14 +1387,13 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
struct rtable *rth;
u32 skeys[2] = { iph->saddr, 0, };
u32 daddr = iph->daddr;
- u8 tos = iph->tos & IPTOS_RT_MASK;
unsigned short est_mtu = 0;
if (ipv4_config.no_pmtu_disc)
return 0;
for (i = 0; i < 2; i++) {
- unsigned hash = rt_hash_code(daddr, skeys[i], tos);
+ unsigned hash = rt_hash_code(daddr, skeys[i]);
rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -1407,7 +1402,6 @@ unsigned short ip_rt_frag_needed(struct iphdr *iph, unsigned short new_mtu)
rth->fl.fl4_src == skeys[i] &&
rth->rt_dst == daddr &&
rth->rt_src == iph->saddr &&
- rth->fl.fl4_tos == tos &&
rth->fl.iif == 0 &&
!(dst_metric_locked(&rth->u.dst, RTAX_MTU))) {
unsigned short mtu = new_mtu;
@@ -1658,7 +1652,7 @@ static int ip_route_input_mc(struct sk_buff *skb, u32 daddr, u32 saddr,
RT_CACHE_STAT_INC(in_slow_mc);
in_dev_put(in_dev);
- hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5), tos);
+ hash = rt_hash_code(daddr, saddr ^ (dev->ifindex << 5));
return rt_intern_hash(hash, rth, (struct rtable**) &skb->dst);
e_nobufs:
@@ -1823,7 +1817,7 @@ static inline int ip_mkroute_input_def(struct sk_buff *skb,
return err;
/* put it into the cache */
- hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos);
+ hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5));
return rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
}
@@ -1864,7 +1858,7 @@ static inline int ip_mkroute_input(struct sk_buff *skb,
return err;
/* put it into the cache */
- hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5), tos);
+ hash = rt_hash_code(daddr, saddr ^ (fl->iif << 5));
err = rt_intern_hash(hash, rth, &rtres);
if (err)
return err;
@@ -2041,7 +2035,7 @@ local_input:
rth->rt_flags &= ~RTCF_LOCAL;
}
rth->rt_type = res.type;
- hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5), tos);
+ hash = rt_hash_code(daddr, saddr ^ (fl.iif << 5));
err = rt_intern_hash(hash, rth, (struct rtable**)&skb->dst);
goto done;
@@ -2088,7 +2082,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr,
int iif = dev->ifindex;
tos &= IPTOS_RT_MASK;
- hash = rt_hash_code(daddr, saddr ^ (iif << 5), tos);
+ hash = rt_hash_code(daddr, saddr ^ (iif << 5));
rcu_read_lock();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
@@ -2286,10 +2280,8 @@ static inline int ip_mkroute_output_def(struct rtable **rp,
int err = __mkroute_output(&rth, res, fl, oldflp, dev_out, flags);
unsigned hash;
if (err == 0) {
- u32 tos = RT_FL_TOS(oldflp);
-
hash = rt_hash_code(oldflp->fl4_dst,
- oldflp->fl4_src ^ (oldflp->oif << 5), tos);
+ oldflp->fl4_src ^ (oldflp->oif << 5));
err = rt_intern_hash(hash, rth, rp);
}
@@ -2304,7 +2296,6 @@ static inline int ip_mkroute_output(struct rtable** rp,
unsigned flags)
{
#ifdef CONFIG_IP_ROUTE_MULTIPATH_CACHED
- u32 tos = RT_FL_TOS(oldflp);
unsigned char hop;
unsigned hash;
int err = -EINVAL;
@@ -2334,7 +2325,7 @@ static inline int ip_mkroute_output(struct rtable** rp,
hash = rt_hash_code(oldflp->fl4_dst,
oldflp->fl4_src ^
- (oldflp->oif << 5), tos);
+ (oldflp->oif << 5));
err = rt_intern_hash(hash, rth, rp);
/* forward hop information to multipath impl. */
@@ -2563,7 +2554,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
unsigned hash;
struct rtable *rth;
- hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5), flp->fl4_tos);
+ hash = rt_hash_code(flp->fl4_dst, flp->fl4_src ^ (flp->oif << 5));
rcu_read_lock_bh();
for (rth = rcu_dereference(rt_hash_table[hash].chain); rth;
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 4b0272c92d6..87f68e787d0 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -257,6 +257,7 @@
#include <linux/fs.h>
#include <linux/random.h>
#include <linux/bootmem.h>
+#include <linux/cache.h>
#include <net/icmp.h>
#include <net/tcp.h>
@@ -275,9 +276,9 @@ atomic_t tcp_orphan_count = ATOMIC_INIT(0);
EXPORT_SYMBOL_GPL(tcp_orphan_count);
-int sysctl_tcp_mem[3];
-int sysctl_tcp_wmem[3] = { 4 * 1024, 16 * 1024, 128 * 1024 };
-int sysctl_tcp_rmem[3] = { 4 * 1024, 87380, 87380 * 2 };
+int sysctl_tcp_mem[3] __read_mostly;
+int sysctl_tcp_wmem[3] __read_mostly;
+int sysctl_tcp_rmem[3] __read_mostly;
EXPORT_SYMBOL(sysctl_tcp_mem);
EXPORT_SYMBOL(sysctl_tcp_rmem);
@@ -365,7 +366,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == TCP_CLOSE)
mask |= POLLHUP;
if (sk->sk_shutdown & RCV_SHUTDOWN)
- mask |= POLLIN | POLLRDNORM;
+ mask |= POLLIN | POLLRDNORM | POLLRDHUP;
/* Connected? */
if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) {
@@ -2081,7 +2082,8 @@ __setup("thash_entries=", set_thash_entries);
void __init tcp_init(void)
{
struct sk_buff *skb = NULL;
- int order, i;
+ unsigned long limit;
+ int order, i, max_share;
if (sizeof(struct tcp_skb_cb) > sizeof(skb->cb))
__skb_cb_too_small_for_tcp(sizeof(struct tcp_skb_cb),
@@ -2155,12 +2157,16 @@ void __init tcp_init(void)
sysctl_tcp_mem[1] = 1024 << order;
sysctl_tcp_mem[2] = 1536 << order;
- if (order < 3) {
- sysctl_tcp_wmem[2] = 64 * 1024;
- sysctl_tcp_rmem[0] = PAGE_SIZE;
- sysctl_tcp_rmem[1] = 43689;
- sysctl_tcp_rmem[2] = 2 * 43689;
- }
+ limit = ((unsigned long)sysctl_tcp_mem[1]) << (PAGE_SHIFT - 7);
+ max_share = min(4UL*1024*1024, limit);
+
+ sysctl_tcp_wmem[0] = SK_STREAM_MEM_QUANTUM;
+ sysctl_tcp_wmem[1] = 16*1024;
+ sysctl_tcp_wmem[2] = max(64*1024, max_share);
+
+ sysctl_tcp_rmem[0] = SK_STREAM_MEM_QUANTUM;
+ sysctl_tcp_rmem[1] = 87380;
+ sysctl_tcp_rmem[2] = max(87380, max_share);
printk(KERN_INFO "TCP: Hash tables configured "
"(established %d bind %d)\n",
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 4fbc40b13f1..e46048974f3 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -161,7 +161,7 @@ int ip6_output(struct sk_buff *skb)
int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
struct ipv6_txoptions *opt, int ipfragok)
{
- struct ipv6_pinfo *np = sk ? inet6_sk(sk) : NULL;
+ struct ipv6_pinfo *np = inet6_sk(sk);
struct in6_addr *first_hop = &fl->fl6_dst;
struct dst_entry *dst = skb->dst;
struct ipv6hdr *hdr;
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 602feec4773..4c20eeb3d56 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -907,7 +907,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER
/* we need to exclude all possible EINVALs except default case */
- if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM &&
+ if (err == -EINVAL && optname != IPV6_ADDRFORM &&
optname != MCAST_MSFILTER) {
int len;
@@ -944,7 +944,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER
/* we need to exclude all possible EINVALs except default case */
- if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM &&
+ if (err == -EINVAL && optname != IPV6_ADDRFORM &&
optname != MCAST_MSFILTER) {
int len;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 5a2063bda67..db3c9ae98e9 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1377,12 +1377,14 @@ icmp6_checkentry(const char *tablename,
static struct ip6t_target ip6t_standard_target = {
.name = IP6T_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = AF_INET6,
};
static struct ip6t_target ip6t_error_target = {
.name = IP6T_ERROR_TARGET,
.target = ip6t_error,
.targetsize = IP6T_FUNCTION_MAXNAMELEN,
+ .family = AF_INET6,
};
static struct nf_sockopt_ops ip6t_sockopts = {
@@ -1401,6 +1403,7 @@ static struct ip6t_match icmp6_matchstruct = {
.matchsize = sizeof(struct ip6t_icmp),
.checkentry = icmp6_checkentry,
.proto = IPPROTO_ICMPV6,
+ .family = AF_INET6,
};
static int __init init(void)
@@ -1410,9 +1413,9 @@ static int __init init(void)
xt_proto_init(AF_INET6);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(AF_INET6, &ip6t_standard_target);
- xt_register_target(AF_INET6, &ip6t_error_target);
- xt_register_match(AF_INET6, &icmp6_matchstruct);
+ xt_register_target(&ip6t_standard_target);
+ xt_register_target(&ip6t_error_target);
+ xt_register_match(&icmp6_matchstruct);
/* Register setsockopt */
ret = nf_register_sockopt(&ip6t_sockopts);
@@ -1429,9 +1432,9 @@ static int __init init(void)
static void __exit fini(void)
{
nf_unregister_sockopt(&ip6t_sockopts);
- xt_unregister_match(AF_INET6, &icmp6_matchstruct);
- xt_unregister_target(AF_INET6, &ip6t_error_target);
- xt_unregister_target(AF_INET6, &ip6t_standard_target);
+ xt_unregister_match(&icmp6_matchstruct);
+ xt_unregister_target(&ip6t_error_target);
+ xt_unregister_target(&ip6t_standard_target);
xt_proto_fini(AF_INET6);
}
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index ac35f952636..c16f62934bd 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -584,6 +584,7 @@ static int init_or_cleanup(int init)
return ret;
}
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 17402780914..332acb37b38 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -11,7 +11,7 @@ config NETFILTER_NETLINK_QUEUE
tristate "Netfilter NFQUEUE over NFNETLINK interface"
depends on NETFILTER_NETLINK
help
- If this option isenabled, the kernel will include support
+ If this option is enabled, the kernel will include support
for queueing packets via NFNETLINK.
config NETFILTER_NETLINK_LOG
@@ -66,7 +66,7 @@ config NF_CONNTRACK_EVENTS
help
If this option is enabled, the connection tracking code will
provide a notifier chain that can be used by other kernel code
- to get notified aboutchanges in the connection tracking state.
+ to get notified about changes in the connection tracking state.
If unsure, say `N'.
@@ -153,7 +153,7 @@ config NETFILTER_XT_TARGET_NFQUEUE
tristate '"NFQUEUE" target Support'
depends on NETFILTER_XTABLES
help
- This Target replaced the old obsolete QUEUE target.
+ This target replaced the old obsolete QUEUE target.
As opposed to QUEUE, it supports 65535 different queues,
not just one.
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index f6498234e26..0ae281d9bfc 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -23,6 +23,8 @@
* 26 Jan 2006: Harald Welte <laforge@netfilter.org>
* - restructure nf_conn (introduce nf_conn_help)
* - redesign 'features' how they were originally intended
+ * 26 Feb 2006: Pablo Neira Ayuso <pablo@eurodev.net>
+ * - add support for L3 protocol module load on demand.
*
* Derived from net/ipv4/netfilter/ip_conntrack_core.c
*/
@@ -85,8 +87,8 @@ unsigned int nf_ct_log_invalid;
static LIST_HEAD(unconfirmed);
static int nf_conntrack_vmalloc;
-static unsigned int nf_conntrack_next_id = 1;
-static unsigned int nf_conntrack_expect_next_id = 1;
+static unsigned int nf_conntrack_next_id;
+static unsigned int nf_conntrack_expect_next_id;
#ifdef CONFIG_NF_CONNTRACK_EVENTS
struct notifier_block *nf_conntrack_chain;
struct notifier_block *nf_conntrack_expect_chain;
@@ -241,6 +243,35 @@ void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p)
module_put(p->me);
}
+int
+nf_ct_l3proto_try_module_get(unsigned short l3proto)
+{
+ int ret;
+ struct nf_conntrack_l3proto *p;
+
+retry: p = nf_ct_l3proto_find_get(l3proto);
+ if (p == &nf_conntrack_generic_l3proto) {
+ ret = request_module("nf_conntrack-%d", l3proto);
+ if (!ret)
+ goto retry;
+
+ return -EPROTOTYPE;
+ }
+
+ return 0;
+}
+
+void nf_ct_l3proto_module_put(unsigned short l3proto)
+{
+ struct nf_conntrack_l3proto *p;
+
+ preempt_disable();
+ p = __nf_ct_l3proto_find(l3proto);
+ preempt_enable();
+
+ module_put(p->me);
+}
+
static int nf_conntrack_hash_rnd_initted;
static unsigned int nf_conntrack_hash_rnd;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 5eadf009bb1..0e0e9d7b34c 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -4,7 +4,7 @@
* (C) 2001 by Jay Schulist <jschlst@samba.org>
* (C) 2002-2006 by Harald Welte <laforge@gnumonks.org>
* (C) 2003 by Patrick Mchardy <kaber@trash.net>
- * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
*
* I've reworked this stuff to use attributes instead of conntrack
* structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -55,20 +55,18 @@ static char __initdata version[] = "0.93";
static inline int
ctnetlink_dump_tuples_proto(struct sk_buff *skb,
- const struct nf_conntrack_tuple *tuple)
+ const struct nf_conntrack_tuple *tuple,
+ struct nf_conntrack_protocol *proto)
{
- struct nf_conntrack_protocol *proto;
int ret = 0;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
- /* If no protocol helper is found, this function will return the
- * generic protocol helper, so proto won't *ever* be NULL */
- proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
if (likely(proto->tuple_to_nfattr))
ret = proto->tuple_to_nfattr(skb, tuple);
- nf_ct_proto_put(proto);
+ NFA_NEST_END(skb, nest_parms);
return ret;
@@ -77,33 +75,44 @@ nfattr_failure:
}
static inline int
-ctnetlink_dump_tuples(struct sk_buff *skb,
- const struct nf_conntrack_tuple *tuple)
+ctnetlink_dump_tuples_ip(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple,
+ struct nf_conntrack_l3proto *l3proto)
{
- struct nfattr *nest_parms;
- struct nf_conntrack_l3proto *l3proto;
int ret = 0;
-
- l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
-
- nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
+
if (likely(l3proto->tuple_to_nfattr))
ret = l3proto->tuple_to_nfattr(skb, tuple);
+
NFA_NEST_END(skb, nest_parms);
+ return ret;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
+ctnetlink_dump_tuples(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple)
+{
+ int ret;
+ struct nf_conntrack_l3proto *l3proto;
+ struct nf_conntrack_protocol *proto;
+
+ l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+ ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
nf_ct_l3proto_put(l3proto);
if (unlikely(ret < 0))
return ret;
- nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
- ret = ctnetlink_dump_tuples_proto(skb, tuple);
- NFA_NEST_END(skb, nest_parms);
+ proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
+ nf_ct_proto_put(proto);
return ret;
-
-nfattr_failure:
- return -1;
}
static inline int
@@ -1153,6 +1162,37 @@ nfattr_failure:
}
static inline int
+ctnetlink_exp_dump_mask(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple,
+ const struct nf_conntrack_tuple *mask)
+{
+ int ret;
+ struct nf_conntrack_l3proto *l3proto;
+ struct nf_conntrack_protocol *proto;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
+
+ l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+ ret = ctnetlink_dump_tuples_ip(skb, mask, l3proto);
+ nf_ct_l3proto_put(l3proto);
+
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
+ nf_ct_proto_put(proto);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ NFA_NEST_END(skb, nest_parms);
+
+ return 0;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
ctnetlink_exp_dump_expect(struct sk_buff *skb,
const struct nf_conntrack_expect *exp)
{
@@ -1162,7 +1202,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
goto nfattr_failure;
- if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0)
+ if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
goto nfattr_failure;
if (ctnetlink_exp_dump_tuple(skb,
&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 290d5a0c559..75577e175b3 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -834,6 +834,8 @@ EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);
EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache);
EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
#endif
+EXPORT_SYMBOL(nf_ct_l3proto_try_module_get);
+EXPORT_SYMBOL(nf_ct_l3proto_module_put);
EXPORT_SYMBOL(nf_conntrack_l3proto_register);
EXPORT_SYMBOL(nf_conntrack_l3proto_unregister);
EXPORT_SYMBOL(nf_conntrack_protocol_register);
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 2cf5fb8322c..b5701662182 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -354,16 +354,17 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
QDEBUG("entered\n");
/* all macros expand to constant values at compile time */
- size = NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
+ size = NLMSG_SPACE(sizeof(struct nfgenmsg)) +
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
#ifdef CONFIG_BRIDGE_NETFILTER
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
#endif
- + NLMSG_SPACE(sizeof(u_int32_t)) /* mark */
- + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hw))
- + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
+ + NFA_SPACE(sizeof(u_int32_t)) /* mark */
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hw))
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
outdev = entinf->outdev;
@@ -388,7 +389,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
else
data_len = queue->copy_range;
- size += NLMSG_SPACE(data_len);
+ size += NFA_SPACE(data_len);
break;
default:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 750b9282976..a657ab5394c 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -21,10 +21,12 @@
#include <linux/seq_file.h>
#include <linux/string.h>
#include <linux/vmalloc.h>
+#include <linux/mutex.h>
#include <linux/netfilter/x_tables.h>
#include <linux/netfilter_arp.h>
+
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
@@ -32,7 +34,7 @@ MODULE_DESCRIPTION("[ip,ip6,arp]_tables backend module");
#define SMP_ALIGN(x) (((x) + SMP_CACHE_BYTES-1) & ~(SMP_CACHE_BYTES-1))
struct xt_af {
- struct semaphore mutex;
+ struct mutex mutex;
struct list_head match;
struct list_head target;
struct list_head tables;
@@ -60,50 +62,54 @@ static const char *xt_prefix[NPROTO] = {
/* Registration hooks for targets. */
int
-xt_register_target(int af, struct xt_target *target)
+xt_register_target(struct xt_target *target)
{
- int ret;
+ int ret, af = target->family;
- ret = down_interruptible(&xt[af].mutex);
+ ret = mutex_lock_interruptible(&xt[af].mutex);
if (ret != 0)
return ret;
list_add(&target->list, &xt[af].target);
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return ret;
}
EXPORT_SYMBOL(xt_register_target);
void
-xt_unregister_target(int af, struct xt_target *target)
+xt_unregister_target(struct xt_target *target)
{
- down(&xt[af].mutex);
+ int af = target->family;
+
+ mutex_lock(&xt[af].mutex);
LIST_DELETE(&xt[af].target, target);
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
}
EXPORT_SYMBOL(xt_unregister_target);
int
-xt_register_match(int af, struct xt_match *match)
+xt_register_match(struct xt_match *match)
{
- int ret;
+ int ret, af = match->family;
- ret = down_interruptible(&xt[af].mutex);
+ ret = mutex_lock_interruptible(&xt[af].mutex);
if (ret != 0)
return ret;
list_add(&match->list, &xt[af].match);
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return ret;
}
EXPORT_SYMBOL(xt_register_match);
void
-xt_unregister_match(int af, struct xt_match *match)
+xt_unregister_match(struct xt_match *match)
{
- down(&xt[af].mutex);
+ int af = match->family;
+
+ mutex_lock(&xt[af].mutex);
LIST_DELETE(&xt[af].match, match);
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
}
EXPORT_SYMBOL(xt_unregister_match);
@@ -120,21 +126,21 @@ struct xt_match *xt_find_match(int af, const char *name, u8 revision)
struct xt_match *m;
int err = 0;
- if (down_interruptible(&xt[af].mutex) != 0)
+ if (mutex_lock_interruptible(&xt[af].mutex) != 0)
return ERR_PTR(-EINTR);
list_for_each_entry(m, &xt[af].match, list) {
if (strcmp(m->name, name) == 0) {
if (m->revision == revision) {
if (try_module_get(m->me)) {
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return m;
}
} else
err = -EPROTOTYPE; /* Found something. */
}
}
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return ERR_PTR(err);
}
EXPORT_SYMBOL(xt_find_match);
@@ -145,21 +151,21 @@ struct xt_target *xt_find_target(int af, const char *name, u8 revision)
struct xt_target *t;
int err = 0;
- if (down_interruptible(&xt[af].mutex) != 0)
+ if (mutex_lock_interruptible(&xt[af].mutex) != 0)
return ERR_PTR(-EINTR);
list_for_each_entry(t, &xt[af].target, list) {
if (strcmp(t->name, name) == 0) {
if (t->revision == revision) {
if (try_module_get(t->me)) {
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return t;
}
} else
err = -EPROTOTYPE; /* Found something. */
}
}
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return ERR_PTR(err);
}
EXPORT_SYMBOL(xt_find_target);
@@ -214,7 +220,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
{
int have_rev, best = -1;
- if (down_interruptible(&xt[af].mutex) != 0) {
+ if (mutex_lock_interruptible(&xt[af].mutex) != 0) {
*err = -EINTR;
return 1;
}
@@ -222,7 +228,7 @@ int xt_find_revision(int af, const char *name, u8 revision, int target,
have_rev = target_revfn(af, name, revision, &best);
else
have_rev = match_revfn(af, name, revision, &best);
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
/* Nothing at all? Return 0 to try loading module. */
if (best == -1) {
@@ -348,20 +354,20 @@ struct xt_table *xt_find_table_lock(int af, const char *name)
{
struct xt_table *t;
- if (down_interruptible(&xt[af].mutex) != 0)
+ if (mutex_lock_interruptible(&xt[af].mutex) != 0)
return ERR_PTR(-EINTR);
list_for_each_entry(t, &xt[af].tables, list)
if (strcmp(t->name, name) == 0 && try_module_get(t->me))
return t;
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
return NULL;
}
EXPORT_SYMBOL_GPL(xt_find_table_lock);
void xt_table_unlock(struct xt_table *table)
{
- up(&xt[table->af].mutex);
+ mutex_unlock(&xt[table->af].mutex);
}
EXPORT_SYMBOL_GPL(xt_table_unlock);
@@ -401,7 +407,7 @@ int xt_register_table(struct xt_table *table,
int ret;
struct xt_table_info *private;
- ret = down_interruptible(&xt[table->af].mutex);
+ ret = mutex_lock_interruptible(&xt[table->af].mutex);
if (ret != 0)
return ret;
@@ -427,7 +433,7 @@ int xt_register_table(struct xt_table *table,
ret = 0;
unlock:
- up(&xt[table->af].mutex);
+ mutex_unlock(&xt[table->af].mutex);
return ret;
}
EXPORT_SYMBOL_GPL(xt_register_table);
@@ -436,10 +442,10 @@ void *xt_unregister_table(struct xt_table *table)
{
struct xt_table_info *private;
- down(&xt[table->af].mutex);
+ mutex_lock(&xt[table->af].mutex);
private = table->private;
LIST_DELETE(&xt[table->af].tables, table);
- up(&xt[table->af].mutex);
+ mutex_unlock(&xt[table->af].mutex);
return private;
}
@@ -503,7 +509,7 @@ static void *xt_tgt_seq_start(struct seq_file *seq, loff_t *pos)
if (!list)
return NULL;
- if (down_interruptible(&xt[af].mutex) != 0)
+ if (mutex_lock_interruptible(&xt[af].mutex) != 0)
return NULL;
return xt_get_idx(list, seq, *pos);
@@ -532,7 +538,7 @@ static void xt_tgt_seq_stop(struct seq_file *seq, void *v)
struct proc_dir_entry *pde = seq->private;
u_int16_t af = (unsigned long)pde->data & 0xffff;
- up(&xt[af].mutex);
+ mutex_unlock(&xt[af].mutex);
}
static int xt_name_seq_show(struct seq_file *seq, void *v)
@@ -664,7 +670,7 @@ static int __init xt_init(void)
return -ENOMEM;
for (i = 0; i < NPROTO; i++) {
- init_MUTEX(&xt[i].mutex);
+ mutex_init(&xt[i].mutex);
INIT_LIST_HEAD(&xt[i].target);
INIT_LIST_HEAD(&xt[i].match);
INIT_LIST_HEAD(&xt[i].tables);
diff --git a/net/netfilter/xt_CLASSIFY.c b/net/netfilter/xt_CLASSIFY.c
index 3224ed87d4c..3cd2ac90a25 100644
--- a/net/netfilter/xt_CLASSIFY.c
+++ b/net/netfilter/xt_CLASSIFY.c
@@ -47,6 +47,7 @@ static struct xt_target classify_reg = {
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_target classify6_reg = {
@@ -56,6 +57,7 @@ static struct xt_target classify6_reg = {
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -64,21 +66,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &classify_reg);
+ ret = xt_register_target(&classify_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &classify6_reg);
+ ret = xt_register_target(&classify6_reg);
if (ret)
- xt_unregister_target(AF_INET, &classify_reg);
+ xt_unregister_target(&classify_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &classify_reg);
- xt_unregister_target(AF_INET6, &classify6_reg);
+ xt_unregister_target(&classify_reg);
+ xt_unregister_target(&classify6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index df2486a3efd..35448b8e688 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -102,6 +102,7 @@ static struct xt_target connmark_reg = {
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -110,6 +111,7 @@ static struct xt_target connmark6_reg = {
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -119,21 +121,21 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_target(AF_INET, &connmark_reg);
+ ret = xt_register_target(&connmark_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &connmark6_reg);
+ ret = xt_register_target(&connmark6_reg);
if (ret)
- xt_unregister_target(AF_INET, &connmark_reg);
+ xt_unregister_target(&connmark_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &connmark_reg);
- xt_unregister_target(AF_INET6, &connmark6_reg);
+ xt_unregister_target(&connmark_reg);
+ xt_unregister_target(&connmark6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c
index dcb5266efae..73bdd5c80e1 100644
--- a/net/netfilter/xt_MARK.c
+++ b/net/netfilter/xt_MARK.c
@@ -119,6 +119,7 @@ static struct xt_target ipt_mark_reg_v0 = {
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
+ .family = AF_INET,
.revision = 0,
};
@@ -129,6 +130,7 @@ static struct xt_target ipt_mark_reg_v1 = {
.table = "mangle",
.checkentry = checkentry_v1,
.me = THIS_MODULE,
+ .family = AF_INET,
.revision = 1,
};
@@ -139,6 +141,7 @@ static struct xt_target ip6t_mark_reg_v0 = {
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
+ .family = AF_INET6,
.revision = 0,
};
@@ -146,18 +149,18 @@ static int __init init(void)
{
int err;
- err = xt_register_target(AF_INET, &ipt_mark_reg_v0);
+ err = xt_register_target(&ipt_mark_reg_v0);
if (err)
return err;
- err = xt_register_target(AF_INET, &ipt_mark_reg_v1);
+ err = xt_register_target(&ipt_mark_reg_v1);
if (err)
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v0);
- err = xt_register_target(AF_INET6, &ip6t_mark_reg_v0);
+ err = xt_register_target(&ip6t_mark_reg_v0);
if (err) {
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
- xt_unregister_target(AF_INET, &ipt_mark_reg_v1);
+ xt_unregister_target(&ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v1);
}
return err;
@@ -165,9 +168,9 @@ static int __init init(void)
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
- xt_unregister_target(AF_INET, &ipt_mark_reg_v1);
- xt_unregister_target(AF_INET6, &ip6t_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v1);
+ xt_unregister_target(&ip6t_mark_reg_v0);
}
module_init(init);
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index 39a963edf16..2873e1c60f6 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -41,6 +41,7 @@ static struct xt_target ipt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -48,6 +49,7 @@ static struct xt_target ip6t_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -55,36 +57,37 @@ static struct xt_target arpt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = NF_ARP,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &ipt_NFQ_reg);
+ ret = xt_register_target(&ipt_NFQ_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &ip6t_NFQ_reg);
+ ret = xt_register_target(&ip6t_NFQ_reg);
if (ret)
goto out_ip;
- ret = xt_register_target(NF_ARP, &arpt_NFQ_reg);
+ ret = xt_register_target(&arpt_NFQ_reg);
if (ret)
goto out_ip6;
return ret;
out_ip6:
- xt_unregister_target(AF_INET6, &ip6t_NFQ_reg);
+ xt_unregister_target(&ip6t_NFQ_reg);
out_ip:
- xt_unregister_target(AF_INET, &ipt_NFQ_reg);
+ xt_unregister_target(&ipt_NFQ_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(NF_ARP, &arpt_NFQ_reg);
- xt_unregister_target(AF_INET6, &ip6t_NFQ_reg);
- xt_unregister_target(AF_INET, &ipt_NFQ_reg);
+ xt_unregister_target(&arpt_NFQ_reg);
+ xt_unregister_target(&ip6t_NFQ_reg);
+ xt_unregister_target(&ipt_NFQ_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_NOTRACK.c b/net/netfilter/xt_NOTRACK.c
index b8634e3f616..cf2ebd76fd6 100644
--- a/net/netfilter/xt_NOTRACK.c
+++ b/net/netfilter/xt_NOTRACK.c
@@ -39,6 +39,7 @@ static struct xt_target notrack_reg = {
.target = target,
.targetsize = 0,
.table = "raw",
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -47,6 +48,7 @@ static struct xt_target notrack6_reg = {
.target = target,
.targetsize = 0,
.table = "raw",
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -54,21 +56,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &notrack_reg);
+ ret = xt_register_target(&notrack_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &notrack6_reg);
+ ret = xt_register_target(&notrack6_reg);
if (ret)
- xt_unregister_target(AF_INET, &notrack_reg);
+ xt_unregister_target(&notrack_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET6, &notrack6_reg);
- xt_unregister_target(AF_INET, &notrack_reg);
+ xt_unregister_target(&notrack6_reg);
+ xt_unregister_target(&notrack_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_comment.c b/net/netfilter/xt_comment.c
index 03d9d741231..2637724b498 100644
--- a/net/netfilter/xt_comment.c
+++ b/net/netfilter/xt_comment.c
@@ -33,6 +33,7 @@ static struct xt_match comment_match = {
.name = "comment",
.match = match,
.matchsize = sizeof(struct xt_comment_info),
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -40,6 +41,7 @@ static struct xt_match comment6_match = {
.name = "comment",
.match = match,
.matchsize = sizeof(struct xt_comment_info),
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -47,21 +49,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &comment_match);
+ ret = xt_register_match(&comment_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &comment6_match);
+ ret = xt_register_match(&comment6_match);
if (ret)
- xt_unregister_match(AF_INET, &comment_match);
+ xt_unregister_match(&comment_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &comment_match);
- xt_unregister_match(AF_INET6, &comment6_match);
+ xt_unregister_match(&comment_match);
+ xt_unregister_match(&comment6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index f34ecb9485c..4985f5ec58c 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -148,6 +148,7 @@ static struct xt_match connbytes_match = {
.match = match,
.checkentry = check,
.matchsize = sizeof(struct xt_connbytes_info),
+ .family = AF_INET,
.me = THIS_MODULE
};
static struct xt_match connbytes6_match = {
@@ -155,26 +156,27 @@ static struct xt_match connbytes6_match = {
.match = match,
.checkentry = check,
.matchsize = sizeof(struct xt_connbytes_info),
+ .family = AF_INET6,
.me = THIS_MODULE
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &connbytes_match);
+ ret = xt_register_match(&connbytes_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &connbytes6_match);
+ ret = xt_register_match(&connbytes6_match);
if (ret)
- xt_unregister_match(AF_INET, &connbytes_match);
+ xt_unregister_match(&connbytes_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &connbytes_match);
- xt_unregister_match(AF_INET6, &connbytes6_match);
+ xt_unregister_match(&connbytes_match);
+ xt_unregister_match(&connbytes6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index 51822471e91..7b16f1ee16b 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -64,14 +64,31 @@ checkentry(const char *tablename,
printk(KERN_WARNING "connmark: only support 32bit mark\n");
return 0;
}
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
return 1;
}
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match connmark_match = {
.name = "connmark",
.match = match,
.matchsize = sizeof(struct xt_connmark_info),
.checkentry = checkentry,
+ .destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -80,6 +97,8 @@ static struct xt_match connmark6_match = {
.match = match,
.matchsize = sizeof(struct xt_connmark_info),
.checkentry = checkentry,
+ .destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -89,20 +108,20 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_match(AF_INET, &connmark_match);
+ ret = xt_register_match(&connmark_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &connmark6_match);
+ ret = xt_register_match(&connmark6_match);
if (ret)
- xt_unregister_match(AF_INET, &connmark_match);
+ xt_unregister_match(&connmark_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &connmark6_match);
- xt_unregister_match(AF_INET, &connmark_match);
+ xt_unregister_match(&connmark6_match);
+ xt_unregister_match(&connmark_match);
}
module_init(init);
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 39fc29496e0..65a84809fd3 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -203,10 +203,39 @@ match(const struct sk_buff *skb,
#endif /* CONFIG_NF_IP_CONNTRACK */
+static int
+checkentry(const char *tablename,
+ const void *ip,
+ const struct xt_match *match,
+ void *matchinfo,
+ unsigned int matchsize,
+ unsigned int hook_mask)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match conntrack_match = {
.name = "conntrack",
.match = match,
+ .checkentry = checkentry,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_conntrack_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -214,14 +243,14 @@ static int __init init(void)
{
int ret;
need_conntrack();
- ret = xt_register_match(AF_INET, &conntrack_match);
+ ret = xt_register_match(&conntrack_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &conntrack_match);
+ xt_unregister_match(&conntrack_match);
}
module_init(init);
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index db6b70cdc77..2f331decd15 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -149,6 +149,7 @@ static struct xt_match dccp_match =
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match dccp6_match =
@@ -158,6 +159,7 @@ static struct xt_match dccp6_match =
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -172,17 +174,17 @@ static int __init init(void)
dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL);
if (!dccp_optbuf)
return -ENOMEM;
- ret = xt_register_match(AF_INET, &dccp_match);
+ ret = xt_register_match(&dccp_match);
if (ret)
goto out_kfree;
- ret = xt_register_match(AF_INET6, &dccp6_match);
+ ret = xt_register_match(&dccp6_match);
if (ret)
goto out_unreg;
return ret;
out_unreg:
- xt_unregister_match(AF_INET, &dccp_match);
+ xt_unregister_match(&dccp_match);
out_kfree:
kfree(dccp_optbuf);
@@ -191,8 +193,8 @@ out_kfree:
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &dccp6_match);
- xt_unregister_match(AF_INET, &dccp_match);
+ xt_unregister_match(&dccp6_match);
+ xt_unregister_match(&dccp_match);
kfree(dccp_optbuf);
}
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index ef8e54d40c9..101f0005e98 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -144,15 +144,32 @@ static int check(const char *tablename,
{
struct xt_helper_info *info = matchinfo;
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
info->name[29] = '\0';
return 1;
}
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match helper_match = {
.name = "helper",
.match = match,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check,
+ .destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match helper6_match = {
@@ -160,6 +177,8 @@ static struct xt_match helper6_match = {
.match = match,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check,
+ .destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -168,21 +187,21 @@ static int __init init(void)
int ret;
need_conntrack();
- ret = xt_register_match(AF_INET, &helper_match);
+ ret = xt_register_match(&helper_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &helper6_match);
+ ret = xt_register_match(&helper6_match);
if (ret < 0)
- xt_unregister_match(AF_INET, &helper_match);
+ xt_unregister_match(&helper_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &helper_match);
- xt_unregister_match(AF_INET6, &helper6_match);
+ xt_unregister_match(&helper_match);
+ xt_unregister_match(&helper6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_length.c b/net/netfilter/xt_length.c
index b9e60f041a6..38560caef75 100644
--- a/net/netfilter/xt_length.c
+++ b/net/netfilter/xt_length.c
@@ -56,6 +56,7 @@ static struct xt_match length_match = {
.name = "length",
.match = match,
.matchsize = sizeof(struct xt_length_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -63,26 +64,27 @@ static struct xt_match length6_match = {
.name = "length",
.match = match6,
.matchsize = sizeof(struct xt_length_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &length_match);
+ ret = xt_register_match(&length_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &length6_match);
+ ret = xt_register_match(&length6_match);
if (ret)
- xt_unregister_match(AF_INET, &length_match);
+ xt_unregister_match(&length_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &length_match);
- xt_unregister_match(AF_INET6, &length6_match);
+ xt_unregister_match(&length_match);
+ xt_unregister_match(&length6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 3049e6f8889..e91c1a444e7 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -141,6 +141,7 @@ static struct xt_match ipt_limit_reg = {
.match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match limit6_reg = {
@@ -148,6 +149,7 @@ static struct xt_match limit6_reg = {
.match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -155,21 +157,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &ipt_limit_reg);
+ ret = xt_register_match(&ipt_limit_reg);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &limit6_reg);
+ ret = xt_register_match(&limit6_reg);
if (ret)
- xt_unregister_match(AF_INET, &ipt_limit_reg);
+ xt_unregister_match(&ipt_limit_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &ipt_limit_reg);
- xt_unregister_match(AF_INET6, &limit6_reg);
+ xt_unregister_match(&ipt_limit_reg);
+ xt_unregister_match(&limit6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_mac.c b/net/netfilter/xt_mac.c
index b4559a46dce..f4defa28a6e 100644
--- a/net/netfilter/xt_mac.c
+++ b/net/netfilter/xt_mac.c
@@ -49,6 +49,7 @@ static struct xt_match mac_match = {
.matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match mac6_match = {
@@ -57,27 +58,28 @@ static struct xt_match mac6_match = {
.matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &mac_match);
+ ret = xt_register_match(&mac_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &mac6_match);
+ ret = xt_register_match(&mac6_match);
if (ret)
- xt_unregister_match(AF_INET, &mac_match);
+ xt_unregister_match(&mac_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &mac_match);
- xt_unregister_match(AF_INET6, &mac6_match);
+ xt_unregister_match(&mac_match);
+ xt_unregister_match(&mac6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index c1a8f0f587f..ce0badfeef9 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -56,6 +56,7 @@ static struct xt_match mark_match = {
.match = match,
.matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -64,27 +65,28 @@ static struct xt_match mark6_match = {
.match = match,
.matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &mark_match);
+ ret = xt_register_match(&mark_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &mark6_match);
+ ret = xt_register_match(&mark6_match);
if (ret)
- xt_unregister_match(AF_INET, &mark_match);
+ xt_unregister_match(&mark_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &mark_match);
- xt_unregister_match(AF_INET6, &mark6_match);
+ xt_unregister_match(&mark_match);
+ xt_unregister_match(&mark6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index f788e8e7625..089f4f7e863 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -121,6 +121,7 @@ static struct xt_match physdev_match = {
.match = match,
.matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -129,6 +130,7 @@ static struct xt_match physdev6_match = {
.match = match,
.matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -136,21 +138,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &physdev_match);
+ ret = xt_register_match(&physdev_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &physdev6_match);
+ ret = xt_register_match(&physdev6_match);
if (ret < 0)
- xt_unregister_match(AF_INET, &physdev_match);
+ xt_unregister_match(&physdev_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &physdev_match);
- xt_unregister_match(AF_INET6, &physdev6_match);
+ xt_unregister_match(&physdev_match);
+ xt_unregister_match(&physdev6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index f38638dfd13..8b8bca988ac 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -37,6 +37,7 @@ static struct xt_match pkttype_match = {
.name = "pkttype",
.match = match,
.matchsize = sizeof(struct xt_pkttype_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -44,27 +45,28 @@ static struct xt_match pkttype6_match = {
.name = "pkttype",
.match = match,
.matchsize = sizeof(struct xt_pkttype_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &pkttype_match);
+ ret = xt_register_match(&pkttype_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &pkttype6_match);
+ ret = xt_register_match(&pkttype6_match);
if (ret)
- xt_unregister_match(AF_INET, &pkttype_match);
+ xt_unregister_match(&pkttype_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &pkttype_match);
- xt_unregister_match(AF_INET6, &pkttype6_match);
+ xt_unregister_match(&pkttype_match);
+ xt_unregister_match(&pkttype6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c
index 1ec22082f04..1099cb005fc 100644
--- a/net/netfilter/xt_policy.c
+++ b/net/netfilter/xt_policy.c
@@ -27,9 +27,9 @@ xt_addr_cmp(const union xt_policy_addr *a1, const union xt_policy_addr *m,
{
switch (family) {
case AF_INET:
- return (a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr;
+ return !((a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr);
case AF_INET6:
- return ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
+ return !ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
}
return 0;
}
@@ -44,7 +44,7 @@ match_xfrm_state(struct xfrm_state *x, const struct xt_policy_elem *e,
#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x))
return MATCH_ADDR(saddr, smask, (union xt_policy_addr *)&x->props.saddr) &&
- MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr.a4) &&
+ MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr) &&
MATCH(proto, x->id.proto) &&
MATCH(mode, x->props.mode) &&
MATCH(spi, x->id.spi) &&
@@ -172,6 +172,7 @@ static struct xt_match policy_match = {
.match = match,
.matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -181,6 +182,7 @@ static struct xt_match policy6_match = {
.match = match,
.matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -188,19 +190,19 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &policy_match);
+ ret = xt_register_match(&policy_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &policy6_match);
+ ret = xt_register_match(&policy6_match);
if (ret)
- xt_unregister_match(AF_INET, &policy_match);
+ xt_unregister_match(&policy_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &policy6_match);
- xt_unregister_match(AF_INET, &policy_match);
+ xt_unregister_match(&policy6_match);
+ xt_unregister_match(&policy_match);
}
module_init(init);
diff --git a/net/netfilter/xt_realm.c b/net/netfilter/xt_realm.c
index 57815a07db6..5e31a4a835b 100644
--- a/net/netfilter/xt_realm.c
+++ b/net/netfilter/xt_realm.c
@@ -45,17 +45,18 @@ static struct xt_match realm_match = {
.matchsize = sizeof(struct xt_realm_info),
.hooks = (1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN),
+ .family = AF_INET,
.me = THIS_MODULE
};
static int __init init(void)
{
- return xt_register_match(AF_INET, &realm_match);
+ return xt_register_match(&realm_match);
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &realm_match);
+ xt_unregister_match(&realm_match);
}
module_init(init);
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index f5d698ba03c..c6eb24a2fe1 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -186,6 +186,7 @@ static struct xt_match sctp_match = {
.matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP,
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -195,27 +196,28 @@ static struct xt_match sctp6_match = {
.matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP,
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &sctp_match);
+ ret = xt_register_match(&sctp_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &sctp6_match);
+ ret = xt_register_match(&sctp6_match);
if (ret)
- xt_unregister_match(AF_INET, &sctp_match);
+ xt_unregister_match(&sctp_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &sctp6_match);
- xt_unregister_match(AF_INET, &sctp_match);
+ xt_unregister_match(&sctp6_match);
+ xt_unregister_match(&sctp_match);
}
module_init(init);
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c
index b8ec00cd51f..e6c0be9d94d 100644
--- a/net/netfilter/xt_state.c
+++ b/net/netfilter/xt_state.c
@@ -44,17 +44,48 @@ match(const struct sk_buff *skb,
return (sinfo->statemask & statebit);
}
+static int check(const char *tablename,
+ const void *inf,
+ const struct xt_match *match,
+ void *matchinfo,
+ unsigned int matchsize,
+ unsigned int hook_mask)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match state_match = {
.name = "state",
.match = match,
+ .checkentry = check,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_state_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match state6_match = {
.name = "state",
.match = match,
+ .checkentry = check,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_state_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -64,21 +95,21 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_match(AF_INET, &state_match);
+ ret = xt_register_match(&state_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &state6_match);
+ ret = xt_register_match(&state6_match);
if (ret < 0)
- xt_unregister_match(AF_INET,&state_match);
+ xt_unregister_match(&state_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &state_match);
- xt_unregister_match(AF_INET6, &state6_match);
+ xt_unregister_match(&state_match);
+ xt_unregister_match(&state6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_string.c b/net/netfilter/xt_string.c
index fccbad6a7f4..703d80fccac 100644
--- a/net/netfilter/xt_string.c
+++ b/net/netfilter/xt_string.c
@@ -78,6 +78,7 @@ static struct xt_match string_match = {
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry,
.destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE
};
static struct xt_match string6_match = {
@@ -86,6 +87,7 @@ static struct xt_match string6_match = {
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry,
.destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -93,20 +95,20 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &string_match);
+ ret = xt_register_match(&string_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &string6_match);
+ ret = xt_register_match(&string6_match);
if (ret)
- xt_unregister_match(AF_INET, &string_match);
+ xt_unregister_match(&string_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &string_match);
- xt_unregister_match(AF_INET6, &string6_match);
+ xt_unregister_match(&string_match);
+ xt_unregister_match(&string6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_tcpmss.c b/net/netfilter/xt_tcpmss.c
index 4925fc98f4a..70a8858ae3f 100644
--- a/net/netfilter/xt_tcpmss.c
+++ b/net/netfilter/xt_tcpmss.c
@@ -98,6 +98,7 @@ static struct xt_match tcpmss_match = {
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -106,6 +107,7 @@ static struct xt_match tcpmss6_match = {
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -113,21 +115,21 @@ static struct xt_match tcpmss6_match = {
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &tcpmss_match);
+ ret = xt_register_match(&tcpmss_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &tcpmss6_match);
+ ret = xt_register_match(&tcpmss6_match);
if (ret)
- xt_unregister_match(AF_INET, &tcpmss_match);
+ xt_unregister_match(&tcpmss_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &tcpmss6_match);
- xt_unregister_match(AF_INET, &tcpmss_match);
+ xt_unregister_match(&tcpmss6_match);
+ xt_unregister_match(&tcpmss_match);
}
module_init(init);
diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
index b5cd0dd4e41..14a990eb666 100644
--- a/net/netfilter/xt_tcpudp.c
+++ b/net/netfilter/xt_tcpudp.c
@@ -204,6 +204,7 @@ static struct xt_match tcp_matchstruct = {
.match = tcp_match,
.matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP,
+ .family = AF_INET,
.checkentry = tcp_checkentry,
.me = THIS_MODULE,
};
@@ -213,6 +214,7 @@ static struct xt_match tcp6_matchstruct = {
.match = tcp_match,
.matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP,
+ .family = AF_INET6,
.checkentry = tcp_checkentry,
.me = THIS_MODULE,
};
@@ -222,6 +224,7 @@ static struct xt_match udp_matchstruct = {
.match = udp_match,
.matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP,
+ .family = AF_INET,
.checkentry = udp_checkentry,
.me = THIS_MODULE,
};
@@ -230,6 +233,7 @@ static struct xt_match udp6_matchstruct = {
.match = udp_match,
.matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP,
+ .family = AF_INET6,
.checkentry = udp_checkentry,
.me = THIS_MODULE,
};
@@ -237,39 +241,39 @@ static struct xt_match udp6_matchstruct = {
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &tcp_matchstruct);
+ ret = xt_register_match(&tcp_matchstruct);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &tcp6_matchstruct);
+ ret = xt_register_match(&tcp6_matchstruct);
if (ret)
goto out_unreg_tcp;
- ret = xt_register_match(AF_INET, &udp_matchstruct);
+ ret = xt_register_match(&udp_matchstruct);
if (ret)
goto out_unreg_tcp6;
- ret = xt_register_match(AF_INET6, &udp6_matchstruct);
+ ret = xt_register_match(&udp6_matchstruct);
if (ret)
goto out_unreg_udp;
return ret;
out_unreg_udp:
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
out_unreg_tcp6:
- xt_unregister_match(AF_INET6, &tcp6_matchstruct);
+ xt_unregister_match(&tcp6_matchstruct);
out_unreg_tcp:
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &udp6_matchstruct);
- xt_unregister_match(AF_INET, &udp_matchstruct);
- xt_unregister_match(AF_INET6, &tcp6_matchstruct);
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&udp6_matchstruct);
+ xt_unregister_match(&udp_matchstruct);
+ xt_unregister_match(&tcp6_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
}
module_init(init);
diff --git a/net/rxrpc/main.c b/net/rxrpc/main.c
index 36fdcbcd80d..48cbd065bb4 100644
--- a/net/rxrpc/main.c
+++ b/net/rxrpc/main.c
@@ -79,8 +79,8 @@ static int __init rxrpc_initialise(void)
error_sysctl:
#ifdef CONFIG_SYSCTL
rxrpc_sysctl_cleanup();
-#endif
error_proc:
+#endif
#ifdef CONFIG_PROC_FS
rxrpc_proc_cleanup();
#endif
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 2b670479dde..78e052591fa 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -347,8 +347,7 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
if (n->ht_down)
n->ht_down->refcnt--;
#ifdef CONFIG_CLS_U32_PERF
- if (n)
- kfree(n->pf);
+ kfree(n->pf);
#endif
kfree(n);
return 0;
@@ -680,8 +679,7 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
return 0;
}
#ifdef CONFIG_CLS_U32_PERF
- if (n)
- kfree(n->pf);
+ kfree(n->pf);
#endif
kfree(n);
return err;
diff --git a/net/sctp/input.c b/net/sctp/input.c
index cb78b50868e..d117ebc75cf 100644
--- a/net/sctp/input.c
+++ b/net/sctp/input.c
@@ -127,7 +127,6 @@ int sctp_rcv(struct sk_buff *skb)
union sctp_addr dest;
int family;
struct sctp_af *af;
- int ret = 0;
if (skb->pkt_type!=PACKET_HOST)
goto discard_it;
@@ -227,16 +226,13 @@ int sctp_rcv(struct sk_buff *skb)
goto discard_release;
nf_reset(skb);
- ret = sk_filter(sk, skb, 1);
- if (ret)
+ if (sk_filter(sk, skb, 1))
goto discard_release;
/* Create an SCTP packet structure. */
chunk = sctp_chunkify(skb, asoc, sk);
- if (!chunk) {
- ret = -ENOMEM;
+ if (!chunk)
goto discard_release;
- }
SCTP_INPUT_CB(skb)->chunk = chunk;
/* Remember what endpoint is to handle this packet. */
@@ -277,11 +273,11 @@ int sctp_rcv(struct sk_buff *skb)
sctp_bh_unlock_sock(sk);
sock_put(sk);
- return ret;
+ return 0;
discard_it:
kfree_skb(skb);
- return ret;
+ return 0;
discard_release:
/* Release any structures we may be holding. */
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 0ea947eb681..b6e4b89539b 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4894,6 +4894,8 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
/* Is there any exceptional events? */
if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue))
mask |= POLLERR;
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ mask |= POLLRDHUP;
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
diff --git a/net/socket.c b/net/socket.c
index e2d5bae994d..5211ba27037 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -319,7 +319,8 @@ static int init_inodecache(void)
{
sock_inode_cachep = kmem_cache_create("sock_inode_cache",
sizeof(struct socket_alloc),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
+ 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
init_once, NULL);
if (sock_inode_cachep == NULL)
return -ENOMEM;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index a5c0c7b6e15..ad9d9fc4e73 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -849,9 +849,10 @@ init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
int register_rpc_pipefs(void)
{
rpc_inode_cachep = kmem_cache_create("rpc_inode_cache",
- sizeof(struct rpc_inode),
- 0, SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
- init_once, NULL);
+ sizeof(struct rpc_inode),
+ 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|
+ SLAB_MEM_SPREAD),
+ init_once, NULL);
if (!rpc_inode_cachep)
return -ENOMEM;
register_filesystem(&rpc_pipe_fs_type);
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 910b37e5083..784b24b6d10 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -1629,7 +1629,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
tipc_msg_print(TIPC_CONS, buf_msg(buf), ">RETR>");
info("...Retransmitted %u times\n",
l_ptr->stale_count);
- link_print(l_ptr, TIPC_CONS, "Resetting Link\n");;
+ link_print(l_ptr, TIPC_CONS, "Resetting Link\n");
tipc_link_reset(l_ptr);
break;
}
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 2b4cc2eea5b..d901465ce01 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1878,6 +1878,8 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
mask |= POLLERR;
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ mask |= POLLRDHUP;
/* readable? */
if (!skb_queue_empty(&sk->sk_receive_queue) ||
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0168d6c3707..59620b1554e 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -44,6 +44,43 @@ define filechk
fi
endef
+######
+# gcc support functions
+# See documentation in Documentation/kbuild/makefiles.txt
+
+# as-option
+# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
+
+as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
+ -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
+ else echo "$(2)"; fi ;)
+
+# cc-option
+# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
+
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+# cc-option-yn
+# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
+cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+ > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
+
+# cc-option-align
+# Prefix align with either -falign or -malign
+cc-option-align = $(subst -functions=0,,\
+ $(call cc-option,-falign-functions=0,-malign-functions=0))
+
+# cc-version
+# Usage gcc-ver := $(call cc-version, $(CC))
+cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
+ $(if $(1), $(1), $(CC)))
+
+# cc-ifversion
+# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
+cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
+ echo $(3); fi;)
+
###
# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
# Usage:
@@ -51,8 +88,7 @@ endef
build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
# If quiet is set, only print short version of command
-cmd = @$(if $($(quiet)cmd_$(1)),\
- echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
+cmd = @$(echo-cmd) $(cmd_$(1))
# Add $(obj)/ for paths that is not absolute
objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -75,30 +111,33 @@ endif
echo-cmd = $(if $($(quiet)cmd_$(1)), \
echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
+make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
+
# function to only execute the passed command if necessary
# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
-#
-if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
+#
+if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
+ $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
@set -e; \
- $(echo-cmd) \
- $(cmd_$(1)); \
- echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
+ $(echo-cmd) $(cmd_$(1)); \
+ echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
# execute the command and also postprocess generated .d dependencies
# file
-if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\
- $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
+if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
+ $(filter-out FORCE $(wildcard $^),$^) \
+ $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
@set -e; \
- $(echo-cmd) \
- $(cmd_$(1)); \
- scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
+ $(echo-cmd) $(cmd_$(1)); \
+ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
rm -f $(depfile); \
mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
# Usage: $(call if_changed_rule,foo)
# will check if $(cmd_foo) changed, or any of the prequisites changed,
# and if so will execute $(rule_foo)
-if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
+if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
+ $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
@set -e; \
$(rule_$(1)))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index c33e62bde6b..e48e60da304 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -4,17 +4,18 @@
src := $(obj)
-.PHONY: __build
+PHONY := __build
__build:
# Read .config if it exist, otherwise ignore
-include .config
+include scripts/Kbuild.include
+
# The filename Kbuild has precedence over Makefile
kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
-include scripts/Kbuild.include
include scripts/Makefile.lib
ifdef host-progs
@@ -128,7 +129,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi)
$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
-cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $<
+cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
%.s: %.c FORCE
$(call if_changed_dep,cc_s_c)
@@ -165,7 +166,7 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
cmd_modversions = \
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
$(CPP) -D__GENKSYMS__ $(c_flags) $< \
- | $(GENKSYMS) \
+ | $(GENKSYMS) -a $(ARCH) \
> $(@D)/.tmp_$(@F:.o=.ver); \
\
$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
@@ -177,12 +178,10 @@ cmd_modversions = \
endif
define rule_cc_o_c
- $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \
- $(cmd_checksrc) \
- $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \
- $(cmd_cc_o_c); \
+ $(call echo-cmd,checksrc) $(cmd_checksrc) \
+ $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
$(cmd_modversions) \
- scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \
+ scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \
rm -f $(depfile); \
mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
endef
@@ -309,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m)
# Descending
# ---------------------------------------------------------------------------
-.PHONY: $(subdir-ym)
+PHONY += $(subdir-ym)
$(subdir-ym):
$(Q)$(MAKE) $(build)=$@
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
-.PHONY: FORCE
+PHONY += FORCE
FORCE:
@@ -331,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),)
include $(cmd_files)
endif
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 8974ea5fc87..cff33498fa1 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -4,7 +4,7 @@
src := $(obj)
-.PHONY: __clean
+PHONY := __clean
__clean:
# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@@ -87,10 +87,16 @@ endif
# Descending
# ---------------------------------------------------------------------------
-.PHONY: $(subdir-ymn)
+PHONY += $(subdir-ymn)
$(subdir-ymn):
$(Q)$(MAKE) $(clean)=$@
# If quiet is set, only print short version of command
cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 23fd1bdc25c..2686dd5dce8 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -2,7 +2,7 @@
# Installing modules
# ==========================================================================
-.PHONY: __modinst
+PHONY := __modinst
__modinst:
include scripts/Kbuild.include
@@ -12,7 +12,7 @@ include scripts/Kbuild.include
__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
-.PHONY: $(modules)
+PHONY += $(modules)
__modinst: $(modules)
@:
@@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
$(modules):
$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index bf96a61d4b8..0e056cffffd 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -4,7 +4,7 @@
#
# Stage one of module building created the following:
# a) The individual .o files used for the module
-# b) A <module>.o file wich is the .o files above linked together
+# b) A <module>.o file which is the .o files above linked together
# c) A <module>.mod file in $(MODVERDIR)/, listing the name of the
# the preliminary <module>.o file, plus all .o files
@@ -32,14 +32,15 @@
# Step 4 is solely used to allow module versioning in external modules,
# where the CRC of each module is retrieved from the Module.symers file.
-.PHONY: _modpost
+PHONY := _modpost
_modpost: __modpost
include .config
include scripts/Kbuild.include
include scripts/Makefile.lib
-symverfile := $(objtree)/Module.symvers
+kernelsymfile := $(objtree)/Module.symvers
+modulesymfile := $(KBUILD_EXTMOD)/Modules.symvers
# Step 1), find all modules listed in $(MODVERDIR)/
__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
@@ -54,10 +55,12 @@ quiet_cmd_modpost = MODPOST
cmd_modpost = scripts/mod/modpost \
$(if $(CONFIG_MODVERSIONS),-m) \
$(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
- $(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \
+ $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
+ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
+ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
$(filter-out FORCE,$^)
-.PHONY: __modpost
+PHONY += __modpost
__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
$(call cmd,modpost)
@@ -94,7 +97,7 @@ targets += $(modules)
# Add FORCE to the prequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------
-.PHONY: FORCE
+PHONY += FORCE
FORCE:
@@ -109,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
ifneq ($(cmd_files),)
include $(cmd_files)
endif
+
+
+# Declare the contents of the .PHONY variable as phony. We keep that
+# information in a variable se we can use it in if_changed and friends.
+
+.PHONY: $(PHONY)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 679124b11e1..668a11a8b38 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -132,20 +132,10 @@ void usage(void)
/*
* Print out the commandline prefixed with cmd_<target filename> :=
- * If commandline contains '#' escape with '\' so make to not see
- * the '#' as a start-of-comment symbol
- **/
+ */
void print_cmdline(void)
{
- char *p = cmdline;
-
- printf("cmd_%s := ", target);
- for (; *p; p++) {
- if (*p == '#')
- printf("\\");
- printf("%c", *p);
- }
- printf("\n\n");
+ printf("cmd_%s := %s\n\n", target, cmdline);
}
char * str_config = NULL;
diff --git a/scripts/checkconfig.pl b/scripts/checkconfig.pl
deleted file mode 100755
index ca1f231b15a..00000000000
--- a/scripts/checkconfig.pl
+++ /dev/null
@@ -1,65 +0,0 @@
-#! /usr/bin/perl
-#
-# checkconfig: find uses of CONFIG_* names without matching definitions.
-# Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
-
-use integer;
-
-$| = 1;
-
-foreach $file (@ARGV)
-{
- # Open this file.
- open(FILE, $file) || die "Can't open $file: $!\n";
-
- # Initialize variables.
- my $fInComment = 0;
- my $fInString = 0;
- my $fUseConfig = 0;
- my $iLinuxConfig = 0;
- my %configList = ();
-
- LINE: while ( <FILE> )
- {
- # Strip comments.
- $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
- m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
-
- # Pick up definitions.
- if ( m/^\s*#/o )
- {
- $iLinuxConfig = $. if m/^\s*#\s*include\s*"linux\/config\.h"/o;
- $configList{uc $1} = 1 if m/^\s*#\s*include\s*"config\/(\S*)\.h"/o;
- }
-
- # Strip strings.
- $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
- m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
-
- # Pick up definitions.
- if ( m/^\s*#/o )
- {
- $iLinuxConfig = $. if m/^\s*#\s*include\s*<linux\/config\.h>/o;
- $configList{uc $1} = 1 if m/^\s*#\s*include\s*<config\/(\S*)\.h>/o;
- $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o;
- $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o;
- }
-
- # Look for usages.
- next unless m/CONFIG_/o;
- WORD: while ( m/\bCONFIG_(\w+)/og )
- {
- $fUseConfig = 1;
- last LINE if $iLinuxConfig;
- next WORD if exists $configList{$1};
- print "$file: $.: need CONFIG_$1.\n";
- $configList{$1} = 0;
- }
- }
-
- # Report superfluous includes.
- if ( $iLinuxConfig && ! $fUseConfig )
- { print "$file: $iLinuxConfig: linux/config.h not needed.\n"; }
-
- close(FILE);
-}
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig
index d9f9f34b22a..8187e6f0dc2 100755
--- a/scripts/extract-ikconfig
+++ b/scripts/extract-ikconfig
@@ -4,6 +4,7 @@
# $arg1 is [b]zImage filename
binoffset="./scripts/binoffset"
+test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
@@ -20,7 +21,7 @@ function dump_config {
let start="$start + 8"
let size="$end - $start"
- head --bytes="$end" "$file" | tail --bytes="$size" | zcat
+ dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
clean_up
exit 0
@@ -45,7 +46,7 @@ then
exit 1
fi
-TMPFILE="/tmp/ikconfig-$$"
+TMPFILE=`mktemp -t ikconfig-XXXXXX` || exit 1
image="$1"
# vmlinux: Attempt to dump the configuration from the file directly
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 416a694b099..5b0344e20d6 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -29,481 +29,421 @@
#include <stdarg.h>
#ifdef __GNU_LIBRARY__
#include <getopt.h>
-#endif /* __GNU_LIBRARY__ */
+#endif /* __GNU_LIBRARY__ */
#include "genksyms.h"
-
/*----------------------------------------------------------------------*/
#define HASH_BUCKETS 4096
static struct symbol *symtab[HASH_BUCKETS];
-FILE *debugfile;
+static FILE *debugfile;
int cur_line = 1;
-char *cur_filename, *output_directory;
+char *cur_filename;
-int flag_debug, flag_dump_defs, flag_warnings;
+static int flag_debug, flag_dump_defs, flag_warnings;
+static const char *arch = "";
+static const char *mod_prefix = "";
static int errors;
static int nsyms;
static struct symbol *expansion_trail;
-static const char * const symbol_type_name[] = {
- "normal", "typedef", "enum", "struct", "union"
+static const char *const symbol_type_name[] = {
+ "normal", "typedef", "enum", "struct", "union"
};
+static int equal_list(struct string_list *a, struct string_list *b);
+static void print_list(FILE * f, struct string_list *list);
+
/*----------------------------------------------------------------------*/
-static const unsigned int crctab32[] =
-{
- 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
- 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
- 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
- 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
- 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
- 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
- 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
- 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
- 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U,
- 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU,
- 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U,
- 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U,
- 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U,
- 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU,
- 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU,
- 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U,
- 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU,
- 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U,
- 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U,
- 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U,
- 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU,
- 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U,
- 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U,
- 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU,
- 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U,
- 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U,
- 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U,
- 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U,
- 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U,
- 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU,
- 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU,
- 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U,
- 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U,
- 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU,
- 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU,
- 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U,
- 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU,
- 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U,
- 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU,
- 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U,
- 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU,
- 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U,
- 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U,
- 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU,
- 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U,
- 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U,
- 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U,
- 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U,
- 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U,
- 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U,
- 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU,
- 0x2d02ef8dU
+static const unsigned int crctab32[] = {
+ 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
+ 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
+ 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
+ 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
+ 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
+ 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
+ 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
+ 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
+ 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U,
+ 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU,
+ 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U,
+ 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U,
+ 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U,
+ 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU,
+ 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU,
+ 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U,
+ 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU,
+ 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U,
+ 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U,
+ 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U,
+ 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU,
+ 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U,
+ 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U,
+ 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU,
+ 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U,
+ 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U,
+ 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U,
+ 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U,
+ 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U,
+ 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU,
+ 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU,
+ 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U,
+ 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U,
+ 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU,
+ 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU,
+ 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U,
+ 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU,
+ 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U,
+ 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU,
+ 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U,
+ 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU,
+ 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U,
+ 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U,
+ 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU,
+ 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U,
+ 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U,
+ 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U,
+ 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U,
+ 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U,
+ 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U,
+ 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU,
+ 0x2d02ef8dU
};
-static inline unsigned long
-partial_crc32_one(unsigned char c, unsigned long crc)
+static unsigned long partial_crc32_one(unsigned char c, unsigned long crc)
{
- return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
+ return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
}
-static inline unsigned long
-partial_crc32(const char *s, unsigned long crc)
+static unsigned long partial_crc32(const char *s, unsigned long crc)
{
- while (*s)
- crc = partial_crc32_one(*s++, crc);
- return crc;
+ while (*s)
+ crc = partial_crc32_one(*s++, crc);
+ return crc;
}
-static inline unsigned long
-crc32(const char *s)
+static unsigned long crc32(const char *s)
{
- return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
+ return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
}
-
/*----------------------------------------------------------------------*/
-static inline enum symbol_type
-map_to_ns(enum symbol_type t)
+static enum symbol_type map_to_ns(enum symbol_type t)
{
- if (t == SYM_TYPEDEF)
- t = SYM_NORMAL;
- else if (t == SYM_UNION)
- t = SYM_STRUCT;
- return t;
+ if (t == SYM_TYPEDEF)
+ t = SYM_NORMAL;
+ else if (t == SYM_UNION)
+ t = SYM_STRUCT;
+ return t;
}
-struct symbol *
-find_symbol(const char *name, enum symbol_type ns)
+struct symbol *find_symbol(const char *name, enum symbol_type ns)
{
- unsigned long h = crc32(name) % HASH_BUCKETS;
- struct symbol *sym;
+ unsigned long h = crc32(name) % HASH_BUCKETS;
+ struct symbol *sym;
- for (sym = symtab[h]; sym ; sym = sym->hash_next)
- if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0)
- break;
+ for (sym = symtab[h]; sym; sym = sym->hash_next)
+ if (map_to_ns(sym->type) == map_to_ns(ns) &&
+ strcmp(name, sym->name) == 0)
+ break;
- return sym;
+ return sym;
}
-struct symbol *
-add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern)
+struct symbol *add_symbol(const char *name, enum symbol_type type,
+ struct string_list *defn, int is_extern)
{
- unsigned long h = crc32(name) % HASH_BUCKETS;
- struct symbol *sym;
-
- for (sym = symtab[h]; sym ; sym = sym->hash_next)
- if (map_to_ns(sym->type) == map_to_ns(type)
- && strcmp(name, sym->name) == 0)
- {
- if (!equal_list(sym->defn, defn))
- error_with_pos("redefinition of %s", name);
+ unsigned long h = crc32(name) % HASH_BUCKETS;
+ struct symbol *sym;
+
+ for (sym = symtab[h]; sym; sym = sym->hash_next) {
+ if (map_to_ns(sym->type) == map_to_ns(type)
+ && strcmp(name, sym->name) == 0) {
+ if (!equal_list(sym->defn, defn))
+ error_with_pos("redefinition of %s", name);
+ return sym;
+ }
+ }
+
+ sym = xmalloc(sizeof(*sym));
+ sym->name = name;
+ sym->type = type;
+ sym->defn = defn;
+ sym->expansion_trail = NULL;
+ sym->is_extern = is_extern;
+
+ sym->hash_next = symtab[h];
+ symtab[h] = sym;
+
+ if (flag_debug) {
+ fprintf(debugfile, "Defn for %s %s == <",
+ symbol_type_name[type], name);
+ if (is_extern)
+ fputs("extern ", debugfile);
+ print_list(debugfile, defn);
+ fputs(">\n", debugfile);
+ }
+
+ ++nsyms;
return sym;
- }
-
- sym = xmalloc(sizeof(*sym));
- sym->name = name;
- sym->type = type;
- sym->defn = defn;
- sym->expansion_trail = NULL;
- sym->is_extern = is_extern;
-
- sym->hash_next = symtab[h];
- symtab[h] = sym;
-
- if (flag_debug)
- {
- fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name);
- if (is_extern)
- fputs("extern ", debugfile);
- print_list(debugfile, defn);
- fputs(">\n", debugfile);
- }
-
- ++nsyms;
- return sym;
}
-
/*----------------------------------------------------------------------*/
-inline void
-free_node(struct string_list *node)
+void free_node(struct string_list *node)
{
- free(node->string);
- free(node);
+ free(node->string);
+ free(node);
}
-void
-free_list(struct string_list *s, struct string_list *e)
+void free_list(struct string_list *s, struct string_list *e)
{
- while (s != e)
- {
- struct string_list *next = s->next;
- free_node(s);
- s = next;
- }
+ while (s != e) {
+ struct string_list *next = s->next;
+ free_node(s);
+ s = next;
+ }
}
-inline struct string_list *
-copy_node(struct string_list *node)
+struct string_list *copy_node(struct string_list *node)
{
- struct string_list *newnode;
+ struct string_list *newnode;
- newnode = xmalloc(sizeof(*newnode));
- newnode->string = xstrdup(node->string);
- newnode->tag = node->tag;
+ newnode = xmalloc(sizeof(*newnode));
+ newnode->string = xstrdup(node->string);
+ newnode->tag = node->tag;
- return newnode;
+ return newnode;
}
-struct string_list *
-copy_list(struct string_list *s, struct string_list *e)
+static int equal_list(struct string_list *a, struct string_list *b)
{
- struct string_list *h, *p;
-
- if (s == e)
- return NULL;
-
- p = h = copy_node(s);
- while ((s = s->next) != e)
- p = p->next = copy_node(s);
- p->next = NULL;
-
- return h;
-}
+ while (a && b) {
+ if (a->tag != b->tag || strcmp(a->string, b->string))
+ return 0;
+ a = a->next;
+ b = b->next;
+ }
-int
-equal_list(struct string_list *a, struct string_list *b)
-{
- while (a && b)
- {
- if (a->tag != b->tag || strcmp(a->string, b->string))
- return 0;
- a = a->next;
- b = b->next;
- }
-
- return !a && !b;
+ return !a && !b;
}
-static inline void
-print_node(FILE *f, struct string_list *list)
+static void print_node(FILE * f, struct string_list *list)
{
- switch (list->tag)
- {
- case SYM_STRUCT:
- putc('s', f);
- goto printit;
- case SYM_UNION:
- putc('u', f);
- goto printit;
- case SYM_ENUM:
- putc('e', f);
- goto printit;
- case SYM_TYPEDEF:
- putc('t', f);
- goto printit;
-
- printit:
- putc('#', f);
- case SYM_NORMAL:
- fputs(list->string, f);
- break;
- }
-}
+ switch (list->tag) {
+ case SYM_STRUCT:
+ putc('s', f);
+ goto printit;
+ case SYM_UNION:
+ putc('u', f);
+ goto printit;
+ case SYM_ENUM:
+ putc('e', f);
+ goto printit;
+ case SYM_TYPEDEF:
+ putc('t', f);
+ goto printit;
-void
-print_list(FILE *f, struct string_list *list)
-{
- struct string_list **e, **b;
- struct string_list *tmp, **tmp2;
- int elem = 1;
-
- if (list == NULL)
- {
- fputs("(nil)", f);
- return;
- }
-
- tmp = list;
- while((tmp = tmp->next) != NULL)
- elem++;
-
- b = alloca(elem * sizeof(*e));
- e = b + elem;
- tmp2 = e - 1;
-
- (*tmp2--) = list;
- while((list = list->next) != NULL)
- *(tmp2--) = list;
-
- while (b != e)
- {
- print_node(f, *b++);
- putc(' ', f);
- }
+ printit:
+ putc('#', f);
+ case SYM_NORMAL:
+ fputs(list->string, f);
+ break;
+ }
}
-static unsigned long
-expand_and_crc_list(struct string_list *list, unsigned long crc)
+static void print_list(FILE * f, struct string_list *list)
{
- struct string_list **e, **b;
- struct string_list *tmp, **tmp2;
- int elem = 1;
-
- if (!list)
- return crc;
+ struct string_list **e, **b;
+ struct string_list *tmp, **tmp2;
+ int elem = 1;
- tmp = list;
- while((tmp = tmp->next) != NULL)
- elem++;
-
- b = alloca(elem * sizeof(*e));
- e = b + elem;
- tmp2 = e - 1;
+ if (list == NULL) {
+ fputs("(nil)", f);
+ return;
+ }
- *(tmp2--) = list;
- while ((list = list->next) != NULL)
- *(tmp2--) = list;
+ tmp = list;
+ while ((tmp = tmp->next) != NULL)
+ elem++;
- while (b != e)
- {
- struct string_list *cur;
- struct symbol *subsym;
+ b = alloca(elem * sizeof(*e));
+ e = b + elem;
+ tmp2 = e - 1;
- cur = *(b++);
- switch (cur->tag)
- {
- case SYM_NORMAL:
- if (flag_dump_defs)
- fprintf(debugfile, "%s ", cur->string);
- crc = partial_crc32(cur->string, crc);
- crc = partial_crc32_one(' ', crc);
- break;
+ (*tmp2--) = list;
+ while ((list = list->next) != NULL)
+ *(tmp2--) = list;
- case SYM_TYPEDEF:
- subsym = find_symbol(cur->string, cur->tag);
- if (subsym->expansion_trail)
- {
- if (flag_dump_defs)
- fprintf(debugfile, "%s ", cur->string);
- crc = partial_crc32(cur->string, crc);
- crc = partial_crc32_one(' ', crc);
- }
- else
- {
- subsym->expansion_trail = expansion_trail;
- expansion_trail = subsym;
- crc = expand_and_crc_list(subsym->defn, crc);
- }
- break;
+ while (b != e) {
+ print_node(f, *b++);
+ putc(' ', f);
+ }
+}
- case SYM_STRUCT:
- case SYM_UNION:
- case SYM_ENUM:
- subsym = find_symbol(cur->string, cur->tag);
- if (!subsym)
- {
- struct string_list *n, *t = NULL;
-
- error_with_pos("expand undefined %s %s",
- symbol_type_name[cur->tag], cur->string);
-
- n = xmalloc(sizeof(*n));
- n->string = xstrdup(symbol_type_name[cur->tag]);
- n->tag = SYM_NORMAL;
- n->next = t;
- t = n;
-
- n = xmalloc(sizeof(*n));
- n->string = xstrdup(cur->string);
- n->tag = SYM_NORMAL;
- n->next = t;
- t = n;
-
- n = xmalloc(sizeof(*n));
- n->string = xstrdup("{ UNKNOWN }");
- n->tag = SYM_NORMAL;
- n->next = t;
-
- subsym = add_symbol(cur->string, cur->tag, n, 0);
- }
- if (subsym->expansion_trail)
- {
- if (flag_dump_defs)
- {
- fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag],
- cur->string);
+static unsigned long expand_and_crc_list(struct string_list *list,
+ unsigned long crc)
+{
+ struct string_list **e, **b;
+ struct string_list *tmp, **tmp2;
+ int elem = 1;
+
+ if (!list)
+ return crc;
+
+ tmp = list;
+ while ((tmp = tmp->next) != NULL)
+ elem++;
+
+ b = alloca(elem * sizeof(*e));
+ e = b + elem;
+ tmp2 = e - 1;
+
+ *(tmp2--) = list;
+ while ((list = list->next) != NULL)
+ *(tmp2--) = list;
+
+ while (b != e) {
+ struct string_list *cur;
+ struct symbol *subsym;
+
+ cur = *(b++);
+ switch (cur->tag) {
+ case SYM_NORMAL:
+ if (flag_dump_defs)
+ fprintf(debugfile, "%s ", cur->string);
+ crc = partial_crc32(cur->string, crc);
+ crc = partial_crc32_one(' ', crc);
+ break;
+
+ case SYM_TYPEDEF:
+ subsym = find_symbol(cur->string, cur->tag);
+ if (subsym->expansion_trail) {
+ if (flag_dump_defs)
+ fprintf(debugfile, "%s ", cur->string);
+ crc = partial_crc32(cur->string, crc);
+ crc = partial_crc32_one(' ', crc);
+ } else {
+ subsym->expansion_trail = expansion_trail;
+ expansion_trail = subsym;
+ crc = expand_and_crc_list(subsym->defn, crc);
+ }
+ break;
+
+ case SYM_STRUCT:
+ case SYM_UNION:
+ case SYM_ENUM:
+ subsym = find_symbol(cur->string, cur->tag);
+ if (!subsym) {
+ struct string_list *n, *t = NULL;
+
+ error_with_pos("expand undefined %s %s",
+ symbol_type_name[cur->tag],
+ cur->string);
+
+ n = xmalloc(sizeof(*n));
+ n->string = xstrdup(symbol_type_name[cur->tag]);
+ n->tag = SYM_NORMAL;
+ n->next = t;
+ t = n;
+
+ n = xmalloc(sizeof(*n));
+ n->string = xstrdup(cur->string);
+ n->tag = SYM_NORMAL;
+ n->next = t;
+ t = n;
+
+ n = xmalloc(sizeof(*n));
+ n->string = xstrdup("{ UNKNOWN }");
+ n->tag = SYM_NORMAL;
+ n->next = t;
+
+ subsym =
+ add_symbol(cur->string, cur->tag, n, 0);
+ }
+ if (subsym->expansion_trail) {
+ if (flag_dump_defs) {
+ fprintf(debugfile, "%s %s ",
+ symbol_type_name[cur->tag],
+ cur->string);
+ }
+
+ crc = partial_crc32(symbol_type_name[cur->tag],
+ crc);
+ crc = partial_crc32_one(' ', crc);
+ crc = partial_crc32(cur->string, crc);
+ crc = partial_crc32_one(' ', crc);
+ } else {
+ subsym->expansion_trail = expansion_trail;
+ expansion_trail = subsym;
+ crc = expand_and_crc_list(subsym->defn, crc);
+ }
+ break;
}
-
- crc = partial_crc32(symbol_type_name[cur->tag], crc);
- crc = partial_crc32_one(' ', crc);
- crc = partial_crc32(cur->string, crc);
- crc = partial_crc32_one(' ', crc);
- }
- else
- {
- subsym->expansion_trail = expansion_trail;
- expansion_trail = subsym;
- crc = expand_and_crc_list(subsym->defn, crc);
- }
- break;
}
- }
- return crc;
+ return crc;
}
-void
-export_symbol(const char *name)
+void export_symbol(const char *name)
{
- struct symbol *sym;
+ struct symbol *sym;
- sym = find_symbol(name, SYM_NORMAL);
- if (!sym)
- error_with_pos("export undefined symbol %s", name);
- else
- {
- unsigned long crc;
+ sym = find_symbol(name, SYM_NORMAL);
+ if (!sym)
+ error_with_pos("export undefined symbol %s", name);
+ else {
+ unsigned long crc;
- if (flag_dump_defs)
- fprintf(debugfile, "Export %s == <", name);
+ if (flag_dump_defs)
+ fprintf(debugfile, "Export %s == <", name);
- expansion_trail = (struct symbol *)-1L;
+ expansion_trail = (struct symbol *)-1L;
- crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
+ crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
- sym = expansion_trail;
- while (sym != (struct symbol *)-1L)
- {
- struct symbol *n = sym->expansion_trail;
- sym->expansion_trail = 0;
- sym = n;
- }
+ sym = expansion_trail;
+ while (sym != (struct symbol *)-1L) {
+ struct symbol *n = sym->expansion_trail;
+ sym->expansion_trail = 0;
+ sym = n;
+ }
- if (flag_dump_defs)
- fputs(">\n", debugfile);
+ if (flag_dump_defs)
+ fputs(">\n", debugfile);
- /* Used as a linker script. */
- printf("__crc_%s = 0x%08lx ;\n", name, crc);
- }
+ /* Used as a linker script. */
+ printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc);
+ }
}
/*----------------------------------------------------------------------*/
-
-void
-error(const char *fmt, ...)
-{
- va_list args;
-
- if (flag_warnings)
- {
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- putc('\n', stderr);
-
- errors++;
- }
-}
-
-void
-error_with_pos(const char *fmt, ...)
+void error_with_pos(const char *fmt, ...)
{
- va_list args;
+ va_list args;
- if (flag_warnings)
- {
- fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line);
+ if (flag_warnings) {
+ fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>",
+ cur_line);
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- putc('\n', stderr);
+ va_start(args, fmt);
+ vfprintf(stderr, fmt, args);
+ va_end(args);
+ putc('\n', stderr);
- errors++;
- }
+ errors++;
+ }
}
-
-void genksyms_usage(void)
+static void genksyms_usage(void)
{
- fputs("Usage:\n"
- "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n"
- "\n"
+ fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
#ifdef __GNU_LIBRARY__
" -d, --debug Increment the debug level (repeatable)\n"
" -D, --dump Dump expanded symbol defs (for debugging only)\n"
@@ -511,81 +451,84 @@ void genksyms_usage(void)
" -q, --quiet Disable warnings (default)\n"
" -h, --help Print this message\n"
" -V, --version Print the release version\n"
-#else /* __GNU_LIBRARY__ */
- " -d Increment the debug level (repeatable)\n"
- " -D Dump expanded symbol defs (for debugging only)\n"
- " -w Enable warnings\n"
- " -q Disable warnings (default)\n"
- " -h Print this message\n"
- " -V Print the release version\n"
-#endif /* __GNU_LIBRARY__ */
+#else /* __GNU_LIBRARY__ */
+ " -d Increment the debug level (repeatable)\n"
+ " -D Dump expanded symbol defs (for debugging only)\n"
+ " -w Enable warnings\n"
+ " -q Disable warnings (default)\n"
+ " -h Print this message\n"
+ " -V Print the release version\n"
+#endif /* __GNU_LIBRARY__ */
, stderr);
}
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
- int o;
+ int o;
#ifdef __GNU_LIBRARY__
- struct option long_opts[] = {
- {"debug", 0, 0, 'd'},
- {"warnings", 0, 0, 'w'},
- {"quiet", 0, 0, 'q'},
- {"dump", 0, 0, 'D'},
- {"version", 0, 0, 'V'},
- {"help", 0, 0, 'h'},
- {0, 0, 0, 0}
- };
-
- while ((o = getopt_long(argc, argv, "dwqVDk:p:",
- &long_opts[0], NULL)) != EOF)
-#else /* __GNU_LIBRARY__ */
- while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF)
-#endif /* __GNU_LIBRARY__ */
- switch (o)
- {
- case 'd':
- flag_debug++;
- break;
- case 'w':
- flag_warnings = 1;
- break;
- case 'q':
- flag_warnings = 0;
- break;
- case 'V':
- fputs("genksyms version 2.5.60\n", stderr);
- break;
- case 'D':
- flag_dump_defs = 1;
- break;
- case 'h':
- genksyms_usage();
- return 0;
- default:
- genksyms_usage();
- return 1;
- }
-
- {
- extern int yydebug;
- extern int yy_flex_debug;
-
- yydebug = (flag_debug > 1);
- yy_flex_debug = (flag_debug > 2);
-
- debugfile = stderr;
- /* setlinebuf(debugfile); */
- }
-
- yyparse();
-
- if (flag_debug)
- {
- fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
- nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS);
- }
-
- return errors != 0;
+ struct option long_opts[] = {
+ {"arch", 1, 0, 'a'},
+ {"debug", 0, 0, 'd'},
+ {"warnings", 0, 0, 'w'},
+ {"quiet", 0, 0, 'q'},
+ {"dump", 0, 0, 'D'},
+ {"version", 0, 0, 'V'},
+ {"help", 0, 0, 'h'},
+ {0, 0, 0, 0}
+ };
+
+ while ((o = getopt_long(argc, argv, "a:dwqVDk:p:",
+ &long_opts[0], NULL)) != EOF)
+#else /* __GNU_LIBRARY__ */
+ while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF)
+#endif /* __GNU_LIBRARY__ */
+ switch (o) {
+ case 'a':
+ arch = optarg;
+ break;
+ case 'd':
+ flag_debug++;
+ break;
+ case 'w':
+ flag_warnings = 1;
+ break;
+ case 'q':
+ flag_warnings = 0;
+ break;
+ case 'V':
+ fputs("genksyms version 2.5.60\n", stderr);
+ break;
+ case 'D':
+ flag_dump_defs = 1;
+ break;
+ case 'h':
+ genksyms_usage();
+ return 0;
+ default:
+ genksyms_usage();
+ return 1;
+ }
+ if ((strcmp(arch, "v850") == 0) || (strcmp(arch, "h8300") == 0))
+ mod_prefix = "_";
+ {
+ extern int yydebug;
+ extern int yy_flex_debug;
+
+ yydebug = (flag_debug > 1);
+ yy_flex_debug = (flag_debug > 2);
+
+ debugfile = stderr;
+ /* setlinebuf(debugfile); */
+ }
+
+ yyparse();
+
+ if (flag_debug) {
+ fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
+ nsyms, HASH_BUCKETS,
+ (double)nsyms / (double)HASH_BUCKETS);
+ }
+
+ return errors != 0;
}
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index f09af47ab28..ab6f34f3873 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -20,74 +20,51 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
#ifndef MODUTILS_GENKSYMS_H
#define MODUTILS_GENKSYMS_H 1
#include <stdio.h>
-
-enum symbol_type
-{
- SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
+enum symbol_type {
+ SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
};
-struct string_list
-{
- struct string_list *next;
- enum symbol_type tag;
- char *string;
+struct string_list {
+ struct string_list *next;
+ enum symbol_type tag;
+ char *string;
};
-struct symbol
-{
- struct symbol *hash_next;
- const char *name;
- enum symbol_type type;
- struct string_list *defn;
- struct symbol *expansion_trail;
- int is_extern;
+struct symbol {
+ struct symbol *hash_next;
+ const char *name;
+ enum symbol_type type;
+ struct string_list *defn;
+ struct symbol *expansion_trail;
+ int is_extern;
};
typedef struct string_list **yystype;
#define YYSTYPE yystype
-extern FILE *outfile, *debugfile;
-
extern int cur_line;
-extern char *cur_filename, *output_directory;
-
-extern int flag_debug, flag_dump_defs, flag_warnings;
-extern int checksum_version, kernel_version;
-
-extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
-extern struct string_list *current_list, *next_list;
-
+extern char *cur_filename;
struct symbol *find_symbol(const char *name, enum symbol_type ns);
struct symbol *add_symbol(const char *name, enum symbol_type type,
- struct string_list *defn, int is_extern);
+ struct string_list *defn, int is_extern);
void export_symbol(const char *);
-struct string_list *reset_list(void);
-void free_list(struct string_list *s, struct string_list *e);
void free_node(struct string_list *list);
+void free_list(struct string_list *s, struct string_list *e);
struct string_list *copy_node(struct string_list *);
-struct string_list *copy_list(struct string_list *s, struct string_list *e);
-int equal_list(struct string_list *a, struct string_list *b);
-void print_list(FILE *, struct string_list *list);
int yylex(void);
int yyparse(void);
void error_with_pos(const char *, ...);
-#define version(a,b,c) ((a << 16) | (b << 8) | (c))
-
/*----------------------------------------------------------------------*/
-
-#define MODUTILS_VERSION "<in-kernel>"
-
#define xmalloc(size) ({ void *__ptr = malloc(size); \
if(!__ptr && size != 0) { \
fprintf(stderr, "out of memory\n"); \
@@ -101,4 +78,4 @@ void error_with_pos(const char *, ...);
} \
__str; })
-#endif /* genksyms.h */
+#endif /* genksyms.h */
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index d591578bd3b..22d281c6ec2 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -124,6 +124,11 @@ static int read_symbol(FILE *in, struct sym_entry *s)
* compressed together */
s->len = strlen(str) + 1;
s->sym = malloc(s->len + 1);
+ if (!s->sym) {
+ fprintf(stderr, "kallsyms failure: "
+ "unable to allocate required amount of memory\n");
+ exit(EXIT_FAILURE);
+ }
strcpy((char *)s->sym + 1, str);
s->sym[0] = stype;
@@ -272,7 +277,12 @@ static void write_src(void)
/* table of offset markers, that give the offset in the compressed stream
* every 256 symbols */
- markers = (unsigned int *) malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256));
+ markers = malloc(sizeof(unsigned int) * ((table_cnt + 255) / 256));
+ if (!markers) {
+ fprintf(stderr, "kallsyms failure: "
+ "unable to allocate required memory\n");
+ exit(EXIT_FAILURE);
+ }
output_label("kallsyms_names");
off = 0;
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5760e057ecb..e6499db4c8c 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,7 @@
# Kernel configuration targets
# These targets are used from top-level makefile
-.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
+PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
xconfig: $(obj)/qconf
$< arch/$(ARCH)/Kconfig
@@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext
$(Q)rm -f arch/um/Kconfig_arch
$(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
-.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig
+PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
randconfig: $(obj)/conf
$< -r arch/$(ARCH)/Kconfig
@@ -78,7 +78,7 @@ help:
@echo ' defconfig - New config with default answer to all options'
@echo ' allmodconfig - New config selecting modules when possible'
@echo ' allyesconfig - New config where all options are accepted with yes'
- @echo ' allnoconfig - New minimal config'
+ @echo ' allnoconfig - New config where all options are answered with no'
# ===========================================================================
# Shared Makefile for the various kconfig executables:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b0cbbe2e41b..1b8882ddbc7 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -374,6 +374,7 @@ int conf_write(const char *name)
out_h = fopen(".tmpconfig.h", "w");
if (!out_h)
return 1;
+ file_write_dep(NULL);
}
sym = sym_lookup("KERNELVERSION", 0);
sym_calc_value(sym);
@@ -512,7 +513,6 @@ int conf_write(const char *name)
if (out_h) {
fclose(out_h);
rename(".tmpconfig.h", "include/linux/autoconf.h");
- file_write_dep(NULL);
}
if (!name || basename != conf_def_filename) {
if (!name)
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
index bbf4887cff7..a8b02632624 100644
--- a/scripts/kconfig/lxdialog/Makefile
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
-
-HOST_EXTRACFLAGS += -DLOCALE
-.PHONY: dochecklxdialog
+HOST_EXTRACFLAGS += -DLOCALE
+
+PHONY += dochecklxdialog
$(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index c4d621b30d0..a22cbedd3b3 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -21,11 +21,13 @@ KERNELOUTPUT := $2
MAKEFLAGS += --no-print-directory
+.PHONY: all \$(MAKECMDGOALS)
+
all:
\$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
-%::
- \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
+Makefile:;
+\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/:
+ \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
EOF
-
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c164b230ad6..84e21201f3c 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -34,7 +34,7 @@ typedef uint16_t __u16;
typedef unsigned char __u8;
/* Big exception to the "don't include kernel headers into userspace, which
- * even potentially has different endianness and word sizes, since
+ * even potentially has different endianness and word sizes, since
* we handle those differences explicitly below */
#include "../../include/linux/mod_devicetable.h"
#include "../../include/linux/input.h"
@@ -153,8 +153,8 @@ static void do_usb_table(void *symval, unsigned long size,
const unsigned long id_size = sizeof(struct usb_device_id);
if (size % id_size || size < id_size) {
- fprintf(stderr, "*** Warning: %s ids %lu bad size "
- "(each on %lu)\n", mod->name, size, id_size);
+ warn("%s ids %lu bad size "
+ "(each on %lu)\n", mod->name, size, id_size);
}
/* Leave last one: it's the terminator. */
size -= id_size;
@@ -217,9 +217,8 @@ static int do_pci_entry(const char *filename,
if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
|| (subclass_mask != 0 && subclass_mask != 0xFF)
|| (interface_mask != 0 && interface_mask != 0xFF)) {
- fprintf(stderr,
- "*** Warning: Can't handle masks in %s:%04X\n",
- filename, id->class_mask);
+ warn("Can't handle masks in %s:%04X\n",
+ filename, id->class_mask);
return 0;
}
@@ -229,7 +228,7 @@ static int do_pci_entry(const char *filename,
return 1;
}
-/* looks like: "ccw:tNmNdtNdmN" */
+/* looks like: "ccw:tNmNdtNdmN" */
static int do_ccw_entry(const char *filename,
struct ccw_device_id *id, char *alias)
{
@@ -445,8 +444,8 @@ static void do_table(void *symval, unsigned long size,
int (*do_entry)(const char *, void *entry, char *alias) = function;
if (size % id_size || size < id_size) {
- fprintf(stderr, "*** Warning: %s ids %lu bad size "
- "(each on %lu)\n", mod->name, size, id_size);
+ warn("%s ids %lu bad size "
+ "(each on %lu)\n", mod->name, size, id_size);
}
/* Leave last one: it's the terminator. */
size -= id_size;
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
index de2aabf89fb..3c92c83733f 100644
--- a/scripts/mod/mk_elfconfig.c
+++ b/scripts/mod/mk_elfconfig.c
@@ -6,7 +6,7 @@
int
main(int argc, char **argv)
{
- unsigned char ei[EI_NIDENT];
+ unsigned char ei[EI_NIDENT];
union { short s; char c[2]; } endian_test;
if (argc != 2) {
@@ -57,7 +57,7 @@ main(int argc, char **argv)
if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
- else
+ else
printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
return 0;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index b8b2a560b26..0b92ddff26f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2,7 +2,7 @@
*
* Copyright 2003 Kai Germaschewski
* Copyright 2002-2004 Rusty Russell, IBM Corporation
- *
+ * Copyright 2006 Sam Ravnborg
* Based in part on module-init-tools/depmod.c,file2alias
*
* This software may be used and distributed according to the terms
@@ -20,9 +20,10 @@ int modversions = 0;
int have_vmlinux = 0;
/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
static int all_versions = 0;
+/* If we are modposting external module set to 1 */
+static int external_module = 0;
-void
-fatal(const char *fmt, ...)
+void fatal(const char *fmt, ...)
{
va_list arglist;
@@ -35,8 +36,7 @@ fatal(const char *fmt, ...)
exit(1);
}
-void
-warn(const char *fmt, ...)
+void warn(const char *fmt, ...)
{
va_list arglist;
@@ -47,6 +47,18 @@ warn(const char *fmt, ...)
va_end(arglist);
}
+static int is_vmlinux(const char *modname)
+{
+ const char *myname;
+
+ if ((myname = strrchr(modname, '/')))
+ myname++;
+ else
+ myname = modname;
+
+ return strcmp(myname, "vmlinux") == 0;
+}
+
void *do_nofail(void *ptr, const char *expr)
{
if (!ptr) {
@@ -59,8 +71,7 @@ void *do_nofail(void *ptr, const char *expr)
static struct module *modules;
-struct module *
-find_module(char *modname)
+static struct module *find_module(char *modname)
{
struct module *mod;
@@ -70,12 +81,11 @@ find_module(char *modname)
return mod;
}
-struct module *
-new_module(char *modname)
+static struct module *new_module(char *modname)
{
struct module *mod;
char *p, *s;
-
+
mod = NOFAIL(malloc(sizeof(*mod)));
memset(mod, 0, sizeof(*mod));
p = NOFAIL(strdup(modname));
@@ -104,6 +114,10 @@ struct symbol {
unsigned int crc;
int crc_valid;
unsigned int weak:1;
+ unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
+ unsigned int kernel:1; /* 1 if symbol is from kernel
+ * (only for external modules) **/
+ unsigned int preloaded:1; /* 1 if symbol from Module.symvers */
char name[0];
};
@@ -122,11 +136,12 @@ static inline unsigned int tdb_hash(const char *name)
return (1103515243 * value + 12345);
}
-/* Allocate a new symbols for use in the hash of exported symbols or
- * the list of unresolved symbols per module */
-
-struct symbol *
-alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
+/**
+ * Allocate a new symbols for use in the hash of exported symbols or
+ * the list of unresolved symbols per module
+ **/
+static struct symbol *alloc_symbol(const char *name, unsigned int weak,
+ struct symbol *next)
{
struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
@@ -138,9 +153,7 @@ alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
}
/* For the hash of exported symbols */
-
-void
-new_symbol(const char *name, struct module *module, unsigned int *crc)
+static struct symbol *new_symbol(const char *name, struct module *module)
{
unsigned int hash;
struct symbol *new;
@@ -148,14 +161,10 @@ new_symbol(const char *name, struct module *module, unsigned int *crc)
hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]);
new->module = module;
- if (crc) {
- new->crc = *crc;
- new->crc_valid = 1;
- }
+ return new;
}
-struct symbol *
-find_symbol(const char *name)
+static struct symbol *find_symbol(const char *name)
{
struct symbol *s;
@@ -170,25 +179,42 @@ find_symbol(const char *name)
return NULL;
}
-/* Add an exported symbol - it may have already been added without a
- * CRC, in this case just update the CRC */
-void
-add_exported_symbol(const char *name, struct module *module, unsigned int *crc)
+/**
+ * Add an exported symbol - it may have already been added without a
+ * CRC, in this case just update the CRC
+ **/
+static struct symbol *sym_add_exported(const char *name, struct module *mod)
{
struct symbol *s = find_symbol(name);
if (!s) {
- new_symbol(name, module, crc);
- return;
- }
- if (crc) {
- s->crc = *crc;
- s->crc_valid = 1;
+ s = new_symbol(name, mod);
+ } else {
+ if (!s->preloaded) {
+ warn("%s: '%s' exported twice. Previous export "
+ "was in %s%s\n", mod->name, name,
+ s->module->name,
+ is_vmlinux(s->module->name) ?"":".ko");
+ }
}
+ s->preloaded = 0;
+ s->vmlinux = is_vmlinux(mod->name);
+ s->kernel = 0;
+ return s;
+}
+
+static void sym_update_crc(const char *name, struct module *mod,
+ unsigned int crc)
+{
+ struct symbol *s = find_symbol(name);
+
+ if (!s)
+ s = new_symbol(name, mod);
+ s->crc = crc;
+ s->crc_valid = 1;
}
-void *
-grab_file(const char *filename, unsigned long *size)
+void *grab_file(const char *filename, unsigned long *size)
{
struct stat st;
void *map;
@@ -207,13 +233,12 @@ grab_file(const char *filename, unsigned long *size)
return map;
}
-/*
- Return a copy of the next line in a mmap'ed file.
- spaces in the beginning of the line is trimmed away.
- Return a pointer to a static buffer.
-*/
-char*
-get_next_line(unsigned long *pos, void *file, unsigned long size)
+/**
+ * Return a copy of the next line in a mmap'ed file.
+ * spaces in the beginning of the line is trimmed away.
+ * Return a pointer to a static buffer.
+ **/
+char* get_next_line(unsigned long *pos, void *file, unsigned long size)
{
static char line[4096];
int skip = 1;
@@ -243,14 +268,12 @@ get_next_line(unsigned long *pos, void *file, unsigned long size)
return NULL;
}
-void
-release_file(void *file, unsigned long size)
+void release_file(void *file, unsigned long size)
{
munmap(file, size);
}
-void
-parse_elf(struct elf_info *info, const char *filename)
+static void parse_elf(struct elf_info *info, const char *filename)
{
unsigned int i;
Elf_Ehdr *hdr = info->hdr;
@@ -297,14 +320,13 @@ parse_elf(struct elf_info *info, const char *filename)
continue;
info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
- info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset
+ info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset
+ sechdrs[i].sh_size;
- info->strtab = (void *)hdr +
+ info->strtab = (void *)hdr +
sechdrs[sechdrs[i].sh_link].sh_offset;
}
if (!info->symtab_start) {
- fprintf(stderr, "modpost: %s no symtab?\n", filename);
- abort();
+ fatal("%s has no symtab?\n", filename);
}
/* Fix endianness in symbols */
for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
@@ -316,36 +338,31 @@ parse_elf(struct elf_info *info, const char *filename)
return;
truncated:
- fprintf(stderr, "modpost: %s is truncated.\n", filename);
- abort();
+ fatal("%s is truncated.\n", filename);
}
-void
-parse_elf_finish(struct elf_info *info)
+static void parse_elf_finish(struct elf_info *info)
{
release_file(info->hdr, info->size);
}
-#define CRC_PFX "__crc_"
-#define KSYMTAB_PFX "__ksymtab_"
+#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
+#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
-void
-handle_modversions(struct module *mod, struct elf_info *info,
- Elf_Sym *sym, const char *symname)
+static void handle_modversions(struct module *mod, struct elf_info *info,
+ Elf_Sym *sym, const char *symname)
{
unsigned int crc;
switch (sym->st_shndx) {
case SHN_COMMON:
- fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n",
- symname, mod->name);
+ warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
break;
case SHN_ABS:
/* CRC'd symbol */
if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
crc = (unsigned int) sym->st_value;
- add_exported_symbol(symname + strlen(CRC_PFX),
- mod, &crc);
+ sym_update_crc(symname + strlen(CRC_PFX), mod, crc);
}
break;
case SHN_UNDEF:
@@ -370,15 +387,15 @@ handle_modversions(struct module *mod, struct elf_info *info,
/* Ignore register directives. */
if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
break;
- if (symname[0] == '.') {
- char *munged = strdup(symname);
- munged[0] = '_';
- munged[1] = toupper(munged[1]);
- symname = munged;
- }
+ if (symname[0] == '.') {
+ char *munged = strdup(symname);
+ munged[0] = '_';
+ munged[1] = toupper(munged[1]);
+ symname = munged;
+ }
}
#endif
-
+
if (memcmp(symname, MODULE_SYMBOL_PREFIX,
strlen(MODULE_SYMBOL_PREFIX)) == 0)
mod->unres = alloc_symbol(symname +
@@ -389,8 +406,7 @@ handle_modversions(struct module *mod, struct elf_info *info,
default:
/* All exported symbols */
if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
- add_exported_symbol(symname + strlen(KSYMTAB_PFX),
- mod, NULL);
+ sym_add_exported(symname + strlen(KSYMTAB_PFX), mod);
}
if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0)
mod->has_init = 1;
@@ -400,20 +416,9 @@ handle_modversions(struct module *mod, struct elf_info *info,
}
}
-int
-is_vmlinux(const char *modname)
-{
- const char *myname;
-
- if ((myname = strrchr(modname, '/')))
- myname++;
- else
- myname = modname;
-
- return strcmp(myname, "vmlinux") == 0;
-}
-
-/* Parse tag=value strings from .modinfo section */
+/**
+ * Parse tag=value strings from .modinfo section
+ **/
static char *next_string(char *string, unsigned long *secsize)
{
/* Skip non-zero chars */
@@ -446,8 +451,418 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
return NULL;
}
-void
-read_symbols(char *modname)
+/**
+ * Test if string s ends in string sub
+ * return 0 if match
+ **/
+static int strrcmp(const char *s, const char *sub)
+{
+ int slen, sublen;
+
+ if (!s || !sub)
+ return 1;
+
+ slen = strlen(s);
+ sublen = strlen(sub);
+
+ if ((slen == 0) || (sublen == 0))
+ return 1;
+
+ if (sublen > slen)
+ return 1;
+
+ return memcmp(s + slen - sublen, sub, sublen);
+}
+
+/**
+ * Whitelist to allow certain references to pass with no warning.
+ * Pattern 1:
+ * If a module parameter is declared __initdata and permissions=0
+ * then this is legal despite the warning generated.
+ * We cannot see value of permissions here, so just ignore
+ * this pattern.
+ * The pattern is identified by:
+ * tosec = .init.data
+ * fromsec = .data*
+ * atsym =__param*
+ *
+ * Pattern 2:
+ * Many drivers utilise a *_driver container with references to
+ * add, remove, probe functions etc.
+ * These functions may often be marked __init and we do not want to
+ * warn here.
+ * the pattern is identified by:
+ * tosec = .init.text | .exit.text
+ * fromsec = .data
+ * atsym = *_driver, *_ops, *_probe, *probe_one
+ **/
+static int secref_whitelist(const char *tosec, const char *fromsec,
+ const char *atsym)
+{
+ int f1 = 1, f2 = 1;
+ const char **s;
+ const char *pat2sym[] = {
+ "_driver",
+ "_ops",
+ "_probe",
+ "_probe_one",
+ NULL
+ };
+
+ /* Check for pattern 1 */
+ if (strcmp(tosec, ".init.data") != 0)
+ f1 = 0;
+ if (strncmp(fromsec, ".data", strlen(".data")) != 0)
+ f1 = 0;
+ if (strncmp(atsym, "__param", strlen("__param")) != 0)
+ f1 = 0;
+
+ if (f1)
+ return f1;
+
+ /* Check for pattern 2 */
+ if ((strcmp(tosec, ".init.text") != 0) &&
+ (strcmp(tosec, ".exit.text") != 0))
+ f2 = 0;
+ if (strcmp(fromsec, ".data") != 0)
+ f2 = 0;
+
+ for (s = pat2sym; *s; s++)
+ if (strrcmp(atsym, *s) == 0)
+ f1 = 1;
+
+ return f1 && f2;
+}
+
+/**
+ * Find symbol based on relocation record info.
+ * In some cases the symbol supplied is a valid symbol so
+ * return refsym. If st_name != 0 we assume this is a valid symbol.
+ * In other cases the symbol needs to be looked up in the symbol table
+ * based on section and address.
+ * **/
+static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
+ Elf_Sym *relsym)
+{
+ Elf_Sym *sym;
+
+ if (relsym->st_name != 0)
+ return relsym;
+ for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
+ if (sym->st_shndx != relsym->st_shndx)
+ continue;
+ if (sym->st_value == addr)
+ return sym;
+ }
+ return NULL;
+}
+
+/*
+ * Find symbols before or equal addr and after addr - in the section sec.
+ * If we find two symbols with equal offset prefer one with a valid name.
+ * The ELF format may have a better way to detect what type of symbol
+ * it is, but this works for now.
+ **/
+static void find_symbols_between(struct elf_info *elf, Elf_Addr addr,
+ const char *sec,
+ Elf_Sym **before, Elf_Sym **after)
+{
+ Elf_Sym *sym;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Addr beforediff = ~0;
+ Elf_Addr afterdiff = ~0;
+ const char *secstrings = (void *)hdr +
+ elf->sechdrs[hdr->e_shstrndx].sh_offset;
+
+ *before = NULL;
+ *after = NULL;
+
+ for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
+ const char *symsec;
+
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+ symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name;
+ if (strcmp(symsec, sec) != 0)
+ continue;
+ if (sym->st_value <= addr) {
+ if ((addr - sym->st_value) < beforediff) {
+ beforediff = addr - sym->st_value;
+ *before = sym;
+ }
+ else if ((addr - sym->st_value) == beforediff) {
+ /* equal offset, valid name? */
+ const char *name = elf->strtab + sym->st_name;
+ if (name && strlen(name))
+ *before = sym;
+ }
+ }
+ else
+ {
+ if ((sym->st_value - addr) < afterdiff) {
+ afterdiff = sym->st_value - addr;
+ *after = sym;
+ }
+ else if ((sym->st_value - addr) == afterdiff) {
+ /* equal offset, valid name? */
+ const char *name = elf->strtab + sym->st_name;
+ if (name && strlen(name))
+ *after = sym;
+ }
+ }
+ }
+}
+
+/**
+ * Print a warning about a section mismatch.
+ * Try to find symbols near it so user can find it.
+ * Check whitelist before warning - it may be a false positive.
+ **/
+static void warn_sec_mismatch(const char *modname, const char *fromsec,
+ struct elf_info *elf, Elf_Sym *sym, Elf_Rela r)
+{
+ const char *refsymname = "";
+ Elf_Sym *before, *after;
+ Elf_Sym *refsym;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Shdr *sechdrs = elf->sechdrs;
+ const char *secstrings = (void *)hdr +
+ sechdrs[hdr->e_shstrndx].sh_offset;
+ const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name;
+
+ find_symbols_between(elf, r.r_offset, fromsec, &before, &after);
+
+ refsym = find_elf_symbol(elf, r.r_addend, sym);
+ if (refsym && strlen(elf->strtab + refsym->st_name))
+ refsymname = elf->strtab + refsym->st_name;
+
+ /* check whitelist - we may ignore it */
+ if (before &&
+ secref_whitelist(secname, fromsec, elf->strtab + before->st_name))
+ return;
+
+ if (before && after) {
+ warn("%s - Section mismatch: reference to %s:%s from %s "
+ "between '%s' (at offset 0x%llx) and '%s'\n",
+ modname, secname, refsymname, fromsec,
+ elf->strtab + before->st_name,
+ (long long)r.r_offset,
+ elf->strtab + after->st_name);
+ } else if (before) {
+ warn("%s - Section mismatch: reference to %s:%s from %s "
+ "after '%s' (at offset 0x%llx)\n",
+ modname, secname, refsymname, fromsec,
+ elf->strtab + before->st_name,
+ (long long)r.r_offset);
+ } else if (after) {
+ warn("%s - Section mismatch: reference to %s:%s from %s "
+ "before '%s' (at offset -0x%llx)\n",
+ modname, secname, refsymname, fromsec,
+ elf->strtab + before->st_name,
+ (long long)r.r_offset);
+ } else {
+ warn("%s - Section mismatch: reference to %s:%s from %s "
+ "(offset 0x%llx)\n",
+ modname, secname, fromsec, refsymname,
+ (long long)r.r_offset);
+ }
+}
+
+/**
+ * A module includes a number of sections that are discarded
+ * either when loaded or when used as built-in.
+ * For loaded modules all functions marked __init and all data
+ * marked __initdata will be discarded when the module has been intialized.
+ * Likewise for modules used built-in the sections marked __exit
+ * are discarded because __exit marked function are supposed to be called
+ * only when a moduel is unloaded which never happes for built-in modules.
+ * The check_sec_ref() function traverses all relocation records
+ * to find all references to a section that reference a section that will
+ * be discarded and warns about it.
+ **/
+static void check_sec_ref(struct module *mod, const char *modname,
+ struct elf_info *elf,
+ int section(const char*),
+ int section_ref_ok(const char *))
+{
+ int i;
+ Elf_Sym *sym;
+ Elf_Ehdr *hdr = elf->hdr;
+ Elf_Shdr *sechdrs = elf->sechdrs;
+ const char *secstrings = (void *)hdr +
+ sechdrs[hdr->e_shstrndx].sh_offset;
+
+ /* Walk through all sections */
+ for (i = 0; i < hdr->e_shnum; i++) {
+ Elf_Rela *rela;
+ Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
+ Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
+ const char *name = secstrings + sechdrs[i].sh_name +
+ strlen(".rela");
+ /* We want to process only relocation sections and not .init */
+ if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA))
+ continue;
+
+ for (rela = start; rela < stop; rela++) {
+ Elf_Rela r;
+ const char *secname;
+ r.r_offset = TO_NATIVE(rela->r_offset);
+ r.r_info = TO_NATIVE(rela->r_info);
+ r.r_addend = TO_NATIVE(rela->r_addend);
+ sym = elf->symtab_start + ELF_R_SYM(r.r_info);
+ /* Skip special sections */
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+
+ secname = secstrings + sechdrs[sym->st_shndx].sh_name;
+ if (section(secname))
+ warn_sec_mismatch(modname, name, elf, sym, r);
+ }
+ }
+}
+
+/**
+ * Functions used only during module init is marked __init and is stored in
+ * a .init.text section. Likewise data is marked __initdata and stored in
+ * a .init.data section.
+ * If this section is one of these sections return 1
+ * See include/linux/init.h for the details
+ **/
+static int init_section(const char *name)
+{
+ if (strcmp(name, ".init") == 0)
+ return 1;
+ if (strncmp(name, ".init.", strlen(".init.")) == 0)
+ return 1;
+ return 0;
+}
+
+/**
+ * Identify sections from which references to a .init section is OK.
+ *
+ * Unfortunately references to read only data that referenced .init
+ * sections had to be excluded. Almost all of these are false
+ * positives, they are created by gcc. The downside of excluding rodata
+ * is that there really are some user references from rodata to
+ * init code, e.g. drivers/video/vgacon.c:
+ *
+ * const struct consw vga_con = {
+ * con_startup: vgacon_startup,
+ *
+ * where vgacon_startup is __init. If you want to wade through the false
+ * positives, take out the check for rodata.
+ **/
+static int init_section_ref_ok(const char *name)
+{
+ const char **s;
+ /* Absolute section names */
+ const char *namelist1[] = {
+ ".init",
+ ".opd", /* see comment [OPD] at exit_section_ref_ok() */
+ ".toc1", /* used by ppc64 */
+ ".stab",
+ ".rodata",
+ ".text.lock",
+ "__bug_table", /* used by powerpc for BUG() */
+ ".pci_fixup_header",
+ ".pci_fixup_final",
+ ".pdr",
+ "__param",
+ NULL
+ };
+ /* Start of section names */
+ const char *namelist2[] = {
+ ".init.",
+ ".altinstructions",
+ ".eh_frame",
+ ".debug",
+ NULL
+ };
+ /* part of section name */
+ const char *namelist3 [] = {
+ ".unwind", /* sample: IA_64.unwind.init.text */
+ NULL
+ };
+
+ for (s = namelist1; *s; s++)
+ if (strcmp(*s, name) == 0)
+ return 1;
+ for (s = namelist2; *s; s++)
+ if (strncmp(*s, name, strlen(*s)) == 0)
+ return 1;
+ for (s = namelist3; *s; s++)
+ if (strstr(name, *s) != NULL)
+ return 1;
+ return 0;
+}
+
+/*
+ * Functions used only during module exit is marked __exit and is stored in
+ * a .exit.text section. Likewise data is marked __exitdata and stored in
+ * a .exit.data section.
+ * If this section is one of these sections return 1
+ * See include/linux/init.h for the details
+ **/
+static int exit_section(const char *name)
+{
+ if (strcmp(name, ".exit.text") == 0)
+ return 1;
+ if (strcmp(name, ".exit.data") == 0)
+ return 1;
+ return 0;
+
+}
+
+/*
+ * Identify sections from which references to a .exit section is OK.
+ *
+ * [OPD] Keith Ownes <kaos@sgi.com> commented:
+ * For our future {in}sanity, add a comment that this is the ppc .opd
+ * section, not the ia64 .opd section.
+ * ia64 .opd should not point to discarded sections.
+ **/
+static int exit_section_ref_ok(const char *name)
+{
+ const char **s;
+ /* Absolute section names */
+ const char *namelist1[] = {
+ ".exit.text",
+ ".exit.data",
+ ".init.text",
+ ".opd", /* See comment [OPD] */
+ ".toc1", /* used by ppc64 */
+ ".altinstructions",
+ ".pdr",
+ "__bug_table", /* used by powerpc for BUG() */
+ ".exitcall.exit",
+ ".eh_frame",
+ ".stab",
+ NULL
+ };
+ /* Start of section names */
+ const char *namelist2[] = {
+ ".debug",
+ NULL
+ };
+ /* part of section name */
+ const char *namelist3 [] = {
+ ".unwind", /* Sample: IA_64.unwind.exit.text */
+ NULL
+ };
+
+ for (s = namelist1; *s; s++)
+ if (strcmp(*s, name) == 0)
+ return 1;
+ for (s = namelist2; *s; s++)
+ if (strncmp(*s, name, strlen(*s)) == 0)
+ return 1;
+ for (s = namelist3; *s; s++)
+ if (strstr(name, *s) != NULL)
+ return 1;
+ return 0;
+}
+
+static void read_symbols(char *modname)
{
const char *symname;
char *version;
@@ -462,9 +877,7 @@ read_symbols(char *modname)
/* When there's no vmlinux, don't print warnings about
* unresolved symbols (since there'll be too many ;) */
if (is_vmlinux(modname)) {
- unsigned int fake_crc = 0;
have_vmlinux = 1;
- add_exported_symbol("struct_module", mod, &fake_crc);
mod->skip = 1;
}
@@ -474,6 +887,8 @@ read_symbols(char *modname)
handle_modversions(mod, &info, sym, symname);
handle_moddevtable(mod, &info, sym, symname);
}
+ check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
+ check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
version = get_modinfo(info.modinfo, info.modinfo_len, "version");
if (version)
@@ -499,21 +914,20 @@ read_symbols(char *modname)
* following helper, then compare to the file on disk and
* only update the later if anything changed */
-void __attribute__((format(printf, 2, 3)))
-buf_printf(struct buffer *buf, const char *fmt, ...)
+void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
+ const char *fmt, ...)
{
char tmp[SZ];
int len;
va_list ap;
-
+
va_start(ap, fmt);
len = vsnprintf(tmp, SZ, fmt, ap);
buf_write(buf, tmp, len);
va_end(ap);
}
-void
-buf_write(struct buffer *buf, const char *s, int len)
+void buf_write(struct buffer *buf, const char *s, int len)
{
if (buf->size - buf->pos < len) {
buf->size += len + SZ;
@@ -523,10 +937,10 @@ buf_write(struct buffer *buf, const char *s, int len)
buf->pos += len;
}
-/* Header for the generated file */
-
-void
-add_header(struct buffer *b, struct module *mod)
+/**
+ * Header for the generated file
+ **/
+static void add_header(struct buffer *b, struct module *mod)
{
buf_printf(b, "#include <linux/module.h>\n");
buf_printf(b, "#include <linux/vermagic.h>\n");
@@ -546,10 +960,10 @@ add_header(struct buffer *b, struct module *mod)
buf_printf(b, "};\n");
}
-/* Record CRCs for unresolved symbols */
-
-void
-add_versions(struct buffer *b, struct module *mod)
+/**
+ * Record CRCs for unresolved symbols
+ **/
+static void add_versions(struct buffer *b, struct module *mod)
{
struct symbol *s, *exp;
@@ -557,8 +971,8 @@ add_versions(struct buffer *b, struct module *mod)
exp = find_symbol(s->name);
if (!exp || exp->module == mod) {
if (have_vmlinux && !s->weak)
- fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
- "undefined!\n", s->name, mod->name);
+ warn("\"%s\" [%s.ko] undefined!\n",
+ s->name, mod->name);
continue;
}
s->module = exp->module;
@@ -579,8 +993,7 @@ add_versions(struct buffer *b, struct module *mod)
continue;
}
if (!s->crc_valid) {
- fprintf(stderr, "*** Warning: \"%s\" [%s.ko] "
- "has no CRC!\n",
+ warn("\"%s\" [%s.ko] has no CRC!\n",
s->name, mod->name);
continue;
}
@@ -590,8 +1003,8 @@ add_versions(struct buffer *b, struct module *mod)
buf_printf(b, "};\n");
}
-void
-add_depends(struct buffer *b, struct module *mod, struct module *modules)
+static void add_depends(struct buffer *b, struct module *mod,
+ struct module *modules)
{
struct symbol *s;
struct module *m;
@@ -621,8 +1034,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules)
buf_printf(b, "\";\n");
}
-void
-add_srcversion(struct buffer *b, struct module *mod)
+static void add_srcversion(struct buffer *b, struct module *mod)
{
if (mod->srcversion[0]) {
buf_printf(b, "\n");
@@ -631,8 +1043,7 @@ add_srcversion(struct buffer *b, struct module *mod)
}
}
-void
-write_if_changed(struct buffer *b, const char *fname)
+static void write_if_changed(struct buffer *b, const char *fname)
{
char *tmp;
FILE *file;
@@ -676,8 +1087,7 @@ write_if_changed(struct buffer *b, const char *fname)
fclose(file);
}
-void
-read_dump(const char *fname)
+static void read_dump(const char *fname, unsigned int kernel)
{
unsigned long size, pos = 0;
void *file = grab_file(fname, &size);
@@ -691,6 +1101,7 @@ read_dump(const char *fname)
char *symname, *modname, *d;
unsigned int crc;
struct module *mod;
+ struct symbol *s;
if (!(symname = strchr(line, '\t')))
goto fail;
@@ -711,15 +1122,30 @@ read_dump(const char *fname)
mod = new_module(NOFAIL(strdup(modname)));
mod->skip = 1;
}
- add_exported_symbol(symname, mod, &crc);
+ s = sym_add_exported(symname, mod);
+ s->kernel = kernel;
+ s->preloaded = 1;
+ sym_update_crc(symname, mod, crc);
}
return;
fail:
fatal("parse error in symbol dump file\n");
}
-void
-write_dump(const char *fname)
+/* For normal builds always dump all symbols.
+ * For external modules only dump symbols
+ * that are not read from kernel Module.symvers.
+ **/
+static int dump_sym(struct symbol *sym)
+{
+ if (!external_module)
+ return 1;
+ if (sym->vmlinux || sym->kernel)
+ return 0;
+ return 1;
+}
+
+static void write_dump(const char *fname)
{
struct buffer buf = { };
struct symbol *symbol;
@@ -728,34 +1154,33 @@ write_dump(const char *fname)
for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
symbol = symbolhash[n];
while (symbol) {
- symbol = symbol->next;
- }
- }
-
- for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
- symbol = symbolhash[n];
- while (symbol) {
- buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
- symbol->name, symbol->module->name);
+ if (dump_sym(symbol))
+ buf_printf(&buf, "0x%08x\t%s\t%s\n",
+ symbol->crc, symbol->name,
+ symbol->module->name);
symbol = symbol->next;
}
}
write_if_changed(&buf, fname);
}
-int
-main(int argc, char **argv)
+int main(int argc, char **argv)
{
struct module *mod;
struct buffer buf = { };
char fname[SZ];
- char *dump_read = NULL, *dump_write = NULL;
+ char *kernel_read = NULL, *module_read = NULL;
+ char *dump_write = NULL;
int opt;
- while ((opt = getopt(argc, argv, "i:mo:a")) != -1) {
+ while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) {
switch(opt) {
case 'i':
- dump_read = optarg;
+ kernel_read = optarg;
+ break;
+ case 'I':
+ module_read = optarg;
+ external_module = 1;
break;
case 'm':
modversions = 1;
@@ -771,8 +1196,10 @@ main(int argc, char **argv)
}
}
- if (dump_read)
- read_dump(dump_read);
+ if (kernel_read)
+ read_dump(kernel_read, 1);
+ if (module_read)
+ read_dump(module_read, 0);
while (optind < argc) {
read_symbols(argv[optind++]);
@@ -799,4 +1226,3 @@ main(int argc, char **argv)
return 0;
}
-
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 7334d839145..b14255c72a3 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -13,20 +13,30 @@
#if KERNEL_ELFCLASS == ELFCLASS32
-#define Elf_Ehdr Elf32_Ehdr
-#define Elf_Shdr Elf32_Shdr
+#define Elf_Ehdr Elf32_Ehdr
+#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
+#define Elf_Addr Elf32_Addr
+#define Elf_Section Elf32_Section
#define ELF_ST_BIND ELF32_ST_BIND
#define ELF_ST_TYPE ELF32_ST_TYPE
+#define Elf_Rela Elf32_Rela
+#define ELF_R_SYM ELF32_R_SYM
+#define ELF_R_TYPE ELF32_R_TYPE
#else
-#define Elf_Ehdr Elf64_Ehdr
-#define Elf_Shdr Elf64_Shdr
+#define Elf_Ehdr Elf64_Ehdr
+#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
+#define Elf_Addr Elf64_Addr
+#define Elf_Section Elf64_Section
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_TYPE ELF64_ST_TYPE
+#define Elf_Rela Elf64_Rela
+#define ELF_R_SYM ELF64_R_SYM
+#define ELF_R_TYPE ELF64_R_TYPE
#endif
#if KERNEL_ELFDATA != HOST_ELFDATA
@@ -91,17 +101,22 @@ struct elf_info {
unsigned int modinfo_len;
};
+/* file2alias.c */
void handle_moddevtable(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname);
-
void add_moddevtable(struct buffer *buf, struct module *mod);
+/* sumversion.c */
void maybe_frob_rcs_version(const char *modfilename,
char *version,
void *modinfo,
unsigned long modinfo_offset);
void get_src_version(const char *modname, char sum[], unsigned sumlen);
+/* from modpost.c */
void *grab_file(const char *filename, unsigned long *size);
char* get_next_line(unsigned long *pos, void *file, unsigned long size);
void release_file(void *file, unsigned long size);
+
+void fatal(const char *fmt, ...);
+void warn(const char *fmt, ...);
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 43271a1ca01..8a2875689e4 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -316,8 +316,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
file = grab_file(cmd, &flen);
if (!file) {
- fprintf(stderr, "Warning: could not find %s for %s\n",
- cmd, objfile);
+ warn("could not find %s for %s\n", cmd, objfile);
goto out;
}
@@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
/* Check if this file is in same dir as objfile */
if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
if (!parse_file(line, md)) {
- fprintf(stderr,
- "Warning: could not open %s: %s\n",
- line, strerror(errno));
+ warn("could not open %s: %s\n",
+ line, strerror(errno));
goto out_file;
}
@@ -383,8 +381,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
struct md4_ctx md;
char *sources, *end, *fname;
const char *basename;
- char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
- strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
+ char filelist[PATH_MAX + 1];
+ char *modverdir = getenv("MODVERDIR");
+
+ if (!modverdir)
+ modverdir = ".";
/* Source files for module are in .tmp_versions/modname.mod,
after the first line. */
@@ -392,28 +393,25 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
basename = strrchr(modname, '/') + 1;
else
basename = modname;
- sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
+ sprintf(filelist, "%s/%.*s.mod", modverdir,
(int) strlen(basename) - 2, basename);
file = grab_file(filelist, &len);
if (!file) {
- fprintf(stderr, "Warning: could not find versions for %s\n",
- filelist);
+ warn("could not find versions for %s\n", filelist);
return;
}
sources = strchr(file, '\n');
if (!sources) {
- fprintf(stderr, "Warning: malformed versions file for %s\n",
- modname);
+ warn("malformed versions file for %s\n", modname);
goto release;
}
sources++;
end = strchr(sources, '\n');
if (!end) {
- fprintf(stderr, "Warning: bad ending versions file for %s\n",
- modname);
+ warn("bad ending versions file for %s\n", modname);
goto release;
}
*end = '\0';
@@ -438,19 +436,19 @@ static void write_version(const char *filename, const char *sum,
fd = open(filename, O_RDWR);
if (fd < 0) {
- fprintf(stderr, "Warning: changing sum in %s failed: %s\n",
+ warn("changing sum in %s failed: %s\n",
filename, strerror(errno));
return;
}
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
- fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n",
+ warn("changing sum in %s:%lu failed: %s\n",
filename, offset, strerror(errno));
goto out;
}
if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
- fprintf(stderr, "Warning: writing sum in %s failed: %s\n",
+ warn("writing sum in %s failed: %s\n",
filename, strerror(errno));
goto out;
}
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index 88e30e82f1c..f34373853ef 100644
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -66,8 +66,8 @@ require 5; # at least perl 5
use strict;
use File::Find;
-my $nm = "/usr/bin/nm -p";
-my $objdump = "/usr/bin/objdump -s -j .comment";
+my $nm = ($ENV{'NM'} || "nm") . " -p";
+my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment";
my $srctree = "";
my $objtree = "";
$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'}));
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index c201ef001f0..7c434e037e7 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -32,12 +32,11 @@ MKSPEC := $(srctree)/scripts/package/mkspec
PREV := set -e; cd ..;
# rpm-pkg
-.PHONY: rpm-pkg rpm
-
+# ---------------------------------------------------------------------------
$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) > $@
-rpm-pkg rpm: $(objtree)/kernel.spec
+rpm-pkg rpm: $(objtree)/kernel.spec FORCE
$(MAKE) clean
$(PREV) ln -sf $(srctree) $(KERNELPATH)
$(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
@@ -54,11 +53,11 @@ rpm-pkg rpm: $(objtree)/kernel.spec
clean-files := $(objtree)/kernel.spec
# binrpm-pkg
-.PHONY: binrpm-pkg
+# ---------------------------------------------------------------------------
$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
-
-binrpm-pkg: $(objtree)/binkernel.spec
+
+binrpm-pkg: $(objtree)/binkernel.spec FORCE
$(MAKE) KBUILD_SRC=
set -e; \
$(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
@@ -71,9 +70,7 @@ clean-files += $(objtree)/binkernel.spec
# Deb target
# ---------------------------------------------------------------------------
-#
-.PHONY: deb-pkg
-deb-pkg:
+deb-pkg: FORCE
$(MAKE) KBUILD_SRC=
$(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
@@ -82,8 +79,7 @@ clean-dirs += $(objtree)/debian/
# tarball targets
# ---------------------------------------------------------------------------
-.PHONY: tar%pkg
-tar%pkg:
+tar%pkg: FORCE
$(MAKE) KBUILD_SRC=
$(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
@@ -92,7 +88,7 @@ clean-dirs += $(objtree)/tar-install/
# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
-help:
+help: FORCE
@echo ' rpm-pkg - Build the kernel as an RPM package'
@echo ' binrpm-pkg - Build an rpm package containing the compiled kernel'
@echo ' and modules'
diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl
deleted file mode 100644
index 4ee6ab2135b..00000000000
--- a/scripts/reference_discarded.pl
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/usr/bin/perl -w
-#
-# reference_discarded.pl (C) Keith Owens 2001 <kaos@ocs.com.au>
-#
-# Released under GPL V2.
-#
-# List dangling references to vmlinux discarded sections.
-
-use strict;
-die($0 . " takes no arguments\n") if($#ARGV >= 0);
-
-my %object;
-my $object;
-my $line;
-my $ignore;
-my $errorcount;
-
-$| = 1;
-
-# printf("Finding objects, ");
-open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
-while (defined($line = <OBJDUMP_LIST>)) {
- chomp($line);
- if ($line =~ /:\s+file format/) {
- ($object = $line) =~ s/:.*//;
- $object{$object}->{'module'} = 0;
- $object{$object}->{'size'} = 0;
- $object{$object}->{'off'} = 0;
- }
- if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
- $object{$object}->{'module'} = 1;
- }
- if ($line =~ /^\s*\d+\s+\.comment\s+/) {
- ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
- }
-}
-close(OBJDUMP_LIST);
-# printf("%d objects, ", scalar keys(%object));
-$ignore = 0;
-foreach $object (keys(%object)) {
- if ($object{$object}->{'module'}) {
- ++$ignore;
- delete($object{$object});
- }
-}
-# printf("ignoring %d module(s)\n", $ignore);
-
-# Ignore conglomerate objects, they have been built from multiple objects and we
-# only care about the individual objects. If an object has more than one GCC:
-# string in the comment section then it is conglomerate. This does not filter
-# out conglomerates that consist of exactly one object, can't be helped.
-
-# printf("Finding conglomerates, ");
-$ignore = 0;
-foreach $object (keys(%object)) {
- if (exists($object{$object}->{'off'})) {
- my ($off, $size, $comment, $l);
- $off = hex($object{$object}->{'off'});
- $size = hex($object{$object}->{'size'});
- open(OBJECT, "<$object") || die "cannot read $object";
- seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
- $l = read(OBJECT, $comment, $size);
- die "read $size bytes from $object .comment failed" if ($l != $size);
- close(OBJECT);
- if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
- ++$ignore;
- delete($object{$object});
- }
- }
-}
-# printf("ignoring %d conglomerate(s)\n", $ignore);
-
-# printf("Scanning objects\n");
-
-# Keith Ownes <kaos@sgi.com> commented:
-# For our future {in}sanity, add a comment that this is the ppc .opd
-# section, not the ia64 .opd section.
-# ia64 .opd should not point to discarded sections.
-$errorcount = 0;
-foreach $object (keys(%object)) {
- my $from;
- open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
- while (defined($line = <OBJDUMP>)) {
- chomp($line);
- if ($line =~ /RELOCATION RECORDS FOR /) {
- ($from = $line) =~ s/.*\[([^]]*).*/$1/;
- }
- if (($line =~ /\.text\.exit$/ ||
- $line =~ /\.exit\.text$/ ||
- $line =~ /\.data\.exit$/ ||
- $line =~ /\.exit\.data$/ ||
- $line =~ /\.exitcall\.exit$/) &&
- ($from !~ /\.text\.exit$/ &&
- $from !~ /\.exit\.text$/ &&
- $from !~ /\.data\.exit$/ &&
- $from !~ /\.opd$/ &&
- $from !~ /\.exit\.data$/ &&
- $from !~ /\.altinstructions$/ &&
- $from !~ /\.pdr$/ &&
- $from !~ /\.debug_.*$/ &&
- $from !~ /\.exitcall\.exit$/ &&
- $from !~ /\.eh_frame$/ &&
- $from !~ /\.stab$/)) {
- printf("Error: %s %s refers to %s\n", $object, $from, $line);
- $errorcount = $errorcount + 1;
- }
- }
- close(OBJDUMP);
-}
-# printf("Done\n");
-
-exit(0);
diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl
deleted file mode 100644
index 7f6960b175a..00000000000
--- a/scripts/reference_init.pl
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/usr/bin/perl -w
-#
-# reference_init.pl (C) Keith Owens 2002 <kaos@ocs.com.au>
-#
-# List references to vmlinux init sections from non-init sections.
-
-# Unfortunately I had to exclude references from read only data to .init
-# sections, almost all of these are false positives, they are created by
-# gcc. The downside of excluding rodata is that there really are some
-# user references from rodata to init code, e.g. drivers/video/vgacon.c
-#
-# const struct consw vga_con = {
-# con_startup: vgacon_startup,
-#
-# where vgacon_startup is __init. If you want to wade through the false
-# positives, take out the check for rodata.
-
-use strict;
-die($0 . " takes no arguments\n") if($#ARGV >= 0);
-
-my %object;
-my $object;
-my $line;
-my $ignore;
-
-$| = 1;
-
-printf("Finding objects, ");
-open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
-while (defined($line = <OBJDUMP_LIST>)) {
- chomp($line);
- if ($line =~ /:\s+file format/) {
- ($object = $line) =~ s/:.*//;
- $object{$object}->{'module'} = 0;
- $object{$object}->{'size'} = 0;
- $object{$object}->{'off'} = 0;
- }
- if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
- $object{$object}->{'module'} = 1;
- }
- if ($line =~ /^\s*\d+\s+\.comment\s+/) {
- ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
- }
-}
-close(OBJDUMP_LIST);
-printf("%d objects, ", scalar keys(%object));
-$ignore = 0;
-foreach $object (keys(%object)) {
- if ($object{$object}->{'module'}) {
- ++$ignore;
- delete($object{$object});
- }
-}
-printf("ignoring %d module(s)\n", $ignore);
-
-# Ignore conglomerate objects, they have been built from multiple objects and we
-# only care about the individual objects. If an object has more than one GCC:
-# string in the comment section then it is conglomerate. This does not filter
-# out conglomerates that consist of exactly one object, can't be helped.
-
-printf("Finding conglomerates, ");
-$ignore = 0;
-foreach $object (keys(%object)) {
- if (exists($object{$object}->{'off'})) {
- my ($off, $size, $comment, $l);
- $off = hex($object{$object}->{'off'});
- $size = hex($object{$object}->{'size'});
- open(OBJECT, "<$object") || die "cannot read $object";
- seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
- $l = read(OBJECT, $comment, $size);
- die "read $size bytes from $object .comment failed" if ($l != $size);
- close(OBJECT);
- if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
- ++$ignore;
- delete($object{$object});
- }
- }
-}
-printf("ignoring %d conglomerate(s)\n", $ignore);
-
-printf("Scanning objects\n");
-foreach $object (sort(keys(%object))) {
- my $from;
- open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
- while (defined($line = <OBJDUMP>)) {
- chomp($line);
- if ($line =~ /RELOCATION RECORDS FOR /) {
- ($from = $line) =~ s/.*\[([^]]*).*/$1/;
- }
- if (($line =~ /\.init$/ || $line =~ /\.init\./) &&
- ($from !~ /\.init$/ &&
- $from !~ /\.init\./ &&
- $from !~ /\.stab$/ &&
- $from !~ /\.rodata$/ &&
- $from !~ /\.text\.lock$/ &&
- $from !~ /\.pci_fixup_header$/ &&
- $from !~ /\.pci_fixup_final$/ &&
- $from !~ /\.pdr$/ &&
- $from !~ /\__param$/ &&
- $from !~ /\.altinstructions/ &&
- $from !~ /\.eh_frame/ &&
- $from !~ /\.debug_/)) {
- printf("Error: %s %s refers to %s\n", $object, $from, $line);
- }
- }
- close(OBJDUMP);
-}
-printf("Done\n");
diff --git a/security/commoncap.c b/security/commoncap.c
index 8a6e097f99e..841eb4e5c62 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -60,8 +60,8 @@ int cap_settime(struct timespec *ts, struct timezone *tz)
int cap_ptrace (struct task_struct *parent, struct task_struct *child)
{
/* Derived from arch/i386/kernel/ptrace.c:sys_ptrace. */
- if (!cap_issubset (child->cap_permitted, current->cap_permitted) &&
- !capable(CAP_SYS_PTRACE))
+ if (!cap_issubset(child->cap_permitted, parent->cap_permitted) &&
+ !__capable(parent, CAP_SYS_PTRACE))
return -EPERM;
return 0;
}
diff --git a/security/keys/key.c b/security/keys/key.c
index 99781b79831..a057e3311aa 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -1,6 +1,6 @@
/* key.c: basic authentication token and access key management
*
- * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Copyright (C) 2004-6 Red Hat, Inc. All Rights Reserved.
* Written by David Howells (dhowells@redhat.com)
*
* This program is free software; you can redistribute it and/or
@@ -271,7 +271,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
* its description */
if (!not_in_quota) {
spin_lock(&user->lock);
- if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS &&
+ if (user->qnkeys + 1 >= KEYQUOTA_MAX_KEYS ||
user->qnbytes + quotalen >= KEYQUOTA_MAX_BYTES
)
goto no_quota;
@@ -795,12 +795,16 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref,
goto error_3;
}
- /* search for an existing key of the same type and description in the
- * destination keyring
+ /* if it's possible to update this type of key, search for an existing
+ * key of the same type and description in the destination keyring and
+ * update that instead if possible
*/
- key_ref = __keyring_search_one(keyring_ref, ktype, description, 0);
- if (!IS_ERR(key_ref))
- goto found_matching_key;
+ if (ktype->update) {
+ key_ref = __keyring_search_one(keyring_ref, ktype, description,
+ 0);
+ if (!IS_ERR(key_ref))
+ goto found_matching_key;
+ }
/* decide on the permissions we want */
perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR;
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 0c62798ac7d..ed71d86d2ce 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -17,10 +17,33 @@
#include <linux/keyctl.h>
#include <linux/fs.h>
#include <linux/capability.h>
+#include <linux/string.h>
#include <linux/err.h>
#include <asm/uaccess.h>
#include "internal.h"
+static int key_get_type_from_user(char *type,
+ const char __user *_type,
+ unsigned len)
+{
+ int ret;
+
+ ret = strncpy_from_user(type, _type, len);
+
+ if (ret < 0)
+ return -EFAULT;
+
+ if (ret == 0 || ret >= len)
+ return -EINVAL;
+
+ if (type[0] == '.')
+ return -EPERM;
+
+ type[len - 1] = '\0';
+
+ return 0;
+}
+
/*****************************************************************************/
/*
* extract the description of a new key from userspace and either add it as a
@@ -38,40 +61,22 @@ asmlinkage long sys_add_key(const char __user *_type,
key_ref_t keyring_ref, key_ref;
char type[32], *description;
void *payload;
- long dlen, ret;
+ long ret;
ret = -EINVAL;
if (plen > 32767)
goto error;
/* draw all the data into kernel space */
- ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+ ret = key_get_type_from_user(type, _type, sizeof(type));
if (ret < 0)
goto error;
- type[31] = '\0';
-
- ret = -EPERM;
- if (type[0] == '.')
- goto error;
-
- ret = -EFAULT;
- dlen = strnlen_user(_description, PAGE_SIZE - 1);
- if (dlen <= 0)
- goto error;
- ret = -EINVAL;
- if (dlen > PAGE_SIZE - 1)
- goto error;
-
- ret = -ENOMEM;
- description = kmalloc(dlen + 1, GFP_KERNEL);
- if (!description)
+ description = strndup_user(_description, PAGE_SIZE);
+ if (IS_ERR(description)) {
+ ret = PTR_ERR(description);
goto error;
- description[dlen] = '\0';
-
- ret = -EFAULT;
- if (copy_from_user(description, _description, dlen) != 0)
- goto error2;
+ }
/* pull the payload in if one was supplied */
payload = NULL;
@@ -136,59 +141,28 @@ asmlinkage long sys_request_key(const char __user *_type,
struct key *key;
key_ref_t dest_ref;
char type[32], *description, *callout_info;
- long dlen, ret;
+ long ret;
/* pull the type into kernel space */
- ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+ ret = key_get_type_from_user(type, _type, sizeof(type));
if (ret < 0)
goto error;
- type[31] = '\0';
-
- ret = -EPERM;
- if (type[0] == '.')
- goto error;
/* pull the description into kernel space */
- ret = -EFAULT;
- dlen = strnlen_user(_description, PAGE_SIZE - 1);
- if (dlen <= 0)
- goto error;
-
- ret = -EINVAL;
- if (dlen > PAGE_SIZE - 1)
- goto error;
-
- ret = -ENOMEM;
- description = kmalloc(dlen + 1, GFP_KERNEL);
- if (!description)
+ description = strndup_user(_description, PAGE_SIZE);
+ if (IS_ERR(description)) {
+ ret = PTR_ERR(description);
goto error;
- description[dlen] = '\0';
-
- ret = -EFAULT;
- if (copy_from_user(description, _description, dlen) != 0)
- goto error2;
+ }
/* pull the callout info into kernel space */
callout_info = NULL;
if (_callout_info) {
- ret = -EFAULT;
- dlen = strnlen_user(_callout_info, PAGE_SIZE - 1);
- if (dlen <= 0)
- goto error2;
-
- ret = -EINVAL;
- if (dlen > PAGE_SIZE - 1)
- goto error2;
-
- ret = -ENOMEM;
- callout_info = kmalloc(dlen + 1, GFP_KERNEL);
- if (!callout_info)
+ callout_info = strndup_user(_callout_info, PAGE_SIZE);
+ if (IS_ERR(callout_info)) {
+ ret = PTR_ERR(callout_info);
goto error2;
- callout_info[dlen] = '\0';
-
- ret = -EFAULT;
- if (copy_from_user(callout_info, _callout_info, dlen) != 0)
- goto error3;
+ }
}
/* get the destination keyring if specified */
@@ -264,36 +238,21 @@ long keyctl_get_keyring_ID(key_serial_t id, int create)
long keyctl_join_session_keyring(const char __user *_name)
{
char *name;
- long nlen, ret;
+ long ret;
/* fetch the name from userspace */
name = NULL;
if (_name) {
- ret = -EFAULT;
- nlen = strnlen_user(_name, PAGE_SIZE - 1);
- if (nlen <= 0)
- goto error;
-
- ret = -EINVAL;
- if (nlen > PAGE_SIZE - 1)
+ name = strndup_user(_name, PAGE_SIZE);
+ if (IS_ERR(name)) {
+ ret = PTR_ERR(name);
goto error;
-
- ret = -ENOMEM;
- name = kmalloc(nlen + 1, GFP_KERNEL);
- if (!name)
- goto error;
- name[nlen] = '\0';
-
- ret = -EFAULT;
- if (copy_from_user(name, _name, nlen) != 0)
- goto error2;
+ }
}
/* join the session */
ret = join_session_keyring(name);
- error2:
- kfree(name);
error:
return ret;
@@ -566,32 +525,18 @@ long keyctl_keyring_search(key_serial_t ringid,
struct key_type *ktype;
key_ref_t keyring_ref, key_ref, dest_ref;
char type[32], *description;
- long dlen, ret;
+ long ret;
/* pull the type and description into kernel space */
- ret = strncpy_from_user(type, _type, sizeof(type) - 1);
+ ret = key_get_type_from_user(type, _type, sizeof(type));
if (ret < 0)
goto error;
- type[31] = '\0';
- ret = -EFAULT;
- dlen = strnlen_user(_description, PAGE_SIZE - 1);
- if (dlen <= 0)
+ description = strndup_user(_description, PAGE_SIZE);
+ if (IS_ERR(description)) {
+ ret = PTR_ERR(description);
goto error;
-
- ret = -EINVAL;
- if (dlen > PAGE_SIZE - 1)
- goto error;
-
- ret = -ENOMEM;
- description = kmalloc(dlen + 1, GFP_KERNEL);
- if (!description)
- goto error;
- description[dlen] = '\0';
-
- ret = -EFAULT;
- if (copy_from_user(description, _description, dlen) != 0)
- goto error2;
+ }
/* get the keyring at which to begin the search */
keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH);
diff --git a/security/seclvl.c b/security/seclvl.c
index 8529ea6f7aa..441beaf1bbc 100644
--- a/security/seclvl.c
+++ b/security/seclvl.c
@@ -8,6 +8,7 @@
* Copyright (c) 2001 WireX Communications, Inc <chris@wirex.com>
* Copyright (c) 2001 Greg Kroah-Hartman <greg@kroah.com>
* Copyright (c) 2002 International Business Machines <robb@austin.ibm.com>
+ * Copyright (c) 2006 Davi E. M. Arnaut <davi.arnaut@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,6 +32,7 @@
#include <linux/kobject.h>
#include <linux/crypto.h>
#include <asm/scatterlist.h>
+#include <linux/scatterlist.h>
#include <linux/gfp.h>
#include <linux/sysfs.h>
@@ -194,35 +196,27 @@ static unsigned char hashedPassword[SHA1_DIGEST_SIZE];
* people...
*/
static int
-plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
+plaintext_to_sha1(unsigned char *hash, const char *plaintext, unsigned int len)
{
- char *pgVirtAddr;
struct crypto_tfm *tfm;
- struct scatterlist sg[1];
+ struct scatterlist sg;
if (len > PAGE_SIZE) {
seclvl_printk(0, KERN_ERR, "Plaintext password too large (%d "
"characters). Largest possible is %lu "
"bytes.\n", len, PAGE_SIZE);
- return -ENOMEM;
+ return -EINVAL;
}
tfm = crypto_alloc_tfm("sha1", CRYPTO_TFM_REQ_MAY_SLEEP);
if (tfm == NULL) {
seclvl_printk(0, KERN_ERR,
"Failed to load transform for SHA1\n");
- return -ENOSYS;
+ return -EINVAL;
}
- // Just get a new page; don't play around with page boundaries
- // and scatterlists.
- pgVirtAddr = (char *)__get_free_page(GFP_KERNEL);
- sg[0].page = virt_to_page(pgVirtAddr);
- sg[0].offset = 0;
- sg[0].length = len;
- strncpy(pgVirtAddr, plaintext, len);
+ sg_init_one(&sg, (u8 *)plaintext, len);
crypto_digest_init(tfm);
- crypto_digest_update(tfm, sg, 1);
+ crypto_digest_update(tfm, &sg, 1);
crypto_digest_final(tfm, hash);
crypto_free_tfm(tfm);
- free_page((unsigned long)pgVirtAddr);
return 0;
}
@@ -234,11 +228,9 @@ static ssize_t
passwd_write_file(struct file * file, const char __user * buf,
size_t count, loff_t *ppos)
{
- int i;
- unsigned char tmp[SHA1_DIGEST_SIZE];
- char *page;
- int rc;
+ char *p;
int len;
+ unsigned char tmp[SHA1_DIGEST_SIZE];
if (!*passwd && !*sha1_passwd) {
seclvl_printk(0, KERN_ERR, "Attempt to password-unlock the "
@@ -251,38 +243,39 @@ passwd_write_file(struct file * file, const char __user * buf,
return -EINVAL;
}
- if (count < 0 || count >= PAGE_SIZE)
+ if (count >= PAGE_SIZE)
return -EINVAL;
if (*ppos != 0)
return -EINVAL;
- page = (char *)get_zeroed_page(GFP_KERNEL);
- if (!page)
+ p = kmalloc(count, GFP_KERNEL);
+ if (!p)
return -ENOMEM;
len = -EFAULT;
- if (copy_from_user(page, buf, count))
+ if (copy_from_user(p, buf, count))
goto out;
- len = strlen(page);
+ len = count;
/* ``echo "secret" > seclvl/passwd'' includes a newline */
- if (page[len - 1] == '\n')
+ if (p[len - 1] == '\n')
len--;
/* Hash the password, then compare the hashed values */
- if ((rc = plaintext_to_sha1(tmp, page, len))) {
+ if ((len = plaintext_to_sha1(tmp, p, len))) {
seclvl_printk(0, KERN_ERR, "Error hashing password: rc = "
- "[%d]\n", rc);
- return rc;
- }
- for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
- if (hashedPassword[i] != tmp[i])
- return -EPERM;
+ "[%d]\n", len);
+ goto out;
}
+
+ len = -EPERM;
+ if (memcmp(hashedPassword, tmp, SHA1_DIGEST_SIZE))
+ goto out;
+
seclvl_printk(0, KERN_INFO,
"Password accepted; seclvl reduced to 0.\n");
seclvl = 0;
len = count;
out:
- free_page((unsigned long)page);
+ kfree (p);
return len;
}
@@ -295,13 +288,11 @@ static struct file_operations passwd_file_ops = {
*/
static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
{
- if (seclvl >= 0) {
- if (child->pid == 1) {
- seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
- "the init process dissallowed in "
- "secure level %d\n", seclvl);
- return -EPERM;
- }
+ if (seclvl >= 0 && child->pid == 1) {
+ seclvl_printk(1, KERN_WARNING, "Attempt to ptrace "
+ "the init process dissallowed in "
+ "secure level %d\n", seclvl);
+ return -EPERM;
}
return 0;
}
@@ -312,55 +303,54 @@ static int seclvl_ptrace(struct task_struct *parent, struct task_struct *child)
*/
static int seclvl_capable(struct task_struct *tsk, int cap)
{
+ int rc = 0;
+
/* init can do anything it wants */
if (tsk->pid == 1)
return 0;
- switch (seclvl) {
- case 2:
- /* fall through */
- case 1:
- if (cap == CAP_LINUX_IMMUTABLE) {
+ if (seclvl > 0) {
+ rc = -EPERM;
+
+ if (cap == CAP_LINUX_IMMUTABLE)
seclvl_printk(1, KERN_WARNING, "Attempt to modify "
"the IMMUTABLE and/or APPEND extended "
"attribute on a file with the IMMUTABLE "
"and/or APPEND extended attribute set "
"denied in seclvl [%d]\n", seclvl);
- return -EPERM;
- } else if (cap == CAP_SYS_RAWIO) { // Somewhat broad...
+ else if (cap == CAP_SYS_RAWIO)
seclvl_printk(1, KERN_WARNING, "Attempt to perform "
"raw I/O while in secure level [%d] "
"denied\n", seclvl);
- return -EPERM;
- } else if (cap == CAP_NET_ADMIN) {
+ else if (cap == CAP_NET_ADMIN)
seclvl_printk(1, KERN_WARNING, "Attempt to perform "
"network administrative task while "
"in secure level [%d] denied\n", seclvl);
- return -EPERM;
- } else if (cap == CAP_SETUID) {
+ else if (cap == CAP_SETUID)
seclvl_printk(1, KERN_WARNING, "Attempt to setuid "
"while in secure level [%d] denied\n",
seclvl);
- return -EPERM;
- } else if (cap == CAP_SETGID) {
+ else if (cap == CAP_SETGID)
seclvl_printk(1, KERN_WARNING, "Attempt to setgid "
"while in secure level [%d] denied\n",
seclvl);
- } else if (cap == CAP_SYS_MODULE) {
+ else if (cap == CAP_SYS_MODULE)
seclvl_printk(1, KERN_WARNING, "Attempt to perform "
"a module operation while in secure "
"level [%d] denied\n", seclvl);
- return -EPERM;
- }
- break;
- default:
- break;
+ else
+ rc = 0;
}
- /* from dummy.c */
- if (cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0)
- return 0; /* capability granted */
- seclvl_printk(1, KERN_WARNING, "Capability denied\n");
- return -EPERM; /* capability denied */
+
+ if (!rc) {
+ if (!(cap_is_fs_cap(cap) ? tsk->fsuid == 0 : tsk->euid == 0))
+ rc = -EPERM;
+ }
+
+ if (rc)
+ seclvl_printk(1, KERN_WARNING, "Capability denied\n");
+
+ return rc;
}
/**
@@ -466,12 +456,9 @@ static int seclvl_inode_setattr(struct dentry *dentry, struct iattr *iattr)
static void seclvl_file_free_security(struct file *filp)
{
struct dentry *dentry = filp->f_dentry;
- struct inode *inode = NULL;
- if (dentry) {
- inode = dentry->d_inode;
- seclvl_bd_release(inode);
- }
+ if (dentry)
+ seclvl_bd_release(dentry->d_inode);
}
/**
@@ -479,9 +466,7 @@ static void seclvl_file_free_security(struct file *filp)
*/
static int seclvl_umount(struct vfsmount *mnt, int flags)
{
- if (current->pid == 1)
- return 0;
- if (seclvl == 2) {
+ if (current->pid != 1 && seclvl == 2) {
seclvl_printk(1, KERN_WARNING, "Attempt to unmount in secure "
"level %d\n", seclvl);
return -EPERM;
@@ -505,8 +490,9 @@ static struct security_operations seclvl_ops = {
static int processPassword(void)
{
int rc = 0;
- hashedPassword[0] = '\0';
if (*passwd) {
+ char *p;
+
if (*sha1_passwd) {
seclvl_printk(0, KERN_ERR, "Error: Both "
"passwd and sha1_passwd "
@@ -514,12 +500,16 @@ static int processPassword(void)
"exclusive.\n");
return -EINVAL;
}
- if ((rc = plaintext_to_sha1(hashedPassword, passwd,
- strlen(passwd)))) {
+
+ p = kstrdup(passwd, GFP_KERNEL);
+ if (p == NULL)
+ return -ENOMEM;
+
+ if ((rc = plaintext_to_sha1(hashedPassword, p, strlen(p))))
seclvl_printk(0, KERN_ERR, "Error: SHA1 support not "
"in kernel\n");
- return rc;
- }
+
+ kfree (p);
/* All static data goes to the BSS, which zero's the
* plaintext password out for us. */
} else if (*sha1_passwd) { // Base 16
@@ -542,7 +532,7 @@ static int processPassword(void)
sha1_passwd[i + 2] = tmp;
}
}
- return 0;
+ return rc;
}
/**
@@ -552,28 +542,46 @@ struct dentry *dir_ino, *seclvl_ino, *passwd_ino;
static int seclvlfs_register(void)
{
+ int rc = 0;
+
dir_ino = securityfs_create_dir("seclvl", NULL);
- if (!dir_ino)
- return -EFAULT;
+
+ if (IS_ERR(dir_ino))
+ return PTR_ERR(dir_ino);
seclvl_ino = securityfs_create_file("seclvl", S_IRUGO | S_IWUSR,
dir_ino, &seclvl, &seclvl_file_ops);
- if (!seclvl_ino)
+ if (IS_ERR(seclvl_ino)) {
+ rc = PTR_ERR(seclvl_ino);
goto out_deldir;
+ }
if (*passwd || *sha1_passwd) {
passwd_ino = securityfs_create_file("passwd", S_IRUGO | S_IWUSR,
dir_ino, NULL, &passwd_file_ops);
- if (!passwd_ino)
+ if (IS_ERR(passwd_ino)) {
+ rc = PTR_ERR(passwd_ino);
goto out_delf;
+ }
}
- return 0;
+ return rc;
+
+out_delf:
+ securityfs_remove(seclvl_ino);
out_deldir:
securityfs_remove(dir_ino);
-out_delf:
+
+ return rc;
+}
+
+static void seclvlfs_unregister(void)
+{
securityfs_remove(seclvl_ino);
- return -EFAULT;
+ if (*passwd || *sha1_passwd)
+ securityfs_remove(passwd_ino);
+
+ securityfs_remove(dir_ino);
}
/**
@@ -582,6 +590,8 @@ out_delf:
static int __init seclvl_init(void)
{
int rc = 0;
+ static char once;
+
if (verbosity < 0 || verbosity > 1) {
printk(KERN_ERR "Error: bad verbosity [%d]; only 0 or 1 "
"are valid values\n", verbosity);
@@ -600,6 +610,11 @@ static int __init seclvl_init(void)
"module parameter(s): rc = [%d]\n", rc);
goto exit;
}
+
+ if ((rc = seclvlfs_register())) {
+ seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
+ goto exit;
+ }
/* register ourselves with the security framework */
if (register_security(&seclvl_ops)) {
seclvl_printk(0, KERN_ERR,
@@ -611,20 +626,24 @@ static int __init seclvl_init(void)
seclvl_printk(0, KERN_ERR, "seclvl: Failure "
"registering with primary security "
"module.\n");
+ seclvlfs_unregister();
goto exit;
} /* if primary module registered */
secondary = 1;
} /* if we registered ourselves with the security framework */
- if ((rc = seclvlfs_register())) {
- seclvl_printk(0, KERN_ERR, "Error registering with sysfs\n");
- goto exit;
- }
+
seclvl_printk(0, KERN_INFO, "seclvl: Successfully initialized.\n");
+
+ if (once) {
+ once = 1;
+ seclvl_printk(0, KERN_INFO, "seclvl is going away. It has been "
+ "buggy for ages. Also, be warned that "
+ "Securelevels are useless.");
+ }
exit:
- if (rc) {
+ if (rc)
printk(KERN_ERR "seclvl: Error during initialization: rc = "
"[%d]\n", rc);
- }
return rc;
}
@@ -633,17 +652,14 @@ static int __init seclvl_init(void)
*/
static void __exit seclvl_exit(void)
{
- securityfs_remove(seclvl_ino);
- if (*passwd || *sha1_passwd)
- securityfs_remove(passwd_ino);
- securityfs_remove(dir_ino);
- if (secondary == 1) {
+ seclvlfs_unregister();
+
+ if (secondary)
mod_unreg_security(MY_NAME, &seclvl_ops);
- } else if (unregister_security(&seclvl_ops)) {
+ else if (unregister_security(&seclvl_ops))
seclvl_printk(0, KERN_INFO,
"seclvl: Failure unregistering with the "
"kernel\n");
- }
}
module_init(seclvl_init);
diff --git a/security/security.c b/security/security.c
index f693e1f66b9..51ef509710b 100644
--- a/security/security.c
+++ b/security/security.c
@@ -174,31 +174,8 @@ int mod_unreg_security(const char *name, struct security_operations *ops)
return security_ops->unregister_security(name, ops);
}
-/**
- * capable - calls the currently loaded security module's capable() function with the specified capability
- * @cap: the requested capability level.
- *
- * This function calls the currently loaded security module's capable()
- * function with a pointer to the current task and the specified @cap value.
- *
- * This allows the security module to implement the capable function call
- * however it chooses to.
- */
-int capable(int cap)
-{
- if (security_ops->capable(current, cap)) {
- /* capability denied */
- return 0;
- }
-
- /* capability granted */
- current->flags |= PF_SUPERPRIV;
- return 1;
-}
-
EXPORT_SYMBOL_GPL(register_security);
EXPORT_SYMBOL_GPL(unregister_security);
EXPORT_SYMBOL_GPL(mod_reg_security);
EXPORT_SYMBOL_GPL(mod_unreg_security);
-EXPORT_SYMBOL(capable);
EXPORT_SYMBOL(security_ops);
diff --git a/sound/oss/.gitignore b/sound/oss/.gitignore
new file mode 100644
index 00000000000..7efb12b4550
--- /dev/null
+++ b/sound/oss/.gitignore
@@ -0,0 +1,4 @@
+#Ignore generated files
+maui_boot.h
+pss_boot.h
+trix_boot.h
diff --git a/sound/oss/ac97_codec.c b/sound/oss/ac97_codec.c
index fd25aca2512..972327c9764 100644
--- a/sound/oss/ac97_codec.c
+++ b/sound/oss/ac97_codec.c
@@ -55,7 +55,7 @@
#include <linux/pci.h>
#include <linux/ac97_codec.h>
#include <asm/uaccess.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#define CODEC_ID_BUFSZ 14
@@ -304,7 +304,7 @@ static const unsigned int ac97_oss_rm[] = {
static LIST_HEAD(codecs);
static LIST_HEAD(codec_drivers);
-static DECLARE_MUTEX(codec_sem);
+static DEFINE_MUTEX(codec_mutex);
/* reads the given OSS mixer from the ac97 the caller must have insured that the ac97 knows
about that given mixer, and should be holding a spinlock for the card */
@@ -769,9 +769,9 @@ void ac97_release_codec(struct ac97_codec *codec)
{
/* Remove from the list first, we don't want to be
"rediscovered" */
- down(&codec_sem);
+ mutex_lock(&codec_mutex);
list_del(&codec->list);
- up(&codec_sem);
+ mutex_unlock(&codec_mutex);
/*
* The driver needs to deal with internal
* locking to avoid accidents here.
@@ -889,7 +889,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
* callbacks.
*/
- down(&codec_sem);
+ mutex_lock(&codec_mutex);
list_add(&codec->list, &codecs);
list_for_each(l, &codec_drivers) {
@@ -903,7 +903,7 @@ int ac97_probe_codec(struct ac97_codec *codec)
}
}
- up(&codec_sem);
+ mutex_unlock(&codec_mutex);
return 1;
}
@@ -1439,7 +1439,7 @@ int ac97_register_driver(struct ac97_driver *driver)
struct list_head *l;
struct ac97_codec *c;
- down(&codec_sem);
+ mutex_lock(&codec_mutex);
INIT_LIST_HEAD(&driver->list);
list_add(&driver->list, &codec_drivers);
@@ -1452,7 +1452,7 @@ int ac97_register_driver(struct ac97_driver *driver)
continue;
c->driver = driver;
}
- up(&codec_sem);
+ mutex_unlock(&codec_mutex);
return 0;
}
@@ -1471,7 +1471,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
struct list_head *l;
struct ac97_codec *c;
- down(&codec_sem);
+ mutex_lock(&codec_mutex);
list_del_init(&driver->list);
list_for_each(l, &codecs)
@@ -1483,7 +1483,7 @@ void ac97_unregister_driver(struct ac97_driver *driver)
}
}
- up(&codec_sem);
+ mutex_unlock(&codec_mutex);
}
EXPORT_SYMBOL_GPL(ac97_unregister_driver);
@@ -1494,14 +1494,14 @@ static int swap_headphone(int remove_master)
struct ac97_codec *c;
if (remove_master) {
- down(&codec_sem);
+ mutex_lock(&codec_mutex);
list_for_each(l, &codecs)
{
c = list_entry(l, struct ac97_codec, list);
if (supported_mixer(c, SOUND_MIXER_PHONEOUT))
c->supported_mixers &= ~SOUND_MASK_PHONEOUT;
}
- up(&codec_sem);
+ mutex_unlock(&codec_mutex);
} else
ac97_hw[SOUND_MIXER_PHONEOUT].offset = AC97_MASTER_VOL_STEREO;
diff --git a/sound/oss/aci.c b/sound/oss/aci.c
index 3928c2802cc..3bfac375dbd 100644
--- a/sound/oss/aci.c
+++ b/sound/oss/aci.c
@@ -56,7 +56,8 @@
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/uaccess.h>
#include "sound_config.h"
@@ -79,7 +80,7 @@ static int aci_micpreamp=3; /* microphone preamp-level that can't be *
* checked with ACI versions prior to 0xb0 */
static int mixer_device;
-static struct semaphore aci_sem;
+static struct mutex aci_mutex;
#ifdef MODULE
static int reset;
@@ -212,7 +213,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
int write[] = {write1, write2, write3};
int read = -EINTR, i;
- if (down_interruptible(&aci_sem))
+ if (mutex_lock_interruptible(&aci_mutex))
goto out;
for (i=0; i<3; i++) {
@@ -227,7 +228,7 @@ int aci_rw_cmd(int write1, int write2, int write3)
}
read = aci_rawread();
-out_up: up(&aci_sem);
+out_up: mutex_unlock(&aci_mutex);
out: return read;
}
@@ -603,7 +604,7 @@ static int __init attach_aci(void)
char *boardname;
int i, rc = -EBUSY;
- init_MUTEX(&aci_sem);
+ mutex_init(&aci_mutex);
outb(0xE3, 0xf8f); /* Write MAD16 password */
aci_port = (inb(0xf90) & 0x10) ?
diff --git a/sound/oss/ad1889.c b/sound/oss/ad1889.c
index a0d73f34310..54dabf86280 100644
--- a/sound/oss/ad1889.c
+++ b/sound/oss/ad1889.c
@@ -38,6 +38,7 @@
#include <linux/ac97_codec.h>
#include <linux/sound.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
#include <asm/delay.h>
#include <asm/io.h>
@@ -238,7 +239,7 @@ static ad1889_dev_t *ad1889_alloc_dev(struct pci_dev *pci)
for (i = 0; i < AD_MAX_STATES; i++) {
dev->state[i].card = dev;
- init_MUTEX(&dev->state[i].sem);
+ mutex_init(&dev->state[i].mutex);
init_waitqueue_head(&dev->state[i].dmabuf.wait);
}
@@ -461,7 +462,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
ssize_t ret = 0;
DECLARE_WAITQUEUE(wait, current);
- down(&state->sem);
+ mutex_lock(&state->mutex);
#if 0
if (dmabuf->mapped) {
ret = -ENXIO;
@@ -546,7 +547,7 @@ static ssize_t ad1889_write(struct file *file, const char __user *buffer, size_t
err2:
remove_wait_queue(&state->dmabuf.wait, &wait);
err1:
- up(&state->sem);
+ mutex_unlock(&state->mutex);
return ret;
}
diff --git a/sound/oss/ad1889.h b/sound/oss/ad1889.h
index e04affce1dd..861b3213f30 100644
--- a/sound/oss/ad1889.h
+++ b/sound/oss/ad1889.h
@@ -100,7 +100,7 @@ typedef struct ad1889_state {
unsigned int subdivision;
} dmabuf;
- struct semaphore sem;
+ struct mutex mutex;
} ad1889_state_t;
typedef struct ad1889_dev {
diff --git a/sound/oss/ali5455.c b/sound/oss/ali5455.c
index 9c9e6c0410f..62bb936b1f3 100644
--- a/sound/oss/ali5455.c
+++ b/sound/oss/ali5455.c
@@ -64,6 +64,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
#ifndef PCI_DEVICE_ID_ALI_5455
@@ -234,7 +236,7 @@ struct ali_state {
struct ali_card *card; /* Card info */
/* single open lock mechanism, only used for recording */
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
/* file mode */
@@ -2807,7 +2809,7 @@ found_virt:
state->card = card;
state->magic = ALI5455_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
file->private_data = state;
dmabuf->trigger = 0;
/* allocate hardware channels */
@@ -3359,7 +3361,7 @@ static void __devinit ali_configure_clocking(void)
state->card = card;
state->magic = ALI5455_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
dmabuf->fmt = ALI5455_FMT_STEREO | ALI5455_FMT_16BIT;
dmabuf->trigger = PCM_ENABLE_OUTPUT;
ali_set_dac_rate(state, 48000);
diff --git a/sound/oss/au1000.c b/sound/oss/au1000.c
index c407de86cbb..eacb0aef21e 100644
--- a/sound/oss/au1000.c
+++ b/sound/oss/au1000.c
@@ -68,6 +68,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/mach-au1x00/au1000.h>
@@ -98,7 +100,7 @@
/* Boot options */
static int vra = 0; // 0 = no VRA, 1 = use VRA if codec supports it
-MODULE_PARM(vra, "i");
+module_param(vra, bool, 0);
MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it");
@@ -120,8 +122,8 @@ struct au1000_state {
int no_vra; // do not use VRA
spinlock_t lock;
- struct semaphore open_sem;
- struct semaphore sem;
+ struct mutex open_mutex;
+ struct mutex sem;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1106,7 +1108,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
count *= db->cnt_factor;
- down(&s->sem);
+ mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
@@ -1125,14 +1127,14 @@ static ssize_t au1000_read(struct file *file, char *buffer,
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
}
} while (avail <= 0);
@@ -1159,7 +1161,7 @@ static ssize_t au1000_read(struct file *file, char *buffer,
} // while (count > 0)
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
@@ -1187,7 +1189,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
count *= db->cnt_factor;
- down(&s->sem);
+ mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
@@ -1204,14 +1206,14 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
}
} while (avail <= 0);
@@ -1240,7 +1242,7 @@ static ssize_t au1000_write(struct file *file, const char *buffer,
} // while (count > 0)
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
@@ -1298,7 +1300,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
dbg("%s", __FUNCTION__);
lock_kernel();
- down(&s->sem);
+ mutex_lock(&s->sem);
if (vma->vm_flags & VM_WRITE)
db = &s->dma_dac;
else if (vma->vm_flags & VM_READ)
@@ -1324,7 +1326,7 @@ static int au1000_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags &= ~VM_IO;
db->mapped = 1;
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
unlock_kernel();
return ret;
}
@@ -1829,21 +1831,21 @@ static int au1000_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
stop_dac(s);
@@ -1879,8 +1881,8 @@ static int au1000_open(struct inode *inode, struct file *file)
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
- init_MUTEX(&s->sem);
+ mutex_unlock(&s->open_mutex);
+ mutex_init(&s->sem);
return nonseekable_open(inode, file);
}
@@ -1896,7 +1898,7 @@ static int au1000_release(struct inode *inode, struct file *file)
lock_kernel();
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
@@ -1906,7 +1908,7 @@ static int au1000_release(struct inode *inode, struct file *file)
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -1996,7 +1998,7 @@ static int __devinit au1000_probe(void)
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->codec.private_data = s;
s->codec.id = 0;
diff --git a/sound/oss/au1550_ac97.c b/sound/oss/au1550_ac97.c
index bdee0502f3e..c1168fae6be 100644
--- a/sound/oss/au1550_ac97.c
+++ b/sound/oss/au1550_ac97.c
@@ -52,6 +52,8 @@
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/uaccess.h>
#include <asm/hardirq.h>
@@ -77,7 +79,7 @@
* 0 = no VRA, 1 = use VRA if codec supports it
*/
static int vra = 1;
-MODULE_PARM(vra, "i");
+module_param(vra, bool, 0);
MODULE_PARM_DESC(vra, "if 1 use VRA if codec supports it");
static struct au1550_state {
@@ -90,8 +92,8 @@ static struct au1550_state {
int no_vra; /* do not use VRA */
spinlock_t lock;
- struct semaphore open_sem;
- struct semaphore sem;
+ struct mutex open_mutex;
+ struct mutex sem;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1044,7 +1046,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
count *= db->cnt_factor;
- down(&s->sem);
+ mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
@@ -1064,14 +1066,14 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
}
} while (avail <= 0);
@@ -1099,7 +1101,7 @@ au1550_read(struct file *file, char *buffer, size_t count, loff_t *ppos)
} /* while (count > 0) */
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
@@ -1125,7 +1127,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
count *= db->cnt_factor;
- down(&s->sem);
+ mutex_lock(&s->sem);
add_wait_queue(&db->wait, &wait);
while (count > 0) {
@@ -1143,14 +1145,14 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
}
} while (avail <= 0);
@@ -1196,7 +1198,7 @@ au1550_write(struct file *file, const char *buffer, size_t count, loff_t * ppos)
} /* while (count > 0) */
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&db->wait, &wait);
set_current_state(TASK_RUNNING);
@@ -1253,7 +1255,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
int ret = 0;
lock_kernel();
- down(&s->sem);
+ mutex_lock(&s->sem);
if (vma->vm_flags & VM_WRITE)
db = &s->dma_dac;
else if (vma->vm_flags & VM_READ)
@@ -1279,7 +1281,7 @@ au1550_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_flags &= ~VM_IO;
db->mapped = 1;
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
unlock_kernel();
return ret;
}
@@ -1790,21 +1792,21 @@ au1550_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
stop_dac(s);
@@ -1840,8 +1842,8 @@ au1550_open(struct inode *inode, struct file *file)
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
- init_MUTEX(&s->sem);
+ mutex_unlock(&s->open_mutex);
+ mutex_init(&s->sem);
return 0;
}
@@ -1858,7 +1860,7 @@ au1550_release(struct inode *inode, struct file *file)
lock_kernel();
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
kfree(s->dma_dac.rawbuf);
@@ -1870,7 +1872,7 @@ au1550_release(struct inode *inode, struct file *file)
s->dma_adc.rawbuf = NULL;
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -1902,7 +1904,7 @@ au1550_probe(void)
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->codec = ac97_alloc_codec();
diff --git a/sound/oss/awe_wave.c b/sound/oss/awe_wave.c
index b3ea719d33d..d1a0eb294d6 100644
--- a/sound/oss/awe_wave.c
+++ b/sound/oss/awe_wave.c
@@ -2944,7 +2944,7 @@ alloc_new_info(void)
{
awe_voice_list *newlist;
- newlist = (awe_voice_list *)kmalloc(sizeof(*newlist), GFP_KERNEL);
+ newlist = kmalloc(sizeof(*newlist), GFP_KERNEL);
if (newlist == NULL) {
printk(KERN_ERR "AWE32: can't alloc info table\n");
return NULL;
@@ -3547,8 +3547,10 @@ awe_load_guspatch(const char __user *addr, int offs, int size, int pmgr_flag)
smp->checksum_flag = 0;
smp->checksum = 0;
- if ((rc = awe_write_wave_data(addr, sizeof_patch, smprec, -1)) < 0)
+ if ((rc = awe_write_wave_data(addr, sizeof_patch, smprec, -1)) < 0) {
+ kfree(vrec);
return rc;
+ }
sf->mem_ptr += rc;
add_sf_sample(sf, smprec);
diff --git a/sound/oss/btaudio.c b/sound/oss/btaudio.c
index 4007a5680ac..bfe3b534ef3 100644
--- a/sound/oss/btaudio.c
+++ b/sound/oss/btaudio.c
@@ -32,6 +32,8 @@
#include <linux/soundcard.h>
#include <linux/slab.h>
#include <linux/kdev_t.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -108,7 +110,7 @@ struct btaudio {
/* locking */
int users;
- struct semaphore lock;
+ struct mutex lock;
/* risc instructions */
unsigned int risc_size;
@@ -440,7 +442,7 @@ static struct file_operations btaudio_mixer_fops = {
static int btaudio_dsp_open(struct inode *inode, struct file *file,
struct btaudio *bta, int analog)
{
- down(&bta->lock);
+ mutex_lock(&bta->lock);
if (bta->users)
goto busy;
bta->users++;
@@ -452,11 +454,11 @@ static int btaudio_dsp_open(struct inode *inode, struct file *file,
bta->read_count = 0;
bta->sampleshift = 0;
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
return 0;
busy:
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
return -EBUSY;
}
@@ -496,11 +498,11 @@ static int btaudio_dsp_release(struct inode *inode, struct file *file)
{
struct btaudio *bta = file->private_data;
- down(&bta->lock);
+ mutex_lock(&bta->lock);
if (bta->recording)
stop_recording(bta);
bta->users--;
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
return 0;
}
@@ -513,7 +515,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(&bta->readq, &wait);
- down(&bta->lock);
+ mutex_lock(&bta->lock);
while (swcount > 0) {
if (0 == bta->read_count) {
if (!bta->recording) {
@@ -528,10 +530,10 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
ret = -EAGAIN;
break;
}
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
current->state = TASK_INTERRUPTIBLE;
schedule();
- down(&bta->lock);
+ mutex_lock(&bta->lock);
if(signal_pending(current)) {
if (0 == ret)
ret = -EINTR;
@@ -604,7 +606,7 @@ static ssize_t btaudio_dsp_read(struct file *file, char __user *buffer,
if (bta->read_offset == bta->buf_size)
bta->read_offset = 0;
}
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
remove_wait_queue(&bta->readq, &wait);
current->state = TASK_RUNNING;
return ret;
@@ -651,10 +653,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
bta->decimation = 0;
}
if (bta->recording) {
- down(&bta->lock);
+ mutex_lock(&bta->lock);
stop_recording(bta);
start_recording(bta);
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
}
/* fall through */
case SOUND_PCM_READ_RATE:
@@ -716,10 +718,10 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
else
bta->bits = 16;
if (bta->recording) {
- down(&bta->lock);
+ mutex_lock(&bta->lock);
stop_recording(bta);
start_recording(bta);
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
}
}
if (debug)
@@ -736,9 +738,9 @@ static int btaudio_dsp_ioctl(struct inode *inode, struct file *file,
case SNDCTL_DSP_RESET:
if (bta->recording) {
- down(&bta->lock);
+ mutex_lock(&bta->lock);
stop_recording(bta);
- up(&bta->lock);
+ mutex_unlock(&bta->lock);
}
return 0;
case SNDCTL_DSP_GETBLKSIZE:
@@ -941,7 +943,7 @@ static int __devinit btaudio_probe(struct pci_dev *pci_dev,
if (rate)
bta->rate = rate;
- init_MUTEX(&bta->lock);
+ mutex_init(&bta->lock);
init_waitqueue_head(&bta->readq);
if (-1 != latency) {
diff --git a/sound/oss/cmpci.c b/sound/oss/cmpci.c
index 7cfbb08db53..1fbd5137f6d 100644
--- a/sound/oss/cmpci.c
+++ b/sound/oss/cmpci.c
@@ -138,6 +138,8 @@
#endif
#ifdef CONFIG_SOUND_CMPCI_JOYSTICK
#include <linux/gameport.h>
+#include <linux/mutex.h>
+
#endif
/* --------------------------------------------------------------------- */
@@ -392,7 +394,7 @@ struct cm_state {
unsigned char fmt, enable;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -2825,21 +2827,21 @@ static int cm_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
if (file->f_mode & FMODE_READ) {
s->status &= ~DO_BIGENDIAN_R;
@@ -2867,7 +2869,7 @@ static int cm_open(struct inode *inode, struct file *file)
}
set_fmt(s, fmtm, fmts);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2879,7 +2881,7 @@ static int cm_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
@@ -2903,7 +2905,7 @@ static int cm_release(struct inode *inode, struct file *file)
s->status &= ~DO_BIGENDIAN_R;
}
s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -3080,7 +3082,7 @@ static int __devinit cm_probe(struct pci_dev *pcidev, const struct pci_device_id
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->magic = CM_MAGIC;
s->dev = pcidev;
diff --git a/sound/oss/cs4281/cs4281m.c b/sound/oss/cs4281/cs4281m.c
index 0720365f643..0004442f9b7 100644
--- a/sound/oss/cs4281/cs4281m.c
+++ b/sound/oss/cs4281/cs4281m.c
@@ -245,9 +245,9 @@ struct cs4281_state {
void *tmpbuff; // tmp buffer for sample conversions
unsigned ena;
spinlock_t lock;
- struct semaphore open_sem;
- struct semaphore open_sem_adc;
- struct semaphore open_sem_dac;
+ struct mutex open_sem;
+ struct mutex open_sem_adc;
+ struct mutex open_sem_dac;
mode_t open_mode;
wait_queue_head_t open_wait;
wait_queue_head_t open_wait_adc;
@@ -3598,20 +3598,20 @@ static int cs4281_release(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_WRITE) {
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
s->open_mode &= ~FMODE_WRITE;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
wake_up(&s->open_wait_dac);
}
if (file->f_mode & FMODE_READ) {
drain_adc(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
stop_adc(s);
dealloc_dmabuf(s, &s->dma_adc);
s->open_mode &= ~FMODE_READ;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
wake_up(&s->open_wait_adc);
}
return 0;
@@ -3651,33 +3651,33 @@ static int cs4281_open(struct inode *inode, struct file *file)
return -ENODEV;
}
if (file->f_mode & FMODE_WRITE) {
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
while (s->open_mode & FMODE_WRITE) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
return -EBUSY;
}
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
interruptible_sleep_on(&s->open_wait_dac);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
}
}
if (file->f_mode & FMODE_READ) {
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
while (s->open_mode & FMODE_READ) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
return -EBUSY;
}
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
interruptible_sleep_on(&s->open_wait_adc);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
}
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
@@ -3691,7 +3691,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_READ;
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
s->dma_adc.subdivision = 0;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
if (prog_dmabuf_adc(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -3711,7 +3711,7 @@ static int cs4281_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_WRITE;
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
s->dma_dac.subdivision = 0;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
if (prog_dmabuf_dac(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -3978,17 +3978,17 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
// wait for device to become free
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
return -EBUSY;
}
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
interruptible_sleep_on(&s->open_wait);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -4018,7 +4018,7 @@ static int cs4281_midi_open(struct inode *inode, struct file *file)
(file->
f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
return nonseekable_open(inode, file);
}
@@ -4057,7 +4057,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait);
current->state = TASK_RUNNING;
}
- down(&s->open_sem);
+ mutex_lock(&s->open_sem);
s->open_mode &=
(~(file->f_mode << FMODE_MIDI_SHIFT)) & (FMODE_MIDI_READ |
FMODE_MIDI_WRITE);
@@ -4067,7 +4067,7 @@ static int cs4281_midi_release(struct inode *inode, struct file *file)
del_timer(&s->midi.timer);
}
spin_unlock_irqrestore(&s->lock, flags);
- up(&s->open_sem);
+ mutex_unlock(&s->open_sem);
wake_up(&s->open_wait);
return 0;
}
@@ -4300,9 +4300,9 @@ static int __devinit cs4281_probe(struct pci_dev *pcidev,
init_waitqueue_head(&s->open_wait_dac);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
- init_MUTEX(&s->open_sem_adc);
- init_MUTEX(&s->open_sem_dac);
+ mutex_init(&s->open_sem);
+ mutex_init(&s->open_sem_adc);
+ mutex_init(&s->open_sem_dac);
spin_lock_init(&s->lock);
s->pBA0phys = pci_resource_start(pcidev, 0);
s->pBA1phys = pci_resource_start(pcidev, 1);
diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c
index 58e25c82eaf..53881bc91bb 100644
--- a/sound/oss/cs46xx.c
+++ b/sound/oss/cs46xx.c
@@ -90,6 +90,7 @@
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/ac97_codec.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/dma.h>
@@ -238,7 +239,7 @@ struct cs_state {
struct cs_card *card; /* Card info */
/* single open lock mechanism, only used for recording */
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
/* file mode */
@@ -297,7 +298,7 @@ struct cs_state {
unsigned subdivision;
} dmabuf;
/* Guard against mmap/write/read races */
- struct semaphore sem;
+ struct mutex sem;
};
struct cs_card {
@@ -375,7 +376,7 @@ struct cs_card {
unsigned char ibuf[CS_MIDIINBUF];
unsigned char obuf[CS_MIDIOUTBUF];
mode_t open_mode;
- struct semaphore open_sem;
+ struct mutex open_mutex;
} midi;
struct cs46xx_pm pm;
};
@@ -1428,9 +1429,9 @@ static int prog_dmabuf(struct cs_state *state)
{
int ret;
- down(&state->sem);
+ mutex_lock(&state->sem);
ret = __prog_dmabuf(state);
- up(&state->sem);
+ mutex_unlock(&state->sem);
return ret;
}
@@ -1831,17 +1832,17 @@ static int cs_midi_open(struct inode *inode, struct file *file)
file->private_data = card;
/* wait for device to become free */
- down(&card->midi.open_sem);
+ mutex_lock(&card->midi.open_mutex);
while (card->midi.open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&card->midi.open_sem);
+ mutex_unlock(&card->midi.open_mutex);
return -EBUSY;
}
- up(&card->midi.open_sem);
+ mutex_unlock(&card->midi.open_mutex);
interruptible_sleep_on(&card->midi.open_wait);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&card->midi.open_sem);
+ mutex_lock(&card->midi.open_mutex);
}
spin_lock_irqsave(&card->midi.lock, flags);
if (!(card->midi.open_mode & (FMODE_READ | FMODE_WRITE))) {
@@ -1859,7 +1860,7 @@ static int cs_midi_open(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&card->midi.lock, flags);
card->midi.open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
- up(&card->midi.open_sem);
+ mutex_unlock(&card->midi.open_mutex);
return 0;
}
@@ -1891,9 +1892,9 @@ static int cs_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&card->midi.owait, &wait);
current->state = TASK_RUNNING;
}
- down(&card->midi.open_sem);
+ mutex_lock(&card->midi.open_mutex);
card->midi.open_mode &= (~(file->f_mode & (FMODE_READ | FMODE_WRITE)));
- up(&card->midi.open_sem);
+ mutex_unlock(&card->midi.open_mutex);
wake_up(&card->midi.open_wait);
return 0;
}
@@ -2081,7 +2082,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
- down(&state->sem);
+ mutex_lock(&state->sem);
if (!dmabuf->ready && (ret = __prog_dmabuf(state)))
goto out2;
@@ -2114,13 +2115,13 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
if (!ret) ret = -EAGAIN;
goto out;
}
- up(&state->sem);
+ mutex_unlock(&state->sem);
schedule();
if (signal_pending(current)) {
if(!ret) ret = -ERESTARTSYS;
goto out;
}
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped)
{
if(!ret)
@@ -2155,7 +2156,7 @@ static ssize_t cs_read(struct file *file, char __user *buffer, size_t count, lof
out:
remove_wait_queue(&state->dmabuf.wait, &wait);
out2:
- up(&state->sem);
+ mutex_unlock(&state->sem);
set_current_state(TASK_RUNNING);
CS_DBGOUT(CS_WAVE_READ | CS_FUNCTION, 4,
printk("cs46xx: cs_read()- %zd\n",ret) );
@@ -2184,7 +2185,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
return -EFAULT;
dmabuf = &state->dmabuf;
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped)
{
ret = -ENXIO;
@@ -2240,13 +2241,13 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
if (!ret) ret = -EAGAIN;
goto out;
}
- up(&state->sem);
+ mutex_unlock(&state->sem);
schedule();
if (signal_pending(current)) {
if(!ret) ret = -ERESTARTSYS;
goto out;
}
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped)
{
if(!ret)
@@ -2278,7 +2279,7 @@ static ssize_t cs_write(struct file *file, const char __user *buffer, size_t cou
start_dac(state);
}
out:
- up(&state->sem);
+ mutex_unlock(&state->sem);
remove_wait_queue(&state->dmabuf.wait, &wait);
set_current_state(TASK_RUNNING);
@@ -2411,7 +2412,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
goto out;
}
- down(&state->sem);
+ mutex_lock(&state->sem);
dmabuf = &state->dmabuf;
if (cs4x_pgoff(vma) != 0)
{
@@ -2438,7 +2439,7 @@ static int cs_mmap(struct file *file, struct vm_area_struct *vma)
CS_DBGOUT(CS_FUNCTION, 2, printk("cs46xx: cs_mmap()-\n") );
out:
- up(&state->sem);
+ mutex_unlock(&state->sem);
return ret;
}
@@ -3200,7 +3201,7 @@ static int cs_open(struct inode *inode, struct file *file)
if (state == NULL)
return -ENOMEM;
memset(state, 0, sizeof(struct cs_state));
- init_MUTEX(&state->sem);
+ mutex_init(&state->sem);
dmabuf = &state->dmabuf;
dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
if(dmabuf->pbuf==NULL)
@@ -3241,10 +3242,10 @@ static int cs_open(struct inode *inode, struct file *file)
state->virt = 0;
state->magic = CS_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
file->private_data = card;
- down(&state->open_sem);
+ mutex_lock(&state->open_mutex);
/* set default sample format. According to OSS Programmer's Guide /dev/dsp
should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3260,7 +3261,7 @@ static int cs_open(struct inode *inode, struct file *file)
cs_set_divisor(dmabuf);
state->open_mode |= FMODE_READ;
- up(&state->open_sem);
+ mutex_unlock(&state->open_mutex);
}
if(file->f_mode & FMODE_WRITE)
{
@@ -3271,7 +3272,7 @@ static int cs_open(struct inode *inode, struct file *file)
if (state == NULL)
return -ENOMEM;
memset(state, 0, sizeof(struct cs_state));
- init_MUTEX(&state->sem);
+ mutex_init(&state->sem);
dmabuf = &state->dmabuf;
dmabuf->pbuf = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
if(dmabuf->pbuf==NULL)
@@ -3312,10 +3313,10 @@ static int cs_open(struct inode *inode, struct file *file)
state->virt = 1;
state->magic = CS_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
file->private_data = card;
- down(&state->open_sem);
+ mutex_lock(&state->open_mutex);
/* set default sample format. According to OSS Programmer's Guide /dev/dsp
should be default to unsigned 8-bits, mono, with sample rate 8kHz and
@@ -3331,7 +3332,7 @@ static int cs_open(struct inode *inode, struct file *file)
cs_set_divisor(dmabuf);
state->open_mode |= FMODE_WRITE;
- up(&state->open_sem);
+ mutex_unlock(&state->open_mutex);
if((ret = prog_dmabuf(state)))
return ret;
}
@@ -3363,14 +3364,14 @@ static int cs_release(struct inode *inode, struct file *file)
cs_clear_tail(state);
drain_dac(state, file->f_flags & O_NONBLOCK);
/* stop DMA state machine and free DMA buffers/channels */
- down(&state->open_sem);
+ mutex_lock(&state->open_mutex);
stop_dac(state);
dealloc_dmabuf(state);
state->card->free_pcm_channel(state->card, dmabuf->channel->num);
free_page((unsigned long)state->dmabuf.pbuf);
- /* we're covered by the open_sem */
- up(&state->open_sem);
+ /* we're covered by the open_mutex */
+ mutex_unlock(&state->open_mutex);
state->card->states[state->virt] = NULL;
state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
@@ -3395,14 +3396,14 @@ static int cs_release(struct inode *inode, struct file *file)
{
CS_DBGOUT(CS_RELEASE, 2, printk("cs46xx: cs_release() FMODE_READ\n") );
dmabuf = &state->dmabuf;
- down(&state->open_sem);
+ mutex_lock(&state->open_mutex);
stop_adc(state);
dealloc_dmabuf(state);
state->card->free_pcm_channel(state->card, dmabuf->channel->num);
free_page((unsigned long)state->dmabuf.pbuf);
- /* we're covered by the open_sem */
- up(&state->open_sem);
+ /* we're covered by the open_mutex */
+ mutex_unlock(&state->open_mutex);
state->card->states[state->virt] = NULL;
state->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
@@ -5507,7 +5508,7 @@ static int __devinit cs46xx_probe(struct pci_dev *pci_dev,
}
init_waitqueue_head(&card->midi.open_wait);
- init_MUTEX(&card->midi.open_sem);
+ mutex_init(&card->midi.open_mutex);
init_waitqueue_head(&card->midi.iwait);
init_waitqueue_head(&card->midi.owait);
cs461x_pokeBA0(card, BA0_MIDCR, MIDCR_MRST);
diff --git a/sound/oss/dmasound/dmasound_awacs.c b/sound/oss/dmasound/dmasound_awacs.c
index 74f975676cc..6ba8d6f45fe 100644
--- a/sound/oss/dmasound/dmasound_awacs.c
+++ b/sound/oss/dmasound/dmasound_awacs.c
@@ -80,7 +80,7 @@
#include <linux/kmod.h>
#include <linux/interrupt.h>
#include <linux/input.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
#ifdef CONFIG_ADB_CUDA
#include <linux/cuda.h>
#endif
@@ -88,8 +88,6 @@
#include <linux/pmu.h>
#endif
-#include <linux/i2c-dev.h>
-
#include <asm/uaccess.h>
#include <asm/prom.h>
#include <asm/machdep.h>
@@ -130,7 +128,7 @@ static struct resource awacs_rsrc[3];
static char awacs_name[64];
static int awacs_revision;
static int awacs_sleeping;
-static DECLARE_MUTEX(dmasound_sem);
+static DEFINE_MUTEX(dmasound_mutex);
static int sound_device_id; /* exists after iMac revA */
static int hw_can_byteswap = 1 ; /* most pmac sound h/w can */
@@ -312,11 +310,11 @@ extern int daca_enter_sleep(void);
extern int daca_leave_sleep(void);
#define TRY_LOCK() \
- if ((rc = down_interruptible(&dmasound_sem)) != 0) \
+ if ((rc = mutex_lock_interruptible(&dmasound_mutex)) != 0) \
return rc;
-#define LOCK() down(&dmasound_sem);
+#define LOCK() mutex_lock(&dmasound_mutex);
-#define UNLOCK() up(&dmasound_sem);
+#define UNLOCK() mutex_unlock(&dmasound_mutex);
/* We use different versions that the ones provided in dmasound.h
*
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c
index c9302a1e515..87bd3100aef 100644
--- a/sound/oss/dmasound/dmasound_core.c
+++ b/sound/oss/dmasound/dmasound_core.c
@@ -195,18 +195,18 @@
*/
int dmasound_catchRadius = 0;
-MODULE_PARM(dmasound_catchRadius, "i");
+module_param(dmasound_catchRadius, int, 0);
static unsigned int numWriteBufs = DEFAULT_N_BUFFERS;
-MODULE_PARM(numWriteBufs, "i");
+module_param(numWriteBufs, int, 0);
static unsigned int writeBufSize = DEFAULT_BUFF_SIZE ; /* in bytes */
-MODULE_PARM(writeBufSize, "i");
+module_param(writeBufSize, int, 0);
#ifdef HAS_RECORD
static unsigned int numReadBufs = DEFAULT_N_BUFFERS;
-MODULE_PARM(numReadBufs, "i");
+module_param(numReadBufs, int, 0);
static unsigned int readBufSize = DEFAULT_BUFF_SIZE; /* in bytes */
-MODULE_PARM(readBufSize, "i");
+module_param(readBufSize, int, 0);
#endif
MODULE_LICENSE("GPL");
diff --git a/sound/oss/emu10k1/hwaccess.h b/sound/oss/emu10k1/hwaccess.h
index 104223a192a..85e27bda694 100644
--- a/sound/oss/emu10k1/hwaccess.h
+++ b/sound/oss/emu10k1/hwaccess.h
@@ -181,7 +181,7 @@ struct emu10k1_card
struct emu10k1_mpuout *mpuout;
struct emu10k1_mpuin *mpuin;
- struct semaphore open_sem;
+ struct mutex open_sem;
mode_t open_mode;
wait_queue_head_t open_wait;
diff --git a/sound/oss/emu10k1/main.c b/sound/oss/emu10k1/main.c
index 23241cbdd90..0cd44a6f7ac 100644
--- a/sound/oss/emu10k1/main.c
+++ b/sound/oss/emu10k1/main.c
@@ -1320,7 +1320,7 @@ static int __devinit emu10k1_probe(struct pci_dev *pci_dev, const struct pci_dev
card->is_aps = (subsysvid == EMU_APS_SUBID);
spin_lock_init(&card->lock);
- init_MUTEX(&card->open_sem);
+ mutex_init(&card->open_sem);
card->open_mode = 0;
init_waitqueue_head(&card->open_wait);
diff --git a/sound/oss/emu10k1/midi.c b/sound/oss/emu10k1/midi.c
index b40b5f97aac..959a96794db 100644
--- a/sound/oss/emu10k1/midi.c
+++ b/sound/oss/emu10k1/midi.c
@@ -110,21 +110,21 @@ match:
#endif
/* Wait for device to become free */
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
while (card->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
return -EBUSY;
}
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
interruptible_sleep_on(&card->open_wait);
if (signal_pending(current)) {
return -ERESTARTSYS;
}
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
}
if ((midi_dev = (struct emu10k1_mididevice *) kmalloc(sizeof(*midi_dev), GFP_KERNEL)) == NULL)
@@ -183,7 +183,7 @@ match:
card->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
return nonseekable_open(inode, file);
}
@@ -234,9 +234,9 @@ static int emu10k1_midi_release(struct inode *inode, struct file *file)
kfree(midi_dev);
- down(&card->open_sem);
+ mutex_lock(&card->open_sem);
card->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE));
- up(&card->open_sem);
+ mutex_unlock(&card->open_sem);
wake_up_interruptible(&card->open_wait);
unlock_kernel();
diff --git a/sound/oss/es1370.c b/sound/oss/es1370.c
index ae55c536613..094f569cc6e 100644
--- a/sound/oss/es1370.c
+++ b/sound/oss/es1370.c
@@ -157,6 +157,7 @@
#include <linux/gameport.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/page.h>
@@ -346,7 +347,7 @@ struct es1370_state {
unsigned sctrl;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -393,7 +394,7 @@ struct es1370_state {
struct gameport *gameport;
#endif
- struct semaphore sem;
+ struct mutex mutex;
};
/* --------------------------------------------------------------------- */
@@ -1159,7 +1160,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
return -ENXIO;
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
- down(&s->sem);
+ mutex_lock(&s->mutex);
if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
goto out;
@@ -1183,14 +1184,14 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->mutex);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out;
}
- down(&s->sem);
+ mutex_lock(&s->mutex);
if (s->dma_adc.mapped)
{
ret = -ENXIO;
@@ -1215,7 +1216,7 @@ static ssize_t es1370_read(struct file *file, char __user *buffer, size_t count,
start_adc(s);
}
out:
- up(&s->sem);
+ mutex_unlock(&s->mutex);
remove_wait_queue(&s->dma_adc.wait, &wait);
set_current_state(TASK_RUNNING);
return ret;
@@ -1235,7 +1236,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
return -ENXIO;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
- down(&s->sem);
+ mutex_lock(&s->mutex);
if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
goto out;
ret = 0;
@@ -1263,14 +1264,14 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->mutex);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out;
}
- down(&s->sem);
+ mutex_lock(&s->mutex);
if (s->dma_dac2.mapped)
{
ret = -ENXIO;
@@ -1296,7 +1297,7 @@ static ssize_t es1370_write(struct file *file, const char __user *buffer, size_t
start_dac2(s);
}
out:
- up(&s->sem);
+ mutex_unlock(&s->mutex);
remove_wait_queue(&s->dma_dac2.wait, &wait);
set_current_state(TASK_RUNNING);
return ret;
@@ -1348,7 +1349,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
VALIDATE_STATE(s);
lock_kernel();
- down(&s->sem);
+ mutex_lock(&s->mutex);
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf_dac2(s)) != 0) {
goto out;
@@ -1380,7 +1381,7 @@ static int es1370_mmap(struct file *file, struct vm_area_struct *vma)
}
db->mapped = 1;
out:
- up(&s->sem);
+ mutex_unlock(&s->mutex);
unlock_kernel();
return ret;
}
@@ -1752,21 +1753,21 @@ static int es1370_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_READ|FMODE_WRITE)))
@@ -1793,8 +1794,8 @@ static int es1370_open(struct inode *inode, struct file *file)
outl(s->ctrl, s->io+ES1370_REG_CONTROL);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
- init_MUTEX(&s->sem);
+ mutex_unlock(&s->open_mutex);
+ mutex_init(&s->mutex);
return nonseekable_open(inode, file);
}
@@ -1806,7 +1807,7 @@ static int es1370_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac2(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac2(s);
synchronize_irq(s->irq);
@@ -1818,7 +1819,7 @@ static int es1370_release(struct inode *inode, struct file *file)
}
s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2198,21 +2199,21 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
return -EINVAL;
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & FMODE_DAC) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
s->dma_dac1.enabled = 1;
@@ -2227,7 +2228,7 @@ static int es1370_open_dac(struct inode *inode, struct file *file)
outl(s->ctrl, s->io+ES1370_REG_CONTROL);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= FMODE_DAC;
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2238,12 +2239,12 @@ static int es1370_release_dac(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
lock_kernel();
drain_dac1(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
stop_dac1(s);
dealloc_dmabuf(s, &s->dma_dac1);
s->open_mode &= ~FMODE_DAC;
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2430,21 +2431,21 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2465,7 +2466,7 @@ static int es1370_midi_open(struct inode *inode, struct file *file)
es1370_handle_midi(s);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2499,7 +2500,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait);
set_current_state(TASK_RUNNING);
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2508,7 +2509,7 @@ static int es1370_midi_release(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2638,7 +2639,7 @@ static int __devinit es1370_probe(struct pci_dev *pcidev, const struct pci_devic
init_waitqueue_head(&s->open_wait);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->magic = ES1370_MAGIC;
s->dev = pcidev;
diff --git a/sound/oss/es1371.c b/sound/oss/es1371.c
index 5c697f16257..4400c853868 100644
--- a/sound/oss/es1371.c
+++ b/sound/oss/es1371.c
@@ -129,6 +129,7 @@
#include <linux/gameport.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
+#include <linux/mutex.h>
#include <asm/io.h>
#include <asm/page.h>
@@ -419,7 +420,7 @@ struct es1371_state {
unsigned dac1rate, dac2rate, adcrate;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -462,7 +463,7 @@ struct es1371_state {
struct gameport *gameport;
#endif
- struct semaphore sem;
+ struct mutex sem;
};
/* --------------------------------------------------------------------- */
@@ -1346,7 +1347,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
return -ENXIO;
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
- down(&s->sem);
+ mutex_lock(&s->sem);
if (!s->dma_adc.ready && (ret = prog_dmabuf_adc(s)))
goto out2;
@@ -1370,14 +1371,14 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
if (s->dma_adc.mapped)
{
ret = -ENXIO;
@@ -1402,7 +1403,7 @@ static ssize_t es1371_read(struct file *file, char __user *buffer, size_t count,
start_adc(s);
}
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&s->dma_adc.wait, &wait);
set_current_state(TASK_RUNNING);
@@ -1423,7 +1424,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
return -ENXIO;
if (!access_ok(VERIFY_READ, buffer, count))
return -EFAULT;
- down(&s->sem);
+ mutex_lock(&s->sem);
if (!s->dma_dac2.ready && (ret = prog_dmabuf_dac2(s)))
goto out3;
ret = 0;
@@ -1451,14 +1452,14 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
ret = -EAGAIN;
goto out;
}
- up(&s->sem);
+ mutex_unlock(&s->sem);
schedule();
if (signal_pending(current)) {
if (!ret)
ret = -ERESTARTSYS;
goto out2;
}
- down(&s->sem);
+ mutex_lock(&s->sem);
if (s->dma_dac2.mapped)
{
ret = -ENXIO;
@@ -1484,7 +1485,7 @@ static ssize_t es1371_write(struct file *file, const char __user *buffer, size_t
start_dac2(s);
}
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
out2:
remove_wait_queue(&s->dma_dac2.wait, &wait);
out3:
@@ -1538,7 +1539,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
VALIDATE_STATE(s);
lock_kernel();
- down(&s->sem);
+ mutex_lock(&s->sem);
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf_dac2(s)) != 0) {
@@ -1571,7 +1572,7 @@ static int es1371_mmap(struct file *file, struct vm_area_struct *vma)
}
db->mapped = 1;
out:
- up(&s->sem);
+ mutex_unlock(&s->sem);
unlock_kernel();
return ret;
}
@@ -1938,21 +1939,21 @@ static int es1371_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
if (file->f_mode & FMODE_READ) {
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags = s->dma_adc.subdivision = 0;
@@ -1982,8 +1983,8 @@ static int es1371_open(struct inode *inode, struct file *file)
outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
- init_MUTEX(&s->sem);
+ mutex_unlock(&s->open_mutex);
+ mutex_init(&s->sem);
return nonseekable_open(inode, file);
}
@@ -1995,7 +1996,7 @@ static int es1371_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac2(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac2(s);
dealloc_dmabuf(s, &s->dma_dac2);
@@ -2005,7 +2006,7 @@ static int es1371_release(struct inode *inode, struct file *file)
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -2377,21 +2378,21 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
return -EINVAL;
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & FMODE_DAC) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
s->dma_dac1.ossfragshift = s->dma_dac1.ossmaxfrags = s->dma_dac1.subdivision = 0;
s->dma_dac1.enabled = 1;
@@ -2405,7 +2406,7 @@ static int es1371_open_dac(struct inode *inode, struct file *file)
outl(s->sctrl, s->io+ES1371_REG_SERIAL_CONTROL);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= FMODE_DAC;
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2416,11 +2417,11 @@ static int es1371_release_dac(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
lock_kernel();
drain_dac1(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
stop_dac1(s);
dealloc_dmabuf(s, &s->dma_dac1);
s->open_mode &= ~FMODE_DAC;
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -2608,21 +2609,21 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2643,7 +2644,7 @@ static int es1371_midi_open(struct inode *inode, struct file *file)
es1371_handle_midi(s);
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2676,7 +2677,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait);
set_current_state(TASK_RUNNING);
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2684,7 +2685,7 @@ static int es1371_midi_release(struct inode *inode, struct file *file)
outl(s->ctrl, s->io+ES1371_REG_CONTROL);
}
spin_unlock_irqrestore(&s->lock, flags);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -2884,7 +2885,7 @@ static int __devinit es1371_probe(struct pci_dev *pcidev, const struct pci_devic
init_waitqueue_head(&s->open_wait);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->magic = ES1371_MAGIC;
s->dev = pcidev;
diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c
index 849b59f67ef..78d3e29ce96 100644
--- a/sound/oss/esssolo1.c
+++ b/sound/oss/esssolo1.c
@@ -105,6 +105,8 @@
#include <linux/gameport.h>
#include <linux/wait.h>
#include <linux/dma-mapping.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/page.h>
@@ -191,7 +193,7 @@ struct solo1_state {
unsigned ena;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1581,7 +1583,7 @@ static int solo1_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
outb(0, s->iobase+6); /* disable DMA */
@@ -1595,7 +1597,7 @@ static int solo1_release(struct inode *inode, struct file *file)
}
s->open_mode &= ~(FMODE_READ | FMODE_WRITE);
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -1624,21 +1626,21 @@ static int solo1_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & (FMODE_READ | FMODE_WRITE)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
s->fmt = AFMT_U8;
s->channels = 1;
@@ -1650,7 +1652,7 @@ static int solo1_open(struct inode *inode, struct file *file)
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags = s->dma_dac.subdivision = 0;
s->dma_dac.enabled = 1;
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
prog_codec(s);
return nonseekable_open(inode, file);
}
@@ -1911,21 +1913,21 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1951,7 +1953,7 @@ static int solo1_midi_open(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -1985,7 +1987,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait);
set_current_state(TASK_RUNNING);
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -1994,7 +1996,7 @@ static int solo1_midi_release(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2132,24 +2134,24 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & FMODE_DMFM) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
if (!request_region(s->sbbase, FMSYNTH_EXTENT, "ESS Solo1")) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
printk(KERN_ERR "solo1: FM synth io ports in use, opl3 loaded?\n");
return -EBUSY;
}
@@ -2161,7 +2163,7 @@ static int solo1_dmfm_open(struct inode *inode, struct file *file)
outb(5, s->sbbase+2);
outb(1, s->sbbase+3); /* enable OPL3 */
s->open_mode |= FMODE_DMFM;
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2172,7 +2174,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
lock_kernel();
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~FMODE_DMFM;
for (regb = 0xb0; regb < 0xb9; regb++) {
outb(regb, s->sbbase);
@@ -2182,7 +2184,7 @@ static int solo1_dmfm_release(struct inode *inode, struct file *file)
}
release_region(s->sbbase, FMSYNTH_EXTENT);
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2362,7 +2364,7 @@ static int __devinit solo1_probe(struct pci_dev *pcidev, const struct pci_device
init_waitqueue_head(&s->open_wait);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->magic = SOLO1_MAGIC;
s->dev = pcidev;
diff --git a/sound/oss/forte.c b/sound/oss/forte.c
index 8406bc90c4f..0294eec8ad9 100644
--- a/sound/oss/forte.c
+++ b/sound/oss/forte.c
@@ -43,6 +43,7 @@
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -185,7 +186,7 @@ struct forte_chip {
unsigned long iobase;
int irq;
- struct semaphore open_sem; /* Device access */
+ struct mutex open_mutex; /* Device access */
spinlock_t lock; /* State */
spinlock_t ac97_lock;
@@ -1242,13 +1243,13 @@ forte_dsp_open (struct inode *inode, struct file *file)
struct forte_chip *chip = forte; /* FIXME: HACK FROM HELL! */
if (file->f_flags & O_NONBLOCK) {
- if (down_trylock (&chip->open_sem)) {
+ if (!mutex_trylock(&chip->open_mutex)) {
DPRINTK ("%s: returning -EAGAIN\n", __FUNCTION__);
return -EAGAIN;
}
}
else {
- if (down_interruptible (&chip->open_sem)) {
+ if (mutex_lock_interruptible(&chip->open_mutex)) {
DPRINTK ("%s: returning -ERESTARTSYS\n", __FUNCTION__);
return -ERESTARTSYS;
}
@@ -1302,7 +1303,7 @@ forte_dsp_release (struct inode *inode, struct file *file)
spin_unlock_irq (&chip->lock);
}
- up (&chip->open_sem);
+ mutex_unlock(&chip->open_mutex);
return ret;
}
@@ -2011,7 +2012,7 @@ forte_probe (struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
memset (chip, 0, sizeof (struct forte_chip));
chip->pci_dev = pci_dev;
- init_MUTEX(&chip->open_sem);
+ mutex_init(&chip->open_mutex);
spin_lock_init (&chip->lock);
spin_lock_init (&chip->ac97_lock);
diff --git a/sound/oss/hal2.c b/sound/oss/hal2.c
index afe97c4ce06..dd4f59d30a3 100644
--- a/sound/oss/hal2.c
+++ b/sound/oss/hal2.c
@@ -32,6 +32,8 @@
#include <linux/dma-mapping.h>
#include <linux/sound.h>
#include <linux/soundcard.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/sgi/hpc3.h>
@@ -92,7 +94,7 @@ struct hal2_codec {
wait_queue_head_t dma_wait;
spinlock_t lock;
- struct semaphore sem;
+ struct mutex sem;
int usecount; /* recording and playback are
* independent */
@@ -1178,7 +1180,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
if (!count)
return 0;
- if (down_interruptible(&adc->sem))
+ if (mutex_lock_interruptible(&adc->sem))
return -EINTR;
if (file->f_flags & O_NONBLOCK) {
err = hal2_get_buffer(hal2, buffer, count);
@@ -1217,7 +1219,7 @@ static ssize_t hal2_read(struct file *file, char *buffer,
}
} while (count > 0 && err >= 0);
}
- up(&adc->sem);
+ mutex_unlock(&adc->sem);
return err;
}
@@ -1232,7 +1234,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
if (!count)
return 0;
- if (down_interruptible(&dac->sem))
+ if (mutex_lock_interruptible(&dac->sem))
return -EINTR;
if (file->f_flags & O_NONBLOCK) {
err = hal2_add_buffer(hal2, buf, count);
@@ -1271,7 +1273,7 @@ static ssize_t hal2_write(struct file *file, const char *buffer,
}
} while (count > 0 && err >= 0);
}
- up(&dac->sem);
+ mutex_unlock(&dac->sem);
return err;
}
@@ -1356,20 +1358,20 @@ static int hal2_release(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_READ) {
struct hal2_codec *adc = &hal2->adc;
- down(&adc->sem);
+ mutex_lock(&adc->sem);
hal2_stop_adc(hal2);
hal2_free_adc_dmabuf(adc);
adc->usecount--;
- up(&adc->sem);
+ mutex_unlock(&adc->sem);
}
if (file->f_mode & FMODE_WRITE) {
struct hal2_codec *dac = &hal2->dac;
- down(&dac->sem);
+ mutex_lock(&dac->sem);
hal2_sync_dac(hal2);
hal2_free_dac_dmabuf(dac);
dac->usecount--;
- up(&dac->sem);
+ mutex_unlock(&dac->sem);
}
return 0;
@@ -1400,7 +1402,7 @@ static void hal2_init_codec(struct hal2_codec *codec, struct hpc3_regs *hpc3,
codec->pbus.pbusnr = index;
codec->pbus.pbus = &hpc3->pbdma[index];
init_waitqueue_head(&codec->dma_wait);
- init_MUTEX(&codec->sem);
+ mutex_init(&codec->sem);
spin_lock_init(&codec->lock);
}
diff --git a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
index abc242abd5b..dd2b871cdac 100644
--- a/sound/oss/i810_audio.c
+++ b/sound/oss/i810_audio.c
@@ -100,6 +100,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/bitops.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
#define DRIVER_VERSION "1.01"
@@ -331,7 +333,7 @@ struct i810_state {
struct i810_card *card; /* Card info */
/* single open lock mechanism, only used for recording */
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
/* file mode */
@@ -2597,7 +2599,7 @@ found_virt:
state->card = card;
state->magic = I810_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
file->private_data = state;
dmabuf->trigger = 0;
@@ -3213,7 +3215,7 @@ static void __devinit i810_configure_clocking (void)
state->card = card;
state->magic = I810_STATE_MAGIC;
init_waitqueue_head(&dmabuf->wait);
- init_MUTEX(&state->open_sem);
+ mutex_init(&state->open_mutex);
dmabuf->fmt = I810_FMT_STEREO | I810_FMT_16BIT;
dmabuf->trigger = PCM_ENABLE_OUTPUT;
i810_set_spdif_output(state, -1, 0);
diff --git a/sound/oss/ite8172.c b/sound/oss/ite8172.c
index 8fd2f9a9e66..00ac1c95a42 100644
--- a/sound/oss/ite8172.c
+++ b/sound/oss/ite8172.c
@@ -71,6 +71,8 @@
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
#include <linux/interrupt.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/uaccess.h>
@@ -304,7 +306,7 @@ struct it8172_state {
unsigned dacrate, adcrate;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1801,21 +1803,21 @@ static int it8172_open(struct inode *inode, struct file *file)
}
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
@@ -1850,7 +1852,7 @@ static int it8172_open(struct inode *inode, struct file *file)
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= (file->f_mode & (FMODE_READ | FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -1864,7 +1866,7 @@ static int it8172_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
@@ -1874,7 +1876,7 @@ static int it8172_release(struct inode *inode, struct file *file)
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= ((~file->f_mode) & (FMODE_READ|FMODE_WRITE));
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -1966,9 +1968,9 @@ static int i2s_fmt[NR_DEVICE];
static unsigned int devindex;
-MODULE_PARM(spdif, "1-" __MODULE_STRING(NR_DEVICE) "i");
+module_param_array(spdif, int, NULL, 0);
MODULE_PARM_DESC(spdif, "if 1 the S/PDIF digital output is enabled");
-MODULE_PARM(i2s_fmt, "1-" __MODULE_STRING(NR_DEVICE) "i");
+module_param_array(i2s_fmt, int, NULL, 0);
MODULE_PARM_DESC(i2s_fmt, "the format of I2S");
MODULE_AUTHOR("Monta Vista Software, stevel@mvista.com");
@@ -1997,7 +1999,7 @@ static int __devinit it8172_probe(struct pci_dev *pcidev,
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->dev = pcidev;
s->io = pci_resource_start(pcidev, 0);
diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c
index d4b569acf76..e647f2f8627 100644
--- a/sound/oss/maestro.c
+++ b/sound/oss/maestro.c
@@ -223,6 +223,8 @@
#include <linux/reboot.h>
#include <linux/bitops.h>
#include <linux/wait.h>
+#include <linux/mutex.h>
+
#include <asm/current.h>
#include <asm/dma.h>
@@ -397,7 +399,7 @@ struct ess_state {
/* this locks around the oss state in the driver */
spinlock_t lock;
/* only let 1 be opening at a time */
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
mode_t open_mode;
@@ -3020,26 +3022,26 @@ ess_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EWOULDBLOCK;
}
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
interruptible_sleep_on(&s->open_wait);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
/* under semaphore.. */
if ((s->card->dmapages==NULL) && allocate_buffers(s)) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -ENOMEM;
}
- /* we're covered by the open_sem */
+ /* we're covered by the open_mutex */
if( ! s->card->dsps_open ) {
maestro_power(s->card,ACPI_D0);
start_bob(s);
@@ -3076,7 +3078,7 @@ ess_open(struct inode *inode, struct file *file)
set_fmt(s, fmtm, fmts);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -3089,7 +3091,7 @@ ess_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
}
@@ -3098,7 +3100,7 @@ ess_release(struct inode *inode, struct file *file)
}
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
- /* we're covered by the open_sem */
+ /* we're covered by the open_mutex */
M_printk("maestro: %d dsps now alive\n",s->card->dsps_open-1);
if( --s->card->dsps_open <= 0) {
s->card->dsps_open = 0;
@@ -3106,7 +3108,7 @@ ess_release(struct inode *inode, struct file *file)
free_buffers(s);
maestro_power(s->card,ACPI_D2);
}
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -3466,7 +3468,7 @@ maestro_probe(struct pci_dev *pcidev,const struct pci_device_id *pdid)
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
spin_lock_init(&s->lock);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
s->magic = ESS_STATE_MAGIC;
s->apu[0] = 6*i;
diff --git a/sound/oss/maestro3.c b/sound/oss/maestro3.c
index f3dec70fcb9..66044aff258 100644
--- a/sound/oss/maestro3.c
+++ b/sound/oss/maestro3.c
@@ -144,6 +144,8 @@
#include <linux/spinlock.h>
#include <linux/ac97_codec.h>
#include <linux/wait.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/dma.h>
@@ -205,7 +207,7 @@ struct m3_state {
when irqhandler uses s->lock
and m3_assp_read uses card->lock ?
*/
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
mode_t open_mode;
@@ -2013,17 +2015,17 @@ static int m3_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EWOULDBLOCK;
}
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
interruptible_sleep_on(&s->open_wait);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&c->lock, flags);
@@ -2047,7 +2049,7 @@ static int m3_open(struct inode *inode, struct file *file)
set_fmt(s, fmtm, fmts);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
spin_unlock_irqrestore(&c->lock, flags);
return nonseekable_open(inode, file);
}
@@ -2062,7 +2064,7 @@ static int m3_release(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
spin_lock_irqsave(&card->lock, flags);
if (file->f_mode & FMODE_WRITE) {
@@ -2083,7 +2085,7 @@ static int m3_release(struct inode *inode, struct file *file)
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
spin_unlock_irqrestore(&card->lock, flags);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
return 0;
@@ -2679,7 +2681,7 @@ static int __devinit m3_probe(struct pci_dev *pci_dev, const struct pci_device_i
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&(s->open_sem));
+ mutex_init(&(s->open_mutex));
s->magic = M3_STATE_MAGIC;
m3_assp_client_init(s);
diff --git a/sound/oss/nec_vrc5477.c b/sound/oss/nec_vrc5477.c
index fbb9170e8e0..21c1954d910 100644
--- a/sound/oss/nec_vrc5477.c
+++ b/sound/oss/nec_vrc5477.c
@@ -78,6 +78,8 @@
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
#include <linux/ac97_codec.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/dma.h>
#include <asm/uaccess.h>
@@ -198,7 +200,7 @@ struct vrc5477_ac97_state {
unsigned short extended_status;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1617,22 +1619,22 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
@@ -1659,7 +1661,7 @@ static int vrc5477_ac97_open(struct inode *inode, struct file *file)
bailout:
spin_unlock_irqrestore(&s->lock, flags);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return ret;
}
@@ -1671,7 +1673,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
@@ -1681,7 +1683,7 @@ static int vrc5477_ac97_release(struct inode *inode, struct file *file)
dealloc_dmabuf(s, &s->dma_adc);
}
s->open_mode &= (~file->f_mode) & (FMODE_READ|FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
wake_up(&s->open_wait);
unlock_kernel();
return 0;
@@ -1867,7 +1869,7 @@ static int __devinit vrc5477_ac97_probe(struct pci_dev *pcidev,
init_waitqueue_head(&s->dma_adc.wait);
init_waitqueue_head(&s->dma_dac.wait);
init_waitqueue_head(&s->open_wait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->dev = pcidev;
diff --git a/sound/oss/rme96xx.c b/sound/oss/rme96xx.c
index faa0b7919b6..a1ec9d131ab 100644
--- a/sound/oss/rme96xx.c
+++ b/sound/oss/rme96xx.c
@@ -58,6 +58,7 @@ TODO:
#include <linux/interrupt.h>
#include <linux/poll.h>
#include <linux/wait.h>
+#include <linux/mutex.h>
#include <asm/dma.h>
#include <asm/page.h>
@@ -326,7 +327,7 @@ typedef struct _rme96xx_info {
/* waiting and locking */
wait_queue_head_t wait;
- struct semaphore open_sem;
+ struct mutex open_mutex;
wait_queue_head_t open_wait;
} dma[RME96xx_MAX_DEVS];
@@ -842,7 +843,7 @@ static void busmaster_free(void* ptr,int size) {
static int rme96xx_dmabuf_init(rme96xx_info * s,struct dmabuf* dma,int ioffset,int ooffset) {
- init_MUTEX(&dma->open_sem);
+ mutex_init(&dma->open_mutex);
init_waitqueue_head(&dma->open_wait);
init_waitqueue_head(&dma->wait);
dma->s = s;
@@ -1469,21 +1470,21 @@ static int rme96xx_open(struct inode *in, struct file *f)
dma = &s->dma[devnum];
f->private_data = dma;
/* wait for device to become free */
- down(&dma->open_sem);
+ mutex_lock(&dma->open_mutex);
while (dma->open_mode & f->f_mode) {
if (f->f_flags & O_NONBLOCK) {
- up(&dma->open_sem);
+ mutex_unlock(&dma->open_mutex);
return -EBUSY;
}
add_wait_queue(&dma->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&dma->open_sem);
+ mutex_unlock(&dma->open_mutex);
schedule();
remove_wait_queue(&dma->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&dma->open_sem);
+ mutex_lock(&dma->open_mutex);
}
COMM ("hardware open")
@@ -1492,7 +1493,7 @@ static int rme96xx_open(struct inode *in, struct file *f)
dma->open_mode |= (f->f_mode & (FMODE_READ | FMODE_WRITE));
dma->opened = 1;
- up(&dma->open_sem);
+ mutex_unlock(&dma->open_mutex);
DBG(printk("device num %d open finished\n",devnum));
return 0;
@@ -1524,7 +1525,7 @@ static int rme96xx_release(struct inode *in, struct file *file)
}
wake_up(&dma->open_wait);
- up(&dma->open_sem);
+ mutex_unlock(&dma->open_mutex);
return 0;
}
diff --git a/sound/oss/sb_mixer.c b/sound/oss/sb_mixer.c
index f56898c3981..ccb21d48d42 100644
--- a/sound/oss/sb_mixer.c
+++ b/sound/oss/sb_mixer.c
@@ -273,14 +273,14 @@ int sb_common_mixer_set(sb_devc * devc, int dev, int left, int right)
int regoffs;
unsigned char val;
+ if ((dev < 0) || (dev >= devc->iomap_sz))
+ return -EINVAL;
+
regoffs = (*devc->iomap)[dev][LEFT_CHN].regno;
if (regoffs == 0)
return -EINVAL;
- if ((dev < 0) || (dev >= devc->iomap_sz))
- return -EINVAL;
-
val = sb_getmixer(devc, regoffs);
change_bits(devc, &val, dev, LEFT_CHN, left);
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 698614226c9..347cd79c250 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -709,11 +709,11 @@ static void seq_local_event(unsigned char *event_rec)
static void seq_sysex_message(unsigned char *event_rec)
{
- int dev = event_rec[1];
+ unsigned int dev = event_rec[1];
int i, l = 0;
unsigned char *buf = &event_rec[2];
- if ((int) dev > max_synthdev)
+ if (dev > max_synthdev)
return;
if (!(synth_open_mask & (1 << dev)))
return;
diff --git a/sound/oss/sonicvibes.c b/sound/oss/sonicvibes.c
index 71b05e2f697..69a4b8778b5 100644
--- a/sound/oss/sonicvibes.c
+++ b/sound/oss/sonicvibes.c
@@ -116,6 +116,8 @@
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
#include <linux/gameport.h>
+#include <linux/mutex.h>
+
#include <asm/io.h>
#include <asm/uaccess.h>
@@ -328,7 +330,7 @@ struct sv_state {
unsigned char fmt, enable;
spinlock_t lock;
- struct semaphore open_sem;
+ struct mutex open_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1922,21 +1924,21 @@ static int sv_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & file->f_mode) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
if (file->f_mode & FMODE_READ) {
fmtm &= ~((SV_CFMT_STEREO | SV_CFMT_16BIT) << SV_CFMT_CSHIFT);
@@ -1956,7 +1958,7 @@ static int sv_open(struct inode *inode, struct file *file)
}
set_fmt(s, fmtm, fmts);
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -1968,7 +1970,7 @@ static int sv_release(struct inode *inode, struct file *file)
lock_kernel();
if (file->f_mode & FMODE_WRITE)
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
@@ -1979,7 +1981,7 @@ static int sv_release(struct inode *inode, struct file *file)
}
s->open_mode &= ~(file->f_mode & (FMODE_READ|FMODE_WRITE));
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2167,21 +2169,21 @@ static int sv_midi_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & (file->f_mode << FMODE_MIDI_SHIFT)) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2210,7 +2212,7 @@ static int sv_midi_open(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&s->lock, flags);
s->open_mode |= (file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ | FMODE_MIDI_WRITE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2248,7 +2250,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
remove_wait_queue(&s->midi.owait, &wait);
set_current_state(TASK_RUNNING);
}
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~((file->f_mode << FMODE_MIDI_SHIFT) & (FMODE_MIDI_READ|FMODE_MIDI_WRITE));
spin_lock_irqsave(&s->lock, flags);
if (!(s->open_mode & (FMODE_MIDI_READ | FMODE_MIDI_WRITE))) {
@@ -2257,7 +2259,7 @@ static int sv_midi_release(struct inode *inode, struct file *file)
}
spin_unlock_irqrestore(&s->lock, flags);
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2388,21 +2390,21 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
file->private_data = s;
/* wait for device to become free */
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
while (s->open_mode & FMODE_DMFM) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return -EBUSY;
}
add_wait_queue(&s->open_wait, &wait);
__set_current_state(TASK_INTERRUPTIBLE);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
schedule();
remove_wait_queue(&s->open_wait, &wait);
set_current_state(TASK_RUNNING);
if (signal_pending(current))
return -ERESTARTSYS;
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
}
/* init the stuff */
outb(1, s->iosynth);
@@ -2412,7 +2414,7 @@ static int sv_dmfm_open(struct inode *inode, struct file *file)
outb(5, s->iosynth+2);
outb(1, s->iosynth+3); /* enable OPL3 */
s->open_mode |= FMODE_DMFM;
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
return nonseekable_open(inode, file);
}
@@ -2423,7 +2425,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
VALIDATE_STATE(s);
lock_kernel();
- down(&s->open_sem);
+ mutex_lock(&s->open_mutex);
s->open_mode &= ~FMODE_DMFM;
for (regb = 0xb0; regb < 0xb9; regb++) {
outb(regb, s->iosynth);
@@ -2432,7 +2434,7 @@ static int sv_dmfm_release(struct inode *inode, struct file *file)
outb(0, s->iosynth+3);
}
wake_up(&s->open_wait);
- up(&s->open_sem);
+ mutex_unlock(&s->open_mutex);
unlock_kernel();
return 0;
}
@@ -2582,7 +2584,7 @@ static int __devinit sv_probe(struct pci_dev *pcidev, const struct pci_device_id
init_waitqueue_head(&s->open_wait);
init_waitqueue_head(&s->midi.iwait);
init_waitqueue_head(&s->midi.owait);
- init_MUTEX(&s->open_sem);
+ mutex_init(&s->open_mutex);
spin_lock_init(&s->lock);
s->magic = SV_MAGIC;
s->dev = pcidev;
diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
index df4d3771fa8..eb5ea32fd1b 100644
--- a/sound/oss/swarm_cs4297a.c
+++ b/sound/oss/swarm_cs4297a.c
@@ -76,6 +76,7 @@
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/smp_lock.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <asm/dma.h>
@@ -153,8 +154,8 @@ static void start_adc(struct cs4297a_state *s);
#if CSDEBUG
static unsigned long cs_debuglevel = 4; // levels range from 1-9
static unsigned long cs_debugmask = CS_INIT /*| CS_IOCTL*/;
-MODULE_PARM(cs_debuglevel, "i");
-MODULE_PARM(cs_debugmask, "i");
+module_param(cs_debuglevel, int, 0);
+module_param(cs_debugmask, int, 0);
#endif
#define CS_TRUE 1
#define CS_FALSE 0
@@ -291,9 +292,9 @@ struct cs4297a_state {
unsigned conversion:1; // conversion from 16 to 8 bit in progress
unsigned ena;
spinlock_t lock;
- struct semaphore open_sem;
- struct semaphore open_sem_adc;
- struct semaphore open_sem_dac;
+ struct mutex open_mutex;
+ struct mutex open_sem_adc;
+ struct mutex open_sem_dac;
mode_t open_mode;
wait_queue_head_t open_wait;
wait_queue_head_t open_wait_adc;
@@ -2352,20 +2353,20 @@ static int cs4297a_release(struct inode *inode, struct file *file)
if (file->f_mode & FMODE_WRITE) {
drain_dac(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
stop_dac(s);
dealloc_dmabuf(s, &s->dma_dac);
s->open_mode &= ~FMODE_WRITE;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
wake_up(&s->open_wait_dac);
}
if (file->f_mode & FMODE_READ) {
drain_adc(s, file->f_flags & O_NONBLOCK);
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
stop_adc(s);
dealloc_dmabuf(s, &s->dma_adc);
s->open_mode &= ~FMODE_READ;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
wake_up(&s->open_wait_adc);
}
return 0;
@@ -2413,37 +2414,37 @@ static int cs4297a_open(struct inode *inode, struct file *file)
;
}
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
while (s->open_mode & FMODE_WRITE) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
return -EBUSY;
}
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
interruptible_sleep_on(&s->open_wait_dac);
if (signal_pending(current)) {
printk("open - sig pending\n");
return -ERESTARTSYS;
}
- down(&s->open_sem_dac);
+ mutex_lock(&s->open_sem_dac);
}
}
if (file->f_mode & FMODE_READ) {
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
while (s->open_mode & FMODE_READ) {
if (file->f_flags & O_NONBLOCK) {
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
return -EBUSY;
}
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
interruptible_sleep_on(&s->open_wait_adc);
if (signal_pending(current)) {
printk("open - sig pending\n");
return -ERESTARTSYS;
}
- down(&s->open_sem_adc);
+ mutex_lock(&s->open_sem_adc);
}
}
s->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
@@ -2456,7 +2457,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_READ;
s->dma_adc.ossfragshift = s->dma_adc.ossmaxfrags =
s->dma_adc.subdivision = 0;
- up(&s->open_sem_adc);
+ mutex_unlock(&s->open_sem_adc);
if (prog_dmabuf_adc(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2474,7 +2475,7 @@ static int cs4297a_open(struct inode *inode, struct file *file)
s->ena &= ~FMODE_WRITE;
s->dma_dac.ossfragshift = s->dma_dac.ossmaxfrags =
s->dma_dac.subdivision = 0;
- up(&s->open_sem_dac);
+ mutex_unlock(&s->open_sem_dac);
if (prog_dmabuf_dac(s)) {
CS_DBGOUT(CS_OPEN | CS_ERROR, 2, printk(KERN_ERR
@@ -2631,8 +2632,8 @@ static int __init cs4297a_init(void)
init_waitqueue_head(&s->open_wait);
init_waitqueue_head(&s->open_wait_adc);
init_waitqueue_head(&s->open_wait_dac);
- init_MUTEX(&s->open_sem_adc);
- init_MUTEX(&s->open_sem_dac);
+ mutex_init(&s->open_sem_adc);
+ mutex_init(&s->open_sem_dac);
spin_lock_init(&s->lock);
s->irq = K_INT_SER_1;
diff --git a/sound/oss/trident.c b/sound/oss/trident.c
index a21c663e7e1..e61a454a815 100644
--- a/sound/oss/trident.c
+++ b/sound/oss/trident.c
@@ -190,7 +190,7 @@
*
* Lock order (high->low)
* lock - hardware lock
- * open_sem - guard opens
+ * open_mutex - guard opens
* sem - guard dmabuf, write re-entry etc
*/
@@ -216,6 +216,8 @@
#include <linux/pm.h>
#include <linux/gameport.h>
#include <linux/kernel.h>
+#include <linux/mutex.h>
+
#include <asm/uaccess.h>
#include <asm/io.h>
#include <asm/dma.h>
@@ -349,7 +351,7 @@ struct trident_state {
unsigned chans_num;
unsigned long fmt_flag;
/* Guard against mmap/write/read races */
- struct semaphore sem;
+ struct mutex sem;
};
@@ -402,7 +404,7 @@ struct trident_card {
struct trident_card *next;
/* single open lock mechanism, only used for recording */
- struct semaphore open_sem;
+ struct mutex open_mutex;
/* The trident has a certain amount of cross channel interaction
so we use a single per card lock */
@@ -1881,7 +1883,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
if (!access_ok(VERIFY_WRITE, buffer, count))
return -EFAULT;
- down(&state->sem);
+ mutex_lock(&state->sem);
if (!dmabuf->ready && (ret = prog_dmabuf_record(state)))
goto out;
@@ -1913,7 +1915,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
goto out;
}
- up(&state->sem);
+ mutex_unlock(&state->sem);
/* No matter how much space left in the buffer, */
/* we have to wait until CSO == ESO/2 or CSO == ESO */
/* when address engine interrupts */
@@ -1940,7 +1942,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
ret = -ERESTARTSYS;
goto out;
}
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped) {
if (!ret)
ret = -ENXIO;
@@ -1968,7 +1970,7 @@ trident_read(struct file *file, char __user *buffer, size_t count, loff_t * ppos
start_adc(state);
}
out:
- up(&state->sem);
+ mutex_unlock(&state->sem);
return ret;
}
@@ -1996,7 +1998,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
* Guard against an mmap or ioctl while writing
*/
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped) {
ret = -ENXIO;
@@ -2045,7 +2047,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
tmo = (dmabuf->dmasize * HZ) / (dmabuf->rate * 2);
tmo >>= sample_shift[dmabuf->fmt];
unlock_set_fmt(state);
- up(&state->sem);
+ mutex_unlock(&state->sem);
/* There are two situations when sleep_on_timeout */
/* returns, one is when the interrupt is serviced */
@@ -2073,7 +2075,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
ret = -ERESTARTSYS;
goto out_nolock;
}
- down(&state->sem);
+ mutex_lock(&state->sem);
if (dmabuf->mapped) {
if (!ret)
ret = -ENXIO;
@@ -2131,7 +2133,7 @@ trident_write(struct file *file, const char __user *buffer, size_t count, loff_t
start_dac(state);
}
out:
- up(&state->sem);
+ mutex_unlock(&state->sem);
out_nolock:
return ret;
}
@@ -2152,24 +2154,24 @@ trident_poll(struct file *file, struct poll_table_struct *wait)
* prog_dmabuf events
*/
- down(&state->sem);
+ mutex_lock(&state->sem);
if (file->f_mode & FMODE_WRITE) {
if (!dmabuf->ready && prog_dmabuf_playback(state)) {
- up(&state->sem);
+ mutex_unlock(&state->sem);
return 0;
}
poll_wait(file, &dmabuf->wait, wait);
}
if (file->f_mode & FMODE_READ) {
if (!dmabuf->ready && prog_dmabuf_record(state)) {
- up(&state->sem);
+ mutex_unlock(&state->sem);
return 0;
}
poll_wait(file, &dmabuf->wait, wait);
}
- up(&state->sem);
+ mutex_unlock(&state->sem);
spin_lock_irqsave(&state->card->lock, flags);
trident_update_ptr(state);
@@ -2207,7 +2209,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
* a read or write against an mmap.
*/
- down(&state->sem);
+ mutex_lock(&state->sem);
if (vma->vm_flags & VM_WRITE) {
if ((ret = prog_dmabuf_playback(state)) != 0)
@@ -2232,7 +2234,7 @@ trident_mmap(struct file *file, struct vm_area_struct *vma)
dmabuf->mapped = 1;
ret = 0;
out:
- up(&state->sem);
+ mutex_unlock(&state->sem);
return ret;
}
@@ -2429,15 +2431,15 @@ trident_ioctl(struct inode *inode, struct file *file,
unlock_set_fmt(state);
break;
}
- down(&state->card->open_sem);
+ mutex_lock(&state->card->open_mutex);
ret = ali_allocate_other_states_resources(state, 6);
if (ret < 0) {
- up(&state->card->open_sem);
+ mutex_unlock(&state->card->open_mutex);
unlock_set_fmt(state);
break;
}
state->card->multi_channel_use_count++;
- up(&state->card->open_sem);
+ mutex_unlock(&state->card->open_mutex);
} else
val = 2; /*yield to 2-channels */
} else
@@ -2727,11 +2729,11 @@ trident_open(struct inode *inode, struct file *file)
/* find an available virtual channel (instance of /dev/dsp) */
while (card != NULL) {
- down(&card->open_sem);
+ mutex_lock(&card->open_mutex);
if (file->f_mode & FMODE_READ) {
/* Skip opens on cards that are in 6 channel mode */
if (card->multi_channel_use_count > 0) {
- up(&card->open_sem);
+ mutex_unlock(&card->open_mutex);
card = card->next;
continue;
}
@@ -2740,16 +2742,16 @@ trident_open(struct inode *inode, struct file *file)
if (card->states[i] == NULL) {
state = card->states[i] = kmalloc(sizeof(*state), GFP_KERNEL);
if (state == NULL) {
- up(&card->open_sem);
+ mutex_unlock(&card->open_mutex);
return -ENOMEM;
}
memset(state, 0, sizeof(*state));
- init_MUTEX(&state->sem);
+ mutex_init(&state->sem);
dmabuf = &state->dmabuf;
goto found_virt;
}
}
- up(&card->open_sem);
+ mutex_unlock(&card->open_mutex);
card = card->next;
}
/* no more virtual channel avaiable */
@@ -2816,7 +2818,7 @@ trident_open(struct inode *inode, struct file *file)
}
state->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&card->open_sem);
+ mutex_unlock(&card->open_mutex);
pr_debug("trident: open virtual channel %d, hard channel %d\n",
state->virt, dmabuf->channel->num);
@@ -2845,7 +2847,7 @@ trident_release(struct inode *inode, struct file *file)
state->virt, dmabuf->channel->num);
/* stop DMA state machine and free DMA buffers/channels */
- down(&card->open_sem);
+ mutex_lock(&card->open_mutex);
if (file->f_mode & FMODE_WRITE) {
stop_dac(state);
@@ -2878,8 +2880,8 @@ trident_release(struct inode *inode, struct file *file)
card->states[state->virt] = NULL;
kfree(state);
- /* we're covered by the open_sem */
- up(&card->open_sem);
+ /* we're covered by the open_mutex */
+ mutex_unlock(&card->open_mutex);
return 0;
}
@@ -4405,7 +4407,7 @@ trident_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id)
card->banks[BANK_B].addresses = &bank_b_addrs;
card->banks[BANK_B].bitmap = 0UL;
- init_MUTEX(&card->open_sem);
+ mutex_init(&card->open_mutex);
spin_lock_init(&card->lock);
init_timer(&card->timer);
diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c
index 83edda93f0b..1a921ee71ab 100644
--- a/sound/oss/via82cxxx_audio.c
+++ b/sound/oss/via82cxxx_audio.c
@@ -38,7 +38,8 @@
#include <linux/dma-mapping.h>
#include <asm/io.h>
#include <asm/uaccess.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
+
#include "sound_config.h"
#include "dev_table.h"
#include "mpu401.h"
@@ -311,8 +312,8 @@ struct via_info {
int mixer_vol; /* 8233/35 volume - not yet implemented */
- struct semaphore syscall_sem;
- struct semaphore open_sem;
+ struct mutex syscall_mutex;
+ struct mutex open_mutex;
/* The 8233/8235 have 4 DX audio channels, two record and
one six channel out. We bind ch_in to DX 1, ch_out to multichannel
@@ -505,10 +506,10 @@ static inline int via_syscall_down (struct via_info *card, int nonblock)
nonblock = 0;
if (nonblock) {
- if (down_trylock (&card->syscall_sem))
+ if (!mutex_trylock(&card->syscall_mutex))
return -EAGAIN;
} else {
- if (down_interruptible (&card->syscall_sem))
+ if (mutex_lock_interruptible(&card->syscall_mutex))
return -ERESTARTSYS;
}
@@ -1609,7 +1610,7 @@ static int via_mixer_ioctl (struct inode *inode, struct file *file, unsigned int
#endif
rc = codec->mixer_ioctl(codec, cmd, arg);
- up (&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
out:
DPRINTK ("EXIT, returning %d\n", rc);
@@ -2228,7 +2229,7 @@ static int via_dsp_mmap(struct file *file, struct vm_area_struct *vma)
if (wr)
card->ch_out.is_mapped = 1;
- up (&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
rc = 0;
out:
@@ -2256,7 +2257,7 @@ handle_one_block:
/* Thomas Sailer:
* But also to ourselves, release semaphore if we do so */
if (need_resched()) {
- up(&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
schedule ();
ret = via_syscall_down (card, nonblock);
if (ret)
@@ -2286,7 +2287,7 @@ handle_one_block:
break;
}
- up(&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
DPRINTK ("Sleeping on block %d\n", n);
schedule();
@@ -2402,7 +2403,7 @@ static ssize_t via_dsp_read(struct file *file, char __user *buffer, size_t count
rc = via_dsp_do_read (card, buffer, count, nonblock);
out_up:
- up (&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
out:
DPRINTK ("EXIT, returning %ld\n",(long) rc);
return rc;
@@ -2426,7 +2427,7 @@ handle_one_block:
/* Thomas Sailer:
* But also to ourselves, release semaphore if we do so */
if (need_resched()) {
- up(&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
schedule ();
ret = via_syscall_down (card, nonblock);
if (ret)
@@ -2456,7 +2457,7 @@ handle_one_block:
break;
}
- up(&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
DPRINTK ("Sleeping on page %d, tmp==%d, ir==%d\n", n, tmp, chan->is_record);
schedule();
@@ -2585,7 +2586,7 @@ static ssize_t via_dsp_write(struct file *file, const char __user *buffer, size_
rc = via_dsp_do_write (card, buffer, count, nonblock);
out_up:
- up (&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
out:
DPRINTK ("EXIT, returning %ld\n",(long) rc);
return rc;
@@ -2634,7 +2635,7 @@ static unsigned int via_dsp_poll(struct file *file, struct poll_table_struct *wa
* Sleeps until all playback has been flushed to the audio
* hardware.
*
- * Locking: inside card->syscall_sem
+ * Locking: inside card->syscall_mutex
*/
static int via_dsp_drain_playback (struct via_info *card,
@@ -2692,7 +2693,7 @@ static int via_dsp_drain_playback (struct via_info *card,
printk (KERN_ERR "sleeping but not active\n");
#endif
- up(&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
DPRINTK ("sleeping, nbufs=%d\n", atomic_read (&chan->n_frags));
schedule();
@@ -2748,7 +2749,7 @@ out:
*
* Handles SNDCTL_DSP_GETISPACE and SNDCTL_DSP_GETOSPACE.
*
- * Locking: inside card->syscall_sem
+ * Locking: inside card->syscall_mutex
*/
static int via_dsp_ioctl_space (struct via_info *card,
@@ -2793,7 +2794,7 @@ static int via_dsp_ioctl_space (struct via_info *card,
*
* Handles SNDCTL_DSP_GETIPTR and SNDCTL_DSP_GETOPTR.
*
- * Locking: inside card->syscall_sem
+ * Locking: inside card->syscall_mutex
*/
static int via_dsp_ioctl_ptr (struct via_info *card,
@@ -3221,7 +3222,7 @@ static int via_dsp_ioctl (struct inode *inode, struct file *file,
break;
}
- up (&card->syscall_sem);
+ mutex_unlock(&card->syscall_mutex);
DPRINTK ("EXIT, returning %d\n", rc);
return rc;
}
@@ -3264,12 +3265,12 @@ static int via_dsp_open (struct inode *inode, struct file *file)
match:
if (nonblock) {
- if (down_trylock (&card->open_sem)) {
+ if (!mutex_trylock(&card->open_mutex)) {
DPRINTK ("EXIT, returning -EAGAIN\n");
return -EAGAIN;
}
} else {
- if (down_interruptible (&card->open_sem)) {
+ if (mutex_lock_interruptible(&card->open_mutex)) {
DPRINTK ("EXIT, returning -ERESTARTSYS\n");
return -ERESTARTSYS;
}
@@ -3355,8 +3356,8 @@ static int via_dsp_release(struct inode *inode, struct file *file)
via_chan_buffer_free (card, &card->ch_in);
}
- up (&card->syscall_sem);
- up (&card->open_sem);
+ mutex_unlock(&card->syscall_mutex);
+ mutex_unlock(&card->open_mutex);
DPRINTK ("EXIT, returning 0\n");
return 0;
@@ -3414,8 +3415,8 @@ static int __devinit via_init_one (struct pci_dev *pdev, const struct pci_device
card->card_num = via_num_cards++;
spin_lock_init (&card->lock);
spin_lock_init (&card->ac97_lock);
- init_MUTEX (&card->syscall_sem);
- init_MUTEX (&card->open_sem);
+ mutex_init(&card->syscall_mutex);
+ mutex_init(&card->open_mutex);
/* we must init these now, in case the intr handler needs them */
via_chan_init_defaults (card, &card->ch_out);
diff --git a/sound/oss/vwsnd.c b/sound/oss/vwsnd.c
index 265423054ca..b372e88e857 100644
--- a/sound/oss/vwsnd.c
+++ b/sound/oss/vwsnd.c
@@ -94,7 +94,7 @@
* Open will block until the previous client has closed the
* device, unless O_NONBLOCK is specified.
*
- * The semaphore devc->io_sema serializes PCM I/O syscalls. This
+ * The semaphore devc->io_mutex serializes PCM I/O syscalls. This
* is unnecessary in Linux 2.2, because the kernel lock
* serializes read, write, and ioctl globally, but it's there,
* ready for the brave, new post-kernel-lock world.
@@ -105,7 +105,7 @@
* area it owns and update its pointers. See pcm_output() and
* pcm_input() for most of the gory stuff.
*
- * devc->mix_sema serializes all mixer ioctls. This is also
+ * devc->mix_mutex serializes all mixer ioctls. This is also
* redundant because of the kernel lock.
*
* The lowest level lock is lith->lithium_lock. It is a
@@ -148,7 +148,8 @@
#include <linux/smp_lock.h>
#include <linux/wait.h>
#include <linux/interrupt.h>
-#include <asm/semaphore.h>
+#include <linux/mutex.h>
+
#include <asm/mach-visws/cobalt.h>
#include "sound_config.h"
@@ -1447,11 +1448,11 @@ typedef enum vwsnd_port_flags {
*
* port->lock protects: hwstate, flags, swb_[iu]_avail.
*
- * devc->io_sema protects: swstate, sw_*, swb_[iu]_idx.
+ * devc->io_mutex protects: swstate, sw_*, swb_[iu]_idx.
*
* everything else is only written by open/release or
* pcm_{setup,shutdown}(), which are serialized by a
- * combination of devc->open_sema and devc->io_sema.
+ * combination of devc->open_mutex and devc->io_mutex.
*/
typedef struct vwsnd_port {
@@ -1507,9 +1508,9 @@ typedef struct vwsnd_dev {
int audio_minor; /* minor number of audio device */
int mixer_minor; /* minor number of mixer device */
- struct semaphore open_sema;
- struct semaphore io_sema;
- struct semaphore mix_sema;
+ struct mutex open_mutex;
+ struct mutex io_mutex;
+ struct mutex mix_mutex;
mode_t open_mode;
wait_queue_head_t open_wait;
@@ -1633,7 +1634,7 @@ static __inline__ unsigned int swb_inc_i(vwsnd_port_t *port, int inc)
* mode-setting ioctls have been done, but before the first I/O is
* done.
*
- * Locking: called with devc->io_sema held.
+ * Locking: called with devc->io_mutex held.
*
* Returns 0 on success, -errno on failure.
*/
@@ -2319,9 +2320,9 @@ static ssize_t vwsnd_audio_read(struct file *file,
vwsnd_dev_t *devc = file->private_data;
ssize_t ret;
- down(&devc->io_sema);
+ mutex_lock(&devc->io_mutex);
ret = vwsnd_audio_do_read(file, buffer, count, ppos);
- up(&devc->io_sema);
+ mutex_unlock(&devc->io_mutex);
return ret;
}
@@ -2394,9 +2395,9 @@ static ssize_t vwsnd_audio_write(struct file *file,
vwsnd_dev_t *devc = file->private_data;
ssize_t ret;
- down(&devc->io_sema);
+ mutex_lock(&devc->io_mutex);
ret = vwsnd_audio_do_write(file, buffer, count, ppos);
- up(&devc->io_sema);
+ mutex_unlock(&devc->io_mutex);
return ret;
}
@@ -2891,9 +2892,9 @@ static int vwsnd_audio_ioctl(struct inode *inode,
vwsnd_dev_t *devc = (vwsnd_dev_t *) file->private_data;
int ret;
- down(&devc->io_sema);
+ mutex_lock(&devc->io_mutex);
ret = vwsnd_audio_do_ioctl(inode, file, cmd, arg);
- up(&devc->io_sema);
+ mutex_unlock(&devc->io_mutex);
return ret;
}
@@ -2929,9 +2930,9 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
return -ENODEV;
}
- down(&devc->open_sema);
+ mutex_lock(&devc->open_mutex);
while (devc->open_mode & file->f_mode) {
- up(&devc->open_sema);
+ mutex_unlock(&devc->open_mutex);
if (file->f_flags & O_NONBLOCK) {
DEC_USE_COUNT;
return -EBUSY;
@@ -2941,10 +2942,10 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
DEC_USE_COUNT;
return -ERESTARTSYS;
}
- down(&devc->open_sema);
+ mutex_lock(&devc->open_mutex);
}
devc->open_mode |= file->f_mode & (FMODE_READ | FMODE_WRITE);
- up(&devc->open_sema);
+ mutex_unlock(&devc->open_mutex);
/* get default sample format from minor number. */
@@ -2960,7 +2961,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
/* Initialize vwsnd_ports. */
- down(&devc->io_sema);
+ mutex_lock(&devc->io_mutex);
{
if (file->f_mode & FMODE_READ) {
devc->rport.swstate = SW_INITIAL;
@@ -2987,7 +2988,7 @@ static int vwsnd_audio_open(struct inode *inode, struct file *file)
devc->wport.frag_count = 0;
}
}
- up(&devc->io_sema);
+ mutex_unlock(&devc->io_mutex);
file->private_data = devc;
DBGRV();
@@ -3005,7 +3006,7 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
int err = 0;
lock_kernel();
- down(&devc->io_sema);
+ mutex_lock(&devc->io_mutex);
{
DBGEV("(inode=0x%p, file=0x%p)\n", inode, file);
@@ -3022,13 +3023,13 @@ static int vwsnd_audio_release(struct inode *inode, struct file *file)
if (wport)
wport->swstate = SW_OFF;
}
- up(&devc->io_sema);
+ mutex_unlock(&devc->io_mutex);
- down(&devc->open_sema);
+ mutex_lock(&devc->open_mutex);
{
devc->open_mode &= ~file->f_mode;
}
- up(&devc->open_sema);
+ mutex_unlock(&devc->open_mutex);
wake_up(&devc->open_wait);
DEC_USE_COUNT;
DBGR();
@@ -3213,7 +3214,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
DBGEV("(devc=0x%p, cmd=0x%x, arg=0x%lx)\n", devc, cmd, arg);
- down(&devc->mix_sema);
+ mutex_lock(&devc->mix_mutex);
{
if ((cmd & ~nrmask) == MIXER_READ(0))
retval = mixer_read_ioctl(devc, nr, (void __user *) arg);
@@ -3222,7 +3223,7 @@ static int vwsnd_mixer_ioctl(struct inode *ioctl,
else
retval = -EINVAL;
}
- up(&devc->mix_sema);
+ mutex_unlock(&devc->mix_mutex);
return retval;
}
@@ -3376,9 +3377,9 @@ static int __init attach_vwsnd(struct address_info *hw_config)
/* Initialize as much of *devc as possible */
- init_MUTEX(&devc->open_sema);
- init_MUTEX(&devc->io_sema);
- init_MUTEX(&devc->mix_sema);
+ mutex_init(&devc->open_mutex);
+ mutex_init(&devc->io_mutex);
+ mutex_init(&devc->mix_mutex);
devc->open_mode = 0;
spin_lock_init(&devc->rport.lock);
init_waitqueue_head(&devc->rport.queue);
diff --git a/sound/oss/waveartist.c b/sound/oss/waveartist.c
index 99d04ad3ca1..afcb524a40e 100644
--- a/sound/oss/waveartist.c
+++ b/sound/oss/waveartist.c
@@ -2028,8 +2028,8 @@ __setup("waveartist=", setup_waveartist);
#endif
MODULE_DESCRIPTION("Rockwell WaveArtist RWA-010 sound driver");
-MODULE_PARM(io, "i"); /* IO base */
-MODULE_PARM(irq, "i"); /* IRQ */
-MODULE_PARM(dma, "i"); /* DMA */
-MODULE_PARM(dma2, "i"); /* DMA2 */
+module_param(io, int, 0); /* IO base */
+module_param(irq, int, 0); /* IRQ */
+module_param(dma, int, 0); /* DMA */
+module_param(dma2, int, 0); /* DMA2 */
MODULE_LICENSE("GPL");
diff --git a/sound/oss/ymfpci.c b/sound/oss/ymfpci.c
index f8bd72e46f5..bf90c124a7e 100644
--- a/sound/oss/ymfpci.c
+++ b/sound/oss/ymfpci.c
@@ -1918,10 +1918,10 @@ static int ymf_open(struct inode *inode, struct file *file)
if (unit == NULL)
return -ENODEV;
- down(&unit->open_sem);
+ mutex_lock(&unit->open_mutex);
if ((state = ymf_state_alloc(unit)) == NULL) {
- up(&unit->open_sem);
+ mutex_unlock(&unit->open_mutex);
return -ENOMEM;
}
list_add_tail(&state->chain, &unit->states);
@@ -1956,7 +1956,7 @@ static int ymf_open(struct inode *inode, struct file *file)
ymfpci_writeb(unit, YDSXGR_TIMERCTRL,
(YDSXGR_TIMERCTRL_TEN|YDSXGR_TIMERCTRL_TIEN));
#endif
- up(&unit->open_sem);
+ mutex_unlock(&unit->open_mutex);
return nonseekable_open(inode, file);
@@ -1974,7 +1974,7 @@ out_nodma:
list_del(&state->chain);
kfree(state);
- up(&unit->open_sem);
+ mutex_unlock(&unit->open_mutex);
return err;
}
@@ -1987,7 +1987,7 @@ static int ymf_release(struct inode *inode, struct file *file)
ymfpci_writeb(unit, YDSXGR_TIMERCTRL, 0);
#endif
- down(&unit->open_sem);
+ mutex_lock(&unit->open_mutex);
/*
* XXX Solve the case of O_NONBLOCK close - don't deallocate here.
@@ -2004,7 +2004,7 @@ static int ymf_release(struct inode *inode, struct file *file)
file->private_data = NULL; /* Can you tell I programmed Solaris */
kfree(state);
- up(&unit->open_sem);
+ mutex_unlock(&unit->open_mutex);
return 0;
}
@@ -2532,7 +2532,7 @@ static int __devinit ymf_probe_one(struct pci_dev *pcidev, const struct pci_devi
spin_lock_init(&codec->reg_lock);
spin_lock_init(&codec->voice_lock);
spin_lock_init(&codec->ac97_lock);
- init_MUTEX(&codec->open_sem);
+ mutex_init(&codec->open_mutex);
INIT_LIST_HEAD(&codec->states);
codec->pci = pcidev;
diff --git a/sound/oss/ymfpci.h b/sound/oss/ymfpci.h
index f810a100c64..ac1785f2b7e 100644
--- a/sound/oss/ymfpci.h
+++ b/sound/oss/ymfpci.h
@@ -22,6 +22,7 @@
*
*/
#include <linux/config.h>
+#include <linux/mutex.h>
/*
* Direct registers
@@ -279,7 +280,7 @@ struct ymf_unit {
/* soundcore stuff */
int dev_audio;
- struct semaphore open_sem;
+ struct mutex open_mutex;
struct list_head ymf_devs;
struct list_head states; /* List of states for this unit */
diff --git a/sound/ppc/daca.c b/sound/ppc/daca.c
index 08cde51177d..aa09ebd9ffb 100644
--- a/sound/ppc/daca.c
+++ b/sound/ppc/daca.c
@@ -22,7 +22,6 @@
#include <sound/driver.h>
#include <linux/init.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <sound/core.h>
diff --git a/sound/ppc/keywest.c b/sound/ppc/keywest.c
index 6058c2dd1b7..fb05938dcbd 100644
--- a/sound/ppc/keywest.c
+++ b/sound/ppc/keywest.c
@@ -23,7 +23,6 @@
#include <linux/init.h>
#include <linux/i2c.h>
#include <linux/delay.h>
-#include <linux/i2c-dev.h>
#include <linux/slab.h>
#include <sound/core.h>
#include "pmac.h"
diff --git a/sound/ppc/toonie.c b/sound/ppc/toonie.c
index 053b8f24e4d..4e595172e42 100644
--- a/sound/ppc/toonie.c
+++ b/sound/ppc/toonie.c
@@ -22,7 +22,6 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
@@ -118,7 +117,7 @@ static int toonie_get_mute_switch(struct snd_kcontrol *kcontrol,
gp = &mix->amp_mute_gpio;
break;
default:
- return -EINVAL;;
+ return -EINVAL;
}
ucontrol->value.integer.value[0] = !check_audio_gpio(gp);
return 0;
@@ -146,7 +145,7 @@ static int toonie_put_mute_switch(struct snd_kcontrol *kcontrol,
gp = &mix->amp_mute_gpio;
break;
default:
- return -EINVAL;;
+ return -EINVAL;
}
val = ! check_audio_gpio(gp);
if (val != ucontrol->value.integer.value[0]) {
diff --git a/sound/ppc/tumbler.c b/sound/ppc/tumbler.c
index 838fc113c44..1146dd882bb 100644
--- a/sound/ppc/tumbler.c
+++ b/sound/ppc/tumbler.c
@@ -28,7 +28,6 @@
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/i2c.h>
-#include <linux/i2c-dev.h>
#include <linux/kmod.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
diff --git a/sound/sparc/cs4231.c b/sound/sparc/cs4231.c
index 53a148b01b6..8804f26ddb3 100644
--- a/sound/sparc/cs4231.c
+++ b/sound/sparc/cs4231.c
@@ -611,8 +611,7 @@ static void snd_cs4231_advance_dma(struct cs4231_dma_control *dma_cont,
unsigned int period_size = snd_pcm_lib_period_bytes(substream);
unsigned int offset = period_size * (*periods_sent);
- if (period_size >= (1 << 24))
- BUG();
+ BUG_ON(period_size >= (1 << 24));
if (dma_cont->request(dma_cont, runtime->dma_addr + offset, period_size))
return;
@@ -1079,8 +1078,7 @@ static int snd_cs4231_playback_prepare(struct snd_pcm_substream *substream)
chip->image[CS4231_IFACE_CTRL] &= ~(CS4231_PLAYBACK_ENABLE |
CS4231_PLAYBACK_PIO);
- if (runtime->period_size > 0xffff + 1)
- BUG();
+ BUG_ON(runtime->period_size > 0xffff + 1);
chip->p_periods_sent = 0;
spin_unlock_irqrestore(&chip->lock, flags);